Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ datafusion-functions = "50"
datafusion-functions-aggregate-common = "50"
datafusion-optimizer = "50"
datafusion-orc = "0.5"
datafusion-pg-catalog = "0.12.2"
datafusion-pg-catalog = "0.12.3"
datafusion-physical-expr = "50"
datafusion-physical-plan = "50"
datafusion-sql = "50"
Expand Down
20 changes: 10 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Development environment flake";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
Expand Down Expand Up @@ -48,7 +48,7 @@
gnuplot ## for cargo bench
];

LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
buildInputs = buildInputs;
NIX_HARDENING_ENABLE = "";
};
});
Expand Down
2 changes: 2 additions & 0 deletions src/common/function/src/system/pg_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ impl PGCatalogFunction {
registry.register(pg_catalog::create_pg_stat_get_numscans());
registry.register(pg_catalog::create_pg_get_constraintdef());
registry.register(pg_catalog::create_pg_get_partition_ancestors_udf());
registry.register(pg_catalog::quote_ident_udf::create_quote_ident_udf());
registry.register(pg_catalog::quote_ident_udf::create_parse_ident_udf());
registry.register_scalar(ObjDescriptionFunction::new());
registry.register_scalar(ColDescriptionFunction::new());
registry.register_scalar(ShobjDescriptionFunction::new());
Expand Down
73 changes: 71 additions & 2 deletions tests/cases/standalone/common/system/pg_catalog.result
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,77 @@ where relnamespace in (
| foo |
+---------+

-- SQLNESS PROTOCOL POSTGRES
SELECT
CASE WHEN
quote_ident(table_schema) IN (
SELECT
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
FROM
generate_series(
array_lower(string_to_array(current_setting('search_path'),','),1),
array_upper(string_to_array(current_setting('search_path'),','),1)
) as i,
string_to_array(current_setting('search_path'),',') s
)
THEN quote_ident(table_name)
ELSE quote_ident(table_schema) || '.' || quote_ident(table_name)
END AS "table"
FROM information_schema.tables
WHERE quote_ident(table_schema) NOT IN ('information_schema',
'pg_catalog',
'_timescaledb_cache',
'_timescaledb_catalog',
'_timescaledb_internal',
'_timescaledb_config',
'timescaledb_information',
'timescaledb_experimental')
ORDER BY CASE WHEN
quote_ident(table_schema) IN (
SELECT
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
FROM
generate_series(
array_lower(string_to_array(current_setting('search_path'),','),1),
array_upper(string_to_array(current_setting('search_path'),','),1)
) as i,
string_to_array(current_setting('search_path'),',') s
) THEN 0 ELSE 1 END, 1;

+----------------+
| table |
+----------------+
| my_db.foo |
| public.numbers |
+----------------+

-- SQLNESS PROTOCOL POSTGRES
SELECT quote_ident(column_name) AS "column", data_type AS "type"
FROM information_schema.columns
WHERE
CASE WHEN array_length(parse_ident('my_db.foo'),1) = 2
THEN quote_ident(table_schema) = (parse_ident('my_db.foo'))[1]
AND quote_ident(table_name) = (parse_ident('my_db.foo'))[2]
ELSE quote_ident(table_name) = 'my_db.foo'
AND
quote_ident(table_schema) IN (
SELECT
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
FROM
generate_series(
array_lower(string_to_array(current_setting('search_path'),','),1),
array_upper(string_to_array(current_setting('search_path'),','),1)
) as i,
string_to_array(current_setting('search_path'),',') s
)
END;

+--------+--------------+
| column | type |
+--------+--------------+
| ts | timestamp(3) |
+--------+--------------+

-- SQLNESS PROTOCOL POSTGRES
-- SQLNESS REPLACE (\d+\s*) OID
select relnamespace, relname, relkind
Expand Down Expand Up @@ -1013,9 +1084,7 @@ SELECT
oid
,nspname
,nspname = ANY (current_schemas(true)) AS is_on_search_path

,obj_description(oid, 'pg_namespace') AS comment

FROM pg_namespace; SELECT
oid
,nspname
Expand Down
63 changes: 60 additions & 3 deletions tests/cases/standalone/common/system/pg_catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,64 @@ where relnamespace in (
where nspname like 'my%'
);

-- SQLNESS PROTOCOL POSTGRES
SELECT
CASE WHEN
quote_ident(table_schema) IN (
SELECT
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
FROM
generate_series(
array_lower(string_to_array(current_setting('search_path'),','),1),
array_upper(string_to_array(current_setting('search_path'),','),1)
) as i,
string_to_array(current_setting('search_path'),',') s
)
THEN quote_ident(table_name)
ELSE quote_ident(table_schema) || '.' || quote_ident(table_name)
END AS "table"
FROM information_schema.tables
WHERE quote_ident(table_schema) NOT IN ('information_schema',
'pg_catalog',
'_timescaledb_cache',
'_timescaledb_catalog',
'_timescaledb_internal',
'_timescaledb_config',
'timescaledb_information',
'timescaledb_experimental')
ORDER BY CASE WHEN
quote_ident(table_schema) IN (
SELECT
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
FROM
generate_series(
array_lower(string_to_array(current_setting('search_path'),','),1),
array_upper(string_to_array(current_setting('search_path'),','),1)
) as i,
string_to_array(current_setting('search_path'),',') s
) THEN 0 ELSE 1 END, 1;

-- SQLNESS PROTOCOL POSTGRES
SELECT quote_ident(column_name) AS "column", data_type AS "type"
FROM information_schema.columns
WHERE
CASE WHEN array_length(parse_ident('my_db.foo'),1) = 2
THEN quote_ident(table_schema) = (parse_ident('my_db.foo'))[1]
AND quote_ident(table_name) = (parse_ident('my_db.foo'))[2]
ELSE quote_ident(table_name) = 'my_db.foo'
AND
quote_ident(table_schema) IN (
SELECT
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
FROM
generate_series(
array_lower(string_to_array(current_setting('search_path'),','),1),
array_upper(string_to_array(current_setting('search_path'),','),1)
) as i,
string_to_array(current_setting('search_path'),',') s
)
END;

-- SQLNESS PROTOCOL POSTGRES
-- SQLNESS REPLACE (\d+\s*) OID
select relnamespace, relname, relkind
Expand Down Expand Up @@ -192,12 +250,11 @@ SELECT
oid
,nspname
,nspname = ANY (current_schemas(true)) AS is_on_search_path

,obj_description(oid, 'pg_namespace') AS comment

FROM pg_namespace; SELECT
oid
,nspname
FROM pg_namespace
WHERE oid = pg_my_temp_schema();