diff options
| author | Tom Lane | 2005-10-02 23:50:16 +0000 |
|---|---|---|
| committer | Tom Lane | 2005-10-02 23:50:16 +0000 |
| commit | aa731ed8433914641e42f32fec0fcf27f01aab7e (patch) | |
| tree | 7120217579cb1a88552c7a1ee44cc0a0749d6e3e /src/include | |
| parent | 1b61ee3c69ccd869bddc56ae1021797a517ca9b7 (diff) | |
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).
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/pg_cast.h | 7 | ||||
| -rw-r--r-- | src/include/catalog/pg_proc.h | 14 | ||||
| -rw-r--r-- | src/include/commands/sequence.h | 9 | ||||
| -rw-r--r-- | src/include/utils/builtins.h | 3 |
5 files changed, 22 insertions, 15 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index cd44e8c1559..569945bd49f 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.302 2005/09/16 05:35:40 neilc Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.303 2005/10/02 23:50:11 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200509161 +#define CATALOG_VERSION_NO 200510011 #endif diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h index 99410eeb778..7f9e30a5b24 100644 --- a/src/include/catalog/pg_cast.h +++ b/src/include/catalog/pg_cast.h @@ -10,7 +10,7 @@ * * Copyright (c) 2002-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.21 2005/04/14 01:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.22 2005/10/02 23:50:11 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -116,7 +116,9 @@ DATA(insert ( 16 23 2558 e )); * from OID to int4 or int8. Similarly for each OID-alias type. Also allow * implicit coercions between OID and each OID-alias type, as well as * regproc<->regprocedure and regoper<->regoperator. (Other coercions - * between alias types must pass through OID.) + * between alias types must pass through OID.) Lastly, there is an implicit + * cast from text to regclass, which exists mainly to support legacy forms + * of nextval() and related functions. */ DATA(insert ( 20 26 1287 i )); DATA(insert ( 21 26 313 i )); @@ -169,6 +171,7 @@ DATA(insert ( 21 2206 313 i )); DATA(insert ( 23 2206 0 i )); DATA(insert ( 2206 20 1288 a )); DATA(insert ( 2206 23 0 a )); +DATA(insert ( 25 2205 1079 i )); /* * String category: this needs to be tightened up diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 4b25833b17f..8c7f5b438cf 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.385 2005/09/16 05:35:40 neilc Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.386 2005/10/02 23:50:11 tgl Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -2073,14 +2073,14 @@ DATA(insert OID = 1572 ( notlike PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ DESCR("does not match LIKE expression"); -/* SEQUENCEs nextval & currval functions */ -DATA(insert OID = 1574 ( nextval PGNSP PGUID 12 f f t f v 1 20 "25" _null_ _null_ _null_ nextval - _null_ )); +/* SEQUENCE functions */ +DATA(insert OID = 1574 ( nextval PGNSP PGUID 12 f f t f v 1 20 "2205" _null_ _null_ _null_ nextval_oid - _null_ )); DESCR("sequence next value"); -DATA(insert OID = 1575 ( currval PGNSP PGUID 12 f f t f v 1 20 "25" _null_ _null_ _null_ currval - _null_ )); +DATA(insert OID = 1575 ( currval PGNSP PGUID 12 f f t f v 1 20 "2205" _null_ _null_ _null_ currval_oid - _null_ )); DESCR("sequence current value"); -DATA(insert OID = 1576 ( setval PGNSP PGUID 12 f f t f v 2 20 "25 20" _null_ _null_ _null_ setval - _null_ )); +DATA(insert OID = 1576 ( setval PGNSP PGUID 12 f f t f v 2 20 "2205 20" _null_ _null_ _null_ setval_oid - _null_ )); DESCR("set sequence value"); -DATA(insert OID = 1765 ( setval PGNSP PGUID 12 f f t f v 3 20 "25 20 16" _null_ _null_ _null_ setval_and_iscalled - _null_ )); +DATA(insert OID = 1765 ( setval PGNSP PGUID 12 f f t f v 3 20 "2205 20 16" _null_ _null_ _null_ setval3_oid - _null_ )); DESCR("set sequence value and iscalled status"); DATA(insert OID = 1579 ( varbit_in PGNSP PGUID 12 f f t f i 3 1562 "2275 26 23" _null_ _null_ _null_ varbit_in - _null_ )); @@ -3190,6 +3190,8 @@ DATA(insert OID = 2220 ( regtypein PGNSP PGUID 12 f f t f s 1 2206 "2275" _nu DESCR("I/O"); DATA(insert OID = 2221 ( regtypeout PGNSP PGUID 12 f f t f s 1 2275 "2206" _null_ _null_ _null_ regtypeout - _null_ )); DESCR("I/O"); +DATA(insert OID = 1079 ( regclass PGNSP PGUID 12 f f t f s 1 2205 "25" _null_ _null_ _null_ text_regclass - _null_ )); +DESCR("convert text to regclass"); DATA(insert OID = 2246 ( fmgr_internal_validator PGNSP PGUID 12 f f t f s 1 2278 "26" _null_ _null_ _null_ fmgr_internal_validator - _null_ )); DESCR("(internal)"); diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h index 38538236c7a..13cbdc403ff 100644 --- a/src/include/commands/sequence.h +++ b/src/include/commands/sequence.h @@ -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/include/commands/sequence.h,v 1.32 2005/06/07 07:08:35 neilc Exp $ + * $PostgreSQL: pgsql/src/include/commands/sequence.h,v 1.33 2005/10/02 23:50:12 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -81,10 +81,11 @@ typedef struct xl_seq_rec } xl_seq_rec; extern Datum nextval(PG_FUNCTION_ARGS); -extern Datum currval(PG_FUNCTION_ARGS); +extern Datum nextval_oid(PG_FUNCTION_ARGS); +extern Datum currval_oid(PG_FUNCTION_ARGS); +extern Datum setval_oid(PG_FUNCTION_ARGS); +extern Datum setval3_oid(PG_FUNCTION_ARGS); extern Datum lastval(PG_FUNCTION_ARGS); -extern Datum setval(PG_FUNCTION_ARGS); -extern Datum setval_and_iscalled(PG_FUNCTION_ARGS); extern void DefineSequence(CreateSeqStmt *stmt); extern void AlterSequence(AlterSeqStmt *stmt); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index ca31f309893..50855daf8d2 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.264 2005/09/16 05:35:41 neilc Exp $ + * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.265 2005/10/02 23:50:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -482,6 +482,7 @@ extern Datum regtypein(PG_FUNCTION_ARGS); extern Datum regtypeout(PG_FUNCTION_ARGS); extern Datum regtyperecv(PG_FUNCTION_ARGS); extern Datum regtypesend(PG_FUNCTION_ARGS); +extern Datum text_regclass(PG_FUNCTION_ARGS); extern List *stringToQualifiedNameList(const char *string, const char *caller); extern char *format_procedure(Oid procedure_oid); extern char *format_operator(Oid operator_oid); |
