|
|
@ -350,7 +350,7 @@ static void truncate_check_perms(Oid relid, Form_pg_class reltuple); |
|
|
|
static void truncate_check_activity(Relation rel); |
|
|
|
static void truncate_check_activity(Relation rel); |
|
|
|
static void RangeVarCallbackForTruncate(const RangeVar *relation, |
|
|
|
static void RangeVarCallbackForTruncate(const RangeVar *relation, |
|
|
|
Oid relId, Oid oldRelId, void *arg); |
|
|
|
Oid relId, Oid oldRelId, void *arg); |
|
|
|
static List *MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
static List *MergeAttributes(List *columns, const List *supers, char relpersistence, |
|
|
|
bool is_partition, List **supconstr, |
|
|
|
bool is_partition, List **supconstr, |
|
|
|
List **supnotnulls); |
|
|
|
List **supnotnulls); |
|
|
|
static List *MergeCheckConstraint(List *constraints, const char *name, Node *expr); |
|
|
|
static List *MergeCheckConstraint(List *constraints, const char *name, Node *expr); |
|
|
@ -361,7 +361,7 @@ static void StoreCatalogInheritance(Oid relationId, List *supers, |
|
|
|
static void StoreCatalogInheritance1(Oid relationId, Oid parentOid, |
|
|
|
static void StoreCatalogInheritance1(Oid relationId, Oid parentOid, |
|
|
|
int32 seqNumber, Relation inhRelation, |
|
|
|
int32 seqNumber, Relation inhRelation, |
|
|
|
bool child_is_partition); |
|
|
|
bool child_is_partition); |
|
|
|
static int findAttrByName(const char *attributeName, List *schema); |
|
|
|
static int findAttrByName(const char *attributeName, const List *columns); |
|
|
|
static void AlterIndexNamespaces(Relation classRel, Relation rel, |
|
|
|
static void AlterIndexNamespaces(Relation classRel, Relation rel, |
|
|
|
Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved); |
|
|
|
Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved); |
|
|
|
static void AlterSeqNamespaces(Relation classRel, Relation rel, |
|
|
|
static void AlterSeqNamespaces(Relation classRel, Relation rel, |
|
|
@ -2307,7 +2307,7 @@ storage_name(char c) |
|
|
|
* Returns new schema given initial schema and superclasses. |
|
|
|
* Returns new schema given initial schema and superclasses. |
|
|
|
* |
|
|
|
* |
|
|
|
* Input arguments: |
|
|
|
* Input arguments: |
|
|
|
* 'schema' is the column/attribute definition for the table. (It's a list |
|
|
|
* 'columns' is the column/attribute definition for the table. (It's a list |
|
|
|
* of ColumnDef's.) It is destructively changed. |
|
|
|
* of ColumnDef's.) It is destructively changed. |
|
|
|
* 'supers' is a list of OIDs of parent relations, already locked by caller. |
|
|
|
* 'supers' is a list of OIDs of parent relations, already locked by caller. |
|
|
|
* 'relpersistence' is the persistence type of the table. |
|
|
|
* 'relpersistence' is the persistence type of the table. |
|
|
@ -2369,17 +2369,17 @@ storage_name(char c) |
|
|
|
*---------- |
|
|
|
*---------- |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static List * |
|
|
|
static List * |
|
|
|
MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
MergeAttributes(List *columns, const List *supers, char relpersistence, |
|
|
|
bool is_partition, List **supconstr, List **supnotnulls) |
|
|
|
bool is_partition, List **supconstr, List **supnotnulls) |
|
|
|
{ |
|
|
|
{ |
|
|
|
List *inhSchema = NIL; |
|
|
|
List *inh_columns = NIL; |
|
|
|
List *constraints = NIL; |
|
|
|
List *constraints = NIL; |
|
|
|
List *nnconstraints = NIL; |
|
|
|
List *nnconstraints = NIL; |
|
|
|
bool have_bogus_defaults = false; |
|
|
|
bool have_bogus_defaults = false; |
|
|
|
int child_attno; |
|
|
|
int child_attno; |
|
|
|
static Node bogus_marker = {0}; /* marks conflicting defaults */ |
|
|
|
static Node bogus_marker = {0}; /* marks conflicting defaults */ |
|
|
|
List *saved_schema = NIL; |
|
|
|
List *saved_columns = NIL; |
|
|
|
ListCell *entry; |
|
|
|
ListCell *lc; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Check for and reject tables with too many columns. We perform this |
|
|
|
* Check for and reject tables with too many columns. We perform this |
|
|
@ -2392,7 +2392,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
* Note that we also need to check that we do not exceed this figure after |
|
|
|
* Note that we also need to check that we do not exceed this figure after |
|
|
|
* including columns from inherited relations. |
|
|
|
* including columns from inherited relations. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (list_length(schema) > MaxHeapAttributeNumber) |
|
|
|
if (list_length(columns) > MaxHeapAttributeNumber) |
|
|
|
ereport(ERROR, |
|
|
|
ereport(ERROR, |
|
|
|
(errcode(ERRCODE_TOO_MANY_COLUMNS), |
|
|
|
(errcode(ERRCODE_TOO_MANY_COLUMNS), |
|
|
|
errmsg("tables can have at most %d columns", |
|
|
|
errmsg("tables can have at most %d columns", |
|
|
@ -2406,15 +2406,15 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
* sense to assume such conflicts are errors. |
|
|
|
* sense to assume such conflicts are errors. |
|
|
|
* |
|
|
|
* |
|
|
|
* We don't use foreach() here because we have two nested loops over the |
|
|
|
* We don't use foreach() here because we have two nested loops over the |
|
|
|
* schema list, with possible element deletions in the inner one. If we |
|
|
|
* columns list, with possible element deletions in the inner one. If we |
|
|
|
* used foreach_delete_current() it could only fix up the state of one of |
|
|
|
* used foreach_delete_current() it could only fix up the state of one of |
|
|
|
* the loops, so it seems cleaner to use looping over list indexes for |
|
|
|
* the loops, so it seems cleaner to use looping over list indexes for |
|
|
|
* both loops. Note that any deletion will happen beyond where the outer |
|
|
|
* both loops. Note that any deletion will happen beyond where the outer |
|
|
|
* loop is, so its index never needs adjustment. |
|
|
|
* loop is, so its index never needs adjustment. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
for (int coldefpos = 0; coldefpos < list_length(schema); coldefpos++) |
|
|
|
for (int coldefpos = 0; coldefpos < list_length(columns); coldefpos++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ColumnDef *coldef = list_nth_node(ColumnDef, schema, coldefpos); |
|
|
|
ColumnDef *coldef = list_nth_node(ColumnDef, columns, coldefpos); |
|
|
|
|
|
|
|
|
|
|
|
if (!is_partition && coldef->typeName == NULL) |
|
|
|
if (!is_partition && coldef->typeName == NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2431,9 +2431,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* restpos scans all entries beyond coldef; incr is in loop body */ |
|
|
|
/* restpos scans all entries beyond coldef; incr is in loop body */ |
|
|
|
for (int restpos = coldefpos + 1; restpos < list_length(schema);) |
|
|
|
for (int restpos = coldefpos + 1; restpos < list_length(columns);) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ColumnDef *restdef = list_nth_node(ColumnDef, schema, restpos); |
|
|
|
ColumnDef *restdef = list_nth_node(ColumnDef, columns, restpos); |
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(coldef->colname, restdef->colname) == 0) |
|
|
|
if (strcmp(coldef->colname, restdef->colname) == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2447,7 +2447,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
coldef->cooked_default = restdef->cooked_default; |
|
|
|
coldef->cooked_default = restdef->cooked_default; |
|
|
|
coldef->constraints = restdef->constraints; |
|
|
|
coldef->constraints = restdef->constraints; |
|
|
|
coldef->is_from_type = false; |
|
|
|
coldef->is_from_type = false; |
|
|
|
schema = list_delete_nth_cell(schema, restpos); |
|
|
|
columns = list_delete_nth_cell(columns, restpos); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
ereport(ERROR, |
|
|
|
ereport(ERROR, |
|
|
@ -2467,18 +2467,18 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (is_partition) |
|
|
|
if (is_partition) |
|
|
|
{ |
|
|
|
{ |
|
|
|
saved_schema = schema; |
|
|
|
saved_columns = columns; |
|
|
|
schema = NIL; |
|
|
|
columns = NIL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Scan the parents left-to-right, and merge their attributes to form a |
|
|
|
* Scan the parents left-to-right, and merge their attributes to form a |
|
|
|
* list of inherited attributes (inhSchema). |
|
|
|
* list of inherited columns (inh_columns). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
child_attno = 0; |
|
|
|
child_attno = 0; |
|
|
|
foreach(entry, supers) |
|
|
|
foreach(lc, supers) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Oid parent = lfirst_oid(entry); |
|
|
|
Oid parent = lfirst_oid(lc); |
|
|
|
Relation relation; |
|
|
|
Relation relation; |
|
|
|
TupleDesc tupleDesc; |
|
|
|
TupleDesc tupleDesc; |
|
|
|
TupleConstr *constr; |
|
|
|
TupleConstr *constr; |
|
|
@ -2486,7 +2486,6 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
List *inherited_defaults; |
|
|
|
List *inherited_defaults; |
|
|
|
List *cols_with_defaults; |
|
|
|
List *cols_with_defaults; |
|
|
|
List *nnconstrs; |
|
|
|
List *nnconstrs; |
|
|
|
AttrNumber parent_attno; |
|
|
|
|
|
|
|
ListCell *lc1; |
|
|
|
ListCell *lc1; |
|
|
|
ListCell *lc2; |
|
|
|
ListCell *lc2; |
|
|
|
Bitmapset *pkattrs; |
|
|
|
Bitmapset *pkattrs; |
|
|
@ -2507,8 +2506,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
* We do not allow partitioned tables and partitions to participate in |
|
|
|
* We do not allow partitioned tables and partitions to participate in |
|
|
|
* regular inheritance. |
|
|
|
* regular inheritance. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE && |
|
|
|
if (relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE && !is_partition) |
|
|
|
!is_partition) |
|
|
|
|
|
|
|
ereport(ERROR, |
|
|
|
ereport(ERROR, |
|
|
|
(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
|
|
|
(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
|
|
|
errmsg("cannot inherit from partitioned table \"%s\"", |
|
|
|
errmsg("cannot inherit from partitioned table \"%s\"", |
|
|
@ -2593,7 +2591,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
nncols = bms_add_member(nncols, |
|
|
|
nncols = bms_add_member(nncols, |
|
|
|
((CookedConstraint *) lfirst(lc1))->attnum); |
|
|
|
((CookedConstraint *) lfirst(lc1))->attnum); |
|
|
|
|
|
|
|
|
|
|
|
for (parent_attno = 1; parent_attno <= tupleDesc->natts; |
|
|
|
for (AttrNumber parent_attno = 1; parent_attno <= tupleDesc->natts; |
|
|
|
parent_attno++) |
|
|
|
parent_attno++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Form_pg_attribute attribute = TupleDescAttr(tupleDesc, |
|
|
|
Form_pg_attribute attribute = TupleDescAttr(tupleDesc, |
|
|
@ -2611,7 +2609,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Does it conflict with some previously inherited column? |
|
|
|
* Does it conflict with some previously inherited column? |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
exist_attno = findAttrByName(attributeName, inhSchema); |
|
|
|
exist_attno = findAttrByName(attributeName, inh_columns); |
|
|
|
if (exist_attno > 0) |
|
|
|
if (exist_attno > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Oid defTypeId; |
|
|
|
Oid defTypeId; |
|
|
@ -2624,7 +2622,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
ereport(NOTICE, |
|
|
|
ereport(NOTICE, |
|
|
|
(errmsg("merging multiple inherited definitions of column \"%s\"", |
|
|
|
(errmsg("merging multiple inherited definitions of column \"%s\"", |
|
|
|
attributeName))); |
|
|
|
attributeName))); |
|
|
|
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); |
|
|
|
def = (ColumnDef *) list_nth(inh_columns, exist_attno - 1); |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Must have the same type and typmod |
|
|
|
* Must have the same type and typmod |
|
|
@ -2761,7 +2759,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
if (CompressionMethodIsValid(attribute->attcompression)) |
|
|
|
if (CompressionMethodIsValid(attribute->attcompression)) |
|
|
|
def->compression = |
|
|
|
def->compression = |
|
|
|
pstrdup(GetCompressionMethodName(attribute->attcompression)); |
|
|
|
pstrdup(GetCompressionMethodName(attribute->attcompression)); |
|
|
|
inhSchema = lappend(inhSchema, def); |
|
|
|
inh_columns = lappend(inh_columns, def); |
|
|
|
newattmap->attnums[parent_attno - 1] = ++child_attno; |
|
|
|
newattmap->attnums[parent_attno - 1] = ++child_attno; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -2862,7 +2860,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
* If we already had a default from some prior parent, check to |
|
|
|
* If we already had a default from some prior parent, check to |
|
|
|
* see if they are the same. If so, no problem; if not, mark the |
|
|
|
* see if they are the same. If so, no problem; if not, mark the |
|
|
|
* column as having a bogus default. Below, we will complain if |
|
|
|
* column as having a bogus default. Below, we will complain if |
|
|
|
* the bogus default isn't overridden by the child schema. |
|
|
|
* the bogus default isn't overridden by the child columns. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Assert(def->raw_default == NULL); |
|
|
|
Assert(def->raw_default == NULL); |
|
|
|
if (def->cooked_default == NULL) |
|
|
|
if (def->cooked_default == NULL) |
|
|
@ -2882,9 +2880,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
if (constr && constr->num_check > 0) |
|
|
|
if (constr && constr->num_check > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ConstrCheck *check = constr->check; |
|
|
|
ConstrCheck *check = constr->check; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < constr->num_check; i++) |
|
|
|
for (int i = 0; i < constr->num_check; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *name = check[i].ccname; |
|
|
|
char *name = check[i].ccname; |
|
|
|
Node *expr; |
|
|
|
Node *expr; |
|
|
@ -2945,27 +2942,27 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* If we had no inherited attributes, the result schema is just the |
|
|
|
* If we had no inherited attributes, the result columns are just the |
|
|
|
* explicitly declared columns. Otherwise, we need to merge the declared |
|
|
|
* explicitly declared columns. Otherwise, we need to merge the declared |
|
|
|
* columns into the inherited schema list. Although, we never have any |
|
|
|
* columns into the inherited column list. Although, we never have any |
|
|
|
* explicitly declared columns if the table is a partition. |
|
|
|
* explicitly declared columns if the table is a partition. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (inhSchema != NIL) |
|
|
|
if (inh_columns != NIL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int schema_attno = 0; |
|
|
|
int newcol_attno = 0; |
|
|
|
|
|
|
|
|
|
|
|
foreach(entry, schema) |
|
|
|
foreach(lc, columns) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ColumnDef *newdef = lfirst(entry); |
|
|
|
ColumnDef *newdef = lfirst(lc); |
|
|
|
char *attributeName = newdef->colname; |
|
|
|
char *attributeName = newdef->colname; |
|
|
|
int exist_attno; |
|
|
|
int exist_attno; |
|
|
|
|
|
|
|
|
|
|
|
schema_attno++; |
|
|
|
newcol_attno++; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Does it conflict with some previously inherited column? |
|
|
|
* Does it conflict with some previously inherited column? |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
exist_attno = findAttrByName(attributeName, inhSchema); |
|
|
|
exist_attno = findAttrByName(attributeName, inh_columns); |
|
|
|
if (exist_attno > 0) |
|
|
|
if (exist_attno > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ColumnDef *def; |
|
|
|
ColumnDef *def; |
|
|
@ -2985,7 +2982,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Yes, try to merge the two column definitions. |
|
|
|
* Yes, try to merge the two column definitions. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (exist_attno == schema_attno) |
|
|
|
if (exist_attno == newcol_attno) |
|
|
|
ereport(NOTICE, |
|
|
|
ereport(NOTICE, |
|
|
|
(errmsg("merging column \"%s\" with inherited definition", |
|
|
|
(errmsg("merging column \"%s\" with inherited definition", |
|
|
|
attributeName))); |
|
|
|
attributeName))); |
|
|
@ -2993,7 +2990,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
ereport(NOTICE, |
|
|
|
ereport(NOTICE, |
|
|
|
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName), |
|
|
|
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName), |
|
|
|
errdetail("User-specified column moved to the position of the inherited column."))); |
|
|
|
errdetail("User-specified column moved to the position of the inherited column."))); |
|
|
|
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); |
|
|
|
def = (ColumnDef *) list_nth(inh_columns, exist_attno - 1); |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Must have the same type and typmod |
|
|
|
* Must have the same type and typmod |
|
|
@ -3118,19 +3115,19 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* No, attach new column to result schema |
|
|
|
* No, attach new column to result columns |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
inhSchema = lappend(inhSchema, newdef); |
|
|
|
inh_columns = lappend(inh_columns, newdef); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
schema = inhSchema; |
|
|
|
columns = inh_columns; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Check that we haven't exceeded the legal # of columns after merging |
|
|
|
* Check that we haven't exceeded the legal # of columns after merging |
|
|
|
* in inherited columns. |
|
|
|
* in inherited columns. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (list_length(schema) > MaxHeapAttributeNumber) |
|
|
|
if (list_length(columns) > MaxHeapAttributeNumber) |
|
|
|
ereport(ERROR, |
|
|
|
ereport(ERROR, |
|
|
|
(errcode(ERRCODE_TOO_MANY_COLUMNS), |
|
|
|
(errcode(ERRCODE_TOO_MANY_COLUMNS), |
|
|
|
errmsg("tables can have at most %d columns", |
|
|
|
errmsg("tables can have at most %d columns", |
|
|
@ -3144,13 +3141,13 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (is_partition) |
|
|
|
if (is_partition) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach(entry, saved_schema) |
|
|
|
foreach(lc, saved_columns) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ColumnDef *restdef = lfirst(entry); |
|
|
|
ColumnDef *restdef = lfirst(lc); |
|
|
|
bool found = false; |
|
|
|
bool found = false; |
|
|
|
ListCell *l; |
|
|
|
ListCell *l; |
|
|
|
|
|
|
|
|
|
|
|
foreach(l, schema) |
|
|
|
foreach(l, columns) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ColumnDef *coldef = lfirst(l); |
|
|
|
ColumnDef *coldef = lfirst(l); |
|
|
|
|
|
|
|
|
|
|
@ -3222,9 +3219,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (have_bogus_defaults) |
|
|
|
if (have_bogus_defaults) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach(entry, schema) |
|
|
|
foreach(lc, columns) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ColumnDef *def = lfirst(entry); |
|
|
|
ColumnDef *def = lfirst(lc); |
|
|
|
|
|
|
|
|
|
|
|
if (def->cooked_default == &bogus_marker) |
|
|
|
if (def->cooked_default == &bogus_marker) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -3247,7 +3244,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, |
|
|
|
*supconstr = constraints; |
|
|
|
*supconstr = constraints; |
|
|
|
*supnotnulls = nnconstraints; |
|
|
|
*supnotnulls = nnconstraints; |
|
|
|
|
|
|
|
|
|
|
|
return schema; |
|
|
|
return columns; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3402,22 +3399,20 @@ StoreCatalogInheritance1(Oid relationId, Oid parentOid, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Look for an existing schema entry with the given name. |
|
|
|
* Look for an existing column entry with the given name. |
|
|
|
* |
|
|
|
* |
|
|
|
* Returns the index (starting with 1) if attribute already exists in schema, |
|
|
|
* Returns the index (starting with 1) if attribute already exists in columns, |
|
|
|
* 0 if it doesn't. |
|
|
|
* 0 if it doesn't. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static int |
|
|
|
static int |
|
|
|
findAttrByName(const char *attributeName, List *schema) |
|
|
|
findAttrByName(const char *attributeName, const List *columns) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ListCell *s; |
|
|
|
ListCell *lc; |
|
|
|
int i = 1; |
|
|
|
int i = 1; |
|
|
|
|
|
|
|
|
|
|
|
foreach(s, schema) |
|
|
|
foreach(lc, columns) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ColumnDef *def = lfirst(s); |
|
|
|
if (strcmp(attributeName, lfirst_node(ColumnDef, lc)->colname) == 0) |
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(attributeName, def->colname) == 0) |
|
|
|
|
|
|
|
return i; |
|
|
|
return i; |
|
|
|
|
|
|
|
|
|
|
|
i++; |
|
|
|
i++; |
|
|
|