From 4343923de6c9147c33a50b673c352b39aebc0123 Mon Sep 17 00:00:00 2001 From: Kirill Gavrilov Date: Wed, 30 Oct 2024 09:33:07 +0000 Subject: [PATCH] resolve temp table name to original --- include/pg.h | 2 ++ include/util.h | 2 ++ src/proxy.cpp | 2 +- src/util.cpp | 10 ++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/pg.h b/include/pg.h index a346f50..adca71f 100644 --- a/include/pg.h +++ b/include/pg.h @@ -39,6 +39,7 @@ extern "C" { #include "storage/smgr.h" #include "utils/catcache.h" #include "utils/syscache.h" +#include "utils/lsyscache.h" #include "catalog/dependency.h" #include "catalog/pg_extension.h" @@ -99,6 +100,7 @@ extern "C" { #include "catalog/pg_namespace.h" #include "utils/catcache.h" #include "utils/syscache.h" +#include "utils/lsyscache.h" #include "catalog/heap.h" diff --git a/include/util.h b/include/util.h index 52c7e39..857d862 100644 --- a/include/util.h +++ b/include/util.h @@ -43,6 +43,8 @@ std::string make_yezzey_url(const std::string &prefix, int64_t modcounts, std::vector parseModcounts(const std::string &prefix, std::string name); + +std::string resolve_temp_relname(char *tempname); #endif EXTERNC void getYezzeyExternalStoragePathByCoords( diff --git a/src/proxy.cpp b/src/proxy.cpp index e5b9ac7..9b01ae1 100644 --- a/src/proxy.cpp +++ b/src/proxy.cpp @@ -207,7 +207,7 @@ EXTERNC SMGRFile yezzey_AORelOpenSegFile(Oid reloid, char *nspname, */ Assert(RecoveryInProgress()); } else { - yfd.relname = std::string(relname); + yfd.relname = resolve_temp_relname(relname); yfd.nspname = std::string(nspname); } } else { diff --git a/src/util.cpp b/src/util.cpp index 50070ed..78c7c8c 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -185,3 +185,13 @@ XLogRecPtr yezzeyGetXStorageInsertLsn(void) { return GetXLogWriteRecPtr(); } + +std::string resolve_temp_relname(char* tempname) { + std::string name(tempname); + if (strncmp(name.c_str(), "pg_temp_", 8) == 0) + { + int oid = atoi(name.substr(8, name.find('_', 8)).c_str()); + return std::string(get_rel_name(oid)); + } + return tempname; +}