From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Rough idea for supporting "sequencename.nextval" syntax |
Date: | 2001-08-16 00:36:54 |
Message-ID: | 7539.997922214@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I have what may be a half-baked idea for allowing nextval and friends to
work with a true sequence-name parameter, rather than a string
equivalent.
Suppose that we invent a new datatype "regclass", similar to regproc:
it's actually an OID, but it has the additional implication that it is
the OID of a pg_class row, and the I/O operations for the type try to
accept or print a class name not just a numeric OID.
Next, hack the parser to understand that when a function has an argument
declared as type regclass and is invoked with the syntax relname.func or
func(relname), what is wanted is for the OID of the relation to be
passed as a constant argument; the relation is NOT inserted into the
query's rangetable.
Then, it's a simple matter to write a variant of nextval that identifies
its target sequence by OID rather than name. The function will still be
responsible for ensuring that what it's pointed at is indeed a sequence,
since the parser won't enforce that.
I haven't yet studied the parser to see how much of a hack this would
be, but it seems doable. The facility might be of use for other
functions besides the sequence ones, too.
Thoughts?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 2001-08-16 01:10:40 | Re: encoding names |
Previous Message | Jan Wieck | 2001-08-15 22:27:24 | Re: Dollar in identifiers |