Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c87382

Browse files
committed
Fix procedure for updating nextval() defaults so that it actually works.
Update release dates for pending back-branch releases.
1 parent 8c73dfc commit 9c87382

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

doc/src/sgml/release.sgml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.386 2005/10/03 13:52:28 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.387 2005/10/03 16:04:13 tgl Exp $
33

44
Typical markup:
55

@@ -393,61 +393,62 @@ pg_[A-Za-z0-9_] <application>
393393

394394
<listitem>
395395
<para>
396-
Add proper sequence function dependencies for <command>
397-
DEFAULT</> clauses (Tom)
396+
Add proper dependencies for arguments of sequence functions (Tom)
398397
</para>
399398
<para>
400-
In previous releases, <function>nextval()</>,
401-
<function>currval</>, and <function>setval()</> recorded sequence
402-
names as simple text strings, meaning that renaming or dropping a
403-
sequence used in a <command>DEFAULT</> clause made the clause
399+
In previous releases, sequence names passed to <function>nextval()</>,
400+
<function>currval()</>, and <function>setval()</> were stored as
401+
simple text strings, meaning that renaming or dropping a
402+
sequence used in a <literal>DEFAULT</> clause made the clause
404403
invalid. This release stores all newly-created sequence function
405-
arguments as internal OIDs, allowing them to handle sequence
404+
arguments as internal OIDs, allowing them to track sequence
406405
renaming, and adding dependency information that prevents
407-
improper sequence removal. It also makes <command>DEFAULT</>
408-
clauses immune to schema search path changes, and allows schema
409-
renaming.
406+
improper sequence removal. It also makes such <literal>DEFAULT</>
407+
clauses immune to schema renaming and search path changes.
410408
</para>
411409
<para>
412-
Some applications might rely on the old text-based behavior of
410+
Some applications might rely on the old behavior of
413411
run-time lookup for sequence names. This can still be done by
414-
casting the argument to <type>text</>, for example
412+
explicitly casting the argument to <type>text</>, for example
415413
<literal>nextval('myseq'::text)</>.
416414
</para>
417415
<para>
418-
Pre-8.1 schemas loaded into 8.1 will use the previous, text-based
416+
Pre-8.1 database dumps loaded into 8.1 will use the old text-based
419417
representation and therefore will not have the features of
420-
OID-stored arguments. However, it is possible to upgrade a
421-
database loaded with pre-8.1 schemas. First, save this query into
422-
a file, such as <filename>fixseq.sql</>:
418+
OID-stored arguments. However, it is possible to update a
419+
database containing text-based <literal>DEFAULT</> clauses.
420+
First, save this query into a file, such as <filename>fixseq.sql</>:
423421
<programlisting>
424422
SELECT 'ALTER TABLE ' ||
425423
pg_catalog.quote_ident(n.nspname) || '.' ||
426424
pg_catalog.quote_ident(c.relname) ||
427425
' ALTER COLUMN ' || pg_catalog.quote_ident(a.attname) ||
428426
' SET DEFAULT ' ||
429-
regexp_replace(d.adsrc, '(nextval\\(''[^'']*'')::text', '\\1', 'g') ||
427+
regexp_replace(d.adsrc,
428+
$$val\(\(('[^']*')::text\)::regclass$$,
429+
$$val\(\1$$,
430+
'g') ||
430431
';'
431432
FROM pg_namespace n, pg_class c, pg_attribute a, pg_attrdef d
432433
WHERE n.oid = c.relnamespace AND
433434
c.oid = a.attrelid AND
434435
a.attrelid = d.adrelid AND
435436
a.attnum = d.adnum AND
436-
d.adsrc ~ '.*nextval\\(''[^'']*''::text';
437+
d.adsrc ~ $$val\(\('[^']*'::text\)::regclass$$;
437438
</programlisting>
438439
Next, run the query against a database to find what
439440
adjustments are required, like this for database <literal>db1</>:
440441
<programlisting>
441-
psql -aT -f fixseq.sql db1
442+
psql -t -f fixseq.sql db1
442443
</programlisting>
443444
This will show the <command>ALTER TABLE</> commands needed to
444445
convert the database to the newer OID-based representation.
445-
Finally, run this to update the database:
446+
If the commands look reasonable, run this to update the database:
446447
<programlisting>
447-
psql -aT -f fixseq.sql db1 | psql -e db1
448+
psql -t -f fixseq.sql db1 | psql -e db1
448449
</programlisting>
449-
This process should be done for each database loaded with pre-8.1
450-
schemas.
450+
This process must be repeated in each database to be updated.
451+
</para>
451452
</listitem>
452453

453454
<listitem>
@@ -2060,7 +2061,7 @@ psql -aT -f fixseq.sql db1 | psql -e db1
20602061

20612062
<note>
20622063
<title>Release date</title>
2063-
<simpara>2005-09-??</simpara>
2064+
<simpara>2005-10-04</simpara>
20642065
</note>
20652066

20662067
<para>
@@ -4836,7 +4837,7 @@ typedefs (Michael)</para></listitem>
48364837

48374838
<note>
48384839
<title>Release date</title>
4839-
<simpara>2005-09-??</simpara>
4840+
<simpara>2005-10-04</simpara>
48404841
</note>
48414842

48424843
<para>
@@ -7463,7 +7464,7 @@ DROP SCHEMA information_schema CASCADE;
74637464

74647465
<note>
74657466
<title>Release date</title>
7466-
<simpara>2005-09-??</simpara>
7467+
<simpara>2005-10-04</simpara>
74677468
</note>
74687469

74697470
<para>

0 commit comments

Comments
 (0)