diff options
author | vvvv <vvvv@yandex-team.ru> | 2022-02-21 14:28:52 +0300 |
---|---|---|
committer | vvvv <vvvv@yandex-team.ru> | 2022-02-21 14:28:52 +0300 |
commit | 8c5813a6d7b1c3161955f13c3130615490f781f2 (patch) | |
tree | 2a298851b971bc8e52c4286dc78b4326b9e360ab | |
parent | 08b3d1347089ac5fe57bcbac2df57dd5aaeefa62 (diff) | |
download | ydb-8c5813a6d7b1c3161955f13c3130615490f781f2.tar.gz |
YQL-13710 more patches
ref:312d4f13f681bc05922f175e4f31da2941587f97
8 files changed, 41 insertions, 24 deletions
diff --git a/ydb/library/yql/parser/pg_query_wrapper/copy_src.py b/ydb/library/yql/parser/pg_query_wrapper/copy_src.py index 100bcb1d0d..8e33f5eb3e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/copy_src.py +++ b/ydb/library/yql/parser/pg_query_wrapper/copy_src.py @@ -14,6 +14,18 @@ def_type = None def_var = None ignore_func = False +to_add_const = set([ + "nullSemAction", + "sentinel", + "backslash_quote", + "gistBufferingOptValues", + "boolRelOpts", + "intRelOpts", + "realRelOpts", + "viewCheckOptValues", + "enumRelOpts", + "stringRelOpts"]) + def fix_line(line, all_lines, pos): global define_for_yylval if line.startswith("#define yylval"): @@ -92,6 +104,20 @@ def fix_line(line, all_lines, pos): ret = None found_v = None + for v in to_add_const: + if v in norm: + ret = line \ + .replace("static","static const") \ + .replace("relopt_enum_elt_def","const relopt_enum_elt_def") + + if v == "backslash_quote": + ret = ret.replace("int","const int") + + if v == "nullSemAction": + ret = ret.replace("JsonSemAction","const JsonSemAction") + + return ret + for v in all_vars: if " " + v + " " in norm or " " + v + ";" in norm or " " + v + "[" in norm or \ "*" + v + " " in norm or "*" + v + ";" in norm or "*" + v + "[" in norm: @@ -183,17 +209,8 @@ def get_vars(): all_vars.remove("Dummy_trace") - all_vars.remove("backslash_quote") - all_vars.remove("sentinel") # rbtree.c - all_vars.remove("nullSemAction") - - all_vars.remove("gistBufferingOptValues") - all_vars.remove("boolRelOpts") - all_vars.remove("intRelOpts") - all_vars.remove("realRelOpts") - all_vars.remove("viewCheckOptValues") - all_vars.remove("enumRelOpts") - all_vars.remove("stringRelOpts") + for x in to_add_const: + all_vars.remove(x) all_vars.add("yychar") all_vars.add("yyin") diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/reloptions.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/reloptions.c index 79c052a97c..2a531e1093 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/reloptions.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/reloptions.c @@ -93,7 +93,7 @@ * value has no effect until the next VACUUM, so no need for stronger lock. */ -static relopt_bool boolRelOpts[] = +static const relopt_bool boolRelOpts[] = { { { @@ -172,7 +172,7 @@ static relopt_bool boolRelOpts[] = {{NULL}} }; -static relopt_int intRelOpts[] = +static const relopt_int intRelOpts[] = { { { @@ -387,7 +387,7 @@ static relopt_int intRelOpts[] = {{NULL}} }; -static relopt_real realRelOpts[] = +static const relopt_real realRelOpts[] = { { { @@ -475,7 +475,7 @@ static relopt_real realRelOpts[] = }; /* values from GistOptBufferingMode */ -relopt_enum_elt_def gistBufferingOptValues[] = +const relopt_enum_elt_def gistBufferingOptValues[] = { {"auto", GIST_OPTION_BUFFERING_AUTO}, {"on", GIST_OPTION_BUFFERING_ON}, @@ -484,7 +484,7 @@ relopt_enum_elt_def gistBufferingOptValues[] = }; /* values from ViewOptCheckOption */ -relopt_enum_elt_def viewCheckOptValues[] = +const relopt_enum_elt_def viewCheckOptValues[] = { /* no value for NOT_SET */ {"local", VIEW_OPTION_CHECK_OPTION_LOCAL}, @@ -492,7 +492,7 @@ relopt_enum_elt_def viewCheckOptValues[] = {(const char *) NULL} /* list terminator */ }; -static relopt_enum enumRelOpts[] = +static const relopt_enum enumRelOpts[] = { { { @@ -520,7 +520,7 @@ static relopt_enum enumRelOpts[] = {{NULL}} }; -static relopt_string stringRelOpts[] = +static const relopt_string stringRelOpts[] = { /* list terminator */ {{NULL}} diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/lib/rbtree.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/lib/rbtree.c index 28681b8f61..4f3a0fe4ae 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/lib/rbtree.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/lib/rbtree.c @@ -60,7 +60,7 @@ struct RBTree */ #define RBTNIL (&sentinel) -static RBTNode sentinel = +static const RBTNode sentinel = { RBTBLACK, RBTNIL, RBTNIL, NULL }; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/scan.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/scan.c index f89b78bd65..82070bd9e7 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/scan.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/scan.c @@ -5136,7 +5136,7 @@ fprintf_to_ereport(const char *fmt, const char *msg) * as such, changing their values can induce very unintuitive behavior. * But we shall have to live with it until we can remove these variables. */ -int backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING; +const int backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING; __thread bool escape_string_warning = true; __thread bool standard_conforming_strings = true; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc.c index 34c47c7923..1275c08f1b 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc.c @@ -377,7 +377,7 @@ StaticAssertDecl(lengthof(xmloption_options) == (XMLOPTION_CONTENT + 2), * Although only "on", "off", and "safe_encoding" are documented, we * accept all the likely variants of "on" and "off". */ -static const struct config_enum_entry backslash_quote_options[] = { +static const const struct config_enum_entry backslash_quote_options[] = { {"safe_encoding", BACKSLASH_QUOTE_SAFE_ENCODING, false}, {"on", BACKSLASH_QUOTE_ON, false}, {"off", BACKSLASH_QUOTE_OFF, false}, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/jsonapi.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/jsonapi.c index dfc14335f0..f84fc93264 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/jsonapi.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/jsonapi.c @@ -64,7 +64,7 @@ static JsonParseErrorType report_parse_error(JsonParseContext ctx, JsonLexContex static char *extract_token(JsonLexContext *lex); /* the null action object used for pure validation */ -JsonSemAction nullSemAction = +const JsonSemAction nullSemAction = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/common/jsonapi.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/common/jsonapi.h index bcfd57cc53..1f0449623e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/common/jsonapi.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/common/jsonapi.h @@ -128,7 +128,7 @@ extern JsonParseErrorType pg_parse_json(JsonLexContext *lex, JsonSemAction *sem); /* the null action object used for pure validation */ -extern JsonSemAction nullSemAction; +extern const JsonSemAction nullSemAction; /* * json_count_array_elements performs a fast secondary parse to determine the diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/parser/parser.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/parser/parser.h index 32a88aeb09..94a77d2665 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/parser/parser.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/parser/parser.h @@ -26,7 +26,7 @@ typedef enum } BackslashQuoteType; /* GUC variables in scan.l (every one of these is a bad idea :-() */ -extern int backslash_quote; +extern const int backslash_quote; extern __thread bool escape_string_warning; extern __thread PGDLLIMPORT bool standard_conforming_strings; |