Ps prepare store query for sql audit
This commit is contained in:
@ -1519,6 +1519,7 @@ int ObSql::handle_ps_prepare(const ObString &stmt,
|
|||||||
// open_cursors is 0 to indicate a special state, no limit is set
|
// open_cursors is 0 to indicate a special state, no limit is set
|
||||||
#define NEED_CHECK_SESS_MAX_PS_HANDLE_LIMIT(v) (0 == v ? false : true)
|
#define NEED_CHECK_SESS_MAX_PS_HANDLE_LIMIT(v) (0 == v ? false : true)
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
ObString cur_query;
|
||||||
// trimed_stmt仅用于query empty检查, prepare语句需要用原始语句, 避免checksum不一致
|
// trimed_stmt仅用于query empty检查, prepare语句需要用原始语句, 避免checksum不一致
|
||||||
ObString trimed_stmt = const_cast<ObString &>(stmt).trim();
|
ObString trimed_stmt = const_cast<ObString &>(stmt).trim();
|
||||||
if (trimed_stmt.empty()) {
|
if (trimed_stmt.empty()) {
|
||||||
@ -1532,6 +1533,7 @@ int ObSql::handle_ps_prepare(const ObString &stmt,
|
|||||||
ObSQLSessionInfo &session = result.get_session();
|
ObSQLSessionInfo &session = result.get_session();
|
||||||
ObPsCache *ps_cache = session.get_ps_cache();
|
ObPsCache *ps_cache = session.get_ps_cache();
|
||||||
ObExecContext &ectx = result.get_exec_context();
|
ObExecContext &ectx = result.get_exec_context();
|
||||||
|
ObIAllocator &allocator = result.get_mem_pool();
|
||||||
ObPhysicalPlanCtx *pctx = ectx.get_physical_plan_ctx();
|
ObPhysicalPlanCtx *pctx = ectx.get_physical_plan_ctx();
|
||||||
ObSchemaGetterGuard *schema_guard = context.schema_guard_;
|
ObSchemaGetterGuard *schema_guard = context.schema_guard_;
|
||||||
ectx.set_is_ps_prepare_stage(true);
|
ectx.set_is_ps_prepare_stage(true);
|
||||||
@ -1545,6 +1547,8 @@ int ObSql::handle_ps_prepare(const ObString &stmt,
|
|||||||
ret = OB_INVALID_ARGUMENT;
|
ret = OB_INVALID_ARGUMENT;
|
||||||
LOG_ERROR("physical plan context or ps plan cache is NULL or schema_guard is null",
|
LOG_ERROR("physical plan context or ps plan cache is NULL or schema_guard is null",
|
||||||
K(ret), K(pctx), K(ps_cache));
|
K(ret), K(pctx), K(ps_cache));
|
||||||
|
} else if (OB_FAIL(ob_write_string(allocator, session.get_current_query_string(), cur_query))) {
|
||||||
|
LOG_WARN("failed to write string", K(ret));
|
||||||
} else if (OB_FAIL(session.store_query_string(trimed_stmt))) {
|
} else if (OB_FAIL(session.store_query_string(trimed_stmt))) {
|
||||||
LOG_WARN("store query string fail", K(ret));
|
LOG_WARN("store query string fail", K(ret));
|
||||||
} else {
|
} else {
|
||||||
@ -1660,6 +1664,7 @@ int ObSql::handle_ps_prepare(const ObString &stmt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
OZ (session.store_query_string(cur_query));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user