Skip to content

Commit

Permalink
resolve temp table name to original
Browse files Browse the repository at this point in the history
  • Loading branch information
diPhantxm authored and reshke committed Oct 30, 2024
1 parent dac0f03 commit 4343923
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ std::string make_yezzey_url(const std::string &prefix, int64_t modcounts,

std::vector<int64_t> parseModcounts(const std::string &prefix,
std::string name);

std::string resolve_temp_relname(char *tempname);
#endif

EXTERNC void getYezzeyExternalStoragePathByCoords(
Expand Down
2 changes: 1 addition & 1 deletion src/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 4343923

Please sign in to comment.