Unix Technical Forum

pg_restore COPY error handling

This is a discussion on pg_restore COPY error handling within the Pgsql Patches forums, part of the PostgreSQL category; --> * Stephen Frost (sfrost@snowman.net) wrote: > Needs to be changed to handle whitespace in front of the actual 'COPY', ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 01:16 AM
Stephen Frost
 
Posts: n/a
Default pg_restore COPY error handling

* Stephen Frost (sfrost@snowman.net) wrote:
> Needs to be changed to handle whitespace in front of the actual 'COPY',
> unless someone else has a better idea. This should be reasonably
> trivial to do though... If you'd like me to make that change and send
> in a new patch, just let me know.


Fixed, using isspace(). Also added an output message to make it a bit
clearer when a failed COPY has been detected, etc.

Updated patch attached.

Thanks,

Stephen


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 01:17 AM
Bruce Momjian
 
Posts: n/a
Default Re: pg_restore COPY error handling


This needs a little style cleanup but I can do that.

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------


Stephen Frost wrote:
> * Stephen Frost (sfrost@snowman.net) wrote:
> > Needs to be changed to handle whitespace in front of the actual 'COPY',
> > unless someone else has a better idea. This should be reasonably
> > trivial to do though... If you'd like me to make that change and send
> > in a new patch, just let me know.

>
> Fixed, using isspace(). Also added an output message to make it a bit
> clearer when a failed COPY has been detected, etc.
>
> Updated patch attached.
>
> Thanks,
>
> Stephen


[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org


--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 01:17 AM
Stephen Frost
 
Posts: n/a
Default Re: pg_restore COPY error handling

Bruce, et al,

* Bruce Momjian (pgman@candle.pha.pa.us) wrote:
> This needs a little style cleanup but I can do that.


Thanks!

> Your patch has been added to the PostgreSQL unapplied patches list at:
>
> http://momjian.postgresql.org/cgi-bin/pgpatches
>
> It will be applied as soon as one of the PostgreSQL committers reviews
> and approves it.


Great! It'd be really nice to have this fix in 8.1.3...

Thanks again,

Stephen

> ---------------------------------------------------------------------------
> Stephen Frost wrote:
> > * Stephen Frost (sfrost@snowman.net) wrote:
> > > Needs to be changed to handle whitespace in front of the actual 'COPY',
> > > unless someone else has a better idea. This should be reasonably
> > > trivial to do though... If you'd like me to make that change and send
> > > in a new patch, just let me know.

> >
> > Fixed, using isspace(). Also added an output message to make it a bit
> > clearer when a failed COPY has been detected, etc.
> >
> > Updated patch attached.
> >
> > Thanks,
> >
> > Stephen

>
> [ Attachment, skipping... ]
>
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Have you searched our list archives?
> >
> > http://archives.postgresql.org

>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman@candle.pha.pa.us | (610) 359-1001
> + If your life is a hard drive, | 13 Roberts Road
> + Christ can be your backup. | Newtown Square, Pennsylvania 19073


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD25uDrzgMPqB3kigRAnMHAKCcP9HRluuN8LBdy3eEUq ViYS3YowCeNah+
bDxfou4Ec3tK2yB+QixA1B8=
=P140
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 01:17 AM
Bruce Momjian
 
Posts: n/a
Default Re: pg_restore COPY error handling

Stephen Frost wrote:
-- Start of PGP signed section.
> Bruce, et al,
>
> * Bruce Momjian (pgman@candle.pha.pa.us) wrote:
> > This needs a little style cleanup but I can do that.

>
> Thanks!
>
> > Your patch has been added to the PostgreSQL unapplied patches list at:
> >
> > http://momjian.postgresql.org/cgi-bin/pgpatches
> >
> > It will be applied as soon as one of the PostgreSQL committers reviews
> > and approves it.

>
> Great! It'd be really nice to have this fix in 8.1.3...


No, it will not be in 8.1.3. It is a new feature.

---------------------------------------------------------------------------


>
> Thanks again,
>
> Stephen
>
> > ---------------------------------------------------------------------------
> > Stephen Frost wrote:
> > > * Stephen Frost (sfrost@snowman.net) wrote:
> > > > Needs to be changed to handle whitespace in front of the actual 'COPY',
> > > > unless someone else has a better idea. This should be reasonably
> > > > trivial to do though... If you'd like me to make that change and send
> > > > in a new patch, just let me know.
> > >
> > > Fixed, using isspace(). Also added an output message to make it a bit
> > > clearer when a failed COPY has been detected, etc.
> > >
> > > Updated patch attached.
> > >
> > > Thanks,
> > >
> > > Stephen

> >
> > [ Attachment, skipping... ]
> >
> > >
> > > ---------------------------(end of broadcast)---------------------------
> > > TIP 4: Have you searched our list archives?
> > >
> > > http://archives.postgresql.org

> >
> > --
> > Bruce Momjian | http://candle.pha.pa.us
> > pgman@candle.pha.pa.us | (610) 359-1001
> > + If your life is a hard drive, | 13 Roberts Road
> > + Christ can be your backup. | Newtown Square, Pennsylvania 19073

-- End of PGP section, PGP failed!

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-18-2008, 01:18 AM
Stephen Frost
 
Posts: n/a
Default Re: pg_restore COPY error handling

* Bruce Momjian (pgman@candle.pha.pa.us) wrote:
> Stephen Frost wrote:
> > Great! It'd be really nice to have this fix in 8.1.3...

>
> No, it will not be in 8.1.3. It is a new feature.


I'd really appriciate it if you could review my post to pgsql-bugs,
Message-ID: <20060120144957.GG6026@ns.snowman.net>. If this patch is
considered a new feature then I'd like to either revisit that decision
or be given some direction on what a bug-fix patch for the grows-to-3G
bug would look like.

Thanks,

Stephen

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD4TRBrzgMPqB3kigRAufTAJ0ebuh0d3DZzrRx8I6v83 rNx/YTEACfV5uI
ph7E+jZ0IEs5izU+5Zrpnno=
=rfgg
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-18-2008, 01:18 AM
Bruce Momjian
 
Posts: n/a
Default Re: pg_restore COPY error handling

Stephen Frost wrote:
-- Start of PGP signed section.
> * Bruce Momjian (pgman@candle.pha.pa.us) wrote:
> > Stephen Frost wrote:
> > > Great! It'd be really nice to have this fix in 8.1.3...

> >
> > No, it will not be in 8.1.3. It is a new feature.

>
> I'd really appriciate it if you could review my post to pgsql-bugs,
> Message-ID: <20060120144957.GG6026@ns.snowman.net>. If this patch is
> considered a new feature then I'd like to either revisit that decision
> or be given some direction on what a bug-fix patch for the grows-to-3G
> bug would look like.


Oh, so when it skips the \., it reads the rest of the file and bombs
out? I thought it just continued fine. How is that failure happening?

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-18-2008, 01:18 AM
Andrew Dunstan
 
Posts: n/a
Default Re: pg_restore COPY error handling

On Wed, 2006-02-01 at 17:20 -0500, Stephen Frost wrote:
> * Bruce Momjian (pgman@candle.pha.pa.us) wrote:
> > Stephen Frost wrote:
> > > Great! It'd be really nice to have this fix in 8.1.3...

> >
> > No, it will not be in 8.1.3. It is a new feature.

>
> I'd really appriciate it if you could review my post to pgsql-bugs,
> Message-ID: <20060120144957.GG6026@ns.snowman.net>. If this patch is
> considered a new feature then I'd like to either revisit that decision
> or be given some direction on what a bug-fix patch for the grows-to-3G
> bug would look like.
>



Stephen,

this is a hopeless way of giving a reference. Many users don't keep list
emails. If you want to refer to a previous post you should give a
reference to the web archives.

I assume you are referring to this post:
http://archives.postgresql.org/pgsql...1/msg00188.php

cheers

andrew


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-18-2008, 01:18 AM
Bruce Momjian
 
Posts: n/a
Default Re: pg_restore COPY error handling

Andrew Dunstan wrote:
> On Wed, 2006-02-01 at 17:20 -0500, Stephen Frost wrote:
> > * Bruce Momjian (pgman@candle.pha.pa.us) wrote:
> > > Stephen Frost wrote:
> > > > Great! It'd be really nice to have this fix in 8.1.3...
> > >
> > > No, it will not be in 8.1.3. It is a new feature.

> >
> > I'd really appriciate it if you could review my post to pgsql-bugs,
> > Message-ID: <20060120144957.GG6026@ns.snowman.net>. If this patch is
> > considered a new feature then I'd like to either revisit that decision
> > or be given some direction on what a bug-fix patch for the grows-to-3G
> > bug would look like.
> >

>
>
> Stephen,
>
> this is a hopeless way of giving a reference. Many users don't keep list
> emails. If you want to refer to a previous post you should give a
> reference to the web archives.
>
> I assume you are referring to this post:
> http://archives.postgresql.org/pgsql...1/msg00188.php


OK, that helps. The solution is to "not do that", meaning install
postgis before the restore or something. Anyway, adding the patch seems
like too large a risk for a minor release, especially since you are the
first person to complain about it that I remember.

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-18-2008, 01:18 AM
Tom Lane
 
Posts: n/a
Default Re: pg_restore COPY error handling

Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Andrew Dunstan wrote:
>> I assume you are referring to this post:
>> http://archives.postgresql.org/pgsql...1/msg00188.php


> OK, that helps. The solution is to "not do that", meaning install
> postgis before the restore or something. Anyway, adding the patch seems
> like too large a risk for a minor release, especially since you are the
> first person to complain about it that I remember.


I don't think you should see this as something specific to PostGIS.
If I interpret Stephen's report properly, any sort of failure during
COPY IN would lead to undesirable behavior in pg_restore.

This is not super surprising because the original design approach for
pg_restore was "bomb out on any sort of difficulty whatsoever". That
was justly complained about, and now it will try to keep going after
SQL-command errors ... but it sounds like the COPY-data processing
part didn't get fixed properly.

I take no position on whether Stephen's patch is any good --- I haven't
looked at it --- but if he's correct about the problem then I agree it's
a bug fix. Before deciding whether it deserves to be back-patched, we
at least ought to look closely enough to characterize the situations in
which pg_restore will fail.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-18-2008, 01:18 AM
Stephen Frost
 
Posts: n/a
Default Re: pg_restore COPY error handling

* Bruce Momjian (pgman@candle.pha.pa.us) wrote:
> Stephen Frost wrote:
> -- Start of PGP signed section.
> > * Bruce Momjian (pgman@candle.pha.pa.us) wrote:
> > > Stephen Frost wrote:
> > > > Great! It'd be really nice to have this fix in 8.1.3...
> > >
> > > No, it will not be in 8.1.3. It is a new feature.

> >
> > I'd really appriciate it if you could review my post to pgsql-bugs,
> > Message-ID: <20060120144957.GG6026@ns.snowman.net>. If this patch is
> > considered a new feature then I'd like to either revisit that decision
> > or be given some direction on what a bug-fix patch for the grows-to-3G
> > bug would look like.

>
> Oh, so when it skips the \., it reads the rest of the file and bombs
> out? I thought it just continued fine. How is that failure happening?


It doesn't actually bomb out either. On the system I was working with
what happened was that it hung after reading in the COPY data. It
looked like it got stuck somehow while trying to parse the data as an
SQL command.

Thanks,

Stephen

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD4VkerzgMPqB3kigRAvQIAJ9B5t3bVS6hsCyheuxhXz OBO2BwKQCcDxt1
wN+woFcorfOu245FN3XlCN0=
=oTrf
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:34 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com