Skip to content

Commit 7a3977c

Browse files
committed
Fix a couple of oversights in new ALTER TABLE code that broke
ALTER SET STATISTICS for functional indexes.
1 parent c00b309 commit 7a3977c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/backend/commands/tablecmds.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.106 2004/05/08 00:34:49 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.107 2004/05/08 22:46:29 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -112,6 +112,7 @@ typedef struct AlteredTableInfo
112112
{
113113
/* Information saved before any work commences: */
114114
Oid relid; /* Relation to work on */
115+
char relkind; /* Its relkind */
115116
TupleDesc oldDesc; /* Pre-modification tuple descriptor */
116117
/* Information saved by Phase 1 for Phase 2: */
117118
List *subcmds[AT_NUM_PASSES]; /* Lists of AlterTableCmd */
@@ -2011,9 +2012,10 @@ ATRewriteCatalogs(List **wqueue)
20112012
{
20122013
AlteredTableInfo *tab = (AlteredTableInfo *) lfirst(ltab);
20132014

2014-
if (tab->subcmds[AT_PASS_ADD_COL] ||
2015-
tab->subcmds[AT_PASS_ALTER_TYPE] ||
2016-
tab->subcmds[AT_PASS_COL_ATTRS])
2015+
if (tab->relkind == RELKIND_RELATION &&
2016+
(tab->subcmds[AT_PASS_ADD_COL] ||
2017+
tab->subcmds[AT_PASS_ALTER_TYPE] ||
2018+
tab->subcmds[AT_PASS_COL_ATTRS]))
20172019
{
20182020
AlterTableCreateToastTable(tab->relid, true);
20192021
}
@@ -2192,7 +2194,7 @@ ATRewriteTables(List **wqueue)
21922194
*/
21932195
reindex_relation(tab->relid, false);
21942196
}
2195-
else
2197+
else if (tab->constraints != NIL)
21962198
{
21972199
/*
21982200
* Test the current data within the table against new constraints
@@ -2486,6 +2488,7 @@ ATGetQueueEntry(List **wqueue, Relation rel)
24862488
*/
24872489
tab = (AlteredTableInfo *) palloc0(sizeof(AlteredTableInfo));
24882490
tab->relid = relid;
2491+
tab->relkind = rel->rd_rel->relkind;
24892492
tab->oldDesc = CreateTupleDescCopy(RelationGetDescr(rel));
24902493

24912494
*wqueue = lappend(*wqueue, tab);

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