Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
07e74305
Commit
07e74305
authored
Oct 03, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update release notes to show how to upgrade a database to use the new
early binding for nextval() calls in default clauses.
parent
6a175779
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
10 deletions
+62
-10
doc/src/sgml/release.sgml
doc/src/sgml/release.sgml
+62
-10
No files found.
doc/src/sgml/release.sgml
View file @
07e74305
<!--
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.38
1 2005/10/02 23:50:06 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.38
2 2005/10/03 01:57:59 momjian
Exp $
Typical markup:
...
...
@@ -262,6 +262,21 @@ pg_[A-Za-z0-9_] <application>
<itemizedlist>
<listitem>
<para>
<varname>Add proper sequence function dependencies (Tom)
</para>
<para>
In previous releases, <function>nextval()</>,
<function>currval</>, and <function>setval()</> recorded
sequence names as simple text strings, meaning that renaming or
dropping a sequence used in a <command>DEFAULT</> made the
clause invalid. This release stores all newly-created sequence
function arguments using internal oids, allowing them to handle
sequence renaming, and adding dependency information that
</para>
</listitem>
<listitem>
<para>
<varname>add_missing_from</> is now false by default (Neil)
...
...
@@ -398,16 +413,53 @@ pg_[A-Za-z0-9_] <application>
</para>
<para>
When an expression like <literal>nextval('myseq')</> appears in a
column default expression or view, the referenced sequence (here
<literal>myseq</>) is now looked up immediately, and its pg_class
OID is placed in the stored expression. This representation will
survive renaming of the referenced sequence, as well as changes in
schema search paths. The system also understands that the sequence
reference represents a dependency, so the sequence cannot be dropped
without dropping the referencing object. To get the old behavior of
run-time lookup of the sequence by name, cast the argument to
<type>text</>, for example <literal>nextval('myseq'::text)</>.
column <command>DEFAULT</> expression or view, the referenced
sequence (here <literal>myseq</>) is now looked up immediately,
and its pg_class OID is placed in the stored expression. This
representation will survive renaming of the referenced sequence,
as well as changes in schema search paths. The system also
understands that the sequence reference represents a dependency,
so the sequence cannot be dropped without dropping the
referencing object. Previous releases stored this information as
a simple text string, with none of the benefits outlined above.
To get the old text-based behavior of run-time lookup of the
sequence name, cast the argument to <type>text</>, for example
<literal>nextval('myseq'::text)</>.
</para>
<para>
Pre-8.1 schemas loaded into 8.1 will use the previous, text-based
representation and therefore will not have these protections.
However, it is possible to upgrade a database to the newer
OID-based arguments. First, save this query into a file, such as
<filename>fixseq.sql</>:
<programlisting>
SELECT 'ALTER TABLE ' ||
pg_catalog.quote_ident(n.nspname) || '.' ||
pg_catalog.quote_ident(c.relname) ||
' ALTER COLUMN ' || pg_catalog.quote_ident(a.attname) ||
' SET DEFAULT ' ||
regexp_replace(d.adsrc, '(nextval\\(''[^'']*'')::text', '\\1', 'g') ||
';'
FROM pg_namespace n, pg_class c, pg_attribute a, pg_attrdef d
WHERE n.oid = c.relnamespace AND
c.oid = a.attrelid AND
a.attrelid = d.adrelid AND
a.attnum = d.adnum AND
d.adsrc ~ '.*nextval\\(''[^'']*''::text';
</programlisting>
Next, run the query against a database to find what
adjustments are required, like this for database <literal>db1</>:
<programlisting>
psql -aT -f fixseq.sql db1
</programlisting>
This will show the <command>ALTER TABLE</> commands needed to
convert the database to the newer OID-based representation.
Finally, run this to update the database:
<programlisting>
psql -aT -f fixseq.sql db1 | psql -e db1
</programlisting>
This process should be done for each database loaded with pre-8.1
schemas.
</listitem>
<listitem>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment