Skip to content
Draft
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
1 change: 1 addition & 0 deletions contrib/babelfishpg_tsql/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ OBJS += src/fts.o
OBJS += src/fts_parser.o
OBJS += src/pltsql_partition.o
OBJS += src/bbf_parallel_query.o
OBJS += src/namespace_support.o
OBJS += src/temp_table.o

export ANTLR4_JAVA_BIN=java
Expand Down
1 change: 1 addition & 0 deletions contrib/babelfishpg_tsql/sql/babelfishpg_tsql.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SELECT set_config('search_path', 'sys, '||current_setting('search_path'), false)
#include "babelfish_partitions.sql"
#include "linked_servers_tsql.sql"
#include "ownership.sql"
#include "namespace_support.sql"
#include "sys_views.sql"
#include "information_schema_tsql.sql"
#include "sys_procedures.sql"
Expand Down
41 changes: 41 additions & 0 deletions contrib/babelfishpg_tsql/sql/namespace_support.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- SQL declarations for is_babelfish_namespace with prosupport
-- Run this after building and installing the extension

-- Create the support function first
CREATE OR REPLACE FUNCTION sys.is_babelfish_namespace_support(internal)
RETURNS internal
AS 'babelfishpg_tsql', 'is_babelfish_namespace_support'
LANGUAGE C STRICT;

-- Create the main function with SUPPORT clause
CREATE OR REPLACE FUNCTION sys.is_babelfish_namespace(ns_oid oid)
RETURNS boolean
AS 'babelfishpg_tsql', 'is_babelfish_namespace'
LANGUAGE C STABLE STRICT
SUPPORT sys.is_babelfish_namespace_support;

-- Privilege support function: provides accurate selectivity for has_*_privilege()
CREATE OR REPLACE FUNCTION sys.has_privilege_support(internal)
RETURNS internal
AS 'babelfishpg_tsql', 'has_privilege_support'
LANGUAGE C STRICT;

-- Attach to built-in privilege functions used in system views
UPDATE pg_catalog.pg_proc SET prosupport = 'sys.has_privilege_support'::regproc
WHERE proname = 'has_table_privilege'
AND pronargs = 2
AND proargtypes[0] = 'oid'::regtype
AND proargtypes[1] = 'text'::regtype;

UPDATE pg_catalog.pg_proc SET prosupport = 'sys.has_privilege_support'::regproc
WHERE proname = 'has_function_privilege'
AND pronargs = 2
AND proargtypes[0] = 'oid'::regtype
AND proargtypes[1] = 'text'::regtype;

UPDATE pg_catalog.pg_proc SET prosupport = 'sys.has_privilege_support'::regproc
WHERE proname = 'has_column_privilege'
AND pronargs = 3
AND proargtypes[0] = 'oid'::regtype
AND proargtypes[1] = 'text'::regtype
AND proargtypes[2] = 'text'::regtype;
Loading
Loading