mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Identity columns
This is the SQL standard-conforming variant of PostgreSQL's serial columns. It fixes a few usability issues that serial columns have: - CREATE TABLE / LIKE copies default but refers to same sequence - cannot add/drop serialness with ALTER TABLE - dropping default does not drop sequence - need to grant separate privileges to sequence - other slight weirdnesses because serial is some kind of special macro Reviewed-by: Vitaly Burovoy <vitaly.burovoy@gmail.com>
This commit is contained in:
@ -2003,6 +2003,20 @@ _copyCurrentOfExpr(const CurrentOfExpr *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyNextValueExpr
|
||||
*/
|
||||
static NextValueExpr *
|
||||
_copyNextValueExpr(const NextValueExpr *from)
|
||||
{
|
||||
NextValueExpr *newnode = makeNode(NextValueExpr);
|
||||
|
||||
COPY_SCALAR_FIELD(seqid);
|
||||
COPY_SCALAR_FIELD(typeId);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyInferenceElem
|
||||
*/
|
||||
@ -2790,6 +2804,7 @@ _copyColumnDef(const ColumnDef *from)
|
||||
COPY_SCALAR_FIELD(storage);
|
||||
COPY_NODE_FIELD(raw_default);
|
||||
COPY_NODE_FIELD(cooked_default);
|
||||
COPY_SCALAR_FIELD(identity);
|
||||
COPY_NODE_FIELD(collClause);
|
||||
COPY_SCALAR_FIELD(collOid);
|
||||
COPY_NODE_FIELD(constraints);
|
||||
@ -2812,6 +2827,7 @@ _copyConstraint(const Constraint *from)
|
||||
COPY_SCALAR_FIELD(is_no_inherit);
|
||||
COPY_NODE_FIELD(raw_expr);
|
||||
COPY_STRING_FIELD(cooked_expr);
|
||||
COPY_SCALAR_FIELD(generated_when);
|
||||
COPY_NODE_FIELD(keys);
|
||||
COPY_NODE_FIELD(exclusions);
|
||||
COPY_NODE_FIELD(options);
|
||||
@ -2920,6 +2936,7 @@ _copyQuery(const Query *from)
|
||||
COPY_NODE_FIELD(rtable);
|
||||
COPY_NODE_FIELD(jointree);
|
||||
COPY_NODE_FIELD(targetList);
|
||||
COPY_SCALAR_FIELD(override);
|
||||
COPY_NODE_FIELD(onConflict);
|
||||
COPY_NODE_FIELD(returningList);
|
||||
COPY_NODE_FIELD(groupClause);
|
||||
@ -2963,6 +2980,7 @@ _copyInsertStmt(const InsertStmt *from)
|
||||
COPY_NODE_FIELD(onConflictClause);
|
||||
COPY_NODE_FIELD(returningList);
|
||||
COPY_NODE_FIELD(withClause);
|
||||
COPY_SCALAR_FIELD(override);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -3811,6 +3829,7 @@ _copyCreateSeqStmt(const CreateSeqStmt *from)
|
||||
COPY_NODE_FIELD(sequence);
|
||||
COPY_NODE_FIELD(options);
|
||||
COPY_SCALAR_FIELD(ownerId);
|
||||
COPY_SCALAR_FIELD(for_identity);
|
||||
COPY_SCALAR_FIELD(if_not_exists);
|
||||
|
||||
return newnode;
|
||||
@ -3823,6 +3842,7 @@ _copyAlterSeqStmt(const AlterSeqStmt *from)
|
||||
|
||||
COPY_NODE_FIELD(sequence);
|
||||
COPY_NODE_FIELD(options);
|
||||
COPY_SCALAR_FIELD(for_identity);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
|
||||
return newnode;
|
||||
@ -4927,6 +4947,9 @@ copyObjectImpl(const void *from)
|
||||
case T_CurrentOfExpr:
|
||||
retval = _copyCurrentOfExpr(from);
|
||||
break;
|
||||
case T_NextValueExpr:
|
||||
retval = _copyNextValueExpr(from);
|
||||
break;
|
||||
case T_InferenceElem:
|
||||
retval = _copyInferenceElem(from);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user