增加视图函数升级脚本
This commit is contained in:
@ -3947,7 +3947,7 @@
|
||||
),
|
||||
AddFuncGroup(
|
||||
"gs_stat_undo", 1,
|
||||
AddBuiltinFunc(_0(4434), _1("gs_stat_undo"), _2(0), _3(false), _4(true), _5(gs_stat_undo), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(0), _21(10, 23, 25, 23, 23, 28, 28, 20, 20, 23, 23), _22(10, 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(10, "curr_used_zone_count", "top_used_zones", "curr_used_undo_size", "undo_threshold", "global_recycle_xid", "oldest_xmin", "total_undo_chain_len", "max_undo_chain_len", "create_undo_file_count", "discard_undo_file_count"), _24(NULL), _25("gs_stat_undo"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0))
|
||||
AddBuiltinFunc(_0(4434), _1("gs_stat_undo"), _2(0), _3(false), _4(true), _5(gs_stat_undo), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(0), _21(10, 23, 25, 23, 23, 28, 28, 20, 20, 23, 23), _22(10, 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(10, "curr_used_zone_count", "top_used_zones", "curr_used_undo_size", "undo_threshold", "global_recycle_xid", "oldest_xmin", "total_undo_chain_len", "max_undo_chain_len", "create_undo_file_count", "discard_undo_file_count"), _24(NULL), _25("gs_stat_undo"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0))
|
||||
),
|
||||
AddFuncGroup(
|
||||
"gs_undo_translot", 1,
|
||||
|
||||
@ -75,7 +75,7 @@ bool will_shutdown = false;
|
||||
* NEXT | 92899 | ? | ?
|
||||
*
|
||||
********************************************/
|
||||
const uint32 GRAND_VERSION_NUM = 92934;
|
||||
const uint32 GRAND_VERSION_NUM = 92935;
|
||||
|
||||
/********************************************
|
||||
* 2.VERSION NUM FOR EACH FEATURE
|
||||
|
||||
@ -904,6 +904,7 @@ Datum transformRelOptions(Datum oldOptions, List *defList, const char *namspace,
|
||||
* doesn't enforce it.)
|
||||
*/
|
||||
const char *storageType = NULL;
|
||||
const char *toastStorageType = NULL;
|
||||
bool toastStorageTypeSet = false;
|
||||
foreach (cell, defList) {
|
||||
DefElem *def = (DefElem *)lfirst(cell);
|
||||
@ -954,6 +955,9 @@ Datum transformRelOptions(Datum oldOptions, List *defList, const char *namspace,
|
||||
continue;
|
||||
} else if (pg_strcasecmp(def->defnamespace, namspace) != 0) {
|
||||
continue;
|
||||
} else {
|
||||
toastStorageType = ((def->arg != NULL) ? defGetString(def) : NULL);
|
||||
continue;
|
||||
}
|
||||
toastStorageTypeSet = true; /* toast table set the storage type itself */
|
||||
} else if (def->defnamespace == NULL)
|
||||
@ -981,6 +985,22 @@ Datum transformRelOptions(Datum oldOptions, List *defList, const char *namspace,
|
||||
}
|
||||
}
|
||||
|
||||
if (namspace != NULL && pg_strcasecmp(namspace, "toast") == 0 && toastStorageType != NULL) {
|
||||
const char *actualStorageType = NULL;
|
||||
if (storageType == NULL) {
|
||||
actualStorageType = u_sess->attr.attr_sql.enable_default_ustore_table ? "ustore" : "astore";
|
||||
} else {
|
||||
actualStorageType = storageType;
|
||||
}
|
||||
|
||||
if (pg_strcasecmp(actualStorageType, "astore") == 0 || pg_strcasecmp(actualStorageType, "ustore") == 0) {
|
||||
if (pg_strcasecmp(actualStorageType, toastStorageType) != 0) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("toast cannot be set for %s with storage_type=%s", actualStorageType, toastStorageType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* we did not specify a storage type for toast, so use the same storage type as its parent */
|
||||
if (namspace != NULL && pg_strcasecmp(namspace, "toast") == 0 && !toastStorageTypeSet) {
|
||||
if (storageType != NULL) {
|
||||
|
||||
@ -364,7 +364,8 @@ void UndoRecord::Load(bool keepBuffer)
|
||||
Page page = BufferGetPage(buffer);
|
||||
BufferDesc *bufDesc = GetBufferDescriptor(buffer - 1);
|
||||
if (bufDesc->tag.blockNum != blk || bufDesc->tag.rnode.dbNode != UNDO_DB_OID ||
|
||||
bufDesc->tag.rnode.relNode != (Oid)zoneId) {
|
||||
bufDesc->tag.rnode.relNode != (Oid)zoneId ||
|
||||
(!PageIsNew(page) && PageGetPageLayoutVersion(page) != PG_COMM_PAGE_LAYOUT_VERSION)) {
|
||||
ereport(PANIC,
|
||||
(errmsg(UNDOFORMAT("undo buffer desc invalid, bufdesc: dbid=%u, relid=%u, blockno=%u. "
|
||||
"expect: dbid=%u, zoneid=%u, blockno=%u."),
|
||||
|
||||
@ -785,4 +785,25 @@ void ReleaseSlotBuffer()
|
||||
PG_END_TRY();
|
||||
}
|
||||
}
|
||||
|
||||
void initUndoZoneLock()
|
||||
{
|
||||
if (g_instance.undo_cxt.uZones != NULL) {
|
||||
int persistZoneCount = PERSIST_ZONE_COUNT;
|
||||
for (int persist = (int)UNDO_PERMANENT; persist <= (int)UNDO_TEMP; persist++) {
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
for (auto idx = 0; idx < persistZoneCount; idx++) {
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
int zoneId = (int)(idx + persist * PERSIST_ZONE_COUNT);
|
||||
UndoZone *uzone = (UndoZone *)g_instance.undo_cxt.uZones[zoneId];
|
||||
if (uzone == NULL) {
|
||||
break;
|
||||
}
|
||||
uzone->InitLock();
|
||||
uzone->GetUndoSpace()->LockInit();
|
||||
uzone->GetSlotSpace()->LockInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace undo
|
||||
|
||||
@ -681,6 +681,7 @@ static void InitializeLWLocks(int numLocks)
|
||||
for (id = NumFixedLWLocks; id < numLocks; id++, lock++) {
|
||||
LWLockInitialize(&lock->lock, LWTRANCHE_UNKNOWN);
|
||||
}
|
||||
undo::initUndoZoneLock();
|
||||
}
|
||||
|
||||
const char *GetBuiltInTrancheName(int trancheId)
|
||||
|
||||
@ -906,7 +906,7 @@ static inline void tableam_tuple_abort_speculative(Relation relation, Tuple tupl
|
||||
|
||||
static inline bool tableam_tuple_check_compress(Relation relation, Tuple tuple)
|
||||
{
|
||||
relation->rd_tam_ops->tuple_check_compress(tuple);
|
||||
return relation->rd_tam_ops->tuple_check_compress(tuple);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
||||
@ -65,6 +65,7 @@ void ReleaseSlotBuffer();
|
||||
void InitUndoCountThreshold();
|
||||
void RebuildUndoZoneBitmap();
|
||||
UndoRecPtr GetPrevUrp(UndoRecPtr currUrp);
|
||||
void initUndoZoneLock();
|
||||
} // namespace undo
|
||||
|
||||
extern void GetUndoFileDirectory(char *path, int len, UndoPersistence upersistence);
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
/*------ add sys fuction gs_stat_undo ------*/
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_stat_undo();
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4434;
|
||||
CREATE FUNCTION pg_catalog.gs_stat_undo(OUT curr_used_zone_count int4, OUT top_used_zones text, OUT curr_used_undo_size int4,
|
||||
OUT undo_threshold int4, OUT oldest_xid_in_undo oid, OUT oldest_xmin oid, OUT total_undo_chain_len oid, OUT max_undo_chain_len oid,
|
||||
OUT create_undo_file_count int4, OUT discard_undo_file_count int4)
|
||||
RETURNS record LANGUAGE INTERNAL as 'gs_stat_undo';
|
||||
@ -0,0 +1,7 @@
|
||||
/*------ add sys fuction gs_stat_undo ------*/
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_stat_undo();
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4434;
|
||||
CREATE FUNCTION pg_catalog.gs_stat_undo(OUT curr_used_zone_count int4, OUT top_used_zones text, OUT curr_used_undo_size int4,
|
||||
OUT undo_threshold int4, OUT oldest_xid_in_undo oid, OUT oldest_xmin oid, OUT total_undo_chain_len oid, OUT max_undo_chain_len oid,
|
||||
OUT create_undo_file_count int4, OUT discard_undo_file_count int4)
|
||||
RETURNS record LANGUAGE INTERNAL as 'gs_stat_undo';
|
||||
@ -0,0 +1,16 @@
|
||||
/*------ add sys fuction gs_stat_undo ------*/
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_stat_undo();
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4434;
|
||||
CREATE FUNCTION pg_catalog.gs_stat_undo(
|
||||
OUT curr_used_zone_count int4,
|
||||
OUT top_used_zones text,
|
||||
OUT curr_used_undo_size int4,
|
||||
OUT undo_threshold int4,
|
||||
OUT global_recycle_xid xid,
|
||||
OUT oldest_xmin xid,
|
||||
OUT total_undo_chain_len int8,
|
||||
OUT max_undo_chain_len int8,
|
||||
OUT create_undo_file_count int4,
|
||||
OUT discard_undo_file_count int4)
|
||||
RETURNS SETOF record
|
||||
LANGUAGE INTERNAL STABLE NOT SHIPPABLE ROWS 1 as 'gs_stat_undo';
|
||||
@ -0,0 +1,16 @@
|
||||
/*------ add sys fuction gs_stat_undo ------*/
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_stat_undo();
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4434;
|
||||
CREATE FUNCTION pg_catalog.gs_stat_undo(
|
||||
OUT curr_used_zone_count int4,
|
||||
OUT top_used_zones text,
|
||||
OUT curr_used_undo_size int4,
|
||||
OUT undo_threshold int4,
|
||||
OUT global_recycle_xid xid,
|
||||
OUT oldest_xmin xid,
|
||||
OUT total_undo_chain_len int8,
|
||||
OUT max_undo_chain_len int8,
|
||||
OUT create_undo_file_count int4,
|
||||
OUT discard_undo_file_count int4)
|
||||
RETURNS SETOF record
|
||||
LANGUAGE INTERNAL STABLE NOT SHIPPABLE ROWS 1 as 'gs_stat_undo';
|
||||
Reference in New Issue
Block a user