heap_create_init_fork(rel);
heap_relid = RelationGetRelid(rel);
- toast_relid = rel->rd_rel->reltoastrelid;
/*
* The same for the toast table, if any.
*/
+ toast_relid = rel->rd_rel->reltoastrelid;
if (OidIsValid(toast_relid))
{
- rel = relation_open(toast_relid, AccessExclusiveLock);
- RelationSetNewRelfilenode(rel, rel->rd_rel->relpersistence,
+ Relation toastrel = relation_open(toast_relid,
+ AccessExclusiveLock);
+
+ RelationSetNewRelfilenode(toastrel,
+ toastrel->rd_rel->relpersistence,
RecentXmin, minmulti);
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
- heap_create_init_fork(rel);
- heap_close(rel, NoLock);
+ if (toastrel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
+ heap_create_init_fork(toastrel);
+ heap_close(toastrel, NoLock);
}
/*
$$ language plpgsql;
-- test effects of TRUNCATE on n_live_tup/n_dead_tup counters
CREATE TABLE trunc_stats_test(id serial);
-CREATE TABLE trunc_stats_test1(id serial);
+CREATE TABLE trunc_stats_test1(id serial, stuff text);
CREATE TABLE trunc_stats_test2(id serial);
-CREATE TABLE trunc_stats_test3(id serial);
+CREATE TABLE trunc_stats_test3(id serial, stuff text);
CREATE TABLE trunc_stats_test4(id serial);
-- check that n_live_tup is reset to 0 after truncate
INSERT INTO trunc_stats_test DEFAULT VALUES;
-- test effects of TRUNCATE on n_live_tup/n_dead_tup counters
CREATE TABLE trunc_stats_test(id serial);
-CREATE TABLE trunc_stats_test1(id serial);
+CREATE TABLE trunc_stats_test1(id serial, stuff text);
CREATE TABLE trunc_stats_test2(id serial);
-CREATE TABLE trunc_stats_test3(id serial);
+CREATE TABLE trunc_stats_test3(id serial, stuff text);
CREATE TABLE trunc_stats_test4(id serial);
-- check that n_live_tup is reset to 0 after truncate