remove oid for gs_global_chain
This commit is contained in:
2
src/common/backend/utils/cache/relcache.cpp
vendored
2
src/common/backend/utils/cache/relcache.cpp
vendored
@ -824,7 +824,7 @@ static struct CatalogRelationBuildParam catalogBuildParam[CATALOG_NUM] = {{Defau
|
||||
"gs_global_chain",
|
||||
GsGlobalChainRelationId_Rowtype_Id,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
Natts_gs_global_chain,
|
||||
Desc_gs_global_chain,
|
||||
false,
|
||||
|
||||
@ -33,30 +33,29 @@ static HTAB *g_recnum_cache = NULL;
|
||||
*
|
||||
* Note:If gchain is empty, next blocknum will start from 0.
|
||||
*/
|
||||
void reload_next_g_blocknum()
|
||||
static uint32 reload_next_g_blocknum()
|
||||
{
|
||||
Relation gchain_rel = NULL;
|
||||
HeapTuple tup = NULL;
|
||||
TableScanDesc scan;
|
||||
uint32 blocknum;
|
||||
uint32 max_num = 0;
|
||||
bool empty = true;
|
||||
bool isnull = false;
|
||||
|
||||
gchain_rel = heap_open(GsGlobalChainRelationId, AccessShareLock);
|
||||
gchain_rel = heap_open(GsGlobalChainRelationId, RowExclusiveLock);
|
||||
scan = heap_beginscan(gchain_rel, SnapshotAny, 0, NULL);
|
||||
while ((tup = heap_getnext(scan, BackwardScanDirection)) != NULL) {
|
||||
blocknum = DatumGetUInt32(heap_getattr(tup, Anum_gs_global_chain_blocknum,
|
||||
RelationGetDescr(gchain_rel), &isnull));
|
||||
if (blocknum >= max_num) {
|
||||
if (blocknum > max_num) {
|
||||
max_num = blocknum;
|
||||
empty = false;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
heap_endscan(scan);
|
||||
heap_close(gchain_rel, AccessShareLock);
|
||||
blocknum = empty ? 0 : (max_num + 1);
|
||||
pg_atomic_fetch_add_u64(&g_blocknum, blocknum);
|
||||
heap_close(gchain_rel, RowExclusiveLock);
|
||||
return max_num;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -70,7 +69,9 @@ uint64 get_next_g_blocknum()
|
||||
if (g_blocknum == 0) {
|
||||
LWLockAcquire(GlobalPrevHashLock, LW_EXCLUSIVE);
|
||||
if (g_blocknum == 0) {
|
||||
reload_next_g_blocknum();
|
||||
pg_atomic_fetch_add_u64(&g_blocknum, 1);
|
||||
int cur_num = reload_next_g_blocknum();
|
||||
pg_atomic_fetch_add_u64(&g_blocknum, cur_num);
|
||||
}
|
||||
LWLockRelease(GlobalPrevHashLock);
|
||||
}
|
||||
@ -580,4 +581,4 @@ void check_ledger_attrs_support(List *attrs)
|
||||
TypeNameToString(colDef->typname))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
#define new_timestamptz
|
||||
#endif
|
||||
|
||||
CATALOG(gs_global_chain,5818) BKI_SCHEMA_MACRO
|
||||
CATALOG(gs_global_chain,5818) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
|
||||
{
|
||||
int8 blocknum;
|
||||
NameData dbname;
|
||||
|
||||
@ -420,8 +420,6 @@ DECLARE_UNIQUE_INDEX(pg_directory_name_index, 4350, on pg_directory using btree(
|
||||
#define PgDirectoryDirectoriesNameIndexId 4350
|
||||
|
||||
/* Add index of table oid for gs_global_chain */
|
||||
DECLARE_UNIQUE_INDEX(gs_global_chain_oid_index, 5510, on gs_global_chain using btree(oid oid_ops));
|
||||
#define GsGlobalChainOidIndexId 5510
|
||||
DECLARE_INDEX(gs_global_chain_relid_index, 5511, on gs_global_chain using btree(relid oid_ops));
|
||||
#define GsGlobalChainRelidIndexId 5511
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ DROP FUNCTION IF EXISTS pg_catalog.ledger_gchain_repair(text, text);
|
||||
DROP INDEX IF EXISTS pg_toast.pg_toast_5818_index;
|
||||
DROP TYPE IF EXISTS pg_toast.pg_toast_5818;
|
||||
DROP TABLE IF EXISTS pg_toast.pg_toast_5818;
|
||||
DROP INDEX IF EXISTS pg_catalog.gs_global_chain_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.gs_global_chain_relid_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.gs_global_chain;
|
||||
DROP TABLE IF EXISTS pg_catalog.gs_global_chain;
|
||||
|
||||
@ -20,7 +20,6 @@ DROP FUNCTION IF EXISTS pg_catalog.ledger_gchain_repair(text, text);
|
||||
DROP INDEX IF EXISTS pg_toast.pg_toast_5818_index;
|
||||
DROP TYPE IF EXISTS pg_toast.pg_toast_5818;
|
||||
DROP TABLE IF EXISTS pg_toast.pg_toast_5818;
|
||||
DROP INDEX IF EXISTS pg_catalog.gs_global_chain_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.gs_global_chain_relid_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.gs_global_chain;
|
||||
DROP TABLE IF EXISTS pg_catalog.gs_global_chain;
|
||||
|
||||
@ -75,10 +75,8 @@ CREATE TABLE pg_catalog.gs_global_chain
|
||||
relhash hash16 NOCOMPRESS not null,
|
||||
globalhash hash32 NOCOMPRESS not null,
|
||||
txcommand text NOCOMPRESS
|
||||
) WITH oids TABLESPACE pg_default;
|
||||
) TABLESPACE pg_default;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 5510;
|
||||
CREATE UNIQUE INDEX gs_global_chain_oid_index ON pg_catalog.gs_global_chain USING BTREE(oid oid_ops);
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 5511;
|
||||
CREATE INDEX gs_global_chain_relid_index ON pg_catalog.gs_global_chain USING BTREE(relid oid_ops);
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
@ -75,10 +75,8 @@ CREATE TABLE pg_catalog.gs_global_chain
|
||||
relhash hash16 NOCOMPRESS not null,
|
||||
globalhash hash32 NOCOMPRESS not null,
|
||||
txcommand text NOCOMPRESS
|
||||
) WITH oids TABLESPACE pg_default;
|
||||
) TABLESPACE pg_default;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 5510;
|
||||
CREATE UNIQUE INDEX gs_global_chain_oid_index ON pg_catalog.gs_global_chain USING BTREE(oid oid_ops);
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 5511;
|
||||
CREATE INDEX gs_global_chain_relid_index ON pg_catalog.gs_global_chain USING BTREE(relid oid_ops);
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
@ -92,7 +92,6 @@ enum HistTableColumn {
|
||||
USERCHAIN_COLUMN_NUM
|
||||
};
|
||||
|
||||
void reload_next_g_blocknum();
|
||||
uint64 get_next_g_blocknum();
|
||||
void reset_g_blocknum();
|
||||
|
||||
@ -123,4 +122,4 @@ bool is_ledger_rowstore(List *defList);
|
||||
bool is_ledger_hashbucketstore(List *defList);
|
||||
void ledger_check_switch_schema(Oid old_nsp, Oid new_nsp);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user