From b2096a55121850ac6189081f682d3ced19aa8574 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Fri, 7 Apr 2000 13:28:37 +0000 Subject: [PATCH] Clean up directory to compile and run on my Linux box at least. Note that there is some trouble with inconsistant input/output formats. --- contrib/bit/Makefile | 27 +++++------ contrib/bit/postgres.h | 74 ----------------------------- contrib/bit/varbit.demo.sql | 2 +- contrib/bit/varbit.h | 23 ++++++++- contrib/bit/varbit.source | 94 ++++++++++++++++++------------------- 5 files changed, 83 insertions(+), 137 deletions(-) delete mode 100644 contrib/bit/postgres.h diff --git a/contrib/bit/Makefile b/contrib/bit/Makefile index 96e751d0c1..58c66b2025 100644 --- a/contrib/bit/Makefile +++ b/contrib/bit/Makefile @@ -1,12 +1,14 @@ -ifndef PGDIR -PGDIR= ../.. -PGDIR=/data/build/postgresql-7.0beta3 -endif +# Makefile +# For the bit/varbit data types -SRCDIR= $(PGDIR)/src +SRCDIR= ../../src include $(SRCDIR)/Makefile.global +INSTALLDIR= $(LIBDIR) +MODDIR= $(INSTALLDIR)/modules +SQLDIR= $(INSTALLDIR)/sql + TARGETS= varbit.sql varbit$(DLSUFFIX) # vartest SOURCE= varbit.c varbit_glue.c @@ -15,27 +17,24 @@ CFLAGS += -g all: $(TARGETS) -varbit$(DLSUFFIX): $(OBJ) - $(CC) $(CFLAGS) -shared -o varbit$(DLSUFFIX) $(SOURCE) $(CLIBS) - vartest: varbit.o vartest.o $(CC) -o $@ varbit.o vartest.o install: $(MAKE) all - cp -p varbit$(DLSUFFIX) $(LIBDIR)/contrib - chmod 555 $(LIBDIR)/contrib/varbit$(DLSUFFIX) + -test -d $(INSTALLDIR) || $(INSTALL) -d $(INSTALLDIR) + -test -d ${MODDIR} || $(INSTALL) -d ${MODDIR} + -test -d ${SQLDIR} || $(INSTALL) -d ${SQLDIR} + $(INSTALL) -m 555 $(filter %$(DLSUFFIX), $(TARGETS)) $(MODDIR) + $(INSTALL) -m 664 $(filter %.sql, $(TARGETS)) $(SQLDIR) %.sql: %.source - echo $(SRCDIR) if [ -z "$$USER" ]; then USER=$$LOGNAME; fi; \ if [ -z "$$USER" ]; then USER=`whoami`; fi; \ if [ -z "$$USER" ]; then echo 'Cannot deduce $$USER.'; exit 1; fi; \ rm -f $@; \ C=`pwd`; \ - O=$C; \ - if [ -d ${LIBDIR}/contrib ]; then O=${LIBDIR}/contrib; else \ - echo "contrib directory does not exist."; fi; \ + O=${MODDIR}; \ sed -e "s:_CWD_:$$C:g" \ -e "s:_OBJWD_:$$O:g" \ -e "s:_DLSUFFIX_:$(DLSUFFIX):g" \ diff --git a/contrib/bit/postgres.h b/contrib/bit/postgres.h deleted file mode 100644 index 44da5d7ac6..0000000000 --- a/contrib/bit/postgres.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef POSTGRES_H -#define POSTGRES_H - -#include - -typedef char bool; -typedef signed char int8; -typedef signed short int16; -typedef signed int int32; - -/*#define NULL ((void *) 0)*/ -#define Min(x, y) ((x) < (y) ? (x) : (y)) -#define Max(x, y) ((x) > (y) ? (x) : (y)) -#define PointerIsValid(pointer) (bool)((void*)(pointer) != NULL) - - -typedef unsigned int Oid; -typedef int16 int2; -typedef int32 int4; -typedef float float4; -typedef double float8; -typedef unsigned char uint8; /* == 8 bits */ -typedef unsigned short uint16; /* == 16 bits */ -typedef unsigned int uint32; /* == 32 bits */ -typedef uint8 bits8; /* >= 8 bits */ -typedef uint16 bits16; /* >= 16 bits */ -typedef uint32 bits32; /* >= 32 bits */ - - -typedef int4 aclitem; - -#define InvalidOid 0 -#define OidIsValid(objectId) ((bool) (objectId != InvalidOid)) - -/* unfortunately, both regproc and RegProcedure are used */ -typedef Oid regproc; -typedef Oid RegProcedure; - -typedef char *((*func_ptr) ()); - - -#define RegProcedureIsValid(p) OidIsValid(p) - -/* ---------------------------------------------------------------- - * Section 2: variable length and array types - * ---------------------------------------------------------------- - */ -/* ---------------- - * struct varlena - * ---------------- - */ -struct varlena -{ - int32 vl_len; - char vl_dat[1]; -}; - -#define VARSIZE(PTR) (((struct varlena *)(PTR))->vl_len) -#define VARDATA(PTR) (((struct varlena *)(PTR))->vl_dat) -#define VARHDRSZ sizeof(int32) - -typedef struct varlena bytea; -typedef struct varlena text; - -typedef int2 int28[8]; -typedef Oid oid8[8]; - -#define ERROR stderr -#define elog fprintf - -#define MaxAttrSize 10000 - -#define palloc malloc -#endif diff --git a/contrib/bit/varbit.demo.sql b/contrib/bit/varbit.demo.sql index 2b2bf661d3..e47a83da05 100644 --- a/contrib/bit/varbit.demo.sql +++ b/contrib/bit/varbit.demo.sql @@ -1,4 +1,4 @@ -create table bit_example (a bits, b bits); +create table bit_example (a bit, b bit); copy bit_example from stdin; X0F X10 X1F X11 diff --git a/contrib/bit/varbit.h b/contrib/bit/varbit.h index 44007ad10a..0b7e3308c4 100644 --- a/contrib/bit/varbit.h +++ b/contrib/bit/varbit.h @@ -1,5 +1,26 @@ -#include "c.h" +#include +#include +#include + +#include /* faked on sunos4 */ + +#include + #include "postgres.h" +#ifdef HAVE_LIMITS_H +#include +#ifndef MAXINT +#define MAXINT INT_MAX +#endif +#else +#ifdef HAVE_VALUES_H +#include +#endif +#endif +#include "fmgr.h" +#include "utils/timestamp.h" +#include "utils/builtins.h" + #define HEXDIG(z) (z)<10 ? ((z)+'0') : ((z)-10+'A') diff --git a/contrib/bit/varbit.source b/contrib/bit/varbit.source index 8b9dc29aab..c47ea72e90 100644 --- a/contrib/bit/varbit.source +++ b/contrib/bit/varbit.source @@ -1,171 +1,171 @@ LOAD '_OBJWD_/varbit.so'; -CREATE FUNCTION varbit_in(opaque) +CREATE FUNCTION varbitin(opaque) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'c'; -CREATE FUNCTION varbit_out(opaque) +CREATE FUNCTION zpbitout(opaque) RETURNS opaque AS '_OBJWD_/varbit.so' LANGUAGE 'c'; -CREATE TYPE bits ( +CREATE TYPE bit ( internallength = -1, - input = varbit_in, - output = varbit_out + input = varbitin, + output = zpbitout ); -CREATE FUNCTION bitcat(bits,bits) RETURNS bits +CREATE FUNCTION bitcat(bit,bit) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR || ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitcat ); -CREATE FUNCTION bitsubstr(bits,integer,integer) RETURNS bits +CREATE FUNCTION bitsubstr(bit,integer,integer) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'C'; -CREATE FUNCTION biteq(bits,bits) RETURNS bool +CREATE FUNCTION biteq(bit,bit) RETURNS bool AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR = ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = biteq, negator = <>, commutator = = ); -CREATE FUNCTION bitne(bits,bits) RETURNS bool +CREATE FUNCTION bitne(bit,bit) RETURNS bool AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR <> ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitne, negator = =, commutator = <> ); -CREATE FUNCTION bitlt(bits,bits) RETURNS bool +CREATE FUNCTION bitlt(bit,bit) RETURNS bool AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR < ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitlt ); -CREATE FUNCTION bitle(bits,bits) RETURNS bool +CREATE FUNCTION bitle(bit,bit) RETURNS bool AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR <= ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitle ); -CREATE FUNCTION bitgt(bits,bits) RETURNS bool +CREATE FUNCTION bitgt(bit,bit) RETURNS bool AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR > ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitgt, negator = <=, commutator = < ); -CREATE FUNCTION bitge(bits,bits) RETURNS bool +CREATE FUNCTION bitge(bit,bit) RETURNS bool as '_OBJWD_/varbit.so' language 'C'; CREATE OPERATOR >= ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitge, negator = <, commutator = <= ); -CREATE FUNCTION bitcmp(bits,bits) RETURNS int4 +CREATE FUNCTION bitcmp(bit,bit) RETURNS integer AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR <=> ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitcmp ); -CREATE FUNCTION bitor(bits,bits) RETURNS bits +CREATE FUNCTION bitor(bit,bit) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR | ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitor, commutator = | ); -CREATE FUNCTION bitand(bits,bits) RETURNS bits +CREATE FUNCTION bitand(bit,bit) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR & ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitand, commutator = & ); -CREATE FUNCTION bitxor(bits,bits) RETURNS bits +CREATE FUNCTION bitxor(bit,bit) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR ^ ( - leftarg = bits, - rightarg = bits, + leftarg = bit, + rightarg = bit, procedure = bitxor ); -CREATE FUNCTION bitnot(bits) RETURNS bits +CREATE FUNCTION bitnot(bit) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR ~ ( - rightarg = bits, + rightarg = bit, procedure = bitnot ); -CREATE FUNCTION bitshiftleft(bits,int4) RETURNS bits +CREATE FUNCTION bitshiftleft(bit,integer) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR << ( - leftarg = bits, - rightarg = int4, + leftarg = bit, + rightarg = integer, procedure = bitshiftleft ); -CREATE FUNCTION bitshiftright(bits,int4) RETURNS bits +CREATE FUNCTION bitshiftright(bit,integer) RETURNS bit AS '_OBJWD_/varbit.so' LANGUAGE 'C'; CREATE OPERATOR >> ( - leftarg = bits, - rightarg = int4, + leftarg = bit, + rightarg = integer, procedure = bitshiftright ); -- 2.40.0