Skip to content

Commit

Permalink
Merge pull request #10156 from goldmedal/feature/add-session-func-pgc…
Browse files Browse the repository at this point in the history
…atalog

Add some pg session function to pg_catalog
  • Loading branch information
Mytherin committed Jan 6, 2024
2 parents a55f89c + 42a5aa3 commit d5969ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/catalog/default/default_functions.cpp
Expand Up @@ -27,6 +27,11 @@ static DefaultMacro internal_macros[] = {

{"pg_catalog", "pg_typeof", {"expression", nullptr}, "lower(typeof(expression))"}, // get the data type of any value

{"pg_catalog", "current_database", {nullptr}, "current_database()"}, // name of current database (called "catalog" in the SQL standard)
{"pg_catalog", "current_query", {nullptr}, "current_query()"}, // the currently executing query (NULL if not inside a plpgsql function)
{"pg_catalog", "current_schema", {nullptr}, "current_schema()"}, // name of current schema
{"pg_catalog", "current_schemas", {"include_implicit"}, "current_schemas(include_implicit)"}, // names of schemas in search path

// privilege functions
// {"has_any_column_privilege", {"user", "table", "privilege", nullptr}, "true"}, //boolean //does user have privilege for any column of table
{"pg_catalog", "has_any_column_privilege", {"table", "privilege", nullptr}, "true"}, //boolean //does current user have privilege for any column of table
Expand Down
10 changes: 10 additions & 0 deletions test/sql/catalog/test_set_search_path.test
Expand Up @@ -90,6 +90,11 @@ SELECT MAIN.CURRENT_SCHEMAS(false);
----
[test, test2]

query I
SELECT pg_catalog.CURRENT_SCHEMAS(false);
----
[test, test2]

statement ok
SET SCHEMA = 'test';

Expand All @@ -103,6 +108,11 @@ SELECT MAIN.CURRENT_SCHEMA();
----
test

query I
SELECT pg_catalog.CURRENT_SCHEMA();
----
test

query I
SELECT current_schema();
----
Expand Down
10 changes: 10 additions & 0 deletions test/sql/pg_catalog/system_functions.test
Expand Up @@ -20,6 +20,11 @@ SELECT CURRENT_DATABASE()
----
memory

query I
SELECT pg_catalog.CURRENT_DATABASE()
----
memory

query I
SELECT USER
----
Expand All @@ -38,6 +43,11 @@ SELECT current_query();
----
SELECT current_query();

query I
SELECT pg_catalog.current_query();
----
SELECT pg_catalog.current_query();

query IIII
SELECT 1, 2, 3, current_query();
----
Expand Down

0 comments on commit d5969ec

Please sign in to comment.