Skip to content

Commit 5e07d3d

Browse files
committed
pgstat: fix small bug in pgstat_drop_relation().
Just after committing 5891c7a, a test running with debug_discard_caches=1 failed locally... pgstat_drop_relation() neither checked pgstat_should_count_relation() nor called pgstat_prep_relation_pending(). With debug_discard_caches=1 rel->pgstat_info wasn't set up, leading pg_stat_get_xact_tuples_inserted() spuriously still returning > 0 while in the transaction dropping the table.
1 parent 81ae9e6 commit 5e07d3d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/backend/utils/activity/pgstat_relation.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,21 @@ void
180180
pgstat_drop_relation(Relation rel)
181181
{
182182
int nest_level = GetCurrentTransactionNestLevel();
183-
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
183+
PgStat_TableStatus *pgstat_info;
184184

185185
pgstat_drop_transactional(PGSTAT_KIND_RELATION,
186186
rel->rd_rel->relisshared ? InvalidOid : MyDatabaseId,
187187
RelationGetRelid(rel));
188188

189+
if (!pgstat_should_count_relation(rel))
190+
return;
191+
189192
/*
190193
* Transactionally set counters to 0. That ensures that accesses to
191194
* pg_stat_xact_all_tables inside the transaction show 0.
192195
*/
193-
if (pgstat_info &&
194-
pgstat_info->trans != NULL &&
196+
pgstat_info = rel->pgstat_info;
197+
if (pgstat_info->trans &&
195198
pgstat_info->trans->nest_level == nest_level)
196199
{
197200
save_truncdrop_counters(pgstat_info->trans, true);

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