Thread: BUG #1269: Copy To Gives Relative path error when explicit path given.

BUG #1269: Copy To Gives Relative path error when explicit path given.

From
"PostgreSQL Bugs List"
Date:
The following bug has been logged online:

Bug reference:      1269
Logged by:          William Mayhew

Email address:      wmayhew3@hotmail.com

PostgreSQL version: 8.0 Beta

Operating system:   WIN 2000 Professional

Description:        Copy To Gives Relative path error when explicit path
given.

Details:

I just installed the 8.0 Beta version I downloaded last night and created a
test database today entitled 'testdb'.  All file systems on my PC are NTFS.


I logged onto the 'testdb' database via the Windows command prompt, using
psql.  Immediately, I got the following warning:

Warning: Console codepage (437) differs from windows codepage (1252)
         8-bit characters will not work correctly. See PostgreSQL
         documentation "Installation on Windows" for details.

Next, I created a table called 'users'.

Before I continue to describe the problem, please be aware that the exact
same problem resulted after leaving the codepage settings unchanged, and
after changing the codepage to 437 via the following command: cmd.exe /c
chcp 437.
I chose 437 because it seemed logical to try that in the event the default
codepage had some undesirable effect on the outcome of my problem.  OK, back
to the problem.

After creating a few rows in the users table.  Of course, I ran a count(*)
query and the number of rows matched the number I inserted into the table.
Just to make sure, I queried all rows to verify the exact data. Next, I
tried to export the data into a flat file.  Here is my syntax and the
accompanying error:

testdb=# COPY users TO 'D:\Program
Files\PostgreSQL\DataFlatFiles\usersdata';
ERROR:  relative path not allowed for COPY to file

That looks like an explicit filename to me, so how can the server view the
quoted filename as a relative path?
What exactly is the server looking for?

Out of desperation I tried to use double quotes, but that seemed to generate
a syntax error.

Next, I thought I would try to change the current working directory to the
exact location where I wanted to write the output file, "usersdata."  On
this attempt, I did not refer to the drive letter or the path.  Here are the
results of my plsql commands:

Step 1
testdb-# \! dir
 Volume in drive D has no label.
 Volume Serial Number is 78D0-B9A2

 Directory of D:\Program Files\PostgreSQL\DataFlatFiles

09/25/2004  07:36p      <DIR>          .
09/25/2004  07:36p      <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)   6,354,862,080 bytes free

Step 2
testdb=# COPY users TO 'usersdata.txt';
ERROR:  relative path not allowed for COPY to file

Am I doing something wrong or is this an actual bug?

Re: BUG #1269: Copy To Gives Relative path error when explicit path given.

From
Tom Lane
Date:
"PostgreSQL Bugs List" <pgsql-bugs@postgresql.org> writes:
> testdb=# COPY users TO 'D:\Program Files\PostgreSQL\DataFlatFiles\usersdata';
> ERROR:  relative path not allowed for COPY to file

You need to double the backslashes.  Or use forward slashes.

            regards, tom lane