源神启东队——注释修改V1.0 #23
|
|
@ -34,7 +34,20 @@
|
|||
#include <sys/utsname.h>
|
||||
|
||||
#include "cgutil.h"
|
||||
|
||||
/*
|
||||
* macro name : EXCP_PARSE_KEY
|
||||
* description : parse strings in an exception format and assign the parsed value to the variable val
|
||||
* Note : The macro takes two arguments: p, which is the string to be parsed, and val, the variable to store
|
||||
* the parsed result.Inside the macro, two pointer variables tmp and bad are declared and initialized
|
||||
* to NULL.The strchr function is used to find the position of the character '=' within the string p.
|
||||
* The resulting pointer is assigned to tmp. At the same time, the character '=' is replaced with '\0'
|
||||
* to treat tmp as the key string.The strtoul function is used to convert the string pointed by tmp to
|
||||
* an unsigned long integer, and the converted result is assigned to val.The code checks if the conversion
|
||||
* result is valid. If the converted string is empty or contains invalid characters, an error message
|
||||
* is printed to the standard error stream, indicating that the value is invalid. Then, it returns -1 to
|
||||
* indicate an error.If no errors occur during the parsing process, the code continues with the
|
||||
* subsequent instructions
|
||||
*/
|
||||
#define EXCP_PARSE_KEY(p, val) \
|
||||
{ \
|
||||
char *tmp = NULL, *bad = NULL; \
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@
|
|||
*-------------------------------------------------------------------------
|
||||
*
|
||||
* cgexec.cpp
|
||||
* Cgroup configration file process functions
|
||||
* Cgroup execute file place the processes in specific control groups (cgroups) and executed
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* src/bin/gs_cgroup/cgconf.cpp
|
||||
* src/bin/gs_cgroup/cgexec.cpp
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
|
@ -70,7 +70,13 @@ static int cgexec_update_class_cpuset(int cls, char* cpuset);
|
|||
static int cgexec_update_top_group_cpuset(int top, char* cpuset);
|
||||
/* update one group cpu cores */
|
||||
static int cgexec_update_cgroup_cpuset(gscgroup_grp_t* grp, char* cpuset);
|
||||
|
||||
/*
|
||||
* function name : CheckBackendEnv
|
||||
* description : check if the input environment variable input_env_value contains any dangerous characters
|
||||
* return value :
|
||||
* 0: normal
|
||||
* 1: abnormal
|
||||
*/
|
||||
int CheckBackendEnv(const char* input_env_value)
|
||||
{
|
||||
const int max_env_len = 1024;
|
||||
|
|
@ -91,7 +97,13 @@ int CheckBackendEnv(const char* input_env_value)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* function name : CheckSystemSucess
|
||||
* description : check the execution result of a system call
|
||||
* return value :
|
||||
* 0: bormal
|
||||
* 1: abnormal
|
||||
*/
|
||||
inline int CheckSystemSucess(pid_t status)
|
||||
{
|
||||
if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
|
||||
|
|
@ -182,6 +194,10 @@ int cgexec_check_cpuset_value(const char* clsset, const char* grpset)
|
|||
int clsstart, clsend;
|
||||
int grpstart, grpend;
|
||||
|
||||
/* sscanf_s is used to parse two strings, clsset and grpset,
|
||||
* and store the parsed integer values in the variables clsstart,
|
||||
* clsend, grpstart, and grpend.
|
||||
*/
|
||||
errno_t ret = sscanf_s(clsset, "%d-%d", &clsstart, &clsend);
|
||||
if (ret != 2) {
|
||||
fprintf(stderr,
|
||||
|
|
|
|||
|
|
@ -323,7 +323,10 @@ int get_all_cndn_num()
|
|||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
*function name: get_all_gtm_num
|
||||
*description : calculate the number of GTM (Global Transaction Manager) nodes that meet certain conditions
|
||||
*/
|
||||
int get_all_gtm_num()
|
||||
{
|
||||
uint32 nodeidx = 0;
|
||||
|
|
|
|||
|
|
@ -179,28 +179,22 @@ void InitBufferPool(void)
|
|||
Size BufferShmemSize(void)
|
||||
{
|
||||
Size size = 0;
|
||||
|
||||
/* size of buffer descriptors */
|
||||
/* 缓冲区描述符的大小*/
|
||||
size = add_size(size, mul_size(TOTAL_BUFFER_NUM, sizeof(BufferDescPadded)));
|
||||
size = add_size(size, PG_CACHE_LINE_SIZE);
|
||||
|
||||
/* size of data pages */
|
||||
/* 数据页面的大小 */
|
||||
size = add_size(size, mul_size(TOTAL_BUFFER_NUM, BLCKSZ));
|
||||
#ifdef __aarch64__
|
||||
size = add_size(size, PG_CACHE_LINE_SIZE);
|
||||
#endif
|
||||
/* size of stuff controlled by freelist.c */
|
||||
/* 由freelist.c所控制的东西的大小 */
|
||||
size = add_size(size, StrategyShmemSize());
|
||||
|
||||
/* size of checkpoint sort array in bufmgr.c */
|
||||
/* 在bufmgr.c中的检查点排序数组的大小*/
|
||||
size = add_size(size, mul_size(TOTAL_BUFFER_NUM, sizeof(CkptSortItem)));
|
||||
|
||||
/* size of candidate buffers */
|
||||
/* 候选缓冲区的大小 */
|
||||
size = add_size(size, mul_size(TOTAL_BUFFER_NUM, sizeof(Buffer)));
|
||||
|
||||
/* size of candidate free map */
|
||||
/* 候选自由映射的大小 */
|
||||
size = add_size(size, mul_size(TOTAL_BUFFER_NUM, sizeof(bool)));
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,16 +52,11 @@ Size BufTableShmemSize(int size)
|
|||
void InitBufTable(int size)
|
||||
{
|
||||
HASHCTL info;
|
||||
|
||||
/* assume no locking is needed yet
|
||||
*
|
||||
* BufferTag maps to Buffer
|
||||
*/
|
||||
/*缓冲区标签映射到缓冲区*/
|
||||
info.keysize = sizeof(BufferTag);
|
||||
info.entrysize = sizeof(BufferLookupEnt);
|
||||
info.hash = tag_hash;
|
||||
info.num_partitions = NUM_BUFFER_PARTITIONS;
|
||||
|
||||
t_thrd.storage_cxt.SharedBufHash = ShmemInitHash("Shared Buffer Lookup Table", size, size, &info,
|
||||
HASH_ELEM | HASH_FUNCTION | HASH_PARTITION);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1679,41 +1679,28 @@ Buffer ReadBufferExtended(Relation reln, ForkNumber fork_num, BlockNumber block_
|
|||
{
|
||||
bool hit = false;
|
||||
Buffer buf;
|
||||
|
||||
if (block_num == P_NEW) {
|
||||
STORAGE_SPACE_OPERATION(reln, BLCKSZ);
|
||||
}
|
||||
|
||||
/* Open it at the smgr level if not already done */
|
||||
/* 以smgr(存储管理器)级别打开一个缓冲区 */
|
||||
RelationOpenSmgr(reln);
|
||||
|
||||
/*
|
||||
* Reject attempts to read non-local temporary relations; we would be
|
||||
* likely to get wrong data since we have no visibility into the owning
|
||||
* session's local buffers.
|
||||
*/
|
||||
if (RELATION_IS_OTHER_TEMP(reln) && fork_num <= INIT_FORKNUM)
|
||||
/*拒绝读取非局部临时关系的请求,因为可能会获得监控不到的错误数据 */
|
||||
if (RELATION_IS_OTHER_TEMP(reln) && fork_num <= INIT_FORKNUM)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot access temporary tables of other sessions")));
|
||||
|
||||
/*
|
||||
* Read the buffer, and update pgstat counters to reflect a cache hit or
|
||||
* miss.
|
||||
*/
|
||||
/*读取缓冲区,更新pgstat 数量反馈cache 命中与否情况*/
|
||||
pgstat_count_buffer_read(reln);
|
||||
pgstatCountBlocksFetched4SessionLevel();
|
||||
|
||||
if (RelationisEncryptEnable(reln)) {
|
||||
reln->rd_smgr->encrypt = true;
|
||||
reln->rd_smgr->encrypt = true;
|
||||
}
|
||||
buf = ReadBuffer_common(reln->rd_smgr, reln->rd_rel->relpersistence, fork_num,
|
||||
buf = ReadBuffer_common(reln->rd_smgr, reln->rd_rel->relpersistence, fork_num,
|
||||
block_num, mode, strategy, &hit, NULL);
|
||||
if (hit) {
|
||||
pgstat_count_buffer_hit(reln);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* ReadBufferWithoutRelcache -- like ReadBufferExtended, but doesn't require
|
||||
* a relcache entry for the relation.
|
||||
|
|
|
|||
|
|
@ -78,9 +78,8 @@ static void fsm_update_recursive(Relation rel, const FSMAddress& addr, uint8 new
|
|||
*/
|
||||
BlockNumber GetPageWithFreeSpace(Relation rel, Size spaceNeeded)
|
||||
{
|
||||
uint8 min_cat = fsm_space_needed_to_cat(spaceNeeded);
|
||||
|
||||
return fsm_search(rel, min_cat);
|
||||
uint8 min_cat = fsm_space_needed_to_cat(spaceNeeded);/*将所需的空间大小转换为一个最小类别(min_cat)的整数*/
|
||||
return fsm_search(rel, min_cat);/*在关系中查找具有至少min_cat类别的可用空间的页面,并返回该页面的块号*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -94,19 +93,20 @@ BlockNumber GetPageWithFreeSpace(Relation rel, Size spaceNeeded)
|
|||
*/
|
||||
BlockNumber RecordAndGetPageWithFreeSpace(Relation rel, BlockNumber oldPage, Size oldSpaceAvail, Size spaceNeeded)
|
||||
{
|
||||
// 将旧可用空间大小转换为相应的类别
|
||||
int old_cat = fsm_space_avail_to_cat(oldSpaceAvail);
|
||||
// 将所需空间大小转换为相应的类别
|
||||
int search_cat = fsm_space_needed_to_cat(spaceNeeded);
|
||||
FSMAddress addr;
|
||||
uint16 slot;
|
||||
int search_slot;
|
||||
|
||||
/* Get the location of the FSM byte representing the heap block */
|
||||
// 获取表示堆块的FSM字节的位置
|
||||
addr = fsm_get_location(oldPage, &slot);
|
||||
|
||||
// 调用fsm_set_and_search函数,尝试在FSM中设置一个新的适合条件的页面,并返回其插槽号
|
||||
search_slot = fsm_set_and_search(rel, addr, slot, (uint8)old_cat, (uint8)search_cat);
|
||||
/*
|
||||
* If fsm_set_and_search found a suitable new block, return that.
|
||||
* Otherwise, search as usual.
|
||||
* 如果fsm_set_and_search找到了适合的新块,返回该新块。
|
||||
* 否则,按照通常的方式进行搜索。
|
||||
*/
|
||||
if (search_slot != -1)
|
||||
return fsm_get_heap_blk(addr, (uint16)search_slot);
|
||||
|
|
@ -123,13 +123,12 @@ BlockNumber RecordAndGetPageWithFreeSpace(Relation rel, BlockNumber oldPage, Siz
|
|||
*/
|
||||
void RecordPageWithFreeSpace(Relation rel, BlockNumber heapBlk, Size spaceAvail)
|
||||
{
|
||||
int new_cat = fsm_space_avail_to_cat(spaceAvail);
|
||||
FSMAddress addr;
|
||||
uint16 slot;
|
||||
|
||||
/* Get the location of the FSM byte representing the heap block */
|
||||
addr = fsm_get_location(heapBlk, &slot);
|
||||
|
||||
int new_cat = fsm_space_avail_to_cat(spaceAvail); // 将空闲空间大小转换为 FSM 分类
|
||||
FSMAddress addr; // FSM 地址
|
||||
uint16 slot; // 插槽号
|
||||
/* 获取表示堆块的 FSM 字节的位置 */
|
||||
addr = fsm_get_location(heapBlk, &slot); // 获取 FSM 地址和插槽号
|
||||
// 调用 fsm_set_and_search 函数,更新 FSM 信息
|
||||
fsm_set_and_search(rel, addr, slot, (uint8)new_cat, 0);
|
||||
}
|
||||
|
||||
|
|
@ -142,26 +141,22 @@ void RecordPageWithFreeSpace(Relation rel, BlockNumber heapBlk, Size spaceAvail)
|
|||
*/
|
||||
void UpdateFreeSpaceMap(Relation rel, BlockNumber startBlkNum, BlockNumber endBlkNum, Size freespace, bool search)
|
||||
{
|
||||
// 将可用空间大小(freespace)转换为相应的类别(new_cat)
|
||||
int new_cat = fsm_space_avail_to_cat(freespace);
|
||||
FSMAddress addr;
|
||||
uint16 slot;
|
||||
BlockNumber blockNum;
|
||||
BlockNumber lastBlkOnPage;
|
||||
|
||||
blockNum = startBlkNum;
|
||||
|
||||
while (blockNum <= endBlkNum) {
|
||||
/*
|
||||
* Find FSM address for this block; update tree all the way to the
|
||||
* root.
|
||||
* 找到这个块的FSM地址;逐级更新树直到根节点。
|
||||
*/
|
||||
addr = fsm_get_location(blockNum, &slot);
|
||||
fsm_update_recursive(rel, addr, (uint8)new_cat, search);
|
||||
|
||||
/*
|
||||
* Get the last block number on this FSM page. If that's greater
|
||||
* than or equal to our endBlkNum, we're done. Otherwise, advance
|
||||
* to the first block on the next page.
|
||||
* 获取此FSM页面上的最后一个块号。如果该块号大于或等于endBlkNum,我们完成了更新。
|
||||
* 否则,前进到下一页的第一个块。
|
||||
*/
|
||||
lastBlkOnPage = fsm_get_lastblckno(rel, addr);
|
||||
if (lastBlkOnPage >= endBlkNum)
|
||||
|
|
@ -177,60 +172,52 @@ void UpdateFreeSpaceMap(Relation rel, BlockNumber startBlkNum, BlockNumber endBl
|
|||
void XLogRecordPageWithFreeSpace(const RelFileNode& rnode, BlockNumber heapBlk, Size spaceAvail)
|
||||
{
|
||||
/*
|
||||
* FSM can not be read by physical location in recovery. It is possible to write on wrong places
|
||||
* if the FSM fork is dropped and then allocated when replaying old xlog.
|
||||
* Since FSM does not have to be totally accurate anyway, just skip it.
|
||||
* 在恢复过程中无法根据物理位置读取FSM。如果在回放旧的XLOG时删除了FSM分支,然后重新分配了它,可能会在错误的位置写入。
|
||||
* 由于FSM不必完全准确,因此可以跳过它。
|
||||
*/
|
||||
if (IsSegmentFileNode(rnode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 将可用空间大小转换为新的类别
|
||||
int new_cat = fsm_space_avail_to_cat(spaceAvail);
|
||||
FSMAddress addr;
|
||||
uint16 slot;
|
||||
BlockNumber blkno;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
|
||||
/* Get the location of the FSM byte representing the heap block */
|
||||
// 获取表示堆块的FSM字节的位置
|
||||
addr = fsm_get_location(heapBlk, &slot);
|
||||
blkno = fsm_logical_to_physical(addr);
|
||||
|
||||
/* If the page doesn't exist already, extend */
|
||||
// 如果页面尚不存在,则扩展
|
||||
buf = XLogReadBufferExtended(rnode, FSM_FORKNUM, blkno, RBM_ZERO_ON_ERROR, NULL);
|
||||
|
||||
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
if (PageIsNew(page))
|
||||
PageInit(page, BLCKSZ, 0);
|
||||
|
||||
// 设置新的可用类别
|
||||
if (fsm_set_avail(page, (int)slot, (uint8)new_cat))
|
||||
MarkBufferDirtyHint(buf, false);
|
||||
UnlockReleaseBuffer(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* GetRecordedFreePage - return the amount of free space on a particular page,
|
||||
* according to the FSM.
|
||||
* GetRecordedFreePage - 返回特定页面上的自由空间大小,
|
||||
* 根据FSM(Free Space Map)确定。
|
||||
*/
|
||||
Size GetRecordedFreeSpace(Relation rel, BlockNumber heapBlk)
|
||||
{
|
||||
FSMAddress addr;
|
||||
uint16 slot;
|
||||
Buffer buf;
|
||||
uint8 cat;
|
||||
|
||||
/* Get the location of the FSM byte representing the heap block */
|
||||
addr = fsm_get_location(heapBlk, &slot);
|
||||
|
||||
buf = fsm_readbuf(rel, addr, false);
|
||||
if (!BufferIsValid(buf))
|
||||
return 0;
|
||||
cat = fsm_get_avail(BufferGetPage(buf), slot);
|
||||
ReleaseBuffer(buf);
|
||||
|
||||
return fsm_space_cat_to_avail(cat);
|
||||
FSMAddress addr; // 声明FSM地址变量
|
||||
uint16 slot; // 声明槽位变量
|
||||
Buffer buf; // 声明缓冲区变量
|
||||
uint8 cat; // 声明类别变量
|
||||
/* 获取表示堆块的FSM字节位置 */
|
||||
addr = fsm_get_location(heapBlk, &slot); // 调用函数获取FSM位置信息
|
||||
buf = fsm_readbuf(rel, addr, false); // 读取FSM中的数据块到缓冲区
|
||||
if (!BufferIsValid(buf)) // 检查缓冲区是否有效
|
||||
return 0; // 如果无效,返回0表示无法获取空闲空间信息
|
||||
cat = fsm_get_avail(BufferGetPage(buf), slot); // 获取槽位相关的空闲空间信息
|
||||
ReleaseBuffer(buf); // 释放缓冲区
|
||||
return fsm_space_cat_to_avail(cat); // 将类别转换为实际可用空间大小并返回
|
||||
}
|
||||
|
||||
void XLogBlockTruncateRelFSM(Relation rel, BlockNumber nblocks)
|
||||
|
|
@ -275,68 +262,49 @@ void FreeSpaceMapTruncateRel(Relation rel, BlockNumber nblocks)
|
|||
FSMAddress first_removed_address;
|
||||
uint16 first_removed_slot;
|
||||
Buffer buf;
|
||||
|
||||
// 打开关系的存储管理器
|
||||
RelationOpenSmgr(rel);
|
||||
|
||||
/*
|
||||
* If no FSM has been created yet for this relation, there's nothing to
|
||||
* truncate.
|
||||
* 如果该关系尚未创建Free Space Map(FSM),则无需截断。
|
||||
*/
|
||||
if (!smgrexists(rel->rd_smgr, FSM_FORKNUM))
|
||||
return;
|
||||
|
||||
/* Get the location in the FSM of the first removed heap block */
|
||||
/* 获取第一个被移除堆块在FSM中的位置 */
|
||||
first_removed_address = fsm_get_location(nblocks, &first_removed_slot);
|
||||
|
||||
/*
|
||||
* Zero out the tail of the last remaining FSM page. If the slot
|
||||
* representing the first removed heap block is at a page boundary, as the
|
||||
* first slot on the FSM page that first_removed_address points to, we can
|
||||
* just truncate that page altogether.
|
||||
* 将最后一个剩余FSM页面的尾部清零。如果第一个被移除的堆块在FSM页面的边界上,
|
||||
* 作为指向的第一个槽(slot)在FSM页面上的地址,我们可以将整个页面截断。
|
||||
*/
|
||||
if (first_removed_slot > 0) {
|
||||
buf = fsm_readbuf(rel, first_removed_address, false);
|
||||
if (!BufferIsValid(buf))
|
||||
return; /* nothing to do; the FSM was already smaller */
|
||||
return; /* 无需处理,FSM已经更小了 */
|
||||
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
|
||||
|
||||
/* NO EREPORT(ERROR) from here till changes are logged */
|
||||
/* 从此处到更改被记录的地方不会发生错误 */
|
||||
START_CRIT_SECTION();
|
||||
|
||||
fsm_truncate_avail(BufferGetPage(buf), (int)first_removed_slot);
|
||||
|
||||
/*
|
||||
* Truncation of a relation is WAL-logged at a higher-level, and we
|
||||
* will be called at WAL replay. But if checksums are enabled, we need
|
||||
* to still write a WAL record to protect against a torn page, if the
|
||||
* page is flushed to disk before the truncation WAL record. We cannot
|
||||
* use MarkBufferDirtyHint here, because that will not dirty the page
|
||||
* during recovery.
|
||||
* 关系的截断在更高级别上记录到WAL中,在WAL回放时会调用我们。但是,如果启用了校验和,
|
||||
* 我们仍然需要写入WAL记录,以保护免受破碎页面的影响,如果在截断WAL记录之前将页面刷新到磁盘上的话。
|
||||
* 在此处我们不能使用MarkBufferDirtyHint,因为在恢复时它不会使页面变脏。
|
||||
*/
|
||||
MarkBufferDirty(buf);
|
||||
if (!t_thrd.xlog_cxt.InRecovery && RelationNeedsWAL(rel) && XLogHintBitIsNeeded()) {
|
||||
log_newpage_buffer(buf, false);
|
||||
}
|
||||
END_CRIT_SECTION();
|
||||
|
||||
UnlockReleaseBuffer(buf);
|
||||
|
||||
new_nfsmblocks = fsm_logical_to_physical(first_removed_address) + 1;
|
||||
} else {
|
||||
new_nfsmblocks = fsm_logical_to_physical(first_removed_address);
|
||||
if (smgrnblocks(rel->rd_smgr, FSM_FORKNUM) <= new_nfsmblocks)
|
||||
return; /* nothing to do; the FSM was already smaller */
|
||||
return; /* 无需处理,FSM已经更小了 */
|
||||
}
|
||||
|
||||
/* Truncate the unused FSM pages, and send smgr inval message */
|
||||
/* 截断未使用的FSM页面,并发送存储管理器的失效消息 */
|
||||
smgrtruncate(rel->rd_smgr, FSM_FORKNUM, new_nfsmblocks);
|
||||
|
||||
/*
|
||||
* We might as well update the local smgr_fsm_nblocks setting.
|
||||
* smgrtruncate sent an smgr cache inval message, which will cause other
|
||||
* backends to invalidate their copy of smgr_fsm_nblocks, and this one too
|
||||
* at the next command boundary. But this ensures it isn't outright wrong
|
||||
* until then.
|
||||
* 我们也可以更新本地的smgr_fsm_nblocks设置。smgrtruncate发送了一个存储管理器缓存失效消息,
|
||||
* 这将导致其他后端在下一个命令边界时使其拥有的smgr_fsm_nblocks无效。但是,这确保了在那之前它不会完全错误。
|
||||
*/
|
||||
rel->rd_smgr->smgr_fsm_nblocks = new_nfsmblocks;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -245,10 +245,17 @@ void create_system_alarm_log(const char* sys_log_path)
|
|||
}
|
||||
(void)closedir(dir);
|
||||
}
|
||||
|
||||
/*
|
||||
* function name : Cleans the system alarm log
|
||||
*
|
||||
* This function is responsible for cleaning the system alarm log file.
|
||||
*
|
||||
* param file_name:The name of the system alarm log file.
|
||||
* param sys_log_path:The path to the system alarm log file.
|
||||
*/
|
||||
void clean_system_alarm_log(const char* file_name, const char* sys_log_path)
|
||||
{
|
||||
Assert(file_name != NULL);
|
||||
Assert(file_name != NULL);// Ensure that the file name is not NULL.
|
||||
|
||||
unsigned long filesize = 0;
|
||||
struct stat statbuff;
|
||||
|
|
|
|||
|
|
@ -211,12 +211,12 @@ class Pterodb():
|
|||
|
||||
def spliceSqlFile(self, fileDir, scriptType="_"):
|
||||
try:
|
||||
NewVersionNum = self.getNewVersionNum()
|
||||
NewVersionNum = self.getNewVersionNum() #Version number and file handling
|
||||
BaseVersionNum = self.upgrade_from
|
||||
fileAllList = os.listdir(fileDir)
|
||||
fileAllList = os.listdir(fileDir) #File and directory operations
|
||||
privateFileAllList = []
|
||||
keyElement = []
|
||||
if fileDir != check_upgrade_path:
|
||||
if fileDir != check_upgrade_path: #Filter the script
|
||||
privateFileAllList = os.listdir(private_dict[fileDir])
|
||||
commonScriptList = list(set(fileAllList) & set(privateFileAllList))
|
||||
commonScriptList = [script for script in commonScriptList if "407" not in script]
|
||||
|
|
@ -237,7 +237,7 @@ class Pterodb():
|
|||
if key not in name:
|
||||
errMsg = "The script {0} name does not meet the specifications, it needs to contain {1}".format(name, key)
|
||||
self.writeLogFile(errMsg)
|
||||
raise Exception(errMsg)
|
||||
raise Exception(errMsg) #Exception handling
|
||||
|
||||
result = []
|
||||
if len(allList) != 0:
|
||||
|
|
@ -264,9 +264,9 @@ class Pterodb():
|
|||
file.write("START TRANSACTION;")
|
||||
file.write(os.linesep)
|
||||
file.write("SET IsInplaceUpgrade = on;")
|
||||
file.write(os.linesep)
|
||||
self.writeLogFile("fileDir is {0}, The list of files being written is {1}".format(fileDir, fileList))
|
||||
for each_file in fileList:
|
||||
file.write(os.linesep) #Open the file and write the transaction and setting statements
|
||||
self.writeLogFile("fileDir is {0}, The list of files being written is {1}".format(fileDir, fileList)) #Write file information
|
||||
for each_file in fileList: #Process each file
|
||||
if os.path.isfile("%s/%s" % (fileDir, each_file)):
|
||||
each_file_with_path = "%s/%s" % (fileDir, each_file)
|
||||
elif os.path.isfile("%s/%s" % (private_dict[fileDir], each_file)):
|
||||
|
|
@ -278,27 +278,34 @@ class Pterodb():
|
|||
for txt in open(each_file_with_path,'r'):
|
||||
file.write(txt)
|
||||
file.write(os.linesep)
|
||||
file.write("COMMIT;")
|
||||
file.write("COMMIT;") #Write a transaction commit statement
|
||||
file.write(os.linesep)
|
||||
file.close()
|
||||
file.close() #Close the file and complete the information record
|
||||
self.writeLogFile("Complate file {0} with the list:{1}".format(fileName, fileList))
|
||||
|
||||
def checkSqlResult(self, Type = "upgrade"):
|
||||
def checkSqlResult(self, Type = "upgrade"): #Check whether the SQL execution results contain ERROR
|
||||
cmd = "grep ERROR " + exec_sql_log
|
||||
(status, output) = commands.getstatusoutput(cmd)
|
||||
if(output.find("ERROR") != -1):
|
||||
raise Exception("Failed to execute catalog %s" % Type)
|
||||
cmd = "grep PANIC " + exec_sql_log
|
||||
cmd = "grep PANIC " + exec_sql_log #Check whether the SQL execution results contain PANIC
|
||||
(status, output) = commands.getstatusoutput(cmd)
|
||||
if(output.find("PANIC") != -1):
|
||||
raise Exception("Failed to execute catalog %s" % Type)
|
||||
cmd = "grep FATAL " + exec_sql_log
|
||||
cmd = "grep FATAL " + exec_sql_log #Check whether the execution result contains FATAL
|
||||
(status, output) = commands.getstatusoutput(cmd)
|
||||
if(output.find("FATAL") != -1):
|
||||
if(output.find("FATAL") != -1):
|
||||
raise Exception("Failed to execute catalog %s" % Type)
|
||||
|
||||
def upgrade_one_database(self, db_name):
|
||||
"""
|
||||
Upgrade a database
|
||||
|
||||
Parameters :
|
||||
db _ name ( str ) : Database name
|
||||
|
||||
Anomaly :
|
||||
Exception : An exception is thrown when the upgrade directory fails
|
||||
"""
|
||||
try:
|
||||
if db_name == "postgres":
|
||||
|
|
@ -321,6 +328,13 @@ class Pterodb():
|
|||
|
||||
def rollback_one_database(self, db_name):
|
||||
"""
|
||||
Roll back a database.
|
||||
|
||||
Args:
|
||||
db_name (str): The name of the database.
|
||||
|
||||
Raises:
|
||||
Exception: If rolling back the catalogs fails.
|
||||
"""
|
||||
try:
|
||||
if db_name == "postgres":
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ the author shall be liable for any damage, etc.
|
|||
char* flag(int b);
|
||||
void describe_char(int c);
|
||||
|
||||
// Function to return a flag string based on a boolean value
|
||||
#undef LONG_FLAG
|
||||
|
||||
char* flag(int b)
|
||||
|
|
@ -38,6 +39,7 @@ char* flag(int b)
|
|||
#endif
|
||||
}
|
||||
|
||||
// Function to describe the properties of a character
|
||||
void describe_char(int c)
|
||||
{
|
||||
unsigned char cp = c, up = toupper(c), lo = tolower(c);
|
||||
|
|
@ -49,6 +51,7 @@ void describe_char(int c)
|
|||
if (!isprint(lo))
|
||||
lo = ' ';
|
||||
|
||||
// Print the character's properties in a formatted line
|
||||
printf("chr#%-4d%2c%6s%6s%6s%6s%6s%6s%6s%6s%6s%6s%6s%4c%4c\n",
|
||||
c,
|
||||
cp,
|
||||
|
|
@ -72,6 +75,7 @@ int main()
|
|||
short c;
|
||||
char* cur_locale = NULL;
|
||||
|
||||
// Set the locale to the user's environment setting
|
||||
cur_locale = setlocale(LC_ALL, "");
|
||||
if (cur_locale)
|
||||
fprintf(stderr, "Successfully set locale to \"%s\"\n", cur_locale);
|
||||
|
|
@ -82,7 +86,10 @@ int main()
|
|||
return 1;
|
||||
}
|
||||
|
||||
// Print the table header
|
||||
printf("char# char alnum alpha cntrl digit lower graph print punct space upper xdigit lo up\n");
|
||||
|
||||
// Iterate from 0 to 255 and describe each character
|
||||
for (c = 0; c <= 255; c++)
|
||||
describe_char(c);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
DBMS: PostgreSQL 6.2b10
|
||||
//Information of the performance test results of the database system
|
||||
|
||||
|
||||
DBMS: PostgreSQL 6.2b10
|
||||
OS: FreeBSD 2.1.5-RELEASE
|
||||
HardWare: i586/90, 24M RAM, IDE
|
||||
StartUp: postmaster -B 256 '-o -S 2048' -S
|
||||
|
|
|
|||
|
|
@ -32,16 +32,23 @@ const uint32 BUFSIZE = 1024;
|
|||
|
||||
bool VerifyBeforeTest (const char* newval)
|
||||
{
|
||||
// Check if g_instance.whitebox_test_param_instance is already initialized with the same test file name
|
||||
if (g_instance.whitebox_test_param_instance &&
|
||||
strcmp(newval, g_instance.whitebox_test_param_instance->test_file_name) == 0) {
|
||||
elog(LOG, "AssignUstoreUnitTest: g_instance.whitebox_test_param_instance is already initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If g_instance.whitebox_test_param_instance is not initialized, allocate memory for it
|
||||
if (!g_instance.whitebox_test_param_instance) {
|
||||
g_instance.whitebox_test_param_instance =
|
||||
(WhiteboxTestParam *)palloc(sizeof(WhiteboxTestParam) * (MAX_UNIT_TEST));
|
||||
}
|
||||
|
||||
// Set the error level to WARNING for whitebox_test_param_instance
|
||||
g_instance.whitebox_test_param_instance->elevel = WARNING;
|
||||
|
||||
// Copy the test file name to whitebox_test_param_instance->test_file_name
|
||||
int rc = sprintf_s(g_instance.whitebox_test_param_instance->test_file_name, MAX_NAME_STR_LEN, "%s", newval);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
if (strcmp(newval, "") == 0) {
|
||||
|
|
@ -243,6 +250,7 @@ bool WhiteboxTestSleep(const char* functionName, int timeout, int skipIteration,
|
|||
}
|
||||
}
|
||||
|
||||
//The WhiteboxTestSuspend function suspends execution at a breakpoint for a specified timeout if enabled.
|
||||
bool WhiteboxTestSuspend(const char* functionName, int timeout, const bool& enabled)
|
||||
{
|
||||
int elapseTime = 0;
|
||||
|
|
@ -264,6 +272,7 @@ bool WhiteboxTestSuspend(const char* functionName, int timeout, const bool& enab
|
|||
}
|
||||
}
|
||||
|
||||
//this function iterates over the available test cases in the whitebox test parameters instance and searches for a matching functionName
|
||||
bool WhiteboxTestSetEnable(const char* functionName, bool enabled)
|
||||
{
|
||||
for (int i = 0; i < g_instance.whitebox_test_param_instance->num_testcase; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue