Re: [HACKERS] 8.0 libpq: missing get_home_path()

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] 8.0 libpq: missing get_home_path()
Дата
Msg-id 200408190001.i7J01Ji12671@candle.pha.pa.us
обсуждение исходный текст
Ответы Re: [HACKERS] 8.0 libpq: missing get_home_path()  (Gaetano Mendola <mendola@bigfoot.com>)
Список pgsql-patches
OK, patch attached and applied.  I also updated the docs.

---------------------------------------------------------------------------

Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > I need to call canonicalize_path() in the macro.
>
> There is only one use of get_home_path in libpq.  Lose it and do
> a direct getenv(HOMEDIR).  You do not really need to do a
> canonicalize_path there; it'd be sufficient to insert the appropriate
> directory separator ('/' or '\') when forming pgpassfile just below.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

--
  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: doc/src/sgml/libpq.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/libpq.sgml,v
retrieving revision 1.160
diff -c -c -r1.160 libpq.sgml
*** doc/src/sgml/libpq.sgml    17 Aug 2004 16:54:46 -0000    1.160
--- doc/src/sgml/libpq.sgml    18 Aug 2004 23:54:05 -0000
***************
*** 136,142 ****
        likely to fail if <application>libpq</application> is passed a host name
        that is not the name of the machine at <literal>hostaddr</>.)  Also,
        <literal>host</> rather than <literal>hostaddr</> is used to identify
!       the connection in <filename>$HOME/.pgpass</>.
       </para>
       <para>
        Without either a host name or host address,
--- 136,143 ----
        likely to fail if <application>libpq</application> is passed a host name
        that is not the name of the machine at <literal>hostaddr</>.)  Also,
        <literal>host</> rather than <literal>hostaddr</> is used to identify
!       the connection in <filename>$HOME/.pgpass</> (or
!       <filename>%USERPROFILE%/.pgpass</> on Win32).
       </para>
       <para>
        Without either a host name or host address,
Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.281
diff -c -c -r1.281 fe-connect.c
*** src/interfaces/libpq/fe-connect.c    18 Aug 2004 02:59:11 -0000    1.281
--- src/interfaces/libpq/fe-connect.c    18 Aug 2004 23:54:19 -0000
***************
*** 3093,3099 ****
  {
      FILE       *fp;
      char       *pgpassfile;
!     char       home[MAXPGPATH];
      struct stat stat_buf;

  #define LINELEN NAMEDATALEN*5
--- 3093,3099 ----
  {
      FILE       *fp;
      char       *pgpassfile;
!     char       *home;
      struct stat stat_buf;

  #define LINELEN NAMEDATALEN*5
***************
*** 3111,3120 ****
      if (port == NULL)
          port = DEF_PGPORT_STR;

!     /* Look for it in the home dir */
!     if (!get_home_path(home))
          return NULL;
!
      pgpassfile = malloc(strlen(home) + 1 + strlen(PGPASSFILE) + 1);
      if (!pgpassfile)
      {
--- 3111,3123 ----
      if (port == NULL)
          port = DEF_PGPORT_STR;

!     /*
!      *    Look for it in the home dir.
!      *    We don't use get_home_path() so we don't pull path.c into our library.
!      */
!     if (!(home = getenv(HOMEDIR)))
          return NULL;
!
      pgpassfile = malloc(strlen(home) + 1 + strlen(PGPASSFILE) + 1);
      if (!pgpassfile)
      {
***************
*** 3122,3128 ****
--- 3125,3135 ----
          return NULL;
      }

+ #ifndef WIN32
      sprintf(pgpassfile, "%s/%s", home, PGPASSFILE);
+ #else
+     sprintf(pgpassfile, "%s\\%s", home, PGPASSFILE);
+ #endif

      /* If password file cannot be opened, ignore it. */
      if (stat(pgpassfile, &stat_buf) == -1)

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

Предыдущее
От: Philip Warner
Дата:
Сообщение: Re: pg_restore recognizing $-quotes
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [pgsql-hackers-win32] 8.0 Beta 1 // Environment Vars // .pgpass