Re: Postgresql 9.0b2 : pg_upgrade not passing username to pgdumpall ?

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Postgresql 9.0b2 : pg_upgrade not passing username to pgdumpall ?
Дата
Msg-id 201006221648.o5MGmC218301@momjian.us
обсуждение исходный текст
Ответ на Postgresql 9.0b2 : pg_upgrade not passing username to pgdumpall ?  ("Cassiano, Marco" <mcassiano@manord.com>)
Ответы R: Postgresql 9.0b2 : pg_upgrade not passing username to pgdumpall ?  ("Cassiano, Marco" <mcassiano@manord.com>)
Список pgsql-admin
Cassiano, Marco wrote:
> Hi all,
>
>
>
> it's my first trial with pg_upgrade so I'm surely missing something....
>
> I'm trying to launch pg_upgrade passing my super user name but
> pg_dumpall fails with a permission denied error....
>
> I don't see the username in the pgdumpall call....could it be this the
> problem ?
>
> Thank you (I hope this is the right list to post this)

Turns out I was missing the user name designation. I am attaching the
patch that fixes this, and a pg_ctl issue on Win32.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + None of us is going to be here forever. +
Index: contrib/pg_upgrade/dump.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_upgrade/dump.c,v
retrieving revision 1.2
diff -c -c -r1.2 dump.c
*** contrib/pg_upgrade/dump.c    12 Jun 2010 17:05:29 -0000    1.2
--- contrib/pg_upgrade/dump.c    22 Jun 2010 16:44:06 -0000
***************
*** 19,27 ****
       * restores the frozenid's for databases and relations.
       */
      exec_prog(ctx, true,
!               SYSTEMQUOTE "\"%s/pg_dumpall\" --port %d --schema-only "
!               "--binary-upgrade > \"%s/" ALL_DUMP_FILE "\"" SYSTEMQUOTE,
!               ctx->new.bindir, ctx->old.port, ctx->cwd);
      check_ok(ctx);
  }

--- 19,27 ----
       * restores the frozenid's for databases and relations.
       */
      exec_prog(ctx, true,
!               SYSTEMQUOTE "\"%s/pg_dumpall\" --port %d --username \"%s\" "
!               "--schema-only --binary-upgrade > \"%s/" ALL_DUMP_FILE "\""
!               SYSTEMQUOTE, ctx->new.bindir, ctx->old.port, ctx->user, ctx->cwd);
      check_ok(ctx);
  }

Index: contrib/pg_upgrade/option.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_upgrade/option.c,v
retrieving revision 1.7
diff -c -c -r1.7 option.c
*** contrib/pg_upgrade/option.c    15 Jun 2010 23:25:01 -0000    1.7
--- contrib/pg_upgrade/option.c    22 Jun 2010 16:44:06 -0000
***************
*** 174,185 ****
           * start.
           */
          /* truncate */
!         ctx->log_fd = fopen(ctx->logfile, "w");
!         if (!ctx->log_fd)
              pg_log(ctx, PG_FATAL, "Cannot write to log file %s\n", ctx->logfile);
          fclose(ctx->log_fd);
!         ctx->log_fd = fopen(ctx->logfile, "a");
!         if (!ctx->log_fd)
              pg_log(ctx, PG_FATAL, "Cannot write to log file %s\n", ctx->logfile);
      }
      else
--- 174,183 ----
           * start.
           */
          /* truncate */
!         if ((ctx->log_fd = fopen(ctx->logfile, "w")) == NULL)
              pg_log(ctx, PG_FATAL, "Cannot write to log file %s\n", ctx->logfile);
          fclose(ctx->log_fd);
!         if ((ctx->log_fd = fopen(ctx->logfile, "a")) == NULL)
              pg_log(ctx, PG_FATAL, "Cannot write to log file %s\n", ctx->logfile);
      }
      else
Index: contrib/pg_upgrade/pg_upgrade.h
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_upgrade/pg_upgrade.h,v
retrieving revision 1.8
diff -c -c -r1.8 pg_upgrade.h
*** contrib/pg_upgrade/pg_upgrade.h    15 Jun 2010 02:08:01 -0000    1.8
--- contrib/pg_upgrade/pg_upgrade.h    22 Jun 2010 16:44:06 -0000
***************
*** 48,54 ****
  #define pg_link_file        win32_pghardlink
  #define EXE_EXT                ".exe"
  #define sleep(x)            Sleep(x * 1000)
! #define DEVNULL "nul"
  /* "con" does not work from the Msys 1.0.10 console (part of MinGW). */
  #define DEVTTY  "con"
  /* from pgport */
--- 48,54 ----
  #define pg_link_file        win32_pghardlink
  #define EXE_EXT                ".exe"
  #define sleep(x)            Sleep(x * 1000)
! #define DEVNULL                "nul"
  /* "con" does not work from the Msys 1.0.10 console (part of MinGW). */
  #define DEVTTY  "con"
  /* from pgport */
Index: contrib/pg_upgrade/server.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_upgrade/server.c,v
retrieving revision 1.2
diff -c -c -r1.2 server.c
*** contrib/pg_upgrade/server.c    14 May 2010 00:32:21 -0000    1.2
--- contrib/pg_upgrade/server.c    22 Jun 2010 16:44:06 -0000
***************
*** 177,188 ****
          port = ctx->new.port;
      }

!     /* use -l for Win32 */
      snprintf(cmd, sizeof(cmd),
               SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
               "-o \"-p %d -c autovacuum=off -c autovacuum_freeze_max_age=2000000000\" "
               "start >> \"%s\" 2>&1" SYSTEMQUOTE,
!              bindir, ctx->logfile, datadir, port, ctx->logfile);
      exec_prog(ctx, true, "%s", cmd);

      /* wait for the server to start properly */
--- 177,198 ----
          port = ctx->new.port;
      }

!     /*
!      * On Win32, we can't send both server output and pg_ctl output
!      * to the same file because we get the error:
!      * "The process cannot access the file because it is being used by another process."
!      * so we have to send pg_ctl output to 'nul'.
!      */
      snprintf(cmd, sizeof(cmd),
               SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
               "-o \"-p %d -c autovacuum=off -c autovacuum_freeze_max_age=2000000000\" "
               "start >> \"%s\" 2>&1" SYSTEMQUOTE,
!              bindir, ctx->logfile, datadir, port,
! #ifndef WIN32
!              ctx->logfile);
! #else
!              DEVNULL);
! #endif
      exec_prog(ctx, true, "%s", cmd);

      /* wait for the server to start properly */
***************
*** 200,205 ****
--- 210,216 ----
  void
  stop_postmaster(migratorContext *ctx, bool fast, bool quiet)
  {
+     char        cmd[MAXPGPATH];
      const char *bindir;
      const char *datadir;

***************
*** 216,225 ****
      else
          return;                    /* no cluster running */

!     /* use -l for Win32 */
!     exec_prog(ctx, fast ? false : true,
                SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" %s stop >> \"%s\" 2>&1" SYSTEMQUOTE,
!          bindir, ctx->logfile, datadir, fast ? "-m fast" : "", ctx->logfile);

      ctx->postmasterPID = 0;
      ctx->running_cluster = NONE;
--- 227,242 ----
      else
          return;                    /* no cluster running */

!     /* See comment in start_postmaster() about why win32 output is ignored. */
!     snprintf(cmd, sizeof(cmd),
                SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" %s stop >> \"%s\" 2>&1" SYSTEMQUOTE,
!               bindir, ctx->logfile, datadir, fast ? "-m fast" : "",
! #ifndef WIN32
!               ctx->logfile);
! #else
!               DEVNULL);
! #endif
!     exec_prog(ctx, fast ? false : true, "%s", cmd);

      ctx->postmasterPID = 0;
      ctx->running_cluster = NONE;

В списке pgsql-admin по дате отправления:

Предыдущее
От: "Igor Neyman"
Дата:
Сообщение: Re: parallel option in pg_restore
Следующее
От: Tom Lane
Дата:
Сообщение: Re: blocking automatic vacuum