Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit31effd1

Browse files
committed
The attached patch changes ALTER TABLE OWNER to also change the
ownership of any toast tables that belong to the table that is beingoperated upon (as suggested by Tom Lane).Neil Conway
1 parent01e3226 commit31effd1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

‎src/backend/commands/command.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.160 2002/03/06 19:58:26 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.161 2002/03/14 22:44:50 momjian Exp $
1212
*
1313
* NOTES
1414
* The PerformAddAttribute() code, like most of the relation
@@ -1619,11 +1619,13 @@ AlterTableOwnerId(Oid relationOid, int32 newOwnerSysId)
16191619
CatalogCloseIndices(Num_pg_class_indices,idescs);
16201620

16211621
/*
1622-
* If we are operating on a table, also change the ownership
1623-
* of all of its indexes.
1622+
* If we are operating on a table, also change the ownership of any
1623+
* indexes that belong to the table, as well as the table's toast
1624+
* table (if it has one)
16241625
*/
16251626
if (tuple_class->relkind==RELKIND_RELATION)
16261627
{
1628+
/* Search for indexes belonging to this table */
16271629
Relationtarget_rel;
16281630
List*index_oid_list,*i;
16291631

@@ -1639,6 +1641,12 @@ AlterTableOwnerId(Oid relationOid, int32 newOwnerSysId)
16391641
}
16401642

16411643
freeList(index_oid_list);
1644+
1645+
/* If it has a toast table, recurse to change its ownership */
1646+
if (tuple_class->reltoastrelid!=InvalidOid)
1647+
{
1648+
AlterTableOwnerId(tuple_class->reltoastrelid,newOwnerSysId);
1649+
}
16421650
}
16431651

16441652
heap_freetuple(tuple);
@@ -1654,10 +1662,11 @@ CheckTupleType(Form_pg_class tuple_class)
16541662
caseRELKIND_INDEX:
16551663
caseRELKIND_VIEW:
16561664
caseRELKIND_SEQUENCE:
1665+
caseRELKIND_TOASTVALUE:
16571666
/* ok to change owner */
16581667
break;
16591668
default:
1660-
elog(ERROR,"ALTER TABLE: relation \"%s\" is not a table, index, view, or sequence",
1669+
elog(ERROR,"ALTER TABLE: relation \"%s\" is not a table,TOAST table,index, view, or sequence",
16611670
NameStr(tuple_class->relname));
16621671
}
16631672
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp