aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarsaly <marsaly@yandex-team.com>2023-01-20 13:26:06 +0300
committermarsaly <marsaly@yandex-team.com>2023-01-20 13:26:06 +0300
commit7b2b58f884db5056c37957fc070a64a2bb7ead82 (patch)
tree115f06cae6aac4c0f56623a2eb9eb52999645ea5
parent4a418cb975d140f0821f370d538b9c52286f8d7b (diff)
downloadydb-7b2b58f884db5056c37957fc070a64a2bb7ead82.tar.gz
- fix PG parser making columns lower case in SELECTs
Fixed PG parser making columns lower case in SELECTs
-rw-r--r--ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scan.c4
-rw-r--r--ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scansup.c11
-rw-r--r--ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/replication/repl_scanner.c2
-rw-r--r--ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/misc.c2
-rw-r--r--ydb/library/yql/parser/pg_wrapper/postgresql/src/include/parser/scansup.h2
5 files changed, 17 insertions, 4 deletions
diff --git a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scan.c b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scan.c
index bf3e17fffbd..4f006b6962f 100644
--- a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scan.c
+++ b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scan.c
@@ -6272,7 +6272,7 @@ YY_RULE_SETUP
/* throw back all but the initial u/U */
yyless(1);
/* and treat it as {identifier} */
- ident = downcase_identifier(yytext, yyleng, false, false);
+ ident = copy_identifier(yytext, yyleng);
yylval->str = ident;
return IDENT;
}
@@ -6553,7 +6553,7 @@ YY_RULE_SETUP
* No. Convert the identifier to lower case, and truncate
* if necessary.
*/
- ident = downcase_identifier(yytext, yyleng, false, false);
+ ident = copy_identifier(yytext, yyleng);
yylval->str = ident;
return IDENT;
}
diff --git a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scansup.c b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scansup.c
index f55caccddfd..d083531052a 100644
--- a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scansup.c
+++ b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser/scansup.c
@@ -79,6 +79,17 @@ downcase_identifier(const char *ident, int len, bool warn, bool truncate)
return result;
}
+char *
+copy_identifier(const char *ident, int len)
+{
+ char *result;
+
+ result = palloc(len + 1);
+ memcpy(result, ident, len);
+ result[len] = '\0';
+
+ return result;
+}
/*
* truncate_identifier() --- truncate an identifier to NAMEDATALEN-1 bytes.
diff --git a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/replication/repl_scanner.c b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/replication/repl_scanner.c
index 98b0a2412ad..80e0cd7f543 100644
--- a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/replication/repl_scanner.c
+++ b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/replication/repl_scanner.c
@@ -1516,7 +1516,7 @@ YY_RULE_SETUP
{
int len = strlen(yytext);
- yylval.str = downcase_identifier(yytext, len, false, false);
+ yylval.str = copy_identifier(yytext, len);
return IDENT;
}
YY_BREAK
diff --git a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/misc.c b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/misc.c
index 88faf4dfd72..f98f0ae332e 100644
--- a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/misc.c
+++ b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/misc.c
@@ -767,7 +767,7 @@ parse_ident(PG_FUNCTION_ARGS)
* being too long. It's easy enough for the user to get the
* truncated names by casting our output to name[].
*/
- downname = downcase_identifier(curname, len, false, false);
+ downname = copy_identifier(curname, len);
part = cstring_to_text_with_len(downname, len);
astate = accumArrayResult(astate, PointerGetDatum(part), false,
TEXTOID, CurrentMemoryContext);
diff --git a/ydb/library/yql/parser/pg_wrapper/postgresql/src/include/parser/scansup.h b/ydb/library/yql/parser/pg_wrapper/postgresql/src/include/parser/scansup.h
index 813327b7074..a767d0858fb 100644
--- a/ydb/library/yql/parser/pg_wrapper/postgresql/src/include/parser/scansup.h
+++ b/ydb/library/yql/parser/pg_wrapper/postgresql/src/include/parser/scansup.h
@@ -20,6 +20,8 @@ extern char *downcase_truncate_identifier(const char *ident, int len,
extern char *downcase_identifier(const char *ident, int len,
bool warn, bool truncate);
+extern char * copy_identifier(const char *ident, int len);
+
extern void truncate_identifier(char *ident, int len, bool warn);
extern bool scanner_isspace(char ch);