Skip to content

Commit

Permalink
Disable pgstat for temp tables to avoid concurrency issues
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Chang <[email protected]>
  • Loading branch information
timchang514 committed Jan 8, 2024
1 parent 5c34265 commit 79916be
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/backend/utils/activity/pgstat_relation.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "utils/rel.h"
#include "utils/timestamp.h"

#include "parser/parser.h"
#include "utils/queryenvironment.h"


/* Record that's written to 2PC state file when pgstat state is persisted */
typedef struct TwoPhasePgStatRecord
Expand Down Expand Up @@ -168,6 +171,9 @@ pgstat_unlink_relation(Relation rel)
void
pgstat_create_relation(Relation rel)
{
/* Skip pg_stat */
if (sql_dialect == SQL_DIALECT_TSQL && rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
return;
pgstat_create_transactional(PGSTAT_KIND_RELATION,
rel->rd_rel->relisshared ? InvalidOid : MyDatabaseId,
RelationGetRelid(rel));
Expand All @@ -182,6 +188,8 @@ pgstat_drop_relation(Relation rel)
int nest_level = GetCurrentTransactionNestLevel();
PgStat_TableStatus *pgstat_info;

if (sql_dialect == SQL_DIALECT_TSQL && rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
return;
pgstat_drop_transactional(PGSTAT_KIND_RELATION,
rel->rd_rel->relisshared ? InvalidOid : MyDatabaseId,
RelationGetRelid(rel));
Expand Down

0 comments on commit 79916be

Please sign in to comment.