return result;
}
+/*
+ * generateSerialExtraStmts
+ * Generate CREATE SEQUENCE and ALTER SEQUENCE ... OWNED BY statements
+ * to create the sequence for a serial or identity column.
+ *
+ * This includes determining the name the sequence will have. The caller
+ * can ask to get back the name components by passing non-null pointers
+ * for snamespace_p and sname_p.
+ */
static void
generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
Oid seqtypid, List *seqoptions, bool for_identity,
* problem, especially since few people would need two serial columns in
* one table.
*/
-
foreach(option, seqoptions)
{
DefElem *defel = lfirst_node(DefElem, option);
RangeVar *rv = makeRangeVarFromNameList(castNode(List, nameEl->arg));
snamespace = rv->schemaname;
+ if (!snamespace)
+ {
+ /* Given unqualified SEQUENCE NAME, select namespace */
+ if (cxt->rel)
+ snamespaceid = RelationGetNamespace(cxt->rel);
+ else
+ snamespaceid = RangeVarGetCreationNamespace(cxt->relation);
+ snamespace = get_namespace_name(snamespaceid);
+ }
sname = rv->relname;
+ /* Remove the SEQUENCE NAME item from seqoptions */
seqoptions = list_delete_ptr(seqoptions, nameEl);
}
else
* not our synthetic one.
*/
if (seqtypid)
- seqstmt->options = lcons(makeDefElem("as", (Node *) makeTypeNameFromOid(seqtypid, -1), -1),
+ seqstmt->options = lcons(makeDefElem("as",
+ (Node *) makeTypeNameFromOid(seqtypid, -1),
+ -1),
seqstmt->options);
/*