Skip site navigation (1) Skip section navigation (2)

Re: Loading a dump containing include commands

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: "Georg M(dot) Sorst" <georgsorst(at)gmx(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Loading a dump containing include commands
Date: 2010-09-29 13:57:28
Message-ID: 4CA345C8.5010902@postnewspapers.com.au (view raw or flat)
Thread:
Lists: pgsql-jdbc
On 29/09/2010 5:16 PM, Georg M. Sorst wrote:
> Hey list!
>
> Is there a way to load a dump with include statements (\i something.sql)
> with the Postgres JDBC driver? Both PGCopyOutputStream and the regular
> Statement seem to choke on \i.

No. \i is a psql-specific instruction. It's not part of the PostgreSQL 
dialect or protocol, it's a utility command in the "psql" interactive 
sql command processor.

You could probably pre-process the input stream to insert includes 
pretty easily, though. Doing it properly and cleanly would require your 
code to be properly aware of quoted blocks, including dollar-quoted 
blocks, but in practice you can probably get away with looking for a 
line-ending followed by a run of zero or more whitespace chars before \i .

-- 
Craig Ringer

Tech-related writing at http://soapyfrogs.blogspot.com/

In response to

pgsql-jdbc by date

Next:From: John ListerDate: 2010-09-29 17:58:36
Subject: Re: selecting using array as IN condition parameter - possible?
Previous:From: Oliver JowettDate: 2010-09-29 13:02:48
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group