Re: [COMMITTERS] pgsql: Add STRICT to PL/pgSQL SELECT INTO, so exceptions - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [COMMITTERS] pgsql: Add STRICT to PL/pgSQL SELECT INTO, so exceptions
Date
Msg-id 200606162033.k5GKXcn04578@candle.pha.pa.us
Whole thread Raw
In response to Re: [COMMITTERS] pgsql: Add STRICT to PL/pgSQL SELECT INTO, so exceptions are thrown if  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [COMMITTERS] pgsql: Add STRICT to PL/pgSQL SELECT INTO, so exceptions are thrown if
List pgsql-hackers
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> Do we actually need different error codes for too few and too many rows?
> >> It looks to me like the only relevant standard error condition is
> >> CARDINALITY_VIOLATION, so either we throw CARDINALITY_VIOLATION for both
> >> cases or we invent nonstandard codes.
> 
> > We could, and then suggest using ROW_COUNT to determine if there were
> > too few rows, or too many.
> 
> SELECT INTO doesn't set ROW_COUNT ... but if we change the code to set
> FOUND before throwing the error, it'd work to tell people to check
> FOUND.
>
> (Thinks a bit...)  Actually not, because if the exception catcher isn't
> in the same function as the SELECT INTO, it'll be looking at the wrong
> FOUND variable.  ROW_COUNT same problem, even if we were setting it.
> 
> Plan B is to invent new errcodes to match the Oracle spellings.  If
> that's what we want to do, it's not that hard.

We could use:
#define ERRCODE_DATA_EXCEPTION              MAKE_SQLSTATE('2','2',
or#define ERRCODE_ERROR_IN_ASSIGNMENT         MAKE_SQLSTATE('2','2',

--  Bruce Momjian   http://candle.pha.pa.us EnterpriseDB    http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [COMMITTERS] pgsql: Add STRICT to PL/pgSQL SELECT INTO, so exceptions are thrown if
Next
From: Bruce Momjian
Date:
Subject: Re: pg_dump -Ft failed on Windows XP