From 3b753f1bc7343db859db1fc9af3f03d383622a68 Mon Sep 17 00:00:00 2001 From: Andrew Pogrebnoy Date: Tue, 19 Nov 2024 17:05:10 +0200 Subject: [PATCH] Get rid off tablespace --- src/access/pg_tde_tdemap.c | 6 +++--- src/access/pg_tde_xlog.c | 2 +- src/catalog/tde_global_space.c | 2 +- src/catalog/tde_keyring.c | 13 +++---------- src/catalog/tde_principal_key.c | 26 +++++++++++-------------- src/encryption/enc_tde.c | 1 - src/include/catalog/tde_global_space.h | 4 +++- src/include/catalog/tde_keyring.h | 3 +-- src/include/catalog/tde_principal_key.h | 4 ++-- src/include/encryption/enc_tde.h | 2 +- src/include/pg_tde.h | 1 - src/include/pg_tde_defines.h | 4 ++-- src/pg_tde.c | 1 - src/pg_tde_event_capture.c | 8 ++------ src/smgr/pg_tde_smgr.c | 2 +- src16/access/pg_tde_io.c | 2 +- src16/access/pg_tde_rewrite.c | 2 +- src16/access/pg_tdeam.c | 6 +++--- src17/access/pg_tde_io.c | 2 +- src17/access/pg_tde_rewrite.c | 2 +- src17/access/pg_tdeam.c | 6 +++--- 21 files changed, 41 insertions(+), 58 deletions(-) diff --git a/src/access/pg_tde_tdemap.c b/src/access/pg_tde_tdemap.c index 59c630f6..cb1d5c21 100644 --- a/src/access/pg_tde_tdemap.c +++ b/src/access/pg_tde_tdemap.c @@ -160,7 +160,7 @@ pg_tde_create_key_map_entry(const RelFileLocator *newrlocator, uint32 entry_type LWLock *lock_pk = tde_lwlock_enc_keys(); LWLockAcquire(lock_pk, LW_EXCLUSIVE); - principal_key = GetPrincipalKey(newrlocator->dbOid, newrlocator->spcOid, LW_EXCLUSIVE); + principal_key = GetPrincipalKey(newrlocator->dbOid, LW_EXCLUSIVE); if (principal_key == NULL) { LWLockRelease(lock_pk); @@ -875,7 +875,7 @@ pg_tde_move_rel_key(const RelFileLocator *newrlocator, const RelFileLocator *old LWLockAcquire(tde_lwlock_enc_keys(), LW_EXCLUSIVE); - principal_key = GetPrincipalKey(oldrlocator->dbOid, oldrlocator->spcOid, LW_EXCLUSIVE); + principal_key = GetPrincipalKey(oldrlocator->dbOid, LW_EXCLUSIVE); Assert(principal_key); key_index = pg_tde_process_map_entry(oldrlocator, MAP_ENTRY_VALID, db_map_path, &offset, false); @@ -946,7 +946,7 @@ pg_tde_get_key_from_file(const RelFileLocator *rlocator, uint32 key_type, bool n * key. */ LWLockAcquire(lock_pk, LW_SHARED); - principal_key = GetPrincipalKey(rlocator->dbOid, rlocator->spcOid, LW_SHARED); + principal_key = GetPrincipalKey(rlocator->dbOid, LW_SHARED); if (principal_key == NULL) { LWLockRelease(lock_pk); diff --git a/src/access/pg_tde_xlog.c b/src/access/pg_tde_xlog.c index ddb4e8a3..bd065445 100644 --- a/src/access/pg_tde_xlog.c +++ b/src/access/pg_tde_xlog.c @@ -114,7 +114,7 @@ tdeheap_rmgr_desc(StringInfo buf, XLogReaderState *record) { XLogExtensionInstall *xlrec = (XLogExtensionInstall *) XLogRecGetData(record); - appendStringInfo(buf, "tde extension install for db %u/%u", xlrec->database_id, xlrec->tablespace_id); + appendStringInfo(buf, "tde extension install for db %u", xlrec->database_id); } if (info == XLOG_TDE_ROTATE_KEY) { diff --git a/src/catalog/tde_global_space.c b/src/catalog/tde_global_space.c index 583bb788..be1294e2 100644 --- a/src/catalog/tde_global_space.c +++ b/src/catalog/tde_global_space.c @@ -115,7 +115,7 @@ init_default_keyring(void) * TODO: should we remove it automaticaly on * pg_tde_rotate_principal_key() ? */ - save_new_key_provider_info(&provider, GLOBAL_DATA_TDE_OID, GLOBALTABLESPACE_OID, false); + save_new_key_provider_info(&provider, GLOBAL_DATA_TDE_OID, false); elog(INFO, "default keyring has been created for the global tablespace (WAL)." " Change it with pg_tde_add_key_provider_* and run pg_tde_rotate_principal_key." diff --git a/src/catalog/tde_keyring.c b/src/catalog/tde_keyring.c index fdb73239..95a9c669 100644 --- a/src/catalog/tde_keyring.c +++ b/src/catalog/tde_keyring.c @@ -306,7 +306,7 @@ write_key_provider_info(KeyringProvideRecord *provider, Oid database_id, * Save the key provider info to the file */ uint32 -save_new_key_provider_info(KeyringProvideRecord* provider, Oid databaseId, Oid tablespaceId, bool write_xlog) +save_new_key_provider_info(KeyringProvideRecord* provider, Oid databaseId, bool write_xlog) { return write_key_provider_info(provider, databaseId, -1, true, write_xlog); } @@ -335,19 +335,12 @@ pg_tde_add_key_provider_internal(PG_FUNCTION_ARGS) char *options = text_to_cstring(PG_GETARG_TEXT_PP(2)); bool is_global = PG_GETARG_BOOL(3); KeyringProvideRecord provider; - Oid dbOid = MyDatabaseId; - Oid spcOid = MyDatabaseTableSpace; - - if (is_global) - { - dbOid = GLOBAL_DATA_TDE_OID; - spcOid = GLOBALTABLESPACE_OID; - } + Oid dbOid = is_global ? GLOBAL_DATA_TDE_OID : MyDatabaseId; strncpy(provider.options, options, sizeof(provider.options)); strncpy(provider.provider_name, provider_name, sizeof(provider.provider_name)); provider.provider_type = get_keyring_provider_from_typename(provider_type); - save_new_key_provider_info(&provider, dbOid, spcOid, true); + save_new_key_provider_info(&provider, dbOid, true); PG_RETURN_INT32(provider.provider_id); } diff --git a/src/catalog/tde_principal_key.c b/src/catalog/tde_principal_key.c index ff525bee..5095fdab 100644 --- a/src/catalog/tde_principal_key.c +++ b/src/catalog/tde_principal_key.c @@ -75,10 +75,10 @@ static void shared_memory_shutdown(int code, Datum arg); static void principal_key_startup_cleanup(int tde_tbl_count, XLogExtensionInstall *ext_info, bool redo, void *arg); static void clear_principal_key_cache(Oid databaseId); static inline dshash_table *get_principal_key_Hash(void); -static TDEPrincipalKey *get_principal_key_from_keyring(Oid dbOid, Oid spcOid); +static TDEPrincipalKey *get_principal_key_from_keyring(Oid dbOid); static TDEPrincipalKey *get_principal_key_from_cache(Oid dbOid); static void push_principal_key_to_cache(TDEPrincipalKey *principalKey); -static Datum pg_tde_get_key_info(PG_FUNCTION_ARGS, Oid dbOid, Oid spcOid); +static Datum pg_tde_get_key_info(PG_FUNCTION_ARGS, Oid dbOid); static keyInfo *load_latest_versioned_key_name(TDEPrincipalKeyInfo *principal_key_info, GenericKeyring *keyring, bool ensure_new_key); @@ -644,7 +644,6 @@ pg_tde_rotate_principal_key_internal(PG_FUNCTION_ARGS) bool ret; TDEPrincipalKey *current_key; Oid dbOid = MyDatabaseId; - Oid spcOid = MyDatabaseTableSpace; if (!PG_ARGISNULL(0)) new_principal_key_name = text_to_cstring(PG_GETARG_TEXT_PP(0)); @@ -657,7 +656,6 @@ pg_tde_rotate_principal_key_internal(PG_FUNCTION_ARGS) if (is_global) { dbOid = GLOBAL_DATA_TDE_OID; - spcOid = GLOBALTABLESPACE_OID; } #endif @@ -667,7 +665,7 @@ pg_tde_rotate_principal_key_internal(PG_FUNCTION_ARGS) is_global ? "cluster" : "database"))); LWLockAcquire(tde_lwlock_enc_keys(), LW_EXCLUSIVE); - current_key = GetPrincipalKey(dbOid, spcOid, LW_EXCLUSIVE); + current_key = GetPrincipalKey(dbOid, LW_EXCLUSIVE); ret = RotatePrincipalKey(current_key, new_principal_key_name, new_provider_name, ensure_new_key); LWLockRelease(tde_lwlock_enc_keys()); @@ -679,20 +677,18 @@ Datum pg_tde_principal_key_info_internal(PG_FUNCTION_ARGS) { Oid dbOid = MyDatabaseId; - Oid spcOid = MyDatabaseTableSpace; bool is_global = PG_GETARG_BOOL(0); if (is_global) { dbOid = GLOBAL_DATA_TDE_OID; - spcOid = GLOBALTABLESPACE_OID; } - return pg_tde_get_key_info(fcinfo, dbOid, spcOid); + return pg_tde_get_key_info(fcinfo, dbOid); } static Datum -pg_tde_get_key_info(PG_FUNCTION_ARGS, Oid dbOid, Oid spcOid) +pg_tde_get_key_info(PG_FUNCTION_ARGS, Oid dbOid) { TupleDesc tupdesc; Datum values[6]; @@ -710,7 +706,7 @@ pg_tde_get_key_info(PG_FUNCTION_ARGS, Oid dbOid, Oid spcOid) errmsg("function returning record called in context that cannot accept type record"))); LWLockAcquire(tde_lwlock_enc_keys(), LW_SHARED); - principal_key = GetPrincipalKey(dbOid, spcOid, LW_SHARED); + principal_key = GetPrincipalKey(dbOid, LW_SHARED); LWLockRelease(tde_lwlock_enc_keys()); if (principal_key == NULL) { @@ -767,7 +763,7 @@ pg_tde_get_key_info(PG_FUNCTION_ARGS, Oid dbOid, Oid spcOid) * Caller should hold an exclusive tde_lwlock_enc_keys lock */ TDEPrincipalKey * -get_principal_key_from_keyring(Oid dbOid, Oid spcOid) +get_principal_key_from_keyring(Oid dbOid) { GenericKeyring *keyring; TDEPrincipalKey *principalKey = NULL; @@ -806,7 +802,7 @@ get_principal_key_from_keyring(Oid dbOid, Oid spcOid) #ifndef FRONTEND /* We don't store global space key in cache */ - if (spcOid != GLOBALTABLESPACE_OID) + if (!TDEisInGlobalSpace(dbOid)) { push_principal_key_to_cache(principalKey); @@ -840,14 +836,14 @@ get_principal_key_from_keyring(Oid dbOid, Oid spcOid) * cache. */ TDEPrincipalKey * -GetPrincipalKey(Oid dbOid, Oid spcOid, LWLockMode lockMode) +GetPrincipalKey(Oid dbOid, LWLockMode lockMode) { #ifndef FRONTEND TDEPrincipalKey *principalKey = NULL; Assert(LWLockHeldByMeInMode(tde_lwlock_enc_keys(), lockMode)); /* We don't store global space key in cache */ - if (spcOid != GLOBALTABLESPACE_OID) + if (!TDEisInGlobalSpace(dbOid)) { principalKey = get_principal_key_from_cache(dbOid); } @@ -864,5 +860,5 @@ GetPrincipalKey(Oid dbOid, Oid spcOid, LWLockMode lockMode) } #endif - return get_principal_key_from_keyring(dbOid, spcOid); + return get_principal_key_from_keyring(dbOid); } diff --git a/src/encryption/enc_tde.c b/src/encryption/enc_tde.c index e3f96676..c4e3abbe 100644 --- a/src/encryption/enc_tde.c +++ b/src/encryption/enc_tde.c @@ -205,7 +205,6 @@ pg_tde_crypt_tuple(HeapTuple tuple, HeapTuple out_tuple, RelKeyData *key, const OffsetNumber PGTdePageAddItemExtended(RelFileLocator rel, - Oid oid, BlockNumber bn, Page page, Item item, diff --git a/src/include/catalog/tde_global_space.h b/src/include/catalog/tde_global_space.h index cca493a1..88099eb4 100644 --- a/src/include/catalog/tde_global_space.h +++ b/src/include/catalog/tde_global_space.h @@ -21,7 +21,7 @@ * We take Oids of the sql operators, so there is no overlap with the "real" * catalog objects possible. */ -#define GLOBAL_DATA_TDE_OID InvalidOid +#define GLOBAL_DATA_TDE_OID 607 #define XLOG_TDE_OID 608 #define GLOBAL_SPACE_RLOCATOR(_obj_oid) (RelFileLocator) { \ @@ -30,6 +30,8 @@ _obj_oid \ } +#define TDEisInGlobalSpace(dbOid) (dbOid == GLOBAL_DATA_TDE_OID) + extern void TDEInitGlobalKeys(const char *dir); #endif /* TDE_GLOBAL_CATALOG_H */ diff --git a/src/include/catalog/tde_keyring.h b/src/include/catalog/tde_keyring.h index 943be4cc..6249ba47 100644 --- a/src/include/catalog/tde_keyring.h +++ b/src/include/catalog/tde_keyring.h @@ -79,8 +79,7 @@ extern ProviderType get_keyring_provider_from_typename(char *provider_type); extern void cleanup_key_provider_info(Oid databaseId); extern void InitializeKeyProviderInfo(void); extern uint32 save_new_key_provider_info(KeyringProvideRecord *provider, - Oid databaseId, Oid tablespaceId, - bool write_xlog); + Oid databaseId, bool write_xlog); extern uint32 redo_key_provider_info(KeyringProviderXLRecord *xlrec); extern bool ParseKeyringJSONOptions(ProviderType provider_type, void *out_opts, diff --git a/src/include/catalog/tde_principal_key.h b/src/include/catalog/tde_principal_key.h index 50828d0f..2ac1ddc6 100644 --- a/src/include/catalog/tde_principal_key.h +++ b/src/include/catalog/tde_principal_key.h @@ -62,9 +62,9 @@ extern void cleanup_principal_key_info(Oid databaseId); #ifndef FRONTEND extern LWLock *tde_lwlock_enc_keys(void); -extern TDEPrincipalKey *GetPrincipalKey(Oid dbOid, Oid spcOid, LWLockMode lockMode); +extern TDEPrincipalKey *GetPrincipalKey(Oid dbOid, LWLockMode lockMode); #else -extern TDEPrincipalKey *GetPrincipalKey(Oid dbOid, Oid spcOid, void *lockMode); +extern TDEPrincipalKey *GetPrincipalKey(Oid dbOid, void *lockMode); #endif extern bool save_principal_key_info(TDEPrincipalKeyInfo *principalKeyInfo); diff --git a/src/include/encryption/enc_tde.h b/src/include/encryption/enc_tde.h index f7732ed6..e1654c30 100644 --- a/src/include/encryption/enc_tde.h +++ b/src/include/encryption/enc_tde.h @@ -24,7 +24,7 @@ extern void /* A wrapper to encrypt a tuple before adding it to the buffer */ extern OffsetNumber - PGTdePageAddItemExtended(RelFileLocator rel, Oid oid, BlockNumber bn, Page page, + PGTdePageAddItemExtended(RelFileLocator rel, BlockNumber bn, Page page, Item item, Size size, OffsetNumber offsetNumber, diff --git a/src/include/pg_tde.h b/src/include/pg_tde.h index 3c579cff..c8046373 100644 --- a/src/include/pg_tde.h +++ b/src/include/pg_tde.h @@ -13,7 +13,6 @@ typedef struct XLogExtensionInstall { Oid database_id; - Oid tablespace_id; } XLogExtensionInstall; typedef void (*pg_tde_on_ext_install_callback) (int tde_tbl_count, XLogExtensionInstall *ext_info, bool redo, void *arg); diff --git a/src/include/pg_tde_defines.h b/src/include/pg_tde_defines.h index 529b2449..9aeee11a 100644 --- a/src/include/pg_tde_defines.h +++ b/src/include/pg_tde_defines.h @@ -40,8 +40,8 @@ #define pgstat_count_tdeheap_delete pgstat_count_heap_delete #define pgstat_count_tdeheap_insert pgstat_count_heap_insert -#define TDE_PageAddItem(rel, oid, blkno, page, item, size, offsetNumber, overwrite, is_heap) \ - PGTdePageAddItemExtended(rel, oid, blkno, page, item, size, offsetNumber, \ +#define TDE_PageAddItem(rel, blkno, page, item, size, offsetNumber, overwrite, is_heap) \ + PGTdePageAddItemExtended(rel, blkno, page, item, size, offsetNumber, \ ((overwrite) ? PAI_OVERWRITE : 0) | \ ((is_heap) ? PAI_IS_HEAP : 0)) diff --git a/src/pg_tde.c b/src/pg_tde.c index 8f4c54c7..1acf89fc 100644 --- a/src/pg_tde.c +++ b/src/pg_tde.c @@ -138,7 +138,6 @@ pg_tde_extension_initialize(PG_FUNCTION_ARGS) XLogExtensionInstall xlrec; xlrec.database_id = MyDatabaseId; - xlrec.tablespace_id = MyDatabaseTableSpace; run_extension_install_callbacks(&xlrec, false); /* diff --git a/src/pg_tde_event_capture.c b/src/pg_tde_event_capture.c index a2bb8b99..beba9d0b 100644 --- a/src/pg_tde_event_capture.c +++ b/src/pg_tde_event_capture.c @@ -102,7 +102,6 @@ pg_tde_ddl_command_start_capture(PG_FUNCTION_ARGS) { CreateStmt *stmt = (CreateStmt *) parsetree; TDEPrincipalKey *principal_key; - Oid tablespace_oid; tdeCurrentCreateEvent.eventType = TDE_TABLE_CREATE_EVENT; tdeCurrentCreateEvent.relation = stmt->relation; @@ -118,10 +117,8 @@ pg_tde_ddl_command_start_capture(PG_FUNCTION_ARGS) if (tdeCurrentCreateEvent.encryptMode) { - tablespace_oid = stmt->tablespacename != NULL ? get_tablespace_oid(stmt->tablespacename, false) - : MyDatabaseTableSpace; LWLockAcquire(tde_lwlock_enc_keys(), LW_SHARED); - principal_key = GetPrincipalKey(MyDatabaseId, tablespace_oid, LW_SHARED); + principal_key = GetPrincipalKey(MyDatabaseId, LW_SHARED); LWLockRelease(tde_lwlock_enc_keys()); if (principal_key == NULL) { @@ -162,11 +159,10 @@ pg_tde_ddl_command_start_capture(PG_FUNCTION_ARGS) TDEPrincipalKey * principal_key; Oid relationId = RangeVarGetRelid(stmt->relation, NoLock, true); Relation rel = table_open(relationId, lockmode); - Oid tablespace_oid = rel->rd_locator.spcOid; table_close(rel, lockmode); LWLockAcquire(tde_lwlock_enc_keys(), LW_SHARED); - principal_key = GetPrincipalKey(MyDatabaseId, tablespace_oid, LW_SHARED); + principal_key = GetPrincipalKey(MyDatabaseId, LW_SHARED); LWLockRelease(tde_lwlock_enc_keys()); if (principal_key == NULL) { diff --git a/src/smgr/pg_tde_smgr.c b/src/smgr/pg_tde_smgr.c index 1ace3c5d..34535d2a 100644 --- a/src/smgr/pg_tde_smgr.c +++ b/src/smgr/pg_tde_smgr.c @@ -51,7 +51,7 @@ tde_smgr_get_key(SMgrRelation reln, RelFileLocator* old_locator, bool can_create } LWLockAcquire(tde_lwlock_enc_keys(), LW_SHARED); - pk = GetPrincipalKey(reln->smgr_rlocator.locator.dbOid, reln->smgr_rlocator.locator.spcOid, LW_SHARED); + pk = GetPrincipalKey(reln->smgr_rlocator.locator.dbOid, LW_SHARED); LWLockRelease(tde_lwlock_enc_keys()); if (pk == NULL) { diff --git a/src16/access/pg_tde_io.c b/src16/access/pg_tde_io.c index 2ad4d366..0c107a33 100644 --- a/src16/access/pg_tde_io.c +++ b/src16/access/pg_tde_io.c @@ -65,7 +65,7 @@ tdeheap_RelationPutHeapTuple(Relation relation, pageHeader = BufferGetPage(buffer); if (encrypt) - offnum = TDE_PageAddItem(relation->rd_locator, tuple->t_tableOid, BufferGetBlockNumber(buffer), pageHeader, (Item) tuple->t_data, + offnum = TDE_PageAddItem(relation->rd_locator, BufferGetBlockNumber(buffer), pageHeader, (Item) tuple->t_data, tuple->t_len, InvalidOffsetNumber, false, true); else offnum = PageAddItem(pageHeader, (Item) tuple->t_data, diff --git a/src16/access/pg_tde_rewrite.c b/src16/access/pg_tde_rewrite.c index 964082a0..3577141e 100644 --- a/src16/access/pg_tde_rewrite.c +++ b/src16/access/pg_tde_rewrite.c @@ -711,7 +711,7 @@ raw_tdeheap_insert(RewriteState state, HeapTuple tup) } /* And now we can insert the tuple into the page */ - newoff = TDE_PageAddItem(state->rs_new_rel->rd_locator, heaptup->t_tableOid, state->rs_blockno, page, (Item) heaptup->t_data, heaptup->t_len, + newoff = TDE_PageAddItem(state->rs_new_rel->rd_locator, state->rs_blockno, page, (Item) heaptup->t_data, heaptup->t_len, InvalidOffsetNumber, false, true); if (newoff == InvalidOffsetNumber) elog(ERROR, "failed to add tuple"); diff --git a/src16/access/pg_tdeam.c b/src16/access/pg_tdeam.c index 840aa6f0..2568b384 100644 --- a/src16/access/pg_tdeam.c +++ b/src16/access/pg_tdeam.c @@ -9382,7 +9382,7 @@ tdeheap_xlog_insert(XLogReaderState *record) HeapTupleHeaderSetCmin(htup, FirstCommandId); htup->t_ctid = target_tid; - if (TDE_PageAddItem(target_locator, target_locator.spcOid, blkno, page, (Item) htup, newlen, xlrec->offnum, + if (TDE_PageAddItem(target_locator, blkno, page, (Item) htup, newlen, xlrec->offnum, true, true) == InvalidOffsetNumber) elog(PANIC, "failed to add tuple"); @@ -9526,7 +9526,7 @@ tdeheap_xlog_multi_insert(XLogReaderState *record) ItemPointerSetBlockNumber(&htup->t_ctid, blkno); ItemPointerSetOffsetNumber(&htup->t_ctid, offnum); - offnum = TDE_PageAddItem(rlocator, rlocator.spcOid, blkno, page, (Item) htup, newlen, offnum, true, true); + offnum = TDE_PageAddItem(rlocator, blkno, page, (Item) htup, newlen, offnum, true, true); if (offnum == InvalidOffsetNumber) elog(PANIC, "failed to add tuple"); } @@ -9800,7 +9800,7 @@ tdeheap_xlog_update(XLogReaderState *record, bool hot_update) /* Make sure there is no forward chain link in t_ctid */ htup->t_ctid = newtid; - offnum = TDE_PageAddItem(rlocator, rlocator.spcOid, newblk, page, (Item) htup, newlen, offnum, true, true); + offnum = TDE_PageAddItem(rlocator, newblk, page, (Item) htup, newlen, offnum, true, true); if (offnum == InvalidOffsetNumber) elog(PANIC, "failed to add tuple"); diff --git a/src17/access/pg_tde_io.c b/src17/access/pg_tde_io.c index 5f0ec931..4136b04b 100644 --- a/src17/access/pg_tde_io.c +++ b/src17/access/pg_tde_io.c @@ -64,7 +64,7 @@ tdeheap_RelationPutHeapTuple(Relation relation, pageHeader = BufferGetPage(buffer); if (encrypt) - offnum = TDE_PageAddItem(relation->rd_locator, tuple->t_tableOid, BufferGetBlockNumber(buffer), pageHeader, (Item) tuple->t_data, + offnum = TDE_PageAddItem(relation->rd_locator, BufferGetBlockNumber(buffer), pageHeader, (Item) tuple->t_data, tuple->t_len, InvalidOffsetNumber, false, true); else offnum = PageAddItem(pageHeader, (Item) tuple->t_data, diff --git a/src17/access/pg_tde_rewrite.c b/src17/access/pg_tde_rewrite.c index 72919c7e..9332b429 100644 --- a/src17/access/pg_tde_rewrite.c +++ b/src17/access/pg_tde_rewrite.c @@ -677,7 +677,7 @@ raw_tdeheap_insert(RewriteState state, HeapTuple tup) } /* And now we can insert the tuple into the page */ - newoff = TDE_PageAddItem(state->rs_new_rel->rd_locator, heaptup->t_tableOid, state->rs_blockno, page, (Item) heaptup->t_data, heaptup->t_len, + newoff = TDE_PageAddItem(state->rs_new_rel->rd_locator, state->rs_blockno, page, (Item) heaptup->t_data, heaptup->t_len, InvalidOffsetNumber, false, true); if (newoff == InvalidOffsetNumber) elog(ERROR, "failed to add tuple"); diff --git a/src17/access/pg_tdeam.c b/src17/access/pg_tdeam.c index 5f6cccfd..597b2335 100644 --- a/src17/access/pg_tdeam.c +++ b/src17/access/pg_tdeam.c @@ -9282,7 +9282,7 @@ tdeheap_xlog_insert(XLogReaderState *record) HeapTupleHeaderSetCmin(htup, FirstCommandId); htup->t_ctid = target_tid; - if (TDE_PageAddItem(target_locator, target_locator.spcOid, blkno, page, (Item) htup, newlen, xlrec->offnum, + if (TDE_PageAddItem(target_locator, blkno, page, (Item) htup, newlen, xlrec->offnum, true, true) == InvalidOffsetNumber) elog(PANIC, "failed to add tuple"); @@ -9426,7 +9426,7 @@ tdeheap_xlog_multi_insert(XLogReaderState *record) ItemPointerSetBlockNumber(&htup->t_ctid, blkno); ItemPointerSetOffsetNumber(&htup->t_ctid, offnum); - offnum = TDE_PageAddItem(rlocator, rlocator.spcOid, blkno, page, (Item) htup, newlen, offnum, true, true); + offnum = TDE_PageAddItem(rlocator, blkno, page, (Item) htup, newlen, offnum, true, true); if (offnum == InvalidOffsetNumber) elog(PANIC, "failed to add tuple"); } @@ -9700,7 +9700,7 @@ tdeheap_xlog_update(XLogReaderState *record, bool hot_update) /* Make sure there is no forward chain link in t_ctid */ htup->t_ctid = newtid; - offnum = TDE_PageAddItem(rlocator, rlocator.spcOid, newblk, page, (Item) htup, newlen, offnum, true, true); + offnum = TDE_PageAddItem(rlocator, newblk, page, (Item) htup, newlen, offnum, true, true); if (offnum == InvalidOffsetNumber) elog(PANIC, "failed to add tuple");