1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Remove QNX port.

This commit is contained in:
Bruce Momjian
2006-01-05 01:56:30 +00:00
parent 349f40b2c2
commit a1675649e4
31 changed files with 25 additions and 2014 deletions

View File

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.113 2005/12/09 21:19:34 petere Exp $
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.114 2006/01/05 01:56:29 momjian Exp $
#
#-------------------------------------------------------------------------
@ -27,14 +27,6 @@ LIBS := $(filter-out -lpgport, $(LIBS))
# The backend doesn't need everything that's in LIBS, however
LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
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?) [ Yes, until the Watcom compiler goes open source it's
# effectively unsupported ]
OBJS += bootstrap/bootstrap.o
endif
##########################################################################
all: submake-libpgport postgres $(POSTGRES_IMP)

View File

@ -2,7 +2,7 @@
#
# Makefile for the bootstrap module
#
# $PostgreSQL: pgsql/src/backend/bootstrap/Makefile,v 1.32 2003/11/29 19:51:40 pgsql Exp $
# $PostgreSQL: pgsql/src/backend/bootstrap/Makefile,v 1.33 2006/01/05 01:56:29 momjian Exp $
#
#-------------------------------------------------------------------------
@ -12,16 +12,9 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
# qnx4's wlink currently crashes with bootstrap.o
ifneq ($(PORTNAME), qnx4)
OBJS= bootparse.o bootstrap.o
else
OBJS= bootparse.o
endif
# make sure bootstrap.o is built even on qnx4
all: SUBSYS.o bootstrap.o
all: SUBSYS.o
SUBSYS.o: $(OBJS)
$(LD) $(LDREL) $(LDOUT) $@ $^

View File

@ -13,7 +13,7 @@
# be converted to Method 2.
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/port/Makefile,v 1.20 2003/11/29 19:51:54 pgsql Exp $
# $PostgreSQL: pgsql/src/backend/port/Makefile,v 1.21 2006/01/05 01:56:29 momjian Exp $
#
#-------------------------------------------------------------------------
@ -25,9 +25,6 @@ OBJS+=dynloader.o pg_sema.o pg_shmem.o
OBJS+=$(TAS)
ifeq ($(PORTNAME), qnx4)
OBJS+=qnx4/SUBSYS.o
endif
ifeq ($(PORTNAME), beos)
OBJS+=beos/SUBSYS.o
endif
@ -43,11 +40,6 @@ all: SUBSYS.o
SUBSYS.o: $(OBJS)
$(LD) $(LDREL) $(LDOUT) $@ $^
qnx4/SUBSYS.o: qnx4.dir
qnx4.dir:
$(MAKE) -C qnx4 all
beos/SUBSYS.o: beos.dir
beos.dir:
@ -74,6 +66,5 @@ distclean clean:
rm -f SUBSYS.o $(OBJS) ipc_test ipc_test.o
$(MAKE) -C beos clean
$(MAKE) -C darwin clean
$(MAKE) -C qnx4 clean
$(MAKE) -C win32 clean

View File

@ -1,51 +0,0 @@
/*-------------------------------------------------------------------------
*
* dynloader.c
* dynamic loader for QNX4 using the shared library mechanism
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/dynloader/qnx4.c,v 1.6 2004/01/07 18:56:27 neilc Exp $
*
* NOTES
*
*-------------------------------------------------------------------------
*/
/* System includes */
#include "postgres.h"
/*
#include <a.out.h>
#include <dl.h>
*/
#include "utils/dynamic_loader.h"
#include "dynloader.h"
void *
pg_dlopen(char *filename)
{
return NULL;
}
PGFunction
pg_dlsym(void *handle, char *funcname)
{
return NULL;
}
void
pg_dlclose(void *handle)
{
}
char *
pg_dlerror()
{
static char errmsg[] = "Failed to load shared library due to lack of shared library support.";
return errmsg;
}

View File

@ -1,22 +0,0 @@
/*-------------------------------------------------------------------------
*
* dynloader.h
* dynamic loader for QNX4 using the shared library mechanism
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/dynloader/qnx4.h,v 1.4 2003/11/29 19:51:54 pgsql Exp $
*
* NOTES
*
*-------------------------------------------------------------------------
*/
#include "fmgr.h"
void *pg_dlopen(char *filename);
PGFunction pg_dlsym(void *handle, char *funcname);
void pg_dlclose(void *handle);
char *pg_dlerror();

View File

@ -1,36 +0,0 @@
#-------------------------------------------------------------------------
#
# Makefile--
# Makefile for port/qnx4
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/port/qnx4/Makefile,v 1.6 2003/11/29 19:51:54 pgsql Exp $
#
#-------------------------------------------------------------------------
subdir = src/backend/port/qnx4
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
OBJS = isnan.o sem.o shm.o
all: SUBSYS.o tstsem tstshm
SUBSYS.o: $(OBJS)
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
tstsem: tstsem.o sem.o
$(CC) -o tstsem sem.o tstsem.o
tstshm: tstshm.o shm.o
$(CC) -o tstshm shm.o tstshm.o
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f SUBSYS.o $(OBJS) tstsem tstsem.o tstshm tstshm.o
ifeq (depend,$(wildcard depend))
include depend
endif

View File

@ -1,31 +0,0 @@
/*-------------------------------------------------------------------------
*
* ipc.h
* System V IPC Emulation
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/ipc.h,v 1.7 2003/11/29 19:51:54 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef _SYS_IPC_H
#define _SYS_IPC_H
/* Common IPC definitions. */
/* Mode bits. */
#define IPC_CREAT 0001000 /* create entry if key doesn't exist */
#define IPC_EXCL 0002000 /* fail if key exists */
#define IPC_NOWAIT 0004000 /* error if request must wait */
/* Keys. */
#define IPC_PRIVATE (key_t)0 /* private key */
/* Control Commands. */
#define IPC_RMID 0 /* remove identifier */
#define IPC_STAT 1 /* get shm status */
#endif /* _SYS_IPC_H */

View File

@ -1,29 +0,0 @@
/*-------------------------------------------------------------------------
*
* isnan.c
* isnan() implementation
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/isnan.c,v 1.5 2004/03/15 03:29:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "c.h"
#include <math.h>
#ifndef __nan_bytes
#define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
#endif /* __nan_bytes */
static unsigned char __nan[8] = __nan_bytes;
int
isnan(double dsrc)
{
return memcmp(&dsrc, __nan, sizeof(double)) == 0;
}

View File

@ -1,396 +0,0 @@
/*-------------------------------------------------------------------------
*
* sem.c
* System V Semaphore Emulation
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/sem.c,v 1.13 2005/10/15 02:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <errno.h>
#include <semaphore.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/sem.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include "miscadmin.h"
#include "storage/ipc.h"
#include "storage/proc.h"
#define SEMMAX (PROC_NSEMS_PER_SET+1)
#define OPMAX 8
#define MODE 0700
#define SHM_INFO_NAME "PgSysV_Sem_Info"
struct pending_ops
{
int op[OPMAX]; /* array of pending operations */
int idx; /* index of first free array member */
};
struct sem_set_info
{
key_t key;
int nsems;
sem_t sem[SEMMAX]; /* array of POSIX semaphores */
struct sem semV[SEMMAX]; /* array of System V semaphore structures */
struct pending_ops pendingOps[SEMMAX]; /* array of pending operations */
};
struct sem_info
{
sem_t sem;
int nsets;
/* there are actually nsets of these: */
struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */
};
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)
{
int r = 0;
sem_wait(&SemInfo->sem);
if (semid < 0 || semid >= SemInfo->nsets ||
semnum < 0 || semnum >= SemInfo->set[semid].nsems)
{
sem_post(&SemInfo->sem);
errno = EINVAL;
return -1;
}
switch (cmd)
{
case GETNCNT:
r = SemInfo->set[semid].semV[semnum].semncnt;
break;
case GETPID:
r = SemInfo->set[semid].semV[semnum].sempid;
break;
case GETVAL:
r = SemInfo->set[semid].semV[semnum].semval;
break;
case GETALL:
for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
arg.array[semnum] = SemInfo->set[semid].semV[semnum].semval;
break;
case SETVAL:
SemInfo->set[semid].semV[semnum].semval = arg.val;
break;
case SETALL:
for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
SemInfo->set[semid].semV[semnum].semval = arg.array[semnum];
break;
case GETZCNT:
r = SemInfo->set[semid].semV[semnum].semzcnt;
break;
case IPC_RMID:
for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
{
if (sem_destroy(&SemInfo->set[semid].sem[semnum]) == -1)
r = -1;
}
SemInfo->set[semid].key = -1;
SemInfo->set[semid].nsems = 0;
break;
default:
sem_post(&SemInfo->sem);
errno = EINVAL;
return -1;
}
sem_post(&SemInfo->sem);
return r;
}
int
semget(key_t key, int nsems, int semflg)
{
int fd,
semid,
semnum,
nsets;
int exist = 0;
Size sem_info_size;
struct stat statbuf;
if (nsems < 0 || nsems > SEMMAX)
{
errno = EINVAL;
return -1;
}
/* open and map shared memory */
if (SemInfo == (struct sem_info *) - 1)
{
/* test if the shared memory already exists */
fd = shm_open(SHM_INFO_NAME, O_RDWR | O_CREAT | O_EXCL, MODE);
if (fd == -1 && errno == EEXIST)
{
exist = 1;
fd = shm_open(SHM_INFO_NAME, O_RDWR | O_CREAT, MODE);
}
if (fd == -1)
return fd;
/* The size may only be set once. Ignore errors. */
nsets = PROC_SEM_MAP_ENTRIES(MaxBackends);
sem_info_size = sizeof(struct sem_info) + (nsets - 1) * sizeof(struct sem_set_info);
ltrunc(fd, sem_info_size, 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 !=
(((sem_info_size / __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",
(long) statbuf.st_size,
(long) sem_info_size,
SHM_INFO_NAME);
errno = EACCES;
return -1;
}
SemInfo = mmap(NULL, sem_info_size,
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (SemInfo == MAP_FAILED)
return -1;
if (!exist)
{
/* initialize shared memory */
memset(SemInfo, 0, sem_info_size);
SemInfo->nsets = nsets;
for (semid = 0; semid < nsets; semid++)
SemInfo->set[semid].key = -1;
/* create semaphore for locking */
sem_init(&SemInfo->sem, 1, 1);
on_proc_exit(semclean, 0);
}
}
sem_wait(&SemInfo->sem);
nsets = SemInfo->nsets;
if (key != IPC_PRIVATE)
{
/* search existing element */
semid = 0;
while (semid < nsets && SemInfo->set[semid].key != key)
semid++;
if (!(semflg & IPC_CREAT) && semid >= nsets)
{
sem_post(&SemInfo->sem);
errno = ENOENT;
return -1;
}
else if (semid < nsets)
{
if (semflg & IPC_CREAT && semflg & IPC_EXCL)
{
sem_post(&SemInfo->sem);
errno = EEXIST;
return -1;
}
else
{
if (nsems != 0 && SemInfo->set[semid].nsems < nsems)
{
sem_post(&SemInfo->sem);
errno = EINVAL;
return -1;
}
sem_post(&SemInfo->sem);
return semid;
}
}
}
/* search first free element */
semid = 0;
while (semid < nsets && SemInfo->set[semid].key != -1)
semid++;
if (semid >= nsets)
{
sem_post(&SemInfo->sem);
errno = ENOSPC;
return -1;
}
for (semnum = 0; semnum < nsems; semnum++)
{
sem_init(&SemInfo->set[semid].sem[semnum], 1, 0);
/* Currently sem_init always returns -1. */
#ifdef NOT_USED
if (sem_init(&SemInfo->set[semid].sem[semnum], 1, 0) == -1)
{
int semnum1;
for (semnum1 = 0; semnum1 < semnum; semnum1++)
sem_destroy(&SemInfo->set[semid].sem[semnum1]);
sem_post(&SemInfo->sem);
return -1;
}
#endif
}
SemInfo->set[semid].key = key;
SemInfo->set[semid].nsems = nsems;
sem_post(&SemInfo->sem);
return semid;
}
int
semop(int semid, struct sembuf * sops, size_t nsops)
{
int i,
r = 0,
r1,
errno1 = 0,
op;
sem_wait(&SemInfo->sem);
if (semid < 0 || semid >= SemInfo->nsets)
{
sem_post(&SemInfo->sem);
errno = EINVAL;
return -1;
}
for (i = 0; i < nsops; i++)
{
if ( /* sops[i].sem_num < 0 || */ sops[i].sem_num >= SemInfo->set[semid].nsems)
{
sem_post(&SemInfo->sem);
errno = EFBIG;
return -1;
}
}
for (i = 0; i < nsops; i++)
{
if (sops[i].sem_op < 0)
{
if (SemInfo->set[semid].semV[sops[i].sem_num].semval < -sops[i].sem_op)
{
if (sops[i].sem_flg & IPC_NOWAIT)
{
sem_post(&SemInfo->sem);
errno = EAGAIN;
return -1;
}
SemInfo->set[semid].semV[sops[i].sem_num].semncnt++;
if (SemInfo->set[semid].pendingOps[sops[i].sem_num].idx >= OPMAX)
{
/* pending operations array overflow */
sem_post(&SemInfo->sem);
errno = ERANGE;
return -1;
}
SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx++] = sops[i].sem_op;
/* suspend */
sem_post(&SemInfo->sem); /* avoid deadlock */
r1 = sem_wait(&SemInfo->set[semid].sem[sops[i].sem_num]);
sem_wait(&SemInfo->sem);
if (r1)
{
errno1 = errno;
r = r1;
/* remove pending operation */
SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0;
}
else
SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op;
SemInfo->set[semid].semV[sops[i].sem_num].semncnt--;
}
else
SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op;
}
else if (sops[i].sem_op > 0)
{
SemInfo->set[semid].semV[sops[i].sem_num].semval += sops[i].sem_op;
op = sops[i].sem_op;
while (op > 0 && SemInfo->set[semid].pendingOps[sops[i].sem_num].idx > 0)
{ /* operations pending */
if (SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx - 1] + op >= 0)
{
/* unsuspend processes */
if (sem_post(&SemInfo->set[semid].sem[sops[i].sem_num]))
{
errno1 = errno;
r = -1;
}
/* adjust pending operations */
op += SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx];
SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0;
}
else
{
/* adjust pending operations */
SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx - 1] += op;
op = 0;
}
}
}
else
/* sops[i].sem_op == 0 */
{
/* not supported */
sem_post(&SemInfo->sem);
errno = ENOSYS;
return -1;
}
SemInfo->set[semid].semV[sops[i].sem_num].sempid = getpid();
}
sem_post(&SemInfo->sem);
errno = errno1;
return r;
}

View File

@ -1,68 +0,0 @@
/*-------------------------------------------------------------------------
*
* sem.h
* System V Semaphore Emulation
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/sem.h,v 1.8 2003/11/29 19:51:54 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef _SYS_SEM_H
#define _SYS_SEM_H
#include <sys/ipc.h>
#ifdef __cplusplus
extern "C"
{
#endif
/*
* Semctl Command Definitions.
*/
#define GETNCNT 3 /* get semncnt */
#define GETPID 4 /* get sempid */
#define GETVAL 5 /* get semval */
#define GETALL 6 /* get all semval's */
#define GETZCNT 7 /* get semzcnt */
#define SETVAL 8 /* set semval */
#define SETALL 9 /* set all semval's */
/*
* There is one semaphore structure for each semaphore in the system.
*/
struct sem
{
ushort_t semval; /* semaphore text map address */
pid_t sempid; /* pid of last operation */
ushort_t semncnt; /* # awaiting semval > cval */
ushort_t semzcnt; /* # awaiting semval = 0 */
};
/*
* User semaphore template for semop system calls.
*/
struct sembuf
{
ushort_t sem_num; /* semaphore # */
short sem_op; /* semaphore operation */
short sem_flg; /* operation flags */
};
extern int semctl(int semid, int semnum, int cmd, /* ... */ union semun arg);
extern int semget(key_t key, int nsems, int semflg);
extern int semop(int semid, struct sembuf * sops, size_t nsops);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SEM_H */

View File

@ -1,274 +0,0 @@
/*-------------------------------------------------------------------------
*
* shm.c
* System V Shared Memory Emulation
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/shm.c,v 1.10 2005/10/15 02:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/stat.h>
#define MODE 0777
#define SHMMAX 1024
struct shm_info
{
int shmid;
key_t key;
size_t size;
void *addr;
};
static struct shm_info *ShmInfo;
static int shm_putinfo(struct shm_info * info);
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)
{
int i;
if (ShmInfo == NULL)
{
ShmInfo = calloc(SHMMAX, sizeof(struct shm_info));
if (ShmInfo == NULL)
return -1;
/* initialize ShmInfo */
for (i = 0; i < SHMMAX; i++)
ShmInfo[i].shmid = -1;
}
/* search first free element */
i = 0;
while (i < SHMMAX && ShmInfo[i].shmid != -1)
i++;
if (i >= SHMMAX)
{
errno = ENOSPC;
return -1;
}
memcpy(&ShmInfo[i], info, sizeof(struct shm_info));
return i;
}
static int
shm_updinfo(int i, struct shm_info * info)
{
if (i >= SHMMAX)
return -1;
if (ShmInfo == NULL)
return -1;
memcpy(&ShmInfo[i], info, sizeof(struct shm_info));
return i;
}
static int
shm_getinfo(int shmid, struct shm_info * info)
{
int i;
if (ShmInfo == NULL)
return -1;
/* search element */
i = 0;
while (i < SHMMAX && ShmInfo[i].shmid != shmid)
i++;
if (i >= SHMMAX)
return -1;
memcpy(info, &ShmInfo[i], sizeof(struct shm_info));
return i;
}
static int
shm_getinfobyaddr(const void *addr, struct shm_info * info)
{
int i;
if (ShmInfo == (struct shm_info *) - 1)
return -1;
/* search element */
i = 0;
while (i < SHMMAX && ShmInfo[i].addr != addr)
i++;
if (i >= SHMMAX)
return -1;
memcpy(info, &ShmInfo[i], sizeof(struct shm_info));
return i;
}
void *
shmat(int shmid, const void *shmaddr, int shmflg)
{
struct shm_info info;
int i;
i = shm_getinfo(shmid, &info);
if (i == -1)
{
errno = EACCES;
return (void *) -1;
}
info.addr = mmap((void *) shmaddr, info.size,
PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0);
if (info.addr == MAP_FAILED)
return info.addr;
if (shm_updinfo(i, &info) == -1)
{
errno = EACCES;
return (void *) -1;
}
return info.addr;
}
int
shmdt(const void *addr)
{
struct shm_info info;
if (shm_getinfobyaddr(addr, &info) == -1)
{
errno = EACCES;
return -1;
}
return munmap((void *) addr, info.size);
}
int
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;
switch (cmd)
{
case IPC_RMID:
if (shm_getinfo(shmid, &info) == -1)
{
errno = EACCES;
return -1;
}
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;
}
else
{
/*
* if there's no entry for this key it doesn't matter the next
* shmget() would get a different shm anyway
*/
buf->shm_nattch = 0;
return 0;
}
}
errno = EINVAL;
return -1;
}
int
shmget(key_t key, size_t size, int flags)
{
char name[NAME_MAX + 1];
int oflag = 0;
struct shm_info info;
if (flags & IPC_CREAT)
oflag |= O_CREAT;
if (flags & IPC_EXCL)
oflag |= O_EXCL;
if (flags & SHM_R)
{
if (flags & SHM_W)
oflag |= O_RDWR;
else
oflag |= O_RDONLY;
}
info.shmid = shm_open(keytoname(key, name), oflag, MODE);
/* store shared memory information */
if (info.shmid != -1)
{
info.key = key;
info.size = size;
info.addr = NULL;
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. */
ltrunc(info.shmid, size, SEEK_SET);
return info.shmid;
}

View File

@ -1,43 +0,0 @@
/*-------------------------------------------------------------------------
*
* shm.h
* System V Shared Memory Emulation
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/shm.h,v 1.8 2003/11/29 19:51:54 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef _SYS_SHM_H
#define _SYS_SHM_H
#include <sys/ipc.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define SHM_R 0400 /* read permission */
#define SHM_W 0200 /* write permission */
struct shmid_ds
{
int dummy;
int shm_nattch;
};
extern void *shmat(int shmid, const void *shmaddr, int shmflg);
extern int shmdt(const void *addr);
extern int shmctl(int shmid, int cmd, struct shmid_ds * buf);
extern int shmget(key_t key, size_t size, int flags);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SHM_H */

View File

@ -1,206 +0,0 @@
/*-------------------------------------------------------------------------
*
* tstsem.c
* Test of System V Semaphore Emulation
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/tstsem.c,v 1.10 2003/11/29 19:51:54 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <signal.h>
#include <unistd.h>
#include "storage/ipc.h"
#include <sys/mman.h>
#include <sys/sem.h>
#define SEMMAX 16
#define OPSMAX 1
int MaxBackends = SEMMAX;
static int semid;
static void
sig_handler(int sig_no)
{
union semun arg;
int i = semctl(semid, 0, GETNCNT, arg);
if (i == -1)
perror("semctl");
else
printf("semval = %d\n", i);
}
void on_proc_exit(void (*function) (), Datum arg)
{
atexit(function);
}
int
main(int argc, char **argv)
{
int c,
errflg = 0;
char s[80];
key_t key = IPC_PRIVATE;
int nsems = SEMMAX;
int semflg = 0;
int unlink = 0;
int i;
struct sembuf sops[OPSMAX];
u_short array[SEMMAX];
union semun arg;
optarg = NULL;
while (!errflg && (c = getopt(argc, argv, "k:n:cxu")) != -1)
{
switch (c)
{
case 'k':
key = atoi(optarg);
break;
case 'n':
nsems = atoi(optarg);
break;
case 'c':
semflg |= IPC_CREAT;
break;
case 'x':
semflg |= IPC_EXCL;
break;
case 'u':
unlink = 1;
break;
default:
errflg++;
}
}
if (errflg)
{
printf("usage: tstsem [-k key] [-n nsems] [-cxu]\n");
exit(1);
}
if (unlink)
{
i = shm_unlink("SysV_Sem_Info");
if (i == -1)
perror("shm_unlink");
exit(i);
}
semid = semget(key, nsems, semflg);
if (semid == -1)
{
perror("semget");
exit(semid);
}
/* test signal interrupts */
signal(SIGTERM, sig_handler);
do
{
printf("(-)sem_op, (+)sem_op, (G)ETVAL, (S)ETVAL, GET(P)ID, GET(A)LL, SETA(L)L, GET(N)CNT, GET(Z)CNT, e(x)it: ");
scanf("%s", s);
switch (s[0])
{
case '-':
case '+':
sops[0].sem_num = 0;
sops[0].sem_op = atoi(s);
if (sops[0].sem_op == 0)
sops[0].sem_op = s[0] == '+' ? +1 : -1;
sops[0].sem_flg = 0;
if (semop(semid, sops, 1) == -1)
perror("semop");
break;
case 'G':
case 'g':
i = semctl(semid, 0, GETVAL, arg);
if (i == -1)
perror("semctl");
else
printf("semval = %d\n", i);
break;
case 'S':
case 's':
printf("semval = ");
scanf("%d", &arg.val);
if (semctl(semid, 0, SETVAL, arg) == -1)
perror("semctl");
break;
case 'P':
case 'p':
i = semctl(semid, 0, GETPID, arg);
if (i == -1)
perror("semctl");
else
printf("PID = %d\n", i);
break;
case 'A':
case 'a':
arg.array = array;
i = semctl(semid, 0, GETALL, arg);
if (i == -1)
perror("semctl");
else
{
for (i = 0; i < nsems; i++)
printf("semval[%d] = %hu\n", i, arg.array[i]);
}
break;
case 'L':
case 'l':
arg.array = array;
for (i = 0; i < nsems; i++)
{
printf("semval[%d] = ", i);
scanf("%hu", &arg.array[i]);
}
if (semctl(semid, 0, SETALL, arg) == -1)
perror("semctl");
break;
case 'N':
case 'n':
i = semctl(semid, 0, GETNCNT, arg);
if (i == -1)
perror("semctl");
else
printf("semval = %d\n", i);
break;
case 'Z':
case 'z':
i = semctl(semid, 0, GETZCNT, arg);
if (i == -1)
perror("semctl");
else
printf("semval = %d\n", i);
break;
}
}
while (s[0] != 'x');
if (semctl(semid, 0, IPC_RMID, arg) == -1)
{
perror("semctl");
exit(-1);
}
exit(0);
}

View File

@ -1,98 +0,0 @@
/*-------------------------------------------------------------------------
*
* tstshm.c
* Test of System V Shared Memory Emulation
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/tstshm.c,v 1.5 2003/11/29 19:51:54 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <unistd.h>
#include <sys/shm.h>
int
main(int argc, char **argv)
{
int c,
errflg = 0;
char s[80];
key_t key = 0x1000;
size_t size = 256;
int shmid = -1;
caddr_t addr = NULL;
optarg = NULL;
while (!errflg && (c = getopt(argc, argv, "k:s:")) != -1)
{
switch (c)
{
case 'k':
key = atoi(optarg);
break;
case 's':
size = atoi(optarg);
break;
default:
errflg++;
}
}
if (errflg)
{
printf("usage: tstshm [-k key] [-s size]\n");
exit(1);
}
do
{
printf("shm(g)et, shm(a)t, shm(d)t, shm(c)tl, (w)rite, (r)ead, e(x)it: ");
scanf("%s", s);
switch (s[0])
{
case 'g':
shmid = shmget(key, size, IPC_CREAT | SHM_R | SHM_W);
if (shmid == -1)
perror("shmget");
break;
case 'a':
addr = shmat(shmid, NULL, 0);
if (addr == (void *) -1)
perror("shmat");
break;
case 'd':
if (shmdt(addr) == -1)
perror("shmdt");
else
addr = NULL;
break;
case 'c':
if (shmctl(shmid, IPC_RMID, NULL) == -1)
perror("shmctl");
else
shmid = -1;
break;
case 'w':
printf("String to write: ");
scanf("%s", addr);
break;
case 'r':
puts(addr);
break;
}
}
while (s[0] != 'x');
return 0;
}

View File

@ -5,7 +5,7 @@
* to contain some useful information. Mechanism differs wildly across
* platforms.
*
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.27 2005/11/22 18:17:26 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.28 2006/01/05 01:56:29 momjian Exp $
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* various details abducted from various places
@ -63,7 +63,7 @@ extern char **environ;
#define PS_USE_PS_STRINGS
#elif (defined(BSD) || defined(__bsdi__) || defined(__hurd__)) && !defined(__darwin__)
#define PS_USE_CHANGE_ARGV
#elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__QNX__) || defined(__svr4__) || defined(__svr5__) || defined(__darwin__)
#elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__svr4__) || defined(__svr5__) || defined(__darwin__)
#define PS_USE_CLOBBER_ARGV
#elif defined (WIN32)
#define PS_USE_WIN32
@ -73,7 +73,7 @@ extern char **environ;
/* Different systems want the buffer padded differently */
#if defined(_AIX) || defined(__linux__) || defined(__QNX__) || defined(__svr4__)
#if defined(_AIX) || defined(__linux__) || defined(__svr4__)
#define PS_PADDING '\0'
#else
#define PS_PADDING ' '

View File

@ -78,7 +78,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.56 2005/11/22 18:17:27 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.57 2006/01/05 01:56:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -2153,7 +2153,7 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
* Some rather brain-dead implementations of qsort will sometimes call the
* comparison routine to compare a value to itself. (At this writing only
* QNX 4 is known to do such silly things.) Don't raise a bogus error in
* that case.
* that case. Update: The QNX port is gone.
*/
if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2)
ereport(ERROR,

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.15 2003/11/29 19:52:04 pgsql Exp $
# $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.16 2006/01/05 01:56:29 momjian Exp $
#
CMDNAME=`basename $0`
@ -36,17 +36,6 @@ EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
# 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: a postmaster is still running" 1>&2
exit 1
fi
rm -f /dev/shmem/PgS*
exit $?
fi
#
# This is based on RedHat 5.2.
#
if [ `uname` = 'Linux' ]; then

View File

@ -6,7 +6,7 @@
* for developers. If you edit any of these, be sure to do a *full*
* rebuild (and an initdb if noted).
*
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.18 2005/10/07 20:11:03 tgl Exp $
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.19 2006/01/05 01:56:29 momjian Exp $
*------------------------------------------------------------------------
*/
@ -155,14 +155,14 @@
/*
* Disable UNIX sockets for those operating system.
*/
#if defined(__QNX__) || defined(__BEOS__) || defined(WIN32)
#if defined(__BEOS__) || defined(WIN32)
#undef HAVE_UNIX_SOCKETS
#endif
/*
* Define this if your operating system supports link()
*/
#if !defined(__QNX__) && !defined(__BEOS__) && \
#if !defined(__BEOS__) && \
!defined(WIN32) && !defined(__CYGWIN__)
#define HAVE_WORKING_LINK 1
#endif

View File

@ -66,7 +66,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.146 2005/12/30 21:43:41 momjian Exp $
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.147 2006/01/05 01:56:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -684,25 +684,6 @@ typedef unsigned int slock_t;
#endif /* HPUX on IA64, non gcc */
#if defined(__QNX__) && defined(__WATCOMC__) /* QNX */
/*
* QNX 4 using WATCOM C
*/
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#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) /* SGI compiler */
/*
* SGI IRIX 5

View File

@ -1,16 +0,0 @@
MK_NO_LORDER= true
AR= ar
AROPT = cr
LD= $(AR)
LDREL= $(AROPT)
LDOUT=
LDFLAGS=
enable_shared = no
DLSUFFIX = .so
CFLAGS_SL =
%$(DLSUFFIX): %.o
@echo 'cannot make shared object $@ from $<'
sqlmansect = 7

View File

@ -2,7 +2,7 @@
#
# Makefile for the plpgsql shared object
#
# $PostgreSQL: pgsql/src/pl/plpgsql/src/Makefile,v 1.27 2005/12/09 21:19:36 petere Exp $
# $PostgreSQL: pgsql/src/pl/plpgsql/src/Makefile,v 1.28 2006/01/05 01:56:30 momjian Exp $
#
#-------------------------------------------------------------------------
@ -21,14 +21,7 @@ rpath :=
OBJS = pl_gram.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o
ifneq ($(PORTNAME), qnx4)
all: all-lib
else
all:
@echo "*****"
@echo "* PL/pgSQL was not built due to library manager problems."
@echo "*****"
endif
# Shared library stuff
include $(top_srcdir)/src/Makefile.shlib

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/isinf.c,v 1.7 2005/10/15 02:49:51 momjian Exp $
* $PostgreSQL: pgsql/src/port/isinf.c,v 1.8 2006/01/05 01:56:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -74,18 +74,3 @@ isinf(double x)
}
#endif
#endif
#ifdef __QNX__
#include <float.h>
int
isinf(double x)
{
if (x == HUGE_VAL)
return 1;
if (x == -HUGE_VAL)
return -1;
return 0;
}
#endif

View File

@ -1 +0,0 @@
LIBS="-lunix"

View File

@ -1,391 +0,0 @@
--
-- FLOAT8
--
CREATE TABLE FLOAT8_TBL(f1 float8);
INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 ');
INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30 ');
INSERT INTO FLOAT8_TBL(f1) VALUES (' -34.84');
INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
-- test for underflow and overflow handling
SELECT '10e400'::float8;
ERROR: "10e400" is out of range for type double precision
SELECT '-10e400'::float8;
ERROR: "-10e400" is out of range for type double precision
SELECT '10e-400'::float8;
ERROR: "10e-400" is out of range for type double precision
SELECT '-10e-400'::float8;
ERROR: "-10e-400" is out of range for type double precision
-- bad input
INSERT INTO FLOAT8_TBL(f1) VALUES ('');
ERROR: invalid input syntax for type double precision: ""
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for type double precision: " "
INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
ERROR: invalid input syntax for type double precision: "xyz"
INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0');
ERROR: invalid input syntax for type double precision: "5.0.0"
INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0');
ERROR: invalid input syntax for type double precision: "5 . 0"
INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0');
ERROR: invalid input syntax for type double precision: "5. 0"
INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3');
ERROR: invalid input syntax for type double precision: " - 3"
INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5');
ERROR: invalid input syntax for type double precision: "123 5"
-- special inputs
SELECT 'NaN'::float8;
float8
--------
NaN
(1 row)
SELECT 'nan'::float8;
float8
--------
NaN
(1 row)
SELECT ' NAN '::float8;
float8
--------
NaN
(1 row)
SELECT 'infinity'::float8;
float8
----------
Infinity
(1 row)
SELECT ' -INFINiTY '::float8;
float8
-----------
-Infinity
(1 row)
-- bad special inputs
SELECT 'N A N'::float8;
ERROR: invalid input syntax for type double precision: "N A N"
SELECT 'NaN x'::float8;
ERROR: invalid input syntax for type double precision: "NaN x"
SELECT ' INFINITY x'::float8;
ERROR: invalid input syntax for type double precision: " INFINITY x"
SELECT 'Infinity'::float8 + 100.0;
ERROR: type "double precision" value out of range: overflow
SELECT 'Infinity'::float8 / 'Infinity'::float8;
?column?
----------
NaN
(1 row)
SELECT 'nan'::float8 / 'nan'::float8;
?column?
----------
NaN
(1 row)
SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
| 1004.3
| -34.84
| 1.2345678901234e+200
| 1.2345678901234e-200
(5 rows)
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3';
four | f1
------+----------------------
| 0
| -34.84
| 1.2345678901234e+200
| 1.2345678901234e-200
(4 rows)
SELECT '' AS one, f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3';
one | f1
-----+--------
| 1004.3
(1 row)
SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1;
three | f1
-------+----------------------
| 0
| -34.84
| 1.2345678901234e-200
(3 rows)
SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3';
three | f1
-------+----------------------
| 0
| -34.84
| 1.2345678901234e-200
(3 rows)
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1;
four | f1
------+----------------------
| 0
| 1004.3
| -34.84
| 1.2345678901234e-200
(4 rows)
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3';
four | f1
------+----------------------
| 0
| 1004.3
| -34.84
| 1.2345678901234e-200
(4 rows)
SELECT '' AS three, f.f1, f.f1 * '-10' AS x
FROM FLOAT8_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+----------------------+-----------------------
| 1004.3 | -10043
| 1.2345678901234e+200 | -1.2345678901234e+201
| 1.2345678901234e-200 | -1.2345678901234e-199
(3 rows)
SELECT '' AS three, f.f1, f.f1 + '-10' AS x
FROM FLOAT8_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+----------------------+----------------------
| 1004.3 | 994.3
| 1.2345678901234e+200 | 1.2345678901234e+200
| 1.2345678901234e-200 | -10
(3 rows)
SELECT '' AS three, f.f1, f.f1 / '-10' AS x
FROM FLOAT8_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+----------------------+-----------------------
| 1004.3 | -100.43
| 1.2345678901234e+200 | -1.2345678901234e+199
| 1.2345678901234e-200 | -1.2345678901234e-201
(3 rows)
SELECT '' AS three, f.f1, f.f1 - '-10' AS x
FROM FLOAT8_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+----------------------+----------------------
| 1004.3 | 1014.3
| 1.2345678901234e+200 | 1.2345678901234e+200
| 1.2345678901234e-200 | 10
(3 rows)
SELECT '' AS one, f.f1 ^ '2.0' AS square_f1
FROM FLOAT8_TBL f where f.f1 = '1004.3';
one | square_f1
-----+------------
| 1008618.49
(1 row)
-- absolute value
SELECT '' AS five, f.f1, @f.f1 AS abs_f1
FROM FLOAT8_TBL f;
five | f1 | abs_f1
------+----------------------+----------------------
| 0 | 0
| 1004.3 | 1004.3
| -34.84 | 34.84
| 1.2345678901234e+200 | 1.2345678901234e+200
| 1.2345678901234e-200 | 1.2345678901234e-200
(5 rows)
-- truncate
SELECT '' AS five, f.f1, trunc(f.f1) AS trunc_f1
FROM FLOAT8_TBL f;
five | f1 | trunc_f1
------+----------------------+----------------------
| 0 | 0
| 1004.3 | 1004
| -34.84 | -34
| 1.2345678901234e+200 | 1.2345678901234e+200
| 1.2345678901234e-200 | 0
(5 rows)
-- round
SELECT '' AS five, f.f1, round(f.f1) AS round_f1
FROM FLOAT8_TBL f;
five | f1 | round_f1
------+----------------------+----------------------
| 0 | 0
| 1004.3 | 1004
| -34.84 | -35
| 1.2345678901234e+200 | 1.2345678901234e+200
| 1.2345678901234e-200 | 0
(5 rows)
-- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
0
1005
-34
1.2345678901234e+200
1
(5 rows)
select ceiling(f1) as ceiling_f1 from float8_tbl f;
ceiling_f1
----------------------
0
1005
-34
1.2345678901234e+200
1
(5 rows)
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
floor_f1
----------------------
0
1004
-35
1.2345678901234e+200
0
(5 rows)
-- sign
select sign(f1) as sign_f1 from float8_tbl f;
sign_f1
---------
0
1
-1
1
1
(5 rows)
-- square root
SELECT sqrt(float8 '64') AS eight;
eight
-------
8
(1 row)
SELECT |/ float8 '64' AS eight;
eight
-------
8
(1 row)
SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
FROM FLOAT8_TBL f
WHERE f.f1 > '0.0';
three | f1 | sqrt_f1
-------+----------------------+-----------------------
| 1004.3 | 31.6906926399535
| 1.2345678901234e+200 | 1.11111110611109e+100
| 1.2345678901234e-200 | 1.11111110611109e-100
(3 rows)
-- power
SELECT power(float8 '144', float8 '0.5');
power
-------
12
(1 row)
-- take exp of ln(f.f1)
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
FROM FLOAT8_TBL f
WHERE f.f1 > '0.0';
three | f1 | exp_ln_f1
-------+----------------------+-----------------------
| 1004.3 | 1004.3
| 1.2345678901234e+200 | 1.23456789012337e+200
| 1.2345678901234e-200 | 1.23456789012338e-200
(3 rows)
-- cube root
SELECT ||/ float8 '27' AS three;
three
-------
3
(1 row)
SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
five | f1 | cbrt_f1
------+----------------------+-----------------------
| 0 | 0
| 1004.3 | 10.014312837827
| -34.84 | -3.26607421344208
| 1.2345678901234e+200 | 4.97933859234757e+066
| 1.2345678901234e-200 | 2.3112042409018e-067
(5 rows)
SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
| 1004.3
| -34.84
| 1.2345678901234e+200
| 1.2345678901234e-200
(5 rows)
UPDATE FLOAT8_TBL
SET f1 = FLOAT8_TBL.f1 * '-1'
WHERE FLOAT8_TBL.f1 > '0.0';
SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
ERROR: type "double precision" value out of range: overflow
SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
ERROR: result is out of range
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
ERROR: cannot take logarithm of zero
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ;
ERROR: cannot take logarithm of a negative number
SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
ERROR: result is out of range
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
ERROR: division by zero
SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
| -34.84
| -1004.3
| -1.2345678901234e+200
| -1.2345678901234e-200
(5 rows)
-- test for over- and underflow
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
ERROR: "10e400" is out of range for type double precision
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
ERROR: "-10e400" is out of range for type double precision
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
ERROR: "10e-400" is out of range for type double precision
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
ERROR: "-10e-400" is out of range for type double precision
-- maintain external table consistency across platforms
-- delete all values and reinsert well-behaved ones
DELETE FROM FLOAT8_TBL;
INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
| -34.84
| -1004.3
| -1.2345678901234e+200
| -1.2345678901234e-200
(5 rows)

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.62 2005/12/09 21:19:36 petere Exp $
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.63 2006/01/05 01:56:30 momjian Exp $
me=`basename $0`
: ${TMPDIR=/tmp}
@ -216,7 +216,7 @@ esac
# On some platforms we can't use Unix sockets.
# ----------
case $host_platform in
*-*-cygwin* | *-*-mingw32* | *-*-qnx* | *beos*)
*-*-cygwin* | *-*-mingw32* | *beos*)
unix_sockets=no;;
*)
unix_sockets=yes;;
@ -228,7 +228,7 @@ esac
# ----------
case $host_platform in
*-*-qnx* | *-*-sco3.2v5*)
*-*-sco3.2v5*)
DIFFFLAGS=-b;;
*)
DIFFFLAGS=-w;;

View File

@ -1,11 +1,8 @@
float4/.*-qnx=float4-exp-three-digits
float4/i.86-pc-mingw32=float4-exp-three-digits
float8/i.86-.*-freebsd[234]=float8-small-is-zero
float8/i.86-.*-openbsd=float8-small-is-zero
float8/i.86-.*-netbsd=float8-small-is-zero
float8/m68k-.*-netbsd=float8-small-is-zero
float8/.*-qnx=float8-exp-three-digits
float8/i.86-pc-mingw32=float8-exp-three-digits-win32
float8/i.86-pc-cygwin=float8-small-is-zero
int8/.*-qnx=int8-exp-three-digits
int8/i.86-pc-mingw32=int8-exp-three-digits