The beos port in the source tree doesn't even compile. and even
after that dynamic loading isn't working and shared memory handling is broken. Attached with this message, there is a Zip file which contain : * beos.diff = patch file generated with difforig * beos = folder with beos support files which need to be moved in / src/backend/port * expected = foler with three file for message and precision difference in regression test * regression.diff = rule problem (need to kill the backend manualy) * dynloader = dynloader files (they are also in the pacth files, but there is so much modification that I have join full files) Everything works except a problem in 'rules' Is there some problems with rules in the current tree ? It used to works with last week tree. Cyril VELTER
This commit is contained in:
parent
a759460178
commit
7ea8403c8a
|
@ -82,6 +82,7 @@ nextstep*) template=nextstep ;;
|
|||
sysv4*) template=svr4 ;;
|
||||
sysv5uw*) template=unixware ;;
|
||||
ultrix*) template=ultrix4 ;;
|
||||
beos*) template=beos ;;
|
||||
esac
|
||||
|
||||
if test x"$template" = x"" ; then
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# Copyright (c) 1998, Regents of the University of California
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.23 2000/09/17 13:02:29 petere Exp $
|
||||
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.24 2000/10/07 14:39:06 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
@ -198,6 +198,11 @@ ifeq ($(PORTNAME), win)
|
|||
shlib := $(NAME)$(DLSUFFIX)
|
||||
endif
|
||||
|
||||
ifeq ($(PORTNAME), beos)
|
||||
install-shlib-dep := install-shlib
|
||||
shlib := lib$(NAME)$(DLSUFFIX)
|
||||
LDFLAGS_SL := -nostart -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
|
||||
endif
|
||||
|
||||
# Note that in what follows, shlib is empty when not building a shared
|
||||
# library.
|
||||
|
@ -225,6 +230,7 @@ endif
|
|||
endif # not win
|
||||
|
||||
ifdef shlib
|
||||
ifneq ($(PORTNAME), beos)
|
||||
ifneq ($(PORTNAME), win)
|
||||
ifneq ($(PORTNAME), aix)
|
||||
|
||||
|
@ -263,6 +269,15 @@ $(top_builddir)/src/utils/dllinit.o: $(top_srcdir)/src/utils/dllinit.c
|
|||
$(MAKE) -C $(top_builddir)/src/utils dllinit.o
|
||||
|
||||
endif # PORTNAME == win
|
||||
|
||||
else # PORTNAME == beos
|
||||
|
||||
# BEOS case
|
||||
$(shlib): $(OBJS)
|
||||
ln -fs $(top_srcdir)/src/backend/postgres _APP_
|
||||
$(CC) -Xlinker -soname=$@ $(LDFLAGS_SL) -o $@ _APP_ $(OBJS) $(SHLIB_LINK)
|
||||
|
||||
endif # PORTNAME == beos
|
||||
endif # shlib
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.31 2000/10/03 03:11:15 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.32 2000/10/07 14:39:07 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -98,6 +98,12 @@ if (!geteuid())
|
|||
}
|
||||
#endif /* __BEOS__ */
|
||||
|
||||
#ifdef __BEOS__
|
||||
/* Specific beos actions on startup */
|
||||
beos_startup(argc,argv);
|
||||
#endif
|
||||
|
||||
|
||||
if (len >= 10 && !strcmp(argv[0] + len - 10, "postmaster"))
|
||||
exit(PostmasterMain(argc, argv));
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# be converted to Method 2.
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.in,v 1.24 2000/08/31 16:10:16 petere Exp $
|
||||
# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.in,v 1.25 2000/10/07 14:39:10 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
@ -27,6 +27,9 @@ OBJS+= @STRTOL@ @STRTOUL@ @SNPRINTF@
|
|||
ifeq ($(PORTNAME), qnx4)
|
||||
OBJS += getrusage.o qnx4/SUBSYS.o
|
||||
endif
|
||||
ifeq ($(PORTNAME), beos)
|
||||
OBJS += beos/SUBSYS.o
|
||||
endif
|
||||
all: SUBSYS.o
|
||||
|
||||
SUBSYS.o: $(OBJS)
|
||||
|
@ -37,6 +40,9 @@ qnx4/SUBSYS.o: qnx4.dir
|
|||
qnx4.dir:
|
||||
$(MAKE) -C qnx4 all
|
||||
|
||||
beos/SUBSYS.o:
|
||||
$(MAKE) -C beos all
|
||||
|
||||
tas.o: tas.s
|
||||
$(CC) $(CFLAGS) -c tas.s
|
||||
|
||||
|
|
|
@ -8,53 +8,65 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.2 2000/10/03 03:11:15 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.3 2000/10/07 14:39:11 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
#include <kernel/OS.h>
|
||||
#include <image.h>
|
||||
#include <errno.h>
|
||||
#include "utils/dynamic_loader.h"
|
||||
#include "utils/elog.h"
|
||||
|
||||
#include "dynloader.h"
|
||||
|
||||
extern char pg_pathname[];
|
||||
|
||||
void *
|
||||
beos_dlopen(const char *filename)
|
||||
void *
|
||||
pg_dlopen(char *filename)
|
||||
{
|
||||
image_id id = -1;
|
||||
image_id* im;
|
||||
|
||||
/* Handle memory allocation to store the Id of the shared object*/
|
||||
im=(image_id*)(malloc(sizeof(image_id)));
|
||||
|
||||
/* Add-on loading */
|
||||
*im=beos_dl_open(filename);
|
||||
|
||||
return im;
|
||||
}
|
||||
|
||||
if ((id = load_add_on(filename)) < 0)
|
||||
return NULL;
|
||||
|
||||
return (void *) id;
|
||||
char *
|
||||
pg_dlerror()
|
||||
{
|
||||
static char errmsg[] = "Load Add-On failed";
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
PGFunction
|
||||
pg_dlsym(void *handle, char *funcname)
|
||||
{
|
||||
PGFunction fpt;
|
||||
|
||||
/* Checking that "Handle" is valid */
|
||||
if ((handle) && ((*(int*)(handle))>=0))
|
||||
{
|
||||
/* Loading symbol */
|
||||
if(get_image_symbol(*((int*)(handle)),funcname,B_SYMBOL_TYPE_TEXT,(void**)&fpt)==B_OK);
|
||||
{
|
||||
return fpt;
|
||||
}
|
||||
elog(NOTICE, "loading symbol '%s' failed ",funcname);
|
||||
}
|
||||
elog(NOTICE, "add-on not loaded correctly");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
beos_dlclose(void *handle)
|
||||
pg_dlclose(void *handle)
|
||||
{
|
||||
image_id id = (image_id) handle;
|
||||
unload_add_on(id);
|
||||
return;
|
||||
}
|
||||
|
||||
void *
|
||||
beos_dlsym(void *handle, const char *name)
|
||||
{
|
||||
image_id id = (image_id)handle;
|
||||
void *addr;
|
||||
|
||||
if (get_image_symbol(id, name, B_SYMBOL_TYPE_ANY, &addr) != B_OK)
|
||||
return NULL;
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
char *
|
||||
beos_dlerror()
|
||||
{
|
||||
return (char *)strerror(errno);
|
||||
}
|
||||
/* Checking that "Handle" is valid */
|
||||
if ((handle) && ((*(int*)(handle))>=0))
|
||||
{
|
||||
if (beos_dl_close(*(image_id*)handle)!=B_OK)
|
||||
elog(NOTICE, "error while unloading add-on");
|
||||
free(handle);
|
||||
}
|
||||
}
|
|
@ -7,27 +7,12 @@
|
|||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: beos.h,v 1.2 2000/10/03 03:11:15 momjian Exp $
|
||||
* $Id: beos.h,v 1.3 2000/10/07 14:39:11 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PORT_PROTOS_H
|
||||
#define PORT_PROTOS_H
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "utils/dynamic_loader.h"
|
||||
|
||||
char *beos_dlerror(void);
|
||||
void *beos_dlopen(const char *filename);
|
||||
void *beos_dlsym(void *handle, const char *name);
|
||||
void beos_dlclose(void *handle);
|
||||
|
||||
#define pg_dlopen(f) beos_dlopen(f)
|
||||
#define pg_dlsym beos_dlsym
|
||||
#define pg_dlclose beos_dlclose
|
||||
#define pg_dlerror beos_dlerror
|
||||
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.51 2000/10/03 03:11:17 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.52 2000/10/07 14:39:12 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
|
@ -243,17 +243,12 @@ on_exit_reset(void)
|
|||
static void
|
||||
IPCPrivateSemaphoreKill(int status, int semId)
|
||||
{
|
||||
/* BeOS has a native sempahore type... */
|
||||
#ifndef __BEOS__
|
||||
union semun semun;
|
||||
semun.val = 0; /* unused */
|
||||
|
||||
if (semctl(semId, 0, IPC_RMID, semun) == -1)
|
||||
elog(NOTICE, "IPCPrivateSemaphoreKill: semctl(%d, 0, IPC_RMID, ...) failed: %s",
|
||||
semId, strerror(errno));
|
||||
#else /* __BEOS__ */
|
||||
delete_sem(semId);
|
||||
#endif /* __BEOS__ */
|
||||
}
|
||||
|
||||
|
||||
|
@ -270,18 +265,11 @@ IPCPrivateMemoryKill(int status, int shmId)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifndef __BEOS__
|
||||
if (shmctl(shmId, IPC_RMID, (struct shmid_ds *) NULL) < 0)
|
||||
{
|
||||
elog(NOTICE, "IPCPrivateMemoryKill: shmctl(%d, %d, 0) failed: %m",
|
||||
shmId, IPC_RMID);
|
||||
}
|
||||
#else
|
||||
if (delete_area(shmId) != B_OK)
|
||||
{
|
||||
elog(NOTICE, "IPCPrivateMemoryKill: delete_area(%d) failed", shmId);
|
||||
}
|
||||
#endif /* __BEOS__ */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,7 +292,6 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
|
|||
int removeOnExit)
|
||||
{
|
||||
int semId;
|
||||
#ifndef __BEOS__
|
||||
int i;
|
||||
int errStatus;
|
||||
u_short array[IPC_NMAXSEM];
|
||||
|
@ -366,21 +353,6 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
|
|||
}
|
||||
|
||||
|
||||
#else /* BeOS implementation */
|
||||
char semname[32];
|
||||
sprintf (semname, "pgsql_ipc:%ld", semKey);
|
||||
semId = create_sem(1, semname);
|
||||
if (semId < 0) {
|
||||
fprintf(stderr, "IpcSemaphoreCreate: create_sem(1, %s) failed: %s\n",
|
||||
semname, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (removeOnExit)
|
||||
on_shmem_exit(IPCPrivateSemaphoreKill, (caddr_t) semId);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_IPC
|
||||
fprintf(stderr, "IpcSemaphoreCreate returns %d\n", semId);
|
||||
fflush(stdout);
|
||||
|
@ -424,7 +396,6 @@ void
|
|||
IpcSemaphoreKill(IpcSemaphoreKey key)
|
||||
{
|
||||
int semId;
|
||||
#ifndef __BEOS__
|
||||
union semun semun;
|
||||
semun.val = 0; /* unused */
|
||||
|
||||
|
@ -433,23 +404,6 @@ IpcSemaphoreKill(IpcSemaphoreKey key)
|
|||
semId = semget(key, 0, 0);
|
||||
if (semId != -1)
|
||||
semctl(semId, 0, IPC_RMID, semun);
|
||||
#else
|
||||
/* first find the semId by looking at sempahore names... */
|
||||
sem_info si;
|
||||
int32 cookie = 0;
|
||||
char semname[32];
|
||||
sprintf(semname, "pgsql_ipc:%ld", key);
|
||||
|
||||
semId = -1;
|
||||
while (get_next_sem_info(0, &cookie, &si) == B_OK) {
|
||||
if (strcmp(si.name, semname) == 0){
|
||||
semId = si.sem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (semId != -1)
|
||||
delete_sem(semId);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
@ -462,7 +416,6 @@ static int IpcSemaphoreLock_return;
|
|||
void
|
||||
IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock)
|
||||
{
|
||||
#ifndef __BEOS__
|
||||
extern int errno;
|
||||
int errStatus;
|
||||
struct sembuf sops;
|
||||
|
@ -495,13 +448,6 @@ IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock)
|
|||
semId, strerror(errno));
|
||||
proc_exit(255);
|
||||
}
|
||||
#else
|
||||
if ((IpcSemaphoreLock_return = acquire_sem(semId)) != B_NO_ERROR) {
|
||||
fprintf(stderr, "IpcSempahoreLock: acquire_sem failed on sem_id %d: %s\n",
|
||||
semId, strerror(errno));
|
||||
proc_exit(255);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
@ -514,7 +460,6 @@ static int IpcSemaphoreUnlock_return;
|
|||
void
|
||||
IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock)
|
||||
{
|
||||
#ifndef __BEOS__
|
||||
extern int errno;
|
||||
int errStatus;
|
||||
struct sembuf sops;
|
||||
|
@ -548,49 +493,28 @@ IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock)
|
|||
semId, strerror(errno));
|
||||
proc_exit(255);
|
||||
}
|
||||
#else
|
||||
if ((IpcSemaphoreUnlock_return = release_sem(semId)) != B_NO_ERROR) {
|
||||
fprintf(stderr, "IpcSempahoreUnlock: release_sem failed on sem_id %d: %s\n",
|
||||
semId, strerror(errno));
|
||||
proc_exit(255);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem)
|
||||
{
|
||||
#ifndef __BEOS__
|
||||
int semncnt;
|
||||
union semun dummy; /* for Solaris */
|
||||
dummy.val = 0; /* unused */
|
||||
|
||||
semncnt = semctl(semId, sem, GETNCNT, dummy);
|
||||
return semncnt;
|
||||
#else
|
||||
sem_info si;
|
||||
|
||||
get_sem_info(semId, &si);
|
||||
return si.count;
|
||||
#endif /* __BEOS__ */
|
||||
}
|
||||
|
||||
int
|
||||
IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem)
|
||||
{
|
||||
#ifndef __BEOS__
|
||||
int semval;
|
||||
union semun dummy; /* for Solaris */
|
||||
dummy.val = 0; /* unused */
|
||||
|
||||
semval = semctl(semId, sem, GETVAL, dummy);
|
||||
return semval;
|
||||
#else
|
||||
sem_info si;
|
||||
|
||||
get_sem_info(semId, &si);
|
||||
return si.count;
|
||||
#endif /* __BEOS__ */
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
@ -611,7 +535,6 @@ IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
|
|||
shmid = PrivateMemoryCreate(memKey, size);
|
||||
}
|
||||
else
|
||||
#ifndef __BEOS__
|
||||
|
||||
shmid = shmget(memKey, size, IPC_CREAT | permission);
|
||||
|
||||
|
@ -649,24 +572,6 @@ IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
|
|||
return IpcMemCreationFailed;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
{
|
||||
char *addr;
|
||||
uint32 pages = ((size - 1) / B_PAGE_SIZE) +1;
|
||||
char areaname[32];
|
||||
sprintf (areaname, "pgsql_ipc%ld", memKey);
|
||||
|
||||
shmid = create_area(areaname, (void*)&addr, B_ANY_ADDRESS, pages * B_PAGE_SIZE,
|
||||
B_NO_LOCK, B_READ_AREA|B_WRITE_AREA);
|
||||
}
|
||||
|
||||
if (shmid < 0) {
|
||||
fprintf(stderr, "IpcMemoryCreate: failed: %s\n",
|
||||
strerror(errno));
|
||||
return IpcMemCreationFailed;
|
||||
}
|
||||
#endif /* __BEOS__ */
|
||||
|
||||
/* if (memKey == PrivateIPCKey) */
|
||||
on_shmem_exit(IPCPrivateMemoryKill, (Datum) shmid);
|
||||
|
@ -683,7 +588,6 @@ IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
|
|||
{
|
||||
IpcMemoryId shmid;
|
||||
|
||||
#ifndef __BEOS__
|
||||
shmid = shmget(memKey, size, 0);
|
||||
|
||||
if (shmid < 0)
|
||||
|
@ -692,17 +596,6 @@ IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
|
|||
memKey, size, strerror(errno));
|
||||
return IpcMemIdGetFailed;
|
||||
}
|
||||
#else
|
||||
char areaname[32];
|
||||
sprintf(areaname, "pgsql_ipc%ld", memKey);
|
||||
shmid = find_area(areaname);
|
||||
|
||||
if (shmid == B_NAME_NOT_FOUND){
|
||||
fprintf(stderr, "IpcMemoryIdGet: find_area(%s) failed: %s\n",
|
||||
areaname, strerror(errno));
|
||||
return IpcMemIdGetFailed;
|
||||
}
|
||||
#endif /* __BEOS__ */
|
||||
|
||||
return shmid;
|
||||
}
|
||||
|
@ -715,10 +608,8 @@ IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
|
|||
static void
|
||||
IpcMemoryDetach(int status, char *shmaddr)
|
||||
{
|
||||
#ifndef __BEOS__
|
||||
if (shmdt(shmaddr) < 0)
|
||||
elog(NOTICE, "IpcMemoryDetach: shmdt(0x%p) failed: %m", shmaddr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
@ -733,7 +624,6 @@ IpcMemoryAttach(IpcMemoryId memId)
|
|||
{
|
||||
char *memAddress;
|
||||
|
||||
#ifndef __BEOS__
|
||||
if (UsePrivateMemory)
|
||||
memAddress = (char *) PrivateMemoryAttach(memId);
|
||||
else
|
||||
|
@ -746,23 +636,6 @@ IpcMemoryAttach(IpcMemoryId memId)
|
|||
memId, strerror(errno));
|
||||
return IpcMemAttachFailed;
|
||||
}
|
||||
#else
|
||||
|
||||
if (UsePrivateMemory)
|
||||
memAddress = (char *) PrivateMemoryAttach(memId);
|
||||
else
|
||||
{
|
||||
area_info ai;
|
||||
get_area_info(memId, &ai);
|
||||
memAddress = (char *)ai.address;
|
||||
}
|
||||
|
||||
if (memAddress == (char *)-1) {
|
||||
fprintf(stderr,"IpcMemoryAttach: failed to get area address (%d): %s\n",
|
||||
memId, strerror(errno));
|
||||
return IpcMemAttachFailed;
|
||||
}
|
||||
#endif /* __BEOS__ */
|
||||
|
||||
if (!UsePrivateMemory)
|
||||
on_shmem_exit(IpcMemoryDetach, PointerGetDatum(memAddress));
|
||||
|
@ -780,7 +653,6 @@ IpcMemoryKill(IpcMemoryKey memKey)
|
|||
{
|
||||
IpcMemoryId shmid;
|
||||
|
||||
#ifndef __BEOS__
|
||||
if (!UsePrivateMemory && (shmid = shmget(memKey, 0, 0)) >= 0)
|
||||
{
|
||||
if (shmctl(shmid, IPC_RMID, (struct shmid_ds *) NULL) < 0)
|
||||
|
@ -789,15 +661,6 @@ IpcMemoryKill(IpcMemoryKey memKey)
|
|||
shmid, IPC_RMID);
|
||||
}
|
||||
}
|
||||
#else
|
||||
char areaname[32];
|
||||
sprintf(areaname, "pgsql_ipc%ld", memKey);
|
||||
shmid = find_area(areaname);
|
||||
if (!UsePrivateMemory && shmid > 0) {
|
||||
if (delete_area(shmid) != B_OK)
|
||||
elog(NOTICE, "IpcMemoryKill: deleta_area(%d) failed!", shmid);
|
||||
}
|
||||
#endif /* __BEOS__ */
|
||||
}
|
||||
|
||||
#ifdef HAS_TEST_AND_SET
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.82 2000/10/03 03:11:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.83 2000/10/07 14:39:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@
|
|||
* This is so that we can support more backends. (system-wide semaphore
|
||||
* sets run out pretty fast.) -ay 4/95
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.82 2000/10/03 03:11:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.83 2000/10/07 14:39:13 momjian Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
|
@ -266,10 +266,8 @@ InitProcess(IPCKey key)
|
|||
* we might be reusing a semaphore that belongs to a dead backend.
|
||||
* So be careful and reinitialize its value here.
|
||||
*/
|
||||
#ifndef __BEOS__
|
||||
semun.val = IpcSemaphoreDefaultStartValue;
|
||||
semctl(semId, semNum, SETVAL, semun);
|
||||
#endif
|
||||
|
||||
IpcSemaphoreLock(semId, semNum, IpcExclusiveLock);
|
||||
MyProc->sem.semId = semId;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.179 2000/10/07 04:00:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.180 2000/10/07 14:39:14 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
|
@ -1462,6 +1462,11 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
|||
|
||||
if (IsUnderPostmaster)
|
||||
{
|
||||
#ifdef __BEOS__
|
||||
/* Specific beos backend stratup actions */
|
||||
beos_backend_startup(argv[0]);
|
||||
#endif
|
||||
|
||||
/* noninteractive case: nothing should be left after switches */
|
||||
if (errs || argc != optind || DBName == NULL)
|
||||
{
|
||||
|
@ -1613,7 +1618,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
|||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.179 $ $Date: 2000/10/07 04:00:41 $\n");
|
||||
puts("$Revision: 1.180 $ $Date: 2000/10/07 14:39:14 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.63 2000/10/03 03:11:21 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.64 2000/10/07 14:39:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -144,6 +144,9 @@ elog(int lev, const char *fmt, ...)
|
|||
sprintf(errorstr_buf, "error %d", errno);
|
||||
errorstr = errorstr_buf;
|
||||
}
|
||||
#else
|
||||
errorstr = strerror(errno);
|
||||
#endif /* __BEOS__ */
|
||||
|
||||
if (lev == ERROR || lev == FATAL)
|
||||
{
|
||||
|
@ -182,9 +185,6 @@ elog(int lev, const char *fmt, ...)
|
|||
prefix = prefix_buf;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
errorstr = strerror(errno);
|
||||
#endif /* __BEOS__ */
|
||||
|
||||
timestamp_size = 0;
|
||||
if (Log_timestamp)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* Copyright (C) 2000 by PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.15 2000/05/29 21:26:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.16 2000/10/07 14:39:15 momjian Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
|
@ -89,6 +89,11 @@ main(int argc, char *argv[])
|
|||
else if (nameflag)
|
||||
puts(pw->pw_name);
|
||||
else
|
||||
#ifdef __BEOS__
|
||||
if (pw->pw_uid==0)
|
||||
printf("1\n");
|
||||
else
|
||||
#endif
|
||||
printf("%d\n", (int) pw->pw_uid);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* or in config.h afterwards. Of course, if you edit config.h, then your
|
||||
* changes will be overwritten the next time you run configure.
|
||||
*
|
||||
* $Id: config.h.in,v 1.140 2000/10/03 19:50:21 petere Exp $
|
||||
* $Id: config.h.in,v 1.141 2000/10/07 14:39:16 momjian Exp $
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
|
@ -227,7 +227,7 @@
|
|||
* Define this is your operating system kernel supports AF_UNIX family
|
||||
* sockets.
|
||||
*/
|
||||
#if !defined(__CYGWIN__) && !defined(__QNX__)
|
||||
#if !defined(__CYGWIN__) && !defined(__QNX__) && !defined(__BEOS__)
|
||||
# define HAVE_UNIX_SOCKETS 1
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,4 +6,68 @@ typedef unsigned char slock_t;
|
|||
|
||||
#define AF_UNIX 1 /* no domain sockets on BeOS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "kernel/image.h"
|
||||
|
||||
#undef HAVE_UNION_SEMUN
|
||||
#define HAVE_UNION_SEMUN 1
|
||||
#undef HAVE_SYS_SEM_H
|
||||
#undef HAVE_SYS_SHM_H
|
||||
|
||||
union semun
|
||||
{
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
unsigned short *array;
|
||||
};
|
||||
/* SYS V emulation */
|
||||
|
||||
#define IPC_RMID 256
|
||||
#define IPC_CREAT 512
|
||||
#define IPC_EXCL 1024
|
||||
#define IPC_PRIVATE 234564
|
||||
|
||||
#define EACCESS 2048
|
||||
#define EIDRM 4096
|
||||
|
||||
#define SETALL 8192
|
||||
#define GETNCNT 16384
|
||||
#define GETVAL 65536
|
||||
#define SETVAL 131072
|
||||
|
||||
struct sembuf
|
||||
{
|
||||
int sem_flg;
|
||||
int sem_op;
|
||||
int sem_num;
|
||||
};
|
||||
|
||||
int semctl(int semId,int semNum,int flag,union semun);
|
||||
int semget(int semKey, int semNum, int flags);
|
||||
int semop(int semId, struct sembuf *sops, int flag);
|
||||
|
||||
struct shmid_ds
|
||||
{
|
||||
int dummy;
|
||||
};
|
||||
|
||||
int shmdt(char* shmaddr);
|
||||
int* shmat(int memId,int m1,int m2);
|
||||
int shmctl(int shmid,int flag, struct shmid_ds* dummy);
|
||||
int shmget(int memKey,int size,int flag);
|
||||
|
||||
|
||||
/* Support functions */
|
||||
/* Specific beos action made on postgres/postmaster startup */
|
||||
void beos_startup(int argc,char** argv);
|
||||
/* Load a shared library */
|
||||
image_id beos_dl_open(char * filename);
|
||||
/* UnLoad a shared library */
|
||||
status_t beos_dl_close(image_id im);
|
||||
/* Specific beos action made on backend startup */
|
||||
void beos_backend_startup(char* binary);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -7,7 +7,7 @@
|
|||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: ipc.h,v 1.41 2000/10/03 03:11:24 momjian Exp $
|
||||
* $Id: ipc.h,v 1.42 2000/10/07 14:39:17 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file is very architecture-specific. This stuff should actually
|
||||
|
@ -27,11 +27,6 @@
|
|||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_IPC_H
|
||||
#include <sys/ipc.h> /* For IPC_PRIVATE */
|
||||
#else
|
||||
/* BeOS doesn't have IPC_PRIVATE so we'll use the value that is set by
|
||||
* FreeBSD (1)
|
||||
*/
|
||||
#define IPC_PRIVATE 1
|
||||
#endif /* HAVE_SYS_IPC_H */
|
||||
|
||||
#include "config.h"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
MK_NO_LORDER=true
|
||||
ifdef ELF_SYSTEM
|
||||
LDFLAGS += -Wl,-E
|
||||
CPPFLAGS+= -I$(top_srcdir)/src/backend/port/beos
|
||||
endif
|
||||
%.so: %.o
|
||||
$(LD) -x -Bshareable -o $@ $<
|
||||
ln -fs $(top_srcdir)/src/backend/postgres _APP_
|
||||
$(CC) -nostart -Xlinker -soname=$@ -o $@ _APP_ $<
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
AROPT:crs
|
||||
SHARED_LIB:-fpic -DPIC
|
||||
CFLAGS:-O2
|
||||
SRCH_INC:
|
||||
SRCH_LIB:
|
||||
USE_LOCALE:no
|
||||
DLSUFFIX:.so
|
||||
YFLAGS:-d
|
||||
YACC:bison -y
|
||||
AROPT=crs
|
||||
SHARED_LIB='-fpic -DPIC'
|
||||
CFLAGS='-O2'
|
||||
LDFLAGS='-lbind'
|
||||
SRCH_INC='/boot/apps/GeekGadgets/include'
|
||||
SRCH_LIB='/boot/apps/GeekGadgets/lib'
|
||||
USE_LOCALE=no
|
||||
DLSUFFIX=.so
|
||||
YFLAGS=-d
|
||||
YACC='bison -y'
|
||||
|
|
|
@ -0,0 +1,532 @@
|
|||
--
|
||||
-- GEOMETRY
|
||||
--
|
||||
--
|
||||
-- Points
|
||||
--
|
||||
SELECT '' AS four, center(f1) AS center
|
||||
FROM BOX_TBL;
|
||||
four | center
|
||||
------+---------
|
||||
| (1,1)
|
||||
| (2,2)
|
||||
| (2.5,3)
|
||||
| (3,3)
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, (@@ f1) AS center
|
||||
FROM BOX_TBL;
|
||||
four | center
|
||||
------+---------
|
||||
| (1,1)
|
||||
| (2,2)
|
||||
| (2.5,3)
|
||||
| (3,3)
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS six, point(f1) AS center
|
||||
FROM CIRCLE_TBL;
|
||||
six | center
|
||||
-----+-----------
|
||||
| (0,0)
|
||||
| (1,2)
|
||||
| (1,3)
|
||||
| (1,2)
|
||||
| (100,200)
|
||||
| (100,0)
|
||||
(6 rows)
|
||||
|
||||
SELECT '' AS six, (@@ f1) AS center
|
||||
FROM CIRCLE_TBL;
|
||||
six | center
|
||||
-----+-----------
|
||||
| (0,0)
|
||||
| (1,2)
|
||||
| (1,3)
|
||||
| (1,2)
|
||||
| (100,200)
|
||||
| (100,0)
|
||||
(6 rows)
|
||||
|
||||
SELECT '' AS two, (@@ f1) AS center
|
||||
FROM POLYGON_TBL
|
||||
WHERE (# f1) > 2;
|
||||
two | center
|
||||
-----+-------------------------------------
|
||||
| (1.33333333333333,1.33333333333333)
|
||||
| (2.33333333333333,1.33333333333333)
|
||||
(2 rows)
|
||||
|
||||
-- "is horizontal" function
|
||||
SELECT '' AS two, p1.f1
|
||||
FROM POINT_TBL p1
|
||||
WHERE ishorizontal(p1.f1, point '(0,0)');
|
||||
two | f1
|
||||
-----+---------
|
||||
| (0,0)
|
||||
| (-10,0)
|
||||
(2 rows)
|
||||
|
||||
-- "is horizontal" operator
|
||||
SELECT '' AS two, p1.f1
|
||||
FROM POINT_TBL p1
|
||||
WHERE p1.f1 ?- point '(0,0)';
|
||||
two | f1
|
||||
-----+---------
|
||||
| (0,0)
|
||||
| (-10,0)
|
||||
(2 rows)
|
||||
|
||||
-- "is vertical" function
|
||||
SELECT '' AS one, p1.f1
|
||||
FROM POINT_TBL p1
|
||||
WHERE isvertical(p1.f1, point '(5.1,34.5)');
|
||||
one | f1
|
||||
-----+------------
|
||||
| (5.1,34.5)
|
||||
(1 row)
|
||||
|
||||
-- "is vertical" operator
|
||||
SELECT '' AS one, p1.f1
|
||||
FROM POINT_TBL p1
|
||||
WHERE p1.f1 ?| point '(5.1,34.5)';
|
||||
one | f1
|
||||
-----+------------
|
||||
| (5.1,34.5)
|
||||
(1 row)
|
||||
|
||||
--
|
||||
-- Line segments
|
||||
--
|
||||
-- intersection
|
||||
SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
|
||||
FROM LSEG_TBL l, POINT_TBL p;
|
||||
ERROR: Unable to identify an operator '#' for types 'lseg' and 'point'
|
||||
You will have to retype this query using an explicit cast
|
||||
-- closest point
|
||||
SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
|
||||
FROM LSEG_TBL l, POINT_TBL p;
|
||||
thirty | f1 | s | closest
|
||||
--------+------------+-------------------------------+---------------------------------------
|
||||
| (0,0) | [(1,2),(3,4)] | (1,2)
|
||||
| (-10,0) | [(1,2),(3,4)] | (1,2)
|
||||
| (-3,4) | [(1,2),(3,4)] | (1,2)
|
||||
| (5.1,34.5) | [(1,2),(3,4)] | (3,4)
|
||||
| (-5,-12) | [(1,2),(3,4)] | (1,2)
|
||||
| (10,10) | [(1,2),(3,4)] | (3,4)
|
||||
| (0,0) | [(0,0),(6,6)] | (-0,0)
|
||||
| (-10,0) | [(0,0),(6,6)] | (0,0)
|
||||
| (-3,4) | [(0,0),(6,6)] | (0.5,0.5)
|
||||
| (5.1,34.5) | [(0,0),(6,6)] | (6,6)
|
||||
| (-5,-12) | [(0,0),(6,6)] | (0,0)
|
||||
| (10,10) | [(0,0),(6,6)] | (6,6)
|
||||
| (0,0) | [(10,-10),(-3,-4)] | (-2.04878048780488,-4.4390243902439)
|
||||
| (-10,0) | [(10,-10),(-3,-4)] | (-3,-4)
|
||||
| (-3,4) | [(10,-10),(-3,-4)] | (-3,-4)
|
||||
| (5.1,34.5) | [(10,-10),(-3,-4)] | (-3,-4)
|
||||
| (-5,-12) | [(10,-10),(-3,-4)] | (-1.60487804878049,-4.64390243902439)
|
||||
| (10,10) | [(10,-10),(-3,-4)] | (2.39024390243902,-6.48780487804878)
|
||||
| (0,0) | [(-1000000,200),(300000,-40)] | (0.0028402365895872,15.384614860264)
|
||||
| (-10,0) | [(-1000000,200),(300000,-40)] | (-9.99715942258202,15.3864610140472)
|
||||
| (-3,4) | [(-1000000,200),(300000,-40)] | (-2.99789812267519,15.3851688427303)
|
||||
| (5.1,34.5) | [(-1000000,200),(300000,-40)] | (5.09647083221496,15.3836744976925)
|
||||
| (-5,-12) | [(-1000000,200),(300000,-40)] | (-4.99494420845634,15.3855375281616)
|
||||
| (10,10) | [(-1000000,200),(300000,-40)] | (10.000993741978,15.3827690473092)
|
||||
| (0,0) | [(11,22),(33,44)] | (11,22)
|
||||
| (-10,0) | [(11,22),(33,44)] | (11,22)
|
||||
| (-3,4) | [(11,22),(33,44)] | (11,22)
|
||||
| (5.1,34.5) | [(11,22),(33,44)] | (14.3,25.3)
|
||||
| (-5,-12) | [(11,22),(33,44)] | (11,22)
|
||||
| (10,10) | [(11,22),(33,44)] | (11,22)
|
||||
(30 rows)
|
||||
|
||||
--
|
||||
-- Lines
|
||||
--
|
||||
--
|
||||
-- Boxes
|
||||
--
|
||||
SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL;
|
||||
six | box
|
||||
-----+----------------------------------------------------------------------------
|
||||
| (2.12132034355964,2.12132034355964),(-2.12132034355964,-2.12132034355964)
|
||||
| (71.7106781186548,72.7106781186548),(-69.7106781186548,-68.7106781186548)
|
||||
| (4.53553390593274,6.53553390593274),(-2.53553390593274,-0.535533905932738)
|
||||
| (3.12132034355964,4.12132034355964),(-1.12132034355964,-0.121320343559643)
|
||||
| (107.071067811865,207.071067811865),(92.9289321881345,192.928932188135)
|
||||
| (170.710678118655,70.7106781186548),(29.2893218813452,-70.7106781186548)
|
||||
(6 rows)
|
||||
|
||||
-- translation
|
||||
SELECT '' AS twentyfour, b.f1 + p.f1 AS translation
|
||||
FROM BOX_TBL b, POINT_TBL p;
|
||||
twentyfour | translation
|
||||
------------+-------------------------
|
||||
| (2,2),(0,0)
|
||||
| (-8,2),(-10,0)
|
||||
| (-1,6),(-3,4)
|
||||
| (7.1,36.5),(5.1,34.5)
|
||||
| (-3,-10),(-5,-12)
|
||||
| (12,12),(10,10)
|
||||
| (3,3),(1,1)
|
||||
| (-7,3),(-9,1)
|
||||
| (0,7),(-2,5)
|
||||
| (8.1,37.5),(6.1,35.5)
|
||||
| (-2,-9),(-4,-11)
|
||||
| (13,13),(11,11)
|
||||
| (2.5,3.5),(2.5,2.5)
|
||||
| (-7.5,3.5),(-7.5,2.5)
|
||||
| (-0.5,7.5),(-0.5,6.5)
|
||||
| (7.6,38),(7.6,37)
|
||||
| (-2.5,-8.5),(-2.5,-9.5)
|
||||
| (12.5,13.5),(12.5,12.5)
|
||||
| (3,3),(3,3)
|
||||
| (-7,3),(-7,3)
|
||||
| (0,7),(0,7)
|
||||
| (8.1,37.5),(8.1,37.5)
|
||||
| (-2,-9),(-2,-9)
|
||||
| (13,13),(13,13)
|
||||
(24 rows)
|
||||
|
||||
SELECT '' AS twentyfour, b.f1 - p.f1 AS translation
|
||||
FROM BOX_TBL b, POINT_TBL p;
|
||||
twentyfour | translation
|
||||
------------+---------------------------
|
||||
| (2,2),(0,0)
|
||||
| (12,2),(10,0)
|
||||
| (5,-2),(3,-4)
|
||||
| (-3.1,-32.5),(-5.1,-34.5)
|
||||
| (7,14),(5,12)
|
||||
| (-8,-8),(-10,-10)
|
||||
| (3,3),(1,1)
|
||||
| (13,3),(11,1)
|
||||
| (6,-1),(4,-3)
|
||||
| (-2.1,-31.5),(-4.1,-33.5)
|
||||
| (8,15),(6,13)
|
||||
| (-7,-7),(-9,-9)
|
||||
| (2.5,3.5),(2.5,2.5)
|
||||
| (12.5,3.5),(12.5,2.5)
|
||||
| (5.5,-0.5),(5.5,-1.5)
|
||||
| (-2.6,-31),(-2.6,-32)
|
||||
| (7.5,15.5),(7.5,14.5)
|
||||
| (-7.5,-6.5),(-7.5,-7.5)
|
||||
| (3,3),(3,3)
|
||||
| (13,3),(13,3)
|
||||
| (6,-1),(6,-1)
|
||||
| (-2.1,-31.5),(-2.1,-31.5)
|
||||
| (8,15),(8,15)
|
||||
| (-7,-7),(-7,-7)
|
||||
(24 rows)
|
||||
|
||||
-- scaling and rotation
|
||||
SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation
|
||||
FROM BOX_TBL b, POINT_TBL p;
|
||||
twentyfour | rotation
|
||||
------------+-----------------------------
|
||||
| (0,0),(0,0)
|
||||
| (-0,0),(-20,-20)
|
||||
| (-0,2),(-14,0)
|
||||
| (0,79.2),(-58.8,0)
|
||||
| (14,-0),(0,-34)
|
||||
| (0,40),(0,0)
|
||||
| (0,0),(0,0)
|
||||
| (-10,-10),(-30,-30)
|
||||
| (-7,3),(-21,1)
|
||||
| (-29.4,118.8),(-88.2,39.6)
|
||||
| (21,-17),(7,-51)
|
||||
| (0,60),(0,20)
|
||||
| (0,0),(0,0)
|
||||
| (-25,-25),(-25,-35)
|
||||
| (-17.5,2.5),(-21.5,-0.5)
|
||||
| (-73.5,104.1),(-108,99)
|
||||
| (29.5,-42.5),(17.5,-47.5)
|
||||
| (0,60),(-10,50)
|
||||
| (0,0),(0,0)
|
||||
| (-30,-30),(-30,-30)
|
||||
| (-21,3),(-21,3)
|
||||
| (-88.2,118.8),(-88.2,118.8)
|
||||
| (21,-51),(21,-51)
|
||||
| (0,60),(0,60)
|
||||
(24 rows)
|
||||
|
||||
SELECT '' AS twenty, b.f1 / p.f1 AS rotation
|
||||
FROM BOX_TBL b, POINT_TBL p
|
||||
WHERE (p.f1 <-> point '(0,0)') >= 1;
|
||||
twenty | rotation
|
||||
--------+-----------------------------------------------------------------------------------
|
||||
| (0,-0),(-0.2,-0.2)
|
||||
| (-0.1,-0.1),(-0.3,-0.3)
|
||||
| (-0.25,-0.25),(-0.25,-0.35)
|
||||
| (-0.3,-0.3),(-0.3,-0.3)
|
||||
| (0.08,-0),(0,-0.56)
|
||||
| (0.12,-0.28),(0.04,-0.84)
|
||||
| (0.26,-0.7),(0.1,-0.82)
|
||||
| (0.12,-0.84),(0.12,-0.84)
|
||||
| (0.0651176557643925,0),(0,-0.0483449262493217)
|
||||
| (0.0976764836465887,-0.0241724631246608),(0.0325588278821962,-0.0725173893739825)
|
||||
| (0.109762715208919,-0.0562379754328844),(0.0813970697054906,-0.0604311578116521)
|
||||
| (0.0976764836465887,-0.0725173893739825),(0.0976764836465887,-0.0725173893739825)
|
||||
| (-0,0.0828402366863905),(-0.201183431952663,0)
|
||||
| (-0.100591715976331,0.124260355029586),(-0.301775147928994,0.0414201183431953)
|
||||
| (-0.251479289940828,0.103550295857988),(-0.322485207100592,0.0739644970414201)
|
||||
| (-0.301775147928994,0.124260355029586),(-0.301775147928994,0.124260355029586)
|
||||
| (0.2,0),(0,0)
|
||||
| (0.3,0),(0.1,0)
|
||||
| (0.3,0.05),(0.25,0)
|
||||
| (0.3,0),(0.3,0)
|
||||
(20 rows)
|
||||
|
||||
--
|
||||
-- Paths
|
||||
--
|
||||
SET geqo TO 'off';
|
||||
SELECT '' AS eight, npoints(f1) AS npoints, f1 AS path FROM PATH_TBL;
|
||||
eight | npoints | path
|
||||
-------+---------+---------------------------
|
||||
| 2 | [(1,2),(3,4)]
|
||||
| 2 | ((1,2),(3,4))
|
||||
| 4 | [(0,0),(3,0),(4,5),(1,6)]
|
||||
| 2 | ((1,2),(3,4))
|
||||
| 2 | ((1,2),(3,4))
|
||||
| 2 | [(1,2),(3,4)]
|
||||
| 2 | [(11,12),(13,14)]
|
||||
| 2 | ((11,12),(13,14))
|
||||
(8 rows)
|
||||
|
||||
SELECT '' AS four, path(f1) FROM POLYGON_TBL;
|
||||
four | path
|
||||
------+---------------------
|
||||
| ((2,0),(2,4),(0,0))
|
||||
| ((3,1),(3,3),(1,0))
|
||||
| ((0,0))
|
||||
| ((0,1),(0,1))
|
||||
(4 rows)
|
||||
|
||||
-- translation
|
||||
SELECT '' AS eight, p1.f1 + point '(10,10)' AS dist_add
|
||||
FROM PATH_TBL p1;
|
||||
eight | dist_add
|
||||
-------+-----------------------------------
|
||||
| [(11,12),(13,14)]
|
||||
| ((11,12),(13,14))
|
||||
| [(10,10),(13,10),(14,15),(11,16)]
|
||||
| ((11,12),(13,14))
|
||||
| ((11,12),(13,14))
|
||||
| [(11,12),(13,14)]
|
||||
| [(21,22),(23,24)]
|
||||
| ((21,22),(23,24))
|
||||
(8 rows)
|
||||
|
||||
-- scaling and rotation
|
||||
SELECT '' AS eight, p1.f1 * point '(2,-1)' AS dist_mul
|
||||
FROM PATH_TBL p1;
|
||||
eight | dist_mul
|
||||
-------+------------------------------
|
||||
| [(4,3),(10,5)]
|
||||
| ((4,3),(10,5))
|
||||
| [(0,0),(6,-3),(13,6),(8,11)]
|
||||
| ((4,3),(10,5))
|
||||
| ((4,3),(10,5))
|
||||
| [(4,3),(10,5)]
|
||||
| [(34,13),(40,15)]
|
||||
| ((34,13),(40,15))
|
||||
(8 rows)
|
||||
|
||||
RESET geqo;
|
||||
--
|
||||
-- Polygons
|
||||
--
|
||||
-- containment
|
||||
SELECT '' AS twentyfour, p.f1, poly.f1, poly.f1 ~ p.f1 AS contains
|
||||
FROM POLYGON_TBL poly, POINT_TBL p;
|
||||
twentyfour | f1 | f1 | contains
|
||||
------------+------------+---------------------+----------
|
||||
| (0,0) | ((2,0),(2,4),(0,0)) | t
|
||||
| (-10,0) | ((2,0),(2,4),(0,0)) | f
|
||||
| (-3,4) | ((2,0),(2,4),(0,0)) | f
|
||||
| (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
|
||||
| (-5,-12) | ((2,0),(2,4),(0,0)) | f
|
||||
| (10,10) | ((2,0),(2,4),(0,0)) | f
|
||||
| (0,0) | ((3,1),(3,3),(1,0)) | f
|
||||
| (-10,0) | ((3,1),(3,3),(1,0)) | f
|
||||
| (-3,4) | ((3,1),(3,3),(1,0)) | f
|
||||
| (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
|
||||
| (-5,-12) | ((3,1),(3,3),(1,0)) | f
|
||||
| (10,10) | ((3,1),(3,3),(1,0)) | f
|
||||
| (0,0) | ((0,0)) | t
|
||||
| (-10,0) | ((0,0)) | f
|
||||
| (-3,4) | ((0,0)) | f
|
||||
| (5.1,34.5) | ((0,0)) | f
|
||||
| (-5,-12) | ((0,0)) | f
|
||||
| (10,10) | ((0,0)) | f
|
||||
| (0,0) | ((0,1),(0,1)) | f
|
||||
| (-10,0) | ((0,1),(0,1)) | f
|
||||
| (-3,4) | ((0,1),(0,1)) | f
|
||||
| (5.1,34.5) | ((0,1),(0,1)) | f
|
||||
| (-5,-12) | ((0,1),(0,1)) | f
|
||||
| (10,10) | ((0,1),(0,1)) | f
|
||||
(24 rows)
|
||||
|
||||
SELECT '' AS twentyfour, p.f1, poly.f1, p.f1 @ poly.f1 AS contained
|
||||
FROM POLYGON_TBL poly, POINT_TBL p;
|
||||
twentyfour | f1 | f1 | contained
|
||||
------------+------------+---------------------+-----------
|
||||
| (0,0) | ((2,0),(2,4),(0,0)) | t
|
||||
| (-10,0) | ((2,0),(2,4),(0,0)) | f
|
||||
| (-3,4) | ((2,0),(2,4),(0,0)) | f
|
||||
| (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
|
||||
| (-5,-12) | ((2,0),(2,4),(0,0)) | f
|
||||
| (10,10) | ((2,0),(2,4),(0,0)) | f
|
||||
| (0,0) | ((3,1),(3,3),(1,0)) | f
|
||||
| (-10,0) | ((3,1),(3,3),(1,0)) | f
|
||||
| (-3,4) | ((3,1),(3,3),(1,0)) | f
|
||||
| (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
|
||||
| (-5,-12) | ((3,1),(3,3),(1,0)) | f
|
||||
| (10,10) | ((3,1),(3,3),(1,0)) | f
|
||||
| (0,0) | ((0,0)) | t
|
||||
| (-10,0) | ((0,0)) | f
|
||||
| (-3,4) | ((0,0)) | f
|
||||
| (5.1,34.5) | ((0,0)) | f
|
||||
| (-5,-12) | ((0,0)) | f
|
||||
| (10,10) | ((0,0)) | f
|
||||
| (0,0) | ((0,1),(0,1)) | f
|
||||
| (-10,0) | ((0,1),(0,1)) | f
|
||||
| (-3,4) | ((0,1),(0,1)) | f
|
||||
| (5.1,34.5) | ((0,1),(0,1)) | f
|
||||
| (-5,-12) | ((0,1),(0,1)) | f
|
||||
| (10,10) | ((0,1),(0,1)) | f
|
||||
(24 rows)
|
||||
|
||||
SELECT '' AS four, npoints(f1) AS npoints, f1 AS polygon
|
||||
FROM POLYGON_TBL;
|
||||
four | npoints | polygon
|
||||
------+---------+---------------------
|
||||
| 3 | ((2,0),(2,4),(0,0))
|
||||
| 3 | ((3,1),(3,3),(1,0))
|
||||
| 1 | ((0,0))
|
||||
| 2 | ((0,1),(0,1))
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, polygon(f1)
|
||||
FROM BOX_TBL;
|
||||
four | polygon
|
||||
------+-------------------------------------------
|
||||
| ((0,0),(0,2),(2,2),(2,0))
|
||||
| ((1,1),(1,3),(3,3),(3,1))
|
||||
| ((2.5,2.5),(2.5,3.5),(2.5,3.5),(2.5,2.5))
|
||||
| ((3,3),(3,3),(3,3),(3,3))
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, polygon(f1)
|
||||
FROM PATH_TBL WHERE isclosed(f1);
|
||||
four | polygon
|
||||
------+-------------------
|
||||
| ((1,2),(3,4))
|
||||
| ((1,2),(3,4))
|
||||
| ((1,2),(3,4))
|
||||
| ((11,12),(13,14))
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, f1 AS open_path, polygon( pclose(f1)) AS polygon
|
||||
FROM PATH_TBL
|
||||
WHERE isopen(f1);
|
||||
four | open_path | polygon
|
||||
------+---------------------------+---------------------------
|
||||
| [(1,2),(3,4)] | ((1,2),(3,4))
|
||||
| [(0,0),(3,0),(4,5),(1,6)] | ((0,0),(3,0),(4,5),(1,6))
|
||||
| [(1,2),(3,4)] | ((1,2),(3,4))
|
||||
| [(11,12),(13,14)] | ((11,12),(13,14))
|
||||
(4 rows)
|
||||
|
||||
-- convert circles to polygons using the default number of points
|
||||
SELECT '' AS six, polygon(f1)
|
||||
FROM CIRCLE_TBL;
|
||||
six | polygon
|
||||
-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
| ((-3,0),(-2.59807621135332,1.5),(-1.5,2.59807621135332),(-1.83690953073357e-16,3),(1.5,2.59807621135332),(2.59807621135332,1.5),(3,3.67381906146713e-16),(2.59807621135332,-1.5),(1.5,-2.59807621135332),(5.5107285922007e-16,-3),(-1.5,-2.59807621135332),(-2.59807621135332,-1.5))
|
||||
| ((-99,2),(-85.6025403784439,52),(-49,88.6025403784439),(0.999999999999994,102),(51,88.6025403784439),(87.6025403784439,52),(101,2.00000000000001),(87.6025403784439,-48),(51,-84.6025403784438),(1.00000000000002,-98),(-49,-84.6025403784439),(-85.6025403784438,-48))
|
||||
| ((-4,3),(-3.33012701892219,5.5),(-1.5,7.33012701892219),(1,8),(3.5,7.33012701892219),(5.33012701892219,5.5),(6,3),(5.33012701892219,0.500000000000001),(3.5,-1.33012701892219),(1,-2),(-1.5,-1.33012701892219),(-3.33012701892219,0.499999999999998))
|
||||
| ((-2,2),(-1.59807621135332,3.5),(-0.5,4.59807621135332),(1,5),(2.5,4.59807621135332),(3.59807621135332,3.5),(4,2),(3.59807621135332,0.500000000000001),(2.5,-0.598076211353315),(1,-1),(-0.5,-0.598076211353316),(-1.59807621135332,0.499999999999999))
|
||||
| ((90,200),(91.3397459621556,205),(95,208.660254037844),(100,210),(105,208.660254037844),(108.660254037844,205),(110,200),(108.660254037844,195),(105,191.339745962156),(100,190),(95,191.339745962156),(91.3397459621556,195))
|
||||
| ((0,0),(13.3974596215561,50),(50,86.6025403784439),(100,100),(150,86.6025403784439),(186.602540378444,50),(200,1.22460635382238e-14),(186.602540378444,-50),(150,-86.6025403784438),(100,-100),(50,-86.6025403784439),(13.3974596215562,-50))
|
||||
(6 rows)
|
||||
|
||||
-- convert the circle to an 8-point polygon
|
||||
SELECT '' AS six, polygon(8, f1)
|
||||
FROM CIRCLE_TBL;
|
||||
six | polygon
|
||||
-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
| ((-3,0),(-2.12132034355964,2.12132034355964),(-1.83690953073357e-16,3),(2.12132034355964,2.12132034355964),(3,3.67381906146713e-16),(2.12132034355964,-2.12132034355964),(5.5107285922007e-16,-3),(-2.12132034355964,-2.12132034355964))
|
||||
| ((-99,2),(-69.7106781186548,72.7106781186548),(0.999999999999994,102),(71.7106781186547,72.7106781186548),(101,2.00000000000001),(71.7106781186548,-68.7106781186547),(1.00000000000002,-98),(-69.7106781186547,-68.7106781186548))
|
||||
| ((-4,3),(-2.53553390593274,6.53553390593274),(1,8),(4.53553390593274,6.53553390593274),(6,3),(4.53553390593274,-0.535533905932737),(1,-2),(-2.53553390593274,-0.535533905932738))
|
||||
| ((-2,2),(-1.12132034355964,4.12132034355964),(1,5),(3.12132034355964,4.12132034355964),(4,2),(3.12132034355964,-0.121320343559642),(1,-1),(-1.12132034355964,-0.121320343559643))
|
||||
| ((90,200),(92.9289321881345,207.071067811865),(100,210),(107.071067811865,207.071067811865),(110,200),(107.071067811865,192.928932188135),(100,190),(92.9289321881345,192.928932188135))
|
||||
| ((0,0),(29.2893218813452,70.7106781186548),(100,100),(170.710678118655,70.7106781186548),(200,1.22460635382238e-14),(170.710678118655,-70.7106781186547),(100,-100),(29.2893218813453,-70.7106781186548))
|
||||
(6 rows)
|
||||
|
||||
--
|
||||
-- Circles
|
||||
--
|
||||
SELECT '' AS six, circle(f1, 50.0)
|
||||
FROM POINT_TBL;
|
||||
six | circle
|
||||
-----+-----------------
|
||||
| <(0,0),50>
|
||||
| <(-10,0),50>
|
||||
| <(-3,4),50>
|
||||
| <(5.1,34.5),50>
|
||||
| <(-5,-12),50>
|
||||
| <(10,10),50>
|
||||
(6 rows)
|
||||
|
||||
SELECT '' AS four, circle(f1)
|
||||
FROM BOX_TBL;
|
||||
four | circle
|
||||
------+-------------------------
|
||||
| <(1,1),1.4142135623731>
|
||||
| <(2,2),1.4142135623731>
|
||||
| <(2.5,3),0.5>
|
||||
| <(3,3),0>
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS two, circle(f1)
|
||||
FROM POLYGON_TBL
|
||||
WHERE (# f1) >= 3;
|
||||
two | circle
|
||||
-----+--------------------------------------------------------
|
||||
| <(1.33333333333333,1.33333333333333),2.04168905063636>
|
||||
| <(2.33333333333333,1.33333333333333),1.47534300379185>
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS distance
|
||||
FROM CIRCLE_TBL c1, POINT_TBL p1
|
||||
WHERE (p1.f1 <-> c1.f1) > 0
|
||||
ORDER BY distance, circle, point using <<;
|
||||
twentyfour | circle | point | distance
|
||||
------------+----------------+------------+-------------------
|
||||
| <(100,0),100> | (5.1,34.5) | 0.976531926977964
|
||||
| <(1,2),3> | (-3,4) | 1.47213595499958
|
||||
| <(0,0),3> | (-3,4) | 2
|
||||
| <(100,0),100> | (-3,4) | 3.07764064044151
|
||||
| <(100,0),100> | (-5,-12) | 5.68348972285122
|
||||
| <(1,3),5> | (-10,0) | 6.40175425099138
|
||||
| <(1,3),5> | (10,10) | 6.40175425099138
|
||||
| <(0,0),3> | (-10,0) | 7
|
||||
| <(1,2),3> | (-10,0) | 8.18033988749895
|
||||
| <(1,2),3> | (10,10) | 9.0415945787923
|
||||
| <(0,0),3> | (-5,-12) | 10
|
||||
| <(100,0),100> | (-10,0) | 10
|
||||
| <(0,0),3> | (10,10) | 11.142135623731
|
||||
| <(1,3),5> | (-5,-12) | 11.1554944214035
|
||||
| <(1,2),3> | (-5,-12) | 12.2315462117278
|
||||
| <(1,3),5> | (5.1,34.5) | 26.7657047773224
|
||||
| <(1,2),3> | (5.1,34.5) | 29.757594539282
|
||||
| <(0,0),3> | (5.1,34.5) | 31.8749193547455
|
||||
| <(100,200),10> | (5.1,34.5) | 180.778038568384
|
||||
| <(100,200),10> | (10,10) | 200.237960416286
|
||||
| <(100,200),10> | (-3,4) | 211.415898254845
|
||||
| <(100,200),10> | (0,0) | 213.606797749979
|
||||
| <(100,200),10> | (-10,0) | 218.254244210267
|
||||
| <(100,200),10> | (-5,-12) | 226.577682802077
|
||||
(24 rows)
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
--
|
||||
-- INT2
|
||||
-- NOTE: int2 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT2_TBL(f1 int2);
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('32767');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('100000');
|
||||
ERROR: pg_atoi: error reading "100000": Range Error
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT2_TBL.*;
|
||||
five | f1
|
||||
------+--------
|
||||
| 0
|
||||
| 1234
|
||||
| -1234
|
||||
| 32767
|
||||
| -32767
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
|
||||
four | f1
|
||||
------+--------
|
||||
| 1234
|
||||
| -1234
|
||||
| 32767
|
||||
| -32767
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+--------
|
||||
| 1234
|
||||
| -1234
|
||||
| 32767
|
||||
| -32767
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| 32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| 32767
|
||||
(3 rows)
|
||||
|
||||
-- positive odds
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
|
||||
one | f1
|
||||
-----+-------
|
||||
| 32767
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| -1234
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | 0
|
||||
| 1234 | 2468
|
||||
| -1234 | -2468
|
||||
| 32767 | -2
|
||||
| -32767 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 0
|
||||
| 1234 | 2468
|
||||
| -1234 | -2468
|
||||
| 32767 | 65534
|
||||
| -32767 | -65534
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 2
|
||||
| 1234 | 1236
|
||||
| -1234 | -1232
|
||||
| 32767 | -32767
|
||||
| -32767 | -32765
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 2
|
||||
| 1234 | 1236
|
||||
| -1234 | -1232
|
||||
| 32767 | 32769
|
||||
| -32767 | -32765
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | -2
|
||||
| 1234 | 1232
|
||||
| -1234 | -1236
|
||||
| 32767 | 32765
|
||||
| -32767 | 32767
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | -2
|
||||
| 1234 | 1232
|
||||
| -1234 | -1236
|
||||
| 32767 | 32765
|
||||
| -32767 | -32769
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 0
|
||||
| 1234 | 617
|
||||
| -1234 | -617
|
||||
| 32767 | 16383
|
||||
| -32767 | -16383
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 0
|
||||
| 1234 | 617
|
||||
| -1234 | -617
|
||||
| 32767 | 16383
|
||||
| -32767 | -16383
|
||||
(5 rows)
|
||||
|
|
@ -0,0 +1,297 @@
|
|||
--
|
||||
-- INT4
|
||||
-- WARNING: int4 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT4_TBL(f1 int4);
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('2147483647');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-2147483647');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
|
||||
ERROR: pg_atoi: error reading "1000000000000": Range Error
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT4_TBL.*;
|
||||
five | f1
|
||||
------+-------------
|
||||
| 0
|
||||
| 123456
|
||||
| -123456
|
||||
| 2147483647
|
||||
| -2147483647
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0';
|
||||
four | f1
|
||||
------+-------------
|
||||
| 123456
|
||||
| -123456
|
||||
| 2147483647
|
||||
| -2147483647
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+-------------
|
||||
| 123456
|
||||
| -123456
|
||||
| 2147483647
|
||||
| -2147483647
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+------------
|
||||
| 0
|
||||
| 123456
|
||||
| 2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | f1
|
||||
-------+------------
|
||||
| 0
|
||||
| 123456
|
||||
| 2147483647
|
||||
(3 rows)
|
||||
|
||||
-- positive odds
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
|
||||
one | f1
|
||||
-----+------------
|
||||
| 2147483647
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+---------
|
||||
| 0
|
||||
| 123456
|
||||
| -123456
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 0
|
||||
| 123456 | 61728
|
||||
| -123456 | -61728
|
||||
| 2147483647 | 1073741823
|
||||
| -2147483647 | -1073741823
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 0
|
||||
| 123456 | 61728
|
||||
| -123456 | -61728
|
||||
| 2147483647 | 1073741823
|
||||
| -2147483647 | -1073741823
|
||||
(5 rows)
|
||||
|
||||
--
|
||||
-- more complex expressions
|
||||
--
|
||||
-- variations on unary minus parsing
|
||||
SELECT -2+3 AS one;
|
||||
one
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT 4-2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT 2- -1 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT 2 - -2 AS four;
|
||||
four
|
||||
------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int2 '2' = int2 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '2' * int2 '2' = int2 '16' / int4 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '1000' < int4 '999' AS false;
|
||||
false
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT 4! AS twenty_four;
|
||||
twenty_four
|
||||
-------------
|
||||
24
|
||||
(1 row)
|
||||
|
||||
SELECT !!3 AS six;
|
||||
six
|
||||
-----
|
||||
6
|
||||
(1 row)
|
||||
|
||||
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
|
||||
ten
|
||||
-----
|
||||
10
|
||||
(1 row)
|
||||
|
||||
SELECT 2 + 2 / 2 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT (2 + 2) / 2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
|
@ -1084,179 +1084,8 @@ SELECT * FROM shoelace ORDER BY sl_name;
|
|||
(8 rows)
|
||||
|
||||
insert into shoelace_ok select * from shoelace_arrive;
|
||||
SELECT * FROM shoelace ORDER BY sl_name;
|
||||
sl_name | sl_avail | sl_color | sl_len | sl_unit | sl_len_cm
|
||||
------------+----------+------------+--------+----------+-----------
|
||||
sl1 | 5 | black | 80 | cm | 80
|
||||
sl2 | 6 | black | 100 | cm | 100
|
||||
sl3 | 10 | black | 35 | inch | 88.9
|
||||
sl4 | 8 | black | 40 | inch | 101.6
|
||||
sl5 | 4 | brown | 1 | m | 100
|
||||
sl6 | 20 | brown | 0.9 | m | 90
|
||||
sl7 | 6 | brown | 60 | cm | 60
|
||||
sl8 | 21 | brown | 40 | inch | 101.6
|
||||
(8 rows)
|
||||
|
||||
SELECT * FROM shoelace_log ORDER BY sl_name;
|
||||
sl_name | sl_avail | log_who | log_when
|
||||
------------+----------+----------+----------
|
||||
sl3 | 10 | Al Bundy | epoch
|
||||
sl6 | 20 | Al Bundy | epoch
|
||||
sl7 | 6 | Al Bundy | epoch
|
||||
sl8 | 21 | Al Bundy | epoch
|
||||
(4 rows)
|
||||
|
||||
CREATE VIEW shoelace_obsolete AS
|
||||
SELECT * FROM shoelace WHERE NOT EXISTS
|
||||
(SELECT shoename FROM shoe WHERE slcolor = sl_color);
|
||||
CREATE VIEW shoelace_candelete AS
|
||||
SELECT * FROM shoelace_obsolete WHERE sl_avail = 0;
|
||||
insert into shoelace values ('sl9', 0, 'pink', 35.0, 'inch', 0.0);
|
||||
insert into shoelace values ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0);
|
||||
SELECT * FROM shoelace_obsolete;
|
||||
sl_name | sl_avail | sl_color | sl_len | sl_unit | sl_len_cm
|
||||
------------+----------+------------+--------+----------+-----------
|
||||
sl9 | 0 | pink | 35 | inch | 88.9
|
||||
sl10 | 1000 | magenta | 40 | inch | 101.6
|
||||
(2 rows)
|
||||
|
||||
SELECT * FROM shoelace_candelete;
|
||||
sl_name | sl_avail | sl_color | sl_len | sl_unit | sl_len_cm
|
||||
------------+----------+------------+--------+----------+-----------
|
||||
sl9 | 0 | pink | 35 | inch | 88.9
|
||||
(1 row)
|
||||
|
||||
DELETE FROM shoelace WHERE EXISTS
|
||||
(SELECT * FROM shoelace_candelete
|
||||
WHERE sl_name = shoelace.sl_name);
|
||||
SELECT * FROM shoelace ORDER BY sl_name;
|
||||
sl_name | sl_avail | sl_color | sl_len | sl_unit | sl_len_cm
|
||||
------------+----------+------------+--------+----------+-----------
|
||||
sl1 | 5 | black | 80 | cm | 80
|
||||
sl10 | 1000 | magenta | 40 | inch | 101.6
|
||||
sl2 | 6 | black | 100 | cm | 100
|
||||
sl3 | 10 | black | 35 | inch | 88.9
|
||||
sl4 | 8 | black | 40 | inch | 101.6
|
||||
sl5 | 4 | brown | 1 | m | 100
|
||||
sl6 | 20 | brown | 0.9 | m | 90
|
||||
sl7 | 6 | brown | 60 | cm | 60
|
||||
sl8 | 21 | brown | 40 | inch | 101.6
|
||||
(9 rows)
|
||||
|
||||
SELECT * FROM shoe ORDER BY shoename;
|
||||
shoename | sh_avail | slcolor | slminlen | slminlen_cm | slmaxlen | slmaxlen_cm | slunit
|
||||
------------+----------+------------+----------+-------------+----------+-------------+----------
|
||||
sh1 | 2 | black | 70 | 70 | 90 | 90 | cm
|
||||
sh2 | 0 | black | 30 | 76.2 | 40 | 101.6 | inch
|
||||
sh3 | 4 | brown | 50 | 50 | 65 | 65 | cm
|
||||
sh4 | 3 | brown | 40 | 101.6 | 50 | 127 | inch
|
||||
(4 rows)
|
||||
|
||||
SELECT count(*) FROM shoe;
|
||||
count
|
||||
-------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
--
|
||||
-- Simple test of qualified ON INSERT ... this did not work in 7.0 ...
|
||||
--
|
||||
create table foo (f1 int);
|
||||
create table foo2 (f1 int);
|
||||
create rule foorule as on insert to foo where f1 < 100
|
||||
do instead nothing;
|
||||
insert into foo values(1);
|
||||
insert into foo values(1001);
|
||||
select * from foo;
|
||||
f1
|
||||
------
|
||||
1001
|
||||
(1 row)
|
||||
|
||||
drop rule foorule;
|
||||
-- this should fail because f1 is not exposed for unqualified reference:
|
||||
create rule foorule as on insert to foo where f1 < 100
|
||||
do instead insert into foo2 values (f1);
|
||||
ERROR: Attribute 'f1' not found
|
||||
-- this is the correct way:
|
||||
create rule foorule as on insert to foo where f1 < 100
|
||||
do instead insert into foo2 values (new.f1);
|
||||
insert into foo values(2);
|
||||
insert into foo values(100);
|
||||
select * from foo;
|
||||
f1
|
||||
------
|
||||
1001
|
||||
100
|
||||
(2 rows)
|
||||
|
||||
select * from foo2;
|
||||
f1
|
||||
----
|
||||
2
|
||||
(1 row)
|
||||
|
||||
drop rule foorule;
|
||||
drop table foo;
|
||||
drop table foo2;
|
||||
--
|
||||
-- Check that ruleutils are working
|
||||
--
|
||||
SELECT viewname, definition FROM pg_views ORDER BY viewname;
|
||||
viewname | definition
|
||||
--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
iexit | SELECT ih.name, ih.thepath, interpt_pp(ih.thepath, r.thepath) AS exit FROM ihighway ih, ramp r WHERE (ih.thepath ## r.thepath);
|
||||
pg_indexes | SELECT c.relname AS tablename, i.relname AS indexname, pg_get_indexdef(x.indexrelid) AS indexdef FROM pg_index x, pg_class c, pg_class i WHERE ((c.oid = x.indrelid) AND (i.oid = x.indexrelid));
|
||||
pg_rules | SELECT c.relname AS tablename, r.rulename, pg_get_ruledef(r.rulename) AS definition FROM pg_rewrite r, pg_class c WHERE ((r.rulename !~ '^_RET'::text) AND (c.oid = r.ev_class));
|
||||
pg_tables | SELECT c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM pg_class c WHERE (((c.relkind = 'r'::"char") OR (c.relkind = 's'::"char")) AND (NOT (EXISTS (SELECT pg_rewrite.rulename FROM pg_rewrite WHERE ((pg_rewrite.ev_class = c.oid) AND (pg_rewrite.ev_type = '1'::"char"))))));
|
||||
pg_user | SELECT pg_shadow.usename, pg_shadow.usesysid, pg_shadow.usecreatedb, pg_shadow.usetrace, pg_shadow.usesuper, pg_shadow.usecatupd, '********'::text AS passwd, pg_shadow.valuntil FROM pg_shadow;
|
||||
pg_views | SELECT c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.relname) AS definition FROM pg_class c WHERE (c.relhasrules AND (EXISTS (SELECT r.rulename FROM pg_rewrite r WHERE ((r.ev_class = c.oid) AND (r.ev_type = '1'::"char")))));
|
||||
rtest_v1 | SELECT rtest_t1.a, rtest_t1.b FROM rtest_t1;
|
||||
rtest_vcomp | SELECT x.part, (x.size * y.factor) AS size_in_cm FROM rtest_comp x, rtest_unitfact y WHERE (x.unit = y.unit);
|
||||
rtest_vview1 | SELECT x.a, x.b FROM rtest_view1 x WHERE (0 < (SELECT count(*) AS count FROM rtest_view2 y WHERE (y.a = x.a)));
|
||||
rtest_vview2 | SELECT rtest_view1.a, rtest_view1.b FROM rtest_view1 WHERE rtest_view1.v;
|
||||
rtest_vview3 | SELECT x.a, x.b FROM rtest_vview2 x WHERE (0 < (SELECT count(*) AS count FROM rtest_view2 y WHERE (y.a = x.a)));
|
||||
rtest_vview4 | SELECT x.a, x.b, count(y.a) AS refcount FROM rtest_view1 x, rtest_view2 y WHERE (x.a = y.a) GROUP BY x.a, x.b;
|
||||
rtest_vview5 | SELECT rtest_view1.a, rtest_view1.b, rtest_viewfunc1(rtest_view1.a) AS refcount FROM rtest_view1;
|
||||
shoe | SELECT sh.shoename, sh.sh_avail, sh.slcolor, sh.slminlen, (sh.slminlen * un.un_fact) AS slminlen_cm, sh.slmaxlen, (sh.slmaxlen * un.un_fact) AS slmaxlen_cm, sh.slunit FROM shoe_data sh, unit un WHERE (sh.slunit = un.un_name);
|
||||
shoe_ready | SELECT rsh.shoename, rsh.sh_avail, rsl.sl_name, rsl.sl_avail, int4smaller(rsh.sh_avail, rsl.sl_avail) AS total_avail FROM shoe rsh, shoelace rsl WHERE (((rsl.sl_color = rsh.slcolor) AND (rsl.sl_len_cm >= rsh.slminlen_cm)) AND (rsl.sl_len_cm <= rsh.slmaxlen_cm));
|
||||
shoelace | SELECT s.sl_name, s.sl_avail, s.sl_color, s.sl_len, s.sl_unit, (s.sl_len * u.un_fact) AS sl_len_cm FROM shoelace_data s, unit u WHERE (s.sl_unit = u.un_name);
|
||||
shoelace_candelete | SELECT shoelace_obsolete.sl_name, shoelace_obsolete.sl_avail, shoelace_obsolete.sl_color, shoelace_obsolete.sl_len, shoelace_obsolete.sl_unit, shoelace_obsolete.sl_len_cm FROM shoelace_obsolete WHERE (shoelace_obsolete.sl_avail = 0);
|
||||
shoelace_obsolete | SELECT shoelace.sl_name, shoelace.sl_avail, shoelace.sl_color, shoelace.sl_len, shoelace.sl_unit, shoelace.sl_len_cm FROM shoelace WHERE (NOT (EXISTS (SELECT shoe.shoename FROM shoe WHERE (shoe.slcolor = shoelace.sl_color))));
|
||||
street | SELECT r.name, r.thepath, c.cname FROM ONLY road r, real_city c WHERE (c.outline ## r.thepath);
|
||||
toyemp | SELECT emp.name, emp.age, emp."location", (12 * emp.salary) AS annualsal FROM emp;
|
||||
(20 rows)
|
||||
|
||||
SELECT tablename, rulename, definition FROM pg_rules
|
||||
ORDER BY tablename, rulename;
|
||||
tablename | rulename | definition
|
||||
---------------+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
rtest_emp | rtest_emp_del | CREATE RULE rtest_emp_del AS ON DELETE TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (old.ename, "current_user"(), 'fired '::bpchar, '$0.00'::money, old.salary);
|
||||
rtest_emp | rtest_emp_ins | CREATE RULE rtest_emp_ins AS ON INSERT TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (new.ename, "current_user"(), 'hired '::bpchar, new.salary, '$0.00'::money);
|
||||
rtest_emp | rtest_emp_upd | CREATE RULE rtest_emp_upd AS ON UPDATE TO rtest_emp WHERE (new.salary <> old.salary) DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (new.ename, "current_user"(), 'honored '::bpchar, new.salary, old.salary);
|
||||
rtest_nothn1 | rtest_nothn_r1 | CREATE RULE rtest_nothn_r1 AS ON INSERT TO rtest_nothn1 WHERE ((new.a >= 10) AND (new.a < 20)) DO INSTEAD SELECT 1;
|
||||
rtest_nothn1 | rtest_nothn_r2 | CREATE RULE rtest_nothn_r2 AS ON INSERT TO rtest_nothn1 WHERE ((new.a >= 30) AND (new.a < 40)) DO INSTEAD NOTHING;
|
||||
rtest_nothn2 | rtest_nothn_r3 | CREATE RULE rtest_nothn_r3 AS ON INSERT TO rtest_nothn2 WHERE (new.a >= 100) DO INSTEAD INSERT INTO rtest_nothn3 (a, b) VALUES (new.a, new.b);
|
||||
rtest_nothn2 | rtest_nothn_r4 | CREATE RULE rtest_nothn_r4 AS ON INSERT TO rtest_nothn2 DO INSTEAD NOTHING;
|
||||
rtest_order1 | rtest_order_r1 | CREATE RULE rtest_order_r1 AS ON INSERT TO rtest_order1 DO INSTEAD INSERT INTO rtest_order2 (a, b, c) VALUES (new.a, nextval('rtest_seq'::text), 'rule 1 - this should run 3rd or 4th'::text);
|
||||
rtest_order1 | rtest_order_r2 | CREATE RULE rtest_order_r2 AS ON INSERT TO rtest_order1 DO INSERT INTO rtest_order2 (a, b, c) VALUES (new.a, nextval('rtest_seq'::text), 'rule 2 - this should run 1st'::text);
|
||||
rtest_order1 | rtest_order_r3 | CREATE RULE rtest_order_r3 AS ON INSERT TO rtest_order1 DO INSTEAD INSERT INTO rtest_order2 (a, b, c) VALUES (new.a, nextval('rtest_seq'::text), 'rule 3 - this should run 3rd or 4th'::text);
|
||||
rtest_order1 | rtest_order_r4 | CREATE RULE rtest_order_r4 AS ON INSERT TO rtest_order1 WHERE (new.a < 100) DO INSTEAD INSERT INTO rtest_order2 (a, b, c) VALUES (new.a, nextval('rtest_seq'::text), 'rule 4 - this should run 2nd'::text);
|
||||
rtest_person | rtest_pers_del | CREATE RULE rtest_pers_del AS ON DELETE TO rtest_person DO DELETE FROM rtest_admin WHERE (rtest_admin.pname = old.pname);
|
||||
rtest_person | rtest_pers_upd | CREATE RULE rtest_pers_upd AS ON UPDATE TO rtest_person DO UPDATE rtest_admin SET pname = new.pname WHERE (rtest_admin.pname = old.pname);
|
||||
rtest_system | rtest_sys_del | CREATE RULE rtest_sys_del AS ON DELETE TO rtest_system DO (DELETE FROM rtest_interface WHERE (rtest_interface.sysname = old.sysname); DELETE FROM rtest_admin WHERE (rtest_admin.sysname = old.sysname); );
|
||||
rtest_system | rtest_sys_upd | CREATE RULE rtest_sys_upd AS ON UPDATE TO rtest_system DO (UPDATE rtest_interface SET sysname = new.sysname WHERE (rtest_interface.sysname = old.sysname); UPDATE rtest_admin SET sysname = new.sysname WHERE (rtest_admin.sysname = old.sysname); );
|
||||
rtest_t4 | rtest_t4_ins1 | CREATE RULE rtest_t4_ins1 AS ON INSERT TO rtest_t4 WHERE ((new.a >= 10) AND (new.a < 20)) DO INSTEAD INSERT INTO rtest_t5 (a, b) VALUES (new.a, new.b);
|
||||
rtest_t4 | rtest_t4_ins2 | CREATE RULE rtest_t4_ins2 AS ON INSERT TO rtest_t4 WHERE ((new.a >= 20) AND (new.a < 30)) DO INSERT INTO rtest_t6 (a, b) VALUES (new.a, new.b);
|
||||
rtest_t5 | rtest_t5_ins | CREATE RULE rtest_t5_ins AS ON INSERT TO rtest_t5 WHERE (new.a > 15) DO INSERT INTO rtest_t7 (a, b) VALUES (new.a, new.b);
|
||||
rtest_t6 | rtest_t6_ins | CREATE RULE rtest_t6_ins AS ON INSERT TO rtest_t6 WHERE (new.a > 25) DO INSTEAD INSERT INTO rtest_t8 (a, b) VALUES (new.a, new.b);
|
||||
rtest_v1 | rtest_v1_del | CREATE RULE rtest_v1_del AS ON DELETE TO rtest_v1 DO INSTEAD DELETE FROM rtest_t1 WHERE (rtest_t1.a = old.a);
|
||||
rtest_v1 | rtest_v1_ins | CREATE RULE rtest_v1_ins AS ON INSERT TO rtest_v1 DO INSTEAD INSERT INTO rtest_t1 (a, b) VALUES (new.a, new.b);
|
||||
rtest_v1 | rtest_v1_upd | CREATE RULE rtest_v1_upd AS ON UPDATE TO rtest_v1 DO INSTEAD UPDATE rtest_t1 SET a = new.a, b = new.b WHERE (rtest_t1.a = old.a);
|
||||
shoelace | shoelace_del | CREATE RULE shoelace_del AS ON DELETE TO shoelace DO INSTEAD DELETE FROM shoelace_data WHERE (shoelace_data.sl_name = old.sl_name);
|
||||
shoelace | shoelace_ins | CREATE RULE shoelace_ins AS ON INSERT TO shoelace DO INSTEAD INSERT INTO shoelace_data (sl_name, sl_avail, sl_color, sl_len, sl_unit) VALUES (new.sl_name, new.sl_avail, new.sl_color, new.sl_len, new.sl_unit);
|
||||
shoelace | shoelace_upd | CREATE RULE shoelace_upd AS ON UPDATE TO shoelace DO INSTEAD UPDATE shoelace_data SET sl_name = new.sl_name, sl_avail = new.sl_avail, sl_color = new.sl_color, sl_len = new.sl_len, sl_unit = new.sl_unit WHERE (shoelace_data.sl_name = old.sl_name);
|
||||
shoelace_data | log_shoelace | CREATE RULE log_shoelace AS ON UPDATE TO shoelace_data WHERE (new.sl_avail <> old.sl_avail) DO INSERT INTO shoelace_log (sl_name, sl_avail, log_who, log_when) VALUES (new.sl_name, new.sl_avail, 'Al Bundy'::name, "timestamp"('epoch'::text));
|
||||
shoelace_ok | shoelace_ok_ins | CREATE RULE shoelace_ok_ins AS ON INSERT TO shoelace_ok DO INSTEAD UPDATE shoelace SET sl_avail = (shoelace.sl_avail + new.ok_quant) WHERE (shoelace.sl_name = new.ok_name);
|
||||
(27 rows)
|
||||
|
||||
FATAL 1: The system is shutting down
|
||||
pqReadData() -- backend closed the channel unexpectedly.
|
||||
This probably means the backend terminated abnormally
|
||||
before or while processing the request.
|
||||
connection to server was lost
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.53 2000/09/29 17:17:37 petere Exp $
|
||||
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.54 2000/10/07 14:39:20 momjian Exp $
|
||||
#
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Syntax: $0 <hostname> [extra-tests]"
|
||||
|
@ -11,7 +11,7 @@ shift
|
|||
extratests="$*"
|
||||
|
||||
case $hostname in
|
||||
i*86-pc-cygwin* | i386-*-qnx*)
|
||||
i*86-pc-cygwin* | i386-*-qnx* | beos)
|
||||
HOSTLOC="-h localhost"
|
||||
;;
|
||||
*)
|
||||
|
|
Loading…
Reference in New Issue