Re: Transaction aborts on syntax error.

From: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
To: "'Bruce Momjian'" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "'Zeugswetter Andreas SB SD'" <ZeugswetterA(at)spardat(dot)at>
Cc: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "'Andrej Czapszys'" <czapszys(at)comcast(dot)net>, "'Gavin Sherry'" <swm(at)linuxworld(dot)com(dot)au>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Transaction aborts on syntax error.
Date: 2004-02-12 22:56:00
Message-ID: 008901c3f1bb$62ea3380$8a7c893e@LaptopDellXP
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>Bruce Momjian wrote
> Zeugswetter Andreas SB SD wrote:
> >
> > >> Improving on "not ideal" would be good, and would get even closer
to
> > >> full Oracle/SQLServer migration/compatibility. However, since
I've
> never
> > >> looked at that section of code, I couldn't comment on any
particular
> > >> approach nor implement such a change, so I'll shut up and be
patient.
> > >
> > > Imagine this:
> > >
> > > BEGIN WORK;
> > > LOCK oldtab;
> > > CREATE_X TABLE newtab AS SELECT * FROM oldtab;
> > > DELETE oldtab;
> > > COMMIT
> > >
> > > In this case, you would want the database to abort on a syntax
error,
> right?
> >
> > Yeah, but in other db's this is solved by the frontend. e.g. in
Informix
> > dbaccess has a mode that simply stops execution upon first error. So
I
> don't
> > think this is a nogo argument, if we added such a feature to psql.
>
> Stops execution on the first error? What does that mean? It means it
> stops reading the rest of the command file? We might be able to do
> that (invalidate the entire session), but is that desired?

I wouldn't want to stop execution on the first error. All of that
transaction stuff doesn't apply to batch execution of script files - the
script is being executed blind, so having a decision point mid-way thru
a transaction isn't that important. This thread wasn't originally about
psql behaviour, though if we divert in that direction....I could see a
use for:

\if error then quit "newtab create failed"
or something like that

or even:
\retry on (with default=off)
to automatically submit an SQL statement if it fails with a retryable
error

Regards, Simon Riggs

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Kirkwood 2004-02-12 23:16:41 Re: [HACKERS] PITR Dead horse?
Previous Message Edwin S. Ramirez 2004-02-12 22:01:47 Re: Transaction aborts on syntax error.