plpgsql execute vs. SELECT ... INTO

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: plpgsql execute vs. SELECT ... INTO
Date: 2010-11-05 22:49:35
Message-ID: 4CD489FF.1000908@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


(Prompted by a puzzled user on IRC)

Ten years ago, nearly, we made this commit
<https://github.com/postgres/postgres/commit/8a2cdd77ad5c0a4f8902ea86d0377336e076abcb>
(see what a good thing it is we carefully got all the history
transferred to git?)

The comment on the commit says:

EXECUTE of a SELECT ... INTO now draws a 'not implemented' error,
rather than executing the INTO clause with non-plpgsql semantics
as it was doing for the last few weeks/months. This keeps our options
open for making it do the right plpgsql-ish thing in future without
creating a backwards compatibility problem. There is no loss of
functionality since people can get the same behavior with CREATE TABLE AS.

Do we really still need to keep out options open on this after all that
time?

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql execute vs. SELECT ... INTO
Date: 2010-11-05 22:54:06
Message-ID: 3915.1288997646@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> The comment on the commit says:

> EXECUTE of a SELECT ... INTO now draws a 'not implemented' error,
> rather than executing the INTO clause with non-plpgsql semantics
> as it was doing for the last few weeks/months. This keeps our options
> open for making it do the right plpgsql-ish thing in future without
> creating a backwards compatibility problem. There is no loss of
> functionality since people can get the same behavior with CREATE TABLE AS.

> Do we really still need to keep out options open on this after all that
> time?

I think it's still a good idea that it won't do something that is very
much different from what a non-EXECUTE'd SELECT INTO will do.

I forget, is there a HINT there suggesting CREATE TABLE AS? Maybe we
should add one if not.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql execute vs. SELECT ... INTO
Date: 2010-11-05 22:59:41
Message-ID: 4CD48C5D.9080703@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 11/05/2010 06:54 PM, Tom Lane wrote:
> Andrew Dunstan<andrew(at)dunslane(dot)net> writes:
>> The comment on the commit says:
>> EXECUTE of a SELECT ... INTO now draws a 'not implemented' error,
>> rather than executing the INTO clause with non-plpgsql semantics
>> as it was doing for the last few weeks/months. This keeps our options
>> open for making it do the right plpgsql-ish thing in future without
>> creating a backwards compatibility problem. There is no loss of
>> functionality since people can get the same behavior with CREATE TABLE AS.
>> Do we really still need to keep out options open on this after all that
>> time?
> I think it's still a good idea that it won't do something that is very
> much different from what a non-EXECUTE'd SELECT INTO will do.
>
> I forget, is there a HINT there suggesting CREATE TABLE AS? Maybe we
> should add one if not.

No, (see below) we should certainly improve that and document the
behavior, if we're going to keep it.

if (*ptr == 'S' || *ptr == 's')
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("EXECUTE of SELECT ... INTO is not
implemented"),
errhint("You might want to use EXECUTE ...
INTO instead.")));

cheers

andrew


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql execute vs. SELECT ... INTO
Date: 2011-03-10 20:59:22
Message-ID: 201103102059.p2AKxN304673@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan wrote:
>
>
> On 11/05/2010 06:54 PM, Tom Lane wrote:
> > Andrew Dunstan<andrew(at)dunslane(dot)net> writes:
> >> The comment on the commit says:
> >> EXECUTE of a SELECT ... INTO now draws a 'not implemented' error,
> >> rather than executing the INTO clause with non-plpgsql semantics
> >> as it was doing for the last few weeks/months. This keeps our options
> >> open for making it do the right plpgsql-ish thing in future without
> >> creating a backwards compatibility problem. There is no loss of
> >> functionality since people can get the same behavior with CREATE TABLE AS.
> >> Do we really still need to keep out options open on this after all that
> >> time?
> > I think it's still a good idea that it won't do something that is very
> > much different from what a non-EXECUTE'd SELECT INTO will do.
> >
> > I forget, is there a HINT there suggesting CREATE TABLE AS? Maybe we
> > should add one if not.
>
> No, (see below) we should certainly improve that and document the
> behavior, if we're going to keep it.
>
> if (*ptr == 'S' || *ptr == 's')
> ereport(ERROR,
> (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> errmsg("EXECUTE of SELECT ... INTO is not
> implemented"),
> errhint("You might want to use EXECUTE ...
> INTO instead.")));

Can someone suggest updated hint text, like this?

errhint("You might want to use EXECUTE ... INTO or EXECUTE CREATE TABLE AS instead.")));

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql execute vs. SELECT ... INTO
Date: 2011-03-16 00:19:01
Message-ID: 201103160019.p2G0J1L25074@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian wrote:
> Andrew Dunstan wrote:
> >
> >
> > On 11/05/2010 06:54 PM, Tom Lane wrote:
> > > Andrew Dunstan<andrew(at)dunslane(dot)net> writes:
> > >> The comment on the commit says:
> > >> EXECUTE of a SELECT ... INTO now draws a 'not implemented' error,
> > >> rather than executing the INTO clause with non-plpgsql semantics
> > >> as it was doing for the last few weeks/months. This keeps our options
> > >> open for making it do the right plpgsql-ish thing in future without
> > >> creating a backwards compatibility problem. There is no loss of
> > >> functionality since people can get the same behavior with CREATE TABLE AS.
> > >> Do we really still need to keep out options open on this after all that
> > >> time?
> > > I think it's still a good idea that it won't do something that is very
> > > much different from what a non-EXECUTE'd SELECT INTO will do.
> > >
> > > I forget, is there a HINT there suggesting CREATE TABLE AS? Maybe we
> > > should add one if not.
> >
> > No, (see below) we should certainly improve that and document the
> > behavior, if we're going to keep it.
> >
> > if (*ptr == 'S' || *ptr == 's')
> > ereport(ERROR,
> > (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> > errmsg("EXECUTE of SELECT ... INTO is not
> > implemented"),
> > errhint("You might want to use EXECUTE ...
> > INTO instead.")));
>
> Can someone suggest updated hint text, like this?
>
> errhint("You might want to use EXECUTE ... INTO or EXECUTE CREATE TABLE AS instead.")));

OK, suggested wording improvement applied with attached patch.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/execute.diff text/x-diff 777 bytes