select from sequences

Started by Jaime Casanovaalmost 19 years ago5 messages
#1Jaime Casanova
systemguards@gmail.com

Hi,

just for curiosity, why the code doesn't throw an error when using
sequences in the from_list of a select?

allow selects from sequences confuses many people about the correct
way of using sequences

--
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jaime Casanova (#1)
Re: select from sequences

"Jaime Casanova" <systemguards@gmail.com> writes:

just for curiosity, why the code doesn't throw an error when using
sequences in the from_list of a select?

That's a feature, not a bug.

regards, tom lane

#3Jaime Casanova
systemguards@gmail.com
In reply to: Tom Lane (#2)
Re: select from sequences

On 2/11/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:

"Jaime Casanova" <systemguards@gmail.com> writes:

just for curiosity, why the code doesn't throw an error when using
sequences in the from_list of a select?

That's a feature, not a bug.

and why is this a feature? i mean, what real use it has?

--
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jaime Casanova (#3)
Re: select from sequences

"Jaime Casanova" <systemguards@gmail.com> writes:

and why is this a feature? i mean, what real use it has?

To find out the parameters of an existing sequence. Remove it and
you'll break pg_dump, to say nothing of any other application.

regards, tom lane

#5Merlin Moncure
mmoncure@gmail.com
In reply to: Jaime Casanova (#3)
Re: select from sequences

On 2/11/07, Jaime Casanova <systemguards@gmail.com> wrote:

On 2/11/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:

"Jaime Casanova" <systemguards@gmail.com> writes:

just for curiosity, why the code doesn't throw an error when using
sequences in the from_list of a select?

That's a feature, not a bug.

and why is this a feature? i mean, what real use it has?

I use it all the time. You can query the sequence for its last value
without using it first. This is a lot more useful than it appears on
the surface.

merlin