|
19 | 19 | * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
20 | 20 | * Portions Copyright (c) 1994, Regents of the University of California
|
21 | 21 | *
|
22 |
| - * $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.11 2008/03/25 22:42:43 tgl Exp $ |
| 22 | + * $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.12 2008/04/24 20:46:49 tgl Exp $ |
23 | 23 | *
|
24 | 24 | *-------------------------------------------------------------------------
|
25 | 25 | */
|
@@ -1718,49 +1718,30 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString)
|
1718 | 1718 | {
|
1719 | 1719 | ColumnDef *def = (ColumnDef *) cmd->def;
|
1720 | 1720 |
|
1721 |
| - Assert(IsA(cmd->def, ColumnDef)); |
1722 |
| - transformColumnDefinition(pstate, &cxt, |
1723 |
| - (ColumnDef *) cmd->def); |
| 1721 | + Assert(IsA(def, ColumnDef)); |
| 1722 | + transformColumnDefinition(pstate, &cxt, def); |
1724 | 1723 |
|
1725 | 1724 | /*
|
1726 | 1725 | * If the column has a non-null default, we can't skip
|
1727 | 1726 | * validation of foreign keys.
|
1728 | 1727 | */
|
1729 |
| - if (((ColumnDef *) cmd->def)->raw_default != NULL) |
| 1728 | + if (def->raw_default != NULL) |
1730 | 1729 | skipValidation = false;
|
1731 | 1730 |
|
1732 |
| - newcmds = lappend(newcmds, cmd); |
1733 |
| - |
1734 |
| - /* |
1735 |
| - * Convert an ADD COLUMN ... NOT NULL constraint to a |
1736 |
| - * separate command |
1737 |
| - */ |
1738 |
| - if (def->is_not_null) |
1739 |
| - { |
1740 |
| - /* Remove NOT NULL from AddColumn */ |
1741 |
| - def->is_not_null = false; |
1742 |
| - |
1743 |
| - /* Add as a separate AlterTableCmd */ |
1744 |
| - newcmd = makeNode(AlterTableCmd); |
1745 |
| - newcmd->subtype = AT_SetNotNull; |
1746 |
| - newcmd->name = pstrdup(def->colname); |
1747 |
| - newcmds = lappend(newcmds, newcmd); |
1748 |
| - } |
1749 |
| - |
1750 | 1731 | /*
|
1751 | 1732 | * All constraints are processed in other ways. Remove the
|
1752 | 1733 | * original list
|
1753 | 1734 | */
|
1754 | 1735 | def->constraints = NIL;
|
1755 | 1736 |
|
| 1737 | + newcmds = lappend(newcmds, cmd); |
1756 | 1738 | break;
|
1757 | 1739 | }
|
1758 | 1740 | case AT_AddConstraint:
|
1759 | 1741 |
|
1760 | 1742 | /*
|
1761 | 1743 | * The original AddConstraint cmd node doesn't go to newcmds
|
1762 | 1744 | */
|
1763 |
| - |
1764 | 1745 | if (IsA(cmd->def, Constraint))
|
1765 | 1746 | transformTableConstraint(pstate, &cxt,
|
1766 | 1747 | (Constraint *) cmd->def);
|
|
0 commit comments