Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7946f77

Browse files
committed
Cause ALTER TABLE to perform ALTER COLUMN DROP DEFAULT operations during
the DROP pass rather than the ADD_CONSTR pass. On examining the code Ithink this was just an oversight rather than intentional, and it seemsto satisfy the principle of least surprise better than the alternativesolution that was discussed. Add an example to the ref page showing howto do ALTER TYPE and update the default in one command. Per gripe fromMarkus Bertheau that that wasn't possible.
1 parent89c07b1 commit7946f77

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

‎doc/src/sgml/ref/alter_table.sgml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.87 2006/07/04 18:07:24 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.88 2006/08/03 20:57:06 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -741,6 +741,19 @@ ALTER TABLE foo
741741
</programlisting>
742742
</para>
743743

744+
<para>
745+
The same, when the column has a default expression that won't automatically
746+
cast to the new datatype:
747+
<programlisting>
748+
ALTER TABLE foo
749+
ALTER COLUMN foo_timestamp DROP DEFAULT,
750+
ALTER COLUMN foo_timestamp TYPE timestamp with time zone
751+
USING
752+
timestamp with time zone 'epoch' + foo_timestamp * interval '1 second',
753+
ALTER COLUMN foo_timestamp SET DEFAULT now();
754+
</programlisting>
755+
</para>
756+
744757
<para>
745758
To rename an existing column:
746759
<programlisting>

‎src/backend/commands/tablecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.198 2006/07/31 20:09:00 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.199 2006/08/03 20:57:06 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2000,7 +2000,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
20002000
ATSimplePermissions(rel, true);
20012001
ATSimpleRecursion(wqueue,rel,cmd,recurse);
20022002
/* No command-specific prep needed */
2003-
pass=AT_PASS_ADD_CONSTR;
2003+
pass=cmd->def ?AT_PASS_ADD_CONSTR :AT_PASS_DROP;
20042004
break;
20052005
caseAT_DropNotNull:/* ALTER COLUMN DROP NOT NULL */
20062006
ATSimplePermissions(rel, false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp