From 5a69710c6dd38b58e2860a1f5b89edb5f4611e77 Mon Sep 17 00:00:00 2001 From: Tim Chang Date: Thu, 25 Jan 2024 16:20:47 -0500 Subject: [PATCH] Add toasts to ENR for temp tables (#298) Fixes an issue with orphaned temp toast table entries. Adding toasts to ENR for temp tables. This was originally introduced as part of #295 Signed-off-by: Tim Chang --- src/backend/catalog/pg_depend.c | 3 ++- src/backend/catalog/toasting.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c index 89bbb5c9e48..9afaaf4e3b0 100644 --- a/src/backend/catalog/pg_depend.c +++ b/src/backend/catalog/pg_depend.c @@ -326,7 +326,8 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId, ((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION) continue; - CatalogTupleDelete(depRel, &tup->t_self); + if (!ENRdropTuple(depRel, tup)) + CatalogTupleDelete(depRel, &tup->t_self); count++; } diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c index cf419a6962c..d726088c8ec 100644 --- a/src/backend/catalog/toasting.c +++ b/src/backend/catalog/toasting.c @@ -200,6 +200,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, */ if (sql_dialect == SQL_DIALECT_TSQL && RelationIsBBFTableVariable(rel)) pg_toast_prefix = "@pg_toast"; + else if (sql_dialect == SQL_DIALECT_TSQL && rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP && get_ENR_withoid(currentQueryEnv, rel->rd_id, ENR_TSQL_TEMP)) + pg_toast_prefix = "#pg_toast"; snprintf(toast_relname, sizeof(toast_relname), "%s_%u", pg_toast_prefix, relOid);