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

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [COMMITTERS] pgsql: Add STRICT to PL/pgSQL SELECT INTO, so exceptions
Date: 2006-06-16 20:33:38
Message-ID: 200606162033.k5GKXcn04578@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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. +

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Neil Conway 2006-06-16 20:41:06 Re: pgsql: DROP ...
Previous Message Andrew Dunstan 2006-06-16 20:23:45 pgsql: DROP ...

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-06-16 21:36:58 Re: pg_dump -Ft failed on Windows XP
Previous Message Simon Riggs 2006-06-16 20:08:57 Re: table/index fillfactor control, try 2