Re: [PATCHES] [pgsql-hackers-win32] Data directory with trailing [back]slash

2004-07-11 Thread Bruce Momjian

I am now confused about the original report.  I don't see how my fix
would correct the reported problem.  trim_trailing_separator() would
have handled d:\pgdata\ and d:\pgdata just fine.  The fix only corrects
d:\.

Magnus, does current CVS fix the problem?

---

Andrew Dunstan wrote:
 
 
 Tom Lane wrote:
 
 Magnus Hagander [EMAIL PROTECTED] writes:
   
 
 It's not possible to start the postmaster on win32 with:
 postmaster -D d:\pgdata\
 or
 postmaster -D d:/pgdata/
 
 
 
 Sounds like canonicalize_path() needs to be applied a bit sooner than
 it is.
 
 BTW I think canonicalize_path() is a few bricks shy of a load yet:
 I'm not sure it works well with Windows drive-letters, and it definitely
 will strip significant slashes when given input like '/' or 'C:\'.
 Feel free to fix those problems while at it...
   
 
 
 Or use the attached patch, which I think does it right.
 
 cheers
 
 andrew


 
 ---(end of broadcast)---
 TIP 9: the planner will ignore your desire to choose an index scan if your
   joining column's datatypes do not match

-- 
  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

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] [pgsql-hackers-win32] Data directory with trailing [back]slash

2004-07-11 Thread Bruce Momjian

I think this still is not fixed.  I think we need to add a call to
trim_trailing_separator() in checkDataDir().  Magnus, can you confirm
this will fix it?

---

Bruce Momjian wrote:
 
 I am now confused about the original report.  I don't see how my fix
 would correct the reported problem.  trim_trailing_separator() would
 have handled d:\pgdata\ and d:\pgdata just fine.  The fix only corrects
 d:\.
 
 Magnus, does current CVS fix the problem?
 
 ---
 
 Andrew Dunstan wrote:
  
  
  Tom Lane wrote:
  
  Magnus Hagander [EMAIL PROTECTED] writes:

  
  It's not possible to start the postmaster on win32 with:
  postmaster -D d:\pgdata\
  or
  postmaster -D d:/pgdata/
  
  
  
  Sounds like canonicalize_path() needs to be applied a bit sooner than
  it is.
  
  BTW I think canonicalize_path() is a few bricks shy of a load yet:
  I'm not sure it works well with Windows drive-letters, and it definitely
  will strip significant slashes when given input like '/' or 'C:\'.
  Feel free to fix those problems while at it...

  
  
  Or use the attached patch, which I think does it right.
  
  cheers
  
  andrew
 
 
  
  ---(end of broadcast)---
  TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
 
 -- 
   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
 
 ---(end of broadcast)---
 TIP 2: you can get off all lists at once with the unregister command
 (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
 

-- 
  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

---(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


Re: [PATCHES] [pgsql-hackers-win32] Data directory with trailing [back]slash

2004-07-11 Thread Bruce Momjian

Oops, path patch attached.

---

Bruce Momjian wrote:
 
 I think this still is not fixed.  I think we need to add a call to
 trim_trailing_separator() in checkDataDir().  Magnus, can you confirm
 this will fix it?
 
 ---
 
 Bruce Momjian wrote:
  
  I am now confused about the original report.  I don't see how my fix
  would correct the reported problem.  trim_trailing_separator() would
  have handled d:\pgdata\ and d:\pgdata just fine.  The fix only corrects
  d:\.
  
  Magnus, does current CVS fix the problem?
  
  ---
  
  Andrew Dunstan wrote:
   
   
   Tom Lane wrote:
   
   Magnus Hagander [EMAIL PROTECTED] writes:
 
   
   It's not possible to start the postmaster on win32 with:
   postmaster -D d:\pgdata\
   or
   postmaster -D d:/pgdata/
   
   
   
   Sounds like canonicalize_path() needs to be applied a bit sooner than
   it is.
   
   BTW I think canonicalize_path() is a few bricks shy of a load yet:
   I'm not sure it works well with Windows drive-letters, and it definitely
   will strip significant slashes when given input like '/' or 'C:\'.
   Feel free to fix those problems while at it...
 
   
   
   Or use the attached patch, which I think does it right.
   
   cheers
   
   andrew
  
  
   
   ---(end of broadcast)---
   TIP 9: the planner will ignore your desire to choose an index scan if your
 joining column's datatypes do not match
  
  -- 
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
  
  ---(end of broadcast)---
  TIP 2: you can get off all lists at once with the unregister command
  (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
  
 
 -- 
   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
 
 ---(end of broadcast)---
 TIP 9: the planner will ignore your desire to choose an index scan if your
   joining column's datatypes do not match
 

-- 
  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: src/backend/postmaster/postmaster.c
===
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.407
diff -c -c -r1.407 postmaster.c
*** src/backend/postmaster/postmaster.c 11 Jul 2004 00:18:43 -  1.407
--- src/backend/postmaster/postmaster.c 11 Jul 2004 21:29:16 -
***
*** 372,378 
InitializeGUCOptions();
  
userPGDATA = getenv(PGDATA);  /* default value */
! 
opterr = 1;
  
while ((opt = getopt(argc, argv, A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:)) != -1)
--- 372,379 
InitializeGUCOptions();
  
userPGDATA = getenv(PGDATA);  /* default value */
!   canonicalize_path(userPGDATA);
!   
opterr = 1;
  
while ((opt = getopt(argc, argv, A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:)) != -1)
Index: src/backend/utils/misc/guc.c
===
RCS file: /cvsroot/pgsql-server/src/backend/utils/misc/guc.c,v
retrieving revision 1.214
diff -c -c -r1.214 guc.c
*** src/backend/utils/misc/guc.c11 Jul 2004 00:18:44 -  1.214
--- src/backend/utils/misc/guc.c11 Jul 2004 21:29:19 -
***
*** 113,118 
--- 113,119 
  static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
  static bool assign_log_stats(bool newval, bool doit, GucSource source);
  static bool assign_transaction_read_only(bool newval, bool doit, GucSource source);
+ static const char *assign_canonical_path(const char *newval, bool doit, GucSource 
source);
  
  static void ReadConfigFile(char *filename, GucContext context);
  
***
*** 1470,1476 
 the specified file.)
},
Dynamic_library_path,
!   $libdir, NULL, NULL
},
  
{
--- 1471,1477 
 the specified file.)
},
Dynamic_library_path,
!   $libdir, 

Re: [PATCHES] [pgsql-hackers-win32] Data directory with trailing [back]slash

2004-07-10 Thread Bruce Momjian

OK, I have fixed the problem.  While your patch got close, it is best to
fix the problem in trim_trailing_separator() rather than above.

Tom already fixed the Unix case by preventing a path of '/' from being
stripped.  This patch prevents c:/ and //network/ from being stripped
too.  (Tom already mentioned Win32 would need work.)

---

Andrew Dunstan wrote:
 
 
 Tom Lane wrote:
 
 Magnus Hagander [EMAIL PROTECTED] writes:
   
 
 It's not possible to start the postmaster on win32 with:
 postmaster -D d:\pgdata\
 or
 postmaster -D d:/pgdata/
 
 
 
 Sounds like canonicalize_path() needs to be applied a bit sooner than
 it is.
 
 BTW I think canonicalize_path() is a few bricks shy of a load yet:
 I'm not sure it works well with Windows drive-letters, and it definitely
 will strip significant slashes when given input like '/' or 'C:\'.
 Feel free to fix those problems while at it...
   
 
 
 Or use the attached patch, which I think does it right.
 
 cheers
 
 andrew


 
 ---(end of broadcast)---
 TIP 9: the planner will ignore your desire to choose an index scan if your
   joining column's datatypes do not match

-- 
  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: src/port/path.c
===
RCS file: /cvsroot/pgsql-server/src/port/path.c,v
retrieving revision 1.21
diff -c -c -r1.21 path.c
*** src/port/path.c 10 Jul 2004 22:58:42 -  1.21
--- src/port/path.c 11 Jul 2004 02:50:49 -
***
*** 389,395 
  trim_trailing_separator(char *path)
  {
char *p = path + strlen(path);
!   
/* trim off trailing slashes */
if (p  path)
for (p--; p  path  IS_DIR_SEP(*p); p--)
--- 389,414 
  trim_trailing_separator(char *path)
  {
char *p = path + strlen(path);
! 
! #ifdef WIN32
! /* Skip over network and drive specifiers for win32 */
! if (strlen(path) = 2)
! {
! if (IS_DIR_SEP(path[0])  IS_DIR_SEP(path[1]))
! {
!   path += 2;
!   while (*path  !IS_DIR_SEP(*path))
!   path++;
!   }
! else if (isalpha(path[0])  path[1] == ':')
! {
! path++;
!   if (IS_DIR_SEP(path[1]))
!   path++;
!   }
! }
! #endif
! 
/* trim off trailing slashes */
if (p  path)
for (p--; p  path  IS_DIR_SEP(*p); p--)

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] [pgsql-hackers-win32] Data directory with trailing [back]slash

2004-06-20 Thread Andrew Dunstan

Tom Lane wrote:
Magnus Hagander [EMAIL PROTECTED] writes:
 

It's not possible to start the postmaster on win32 with:
postmaster -D d:\pgdata\
or
postmaster -D d:/pgdata/
   

Sounds like canonicalize_path() needs to be applied a bit sooner than
it is.
BTW I think canonicalize_path() is a few bricks shy of a load yet:
I'm not sure it works well with Windows drive-letters, and it definitely
will strip significant slashes when given input like '/' or 'C:\'.
Feel free to fix those problems while at it...
 

Or use the attached patch, which I think does it right.
cheers
andrew
Index: src/port/path.c
===
RCS file: /projects/cvsroot/pgsql-server/src/port/path.c,v
retrieving revision 1.20
diff -c -r1.20 path.c
*** src/port/path.c	11 Jun 2004 17:09:13 -	1.20
--- src/port/path.c	21 Jun 2004 00:19:27 -
***
*** 115,121 
--- 115,144 
  		if (*p == '\\')
  			*p = '/';
  	}
+ 
+ /* skip network and drive specifiers for win32 */
+ if (strlen(path) = 2)
+ {
+ if (path[0] == '/'  path[1] == '/')
+ {
+ /* network drive */
+ path = strstr(path + 2, /);
+ if (path == NULL)
+ return;
+ }
+ else if (path[1] == ':' 
+  ((path[0] = 'a'  path[0] = 'z') ||
+   (path[0] = 'A'  path[0] = 'Z')))
+ {
+ /* local drive */
+ path += 2;
+ }
+ }
+ 
  #endif
+ 
+ if (path[0] == '/')/* don't trim leading '/'. */
+ ++path;
  
  	trim_trailing_separator(path);
  }

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match