mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Change nextval and other sequence functions to specify their sequence
argument as a 'regclass' value instead of a text string. The frontend conversion of text string to pg_class OID is now encapsulated as an implicitly-invocable coercion from text to regclass. This provides backwards compatibility to the old behavior when the sequence argument is explicitly typed as 'text'. When the argument is just an unadorned literal string, it will be taken as 'regclass', which means that the stored representation will be an OID. This solves longstanding problems with renaming sequences that are referenced in default expressions, as well as new-in-8.1 problems with renaming such sequences' schemas or moving them to another schema. All per recent discussion. Along the way, fix some rather serious problems in dbmirror's support for mirroring sequence operations (int4 vs int8 confusion for instance).
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.324 2005/08/01 20:31:09 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.325 2005/10/02 23:50:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -912,12 +912,15 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
||||
* DEFAULT).
|
||||
*
|
||||
* Create an expression tree representing the function call
|
||||
* nextval('"sequencename"')
|
||||
* nextval('sequencename'). We cannot reduce the raw tree
|
||||
* to cooked form until after the sequence is created, but
|
||||
* there's no need to do so.
|
||||
*/
|
||||
qstring = quote_qualified_identifier(snamespace, sname);
|
||||
snamenode = makeNode(A_Const);
|
||||
snamenode->val.type = T_String;
|
||||
snamenode->val.val.str = qstring;
|
||||
snamenode->typename = SystemTypeName("regclass");
|
||||
funccallnode = makeNode(FuncCall);
|
||||
funccallnode->funcname = SystemFuncName("nextval");
|
||||
funccallnode->args = list_make1(snamenode);
|
||||
|
Reference in New Issue
Block a user