Re: COPY command works with older driver but not newer one ?

Lists: pgsql-jdbc
From: Warren Bell <warren(at)clarksnutrition(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: COPY command works with older driver but not newer one ?
Date: 2009-01-12 02:28:13
Message-ID: 496AAABD.7070606@clarksnutrition.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

When you say server I am assuming you are talking about the database, if
so, I am only talking about one 8.1 database. The older driver works on
8.1 and the newer driver does not work on 8.1. I also tried the same
scenario on a PostgresPlus 8.3 database on an Apple with the same
results, the older driver worked and the newer one does not. Why does it
work with the older driver and not the new one? Is this a capability
that was changed between drivers?

Oliver Jowett wrote:

You will need to synthesize the complete query string yourself instead
of using a parameter placeholder, as it appears that the server doesn't
support a parameter placeholder as the filename argument to COPY FROM.
This is similar to how you can't use parameter placeholders for table
names, etc - the driver is limited by where the server's query parser
will accept a $1, $2, etc in the query string.

Though I'm not sure why the server doesn't allow this case, it seems
like the argument to COPY FROM is data, not structural. Perhaps the FROM
STDIN case is the problem.

-O

19:18:01.025 (1) FE=> Parse(stmt=null,query="COPY import FROM
$1",oids={1043})
19:18:01.029 (1) FE=>
Bind(stmt=null,portal=null,$1=</Users/Warren/Desktop/test.txt>)

19:18:01.048 (1) <=BE ErrorMessage(ERROR: syntax error at or near "$1"


From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Warren Bell <warren(at)clarksnutrition(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: COPY command works with older driver but not newer one ?
Date: 2009-01-12 05:44:04
Message-ID: 496AD8A4.3020404@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Warren Bell wrote:

> When you say server I am assuming you are talking about the database,

I mean the database server processes, yes.

> Why does it
> work with the older driver and not the new one?

Because the newer driver (here, "newer" means something like "anything
more recent than 2005") uses a newer version of the wire protocol and
passes parameter values out-of-line from the query string, rather than
substituting parameter values into the query string itself.

-O