Re: is_absolute_path incorrect on Windows
Bruce Momjian <bruce@momjian.us>
From: Bruce Momjian <bruce@momjian.us>
To: Magnus Hagander <magnus@hagander.net>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2011-02-03T16:50:47Z
Lists: pgsql-hackers
Attachments
- /rtmp/relative.diff (text/x-diff) patch
Bruce Momjian wrote: > > However, it misses the case with for example E:foo, which is a perfectly > > valid path on windows. Which isn't absolute *or* relative - it's relative > > to the current directory on the E: drive. Which will be the same as the > > current directory for the process *if* the process current directory is > > on drive E:. In other cases, it's a different directory. > > I would argue that E:foo is always relative (which matches > is_absolute_path()). If E: is the current drive of the process, it is > relative, and if the current drive is not E:, it is relative to the last > current drive on E: for that process, or the top level if there was no > current drive. (Tested on XP.) > > There seem to be three states: > > 1. absolute - already tested by is_absolute_path() > 2. relative to the current directory (current drive) > 3. relative on a different drive > > We could probably develop code to test all three, but keep in mind that > the path itself can't distinguish between 2 and 3, and while you can > test the current drive, if the current drive changes, a 2 could become a > 3, and via versa. I have reviewed is_absolute_path() and have implemented path_is_relative_and_below_cwd() to cleanly handle cases like 'E:abc' on Win32; patch attached. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +