Re: Subtle pg_dump problem... - Mailing list pgsql-hackers

From Oleg Bartunov
Subject Re: Subtle pg_dump problem...
Date
Msg-id Pine.GSO.4.58.0405121919420.9525@ra.sai.msu.su
Whole thread Raw
In response to Re: Subtle pg_dump problem...  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
List pgsql-hackers
Christopher,

here is a cut'n paste from test script (patch applied):

dropdb qq
createdb qq
psql qq  -c "create schema contrib;"
psql qq < tsearch2_contrib-2.sql
psql qq -c "create table test ( a text, fts contrib.tsvector);"
psql qq -c "insert into test(a) values ('I hit a dog');"
psql qq -c "set search_path = public,contrib; update test set fts = to_tsvector(a);"
pg_dump qq > qq.dump

There's certainly one record and after restoring I could use tsearch2
as usual (of course, setting search_path properly).

Oleg
On Wed, 12 May 2004, Christopher Kings-Lynne wrote:

> >>6. However, it is now not possible to restore the sql script as it was
> >>dumped, as you get this error:
> >>
> >>ERROR:  relation "pg_ts_cfg" does not exist
> >>
> >
> >
> > No problem,
> >
> > megera@mira:~/app/pgsql/tsearch2/test_scheme$ createdb qq
> > CREATE DATABASE
> > megera@mira:~/app/pgsql/tsearch2/test_scheme$ psql qq -c "create schema contrib"
> > CREATE SCHEMA
> > psql qq < ./tsearch2_contrib.sql
> > psql qq < ./test.dump
> > SET
> > SET
> > SET
> > SET
> > CREATE TABLE
>
> Is that because you didn't insert any data into the table before dumping
> it?  You will get the same error that follows:
>
> > But I get error later:
> >
> > qq=# insert into test(a) values( 'the hot dog');
> > INSERT 3478544 1
> > qq=# update test set fts=contrib.to_tsvector(a);
> > ERROR:  relation "pg_ts_cfg" does not exist
> >
> > after setting proper search_path it worked:
> >
> > qq=# set search_path to public,contrib;
> > SET
> > qq=# update test set fts=contrib.to_tsvector(a);
> > UPDATE 1
>
> My point is that if you pg_dump a table that has data in it, pg_dump
> will set yoru search_path for you, and so the restore will fail.
>
> > pg_dump qq > qq.dump
> > dropdb qq
> > createdb qq
> > psql qq < qq.dump
> > qq=# set search_path to public,contrib;
> > SET
> > qq=# update test set fts=contrib.to_tsvector(a);
> > UPDATE 1
> >
> >
> > works like a charm :)
>
> I bet you don't have any data in the table.
>
> Chris
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
Regards,    Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83


pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: Subtle pg_dump problem...
Next
From: Oleg Bartunov
Date:
Subject: Re: Subtle pg_dump problem...