!3730 修改diagnostics兼容导致的内存溢出和fast check缺陷
Merge pull request !3730 from 暖阳/diagnostics
This commit is contained in:
@ -5806,34 +5806,21 @@ void cleanErrorDataArea(ErrorDataArea *errorDataArea)
|
||||
ListCell *lc = NULL;
|
||||
foreach (lc, errorDataArea->sqlErrorDataList) {
|
||||
DolphinErrorData *eData = (DolphinErrorData *)lfirst(lc);
|
||||
if (eData->errorcode)
|
||||
pfree_ext(eData->errorcode);
|
||||
if (eData->sqlstatestr)
|
||||
pfree_ext(eData->sqlstatestr);
|
||||
if (eData->class_origin)
|
||||
pfree_ext(eData->class_origin);
|
||||
if (eData->subclass_origin)
|
||||
pfree_ext(eData->subclass_origin);
|
||||
if (eData->constraint_catalog)
|
||||
pfree_ext(eData->constraint_catalog);
|
||||
if (eData->constraint_schema)
|
||||
pfree_ext(eData->constraint_schema);
|
||||
if (eData->constraint_name)
|
||||
pfree_ext(eData->constraint_name);
|
||||
if (eData->catalog_name)
|
||||
pfree_ext(eData->catalog_name);
|
||||
if (eData->schema_name)
|
||||
pfree_ext(eData->schema_name);
|
||||
if (eData->table_name)
|
||||
pfree_ext(eData->table_name);
|
||||
if (eData->column_name)
|
||||
pfree_ext(eData->column_name);
|
||||
if (eData->cursor_name)
|
||||
pfree_ext(eData->cursor_name);
|
||||
if (eData->message_text)
|
||||
pfree_ext(eData->message_text);
|
||||
pfree_ext(eData->errorcode);
|
||||
pfree_ext(eData->sqlstatestr);
|
||||
pfree_ext(eData->class_origin);
|
||||
pfree_ext(eData->subclass_origin);
|
||||
pfree_ext(eData->constraint_catalog);
|
||||
pfree_ext(eData->constraint_schema);
|
||||
pfree_ext(eData->constraint_name);
|
||||
pfree_ext(eData->catalog_name);
|
||||
pfree_ext(eData->schema_name);
|
||||
pfree_ext(eData->table_name);
|
||||
pfree_ext(eData->column_name);
|
||||
pfree_ext(eData->cursor_name);
|
||||
pfree_ext(eData->message_text);
|
||||
}
|
||||
list_free_ext(errorDataArea->sqlErrorDataList);
|
||||
list_free_deep(errorDataArea->sqlErrorDataList);
|
||||
errorDataArea->sqlErrorDataList = NIL;
|
||||
errorDataArea->current_edata_count = 0;
|
||||
for (int i = 0; i <= enum_dolphin_error_level::B_END; i++) {
|
||||
@ -5969,7 +5956,9 @@ void resetErrorDataArea(bool stacked, bool handler_active)
|
||||
copyErrorDataArea(errorDataArea, lastErrorDataArea);
|
||||
}
|
||||
} else {
|
||||
cleanErrorDataArea(lastErrorDataArea);
|
||||
if (!handler_active) {
|
||||
cleanErrorDataArea(lastErrorDataArea);
|
||||
}
|
||||
}
|
||||
cleanErrorDataArea(errorDataArea);
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
@ -6274,7 +6263,7 @@ void getDiagnosticsInfo(List* condInfo, bool hasCondNum, List* condNum)
|
||||
int conditionNum = getConditionNum(condNum);
|
||||
|
||||
if (conditionNum < 1 || conditionNum > condCount) {
|
||||
ErrorData* edata = &t_thrd.log_cxt.errordata[t_thrd.log_cxt.errordata_stack_depth];
|
||||
ErrorData* edata = (ErrorData *)palloc0(sizeof(ErrorData));
|
||||
edata->elevel = ERROR;
|
||||
edata->sqlerrcode = ERRCODE_INVALID_CONDITION_NUMBER;
|
||||
edata->message = "Invalid condition number";
|
||||
@ -6282,6 +6271,7 @@ void getDiagnosticsInfo(List* condInfo, bool hasCondNum, List* condNum)
|
||||
edata->cons_name = edata->catalog_name = edata->schema_name = edata->table_name = edata->column_name = edata->cursor_name = NULL;
|
||||
copyErrorDataArea(u_sess->dolphin_errdata_ctx.lastErrorDataArea, u_sess->dolphin_errdata_ctx.errorDataArea);
|
||||
pushErrorData(edata);
|
||||
pfree_ext(edata);
|
||||
FreeStringInfo(&buf);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2936,11 +2936,13 @@ static int exec_exception_handler(PLpgSQL_execstate* estate, PLpgSQL_stmt_block*
|
||||
|
||||
if (exception_matches_conditions(edata, exception->conditions)) {
|
||||
|
||||
u_sess->dolphin_errdata_ctx.handler_active = true;
|
||||
estate->handler_level = estate->block_level + 1;
|
||||
resetErrorDataArea(true, u_sess->dolphin_errdata_ctx.handler_active);
|
||||
pushErrorData(edata);
|
||||
copyErrorDataArea(u_sess->dolphin_errdata_ctx.errorDataArea, u_sess->dolphin_errdata_ctx.lastErrorDataArea);
|
||||
if (DB_IS_CMPT(B_FORMAT)) {
|
||||
u_sess->dolphin_errdata_ctx.handler_active = true;
|
||||
estate->handler_level = estate->block_level + 1;
|
||||
resetErrorDataArea(true, u_sess->dolphin_errdata_ctx.handler_active);
|
||||
pushErrorData(edata);
|
||||
copyErrorDataArea(u_sess->dolphin_errdata_ctx.errorDataArea, u_sess->dolphin_errdata_ctx.lastErrorDataArea);
|
||||
}
|
||||
/*
|
||||
* Initialize the magic SQLSTATE and SQLERRM variables for
|
||||
* the exception block. We needn't do this until we have
|
||||
@ -4400,7 +4402,7 @@ static int exec_stmt_b_getdiag(PLpgSQL_execstate* estate, PLpgSQL_stmt_getdiag*
|
||||
|
||||
if (stmt->has_cond) {
|
||||
if (condition_number < 1 || condition_number > condCount) {
|
||||
ErrorData* edata = &t_thrd.log_cxt.errordata[t_thrd.log_cxt.errordata_stack_depth];
|
||||
ErrorData* edata = (ErrorData *)palloc0(sizeof(ErrorData));
|
||||
edata->elevel = ERROR;
|
||||
edata->sqlerrcode = ERRCODE_INVALID_CONDITION_NUMBER;
|
||||
edata->message = "Invalid condition number";
|
||||
@ -4408,6 +4410,7 @@ static int exec_stmt_b_getdiag(PLpgSQL_execstate* estate, PLpgSQL_stmt_getdiag*
|
||||
edata->cons_name = edata->catalog_name = edata->schema_name = edata->table_name = edata->column_name = edata->cursor_name = NULL;
|
||||
copyErrorDataArea(u_sess->dolphin_errdata_ctx.lastErrorDataArea, u_sess->dolphin_errdata_ctx.errorDataArea);
|
||||
pushErrorData(edata);
|
||||
pfree_ext(edata);
|
||||
FreeStringInfo(&buf);
|
||||
return PLPGSQL_RC_OK;
|
||||
}
|
||||
|
||||
@ -1336,9 +1336,8 @@ show warnings;
|
||||
---------+-------+---------------------------
|
||||
Error | 42P01 | table "t1" does not exist
|
||||
Warning | 64 | column is not defined2222
|
||||
Warning | 64 | column is not defined2222
|
||||
Warning | 64 | column is not defined
|
||||
(4 rows)
|
||||
(3 rows)
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
NOTICE: table "t1" does not exist, skipping
|
||||
|
||||
Reference in New Issue
Block a user