|
|
|
@ -122,6 +122,24 @@ DefineSequence(CreateSeqStmt *seq) |
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
|
|
|
|
errmsg("unlogged sequences are not supported"))); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If if_not_exists was given and a relation with the same name already |
|
|
|
|
* exists, bail out. (Note: we needn't check this when not if_not_exists, |
|
|
|
|
* because DefineRelation will complain anyway.) |
|
|
|
|
*/ |
|
|
|
|
if (seq->if_not_exists) |
|
|
|
|
{ |
|
|
|
|
RangeVarGetAndCheckCreationNamespace(seq->sequence, NoLock, &seqoid); |
|
|
|
|
if (OidIsValid(seqoid)) |
|
|
|
|
{ |
|
|
|
|
ereport(NOTICE, |
|
|
|
|
(errcode(ERRCODE_DUPLICATE_TABLE), |
|
|
|
|
errmsg("relation \"%s\" already exists, skipping", |
|
|
|
|
seq->sequence->relname))); |
|
|
|
|
return InvalidOid; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Check and set all option values */ |
|
|
|
|
init_params(seq->options, true, &new, &owned_by); |
|
|
|
|
|
|
|
|
@ -210,7 +228,7 @@ DefineSequence(CreateSeqStmt *seq) |
|
|
|
|
stmt->options = NIL; |
|
|
|
|
stmt->oncommit = ONCOMMIT_NOOP; |
|
|
|
|
stmt->tablespacename = NULL; |
|
|
|
|
stmt->if_not_exists = false; |
|
|
|
|
stmt->if_not_exists = seq->if_not_exists; |
|
|
|
|
|
|
|
|
|
seqoid = DefineRelation(stmt, RELKIND_SEQUENCE, seq->ownerId); |
|
|
|
|
Assert(seqoid != InvalidOid); |
|
|
|
|