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

2004-08-19 Thread Gaetano Mendola
Bruce Momjian wrote:
OK, patch attached and applied.  I also updated the docs.
Just a note for the docs:
%USERPROFILE%/.pgpass shall be not %USERPROFILE%\.pgpass ?
Regards
Gaetano Mendola
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


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

2004-08-18 Thread Bruce Momjian

OK, patch attached and applied.  I also updated the docs.

---

Tom Lane wrote:
 Bruce Momjian [EMAIL PROTECTED] 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
  [EMAIL PROTECTED]   |  (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 -  1.160
--- doc/src/sgml/libpq.sgml 18 Aug 2004 23:54:05 -
***
*** 136,142 
likely to fail if applicationlibpq/application is passed a host name
that is not the name of the machine at literalhostaddr/.)  Also,
literalhost/ rather than literalhostaddr/ 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 applicationlibpq/application is passed a host name
that is not the name of the machine at literalhostaddr/.)  Also,
literalhost/ rather than literalhostaddr/ 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 -  1.281
--- src/interfaces/libpq/fe-connect.c   18 Aug 2004 23:54:19 -
***
*** 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)

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly