Skip to content

Commit d13f372

Browse files
committed
Fix pg_get_serial_sequence(), which could incorrectly return the name
of an index on a serial column, rather than the name of the associated sequence. Fallout from recent changes in dependency setup for serials. Per bug #2732 from Basil Evseenko.
1 parent 792d6ed commit d13f372

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ruleutils.c - Functions to convert stored expressions/querytrees
33
* back to source text
44
*
5-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.234 2006/10/04 00:29:59 momjian Exp $
5+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.235 2006/11/10 22:59:29 tgl Exp $
66
**********************************************************************/
77

88
#include "postgres.h"
@@ -1288,12 +1288,14 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
12881288
Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
12891289

12901290
/*
1291-
* We assume any auto dependency of a relation on a column must be
1292-
* what we are looking for.
1291+
* We assume any auto dependency of a sequence on a column must be
1292+
* what we are looking for. (We need the relkind test because indexes
1293+
* can also have auto dependencies on columns.)
12931294
*/
12941295
if (deprec->classid == RelationRelationId &&
12951296
deprec->objsubid == 0 &&
1296-
deprec->deptype == DEPENDENCY_AUTO)
1297+
deprec->deptype == DEPENDENCY_AUTO &&
1298+
get_rel_relkind(deprec->objid) == RELKIND_SEQUENCE)
12971299
{
12981300
sequenceId = deprec->objid;
12991301
break;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy