Skip to content

Commit cc45e01

Browse files
authored
Merge 3d60237 into 658eb36
2 parents 658eb36 + 3d60237 commit cc45e01

File tree

12 files changed

+199
-9
lines changed

12 files changed

+199
-9
lines changed

ydb/library/yql/parser/pg_catalog/catalog.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,8 @@ struct TCatalog {
14171417
{"pg_catalog", "pg_description"},
14181418
{"pg_catalog", "pg_am"},
14191419
{"pg_catalog", "pg_namespace"},
1420+
{"pg_catalog", "pg_auth_members"},
1421+
{"pg_catalog", "pg_roles"},
14201422
{"information_schema", "tables"},
14211423
{"information_schema", "columns"},
14221424
{"information_schema", "table_constraints"},
@@ -1490,6 +1492,24 @@ struct TCatalog {
14901492
{"pg_catalog", "pg_namespace", "nspname", "name"},
14911493
{"pg_catalog", "pg_namespace", "oid", "oid"},
14921494

1495+
{"pg_catalog", "pg_auth_members", "roleid", "oid"},
1496+
{"pg_catalog", "pg_auth_members", "member", "oid"},
1497+
{"pg_catalog", "pg_auth_members", "grantor", "oid"},
1498+
{"pg_catalog", "pg_auth_members", "admin_option", "bool"},
1499+
1500+
{"pg_catalog", "pg_roles", "rolname", "name"},
1501+
{"pg_catalog", "pg_roles", "oid", "oid"},
1502+
{"pg_catalog", "pg_roles", "rolbypassrls", "bool"},
1503+
{"pg_catalog", "pg_roles", "rolcanlogin", "bool"},
1504+
{"pg_catalog", "pg_roles", "rolconfig", "_text"},
1505+
{"pg_catalog", "pg_roles", "rolconnlimit", "int4"},
1506+
{"pg_catalog", "pg_roles", "rolcreatedb", "bool"},
1507+
{"pg_catalog", "pg_roles", "rolcreaterole", "bool"},
1508+
{"pg_catalog", "pg_roles", "rolinherit", "bool"},
1509+
{"pg_catalog", "pg_roles", "rolreplication", "bool"},
1510+
{"pg_catalog", "pg_roles", "rolsuper", "bool"},
1511+
{"pg_catalog", "pg_roles", "rolvaliduntil", "timestamptz"},
1512+
14931513
{"information_schema", "tables", "table_schema", "name"},
14941514
{"information_schema", "tables", "table_name", "name"},
14951515

ydb/library/yql/parser/pg_wrapper/comp_factory.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,20 @@ const MemoryContextMethods MkqlMethods = {
184184
#endif
185185
};
186186

187+
Datum MakeArrayOfText(const TVector<TString>& arr) {
188+
TVector<Datum> elems(arr.size());
189+
for (size_t i = 0; i < elems.size(); ++i) {
190+
elems[i] = (Datum)MakeVar(arr[i]);
191+
}
192+
193+
auto ret = construct_array(elems.data(), (int)arr.size(), TEXTOID, -1, false, 'i');
194+
for (size_t i = 0; i < elems.size(); ++i) {
195+
pfree((void*)elems[i]);
196+
}
197+
198+
return (Datum)ret;
199+
}
200+
187201
class TPgConst : public TMutableComputationNode<TPgConst> {
188202
typedef TMutableComputationNode<TPgConst> TBaseComputation;
189203
public:
@@ -358,6 +372,27 @@ class TPgTableContent : public TMutableComputationNode<TPgTableContent> {
358372
};
359373

360374
ApplyFillers(AllPgTablesFillers, Y_ARRAY_SIZE(AllPgTablesFillers), PgTablesFillers_);
375+
} else if (Table_ == "pg_roles") {
376+
static const std::pair<const char*, TPgRolesFiller> AllPgRolesFillers[] = {
377+
{"rolname", []() { return PointerDatumToPod((Datum)MakeFixedString("postgres", NAMEDATALEN)); }},
378+
{"oid", []() { return ScalarDatumToPod(ObjectIdGetDatum(1)); }},
379+
{"rolbypassrls", []() { return ScalarDatumToPod(BoolGetDatum(true)); }},
380+
{"rolsuper", []() { return ScalarDatumToPod(BoolGetDatum(true)); }},
381+
{"rolinherit", []() { return ScalarDatumToPod(BoolGetDatum(true)); }},
382+
{"rolcreaterole", []() { return ScalarDatumToPod(BoolGetDatum(true)); }},
383+
{"rolcreatedb", []() { return ScalarDatumToPod(BoolGetDatum(true)); }},
384+
{"rolcanlogin", []() { return ScalarDatumToPod(BoolGetDatum(true)); }},
385+
{"rolreplication", []() { return ScalarDatumToPod(BoolGetDatum(true)); }},
386+
{"rolconnlimit", []() { return ScalarDatumToPod(Int32GetDatum(-1)); }},
387+
{"rolvaliduntil", []() { return NUdf::TUnboxedValuePod(); }},
388+
{"rolconfig", []() { return PointerDatumToPod(MakeArrayOfText({
389+
"search_path=public",
390+
"default_transaction_isolation=serializable",
391+
"standard_conforming_strings=on",
392+
})); }},
393+
};
394+
395+
ApplyFillers(AllPgRolesFillers, Y_ARRAY_SIZE(AllPgRolesFillers), PgRolesFillers_);
361396
}
362397
} else {
363398
if (Table_ == "tables") {
@@ -559,6 +594,14 @@ class TPgTableContent : public TMutableComputationNode<TPgTableContent> {
559594

560595
rows.emplace_back(row);
561596
}
597+
} else if (Table_ == "pg_roles") {
598+
NUdf::TUnboxedValue* items;
599+
auto row = compCtx.HolderFactory.CreateDirectArrayHolder(PgRolesFillers_.size(), items);
600+
for (ui32 i = 0; i < PgRolesFillers_.size(); ++i) {
601+
items[i] = PgRolesFillers_[i]();
602+
}
603+
604+
rows.emplace_back(row);
562605
}
563606
} else {
564607
if (Table_ == "tables") {
@@ -613,6 +656,8 @@ class TPgTableContent : public TMutableComputationNode<TPgTableContent> {
613656
TVector<TPgNamespaceFiller> PgNamespaceFillers_;
614657
using TPgAmFiller = NUdf::TUnboxedValuePod(*)(const NPg::TAmDesc&);
615658
TVector<TPgAmFiller> PgAmFillers_;
659+
using TPgRolesFiller = NUdf::TUnboxedValuePod(*)();
660+
TVector<TPgRolesFiller> PgRolesFillers_;
616661

617662
struct TDescriptionDesc {
618663
ui32 Objoid = 0;

ydb/library/yql/tests/sql/dq_file/part11/canondata/result.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,28 @@
20582058
}
20592059
],
20602060
"test.test[pg-tpch-q19-default.txt-Results]": [],
2061+
"test.test[pg_catalog-pg_roles-default.txt-Analyze]": [
2062+
{
2063+
"checksum": "c1f2d837c3623c81dd596a9877913fb8",
2064+
"size": 948,
2065+
"uri": "https://{canondata_backend}/1942671/18f32d5eb8ab2aab65012dda63f9cfd635ed3680/resource.tar.gz#test.test_pg_catalog-pg_roles-default.txt-Analyze_/plan.txt"
2066+
}
2067+
],
2068+
"test.test[pg_catalog-pg_roles-default.txt-Debug]": [
2069+
{
2070+
"checksum": "2b3e29957c8a5bac294b21ccb291c57f",
2071+
"size": 645,
2072+
"uri": "https://{canondata_backend}/1942671/18f32d5eb8ab2aab65012dda63f9cfd635ed3680/resource.tar.gz#test.test_pg_catalog-pg_roles-default.txt-Debug_/opt.yql_patched"
2073+
}
2074+
],
2075+
"test.test[pg_catalog-pg_roles-default.txt-Plan]": [
2076+
{
2077+
"checksum": "c1f2d837c3623c81dd596a9877913fb8",
2078+
"size": 948,
2079+
"uri": "https://{canondata_backend}/1942671/18f32d5eb8ab2aab65012dda63f9cfd635ed3680/resource.tar.gz#test.test_pg_catalog-pg_roles-default.txt-Plan_/plan.txt"
2080+
}
2081+
],
2082+
"test.test[pg_catalog-pg_roles-default.txt-Results]": [],
20612083
"test.test[produce-process_with_lambda-default.txt-Analyze]": [
20622084
{
20632085
"checksum": "ebe34f5d2b86ce7954a161dc02a783aa",

ydb/library/yql/tests/sql/dq_file/part17/canondata/result.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,28 @@
20692069
}
20702070
],
20712071
"test.test[pg-wide_top_sort--Results]": [],
2072+
"test.test[pg_catalog-pg_auth_members-default.txt-Analyze]": [
2073+
{
2074+
"checksum": "c1f2d837c3623c81dd596a9877913fb8",
2075+
"size": 948,
2076+
"uri": "https://{canondata_backend}/1784826/fe2bef548a55eb11e26daaded455ba74fda33a1b/resource.tar.gz#test.test_pg_catalog-pg_auth_members-default.txt-Analyze_/plan.txt"
2077+
}
2078+
],
2079+
"test.test[pg_catalog-pg_auth_members-default.txt-Debug]": [
2080+
{
2081+
"checksum": "89087bb5c866532507e766caadeb1947",
2082+
"size": 462,
2083+
"uri": "https://{canondata_backend}/1784826/fe2bef548a55eb11e26daaded455ba74fda33a1b/resource.tar.gz#test.test_pg_catalog-pg_auth_members-default.txt-Debug_/opt.yql_patched"
2084+
}
2085+
],
2086+
"test.test[pg_catalog-pg_auth_members-default.txt-Plan]": [
2087+
{
2088+
"checksum": "c1f2d837c3623c81dd596a9877913fb8",
2089+
"size": 948,
2090+
"uri": "https://{canondata_backend}/1784826/fe2bef548a55eb11e26daaded455ba74fda33a1b/resource.tar.gz#test.test_pg_catalog-pg_auth_members-default.txt-Plan_/plan.txt"
2091+
}
2092+
],
2093+
"test.test[pg_catalog-pg_auth_members-default.txt-Results]": [],
20722094
"test.test[pg_catalog-pg_timezone_names-default.txt-Analyze]": [
20732095
{
20742096
"checksum": "c1f2d837c3623c81dd596a9877913fb8",

ydb/library/yql/tests/sql/sql2yql/canondata/result.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13257,6 +13257,13 @@
1325713257
"uri": "https://{canondata_backend}/1900335/4d293a21f9bd1b76eb022a05e776cb2a96e3a5de/resource.tar.gz#test_sql2yql.test_pg_catalog-pg_am_pg_syntax_/sql.yql"
1325813258
}
1325913259
],
13260+
"test_sql2yql.test[pg_catalog-pg_auth_members]": [
13261+
{
13262+
"checksum": "e87d30ebc286e1af83619ff895c8d3ad",
13263+
"size": 868,
13264+
"uri": "https://{canondata_backend}/1942671/97ffbf971de6e6c2db7e871e5dfde6d17befe266/resource.tar.gz#test_sql2yql.test_pg_catalog-pg_auth_members_/sql.yql"
13265+
}
13266+
],
1326013267
"test_sql2yql.test[pg_catalog-pg_database]": [
1326113268
{
1326213269
"checksum": "3c66358cd738a51ccd0766e18e21fc45",
@@ -13292,6 +13299,13 @@
1329213299
"uri": "https://{canondata_backend}/1900335/4d293a21f9bd1b76eb022a05e776cb2a96e3a5de/resource.tar.gz#test_sql2yql.test_pg_catalog-pg_namespace_pg_syntax_/sql.yql"
1329313300
}
1329413301
],
13302+
"test_sql2yql.test[pg_catalog-pg_roles]": [
13303+
{
13304+
"checksum": "132648e5428703bb0329f35ed030555c",
13305+
"size": 1561,
13306+
"uri": "https://{canondata_backend}/1942671/97ffbf971de6e6c2db7e871e5dfde6d17befe266/resource.tar.gz#test_sql2yql.test_pg_catalog-pg_roles_/sql.yql"
13307+
}
13308+
],
1329513309
"test_sql2yql.test[pg_catalog-pg_set_config]": [
1329613310
{
1329713311
"checksum": "0b00c0ffc35339caa3a22beb1e12d9af",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--!syntax_pg
2+
select
3+
roleid,
4+
member,
5+
grantor,
6+
admin_option
7+
from pg_catalog.pg_auth_members
8+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--!syntax_pg
2+
select
3+
oid,
4+
rolbypassrls,
5+
rolcanlogin,
6+
rolconfig,
7+
rolconnlimit,
8+
rolcreatedb,
9+
rolcreaterole,
10+
rolinherit,
11+
rolname,
12+
rolreplication,
13+
rolsuper,
14+
rolvaliduntil
15+
from pg_catalog.pg_roles
16+
order by oid
17+

ydb/library/yql/tests/sql/yt_native_file/part11/canondata/result.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,27 @@
18401840
"uri": "https://{canondata_backend}/1937027/642fd2ff53bdb0fed32ca89598d70c9c5848ac20/resource.tar.gz#test.test_pg-tpch-q19-default.txt-Results_/results.txt"
18411841
}
18421842
],
1843+
"test.test[pg_catalog-pg_roles-default.txt-Debug]": [
1844+
{
1845+
"checksum": "d5287e3a68ac9d7422c95bad2e0fcdff",
1846+
"size": 587,
1847+
"uri": "https://{canondata_backend}/1942671/ba1b384ae189e43a41610dd3346b04832beabd4c/resource.tar.gz#test.test_pg_catalog-pg_roles-default.txt-Debug_/opt.yql"
1848+
}
1849+
],
1850+
"test.test[pg_catalog-pg_roles-default.txt-Plan]": [
1851+
{
1852+
"checksum": "c1f2d837c3623c81dd596a9877913fb8",
1853+
"size": 948,
1854+
"uri": "https://{canondata_backend}/1942671/ba1b384ae189e43a41610dd3346b04832beabd4c/resource.tar.gz#test.test_pg_catalog-pg_roles-default.txt-Plan_/plan.txt"
1855+
}
1856+
],
1857+
"test.test[pg_catalog-pg_roles-default.txt-Results]": [
1858+
{
1859+
"checksum": "bec9b807ec5e51094ba20c22b9e687b2",
1860+
"size": 4018,
1861+
"uri": "https://{canondata_backend}/1942671/ba1b384ae189e43a41610dd3346b04832beabd4c/resource.tar.gz#test.test_pg_catalog-pg_roles-default.txt-Results_/results.txt"
1862+
}
1863+
],
18431864
"test.test[produce-process_with_lambda-default.txt-Debug]": [
18441865
{
18451866
"checksum": "57b040e7126bb73a5732c185709e1728",

ydb/library/yql/tests/sql/yt_native_file/part14/canondata/result.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,9 +2386,9 @@
23862386
],
23872387
"test.test[pg_catalog-pg_tables-default.txt-Results]": [
23882388
{
2389-
"checksum": "184cdb7b88a0cbc27eab10f27a1f9594",
2390-
"size": 3071,
2391-
"uri": "https://{canondata_backend}/1773845/2d08ad134994d3e36dc49c3a759a1fb95cec5e61/resource.tar.gz#test.test_pg_catalog-pg_tables-default.txt-Results_/results.txt"
2389+
"checksum": "5fe341df627412345fb04a78265f2ecc",
2390+
"size": 3314,
2391+
"uri": "https://{canondata_backend}/1936273/e462bdc099ba4dbd155abc458ce19bf37225c228/resource.tar.gz#test.test_pg_catalog-pg_tables-default.txt-Results_/results.txt"
23922392
}
23932393
],
23942394
"test.test[produce-process_rows_sorted_desc_multi_out--Debug]": [

ydb/library/yql/tests/sql/yt_native_file/part16/canondata/result.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,9 +1888,9 @@
18881888
],
18891889
"test.test[pg_catalog-columns-default.txt-Results]": [
18901890
{
1891-
"checksum": "490a1e0d0509eec4920379998de15566",
1892-
"size": 13320,
1893-
"uri": "https://{canondata_backend}/1814674/d705af5d4baa19963255001d314ce2ac75be9a4a/resource.tar.gz#test.test_pg_catalog-columns-default.txt-Results_/results.txt"
1891+
"checksum": "86487c14aee284a3fc83c6565a84bd94",
1892+
"size": 16354,
1893+
"uri": "https://{canondata_backend}/1942671/557a92985829819fe7b7623859d0c502cd47d633/resource.tar.gz#test.test_pg_catalog-columns-default.txt-Results_/results.txt"
18941894
}
18951895
],
18961896
"test.test[pragma-config_exec--Debug]": [

0 commit comments

Comments
 (0)