Problem specifying limit in select inside insert.

Started by Denis Perchineover 25 years ago2 messages
#1Denis Perchine
dyp@perchine.com

Hello,

I have quite strange behavior of the following SQL:

insert into address (cid,email) select distinct '49'::int,member.email from
member imit 1 ;

It should insert just 1 record.
But it insert all recodrs which will be selected by subselect...
What's wrong with this SQL? Or this is a bug? If it is a bug...
How to fix it (patch, workaround...)

Thanks in advance.

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Denis Perchine (#1)
Re: Problem specifying limit in select inside insert.

Denis Perchine <dyp@perchine.com> writes:

insert into address (cid,email) select distinct '49'::int,member.email from
member imit 1 ;

INSERT ... SELECT ... LIMIT doesn't work. In existing releases the
LIMIT clause is just dropped on the floor by the parser :-(. In current
CVS sources you get
ERROR: LIMIT is not supported in subselects
which at least lets you know you have a problem. I have a to-do item
to see if this can be made to work right, but it's not very high
priority. I think the correct fix is to pull LIMIT handling out of
ExecutorRun and make it be handled by a new plan node type, but that'll
probably take more time than I can spare before 7.1 ...

regards, tom lane