Thread: Win32 adjustments

Win32 adjustments

From
Bruce Momjian
Date:
I have applied the following patch with Magnus's guidance.  It fixes
some Win32 problems introduced by my relative path installs.

It also removes the newline from psql for MinGW-only as posted by
Andrew.  I added a mention to the Win32 todo list so we know to remove
it once we find the real cause.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.388
diff -c -c -r1.388 postmaster.c
*** src/backend/postmaster/postmaster.c    17 May 2004 14:35:29 -0000    1.388
--- src/backend/postmaster/postmaster.c    18 May 2004 18:18:26 -0000
***************
*** 295,302 ****

  #ifdef EXEC_BACKEND

- static char    postgres_exec_path[MAXPGPATH];
-
  #ifdef WIN32
  pid_t win32_forkexec(const char* path, char *argv[]);

--- 295,300 ----
***************
*** 463,468 ****
--- 461,471 ----

      IgnoreSystemIndexes(false);

+     if (find_my_exec(argv[0], my_exec_path) < 0)
+         ereport(FATAL,
+                 (errmsg("%s: could not locate my own executable path",
+                         progname)));
+
      /*
       * Options setup
       */
***************
*** 690,702 ****
                  (errmsg_internal("-----------------------------------------")));
      }

-     /*
-      * On some systems our dynloader code needs the executable's pathname.
-      */
-     if (find_my_exec(argv[0], my_exec_path) < 0)
-         ereport(FATAL,
-                 (errmsg("%s: could not locate my own executable path",
-                         progname)));
      if (strlen(pkglib_path) == 0)
          get_pkglib_path(my_exec_path, pkglib_path);

--- 693,698 ----
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/tcop/postgres.c,v
retrieving revision 1.407
diff -c -c -r1.407 postgres.c
*** src/backend/tcop/postgres.c    17 May 2004 14:35:31 -0000    1.407
--- src/backend/tcop/postgres.c    18 May 2004 18:18:29 -0000
***************
*** 2190,2195 ****
--- 2190,2200 ----
       */
      EchoQuery = false;

+     if (strlen(my_exec_path) == 0 && find_my_exec(argv[0], my_exec_path) < 0)
+         ereport(FATAL,
+                 (errmsg("%s: could not locate postgres executable",
+                         argv[0])));
+
      if (!IsUnderPostmaster)
      {
          InitializeGUCOptions();
***************
*** 2549,2554 ****
--- 2554,2562 ----
      }
      Assert(DataDir);

+     if (strlen(pkglib_path) == 0)
+         get_pkglib_path(my_exec_path, pkglib_path);
+
      /* Acquire configuration parameters */
      if (IsUnderPostmaster)
      {
***************
*** 2645,2660 ****
                              argv[0])));
          }

-         /*
-          * On some systems our dynloader code needs the executable's pathname.
-          */
-         if (strlen(my_exec_path) == 0 && find_my_exec(argv[0], my_exec_path) < 0)
-             ereport(FATAL,
-                     (errmsg("%s: could not locate postgres executable",
-                             argv[0])));
-         if (strlen(pkglib_path) == 0)
-             get_pkglib_path(my_exec_path, pkglib_path);
-
          /*
           * Validate we have been given a reasonable-looking DataDir (if
           * under postmaster, assume postmaster did this already).
--- 2653,2658 ----
Index: src/bin/psql/print.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/print.c,v
retrieving revision 1.46
diff -c -c -r1.46 print.c
*** src/bin/psql/print.c    24 Jan 2004 20:43:26 -0000    1.46
--- src/bin/psql/print.c    18 May 2004 18:18:30 -0000
***************
*** 388,394 ****
--- 388,397 ----
          for (ptr = footers; *ptr; ptr++)
              fprintf(fout, "%s\n", *ptr);

+ #ifndef __MINGW32__
+     /* for some reason MinGW outputs an extra newline, so this supresses it */
      fputc('\n', fout);
+ #endif

      /* clean up */
      free(cell_w);
Index: src/port/exec.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/exec.c,v
retrieving revision 1.7
diff -c -c -r1.7 exec.c
*** src/port/exec.c    18 May 2004 03:36:45 -0000    1.7
--- src/port/exec.c    18 May 2004 18:18:31 -0000
***************
*** 23,28 ****
--- 23,32 ----
  #include <sys/stat.h>
  #include <unistd.h>

+ #include <sys/wait.h>
+
+ #define _(x) gettext((x))
+
  #include "miscadmin.h"

  /* $PATH (or %PATH%) path separator */
***************
*** 331,336 ****
--- 335,380 ----


  /*
+  * pclose() plus useful error reporting
+  * Is this necessary?  bjm 2004-05-11
+  * It is better here because pipe.c has win32 backend linkage.
+  */
+ int
+ pclose_check(FILE *stream)
+ {
+     int        exitstatus;
+
+     exitstatus = pclose(stream);
+
+     if (exitstatus == 0)
+         return 0;                    /* all is well */
+
+     if (exitstatus == -1)
+     {
+         /* pclose() itself failed, and hopefully set errno */
+         perror("pclose failed");
+     }
+     else if (WIFEXITED(exitstatus))
+     {
+         fprintf(stderr, _("child process exited with exit code %d\n"),
+                 WEXITSTATUS(exitstatus));
+     }
+     else if (WIFSIGNALED(exitstatus))
+     {
+         fprintf(stderr, _("child process was terminated by signal %d\n"),
+                 WTERMSIG(exitstatus));
+     }
+     else
+     {
+         fprintf(stderr, _("child process exited with unrecognized status %d\n"),
+                 exitstatus);
+     }
+
+     return -1;
+ }
+
+
+ /*
   * Windows doesn't like relative paths to executables (other things work fine)
   * so we call its builtin function to expand them. Elsewhere this is a NOOP
   *
***************
*** 353,356 ****
--- 397,401 ----
  #endif
      return;
  }
+

Index: src/port/pipe.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/pipe.c,v
retrieving revision 1.3
diff -c -c -r1.3 pipe.c
*** src/port/pipe.c    11 May 2004 21:57:15 -0000    1.3
--- src/port/pipe.c    18 May 2004 18:18:31 -0000
***************
*** 17,26 ****

  #include "postgres.h"

- #include <sys/wait.h>
-
- #define _(x) gettext((x))
-
  #ifdef WIN32
  int
  pgpipe(int handles[2])
--- 17,22 ----
***************
*** 70,109 ****
  }
  #endif

- /*
-  * pclose() plus useful error reporting
-  * Is this necessary?  bjm 2004-05-11
-  */
- int
- pclose_check(FILE *stream)
- {
-     int        exitstatus;
-
-     exitstatus = pclose(stream);
-
-     if (exitstatus == 0)
-         return 0;                    /* all is well */
-
-     if (exitstatus == -1)
-     {
-         /* pclose() itself failed, and hopefully set errno */
-         perror("pclose failed");
-     }
-     else if (WIFEXITED(exitstatus))
-     {
-         fprintf(stderr, _("child process exited with exit code %d\n"),
-                 WEXITSTATUS(exitstatus));
-     }
-     else if (WIFSIGNALED(exitstatus))
-     {
-         fprintf(stderr, _("child process was terminated by signal %d\n"),
-                 WTERMSIG(exitstatus));
-     }
-     else
-     {
-         fprintf(stderr, _("child process exited with unrecognized status %d\n"),
-                 exitstatus);
-     }
-
-     return -1;
- }
--- 66,68 ----

Re: Win32 adjustments

From
Peter Eisentraut
Date:
Bruce Momjian wrote:
> I have applied the following patch with Magnus's guidance.  It fixes
> some Win32 problems introduced by my relative path installs.
>
> It also removes the newline from psql for MinGW-only as posted by
> Andrew.  I added a mention to the Win32 todo list so we know to
> remove it once we find the real cause.

We don't have any NLS support for libpgport.  All of these strings are
dead meat.  This needs fixing.


Re: Win32 adjustments

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > I have applied the following patch with Magnus's guidance.  It fixes
> > some Win32 problems introduced by my relative path installs.
> >
> > It also removes the newline from psql for MinGW-only as posted by
> > Andrew.  I added a mention to the Win32 todo list so we know to
> > remove it once we find the real cause.
>
> We don't have any NLS support for libpgport.  All of these strings are
> dead meat.  This needs fixing.

OK, how do I do that?  Add _()?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073