Return-Path: siumk@uxmail.ust.hk Delivery-Date: Mon, 25 Apr 94 03:58:52 -0700 Return-Path: siumk@uxmail.ust.hk Received: from stu.ust.hk (stu.ust.hk [143.89.14.22]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id DAA06820 for ; Mon, 25 Apr 1994 03:58:28 -0700 Received: from ccdsu1 by stu.ust.hk id <17621(3)>; Mon, 25 Apr 1994 18:59:05 +0800 Message-Id: <94Apr25.185905hkt.17621(3)@stu.ust.hk> From: Mak Siu Kei Alan To: aoki@postgres.Berkeley.EDU Date: Mon, 25 Apr 1994 18:59:01 +0800 From siumk Mon Apr 25 18:59 HKT 1994 Content-Type: text Content-Length: 63961 # /*************************************************************************** # * * # * This is the installation instructions of * # * Postgres Version 4 Release 2 beta * # * released on April 3, 1994 * # * from University of California, Berkeley * # * running on FreeBSD-1.1-beta * # * ported by Clarence Chu clarence.chu@f132.n700.z6.ftn.air.org * # * * # ***************************************************************************/ # # Source code of Postgres-v4r2-beta # is available at s2k-ftp.cs.berkeley.edu # # Please be warned that the DBMS enclosed will # *NOT* run on earlier version of FreeBSD. # # Step 1 # ====== # Since Postgres requires the OS to have SYSVSHM and SYSVSEM enabled, # include the following 6(six) lines in /sys/i386/conf/YOURCONFIGFILE # # options SYSVIPC # SYSV Inter Process Communications # options SYSVSHM # SYSV Share Memory # options SYSVSEM # SYSV Semophore # options SYSVMSG # SYSV Message support # options "SEMMNI=20" # Semaphore parameters # options "SEMUME=20" # in /usr/include/sys/sem.h # # Run the following to remake your kernel # # # cd /sys/i386/conf # # config YOURCONFIGFILE # # cd ../../compile/YOURCONFIGFILE # # make depend # # make # # mv /386bsd /386bsd.old # # mv 386bsd / # # fastboot # # Step 2 # ====== # To compile the system, apply patch to your postgres source tree # # # #assume you have postgres source installed under /usr # # cd /usr # # patch -p < THIS_FILE # # follow the instruction of postgres-setup.{cat,ps} to make the system # with addition of gnuregexp.h added to your include path # i.e. # ln -s /usr/src/gnu/libregex/regex.h /usr/include/gnuregexp.h # # Step 3 # ====== # After making postgres, and have it installed, # Log in "postgres" and issue # # $ initdb -v # $ postmaster & # $ createuser # $ createdb # $ monitor # type \h for help # # Step 4 # ====== # Documentations are located at /usr/local/postgres/doc, and # /usr/local/postgres/man/man[1-5l] in Postscript format. # It is time to refer to them. # # Step 5 # ====== # For programming in C functions, use the following template # for your Makefile: # # # # # Makefile template # # # all: .so # # INCDIR= -I/usr/local/postgres/include # CFLAGS= -O2 -fPIC # LDFLAGS= -Bshareable -dc -dp # # .SUFFIXES: # .SUFFIXES: .so .c .o # # .c.o: # cc ${INCDIR} ${CFLAGS} -c $< # # .o.so: # ld ${LDFLAGS} -o $@ $< # # clean: # rm -f *.o *.so *.core # # Finally # ======= # In case of problems or suggestions, I can be reached via email at # # clarence.chu@f132.n700.z6.ftn.air.org # pager (852)-112-8398 a/c 3090 # # /************************** that's all, folks. *****************************/ *** postgres.orig/src/libpq/Makefile Wed Feb 9 08:12:06 1994 --- postgres/src/libpq/Makefile Mon Apr 11 21:24:45 1994 *************** *** 27,32 **** --- 27,38 ---- NOPROFILE=1 .endif + .if (${PORTNAME}=="freebsd") + PICFLAGS=-fPIC + NOPROFILE=1 + CFLAGS+= ${PICFLAGS} + .endif + .if defined(OLD_MKDIR) beforeinstall: @-if test ! -d ${DESTDIR}${LIBDIR}; \ *************** *** 93,99 **** ${INSTALL} -c -m 444 \ ${.CURDIR}/../backend/$$i ${HEADERDIR}/$$i; \ done ! -ln -f ${HEADERDIR}/tmp/libpq.h ${HEADERDIR} # XXX - installing fmgr.h depends on the backend being built ${INSTALL} -c -m 444 \ ${.CURDIR}/../backend/${MAKEOBJDIR}/fmgr.h ${HEADERDIR}/fmgr.h --- 99,105 ---- ${INSTALL} -c -m 444 \ ${.CURDIR}/../backend/$$i ${HEADERDIR}/$$i; \ done ! -ln -s ${HEADERDIR}/tmp/libpq.h ${HEADERDIR} # XXX - installing fmgr.h depends on the backend being built ${INSTALL} -c -m 444 \ ${.CURDIR}/../backend/${MAKEOBJDIR}/fmgr.h ${HEADERDIR}/fmgr.h *** postgres.orig/src/bin/monitor/monitor.c Sat Apr 2 06:39:56 1994 --- postgres/src/bin/monitor/monitor.c Mon Apr 11 21:24:45 1994 *************** *** 87,93 **** * Declaration of global variables (but only to the file monitor.c */ ! #define DEFAULT_EDITOR "/usr/ucb/vi" #define COPYBUFSIZ 8192 static char *user_editor; /* user's desired editor */ static int tmon_temp; /* file descriptor for temp. buffer file */ --- 87,93 ---- * Declaration of global variables (but only to the file monitor.c */ ! #define DEFAULT_EDITOR "/usr/bin/vi" #define COPYBUFSIZ 8192 static char *user_editor; /* user's desired editor */ static int tmon_temp; /* file descriptor for temp. buffer file */ *** postgres.orig/src/bin/ipcclean/freebsd/ipcclean.sh Mon Apr 25 12:57:01 1994 --- postgres/src/bin/ipcclean/freebsd/ipcclean.sh Mon Apr 11 21:24:46 1994 *************** *** 0 **** --- 1,8 ---- + #!/bin/sh + # + # /usr/local/devel/postgres-4.2-devel/src/bin/ipcclean/freebsd/RCS/ipcclean.sh,v 1.3 1993/07/10 04:31:17 clarence Exp + # + PATH=_fUnKy_IPCCLEANPATH_sTuFf_:$PATH + export PATH + ipcs | egrep '^m .*|^s .*' | egrep "`whoami`|postgres|picasso" | \ + awk '{printf "ipcrm -%s %s\n", $1, $2}' '-' | sh *** postgres.orig/src/bin/shmemdoc/shmemdoc.c Sat Apr 2 06:40:00 1994 --- postgres/src/bin/shmemdoc/shmemdoc.c Mon Apr 11 21:24:47 1994 *************** *** 534,555 **** { int i; int semval, sempid, semncnt, semzcnt; ! int ignore; for (i = 0; SemNames[i] != (char *) NULL; i++) { ! if ((semval = semctl(SemaphoreId, i, GETVAL, &ignore)) < 0) { perror(SemNames[i]); return(-errno); } ! if ((sempid = semctl(SemaphoreId, i, GETPID, &ignore)) < 0) { perror(SemNames[i]); return(-errno); } ! if ((semncnt = semctl(SemaphoreId, i, GETNCNT, &ignore)) < 0) { perror(SemNames[i]); return(-errno); } ! if ((semzcnt = semctl(SemaphoreId, i, GETZCNT, &ignore)) < 0) { perror(SemNames[i]); return(-errno); } --- 534,555 ---- { int i; int semval, sempid, semncnt, semzcnt; ! union semun ignore; for (i = 0; SemNames[i] != (char *) NULL; i++) { ! if ((semval = semctl(SemaphoreId, i, GETVAL, ignore)) < 0) { perror(SemNames[i]); return(-errno); } ! if ((sempid = semctl(SemaphoreId, i, GETPID, ignore)) < 0) { perror(SemNames[i]); return(-errno); } ! if ((semncnt = semctl(SemaphoreId, i, GETNCNT, ignore)) < 0) { perror(SemNames[i]); return(-errno); } ! if ((semzcnt = semctl(SemaphoreId, i, GETZCNT, ignore)) < 0) { perror(SemNames[i]); return(-errno); } *** postgres.orig/src/bin/fsutils/pls/print.c Wed Sep 29 11:14:14 1993 --- postgres/src/bin/fsutils/pls/print.c Mon Apr 11 21:45:07 1994 *************** *** 44,49 **** --- 44,50 ---- #include #include + #include #include #include #include *************** *** 62,68 **** --- 63,71 ---- static void printlink __P((FTSENT *)); static void printtime __P((time_t)); static int printtype __P((u_int)); + #ifndef __FreeBSD__ char *strmode __P((int,char*)); + #endif #define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT) *************** *** 320,325 **** --- 323,329 ---- int *m[] = { m1, m2, m3, m4, m5, m6, m7, m8, m9}; + #ifndef __FreeBSD__ char * strmode(flags,lp) char *lp; *************** *** 348,350 **** --- 352,355 ---- } return (lp); } + #endif /* __FreeBSD__ */ *** postgres.orig/src/bin/fsutils/pls/pwcache.c Sat Feb 20 08:34:25 1993 --- postgres/src/bin/fsutils/pls/pwcache.c Mon Apr 11 21:44:00 1994 *************** *** 44,50 **** --- 44,52 ---- #define NCACHE 64 /* power of 2 */ #define MASK NCACHE - 1 /* bits to store with */ + #ifndef UT_NAMESIZE #define UT_NAMESIZE 32 /* never go wrong. Hack.. I need to go skiing */ + #endif /* UT_NAMESIZE */ static int pwopen = 0; static int gropen = 0; *** postgres.orig/src/bin/fsutils/Makefile.global Thu Jul 29 07:41:25 1993 --- postgres/src/bin/fsutils/Makefile.global Mon Apr 11 21:36:56 1994 *************** *** 13,18 **** --- 13,22 ---- LIBPQ= ${LIBDIR}/libpq.a .endif + .if (${PORTNAME}=="freebsd") + LIBPQ= -lpq + .endif + LDADD+= ${LIBPQ} DPADD+= ${LIBPQ} *** postgres.orig/src/bin/Makefile.global Wed Aug 4 19:02:36 1993 --- postgres/src/bin/Makefile.global Mon Apr 11 21:35:16 1994 *************** *** 14,19 **** --- 14,23 ---- LIBPQ= ${LIBDIR}/libpq.a .endif + .if (${PORTNAME}=="freebsd") + LIBPQ= -lpq + .endif + LDADD+= ${LIBPQ} DPADD+= ${LIBPQ} *** postgres.orig/src/doc/implementation/Makefile Fri Mar 18 06:20:59 1994 --- postgres/src/doc/implementation/Makefile Mon Apr 11 21:24:48 1994 *************** *** 11,17 **** GROFF=groff -set #DOCOBJS= ${DOCSRCS:S/.me/.cat/g} ${DOCSRCS:S/.me/.ps/g} ! DOCOBJS= ${DOCSRCS:S/.me/.ps/g} README .me.cat: ${GROFF} -me -Tascii ${.IMPSRC} > ${.TARGET} --- 11,17 ---- GROFF=groff -set #DOCOBJS= ${DOCSRCS:S/.me/.cat/g} ${DOCSRCS:S/.me/.ps/g} ! DOCOBJS= ${DOCSRCS:S/.me/.ps/g} .me.cat: ${GROFF} -me -Tascii ${.IMPSRC} > ${.TARGET} *************** *** 22,35 **** all: ${DOCOBJS} install: all ! @-if [ ! -d ${POSTDOCDIR} ]; then \ mkdir ${POSTDOCDIR}; \ fi ! @-if [ ! -d ${POSTDOCDIR}/implementation ]; then \ ! mkdir ${POSTDOCDIR}/papers; \ fi ! for i in ${DOCOBJS}; do \ ! ${INSTALL} -m 444 $$i ${POSTDOCDIR}/implementation/$$i; \ done .include --- 22,37 ---- all: ${DOCOBJS} install: all ! echo installing......${POSTDOCDIR} ! if [ ! -d ${POSTDOCDIR} ]; then \ mkdir ${POSTDOCDIR}; \ fi ! if [ ! -d ${POSTDOCDIR}/implementation ]; then \ ! mkdir ${POSTDOCDIR}/implementation; \ fi ! for i in ${DOCOBJS}; \ ! do ; \ ! ${INSTALL} -m 444 $$i ${POSTDOCDIR}/implementation ; \ done .include *** postgres.orig/src/regress/Makefile.global Sat Apr 2 15:55:58 1994 --- postgres/src/regress/Makefile.global Mon Apr 11 21:24:48 1994 *************** *** 16,22 **** SLSUFF=.so .SUFFIXES: ${SLSUFF} .o${SLSUFF}: ! ${LD} -dc -dp -Bdynamic -o ${.TARGET} ${.ALLSRC} .elif (${PORTNAME} == "alpha") SLSUFF=.so .SUFFIXES: ${SLSUFF} --- 16,28 ---- SLSUFF=.so .SUFFIXES: ${SLSUFF} .o${SLSUFF}: ! ${LD} -dc -dp -Bdynamic -o ${.TARGET} ${.ALLSRC} ! .elif (${PORTNAME} == "freebsd") ! CFLAGS+= -fPIC ! SLSUFF=.so ! .SUFFIXES: ${SLSUFF} ! .o${SLSUFF}: ! ${LD} -dc -dp -Bshareable -o ${.TARGET} ${.ALLSRC} .elif (${PORTNAME} == "alpha") SLSUFF=.so .SUFFIXES: ${SLSUFF} *************** *** 51,59 **** .SUFFIXES: .source .pq .sh .source.pq: ! [ -z "$$USER" ] && USER=$$LOGNAME; \ ! [ -z "$$USER" ] && USER=`whoami`; \ ! [ -z "$$USER" ] && exit 1; \ rm -f $*.pq; \ if [ "${.CURDIR}" = ".." ]; then \ C="`pwd`/"; \ --- 57,71 ---- .SUFFIXES: .source .pq .sh .source.pq: ! -if [ -z "$$USER" ]; then \ ! USER=$$LOGNAME; \ ! fi; \ ! if [ -z "$$USER" ]; then \ ! USER=`whoami`; \ ! fi; \ ! if [ -z "$$USER" ]; then \ ! exit 1; \ ! fi; \ rm -f $*.pq; \ if [ "${.CURDIR}" = ".." ]; then \ C="`pwd`/"; \ *************** *** 66,74 **** -e "s/_USER_/$$USER/g" < ${.CURDIR}/$*.source > $*.pq .source.sh: ! [ -z "$$USER" ] && USER=$$LOGNAME; \ ! [ -z "$$USER" ] && USER=`whoami`; \ ! [ -z "$$USER" ] && exit 1; \ rm -f $*.sh; \ if [ "${.CURDIR}" = ".." ]; then \ C="`pwd`/"; \ --- 78,92 ---- -e "s/_USER_/$$USER/g" < ${.CURDIR}/$*.source > $*.pq .source.sh: ! -if [ -z "$$USER" ]; then \ ! USER=$$LOGNAME; \ ! fi; \ ! if [ -z "$$USER" ]; then \ ! USER=`whoami`; \ ! fi; \ ! if [ -z "$$USER" ]; then \ ! exit 1; \ ! fi; \ rm -f $*.sh; \ if [ "${.CURDIR}" = ".." ]; then \ C="`pwd`/"; \ *** postgres.orig/src/backend/bootstrap/bootscanner.lex Mon Feb 7 19:32:34 1994 --- postgres/src/backend/bootstrap/bootscanner.lex Mon Apr 11 21:24:48 1994 *************** *** 19,25 **** /* * This is actually conditional on use of "flex" instead of "lex" */ ! #ifdef __linux__ #undef yywrap #endif /* __linux__ */ --- 19,25 ---- /* * This is actually conditional on use of "flex" instead of "lex" */ ! #if defined(__linux__) || defined(__FreeBSD__) #undef yywrap #endif /* __linux__ */ *** postgres.orig/src/backend/parser/scan.l Wed Feb 2 09:18:36 1994 --- postgres/src/backend/parser/scan.l Mon Apr 11 21:24:49 1994 *************** *** 7,21 **** **********************************************************************/ #include ! #include #include "parse.h" #include "nodes/pg_lisp.h" #include "parser/atoms.h" ! #undef input ! #undef unput extern LispValue yylval; %} --- 7,70 ---- **********************************************************************/ #include ! #include #include "parse.h" #include "nodes/pg_lisp.h" #include "parser/atoms.h" ! extern int StringInput; ! extern char *TheString; ! extern char *Ch; ! char *InputFrag; ! int FragLen; ! ! /* ! * kai: ! * Porting this from Unix standard lex to Linux' flex wasn't fun. First of all, ! * they use very different input styles (lex does it character by character, ! * while flex uses a big buffer). And then there are functions in parse_query.c ! * which reverse the order of scanning. Nevertheless I hope everything is ! * working now. ! * ! * It seems that StringInput == 0 does not happen (the old code in ! * parse_query.c would break badly for queries with or without a from-clause), ! * but I am not sure, whether other statements are passed directly or not. ! */ ! ! #undef YY_INPUT ! #define YY_INPUT(buf,result,max_len) \ ! if (StringInput) { \ ! int len; \ ! if (InputFrag && FragLen <= 0) \ ! InputFrag = 0; \ ! if (InputFrag) { \ ! if((len = FragLen) > max_len) \ ! len = max_len; \ ! result = len; \ ! bcopy(InputFrag, (char *) buf, len); \ ! InputFrag += len; \ ! FragLen -= len; \ ! } else { \ ! if(Ch == NULL) \ ! Ch = TheString; \ ! if((len = strlen(Ch)) > max_len) \ ! len = max_len; \ ! result = len; \ ! bcopy(Ch, (char *) buf, len); \ ! Ch += len; \ ! } \ ! } else { \ ! if ( (result = read( stdin, (char *) buf, max_len )) < 0 ) \ ! YY_FATAL_ERROR( "read() in flex scanner failed" ); \ ! } ! ! #undef YY_BUF_SIZE ! #define YY_BUF_SIZE \ ! (StringInput ? \ ! strlen(TheString) + 4 : \ ! (YY_READ_BUF_SIZE * 2) /* size of default input buffer */) extern LispValue yylval; %} *************** *** 99,101 **** --- 148,219 ---- {other} { return (yytext[0]); } %% + + + /* + * Switch to new input (discard the read buffer) + */ + void NewInput(void) + { + if(yy_current_buffer) + YY_NEW_FILE; + } + + + /* + * Get a character out of flex's buffer + */ + int DoInput(void) + { + char *yy_cp = yy_c_buf_p; + char *yy_bp = yytext; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + if ( yy_c_buf_p >= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + switch ( yy_get_next_buffer() ) { + case EOB_ACT_CONTINUE_SCAN: + break; + + case EOB_ACT_LAST_MATCH: + case EOB_ACT_END_OF_FILE: + return -1; + } + + yy_cp++; + yy_c_buf_p = yy_cp; + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + + return yy_cp[-1]; + } + + + /* + * This function determines the current position of the lexical scanning + * relative to TheString. + */ + char *CurScan(void) + { + return (InputFrag ? InputFrag : Ch) + + (yy_c_buf_p - &yy_current_buffer->yy_ch_buf[yy_n_chars]); + } + + + /* + * Put a character back into flex's buffer + */ + void DoUnput(char c) + { + yyunput(c, yytext); + } + + + /* + * Delete the input buffer. + */ + void DeleteBuffer(void) + { + if(yy_current_buffer) + yy_delete_buffer(yy_current_buffer); + yy_init = 1; + } *** postgres.orig/src/backend/parser/error.c Tue Aug 14 18:30:38 1990 --- postgres/src/backend/parser/error.c Mon Apr 11 21:24:49 1994 *************** *** 19,25 **** yyerror(message) char message[]; { ! extern char yytext[]; elog(WARN, "parser: %s at or near \"%s\"\n", message, yytext); } --- 19,25 ---- yyerror(message) char message[]; { ! extern char *yytext; elog(WARN, "parser: %s at or near \"%s\"\n", message, yytext); } *** postgres.orig/src/backend/parser/gram.y Tue Feb 15 15:22:03 1994 --- postgres/src/backend/parser/gram.y Fri Apr 22 18:59:45 1994 *************** *** 37,45 **** #include "tmp/acl.h" #include "lib/lisplist.h" ! #define ELEMENT yyval = nappend1( LispNil , yypvt[-0] ) ! #define INC_LIST yyval = nappend1( yypvt[-2] , yypvt[-0] ) /* $1,$3 */ #define NULLTREE yyval = LispNil ; #define LAST(lv) lispCons ( lv , LispNil ) --- 37,45 ---- #include "tmp/acl.h" #include "lib/lisplist.h" ! #define ELEMENT yyval = nappend1( LispNil , yyvsp[-0] ) ! #define INC_LIST yyval = nappend1( yyvsp[-2] , yyvsp[-0] ) /* $1,$3 */ #define NULLTREE yyval = LispNil ; #define LAST(lv) lispCons ( lv , LispNil ) *************** *** 233,249 **** aclitem_lv = lispVectori(sizeof(AclItem)); modechg_lv = lispInteger(0); ! Ch = aclparse(Ch, (AclItem *) LISPVALUE_BYTEVECTOR(aclitem_lv), ! &modechg_lv->val.fixnum); temp = lispCons(aclitem_lv, lispCons(modechg_lv, LispNil)); } relation_name_list { $$ = lispCons(KW(change), lispCons(KW(acl), ! nconc(temp, $4))); } ; --- 233,251 ---- aclitem_lv = lispVectori(sizeof(AclItem)); modechg_lv = lispInteger(0); ! ! Ch = aclparse((char *) CurScan(), (AclItem *) LISPVALUE_BYTEVECTOR(aclitem_lv), ! (unsigned *) &modechg_lv->val.fixnum); temp = lispCons(aclitem_lv, lispCons(modechg_lv, LispNil)); + } relation_name_list { $$ = lispCons(KW(change), lispCons(KW(acl), ! nconc(temp, $4))); } ; *** postgres.orig/src/backend/parser/io.c Thu Dec 31 01:39:00 1992 --- postgres/src/backend/parser/io.c Mon Apr 11 21:24:50 1994 *************** *** 20,66 **** void init_io() { ! Ch = NULL; } char input() { ! char c; ! ! if (StringInput) { ! if (Ch == NULL) { ! Ch = TheString; ! return(*Ch++); ! } else if (*Ch == '\0') { ! return(0); ! } else { ! return(*Ch++); ! } ! } else { ! c = getchar(); ! if (c == EOF) { ! return(0); ! } else { ! return(c); ! } ! } } void unput(c) char c; { ! ! if (StringInput) { ! if (Ch == NULL) { ! elog(FATAL, "Unput() failed.\n"); ! /* NOTREACHED */ ! } else if (c != 0) { ! *--Ch = c; ! } ! } else { ! ungetc(c, stdin); ! } } --- 20,42 ---- void init_io() { ! void NewInput(void), DeleteBuffer(void); ! DeleteBuffer(); ! NewInput(); Ch = NULL; } char input() { ! char DoInput(void); ! return DoInput(); } void unput(c) char c; { ! void DoUnput(char); ! return DoUnput(c); } *** postgres.orig/src/backend/parser/parse_query.c Tue Feb 15 15:22:55 1994 --- postgres/src/backend/parser/parse_query.c Mon Apr 11 21:24:51 1994 *************** *** 778,791 **** **********************************************************************/ static char *target_list_place; ! static char *from_list_place; SkipForwardToFromList() { LispValue next_token; ! extern char *Ch; ! char *temp = Ch; while ((int)(next_token=(LispValue)yylex()) > 0 && (next_token != (LispValue) FROM && /* --- 778,808 ---- **********************************************************************/ static char *target_list_place; ! /* static char *from_list_place; */ ! ! extern char *Ch, *InputFrag; ! extern char *CurScan(); ! extern int FragLen; SkipForwardToFromList() { LispValue next_token; ! char *temp = CurScan(); + /* + * kai: Don't deliver a from clause, if the scanner hasn't passed beyond + * the last from clause yet. + */ + if(temp < InputFrag) + return; + + /* + * kai: I don't really know, what to do: the former behaviour of this + * was, that it finds any from clause, whether or not it belongs + * to the same postquel statement. Changed it to stop scan at + * any append, delete, replace or retrieve, seems to work, but is + * different from original behaviour ... + */ while ((int)(next_token=(LispValue)yylex()) > 0 && (next_token != (LispValue) FROM && /* *************** *** 800,833 **** ; /* empty while */ if (next_token == (LispValue) FROM ) { ! Ch -= 4; ! from_list_place = Ch; target_list_place = temp; } else { Ch = temp; } } LispValue SkipBackToTlist() { - extern char yytext[]; extern LispValue yychar; extern int yyleng; - extern char *Ch; - char *temp = yytext; int i; /* need to put the token after the target_list back first */ ! temp = yytext; ! if((yychar == (LispValue)WHERE) || (yychar == (LispValue)SORT)){ ! for (i = yyleng; i > -1 ; -- i ) { ! unput (yytext[i]); ! } ! } ! bcopy(Ch,from_list_place,strlen(Ch) + 1 ); ! Ch = target_list_place; return(LispNil); } --- 817,846 ---- ; /* empty while */ if (next_token == (LispValue) FROM ) { ! Ch = CurScan() - 4; ! FragLen = Ch - temp; target_list_place = temp; } else { Ch = temp; } + + NewInput(); } LispValue SkipBackToTlist() { extern LispValue yychar; extern int yyleng; int i; /* need to put the token after the target_list back first */ ! Ch = CurScan(); ! if((yychar == (LispValue)WHERE) || (yychar == (LispValue)SORT)) ! Ch -= yyleng; ! InputFrag = target_list_place; ! NewInput(); return(LispNil); } *** postgres.orig/src/backend/parser/ylib.c Tue Feb 15 14:11:14 1994 --- postgres/src/backend/parser/ylib.c Mon Apr 11 21:24:51 1994 *************** *** 56,61 **** --- 56,62 ---- { LispValue parse, savetree; int yyresult; + void DeleteBuffer(void); init_io(); *************** *** 68,73 **** --- 69,75 ---- parser_init(typev, nargs); yyresult = yyparse(); + DeleteBuffer(); clearerr(stdin); *************** *** 401,406 **** --- 403,409 ---- } #define ADD_TO_RT(rt_entry) p_rtable = nappend1(p_rtable,rt_entry) + extern List p_rtable; List ParseFunc ( funcname , fargs, curr_resno ) char *funcname; *************** *** 428,434 **** LispValue setup_base_tlist(); bool retset; bool exists; - extern LispValue p_rtable; extern void make_arguments(); bool attisset = false; ObjectId toid; --- 431,436 ---- *** postgres.orig/src/backend/planner/path/xfunc.c Tue Nov 9 10:11:50 1993 --- postgres/src/backend/planner/path/xfunc.c Mon Apr 11 21:24:52 1994 *************** *** 20,26 **** --- 20,31 ---- ** xfunc_disjunct_sort */ #include /* for MAXFLOAT on most systems */ + #ifdef __FreeBSD__ + #include + #define MAXFLOAT FLT_MAX + #else #include /* for MAXFLOAT on SunOS */ + #endif #include #include "nodes/pg_lisp.h" *** postgres.orig/src/backend/planner/path/costsize.c Sat Jul 17 08:14:43 1993 --- postgres/src/backend/planner/path/costsize.c Mon Apr 11 21:24:53 1994 *************** *** 24,30 **** --- 24,35 ---- */ #include + #ifdef __FreeBSD__ + #include + #define MAXINT INT_MAX + #else #include + #endif #include "tmp/c.h" *** postgres.orig/src/backend/port/freebsd/Makefile.inc Mon Apr 25 12:56:08 1994 --- postgres/src/backend/port/freebsd/Makefile.inc Mon Apr 11 21:24:55 1994 *************** *** 0 **** --- 1,14 ---- + # + # freebsd specific stuff + # + # /usr/local/devel/postgres-4.2-devel/src/backend/port/freebsd/RCS/Makefile.inc,v 1.9 1994/02/09 00:12:24 aoki Exp + # + + CFLAGS+= -DUSE_POSIX_TIME + + LDADD+= -lln -lgnuregex + + SRCS+= + + SRCS+= dynloader.c + HEADERS+= machine.h *** postgres.orig/src/backend/port/freebsd/dynloader.c Mon Apr 25 12:56:09 1994 --- postgres/src/backend/port/freebsd/dynloader.c Mon Apr 11 21:24:55 1994 *************** *** 0 **** --- 1,70 ---- + /* + * FILE + * dynloader.c + * + * DESCRIPTION + * dynamic loader for FreeBSD-1.1-beta using the shared library mechanism + * + * INTERFACE ROUTINES + * pg_dlopen + * pg_dlsym + * pg_dlclose + * + * NOTES + * pg_dlclose is actually macros, defined in + * port-protos.h. + * + * IDENTIFICATION + * /usr/local/devel/postgres-4.2-devel/src/backend/port/freebsd/RCS/dynloader.c,v 1.20 1993/08/04 11:02:54 aoki Exp + */ + + #include + #include "dlfcn.h" + + #include "port-protos.h" + + /* + * Dynamic Loader on FreeBSD-1.1-beta. + * + * this dynamic loader uses the system dynamic loading interface for shared + * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared + * library as the file to be dynamically loaded. + * + * Note that only pg_dlopen and pg_dlsym are defined here. + * pg_dlclose is actually macros. + */ + + /* + * pg_dlopen-- + * attempts to dynamically loaded in filename and returns error in + * err, if any. + */ + void * + pg_dlopen(filename, err) + char *filename; char **err; + { + void *handle; + + if ((handle = dlopen(filename, 1)) == (void *) NULL) { + *err = "dlopen() error"; + } + return((void *) handle); + } + + /* + * pg_dlsym-- + * attempts to search symbol name in pg_dlopen()ed handle + * if funcname is not found, it'll return NULL. + */ + func_ptr + pg_dlsym(handle,funcname) + void *handle; char *funcname; + { + char *symname; + func_ptr retval; + symname = (char *)palloc(strlen(funcname)+2); + strcpy (symname,"_"); strcat(symname,funcname); + retval = ((void *) dlsym(handle,symname)); + pfree(symname); + return(retval); + } *** postgres.orig/src/backend/port/freebsd/dlfcn.h Mon Apr 25 12:56:09 1994 --- postgres/src/backend/port/freebsd/dlfcn.h Mon Apr 11 21:24:55 1994 *************** *** 0 **** --- 1,21 ---- + /* + * @(#)dlfcn.h 1.3 revision of 92/12/27 20:58:32 + * This is an unpublished work copyright (c) 1992 Helios Software GmbH + * 3000 Hannover 1, Germany + */ + + /* + * Mode flags for the dlopen routine. + */ + #define RTLD_LAZY 1 + #define RTLD_NOW 2 + + #if __STDC__ || defined(_IBMR2) + void *dlopen(const char *path, int mode); + void *dlsym(void *handle, const char *symbol); + int dlclose(void *handle); + #else + void *dlopen(); + void *dlsym(); + int dlclose(); + #endif *** postgres.orig/src/backend/port/freebsd/machine.h Mon Apr 25 12:56:09 1994 --- postgres/src/backend/port/freebsd/machine.h Mon Apr 11 21:24:56 1994 *************** *** 0 **** --- 1,12 ---- + + /* + * /usr/local/devel/postgres-4.2-devel/src/backend/port/sparc/RCS/machine.h,v 1.2 1989/09/05 17:20:51 mao Version_2 + */ + + #ifndef MACHINE_H + #define MACHINE_H + + #define BLCKSZ 8192 + + #endif + *** postgres.orig/src/backend/port/freebsd/port-protos.h Mon Apr 25 12:56:09 1994 --- postgres/src/backend/port/freebsd/port-protos.h Mon Apr 11 21:24:56 1994 *************** *** 0 **** --- 1,27 ---- + /* + * FILE + * port-protos.h + * + * DESCRIPTION + * port-specific prototypes for FreeBSD + * + * NOTES + * + * IDENTIFICATION + * /usr/local/devel/postgres-4.2-devel/src/backend/port/freebsd/RCS/port-protos.h,v 1.5 1993/08/04 11:02:54 aoki Exp + */ + + #ifndef PortProtos_H /* include this file only once */ + #define PortProtos_H 1 + + #include "dlfcn.h" + #include "fmgr.h" + #include "utils/dynamic_loader.h" + + /* dynloader.c */ + + #define pg_dlclose dlclose + + /* port.c */ + + #endif /* PortProtos_H */ *** postgres.orig/src/backend/storage/ipc/ipc.c Tue Feb 1 19:55:16 1994 --- postgres/src/backend/storage/ipc/ipc.c Mon Apr 11 21:24:57 1994 *************** *** 257,263 **** --- 257,268 ---- return(2); /* returns the number of the invalid argument */ } + #if defined(linux) || defined(__FreeBSD__) + semId = semget(semKey, 0, permission); + #else semId = semget(semKey, 0, 0); + #endif + if (semId == -1) { *status = IpcSemIdNotExist; /* there doesn't exist a semaphore */ #ifdef DEBUG_IPC *************** *** 336,342 **** --- 341,352 ---- return(2); /* returns the number of the invalid argument */ } + #if defined(linux) || defined(__FreeBSD__) + semId = semget(semKey, 0, permission); + #else semId = semget(semKey, 0, 0); + #endif + if (semId == -1) { *status = IpcSemIdNotExist; /* there doesn't exist a semaphore */ semId = semget(semKey, semNum, IPC_CREAT|permission); *************** *** 400,406 **** --- 410,421 ---- /* kill semaphore if existent */ + #if defined(linux) || defined(__FreeBSD__) + semId = semget(key, 0, 0600); + #else semId = semget(key, 0, 0); + #endif + if (semId != -1) semctl(semId, 0, IPC_RMID, semun); } *** postgres.orig/src/backend/storage/ipc/s_lock.c Sat Apr 2 06:43:34 1994 --- postgres/src/backend/storage/ipc/s_lock.c Mon Apr 11 21:24:57 1994 *************** *** 232,245 **** slock_t *lock; { slock_t res; ! __asm__("xchgb %0,%1":"=q" (res),"=m" (*m):"0" (0x1)); return(res); } S_LOCK(lock) slock_t *lock; { ! while (tas(addr)) ; } --- 232,245 ---- slock_t *lock; { slock_t res; ! __asm__("xchgb %0,%1":"=q" (res),"=m" (*lock):"0" (0x1)); return(res); } S_LOCK(lock) slock_t *lock; { ! while (tas(lock)) ; } *** postgres.orig/src/backend/storage/ipc/spin.c Mon Feb 7 19:44:29 1994 --- postgres/src/backend/storage/ipc/spin.c Mon Apr 11 21:24:57 1994 *************** *** 181,187 **** --- 181,192 ---- { IpcSemaphoreId id; + #if defined(linux) || defined(__FreeBSD__) + id = semget (key, MAX_SPINS, 0600); + #else id = semget (key, MAX_SPINS, 0); + #endif + if (id < 0) { if (errno == EEXIST) { /* key is the name of someone else's semaphore */ *** postgres.orig/src/backend/tcop/postgres.c Sat Apr 2 06:43:45 1994 --- postgres/src/backend/tcop/postgres.c Mon Apr 11 21:24:58 1994 *************** *** 1143,1148 **** --- 1143,1162 ---- * us back here. * ---------------- */ + #if 0 + #if defined(linux) || defined(__FreeBSD__) + { + #ifndef SA_NOMASK + #define SA_NOMASK 0 + #endif + struct sigaction action; + action.sa_handler = (void *) handle_warn; + sigemptyset(&action.sa_mask); + action.sa_flags = SA_NOMASK; + sigaction(SIGHUP, &action, 0); + } + #endif + #endif signal(SIGHUP, handle_warn); if (setjmp(Warn_restart) != 0) { *** postgres.orig/src/backend/utils/adt/regexp.c Mon Nov 1 08:49:21 1993 --- postgres/src/backend/utils/adt/regexp.c Mon Apr 11 21:24:58 1994 *************** *** 45,51 **** --- 45,60 ---- #if defined(DISABLE_XOPEN_NLS) #undef _XOPEN_SOURCE #endif /* DISABLE_XOPEN_NLS */ + + #ifdef __FreeBSD__ + #define GNU_REGCOMP + #endif + + #ifdef GNU_REGCOMP + #include + #else #include + #endif /* * interface routines called by the function manager *************** *** 59,65 **** --- 68,78 ---- uint16 arg1; struct varlena *p; { + #ifdef GNU_REGCOMP + struct re_pattern_buffer rpb; + #else char *expbuf, *endbuf; + #endif char *sterm, *pterm; int result; char *s = (char *) &arg1; *************** *** 67,74 **** --- 80,93 ---- if (!s || !p) return FALSE; + #ifdef GNU_REGCOMP + memset((void *) &rpb, 0, sizeof(rpb)); + rpb.buffer = (unsigned char *) palloc(EXPBUFSZ); + rpb.allocated = EXPBUFSZ; + #else expbuf = (char *) palloc(EXPBUFSZ); endbuf = expbuf + (EXPBUFSZ - 1); + #endif /* be sure sterm is null-terminated */ sterm = (char *) palloc(P2CHARLEN + 1); *************** *** 84,99 **** *(pterm + p->vl_len - sizeof(int32)) = (char)NULL; /* compile the re */ (void) compile(pterm, expbuf, endbuf, NULL); /* do the regexp matching */ result = step(sterm, expbuf); - pfree(expbuf); pfree(sterm); pfree(pterm); ! return ((bool) result); } bool --- 103,130 ---- *(pterm + p->vl_len - sizeof(int32)) = (char)NULL; /* compile the re */ + #ifdef GNU_REGCOMP + (void) re_compile_pattern(pterm, strlen(pterm), &rpb); + #else (void) compile(pterm, expbuf, endbuf, NULL); + #endif /* do the regexp matching */ + #ifdef GNU_REGCOMP + result = re_search(&rpb, sterm, strlen(sterm), 0, strlen(sterm), 0); + pfree(rpb.buffer); + #else result = step(sterm, expbuf); pfree(expbuf); + #endif + pfree(sterm); pfree(pterm); ! #ifdef GNU_REGCOMP ! return (bool)(result >= 0); ! #else return ((bool) result); + #endif } bool *************** *** 109,115 **** --- 140,150 ---- uint32 arg1; struct varlena *p; { + #ifdef GNU_REGCOMP + struct re_pattern_buffer rpb; + #else char *expbuf, *endbuf; + #endif char *sterm, *pterm; int result; char *s = (char *) &arg1; *************** *** 117,124 **** --- 152,165 ---- if (!s || !p) return FALSE; + #ifdef GNU_REGCOMP + memset((void *) &rpb, 0, sizeof(rpb)); + rpb.buffer = (unsigned char *) palloc(EXPBUFSZ); + rpb.allocated = EXPBUFSZ; + #else expbuf = (char *) palloc(EXPBUFSZ); endbuf = expbuf + (EXPBUFSZ - 1); + #endif /* be sure sterm is null-terminated */ sterm = (char *) palloc(P4CHARLEN + 1); *************** *** 134,149 **** *(pterm + p->vl_len - sizeof(int32)) = (char)NULL; /* compile the re */ (void) compile(pterm, expbuf, endbuf, NULL); /* do the regexp matching */ result = step(sterm, expbuf); - pfree(expbuf); pfree(sterm); pfree(pterm); return ((bool) result); } bool --- 175,203 ---- *(pterm + p->vl_len - sizeof(int32)) = (char)NULL; /* compile the re */ + #ifdef GNU_REGCOMP + (void) re_compile_pattern(pterm, strlen(pterm), &rpb); + #else (void) compile(pterm, expbuf, endbuf, NULL); + #endif /* do the regexp matching */ + #ifdef GNU_REGCOMP + result = re_search(&rpb, sterm, strlen(sterm), 0, strlen(sterm), 0); + pfree(rpb.buffer); + #else result = step(sterm, expbuf); pfree(expbuf); + #endif + pfree(sterm); pfree(pterm); + #ifdef GNU_REGCOMP + return (bool)(result >= 0); + #else return ((bool) result); + #endif } bool *************** *** 159,173 **** --- 213,237 ---- char *s; struct varlena *p; { + #ifdef GNU_REGCOMP + struct re_pattern_buffer rpb; + #else char *expbuf, *endbuf; + #endif char *sterm, *pterm; int result; if (!s || !p) return FALSE; + #ifdef GNU_REGCOMP + memset((void *) &rpb, 0, sizeof(rpb)); + rpb.buffer = (unsigned char *) palloc(EXPBUFSZ); + rpb.allocated = EXPBUFSZ; + #else expbuf = (char *) palloc(EXPBUFSZ); endbuf = expbuf + (EXPBUFSZ - 1); + #endif /* be sure sterm is null-terminated */ sterm = (char *) palloc(P8CHARLEN + 1); *************** *** 183,198 **** *(pterm + p->vl_len - sizeof(int32)) = (char)NULL; /* compile the re */ (void) compile(pterm, expbuf, endbuf, NULL); /* do the regexp matching */ result = step(sterm, expbuf); - pfree(expbuf); pfree(sterm); pfree(pterm); return ((bool) result); } bool --- 247,275 ---- *(pterm + p->vl_len - sizeof(int32)) = (char)NULL; /* compile the re */ + #ifdef GNU_REGCOMP + (void) re_compile_pattern(pterm, strlen(pterm), &rpb); + #else (void) compile(pterm, expbuf, endbuf, NULL); + #endif /* do the regexp matching */ + #ifdef GNU_REGCOMP + result = re_search(&rpb, sterm, strlen(sterm), 0, strlen(sterm), 0); + pfree(rpb.buffer); + #else result = step(sterm, expbuf); pfree(expbuf); + #endif + pfree(sterm); pfree(pterm); + #ifdef GNU_REGCOMP + return (bool)(result >= 0); + #else return ((bool) result); + #endif } bool *************** *** 208,222 **** --- 285,309 ---- char *s; struct varlena *p; { + #ifdef GNU_REGCOMP + struct re_pattern_buffer rpb; + #else char *expbuf, *endbuf; + #endif char *sterm, *pterm; int result; if (!s || !p) return FALSE; + #ifdef GNU_REGCOMP + memset((void *) &rpb, 0, sizeof(rpb)); + rpb.buffer = (unsigned char *) palloc(EXPBUFSZ); + rpb.allocated = EXPBUFSZ; + #else expbuf = (char *) palloc(EXPBUFSZ); endbuf = expbuf + (EXPBUFSZ - 1); + #endif /* be sure sterm is null-terminated */ sterm = (char *) palloc(P16CHARLEN + 1); *************** *** 232,247 **** *(pterm + p->vl_len - sizeof(int32)) = (char)NULL; /* compile the re */ (void) compile(pterm, expbuf, endbuf, NULL); /* do the regexp matching */ result = step(sterm, expbuf); - pfree(expbuf); pfree(sterm); pfree(pterm); return ((bool) result); } bool --- 319,347 ---- *(pterm + p->vl_len - sizeof(int32)) = (char)NULL; /* compile the re */ + #ifdef GNU_REGCOMP + (void) re_compile_pattern(pterm, strlen(pterm), &rpb); + #else (void) compile(pterm, expbuf, endbuf, NULL); + #endif /* do the regexp matching */ + #ifdef GNU_REGCOMP + result = re_search(&rpb, sterm, strlen(sterm), 0, strlen(sterm), 0); + pfree(rpb.buffer); + #else result = step(sterm, expbuf); pfree(expbuf); + #endif + pfree(sterm); pfree(pterm); + #ifdef GNU_REGCOMP + return (bool)(result >= 0); + #else return ((bool) result); + #endif } bool *************** *** 257,263 **** --- 357,367 ---- struct varlena *s; struct varlena *p; { + #ifdef GNU_REGCOMP + struct re_pattern_buffer rpb; + #else char *expbuf, *endbuf; + #endif char *sbuf, *pbuf; int result; *************** *** 275,282 **** --- 379,392 ---- sbuf = (char *) palloc(s->vl_len - sizeof(int32) + 1); pbuf = (char *) palloc(p->vl_len - sizeof(int32) + 1); + #ifdef GNU_REGCOMP + memset((void *) &rpb, 0, sizeof(rpb)); + rpb.buffer = (unsigned char *) palloc(EXPBUFSZ); + rpb.allocated = EXPBUFSZ; + #else expbuf = (char *) palloc(EXPBUFSZ); endbuf = expbuf + (EXPBUFSZ - 1); + #endif bcopy(s->vl_dat, sbuf, s->vl_len - sizeof(int32)); bcopy(p->vl_dat, pbuf, p->vl_len - sizeof(int32)); *************** *** 285,300 **** /* compile the re */ (void) compile(pbuf, expbuf, endbuf, NULL); /* do the regexp matching */ result = step(sbuf, expbuf); - pfree(expbuf); pfree(sbuf); pfree(pbuf); return ((bool) result); } bool --- 395,423 ---- /* compile the re */ + #ifdef GNU_REGCOMP + (void) re_compile_pattern(pbuf, strlen(pbuf), &rpb); + #else (void) compile(pbuf, expbuf, endbuf, NULL); + #endif /* do the regexp matching */ + #ifdef GNU_REGCOMP + result = re_search(&rpb, sbuf, strlen(sbuf), 0, strlen(sbuf), 0); + pfree(rpb.buffer); + #else result = step(sbuf, expbuf); pfree(expbuf); + #endif + pfree(sbuf); pfree(pbuf); + #ifdef GNU_REGCOMP + return (bool)(result >= 0); + #else return ((bool) result); + #endif } bool *** postgres.orig/src/backend/utils/adt/numutils.c Wed Feb 9 08:12:06 1994 --- postgres/src/backend/utils/adt/numutils.c Mon Apr 11 21:24:59 1994 *************** *** 17,22 **** --- 17,31 ---- RcsId("/usr/local/devel/postgres-4.2-devel/src/backend/utils/adt/RCS/numutils.c,v 1.10 1994/02/09 00:12:24 aoki Exp"); + static int + skip_space(str) + char *str; + { + while((*str)&&(isspace(*str))) + str++; + return(*str); + } + int32 pg_atoi(s, size, c) char *s; *************** *** 32,38 **** l = strtol(s, &badp, 10); if (errno) /* strtol must set ERANGE */ elog(WARN, "pg_atoi: error reading \"%s\": %m", s); ! if (badp && *badp && (*badp != c)) elog(WARN, "pg_atoi: error in \"%s\": can\'t parse \"%s\"", s, badp); switch (size) { --- 41,47 ---- l = strtol(s, &badp, 10); if (errno) /* strtol must set ERANGE */ elog(WARN, "pg_atoi: error reading \"%s\": %m", s); ! if (badp && *badp && (skip_space(badp) != c)) elog(WARN, "pg_atoi: error in \"%s\": can\'t parse \"%s\"", s, badp); switch (size) { *************** *** 389,391 **** --- 398,678 ---- *val = v; return (0); } + + #ifdef __FreeBSD__ + /*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + /* the following four functions are stolen from the source code of + * function cvt() in 386bsd itself in /usr/src/lib/libc/stdio/vfprintf.c + * by K.Okamoto + */ + + #define to_char(n) ((n) + '0') + #define to_digit(c) ((c) - '0') + # define MAXDIG 25 + # define MAXEXP 40 + + static char * + exponent(p, exp) + register char *p; + register int exp; + { + register char *t; + char expbuf[MAXEXP]; + + *p++ = 'E'; + if (exp < 0) { + exp = -exp; + *p++ = '-'; + } + else + *p++ = '+'; + t = expbuf + MAXEXP; + if (exp > 9) { + do { + *--t = to_char(exp % 10); + } while ((exp /= 10) > 9); + *--t = to_char(exp); + for (; t < expbuf + MAXEXP; *p++ = *t++); + } + else { + *p++ = '0'; + *p++ = to_char(exp); + } + return (p); + } + + static char * + round(fract, exp, start, end, ch, sign) + double fract; + int *exp; + register char *start, *end; + char ch; + int *sign; + { + double tmp; + + if (fract) + (void)modf(fract * 10, &tmp); + else + tmp = to_digit(ch); + if (tmp > 4) + for (;; --end) { + if (*end == '.') + --end; + if (++*end <= '9') + break; + *end = '0'; + if (end == start) { + if (exp) { /* e/E; increment exponent */ + *end = '1'; + ++*exp; + } + else { /* f; add extra digit */ + *--end = '1'; + --start; + } + break; + } + } + /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */ + else if (*sign != 0) + for (;; --end) { + if (*end == '.') + --end; + if (*end != '0') + break; + if (end == start) + *sign = 0; + } + return (start); + } + + char * + fcvt(number, prec, expon, sign, startp, endp) + double number; + register int prec; + int *expon, *sign; + char *startp, *endp; + { + register char *p, *t; + register double fract; + int expcnt; + double integer, tmp; + + *startp = '\0'; + expcnt = 0; + if (number < 0) { + number = -number; + *sign = 1; + } else + *sign = 0; + + fract = modf(number, &integer); + + /* get an extra slot for rounding. */ + t = ++startp; + + /* + * get integer portion of number; put into the end of the buffer; the + * .01 is added for modf(356.0 / 10, &integer) returning .59999999... + */ + for (p = endp - 1; integer; ++expcnt) { + tmp = modf(integer / 10, &integer); + *p-- = to_char((int)((tmp + .01) * 10)); + } + /* reverse integer into beginning of buffer */ + if (expcnt) + for (; ++p < endp; *t++ = *p); + else + *t++ = '0'; + /* + * if precision required, add in a decimal point. + */ + if (prec ) + *t++ = '.'; + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) + do { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } while (--prec && fract); + if (fract) + startp = round(fract, (int *)NULL, startp, + t - 1, (char)0, sign); + } + for (; prec--; *t++ = '0'); + *expon = expcnt; + return ((char *)(startp)); + } + + + char * + ecvt(number, prec, expon, sign, startp, endp) + double number; + register int prec; + int *expon, *sign; + char *startp, *endp; + { + register char *p, *t; + register double fract; + int expcnt, gformat; + double integer, tmp; + + *startp = '\0'; + expcnt = gformat = 0; + if (number < 0) { + number = -number; + *sign = 1; + } else + *sign = 0; + + fract = modf(number, &integer); + + /* get an extra slot for rounding. */ + t = ++startp; + + /* + * get integer portion of number; put into the end of the buffer; the + * .01 is added for modf(356.0 / 10, &integer) returning .59999999... + */ + for (p = endp - 1; integer; ++expcnt) { + tmp = modf(integer / 10, &integer); + *p-- = to_char((int)((tmp + .01) * 10)); + } + if (expcnt) { + *t++ = *++p; + if (prec) + *t++ = '.'; + /* if requires more precision and some integer left */ + for (; prec && ++p < endp; --prec) + *t++ = *p; + /* + * if done precision and more of the integer component, + * round using it; adjust fract so we don't re-round + * later. + */ + if (!prec && ++p < endp) { + fract = 0; + startp = round((double)0, &expcnt, startp, + t - 1, *p, sign); + } + /* adjust expcnt for digit in front of decimal */ + --expcnt; + } + /* until first fractional digit, decrement exponent */ + else if (fract) { + /* adjust expcnt for digit in front of decimal */ + for (expcnt = -1;; --expcnt) { + fract = modf(fract * 10, &tmp); + if (tmp) + break; + } + *t++ = to_char((int)tmp); + if (prec) + *t++ = '.'; + } + else { + *t++ = '0'; + if (prec) + *t++ = '.'; + } + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) + do { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } while (--prec && fract); + if (fract) + startp = round(fract, &expcnt, startp, + t - 1, (char)0, sign); + } + /* if requires more precision */ + for (; prec--; *t++ = '0'); + /* unless alternate flag, trim any g/G format trailing 0's */ + if (gformat) { + while (t > startp && *--t == '0'); + if (*t == '.') + --t; + ++t; + } + t = exponent(t, expcnt); + *expon = expcnt; + return ((char *)(startp)); + } + #endif /* __FreeBSD__ */ *** postgres.orig/src/backend/utils/error/format.c Sun Oct 3 09:40:31 1993 --- postgres/src/backend/utils/error/format.c Mon Apr 11 21:24:59 1994 *************** *** 43,48 **** --- 43,54 ---- static char FormBuf[FormMaxSize]; static char *FormBufP = FormBuf; + #ifdef __FreeBSD__ + #ifndef NEED_VSPRINTF + #define NEED_VSPRINTF + #endif + #endif + /* ---------------- * form * ---------------- *************** *** 60,67 **** --- 66,78 ---- va_list args; char *format; char *str; + #ifdef __FreeBSD__ + #define NEED_VSPRINTF + #endif + #ifdef NEED_VSPRINTF FILE fake; + #endif /* NEED_VSPRINTF */ #ifdef lint fmt = fmt; *************** *** 70,92 **** if (FormBufP + FormMinSize > FormBuf + FormMaxSize) FormBufP = FormBuf; fake._cnt = ((FormBuf + FormMaxSize) - FormBufP) - 1; fake._base = fake._ptr = (iochar *) FormBufP; fake._flag = _IOWRT | _IOSTRG; fake._file = _NFILE; #endif /* NEED_VSPRINTF */ va_start(args); format = va_arg(args, char *); str = FormBufP; ! #ifdef NEED_VSPRINTF _doprnt(format, args, &fake); #ifndef lint (void) putc('\0', &fake); #endif /* lint */ FormBufP += strlen(FormBufP) + 1; ! #else /* !NEED_VSPRINTF */ (void) vsprintf(FormBuf, format, args); #endif /* !NEED_VSPRINTF */ va_end(args); --- 81,111 ---- if (FormBufP + FormMinSize > FormBuf + FormMaxSize) FormBufP = FormBuf; + #ifdef NEED_VSPRINTF + #ifdef __FreeBSD__ + fake._w = ((FormBuf + FormMaxSize) - FormBufP) - 1; + fake._bf._base = fake._p = (iochar *) FormBufP; + fake._flags = __SWR | __SSTR; + fake._file = _NFILE; + #else fake._cnt = ((FormBuf + FormMaxSize) - FormBufP) - 1; fake._base = fake._ptr = (iochar *) FormBufP; fake._flag = _IOWRT | _IOSTRG; fake._file = _NFILE; + #endif /* __FreeBSD__ */ #endif /* NEED_VSPRINTF */ va_start(args); format = va_arg(args, char *); str = FormBufP; ! #ifndef NEED_VSPRINTF _doprnt(format, args, &fake); #ifndef lint (void) putc('\0', &fake); #endif /* lint */ FormBufP += strlen(FormBufP) + 1; ! #else /* NEED_VSPRINTF */ (void) vsprintf(FormBuf, format, args); #endif /* !NEED_VSPRINTF */ va_end(args); *** postgres.orig/src/backend/utils/init/miscinit.c Thu Feb 17 11:24:39 1994 --- postgres/src/backend/utils/init/miscinit.c Mon Apr 11 21:48:11 1994 *************** *** 14,27 **** * ---------------------------------------------------------------- */ - #include /* for getgrgid */ - #include /* for getpwuid */ #include #include /* for MAXPATHLEN */ #include #include #include #include "tmp/postgres.h" #include "tmp/portal.h" /* for EnablePortalManager, etc. */ --- 14,28 ---- * ---------------------------------------------------------------- */ #include #include /* for MAXPATHLEN */ #include #include #include + #include /* for getgrgid */ + #include /* for getpwuid */ + #include "tmp/postgres.h" #include "tmp/portal.h" /* for EnablePortalManager, etc. */ *************** *** 525,531 **** return(-1); } ! static struct groupInfo { gid_t *list; int glim; int ngroups; --- 526,532 ---- return(-1); } ! struct groupInfo { gid_t *list; int glim; int ngroups; *** postgres.orig/src/backend/utils/Gen_fmgrtab.sh Thu Jun 24 12:05:17 1993 --- postgres/src/backend/utils/Gen_fmgrtab.sh Mon Apr 11 21:25:00 1994 *************** *** 95,100 **** --- 95,101 ---- #define FMgrIncluded 1 #include "tmp/c.h" + #include "tmp/postgres.h" typedef char * ((*func_ptr)()); /* ptr to func returning (char *) */ *************** *** 209,219 **** * will need to resolve an external function reference. * * IDENTIFICATION ! * \/usr/local/devel/postgres-4.2-devel/src/backend/utils/RCS/Gen_fmgrtab.sh,v 1.5 1993/06/24 04:05:34 aoki Exp *---------------------------------------------------------------- */ #include /* for MAXINT */ #include "utils/fmgrtab.h" --- 210,225 ---- * will need to resolve an external function reference. * * IDENTIFICATION ! * /usr/local/devel/postgres-4.2-devel/src/backend/utils/RCS/Gen_fmgrtab.sh,v 1.5 1993/06/24 04:05:34 aoki Exp *---------------------------------------------------------------- */ + #ifdef __FreeBSD__ + #include + #define MAXINT INT_MAX + #else #include /* for MAXINT */ + #endif #include "utils/fmgrtab.h" *** postgres.orig/src/backend/lib/readfuncs.c Mon Feb 7 19:54:33 1994 --- postgres/src/backend/lib/readfuncs.c Mon Apr 11 21:25:01 1994 *************** *** 15,20 **** --- 15,23 ---- #include + #if defined(linux) || defined(__FreeBSD__) + #include + #endif #include #include *** postgres.orig/src/backend/libpq/portal.c Wed Feb 2 04:38:49 1994 --- postgres/src/backend/libpq/portal.c Fri Apr 22 14:51:03 1994 *************** *** 210,216 **** continue; } } ! pnames[i][0] = '\0'; } } --- 210,217 ---- continue; } } ! /* pnames[i][0] = '\0'; */ ! pnames[i] = NULL; } } *** postgres.orig/src/backend/libpq/pqcomm.c Wed Feb 9 08:12:06 1994 --- postgres/src/backend/libpq/pqcomm.c Mon Apr 11 21:25:01 1994 *************** *** 48,53 **** --- 48,59 ---- #endif /* SOMAXCONN */ #endif /* PORTNAME_linux */ + #ifdef PORTNAME_freebsd + #ifndef SOMAXCONN + #define SOMAXCONN 5 /* from FreeBSD listen(2) man page */ + #endif /* SOMAXCONN */ + #endif /* PORTNAME_freebsd */ + #include "libpq/auth.h" #include "tmp/c.h" #include "tmp/libpq.h" *************** *** 533,538 **** --- 539,564 ---- /* StreamOpen already set PQerrormsg */ return(STATUS_ERROR); + #if defined(linux) || defined(__FreeBSD__) + { + struct hostent *hp; + + /* The gethostbyname() just succeeded for the StreamOpen() call, so + it shouldn't fail, but who knows. */ + if (! hostName) + hostName = "localhost"; + if ((hp = gethostbyname(hostName)) && hp->h_addrtype == AF_INET) + bcopy(hp->h_addr, (char *)&(SendPort -> raddr.sin_addr), hp->h_length); + else { + fprintf(stderr, + "StreamServerPort: cannot find hostname '%s' for stream port\n", + hostName); + return(STATUS_ERROR); + } + SendPort -> raddr.sin_family = AF_INET; + SendPort -> raddr.sin_port = htons(portName); + } + #endif /* initialize */ msgtype = fe_getauthsvc(); status = PacketSend(SendPort, MyConn, &startup, msgtype, *** postgres.orig/src/backend/postmaster/postmaster.c Wed Feb 9 08:12:06 1994 --- postgres/src/backend/postmaster/postmaster.c Mon Apr 11 21:25:02 1994 *************** *** 37,43 **** --- 37,48 ---- #include #include #include + #ifdef __FreeBSD__ + #include + #define MAXINT INT_MAX + #else #include /* for MAXINT */ + #endif #if defined(PORTNAME_alpha) || defined(PORTNAME_aix) #if !defined(_BSD) *************** *** 588,601 **** */ reaper() { union wait status; /* backend exit status */ int pid; /* process id of dead backend */ if (DebugLvl) fprintf(stderr, "%s: reaping dead processes...\n", progname); while((pid = wait3(&status, WNOHANG, (struct rusage *) NULL)) > 0) ! CleanupProc(pid, status.w_status); } /* --- 593,614 ---- */ reaper() { + #if defined(linux) || defined(__FreeBSD__) + int status; + #else union wait status; /* backend exit status */ + #endif int pid; /* process id of dead backend */ if (DebugLvl) fprintf(stderr, "%s: reaping dead processes...\n", progname); while((pid = wait3(&status, WNOHANG, (struct rusage *) NULL)) > 0) ! #if defined(linux) || defined(__FreeBSD__) ! (void) CleanupProc(pid, WEXITSTATUS(status)); ! #else ! (void) CleanupProc(pid, status.w_status); ! #endif } /* *** postgres.orig/src/tools/bmake/parse.c Sat Aug 7 17:05:15 1993 --- postgres/src/tools/bmake/parse.c Mon Apr 11 21:25:03 1994 *************** *** 1334,1340 **** * XXX: If the child writes more than a pipe's worth, we will * deadlock. */ ! while(((pid = wait(&status)) != cpid) && (pid >= 0)) { ; } --- 1334,1340 ---- * XXX: If the child writes more than a pipe's worth, we will * deadlock. */ ! while(((pid = wait((int *)&status)) != cpid) && (pid >= 0)) { ; } *** postgres.orig/src/tools/bmake/compat.c Sat Aug 7 17:47:15 1993 --- postgres/src/tools/bmake/compat.c Mon Apr 11 21:25:03 1994 *************** *** 270,276 **** id = 0; } ! while ((stat = wait(&reason)) != cpid) { if (stat == -1 && errno != EINTR) { break; } --- 270,276 ---- id = 0; } ! while ((stat = wait((int *)&reason)) != cpid) { if (stat == -1 && errno != EINTR) { break; } *** postgres.orig/src/tools/bmake/job.c Sat Aug 7 17:47:15 1993 --- postgres/src/tools/bmake/job.c Mon Apr 11 21:25:04 1994 *************** *** 1920,1926 **** return; } ! while ((pid = wait3(&status, (block?0:WNOHANG)|WUNTRACED, (struct rusage *)0)) > 0) { if (DEBUG(JOB)) --- 1920,1926 ---- return; } ! while ((pid = wait3((int *) &status, (block?0:WNOHANG)|WUNTRACED, (struct rusage *)0)) > 0) { if (DEBUG(JOB)) *************** *** 2632,2638 **** /* * Catch as many children as want to report in at first, then give up */ ! while (wait3(&foo, WNOHANG, (struct rusage *)0) > 0) { ; } (void) unlink (tfile); --- 2632,2638 ---- /* * Catch as many children as want to report in at first, then give up */ ! while (wait3((int *) &foo, WNOHANG, (struct rusage *)0) > 0) { ; } (void) unlink (tfile); *** postgres.orig/src/tools/bmake/Bootstrap Sat Apr 2 06:45:02 1994 --- postgres/src/tools/bmake/Bootstrap Mon Apr 11 21:25:05 1994 *************** *** 58,63 **** --- 58,75 ---- s/^MORELIBS=.*/MORELIBS=-lbsd/ EOF ;; + freebsd) + cat > $SEDFILE << 'EOF' + s/^PORTNAME=.*/PORTNAME=freebsd/ + s/^OLD_CC=.*/OLD_CC=/ + s/^AR_TYPE=.*/AR_TYPE=/ + s/^NEED_STRINGS=.*/NEED_STRINGS=/ + s/^BSD_WAIT3.*=/BSD_WAIT3=-D__USE_BSD -D__USE_BSD_SIGNAL/ + s/^MORESRCS=.*/MORESRCS=/ + s/^MOREOBJS=.*/MOREOBJS=/ + s/^MORELIBS=.*/MORELIBS=/ + EOF + ;; sparc) cat > $SEDFILE << 'EOF' s/^PORTNAME=.*/PORTNAME=sparc/ *************** *** 84,90 **** ;; *) echo "$0: invalid port name:" $1 ! echo "$0: valid port names are: aix alpha hpux linux sparc ultrix4" exit 1; ;; esac --- 96,102 ---- ;; *) echo "$0: invalid port name:" $1 ! echo "$0: valid port names are: aix alpha hpux linux freebsd sparc ultrix4" exit 1; ;; esac *** postgres.orig/src/ref/make_kwtab Tue Jan 26 10:42:56 1993 --- postgres/src/ref/make_kwtab Mon Apr 11 21:31:56 1994 *************** *** 31,34 **** } print ".fi"; print ".ft"; ! } --- 31,34 ---- } print ".fi"; print ".ft"; ! }' *** postgres.orig/src/ref/Makefile Fri Mar 11 21:12:29 1994 --- postgres/src/ref/Makefile Mon Apr 11 21:25:05 1994 *************** *** 283,305 **** all: ref.cat ref.ps ${OBJS} install: ${OBJS} all ! @-for i in ${PROG_MAN_DIR} ${CMD_MAN_DIR} ${LIB_MAN_DIR} ${FILE_MAN_DIR}; \ ! do \ ! if [ ! -d $$i ]; then \ ! mkdir $$i; \ ! fi; \ ! done for i in ${PROG_MAN_OBJS}; do \ ! install -m 444 $$i ${PROG_MAN_DIR}/$$i; \ done; \ for i in ${CMD_MAN_OBJS}; do \ ! install -m 444 $$i ${CMD_MAN_DIR}/$$i; \ done; \ for i in ${LIB_MAN_OBJS}; do \ ! install -m 444 $$i ${LIB_MAN_DIR}/$$i; \ done; \ for i in ${FILE_MAN_OBJS}; do \ ! install -m 444 $$i ${FILE_MAN_DIR}/$$i; \ done; \ install -m 444 ref.cat ${POSTDOCDIR}/ref.cat; \ install -m 444 ref.ps ${POSTDOCDIR}/ref.ps; --- 283,306 ---- all: ref.cat ref.ps ${OBJS} install: ${OBJS} all ! echo installing reference ! for i in ${PROG_MAN_DIR} ${CMD_MAN_DIR} ${LIB_MAN_DIR} ${FILE_MAN_DIR}; \ ! do ; \ ! if [ ! -d $$i ]; then \ ! mkdir $$i ; \ ! fi ; \ ! done ; \ for i in ${PROG_MAN_OBJS}; do \ ! install -m 444 $$i ${PROG_MAN_DIR}; \ done; \ for i in ${CMD_MAN_OBJS}; do \ ! install -m 444 $$i ${CMD_MAN_DIR}; \ done; \ for i in ${LIB_MAN_OBJS}; do \ ! install -m 444 $$i ${LIB_MAN_DIR}; \ done; \ for i in ${FILE_MAN_OBJS}; do \ ! install -m 444 $$i ${FILE_MAN_DIR}; \ done; \ install -m 444 ref.cat ${POSTDOCDIR}/ref.cat; \ install -m 444 ref.ps ${POSTDOCDIR}/ref.ps; *** postgres.orig/src/Makefile.global Sat Apr 2 06:55:55 1994 --- postgres/src/Makefile.global Mon Apr 11 21:25:06 1994 *************** *** 60,65 **** --- 60,66 ---- # hpux - HP PA-RISC on HP-UX 9.00 or 9.01 # alpha - DEC Alpha AXP on OSF/1 1.3 # aix - IBM POWER on AIX 3.2.5 + # freebsd - PC[345]86 on FreeBSD-1.1 # Some hooks are provided for # linux - Intel 386/486 on Linux 0.99pl11 # svr4 - Intel 386/486 on Intel SVR4 *************** *** 71,77 **** # ./obj/Makefile.global does not take effect (for .if purposes) # until after this file is processed! # ! PORTNAME?= ultrix4 # # POSTGRESLOGIN is the login name of the user who gets special --- 72,78 ---- # ./obj/Makefile.global does not take effect (for .if purposes) # until after this file is processed! # ! PORTNAME?= freebsd # # POSTGRESLOGIN is the login name of the user who gets special *************** *** 140,146 **** MACHINE=sparc .elif (${PORTNAME} == "hpux") MACHINE=hppa ! .elif (${PORTNAME} == "linux" || ${PORTNAME} == "svr4") MACHINE=i386 .endif --- 141,147 ---- MACHINE=sparc .elif (${PORTNAME} == "hpux") MACHINE=hppa ! .elif (${PORTNAME} == "linux" || ${PORTNAME} == "svr4" || ${PORTNAME} == "freebsd") MACHINE=i386 .endif *************** *** 328,335 **** # semantics. We can use the POSIX sigaction(2) on systems that # allow us to request restartable signals (SA_RESTART). # ! .if (${PORTNAME} == "alpha" || ${PORTNAME} == "svr4") CFLAGS+= -DUSE_POSIX_SIGNALS .endif # # Some systems don't allow restartable signals at all unless we --- 329,339 ---- # semantics. We can use the POSIX sigaction(2) on systems that # allow us to request restartable signals (SA_RESTART). # ! .if (${PORTNAME} == "alpha" || ${PORTNAME} == "svr4" || ${PORTNAME} == "freebsd") CFLAGS+= -DUSE_POSIX_SIGNALS + .if (${PORTNAME} == "freebsd") + CFLAGS+= -fwritable-strings + .endif .endif # # Some systems don't allow restartable signals at all unless we *** postgres.orig/src/grepsrc Thu Dec 24 06:03:23 1992 --- postgres/src/grepsrc Mon Apr 11 21:46:20 1994 *************** *** 5,9 **** ;; esac ! gfind . -name '*.[hclyg]*' -print | xargs egrep "$1" --- 5,9 ---- ;; esac ! find . -name '*.[hclyg]*' -print | xargs egrep "$1"