Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support search_path in SET too #2261

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions ydb/library/yql/sql/pg/pg_sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2129,21 +2129,26 @@ class TConverter : public IPGParseEvents {
}

auto name = to_lower(TString(value->name));
if (isSetConfig) {
if (name == "search_path") {
if (ListLength(value->args) != 1) {
AddError(TStringBuilder() << "VariableSetStmt, expected 1 arg, but got: " << ListLength(value->args));
return nullptr;
}
auto val = ListNodeNth(value->args, 0);
if (!isSetConfig) {
if (NodeTag(val) == T_A_Const) {
val = (const Node*)&CAST_NODE(A_Const, val)->val;
} else {
AddError(TStringBuilder() << "VariableSetStmt, expected const for " << value->name << " option");
return nullptr;
}
}

if (NodeTag(val) != T_String) {
AddError(TStringBuilder() << "VariableSetStmt, expected string literal for " << value->name << " option");
return nullptr;
}
TString rawStr = to_lower(TString(StrVal(val)));
if (name != "search_path") {
AddError(TStringBuilder() << "VariableSetStmt, set_config doesn't support that option:" << name);
return nullptr;
}
if (rawStr != "pg_catalog" && rawStr != "public" && rawStr != "" && rawStr != "information_schema") {
AddError(TStringBuilder() << "VariableSetStmt, search path supports only 'information_schema', 'public', 'pg_catalog', '' but got: '" << rawStr << "'");
return nullptr;
Expand All @@ -2154,6 +2159,13 @@ class TConverter : public IPGParseEvents {
return State.Statements.back();
}

if (isSetConfig) {
if (name != "search_path") {
AddError(TStringBuilder() << "VariableSetStmt, set_config doesn't support that option:" << name);
return nullptr;
}
}

if (name == "useblocks" || name == "emitaggapply") {
if (ListLength(value->args) != 1) {
AddError(TStringBuilder() << "VariableSetStmt, expected 1 arg, but got: " << ListLength(value->args));
Expand Down
Loading