Re: BUG #4901: Column name "window" breaks pg_dump/pg_restore

Lists: pgsql-bugs
From: "Steve Purcell" <steve(at)sanityinc(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4901: Column name "window" breaks pg_dump/pg_restore
Date: 2009-07-05 12:58:44
Message-ID: 200907051258.n65Cwi1x034109@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 4901
Logged by: Steve Purcell
Email address: steve(at)sanityinc(dot)com
PostgreSQL version: 8.4.0
Operating system: Linux (Debian Unstable)
Description: Column name "window" breaks pg_dump/pg_restore
Details:

The DB schema for openx (openx.org) contains a table with a column called
"window", which now causes a syntax error if unquoted. pg_dump doesn't
quote the column, so pg_restore/psql fail on the pg_dump output. Here's
what pg_dump spits out for the table:

CREATE TABLE ox_data_bkt_a (
server_conv_id bigint NOT NULL,
server_ip character varying(16) DEFAULT ''::character varying NOT NULL,
tracker_id integer NOT NULL,
date_time timestamp without time zone,
action_date_time timestamp without time zone,
creative_id integer NOT NULL,
zone_id integer NOT NULL,
ip_address character varying(16) DEFAULT ''::character varying NOT
NULL,
action integer,
window integer,
status integer
);

....

COPY ox_data_bkt_a (server_conv_id, server_ip, tracker_id, date_time,
action_date_time, creative_id, zone_id, ip_a
ddress, action, window, status) FROM stdin;


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Steve Purcell" <steve(at)sanityinc(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4901: Column name "window" breaks pg_dump/pg_restore
Date: 2009-07-05 15:55:05
Message-ID: 9776.1246809305@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Steve Purcell" <steve(at)sanityinc(dot)com> writes:
> The DB schema for openx (openx.org) contains a table with a column called
> "window", which now causes a syntax error if unquoted. pg_dump doesn't
> quote the column, so pg_restore/psql fail on the pg_dump output.

This is one of the reasons why it's recommended that you use the later
version's pg_dump to perform a cross-version dump and restore. 8.4's
pg_dump knows that "window" is a reserved word, but 8.3's could hardly
be expected to.

regards, tom lane


From: Steve Purcell <steve(at)sanityinc(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4901: Column name "window" breaks pg_dump/pg_restore
Date: 2009-07-05 16:37:35
Message-ID: 824E8CE3-2F90-4169-9B9C-BE1E5AF87EA6@sanityinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Thanks for the quick reply, Tom. That makes sense, and yes, that does
appear to be the problem.

I thought that I *was* using the newer pg_dump, but I'm doing this on
Debian:

# su - postgres -c "env PGCLUSTER=8.3/main pg_dump openx|env
PGCLUSTER=8.4/main pg_restore -d template1 -C"

And the debian pg_wrapper script ends up selecting the 8.3 pg_dump
binary in the first case. I'll have to figure out if there's even a
way to execute the newer pg_dump against the old database, which I
expect to be fiddly.

Thanks again, and sorry for the noise.

-Steve

On 5 Jul 2009, at 17:55, Tom Lane wrote:

> "Steve Purcell" <steve(at)sanityinc(dot)com> writes:
>> The DB schema for openx (openx.org) contains a table with a column
>> called
>> "window", which now causes a syntax error if unquoted. pg_dump
>> doesn't
>> quote the column, so pg_restore/psql fail on the pg_dump output.
>
> This is one of the reasons why it's recommended that you use the later
> version's pg_dump to perform a cross-version dump and restore. 8.4's
> pg_dump knows that "window" is a reserved word, but 8.3's could hardly
> be expected to.
>
> regards, tom lane
>


From: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
To: Steve Purcell <steve(at)sanityinc(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4901: Column name "window" breaks pg_dump/pg_restore
Date: 2009-07-06 10:28:59
Message-ID: 87skha85qs.fsf@hi-media-techno.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Steve Purcell <steve(at)sanityinc(dot)com> writes:

> # su - postgres -c "env PGCLUSTER=8.3/main pg_dump openx|env
> PGCLUSTER=8.4/main pg_restore -d template1 -C"
>
> And the debian pg_wrapper script ends up selecting the 8.3 pg_dump binary in
> the first case. I'll have to figure out if there's even a way to execute
> the newer pg_dump against the old database, which I expect to be
> fiddly.

I guess you could trick the binary choice then force another server
choice :
pg_dump --cluster 8.4/main -p <port of 8.3> ...

But I'd simply go with:
/usr/lib/postgresql/8.4/bin/pg_dump <options to target 8.3>

For people unaware of debian way of supporting more than one major
version and cluster, all PostgreSQL user binaries in /usr/bin are a link
to their pg_wrapper, which support the --cluster 8.X/clustername option
and will choose the right versionned binary and port number etc.

Regards,
--
dim


From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4901: Column name "window" breaks pg_dump/pg_restore
Date: 2009-07-06 11:31:21
Message-ID: h2sna9$ur7$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On 2009-07-05, Steve Purcell <steve(at)sanityinc(dot)com> wrote:
> Thanks for the quick reply, Tom. That makes sense, and yes, that does
> appear to be the problem.
>
> I thought that I *was* using the newer pg_dump, but I'm doing this on
> Debian:
>
> # su - postgres -c "env PGCLUSTER=8.3/main pg_dump openx|env
> PGCLUSTER=8.4/main pg_restore -d template1 -C"
>
> And the debian pg_wrapper script ends up selecting the 8.3 pg_dump
> binary in the first case. I'll have to figure out if there's even a
> way to execute the newer pg_dump against the old database, which I
> expect to be fiddly.

easiest is to bypass pg_wrapper

/usr/lib/postgresql/8.4/bin/pg_dump -p 5432

I have raised this with debian.


From: Steve Purcell <steve(at)sanityinc(dot)com>
To: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4901: Column name "window" breaks pg_dump/pg_restore
Date: 2009-07-06 13:11:19
Message-ID: E264DA28-0CE4-46C6-91D0-FE556E60DD70@sanityinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Terrific, thanks for that. I'd figured out the first trick you
suggested, but the second is much clearer.

-Steve

On 6 Jul 2009, at 12:28, Dimitri Fontaine wrote:

> Steve Purcell <steve(at)sanityinc(dot)com> writes:
>
>> # su - postgres -c "env PGCLUSTER=8.3/main pg_dump openx|env
>> PGCLUSTER=8.4/main pg_restore -d template1 -C"
>>
>> And the debian pg_wrapper script ends up selecting the 8.3 pg_dump
>> binary in
>> the first case. I'll have to figure out if there's even a way to
>> execute
>> the newer pg_dump against the old database, which I expect to be
>> fiddly.
>
> I guess you could trick the binary choice then force another server
> choice :
> pg_dump --cluster 8.4/main -p <port of 8.3> ...
>
> But I'd simply go with:
> /usr/lib/postgresql/8.4/bin/pg_dump <options to target 8.3>
>
> For people unaware of debian way of supporting more than one major
> version and cluster, all PostgreSQL user binaries in /usr/bin are a
> link
> to their pg_wrapper, which support the --cluster 8.X/clustername
> option
> and will choose the right versionned binary and port number etc.
>
> Regards,
> --
> dim
>