aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-09-15 14:04:51 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-09-15 14:21:30 -0400
commitf830183492d3a3b74cbd33645db19b8b5b5a2622 (patch)
tree8b3514a2fa3c721d969d21d786b374129d6736ec /src/backend/utils
parenta2a61f633e36445d7a15baad22d4d1db102e4a7e (diff)
downloadpostgresql-f830183492d3a3b74cbd33645db19b8b5b5a2622.tar.gz
postgresql-f830183492d3a3b74cbd33645db19b8b5b5a2622.zip
Apply pg_get_serial_sequence() to identity column sequences as well
Bug: #14813
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/ruleutils.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 37d4ef043d7..eb01f354634 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -2322,7 +2322,7 @@ pg_get_userbyid(PG_FUNCTION_ARGS)
/*
* pg_get_serial_sequence
- * Get the name of the sequence used by a serial column,
+ * Get the name of the sequence used by an identity or serial column,
* formatted suitably for passing to setval, nextval or currval.
* First parameter is not treated as double-quoted, second parameter
* is --- see documentation for reason.
@@ -2380,13 +2380,14 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
/*
- * We assume any auto dependency of a sequence on a column must be
- * what we are looking for. (We need the relkind test because indexes
- * can also have auto dependencies on columns.)
+ * Look for an auto dependency (serial column) or internal dependency
+ * (identity column) of a sequence on a column. (We need the relkind
+ * test because indexes can also have auto dependencies on columns.)
*/
if (deprec->classid == RelationRelationId &&
deprec->objsubid == 0 &&
- deprec->deptype == DEPENDENCY_AUTO &&
+ (deprec->deptype == DEPENDENCY_AUTO ||
+ deprec->deptype == DEPENDENCY_INTERNAL) &&
get_rel_relkind(deprec->objid) == RELKIND_SEQUENCE)
{
sequenceId = deprec->objid;