forked from huawei/openGauss-server
commit
3fe1bf4cb7
|
|
@ -451,6 +451,33 @@ const char* show_nodegroup_mode(void)
|
|||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
const int GetCustomParserId()
|
||||
{
|
||||
int id = 0;
|
||||
switch (u_sess->attr.attr_sql.sql_compatibility) {
|
||||
case A_FORMAT:
|
||||
id = DB_CMPT_A;
|
||||
break;
|
||||
case B_FORMAT:
|
||||
id = DB_CMPT_B;
|
||||
break;
|
||||
case C_FORMAT:
|
||||
id = DB_CMPT_C;
|
||||
break;
|
||||
case PG_FORMAT:
|
||||
id = DB_CMPT_PG;
|
||||
break;
|
||||
default:
|
||||
ereport(WARNING, (errmsg("Unknown sql compatibility: %d", u_sess->attr.attr_sql.sql_compatibility)));
|
||||
return -1;
|
||||
}
|
||||
Assert(id >= 0 && id < DB_CMPT_MAX);
|
||||
return id;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1307,6 +1307,17 @@ static void InitSqlConfigureNamesBool()
|
|||
NULL,
|
||||
NULL,
|
||||
NULL},
|
||||
{{"enable_custom_parser",
|
||||
PGC_USERSET,
|
||||
NODE_SINGLENODE,
|
||||
UNGROUPED,
|
||||
gettext_noop("Enables custom parser"),
|
||||
NULL},
|
||||
&u_sess->attr.attr_sql.enable_custom_parser,
|
||||
false,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL},
|
||||
#endif
|
||||
|
||||
{{"enable_partition_opfusion",
|
||||
|
|
|
|||
|
|
@ -102,6 +102,20 @@ extern bool is_func_need_cache(Oid funcid, const char* func_name);
|
|||
extern bool plpgsql_check_insert_colocate(
|
||||
Query* query, List* qry_part_attr_num, List* trig_part_attr_num, PLpgSQL_function* func);
|
||||
|
||||
typedef int (*plsql_parser)(void);
|
||||
static inline plsql_parser PlsqlParser(){
|
||||
int (*plsql_parser_hook)(void) = plpgsql_yyparse;
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
if (u_sess->attr.attr_sql.enable_custom_parser) {
|
||||
int id = GetCustomParserId();
|
||||
if (id >= 0 && g_instance.plsql_parser_hook[id] != NULL) {
|
||||
plsql_parser_hook = (int(*)(void))g_instance.plsql_parser_hook[id];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return plsql_parser_hook;
|
||||
}
|
||||
|
||||
/* ----------
|
||||
* plpgsql_compile Make an execution tree for a PL/pgSQL function.
|
||||
*
|
||||
|
|
@ -1098,7 +1112,7 @@ static PLpgSQL_function* do_compile(FunctionCallInfo fcinfo, HeapTuple proc_tup,
|
|||
*/
|
||||
bool saved_flag = u_sess->plsql_cxt.have_error;
|
||||
u_sess->plsql_cxt.have_error = false;
|
||||
parse_rc = plpgsql_yyparse();
|
||||
parse_rc = (*PlsqlParser())();
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
if (u_sess->plsql_cxt.have_error && u_sess->attr.attr_common.plsql_show_all_error) {
|
||||
u_sess->plsql_cxt.have_error = false;
|
||||
|
|
@ -1368,7 +1382,7 @@ PLpgSQL_function* plpgsql_compile_inline(char* proc_source)
|
|||
/*
|
||||
* Now parse the function's text
|
||||
*/
|
||||
parse_rc = plpgsql_yyparse();
|
||||
parse_rc = (*PlsqlParser())();
|
||||
if (parse_rc != 0) {
|
||||
ereport(ERROR, (errmodule(MOD_PLSQL), errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE),
|
||||
errmsg("Syntax parsing error, plpgsql parser returned %d", parse_rc)));
|
||||
|
|
|
|||
|
|
@ -816,6 +816,7 @@ void client_read_ended(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Do raw parsing (only).
|
||||
*
|
||||
|
|
@ -841,7 +842,16 @@ List* pg_parse_query(const char* query_string, List** query_string_locationlist)
|
|||
|
||||
PGSTAT_START_TIME_RECORD();
|
||||
|
||||
raw_parsetree_list = raw_parser(query_string, query_string_locationlist);
|
||||
List* (*parser_hook)(const char*, List**) = raw_parser;
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
if (u_sess->attr.attr_sql.enable_custom_parser) {
|
||||
int id = GetCustomParserId();
|
||||
if (id >= 0 && g_instance.raw_parser_hook[id] != NULL) {
|
||||
parser_hook = (List* (*)(const char*, List**))g_instance.raw_parser_hook[id];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
raw_parsetree_list = parser_hook(query_string, query_string_locationlist);
|
||||
|
||||
PGSTAT_END_TIME_RECORD(PARSE_TIME);
|
||||
|
||||
|
|
|
|||
|
|
@ -232,6 +232,9 @@ typedef struct knl_session_attr_sql {
|
|||
int pldebugger_timeout;
|
||||
bool for_print_tuple;
|
||||
bool numeric_out_for_format;
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
bool enable_custom_parser;
|
||||
#endif
|
||||
} knl_session_attr_sql;
|
||||
|
||||
#endif /* SRC_INCLUDE_KNL_KNL_SESSION_ATTR_SQL */
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ const int NUM_PERCENTILE_COUNT = 2;
|
|||
const int INIT_NUMA_ALLOC_COUNT = 32;
|
||||
const int HOTKEY_ABANDON_LENGTH = 100;
|
||||
const int MAX_GLOBAL_CACHEMEM_NUM = 128;
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
const int DB_CMPT_MAX = 4;
|
||||
#endif
|
||||
|
||||
enum knl_virtual_role {
|
||||
VUNKNOWN = 0,
|
||||
|
|
@ -1030,6 +1033,11 @@ typedef struct knl_instance_context {
|
|||
knl_g_streaming_dr_context streaming_dr_cxt;
|
||||
struct PLGlobalPackageRuntimeCache* global_session_pkg;
|
||||
pg_atomic_uint32 extensionNum;
|
||||
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
void *raw_parser_hook[DB_CMPT_MAX];
|
||||
void *plsql_parser_hook[DB_CMPT_MAX];
|
||||
#endif
|
||||
} knl_instance_context;
|
||||
|
||||
extern long random();
|
||||
|
|
|
|||
|
|
@ -332,6 +332,10 @@ extern bool exist_logic_cluster();
|
|||
#ifdef ENABLE_MULTIPLE_NODES
|
||||
extern const char* show_nodegroup_mode(void);
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
extern const int GetCustomParserId();
|
||||
#endif
|
||||
extern const char* show_lcgroup_name();
|
||||
extern Oid get_pgxc_logic_groupoid(Oid roleid);
|
||||
extern Oid get_pgxc_logic_groupoid(const char* groupname);
|
||||
|
|
|
|||
Loading…
Reference in New Issue