aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2001-05-24 15:53:34 +0000
committerBruce Momjian <bruce@momjian.us>2001-05-24 15:53:34 +0000
commitf36fc7bb63addb9254e6d0db77e511841eba8de8 (patch)
tree6eb786ca46c5e2dc585bdf66e10e751f7b784f8a
parent6f101c806b11af05ab9d775efa2012d497375ba0 (diff)
downloadpostgresql-f36fc7bb63addb9254e6d0db77e511841eba8de8.tar.gz
postgresql-f36fc7bb63addb9254e6d0db77e511841eba8de8.zip
I haven't tried building postgres with the Watcom compiler for 7.1 because
it does not support 64bit integers. AFAIK that's the default data type for OIDs, so I am not surprised that this does not work. Use gcc instead. BTW., 7.1 does not compile as is with gcc either, I believed the required patches made it into the 7.1.1 release but obviously I missed the deadline. Since the ports mailing list does not seem to be archived I have attached a copy of the patch (for 7.1 and 7.1.1). I've just performed a build of a Watcom compiled version and found a couple of bugs in the watcom specific part of that patch. Please use the attached version instead. Tegge, Bernd
-rw-r--r--doc/FAQ_QNX486
-rw-r--r--src/backend/Makefile5
-rw-r--r--src/backend/port/qnx4/sem.c41
-rw-r--r--src/backend/port/qnx4/shm.c61
-rw-r--r--src/backend/port/qnx4/tstsem.c6
-rw-r--r--src/bin/ipcclean/ipcclean.sh14
-rw-r--r--src/include/port/qnx4.h10
-rw-r--r--src/include/storage/s_lock.h26
-rw-r--r--src/makefiles/Makefile.qnx44
-rw-r--r--src/pl/plpgsql/Makefile11
10 files changed, 191 insertions, 73 deletions
diff --git a/doc/FAQ_QNX4 b/doc/FAQ_QNX4
index 5880feab8cd..53209a8c8f8 100644
--- a/doc/FAQ_QNX4
+++ b/doc/FAQ_QNX4
@@ -1,5 +1,9 @@
PostgresSQL on QNX 4
--------------------
+last updated: $Date: 2001/05/24 15:53:31 $
+
+current maintainer: Bernd Tegge (tegge@repas-aeg.de)
+original author: Andreas Kardos (kardos@repas-aeg.de)
This port is an important step because PostgreSQL is now the only free
relational database with full SQL and ODBC support available for QNX 4.
@@ -7,47 +11,66 @@ The only commercial databases available are Empress RDBMS and Velocis
Database Server (not supported for Digital Unix).
The most effort required the emulation of System V semaphore sets,
-shared memory and IPC and of some IEEE floating-point functionality. For
-the Watcom compiler spinlocks have been implemented using POSIX semaphores.
+shared memory and IPC and of some IEEE floating-point functionality.
-It is recomended to use the GNU C compiler instead of the Watcom compiler
+It is recommended to use the GNU C compiler instead of the Watcom compiler
because the Watcom compiler doesn't support a int8 datatype (long or
-long long int) and it does not have a C++ frontend.
-It could be managed to build postgres using the Watcom compiler but it crashes
-quite early. These problems probably could be solved. The only advantage would
-be support of Tk and pgaccess. For the Watcom compiler some more modifications
-have to be made which are not described here.
+long long int) and it does not have a C++ frontend. The only advantage
+using Watcom C would be support of Tk and pgaccess.
QNX 4 does not offer native support of shared libraries. Therefore the related
functionality cannot be used. Shared library support could probably be
implemented in future.
-QNX 4 does not support UNIX domain sockets. Connections can only be made
-with TCP/IP sockets. Therefore postmaster must always be started with the
--i option. Furthermore it would be useful to set the PGHOST variable.
+QNX 4 does not support UNIX domain sockets. Clients must use TCP/IP sockets.
+Therefore postmaster must always be started with the -i option. Furthermore
+it would be useful to set the PGHOST variable.
Prerequisites:
--------------
The following prerequisites have been used:
-QNX 4.25
-Watcom C 10.6
-GNU make
+QNX standard:
+QNX 4.25, Watcom C 10.6, GNU make
+
+Available from http://www.teaser.fr/~jcmichot/
flex-2.5.4a.tar.gz (flex)
-egcs111-qnx4-r20.tar[.gz] (GNU C)
+egcs-112-qnx4-r20.tar[.gz] (GNU C)
+
+Available from ftp://ftp.visi.com/users/hawkeyd/qnx/
+bison-1.2.5.tar.gz
+
+Available from http://quics.qnx.com/cgi-bin/dir_find.cgi?/usr/free/
perl 5.004_04
+
+from ftp://ftp.freesoftware.com/pub/infozip/zlib/
+zlib 1.1.3
+
tcl8.0.3.tar.Z (Tcl)
+In order to achieve meaningful results for the regression tests, you need
+a different shell. The standard QNX shell is quite broken with regard to
+scripting (even QSSL suggested to use pdksh or bash). Both are available
+in source and binaries at
+http://quics.qnx.com/cgi-bin/dir_find.cgi?/usr/free/
+
flex can be built without any problems using the Watcom or GNU C compilers.
+The current version of bison (1.2.8 at the time of this writing) does not
+build cleanly on QNX4 with gcc installed, but you can download src and
+binary of a previous version from the above mentioned ftp site.
+
+download source
GNU C can be installed by
-/etc/install -u egcs111-qnx4-r20.tar[.gz]
+/etc/install -u egcs112-qnx4-r20.tar[.gz]
Although Tcl can be built after some slight code changes using the Watcom
compiler, the GNU C compiler should be used instead. Otherwise it would be
impossible to link postgres built with GNU C together with libtcl8.0.a built
-with the Watcom compiler.
+with the Watcom compiler. However, if you are going to build a Watcom version
+you must build the tcl and tk libraries with Watcom too.
+
To make unix/tclUnixTest.c compilable uncomment
#include <sys/resource.h>
in it or
@@ -79,17 +102,14 @@ ln -s /usr/src/pgsql/src/backend/port/qnx4/sem.h /usr/include/sys/sem.h
ln -s /usr/src/pgsql/src/backend/port/qnx4/shm.h /usr/include/sys/shm.h
For ecgs-2.91.60 the file
-/usr/local/lib/gcc-lib/i386-pc-qnx4/egcs-2.91.60/include/g++/stl_alloc.h
+/usr/local/lib/gcc-lib/i386-pc-qnx4/egcs-2.91.66/include/g++/stl_alloc.h
had to be patched (extern "C++" { ... } // extern "C++").
See attached patch.
-If you use another ecpg version the include/g++ path in Makefile.qnx4
-(CXXFLAGS) has to be adopted.
-
If all prerequisites are available postgres can be built and installed by
cd pgsql/src
-./configure --with-tcl --with-perl --with-x
-gmake all > make.log 2>&1
+./configure --with-tcl --without-tk --with-perl
+gmake > make.log 2>&1
gmake install > make.install.log 2>&1
su
cd interfaces/perl5
@@ -113,11 +133,15 @@ Currently yacc fails on backend/parser/gram.y and
interfaces/ecpg/preproc/preproc.y due to exceeded maximum table size. You can
generate the gram.h, parse.h, preproc.h and preproc.c files on another platform
and use them. This is only a problem when you use the current source tree since
-parse.h, gram.c, preproc.h and preporc.c are included in official
-distributions.
+parse.h, gram.c, preproc.h and preproc.c are included in official
+distributions. In order to avoid this, install the bison binary mentioned
+above.
Regression tests:
-----------------
+please don't use the QNX shell for the parallel regression tests. Download
+bash from quics.qnx.com and run 'make SHELL=/usr/local/bin/bash check'
+instead.
The majority of regression tests succeeded. The following tests failed:
@@ -136,7 +160,8 @@ if a value of type money is inserted in string representation e.g. as in
"insert into rtest_emp values ('wiech', '5000.00');"
Subject of further investigation.
-create_function_2, triggers, misc, plpgsql:
+create_function_1, create_function_2, create_type, create_operator,
+create_view, select_views, triggers, misc, plpgsql:
Error messages due to the lack of shared library support.
numeric, numeric_big, sanity_check:
@@ -147,14 +172,19 @@ Subject of further investigation. Probably because of the missing indices
these numeric tests take a long time.
The diffence in sanity_check.out is a consequence of this problem only.
-The reached state of this port should be sufficient for lot of applications.
+The current state of this port should be sufficient for lot of applications.
+
+The Watcom version failed additional tests because of the lack of int8
+support.
Have fun!
Andreas Kardos
-kardos@repas-aeg.de
2000-04-04
+Bernd Tegge
+tegge@repas-aeg.de
+2001-03-01
---------------------------------------------------------------------------
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 30ea30f8d75..4db21fe665c 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.71 2001/04/23 20:27:55 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.72 2001/05/24 15:53:32 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -25,7 +25,8 @@ OBJS := $(DIRS:%=%/SUBSYS.o)
ifeq ($(PORTNAME), qnx4)
# This file crashes qnx4's wlink and is therefore not in
# bootstrap/SUBSYS.o on that platform. (Wotta hack ... is it still
-# necessary?)
+# necessary?) [ Yes, until the Watcom compiler goes open source it's
+# effectively unsupported ]
OBJS+= bootstrap/bootstrap.o
endif
diff --git a/src/backend/port/qnx4/sem.c b/src/backend/port/qnx4/sem.c
index f339e16973a..188a5f0616f 100644
--- a/src/backend/port/qnx4/sem.c
+++ b/src/backend/port/qnx4/sem.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.4 2001/02/02 18:21:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.5 2001/05/24 15:53:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,14 +23,16 @@
#include "storage/ipc.h"
#include "storage/proc.h"
#include <sys/sem.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
-#define SETMAX ((MAXBACKENDS + PROC_NSEMS_PER_SET - 1) / PROC_NSEMS_PER_SET)
+#define SETMAX ((MAXBACKENDS + PROC_NSEMS_PER_SET + 1) / PROC_NSEMS_PER_SET)
#define SEMMAX (PROC_NSEMS_PER_SET+1)
#define OPMAX 8
#define MODE 0700
-#define SHM_INFO_NAME "SysV_Sem_Info"
+#define SHM_INFO_NAME "PgSysV_Sem_Info"
struct pending_ops
@@ -56,6 +58,17 @@ struct sem_info
static struct sem_info *SemInfo = (struct sem_info *) - 1;
+/* ----------------------------------------------------------------
+ * semclean - remove the shared memory file on exit
+ * only called by the process which created the shm file
+ * ----------------------------------------------------------------
+ */
+
+static void
+semclean( void )
+{
+ remove( "/dev/shmem/" SHM_INFO_NAME );
+}
int
semctl(int semid, int semnum, int cmd, /* ... */ union semun arg)
@@ -132,6 +145,7 @@ semget(key_t key, int nsems, int semflg)
semid,
semnum /* , semnum1 */ ;
int exist = 0;
+ struct stat statbuf;
if (nsems < 0 || nsems > SEMMAX)
{
@@ -153,6 +167,26 @@ semget(key_t key, int nsems, int semflg)
return fd;
/* The size may only be set once. Ignore errors. */
ltrunc(fd, sizeof(struct sem_info), SEEK_SET);
+ if ( fstat( fd, &statbuf ) ) /* would be strange : the only doc'ed */
+ { /* error is EBADF */
+ close( fd );
+ return -1;
+ }
+ /*
+ * size is rounded by proc to the next __PAGESIZE
+ */
+ if ( statbuf.st_size !=
+ ((( sizeof(struct sem_info) /__PAGESIZE)+1) * __PAGESIZE) )
+ {
+ fprintf( stderr,
+ "Found a pre-existing shared memory block for the semaphore memory\n"
+ "of a different size (%ld instead %ld). Make sure that all executables\n"
+ "are from the same release or remove the file \"/dev/shmem/%s\"\n"
+ "left by a previous version.\n", statbuf.st_size,
+ sizeof(struct sem_info), SHM_INFO_NAME);
+ errno = EACCES;
+ return -1;
+ }
SemInfo = mmap(NULL, sizeof(struct sem_info),
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (SemInfo == MAP_FAILED)
@@ -167,6 +201,7 @@ semget(key_t key, int nsems, int semflg)
for (semid = 0; semid < SETMAX; semid++)
SemInfo->set[semid].key = -1;
sem_post(&SemInfo->sem);
+ on_proc_exit( semclean, NULL );
}
}
diff --git a/src/backend/port/qnx4/shm.c b/src/backend/port/qnx4/shm.c
index 14c77f4fc9c..b96203f1c2d 100644
--- a/src/backend/port/qnx4/shm.c
+++ b/src/backend/port/qnx4/shm.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.4 2001/03/22 03:59:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.5 2001/05/24 15:53:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,9 +15,11 @@
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/shm.h>
+#include <sys/stat.h>
#define MODE 0777
@@ -41,6 +43,12 @@ static int shm_updinfo(int i, struct shm_info * info);
static int shm_getinfo(int shmid, struct shm_info * info);
static int shm_getinfobyaddr(const void *addr, struct shm_info * info);
+static char *
+keytoname(key_t key, char *name)
+{
+ sprintf( name,"PgShm%x", key );
+ return name;
+}
static int
shm_putinfo(struct shm_info * info)
@@ -172,25 +180,51 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf)
{
struct shm_info info;
char name[NAME_MAX + 1];
+ int result;
+ int fd;
+ struct stat statbuf;
- if (cmd == IPC_RMID)
+
+ switch( cmd )
{
+ case IPC_RMID :
if (shm_getinfo(shmid, &info) == -1)
{
errno = EACCES;
return -1;
}
- return shm_unlink(itoa(info.key, name, 16));
+ close( info.shmid );
+ keytoname(info.key, name);
+ return shm_unlink( name );
+
+ case IPC_STAT :
+ /*
+ * we have to open it first. stat() does no prefix tracking
+ * -> the call would go to fsys instead of proc
+ */
+ keytoname(shmid, name);
+ fd = shm_open( name, 0, MODE );
+ if ( fd >= 0 )
+ {
+ result = fstat( fd, &statbuf );
+ /*
+ * if the file exists, subtract 2 from linkcount :
+ * one for our own open and one for the dir entry
+ */
+ if ( ! result )
+ buf->shm_nattch = statbuf.st_nlink-2;
+ close( fd );
+ return result;
}
- if (cmd == IPC_STAT)
+ else
{
-
/*
- * Can we support IPC_STAT? We only need shm_nattch ... For now,
- * punt and assume the shm seg does not exist.
+ * if there's no entry for this key it doesn't matter
+ * the next shmget() would get a different shm anyway
*/
- errno = EINVAL;
- return -1;
+ buf->shm_nattch = 0;
+ return 0;
+ }
}
errno = EINVAL;
return -1;
@@ -214,7 +248,7 @@ shmget(key_t key, size_t size, int flags)
else
oflag |= O_RDONLY;
}
- info.shmid = shm_open(itoa(key, name, 16), oflag, MODE);
+ info.shmid = shm_open(keytoname(key, name), oflag, MODE);
/* store shared memory information */
if (info.shmid != -1)
@@ -222,8 +256,13 @@ shmget(key_t key, size_t size, int flags)
info.key = key;
info.size = size;
info.addr = NULL;
- if (shm_putinfo(&info) == -1)
+ if (shm_putinfo(&info) == -1) {
+ close( info.shmid );
+ if ( (oflag & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) ) {
+ shm_unlink( name );
+ }
return -1;
+ }
}
/* The size may only be set once. Ignore errors. */
diff --git a/src/backend/port/qnx4/tstsem.c b/src/backend/port/qnx4/tstsem.c
index dc697ceaed5..c58a724f9d0 100644
--- a/src/backend/port/qnx4/tstsem.c
+++ b/src/backend/port/qnx4/tstsem.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.3 2000/04/12 17:15:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.4 2001/05/24 15:53:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,6 +40,10 @@ sig_handler(int sig_no)
printf("semval = %d\n", i);
}
+void on_proc_exit( void (*function)(), Datum arg )
+{
+ atexit( function );
+}
int
main(int argc, char **argv)
{
diff --git a/src/bin/ipcclean/ipcclean.sh b/src/bin/ipcclean/ipcclean.sh
index db3f003b0cd..881391e641e 100644
--- a/src/bin/ipcclean/ipcclean.sh
+++ b/src/bin/ipcclean/ipcclean.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.10 2001/02/10 10:27:28 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.11 2001/05/24 15:53:33 momjian Exp $
#
CMDNAME=`basename $0`
@@ -33,7 +33,17 @@ EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
# List of platform-specific hacks
# Feel free to add yours here.
#-----------------------------------
-
+#
+# This is QNX 4.25
+#
+if [ `uname` = 'QNX' ]; then
+ if ps -eA | grep -s '[p]ostmaster' >/dev/null 2>&1 ; then
+ echo "$CMDNAME: You still have a postmaster running." 1>&2
+ exit 1
+ fi
+ rm -f /dev/shmem/PgS*
+ exit $?
+fi
#
# This is based on RedHat 5.2.
#
diff --git a/src/include/port/qnx4.h b/src/include/port/qnx4.h
index b1069932b74..d1a4bc9af99 100644
--- a/src/include/port/qnx4.h
+++ b/src/include/port/qnx4.h
@@ -4,12 +4,8 @@
#include <ioctl.h> /* for unix.h */
#include <unix.h>
#include <sys/select.h> /* for select */
-#if !defined(__GNUC__)
-#include <semaphore.h> /* for sem_t */
-#endif
#define HAS_TEST_AND_SET
-#define HAVE_STRING_H
#undef HAVE_GETRUSAGE
@@ -26,14 +22,8 @@ extern unsigned char __nan[8];
typedef u_short ushort;
-#if defined(__GNUC__)
typedef unsigned char slock_t;
-#else
-typedef sem_t slock_t;
-
-#endif
-
extern int isnan(double dsrc);
extern double rint(double x);
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index e8f900a4ef4..86fc8e2c869 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.92 2001/04/13 23:32:57 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.93 2001/05/24 15:53:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -106,7 +106,7 @@
*/
-#if defined(__i386__) && !defined(__QNX__)
+#if defined(__i386__)
#define TAS(lock) tas(lock)
static __inline__ int
@@ -396,18 +396,19 @@ tas(volatile slock_t *lock)
#endif /* __hpux */
-
-#if defined(__QNX__)
+#if defined(__QNX__) && defined(__WATCOMC__)
/*
- * QNX 4
- *
- * Note that slock_t under QNX is sem_t instead of char
+ * QNX 4 using WATCOM C
*/
-#define TAS(lock) (sem_trywait((lock)) < 0)
-#define S_UNLOCK(lock) sem_post((lock))
-#define S_INIT_LOCK(lock) sem_init((lock), 1, 1)
-#define S_LOCK_FREE(lock) ((lock)->value)
-#endif /* __QNX__ */
+#define TAS(lock) wc_tas(lock)
+extern slock_t wc_tas(volatile slock_t *lock);
+#pragma aux wc_tas =\
+ " mov al,1 " \
+ " lock xchg al,[esi]" \
+ parm [esi] \
+ value [al];
+
+#endif /* __QNX__ and __WATCOMC__*/
#if defined(__sgi)
@@ -544,7 +545,6 @@ extern int tas(volatile slock_t *lock); /* in port/.../tas.s, or
/****************************************************************************
* Platform-independent out-of-line support routines
*/
-
extern void s_lock(volatile slock_t *lock,
const char *file, const int line);
extern void s_lock_sleep(unsigned spins, int timeout, int microsec,
diff --git a/src/makefiles/Makefile.qnx4 b/src/makefiles/Makefile.qnx4
index a7d902ad245..2fb9d7bd193 100644
--- a/src/makefiles/Makefile.qnx4
+++ b/src/makefiles/Makefile.qnx4
@@ -13,5 +13,5 @@ CFLAGS_SL =
%$(DLSUFFIX): %.o
@echo 'cannot make shared object $@ from $<'
-# Hack alert! Fix your compiler installation...
-override CXXFLAGS +=-I/usr/local/lib/gcc-lib/i386-pc-qnx4/egcs-2.91.60/include/g++
+override CXXFLAGS +=-I/usr/local/include/g++
+override CFLAGS +=-I/usr/local/include
diff --git a/src/pl/plpgsql/Makefile b/src/pl/plpgsql/Makefile
index 2a6598676bb..860416dcdc6 100644
--- a/src/pl/plpgsql/Makefile
+++ b/src/pl/plpgsql/Makefile
@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/pl/plpgsql/Makefile,v 1.5 2000/08/31 16:12:15 petere Exp $
+# $Header: /cvsroot/pgsql/src/pl/plpgsql/Makefile,v 1.6 2001/05/24 15:53:34 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -12,8 +12,17 @@ subdir = src/pl/plpgsql
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
+ifneq ($(PORTNAME), qnx4)
+
all install installdirs uninstall distprep:
$(MAKE) -C src $@
+else #qnx4
+
+all install installdirs uninstall distprep:
+ echo plpgsql not supported with QNX due to lack of shared library support
+
+endif # qnx4
+
clean distclean maintainer-clean:
-$(MAKE) -C src $@