summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorTom Lane2009-10-06 00:55:26 +0000
committerTom Lane2009-10-06 00:55:26 +0000
commite537ef80262ede8bb0b721129a1709681e0271a6 (patch)
treeb06f81c19c3193d72dba968ee33324d951897d64 /src/backend/commands
parent7d3b3eedd8d49a342cb533cc31bbe5bcf1ce03be (diff)
Change CREATE TABLE so that column default expressions coming from differentHEADmaster
inheritance parent tables are compared using equal(), instead of doing strcmp() on the nodeToString representation. The old implementation was always a tad cheesy, and it finally fails completely as of 8.4, now that the node tree might contain syntax location information. equal() knows it's supposed to ignore those fields, but strcmp() hardly can. Per recent report from Scott Ribe.
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/tablecmds.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index d3b89b12d7..03bbbb5bf5 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -493,7 +493,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
cooked->contype = CONSTR_DEFAULT;
cooked->name = NULL;
cooked->attnum = attnum;
- cooked->expr = stringToNode(colDef->cooked_default);
+ cooked->expr = colDef->cooked_default;
cooked->is_local = true; /* not used for defaults */
cooked->inhcount = 0; /* ditto */
cookedDefaults = lappend(cookedDefaults, cooked);
@@ -1168,8 +1168,8 @@ MergeAttributes(List *schema, List *supers, bool istemp,
List *constraints = NIL;
int parentsWithOids = 0;
bool have_bogus_defaults = false;
- char *bogus_marker = "Bogus!"; /* marks conflicting defaults */
int child_attno;
+ static Node bogus_marker = { 0 }; /* marks conflicting defaults */
/*
* Check for and reject tables with too many columns. We perform this
@@ -1353,7 +1353,7 @@ MergeAttributes(List *schema, List *supers, bool istemp,
*/
if (attribute->atthasdef)
{
- char *this_default = NULL;
+ Node *this_default = NULL;
AttrDefault *attrdef;
int i;
@@ -1364,7 +1364,7 @@ MergeAttributes(List *schema, List *supers, bool istemp,
{
if (attrdef[i].adnum == parent_attno)
{
- this_default = attrdef[i].adbin;
+ this_default = stringToNode(attrdef[i].adbin);
break;
}
}
@@ -1382,10 +1382,10 @@ MergeAttributes(List *schema, List *supers, bool istemp,
*/
Assert(def->raw_default == NULL);
if (def->cooked_default == NULL)
- def->cooked_default = pstrdup(this_default);
- else if (strcmp(def->cooked_default, this_default) != 0)
+ def->cooked_default = this_default;
+ else if (!equal(def->cooked_default, this_default))
{
- def->cooked_default = bogus_marker;
+ def->cooked_default = &bogus_marker;
have_bogus_defaults = true;
}
}
@@ -1524,7 +1524,7 @@ MergeAttributes(List *schema, List *supers, bool istemp,
{
ColumnDef *def = lfirst(entry);
- if (def->cooked_default == bogus_marker)
+ if (def->cooked_default == &bogus_marker)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_DEFINITION),
errmsg("column \"%s\" inherits conflicting default values",