Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pgtle.create_shell_type function to support shell type creation in pg_tle #205

Merged
merged 3 commits into from
Jun 13, 2023
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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
EXTENSION = pg_tle
EXTVERSION = 1.0.4
EXTVERSION = 1.0.5

SCHEMA = pgtle
MODULE_big = $(EXTENSION)

OBJS = src/tleextension.o src/guc-file.o src/feature.o src/passcheck.o src/uni_api.o
OBJS = src/tleextension.o src/guc-file.o src/feature.o src/passcheck.o src/uni_api.o src/datatype.o

EXTRA_CLEAN = src/guc-file.c pg_tle.control pg_tle--$(EXTVERSION).sql
DATA = pg_tle.control pg_tle--1.0.0.sql pg_tle--1.0.0--1.0.1.sql pg_tle--1.0.1--1.0.4.sql
DATA = pg_tle.control pg_tle--1.0.0.sql pg_tle--1.0.0--1.0.1.sql pg_tle--1.0.1--1.0.4.sql pg_tle--1.0.4--1.0.5.sql

REGRESS = pg_tle_api pg_tle_management pg_tle_injection pg_tle_perms pg_tle_requires
REGRESS = pg_tle_api pg_tle_management pg_tle_injection pg_tle_perms pg_tle_requires pg_tle_datatype

REGRESS_OPTS = --inputdir=test --temp-config ./regress.conf

Expand Down
3 changes: 3 additions & 0 deletions include/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef SET_USER_COMPAT_H
#define SET_USER_COMPAT_H

#include "catalog/pg_namespace.h"
#include "tcop/utility.h"

/*
Expand Down Expand Up @@ -244,11 +245,13 @@
#define PG_EXTENSION_OWNERCHECK(ExtensionOid, UserId) pg_extension_ownercheck(ExtensionOid, UserId)
#define PG_NAMESPACE_ACLCHECK(NamespaceOid, UserId, Operation) pg_namespace_aclcheck(NamespaceOid, UserId, Operation)
#define STRING_TO_QUALIFIED_NAME_LIST(string) stringToQualifiedNameList(string)
#define CHECK_CAN_SET_ROLE(member, role) check_is_member_of_role(member, role)
#else
#define PG_DATABASE_ACLCHECK(DatabaseId, UserId, Operation) object_aclcheck(DatabaseRelationId, DatabaseId, UserId, Operation);
#define PG_EXTENSION_OWNERCHECK(ExtensionOid, UserId) object_ownercheck(ExtensionRelationId, ExtensionOid, UserId)
#define PG_NAMESPACE_ACLCHECK(NamespaceOid, UserId, Operation) object_aclcheck(NamespaceRelationId, NamespaceOid, UserId, Operation)
#define STRING_TO_QUALIFIED_NAME_LIST(string) stringToQualifiedNameList(string, NULL)
#define CHECK_CAN_SET_ROLE(member, role) check_can_set_role(member, role)
#endif


Expand Down
1 change: 1 addition & 0 deletions include/tleextension.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define PG_TLE_EXTNAME "pg_tle"
#define PG_TLE_OUTER_STR "$_pgtle_o_$"
#define PG_TLE_INNER_STR "$_pgtle_i_$"
#define PG_TLE_ADMIN "pgtle_admin"

/*
* creating_extension is only true while running a CREATE EXTENSION or ALTER
Expand Down
64 changes: 64 additions & 0 deletions pg_tle--1.0.4--1.0.5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION pg_tle" to load this file. \quit

CREATE FUNCTION pgtle.create_shell_type
(
typenamespace regnamespace,
typename name
)
RETURNS void
SET search_path TO 'pgtle'
STRICT
AS 'MODULE_PATHNAME', 'pg_tle_create_shell_type'
LANGUAGE C;

CREATE FUNCTION pgtle.create_shell_type_if_not_exists
(
typenamespace regnamespace,
typename name
)
RETURNS boolean
SET search_path TO 'pgtle'
STRICT
AS 'MODULE_PATHNAME', 'pg_tle_create_shell_type_if_not_exists'
LANGUAGE C;

REVOKE EXECUTE ON FUNCTION pgtle.create_shell_type
(
typenamespace regnamespace,
typename name
) FROM PUBLIC;

REVOKE EXECUTE ON FUNCTION pgtle.create_shell_type_if_not_exists
(
typenamespace regnamespace,
typename name
) FROM PUBLIC;

GRANT EXECUTE ON FUNCTION pgtle.create_shell_type
(
typenamespace regnamespace,
typename name
) TO pgtle_admin;

GRANT EXECUTE ON FUNCTION pgtle.create_shell_type_if_not_exists
(
typenamespace regnamespace,
typename name
) TO pgtle_admin;
Loading