diff options
-rw-r--r-- | ydb/core/kqp/ut/pg/pg_catalog_ut.cpp | 2 | ||||
-rw-r--r-- | ydb/library/yql/parser/pg_catalog/safe_procs.h | 14 | ||||
-rw-r--r-- | ydb/library/yql/parser/pg_wrapper/comp_factory.cpp | 38 | ||||
-rw-r--r-- | ydb/library/yql/sql/pg/pg_sql.cpp | 6 |
4 files changed, 56 insertions, 4 deletions
diff --git a/ydb/core/kqp/ut/pg/pg_catalog_ut.cpp b/ydb/core/kqp/ut/pg/pg_catalog_ut.cpp index 21ce8a8d38..d6b6d82d8c 100644 --- a/ydb/core/kqp/ut/pg/pg_catalog_ut.cpp +++ b/ydb/core/kqp/ut/pg/pg_catalog_ut.cpp @@ -459,7 +459,7 @@ Y_UNIT_TEST_SUITE(PgCatalog) { UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString()); UNIT_ASSERT_C(!result.GetResultSets().empty(), "no result sets"); CompareYson( - Sprintf("[[\"%u\"]]", experimentalPg ? 208 : 205), + Sprintf("[[\"%u\"]]", experimentalPg ? 214 : 211), FormatResultSetYson(result.GetResultSet(0))); } } diff --git a/ydb/library/yql/parser/pg_catalog/safe_procs.h b/ydb/library/yql/parser/pg_catalog/safe_procs.h index aeeead2077..c4d91e029f 100644 --- a/ydb/library/yql/parser/pg_catalog/safe_procs.h +++ b/ydb/library/yql/parser/pg_catalog/safe_procs.h @@ -4,3 +4,17 @@ "pg_total_relation_size", "row_to_json", "version", + +"set_config",//pgadmin +"pg_is_in_recovery",//pgadmin +"pg_is_wal_replay_paused",//pgadmin +"has_database_privilege",//pgadmin +"pg_backend_pid",//pgadmin +"has_schema_privilege",//pgadmin + +"pg_encoding_to_char",//psql +"pg_function_is_visible",//psql +"pg_get_function_result",//psql +"pg_get_function_arguments",//psql +"pg_table_is_visible",//psql + diff --git a/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp b/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp index a3fcc5e696..a7c7c159ad 100644 --- a/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp +++ b/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp @@ -435,7 +435,7 @@ public: {"rolname", [](ui32 index) { return PointerDatumToPod((Datum)MakeFixedString(index == 1 ? "postgres" : *PGGetGUCSetting("ydb_user"), NAMEDATALEN)); }}, - {"oid", [](ui32) { return ScalarDatumToPod(ObjectIdGetDatum(1)); }}, + {"oid", [](ui32 index) { return ScalarDatumToPod(ObjectIdGetDatum(index)); }}, {"rolbypassrls", [](ui32) { return ScalarDatumToPod(BoolGetDatum(true)); }}, {"rolsuper", [](ui32) { return ScalarDatumToPod(BoolGetDatum(true)); }}, {"rolinherit", [](ui32) { return ScalarDatumToPod(BoolGetDatum(true)); }}, @@ -453,6 +453,26 @@ public: }; ApplyFillers(AllPgRolesFillers, Y_ARRAY_SIZE(AllPgRolesFillers), PgRolesFillers_); + } else if (Table_ == "pg_user") { + static const std::pair<const char*, TPgUserFiller> AllPgUserFillers[] = { + {"usename", [](ui32 index) { + return PointerDatumToPod((Datum)MakeFixedString(index == 1 ? "postgres" : *PGGetGUCSetting("ydb_user"), NAMEDATALEN)); + }}, + {"usesysid", [](ui32 index) { return ScalarDatumToPod(ObjectIdGetDatum(index)); }}, + {"usecreatedb", [](ui32) { return ScalarDatumToPod(BoolGetDatum(true)); }}, + {"usesuper", [](ui32) { return ScalarDatumToPod(BoolGetDatum(true)); }}, + {"userepl", [](ui32) { return ScalarDatumToPod(BoolGetDatum(true)); }}, + {"usebypassrls", [](ui32) { return ScalarDatumToPod(BoolGetDatum(true)); }}, + {"passwd", [](ui32) { return NUdf::TUnboxedValuePod(); }}, + {"valuntil", [](ui32) { return NUdf::TUnboxedValuePod(); }}, + {"useconfig", [](ui32) { return PointerDatumToPod(MakeArrayOfText({ + "search_path=public", + "default_transaction_isolation=serializable", + "standard_conforming_strings=on", + })); }}, + }; + + ApplyFillers(AllPgUserFillers, Y_ARRAY_SIZE(AllPgUserFillers), PgUserFillers_); } else if (Table_ == "pg_stat_database") { static const std::pair<const char*, TPgDatabaseStatFiller> AllPgDatabaseStatFillers[] = { {"datid", [](ui32 index) { return ScalarDatumToPod(ObjectIdGetDatum(index ? 3 : 0)); }}, @@ -804,6 +824,20 @@ public: sysFiller.Fill(items); rows.emplace_back(row); } + } else if (Table_ == "pg_user") { + ui32 tableSize = PGGetGUCSetting("ydb_user") ? 2 : 1; + for (ui32 index = 1; index <= tableSize; ++index) { + NUdf::TUnboxedValue* items; + auto row = compCtx.HolderFactory.CreateDirectArrayHolder(PgUserFillers_.size(), items); + for (ui32 i = 0; i < PgUserFillers_.size(); ++i) { + if (PgUserFillers_[i]) { + items[i] = PgUserFillers_[i](index); + } + } + + sysFiller.Fill(items); + rows.emplace_back(row); + } } else if (Table_ == "pg_stat_database") { for (ui32 index = 0; index <= 1; ++index) { NUdf::TUnboxedValue* items; @@ -956,6 +990,8 @@ private: TVector<TPgAmFiller> PgAmFillers_; using TPgRolesFiller = NUdf::TUnboxedValuePod(*)(ui32 index); TVector<TPgRolesFiller> PgRolesFillers_; + using TPgUserFiller = NUdf::TUnboxedValuePod(*)(ui32 index); + TVector<TPgUserFiller> PgUserFillers_; using TPgDatabaseStatFiller = NUdf::TUnboxedValuePod(*)(ui32 index); TVector<TPgDatabaseStatFiller> PgDatabaseStatFillers_; diff --git a/ydb/library/yql/sql/pg/pg_sql.cpp b/ydb/library/yql/sql/pg/pg_sql.cpp index 4411804165..9b560d7e3c 100644 --- a/ydb/library/yql/sql/pg/pg_sql.cpp +++ b/ydb/library/yql/sql/pg/pg_sql.cpp @@ -3505,8 +3505,10 @@ public: ); case SVFOP_CURRENT_USER: case SVFOP_CURRENT_ROLE: - case SVFOP_USER: - return L(A("PgConst"), QA("postgres"), L(A("PgType"), QA("name"))); + case SVFOP_USER: { + auto user = Settings.GUCSettings->Get("ydb_user"); + return L(A("PgConst"), user ? QAX(TString(*user)) : QA("postgres"), L(A("PgType"), QA("name"))); + } case SVFOP_CURRENT_CATALOG: { std::optional<TString> database; if (Settings.GUCSettings) { |