diff --git a/configure b/configure index 13de7fd2f0..1a09a82268 100755 --- a/configure +++ b/configure @@ -1393,7 +1393,7 @@ case $host_os in hpux*) template=hpux ;; irix*) template=irix5 ;; linux*) template=linux ;; - mingw*) template=win ;; + mingw*) template=win32 ;; netbsd*) template=netbsd ;; nextstep*) template=nextstep ;; openbsd*) template=openbsd ;; @@ -2808,7 +2808,6 @@ echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;} done IFS=$ac_save_IFS - # # Tcl/Tk # @@ -5236,6 +5235,65 @@ _ACEOF fi + +echo "$as_me:$LINENO: checking for main in -lwsock32" >&5 +echo $ECHO_N "checking for main in -lwsock32... $ECHO_C" >&6 +if test "${ac_cv_lib_wsock32_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lwsock32 $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_wsock32_main=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_wsock32_main=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_wsock32_main" >&5 +echo "${ECHO_T}$ac_cv_lib_wsock32_main" >&6 +if test $ac_cv_lib_wsock32_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBWSOCK32 1 +_ACEOF + + LIBS="-lwsock32 $LIBS" + +fi + echo "$as_me:$LINENO: checking for library containing getopt_long" >&5 echo $ECHO_N "checking for library containing getopt_long... $ECHO_C" >&6 if test "${ac_cv_search_getopt_long+set}" = set; then @@ -6072,6 +6130,85 @@ echo "$as_me: error: library 'krb' is required for Kerberos 4" >&2;} { (exit 1); exit 1; }; } fi + +for ac_func in gethostname +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + LIBOBJS="$LIBOBJS $ac_func.$ac_objext" +fi +done + + fi if test "$with_krb5" = yes ; then @@ -11080,7 +11217,7 @@ fi -for ac_func in crypt fseeko gethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul +for ac_func in crypt fseeko getopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -11258,9 +11395,8 @@ LIBOBJS="$LIBOBJS qsort.$ac_objext" ;; esac # Win32 can't to rename or unlink on an open file -case $host_os in win32*) -LIBOBJS="$LIBOBJS dirmod.$ac_objext" -LIBOBJS="$LIBOBJS opendir.$ac_objext" ;; +case $host_os in win32*|mingw*) +LIBOBJS="$LIBOBJS dirmod.$ac_objext" ;; esac if test "$with_readline" = yes; then diff --git a/configure.in b/configure.in index b7f5aa63d0..774f439829 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $Header: /cvsroot/pgsql/configure.in,v 1.249 2003/05/10 04:03:37 momjian Exp $ +dnl $Header: /cvsroot/pgsql/configure.in,v 1.250 2003/05/15 16:35:27 momjian Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -65,7 +65,7 @@ case $host_os in hpux*) template=hpux ;; irix*) template=irix5 ;; linux*) template=linux ;; - mingw*) template=win ;; + mingw*) template=win32 ;; netbsd*) template=netbsd ;; nextstep*) template=nextstep ;; openbsd*) template=openbsd ;; @@ -319,7 +319,6 @@ for dir in $LIBRARY_DIRS $SRCH_LIB; do done IFS=$ac_save_IFS - # # Tcl/Tk # @@ -607,6 +606,7 @@ AC_CHECK_LIB(BSD, main) AC_CHECK_LIB(gen, main) AC_CHECK_LIB(PW, main) AC_CHECK_LIB(resolv, main) +AC_CHECK_LIB(wsock32, main) AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt]) # QNX: AC_CHECK_LIB(unix, main) @@ -639,6 +639,7 @@ fi if test "$with_krb4" = yes ; then AC_CHECK_LIB(des, des_encrypt, [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])]) AC_CHECK_LIB(krb, krb_sendauth, [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])]) + AC_REPLACE_FUNCS([gethostname]) fi if test "$with_krb5" = yes ; then @@ -839,7 +840,7 @@ else AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break]) fi -AC_REPLACE_FUNCS([crypt fseeko gethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul]) +AC_REPLACE_FUNCS([crypt fseeko getopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul]) # system's version of getaddrinfo(), if any, may be used only if we found # a definition for struct addrinfo; see notes in src/include/getaddrinfo.h @@ -862,9 +863,8 @@ AC_LIBOBJ(qsort) ;; esac # Win32 can't to rename or unlink on an open file -case $host_os in win32*) -AC_LIBOBJ(dirmod) -AC_LIBOBJ(opendir) ;; +case $host_os in win32*|mingw*) +AC_LIBOBJ(dirmod) ;; esac if test "$with_readline" = yes; then diff --git a/doc/TODO b/doc/TODO index 9191f9ff1a..3422af9c1f 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,6 +1,6 @@ TODO list for PostgreSQL ======================== -Last updated: Wed Apr 2 17:44:34 EST 2003 +Last updated: Thu May 15 12:10:39 EDT 2003 Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index 9c5abfd64a..87257922f3 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.31 2003/04/25 04:37:23 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.32 2003/05/15 16:35:28 momjian Exp $ * * Since the server static private key ($DataDir/server.key) * will normally be stored unencrypted so that the database @@ -85,16 +85,12 @@ #include "libpq/libpq.h" #include "miscadmin.h" -#ifdef WIN32 -#include "win32.h" -#else #include #include #include #include #ifdef HAVE_NETINET_TCP_H #include -#endif #include #endif diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index bebff36537..27d9437154 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -30,7 +30,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.152 2003/04/25 01:24:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.153 2003/05/15 16:35:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -357,6 +357,9 @@ Setup_AF_UNIX(void) Assert(Unix_socket_group); if (Unix_socket_group[0] != '\0') { +#ifdef WIN32 + elog(FATAL, "Config value 'unix_socket_group' not supported on this platform"); +#else char *endptr; unsigned long int val; gid_t gid; @@ -385,6 +388,7 @@ Setup_AF_UNIX(void) sock_path, strerror(errno)); return STATUS_ERROR; } +#endif } if (chmod(sock_path, Unix_socket_permissions) == -1) diff --git a/src/backend/main/main.c b/src/backend/main/main.c index 8f69e0a693..c86b45b132 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.56 2002/11/08 20:23:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.57 2003/05/15 16:35:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -159,13 +159,14 @@ main(int argc, char *argv[]) strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0))) { +#ifndef WIN32 +#ifndef __BEOS__ /* * Make sure we are not running as root. * * BeOS currently runs everything as root :-(, so this check must be * temporarily disabled there... */ -#ifndef __BEOS__ if (geteuid() == 0) { fprintf(stderr, gettext( @@ -176,7 +177,7 @@ main(int argc, char *argv[]) )); exit(1); } -#endif /* __BEOS__ */ +#endif /* !__BEOS__ */ /* * Also make sure that real and effective uids are the same. @@ -193,6 +194,7 @@ main(int argc, char *argv[]) argv[0]); exit(1); } +#endif /* !WIN32 */ } /* @@ -221,6 +223,7 @@ main(int argc, char *argv[]) * specifying current userid as the "authenticated" Postgres user * name. */ +#ifndef WIN32 pw = getpwuid(geteuid()); if (pw == NULL) { @@ -230,6 +233,18 @@ main(int argc, char *argv[]) } /* Allocate new memory because later getpwuid() calls can overwrite it */ pw_name_persist = strdup(pw->pw_name); +#else + { + long namesize = 256 /* UNLEN */ + 1; + + pw_name_persist = malloc(namesize); + if (!GetUserName(pw_name_persist, &namesize)) + { + fprintf(stderr, "%s: GetUserName failed\n", argv[0]); + exit(1); + } + } +#endif exit(PostgresMain(argc, new_argv, pw_name_persist)); } diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 4f8b0b10fc..0a7ae361f4 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.413 2003/05/04 00:03:55 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.414 2003/05/15 16:35:28 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -322,12 +322,12 @@ static void doNegateFloat(Value *v); */ /* ordinary key words in alphabetical order */ -%token ABORT_P ABSOLUTE ACCESS ACTION ADD AFTER +%token ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER AGGREGATE ALL ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC ASSERTION ASSIGNMENT AT AUTHORIZATION BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT - BOOLEAN BOTH BY + BOOLEAN_P BOTH BY CACHE CALLED CASCADE CASE CAST CHAIN CHAR_P CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE @@ -336,9 +336,9 @@ static void doNegateFloat(Value *v); CREATEUSER CROSS CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE - DATABASE DAY_P DEALLOCATE DEC DECIMAL DECLARE DEFAULT + DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS - DESC DISTINCT DO DOMAIN_P DOUBLE DROP + DESC DISTINCT DO DOMAIN_P DOUBLE_P DROP EACH ELSE ENCODING ENCRYPTED END_P ESCAPE EXCEPT EXCLUSIVE EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT @@ -351,8 +351,8 @@ static void doNegateFloat(Value *v); HANDLER HAVING HOLD HOUR_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCREMENT - INDEX INHERITS INITIALLY INNER_P INOUT INPUT - INSENSITIVE INSERT INSTEAD INT INTEGER INTERSECT + INDEX INHERITS INITIALLY INNER_P INOUT INPUT_P + INSENSITIVE INSERT INSTEAD INT_P INTEGER INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION JOIN @@ -373,18 +373,17 @@ static void doNegateFloat(Value *v); ORDER OUT_P OUTER_P OVERLAPS OVERLAY OWNER PARTIAL PASSWORD PATH_P PENDANT PLACING POSITION - PRECISION PRESERVE PREPARE PRIMARY PRIOR PRIVILEGES PROCEDURAL - PROCEDURE + PRECISION PRESERVE PREPARE PRIMARY + PRIOR PRIVILEGES PROCEDURAL PROCEDURE - READ REAL RECHECK REFERENCES REINDEX RELATIVE RENAME REPLACE + READ REAL RECHECK REFERENCES REINDEX RELATIVE_P RENAME REPLACE RESET RESTART RESTRICT RETURNS REVOKE RIGHT ROLLBACK ROW ROWS RULE SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT - STATISTICS STDIN STDOUT STORAGE STRICT SUBSTRING - SYSID + STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYSID TABLE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P @@ -2675,14 +2674,14 @@ fetch_direction: n->howMany = -1; $$ = (Node *)n; } - | ABSOLUTE fetch_count + | ABSOLUTE_P fetch_count { FetchStmt *n = makeNode(FetchStmt); n->direction = FETCH_ABSOLUTE; n->howMany = $2; $$ = (Node *)n; } - | RELATIVE fetch_count + | RELATIVE_P fetch_count { FetchStmt *n = makeNode(FetchStmt); n->direction = FETCH_RELATIVE; @@ -3146,15 +3145,15 @@ createfunc_opt_item: { $$ = makeDefElem("volatility", (Node *)makeString("volatile")); } - | CALLED ON NULL_P INPUT + | CALLED ON NULL_P INPUT_P { $$ = makeDefElem("strict", (Node *)makeInteger(FALSE)); } - | RETURNS NULL_P ON NULL_P INPUT + | RETURNS NULL_P ON NULL_P INPUT_P { $$ = makeDefElem("strict", (Node *)makeInteger(TRUE)); } - | STRICT + | STRICT_P { $$ = makeDefElem("strict", (Node *)makeInteger(TRUE)); } @@ -5077,7 +5076,7 @@ GenericType: * Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30 * - thomas 1997-09-18 */ -Numeric: INT +Numeric: INT_P { $$ = SystemTypeName("int4"); } @@ -5101,11 +5100,11 @@ Numeric: INT { $$ = $2; } - | DOUBLE PRECISION + | DOUBLE_P PRECISION { $$ = SystemTypeName("float8"); } - | DECIMAL opt_decimal + | DECIMAL_P opt_decimal { $$ = SystemTypeName("numeric"); $$->typmod = $2; @@ -5120,7 +5119,7 @@ Numeric: INT $$ = SystemTypeName("numeric"); $$->typmod = $2; } - | BOOLEAN + | BOOLEAN_P { $$ = SystemTypeName("bool"); } @@ -7179,7 +7178,7 @@ ColLabel: IDENT { $$ = $1; } */ unreserved_keyword: ABORT_P - | ABSOLUTE + | ABSOLUTE_P | ACCESS | ACTION | ADD @@ -7222,7 +7221,7 @@ unreserved_keyword: | DELIMITER | DELIMITERS | DOMAIN_P - | DOUBLE + | DOUBLE_P | DROP | EACH | ENCODING @@ -7248,7 +7247,7 @@ unreserved_keyword: | INDEX | INHERITS | INOUT - | INPUT + | INPUT_P | INSENSITIVE | INSERT | INSTEAD @@ -7299,7 +7298,7 @@ unreserved_keyword: | READ | RECHECK | REINDEX - | RELATIVE + | RELATIVE_P | RENAME | REPLACE | RESET @@ -7328,8 +7327,8 @@ unreserved_keyword: | STDIN | STDOUT | STORAGE - | STRICT | SYSID + | STRICT_P | TEMP | TEMPLATE | TEMPORARY @@ -7374,17 +7373,17 @@ unreserved_keyword: col_name_keyword: BIGINT | BIT - | BOOLEAN + | BOOLEAN_P | CHAR_P | CHARACTER | COALESCE | CONVERT | DEC - | DECIMAL + | DECIMAL_P | EXISTS | EXTRACT | FLOAT_P - | INT + | INT_P | INTEGER | INTERVAL | NCHAR diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c index 2bee083287..b035a828f3 100644 --- a/src/backend/parser/keywords.c +++ b/src/backend/parser/keywords.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.138 2003/04/08 23:20:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.139 2003/05/15 16:35:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,7 +31,7 @@ static const ScanKeyword ScanKeywords[] = { /* name, value */ {"abort", ABORT_P}, - {"absolute", ABSOLUTE}, + {"absolute", ABSOLUTE_P}, {"access", ACCESS}, {"action", ACTION}, {"add", ADD}, @@ -57,7 +57,7 @@ static const ScanKeyword ScanKeywords[] = { {"bigint", BIGINT}, {"binary", BINARY}, {"bit", BIT}, - {"boolean", BOOLEAN}, + {"boolean", BOOLEAN_P}, {"both", BOTH}, {"by", BY}, {"cache", CACHE}, @@ -99,7 +99,7 @@ static const ScanKeyword ScanKeywords[] = { {"day", DAY_P}, {"deallocate", DEALLOCATE}, {"dec", DEC}, - {"decimal", DECIMAL}, + {"decimal", DECIMAL_P}, {"declare", DECLARE}, {"default", DEFAULT}, {"deferrable", DEFERRABLE}, @@ -112,7 +112,7 @@ static const ScanKeyword ScanKeywords[] = { {"distinct", DISTINCT}, {"do", DO}, {"domain", DOMAIN_P}, - {"double", DOUBLE}, + {"double", DOUBLE_P}, {"drop", DROP}, {"each", EACH}, {"else", ELSE}, @@ -157,11 +157,11 @@ static const ScanKeyword ScanKeywords[] = { {"initially", INITIALLY}, {"inner", INNER_P}, {"inout", INOUT}, - {"input", INPUT}, + {"input", INPUT_P}, {"insensitive", INSENSITIVE}, {"insert", INSERT}, {"instead", INSTEAD}, - {"int", INT}, + {"int", INT_P}, {"integer", INTEGER}, {"intersect", INTERSECT}, {"interval", INTERVAL}, @@ -246,7 +246,7 @@ static const ScanKeyword ScanKeywords[] = { {"recheck", RECHECK}, {"references", REFERENCES}, {"reindex", REINDEX}, - {"relative", RELATIVE}, + {"relative", RELATIVE_P}, {"rename", RENAME}, {"replace", REPLACE}, {"reset", RESET}, @@ -283,7 +283,7 @@ static const ScanKeyword ScanKeywords[] = { {"stdin", STDIN}, {"stdout", STDOUT}, {"storage", STORAGE}, - {"strict", STRICT}, + {"strict", STRICT_P}, {"substring", SUBSTRING}, {"sysid", SYSID}, {"table", TABLE}, diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile index 3a9a38af89..66086d9c3b 100644 --- a/src/backend/port/Makefile +++ b/src/backend/port/Makefile @@ -13,7 +13,7 @@ # be converted to Method 2. # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.18 2002/07/27 20:10:05 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.19 2003/05/15 16:35:29 momjian Exp $ # #------------------------------------------------------------------------- @@ -26,7 +26,7 @@ OBJS+=dynloader.o pg_sema.o pg_shmem.o OBJS+=$(TAS) ifeq ($(PORTNAME), qnx4) -OBJS+=getrusage.o qnx4/SUBSYS.o +OBJS+=qnx4/SUBSYS.o endif ifeq ($(PORTNAME), beos) OBJS+=beos/SUBSYS.o @@ -34,6 +34,9 @@ endif ifeq ($(PORTNAME), darwin) OBJS+=darwin/SUBSYS.o endif +ifeq ($(PORTNAME), win32) +OBJS+=win32/SUBSYS.o +endif all: SUBSYS.o @@ -55,6 +58,11 @@ darwin/SUBSYS.o: darwin.dir darwin.dir: $(MAKE) -C darwin all +win32/SUBSYS.o: win32.dir + +win32.dir: + $(MAKE) -C win32 all + tas.o: tas.s $(CC) $(CFLAGS) -c $< @@ -67,3 +75,5 @@ distclean clean: $(MAKE) -C beos clean $(MAKE) -C darwin clean $(MAKE) -C qnx4 clean + $(MAKE) -C win32 clean + diff --git a/src/backend/port/dynloader/win.c b/src/backend/port/dynloader/win32.c similarity index 75% rename from src/backend/port/dynloader/win.c rename to src/backend/port/dynloader/win32.c index 005ac40e75..e124ee4120 100644 --- a/src/backend/port/dynloader/win.c +++ b/src/backend/port/dynloader/win32.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/win.c,v 1.2 2003/03/21 17:18:34 petere Exp $ */ +/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/win32.c,v 1.1 2003/05/15 16:35:29 momjian Exp $ */ #include diff --git a/src/backend/port/dynloader/win.h b/src/backend/port/dynloader/win32.h similarity index 100% rename from src/backend/port/dynloader/win.h rename to src/backend/port/dynloader/win32.h diff --git a/src/backend/port/win32/sema.c b/src/backend/port/win32/sema.c index 489918fa97..267b461920 100644 --- a/src/backend/port/win32/sema.c +++ b/src/backend/port/win32/sema.c @@ -10,7 +10,6 @@ #include "postgres.h" #include "storage/shmem.h" -#include "sema.h" #include @@ -131,7 +130,8 @@ semget(int semKey, int semNum, int flags) Size sem_set_size = sizeof(win32_sem_set_hdr) + semNum * (sizeof(HANDLE) + sizeof(int)); HANDLE *sem_handles = NULL; int *sem_counts = NULL; - + int i; + sec_attrs.nLength = sizeof(sec_attrs); sec_attrs.lpSecurityDescriptor = NULL; sec_attrs.bInheritHandle = TRUE; @@ -158,7 +158,7 @@ semget(int semKey, int semNum, int flags) sem_handles = (HANDLE *) ((off_t) new_set + new_set->m_semaphoreHandles); sem_counts = (int *) ((off_t) new_set + new_set->m_semaphoreCounts); - for (int i = 0; i < semNum && ans; ++i) + for (i = 0; i < semNum && ans; ++i) { strcpy(num_part, _itoa(i, cur_num, 10)); @@ -186,8 +186,9 @@ semget(int semKey, int semNum, int flags) return MAKE_OFFSET(new_set); else { + int i; /* Blow away what we've got right now... */ - for (int i = 0; i < semNum; ++i) + for (i = 0; i < semNum; ++i) { if (sem_handles[i]) CloseHandle(sem_handles[i]); diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index e5bd93eb06..2b8708fc5d 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -13,7 +13,7 @@ * * Copyright (c) 2001-2003, PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.35 2003/04/27 20:09:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.36 2003/05/15 16:35:29 momjian Exp $ * ---------- */ #include "postgres.h" @@ -217,7 +217,7 @@ pgstat_init(void) * messages will be discarded; backends won't block waiting to send * messages to the collector. */ - if (fcntl(pgStatSock, F_SETFL, O_NONBLOCK) < 0) + if (FCNTL_NONBLOCK(pgStatSock) < 0) { elog(LOG, "PGSTAT: fcntl() failed: %m"); goto startup_failed; @@ -1520,7 +1520,7 @@ pgstat_recvbuffer(void) * Set the write pipe to nonblock mode, so that we cannot block when * the collector falls behind. */ - if (fcntl(writePipe, F_SETFL, O_NONBLOCK) < 0) + if (FCNTL_NONBLOCK(writePipe) < 0) { elog(LOG, "PGSTATBUFF: fcntl() failed: %m"); exit(1); diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index f52e2879f8..40179c80af 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.327 2003/05/10 18:15:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.328 2003/05/15 16:35:29 momjian Exp $ * * NOTES * @@ -211,6 +211,11 @@ bool LogSourcePort; bool Log_connections = false; bool Db_user_namespace = false; +/* For FNCTL_NONBLOCK */ +#if defined(WIN32) || defined(__BEOS__) +long ioctlsocket_ret; +#endif + /* list of library:init-function to be preloaded */ char *preload_libraries_string = NULL; @@ -1708,6 +1713,9 @@ reaper(SIGNAL_ARGS) { int save_errno = errno; +#ifdef WIN32 +#warning fix waidpid for Win32 +#else #ifdef HAVE_WAITPID int status; /* backend exit status */ @@ -1807,6 +1815,7 @@ reaper(SIGNAL_ARGS) CleanupProc(pid, exitstatus); } /* loop over pending child-death reports */ +#endif if (FatalError) { @@ -2141,23 +2150,14 @@ report_fork_failure_to_client(Port *port, int errnum) { char buffer[1000]; -#ifdef __BEOS__ - int on = 1; -#endif - /* Format the error message packet */ snprintf(buffer, sizeof(buffer), "E%s%s\n", gettext("Server process fork() failed: "), strerror(errnum)); /* Set port to non-blocking. Don't do send() if this fails */ -#ifdef __BEOS__ - if (ioctl(port->sock, FIONBIO, &on) != 0) + if (FCNTL_NONBLOCK(port->sock) < 0) return; -#else - if (fcntl(port->sock, F_SETFL, O_NONBLOCK) < 0) - return; -#endif send(port->sock, buffer, strlen(buffer) + 1, 0); } diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index cc02c75f13..02ab546902 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.129 2003/02/18 02:13:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.130 2003/05/15 16:35:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -944,6 +944,9 @@ ProcSendSignal(BackendId procId) bool enable_sig_alarm(int delayms, bool is_statement_timeout) { +#ifdef WIN32 +# warning add Win32 timer +#else struct timeval fin_time; #ifndef __BEOS__ struct itimerval timeval; @@ -1012,7 +1015,7 @@ enable_sig_alarm(int delayms, bool is_statement_timeout) if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0) return false; #endif - +#endif return true; } @@ -1026,6 +1029,9 @@ enable_sig_alarm(int delayms, bool is_statement_timeout) bool disable_sig_alarm(bool is_statement_timeout) { +#ifdef WIN32 +#warning add Win32 timer +#else /* * Always disable the interrupt if it is active; this avoids being * interrupted by the signal handler and thereby possibly getting @@ -1065,7 +1071,7 @@ disable_sig_alarm(bool is_statement_timeout) if (!CheckStatementTimeout()) return false; } - +#endif return true; } @@ -1098,6 +1104,9 @@ CheckStatementTimeout(void) else { /* Not time yet, so (re)schedule the interrupt */ +#ifdef WIN32 +#warning add win32 timer +#else #ifndef __BEOS__ struct itimerval timeval; @@ -1120,6 +1129,7 @@ CheckStatementTimeout(void) (statement_fin_time.tv_usec - now.tv_usec); if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0) return false; +#endif #endif } diff --git a/src/backend/utils/init/findbe.c b/src/backend/utils/init/findbe.c index 94d744bce9..b0bb792379 100644 --- a/src/backend/utils/init/findbe.c +++ b/src/backend/utils/init/findbe.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.32 2003/04/04 20:42:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.33 2003/05/15 16:35:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,9 +44,11 @@ static int ValidateBinary(char *path) { struct stat buf; +#ifndef WIN32 uid_t euid; struct group *gp; struct passwd *pwp; +#endif int i; int is_r = 0; int is_x = 0; @@ -82,6 +84,11 @@ ValidateBinary(char *path) * Ensure that the file is both executable and readable (required for * dynamic loading). */ +#ifdef WIN32 + is_r = buf.st_mode & S_IRUSR; + is_x = buf.st_mode & S_IXUSR; + return is_x ? (is_r ? 0 : -2) : -1; +#else euid = geteuid(); if (euid == buf.st_uid) { @@ -125,6 +132,7 @@ ValidateBinary(char *path) elog(DEBUG2, "ValidateBinary: \"%s\" is not other read/execute", path); return is_x ? (is_r ? 0 : -2) : -1; +#endif } /* diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c index 7c62d8c4ab..fcb88f156c 100644 --- a/src/backend/utils/mb/encnames.c +++ b/src/backend/utils/mb/encnames.c @@ -2,7 +2,7 @@ * Encoding names and routines for work with it. All * in this file is shared bedween FE and BE. * - * $Id: encnames.c,v 1.12 2003/03/10 22:28:18 tgl Exp $ + * $Id: encnames.c,v 1.13 2003/05/15 16:35:29 momjian Exp $ */ #ifdef FRONTEND #include "postgres_fe.h" @@ -13,11 +13,7 @@ #include "utils/builtins.h" #endif -#ifdef WIN32 -#include "win32.h" -#else #include -#endif #include "mb/pg_wchar.h" #include diff --git a/src/include/c.h b/src/include/c.h index 3cb185e5c7..4daa40d5d5 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.144 2003/05/09 16:59:43 momjian Exp $ + * $Id: c.h,v 1.145 2003/05/15 16:35:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,6 @@ #include "pg_config.h" #include "pg_config_manual.h" /* must be after pg_config.h */ -#include "pg_config_os.h" #include "postgres_ext.h" #include @@ -66,11 +65,14 @@ #include #include -#include /* ensure O_BINARY is available */ +#include /* ensure O_BINARY is available */ #ifdef HAVE_SUPPORTDEFS_H #include #endif +/* Must be here so we can redefine some functions on Win32 */ +#include "pg_config_os.h" + /* Must be before gettext() games below */ #include @@ -696,64 +698,23 @@ typedef NameData *Name; #define PG_BINARY_W "w" #endif +#if !defined(WIN32) && !defined(__BEOS__) +#define FCNTL_NONBLOCK(sock) fcntl(sock, F_SETFL, O_NONBLOCK) +#else +extern long ioctlsocket_ret; +/* Returns non-0 on failure, while fcntl() returns -1 on failure */ +#ifdef WIN32 +#define FCNTL_NONBLOCK(sock) ((ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1) +#endif +#ifdef __BEOS__ +#define FCNTL_NONBLOCK(sock) ((ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1) +#endif +#endif + #if defined(sun) && defined(__sparc__) && !defined(__SVR4) #include #endif -/* Portable path handling for Unix/Win32 */ -bool is_absolute_path(const char *filename); -char *first_path_separator(const char *filename); -char *last_path_separator(const char *filename); -char *get_progname(char *argv0); - -#if defined(bsdi) || defined(netbsd) -int fseeko(FILE *stream, off_t offset, int whence); -off_t ftello(FILE *stream); -#endif - -/* - * Win32 doesn't have reliable rename/unlink during concurrent access - */ -#if defined(WIN32) && !defined(FRONTEND) -int pgrename(const char *from, const char *to); -int pgunlink(const char *path); -#define rename(path) pgrename(path) -#define unlink(from, to) pgunlink(from, to) -#endif - -/* - * Win32 doesn't have opendir/readdir/closedir() - */ -#ifdef WIN32 -struct dirent { - ino_t d_ino; /* inode (always 1 on WIN32) */ - char d_name[MAX_PATH + 1]; /* filename (null terminated) */ -}; - -typedef struct { - HANDLE handle; /* handle for FindFirstFile or - * FindNextFile */ - long offset; /* offset into directory */ - int finished; /* 1 if there are not more files */ - WIN32_FIND_DATA finddata; /* file data FindFirstFile or FindNextFile - * returns */ - char *dir; /* the directory path we are reading */ - struct dirent ent; /* the dirent to return */ -} DIR; - -extern DIR *opendir(const char *); -extern struct dirent *readdir(DIR *); -extern int closedir(DIR *); -#endif - -/* - * Win32 requires a special close for sockets and pipes, while on Unix - * close() does them all. - */ -#ifndef WIN32 -#define closesocket close -#endif - /* These are for things that are one way on Unix and another on NT */ #define NULL_DEV "/dev/null" @@ -794,37 +755,6 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args); #define SIGNAL_ARGS int postgres_signal_arg #endif -/* - * Default "extern" declarations or macro substitutes for library routines. - * When necessary, these routines are provided by files in src/port/. - */ -#ifndef HAVE_CRYPT -char *crypt(const char *key, const char *setting); -#endif - -#ifndef HAVE_FSEEKO -#define fseeko(a, b, c) fseek((a), (b), (c)) -#define ftello(a) ftell((a)) -#endif - -#ifndef HAVE_ISINF -extern int isinf(double x); -#endif - -#ifndef HAVE_GETHOSTNAME -extern int gethostname(char *name, int namelen); -#endif - -#ifndef HAVE_RINT -extern double rint(double x); -#endif - -#ifndef HAVE_INET_ATON -# include -# include -extern int inet_aton(const char *cp, struct in_addr * addr); -#endif - /* * When there is no sigsetjmp, its functionality is provided by plain * setjmp. Incidentally, nothing provides setjmp's functionality in @@ -836,22 +766,6 @@ extern int inet_aton(const char *cp, struct in_addr * addr); # define siglongjmp longjmp #endif -#ifndef HAVE_STRCASECMP -extern int strcasecmp(char *s1, char *s2); -#endif - -#ifndef HAVE_STRDUP -extern char *strdup(char const *); -#endif - -#ifndef HAVE_RANDOM -extern long random(void); -#endif - -#ifndef HAVE_SRANDOM -extern void srandom(unsigned int seed); -#endif - #if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC extern int fdatasync(int fildes); #endif @@ -868,4 +782,7 @@ extern int fdatasync(int fildes); # define HAVE_STRTOULL 1 #endif +/* /port compatibility functions */ +#include "port.h" + #endif /* C_H */ diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index 2749395670..e8699c2f4a 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -6,7 +6,7 @@ * for developers. If you edit any of these, be sure to do a *full* * rebuild (and an initdb if noted). * - * $Id: pg_config_manual.h,v 1.2 2003/04/18 01:03:42 momjian Exp $ + * $Id: pg_config_manual.h,v 1.3 2003/05/15 16:35:29 momjian Exp $ *------------------------------------------------------------------------ */ @@ -130,7 +130,7 @@ * Define this if your operating system supports AF_UNIX family * sockets. */ -#if !defined(__QNX__) && !defined(__BEOS__) +#if !defined(__QNX__) && !defined(__BEOS__) && !defined(WIN32) # define HAVE_UNIX_SOCKETS 1 #endif diff --git a/src/include/port.h b/src/include/port.h new file mode 100644 index 0000000000..f5672355bd --- /dev/null +++ b/src/include/port.h @@ -0,0 +1,93 @@ +/*------------------------------------------------------------------------- + * + * port.h + * Header for /port compatibility functions. + * + * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $Id: port.h,v 1.1 2003/05/15 16:35:29 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + +/* Portable path handling for Unix/Win32 */ +bool is_absolute_path(const char *filename); +char *first_path_separator(const char *filename); +char *last_path_separator(const char *filename); +char *get_progname(char *argv0); + +#if defined(bsdi) || defined(netbsd) +int fseeko(FILE *stream, off_t offset, int whence); +off_t ftello(FILE *stream); +#endif + +/* + * Win32 doesn't have reliable rename/unlink during concurrent access + */ +#if defined(WIN32) && !defined(FRONTEND) +int pgrename(const char *from, const char *to); +int pgunlink(const char *path); +#define rename(from, to) pgrename(from, to) +#define unlink(path) pgunlink(path) +#endif + +/* + * Win32 requires a special close for sockets and pipes, while on Unix + * close() does them all. + */ +#ifndef WIN32 +#define closesocket close +#endif + +/* + * Default "extern" declarations or macro substitutes for library routines. + * When necessary, these routines are provided by files in src/port/. + */ +#ifndef HAVE_CRYPT +char *crypt(const char *key, const char *setting); +#endif + +#ifndef HAVE_FSEEKO +#define fseeko(a, b, c) fseek((a), (b), (c)) +#define ftello(a) ftell((a)) +#endif + +#ifndef HAVE_GETOPT +extern int getopt(int nargc, char *const *nargv, const char *ostr); +#endif + +#ifndef HAVE_ISINF +extern int isinf(double x); +#endif + +#if !defined(HAVE_GETHOSTNAME) && defined(KRB4) +extern int gethostname(char *name, int namelen); +#endif + +#ifndef HAVE_RINT +extern double rint(double x); +#endif + +#ifndef HAVE_INET_ATON +# include +# include +extern int inet_aton(const char *cp, struct in_addr * addr); +#endif + +#ifndef HAVE_STRCASECMP +extern int strcasecmp(char *s1, char *s2); +#endif + +#ifndef HAVE_STRDUP +extern char *strdup(char const *); +#endif + +#ifndef HAVE_RANDOM +extern long random(void); +#endif + +#ifndef HAVE_SRANDOM +extern void srandom(unsigned int seed); +#endif + diff --git a/src/include/port/win.h b/src/include/port/win.h deleted file mode 100644 index 79fb93950a..0000000000 --- a/src/include/port/win.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $Header: /cvsroot/pgsql/src/include/port/Attic/win.h,v 1.15 2003/03/21 17:18:34 petere Exp $ */ - -#define HAS_TEST_AND_SET - -#ifdef BUILDING_DLL -#define DLLIMPORT __declspec (dllexport) -#else -#define DLLIMPORT __declspec (dllimport) -#endif - -#if defined(_DLL) -#define DLLIMPORT __declspec (dllexport) -#else -#define DLLIMPORT __declspec (dllimport) -#endif diff --git a/src/include/port/win32.h b/src/include/port/win32.h index e608e28257..36bb246e9b 100644 --- a/src/include/port/win32.h +++ b/src/include/port/win32.h @@ -1,4 +1,15 @@ -/* $Header: /cvsroot/pgsql/src/include/port/win32.h,v 1.9 2003/04/29 18:25:54 momjian Exp $ */ +/* $Header: /cvsroot/pgsql/src/include/port/win32.h,v 1.10 2003/05/15 16:35:29 momjian Exp $ */ + +/* undefine and redefine after #include */ +#undef mkdir + +#undef ERROR +#include +#undef near + +/* Must be here to avoid conflicting with prototype in windows.h */ +#define mkdir(a,b) mkdir(a) + #define USES_WINSOCK #define NOFILE 100 @@ -33,6 +44,9 @@ /* * IPC defines */ +#undef HAVE_UNION_SEMUN +#define HAVE_UNION_SEMUN 1 + #define IPC_RMID 256 #define IPC_CREAT 512 #define IPC_EXCL 1024 @@ -40,6 +54,14 @@ #define IPC_NOWAIT 2048 #define IPC_STAT 4096 +#define EACCESS 2048 +#define EIDRM 4096 + +#define SETALL 8192 +#define GETNCNT 16384 +#define GETVAL 65536 +#define SETVAL 131072 +#define GETPID 262144 /* * Shared memory @@ -77,6 +99,30 @@ 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); +#define sleep(sec) (Sleep(sec * 1000), /* no return value */ 0) + +/* Some extra signals */ +#define SIGHUP 1 +#define SIGQUIT 3 +#define SIGTRAP 5 +#define SIGABRT 22 /* Set to match W32 value -- not UNIX value */ +#define SIGKILL 9 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGSTOP 17 +#define SIGCONT 19 +#define SIGCHLD 20 +#define SIGTTIN 21 +#define SIGTTOU 22 /* Same as SIGABRT -- no problem, I hope */ +#define SIGWINCH 28 +#define SIGUSR1 30 +#define SIGUSR2 31 + +struct timezone +{ + int tz_minuteswest; /* Minutes west of GMT. */ + int tz_dsttime; /* Nonzero if DST is ever in effect. */ +}; /* FROM SRA */ @@ -130,5 +176,3 @@ extern double rint(double x); */ #define snprintf _snprintf #define vsnprintf _vsnprintf - - diff --git a/src/include/port/win32_include/dlfcn.h b/src/include/port/win32_include/dlfcn.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/include/port/win32_include/grp.h b/src/include/port/win32_include/grp.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/include/port/win32_include/netdb.h b/src/include/port/win32_include/netdb.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/include/port/win32_include/netinet/in.h b/src/include/port/win32_include/netinet/in.h new file mode 100644 index 0000000000..52db5248cb --- /dev/null +++ b/src/include/port/win32_include/netinet/in.h @@ -0,0 +1,2 @@ +#include + diff --git a/src/include/port/win32_include/pwd.h b/src/include/port/win32_include/pwd.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/include/port/win32_include/sys/socket.h b/src/include/port/win32_include/sys/socket.h new file mode 100644 index 0000000000..93df14ed7c --- /dev/null +++ b/src/include/port/win32_include/sys/socket.h @@ -0,0 +1,15 @@ +/* + * Unfortunately, of VC++ also defines ERROR. + * To avoid the conflict, we include here and undefine ERROR + * immediately. + * + * Note: Don't include directly. It causes compile errors. + */ +#include +#undef ERROR +#undef small + +/* Restore old ERROR value */ +#ifdef PGERROR +#define ERROR PGERROR +#endif diff --git a/src/include/port/win32_include/sys/wait.h b/src/include/port/win32_include/sys/wait.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/include/rusagestub.h b/src/include/rusagestub.h index 165b640d10..d0bc84fe98 100644 --- a/src/include/rusagestub.h +++ b/src/include/rusagestub.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rusagestub.h,v 1.10 2002/06/20 20:29:42 momjian Exp $ + * $Id: rusagestub.h,v 1.11 2003/05/15 16:35:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,7 +15,9 @@ #define RUSAGESTUB_H #include /* for struct timeval */ +#ifndef WIN32 #include /* for struct tms */ +#endif #include /* for CLK_TCK */ #define RUSAGE_SELF 0 diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index e341fa48f3..5a3f7ae338 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: elog.h,v 1.41 2003/04/24 21:16:44 tgl Exp $ + * $Id: elog.h,v 1.42 2003/05/15 16:35:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,6 +35,15 @@ #define WARNING 19 /* Warnings */ #define ERROR 20 /* user error - abort transaction; return * to known state */ +#define ERROR 20 /* user error - abort transaction; return + * to known state */ +/* Save ERROR value in PGERROR so it can bve restored when Win32 includes + * modify it. We have to use a constant rather than ERROR because macros + * are expanded only when referenced outside macros. + */ +#ifdef WIN32 +#define PGERROR 20 +#endif #define FATAL 21 /* fatal error - abort process */ #define PANIC 22 /* take down the other backends with me */ diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 10e2ee15f1..07c059f559 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.76 2003/04/19 00:02:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.77 2003/05/15 16:35:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -386,10 +386,10 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, /* * libpq uses a non-blocking socket. But kerberos needs a blocking * socket, and we have to block somehow to do mutual authentication - * anyway. So we temporarily make it blocking. + * anyway. So we temporarily make it blocking. Win32 doesn't support this. */ flags = fcntl(sock, F_GETFL); - if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK))) + if (flags < 0 || fcntl(sock, F_SETFL, flags & ~O_NONBLOCK))) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, libpq_gettext("could not set socket to blocking mode: %s\n"), strerror(errno)); diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 75bcb43433..cf33c225dc 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.240 2003/05/05 00:44:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.241 2003/05/15 16:35:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -719,17 +719,7 @@ update_db_info(PGconn *conn) static int connectMakeNonblocking(PGconn *conn) { -#if defined(WIN32) || defined(__BEOS__) - int on = 1; -#endif - -#if defined(WIN32) - if (ioctlsocket(conn->sock, FIONBIO, &on) != 0) -#elif defined(__BEOS__) - if (ioctl(conn->sock, FIONBIO, &on) != 0) -#else - if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0) -#endif + if (FCNTL_NONBLOCK(conn->sock) < 0) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not set socket to non-blocking mode: %s\n"), diff --git a/src/makefiles/Makefile.win b/src/makefiles/Makefile.win32 similarity index 74% rename from src/makefiles/Makefile.win rename to src/makefiles/Makefile.win32 index d16afb1757..0fb52b97fe 100644 --- a/src/makefiles/Makefile.win +++ b/src/makefiles/Makefile.win32 @@ -1,4 +1,8 @@ -# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.19 2003/03/21 17:18:34 petere Exp $ +# $Header: /cvsroot/pgsql/src/makefiles/Makefile.win32,v 1.1 2003/05/15 16:35:30 momjian Exp $ + +# Use replacement include files for those missing on Win32 +override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32_include" + DLLTOOL= dlltool DLLWRAP= dllwrap BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres diff --git a/src/port/dirmod.c b/src/port/dirmod.c index e44ecc5edf..21c205a5d0 100644 --- a/src/port/dirmod.c +++ b/src/port/dirmod.c @@ -6,6 +6,8 @@ #ifndef TEST_VERSION +#include "postgres.h" + #undef rename #undef unlink diff --git a/src/port/getopt.c b/src/port/getopt.c index bfb6b30077..0d60673db5 100644 --- a/src/port/getopt.c +++ b/src/port/getopt.c @@ -30,9 +30,11 @@ * 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. */ +#include "postgres.h" + + #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; #endif /* LIBC_SCCS and not lint */ @@ -92,7 +94,7 @@ const char *ostr; ++optind; if (opterr && *ostr != ':') (void) fprintf(stderr, - "%s: illegal option -- %c\n", argv[0], optopt); + "illegal option -- %c\n", optopt); return BADCH; } if (*++oli != ':') @@ -112,8 +114,8 @@ const char *ostr; return BADARG; if (opterr) (void) fprintf(stderr, - "%s: option requires an argument -- %c\n", - argv[0], optopt); + "option requires an argument -- %c\n", + optopt); return BADCH; } else diff --git a/src/port/getrusage.c b/src/port/getrusage.c index 14d3748046..386b1acf65 100644 --- a/src/port/getrusage.c +++ b/src/port/getrusage.c @@ -1,7 +1,9 @@ -/* $Id: getrusage.c,v 1.1 2002/07/18 04:13:59 momjian Exp $ */ +/* $Id: getrusage.c,v 1.2 2003/05/15 16:35:30 momjian Exp $ */ #include #include + +#include "postgres.h" #include "rusagestub.h" /* This code works on: @@ -19,6 +21,10 @@ int getrusage(int who, struct rusage * rusage) { +#ifdef WIN32 + if (rusage) + memset(rusage, 0, sizeof(rusage)); +#else struct tms tms; int tick_rate = CLK_TCK; /* ticks per second */ clock_t u, @@ -54,5 +60,6 @@ getrusage(int who, struct rusage * rusage) rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate); rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate); rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate); +#endif return 0; } diff --git a/src/port/opendir.c b/src/port/opendir.c deleted file mode 100644 index 79ef4d38ac..0000000000 --- a/src/port/opendir.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * $Header: /cvsroot/pgsql/src/port/Attic/opendir.c,v 1.1 2003/05/09 01:16:29 momjian Exp $ - * - * Copyright (c) 2003 SRA, Inc. - * Copyright (c) 2003 SKC, Inc. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose, without fee, and without a - * written agreement is hereby granted, provided that the above - * copyright notice and this paragraph and the following two - * paragraphs appear in all copies. - * - * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, - * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING - * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS - * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS - * IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, - * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - */ - -#include "postgres.h" - -#include -#include -#include - -#include "dirent.h" - -DIR * -opendir(const char *dir) -{ - DIR *dp; - char *findspec; - HANDLE handle; - size_t dirlen; - - dirlen = strlen(dir); - findspec = palloc(dirlen + 2 + 1); - if (findspec == NULL) - return NULL; - - if (dirlen == 0) - strcpy(findspec, "*"); - else if (isalpha(dir[0]) && dir[1] == ':' && dir[2] == '\0') - sprintf(findspec, "%s*", dir); - else if (dir[dirlen - 1] == '/' || dir[dirlen - 1] == '\\') - sprintf(findspec, "%s*", dir); - else - sprintf(findspec, "%s\\*", dir); - - dp = (DIR *)palloc(sizeof(DIR)); - if (dp == NULL) - { - pfree(findspec); - errno = ENOMEM; - return NULL; - } - - dp->offset = 0; - dp->finished = 0; - dp->dir = pstrdup(dir); - if (dp->dir == NULL) - { - pfree(dp); - pfree(findspec); - errno = ENOMEM; - return NULL; - } - - handle = FindFirstFile(findspec, &(dp->finddata)); - if (handle == INVALID_HANDLE_VALUE) - { - pfree(dp->dir); - pfree(dp); - pfree(findspec); - errno = ENOENT; - return NULL; - } - dp->handle = handle; - - pfree(findspec); - return dp; -} - - -struct dirent * -readdir(DIR *dp) -{ - if (dp == NULL || dp->finished) - return NULL; - - if (dp->offset != 0) - { - if (FindNextFile(dp->handle, &(dp->finddata)) == 0) - { - dp->finished = 1; - return NULL; - } - } - dp->offset++; - - strncpy(dp->ent.d_name, dp->finddata.cFileName, MAX_PATH); - dp->ent.d_ino = 1; - - return &(dp->ent); -} - - -int -closedir(DIR *dp) -{ - FindClose(dp->handle); - pfree(dp->dir); - pfree(dp); - - return 0; -} diff --git a/src/template/win32 b/src/template/win32 new file mode 100644 index 0000000000..736e0f293d --- /dev/null +++ b/src/template/win32 @@ -0,0 +1,3 @@ +if test "$GCC" = yes; then + CFLAGS="-O2" +fi