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 create_operator_func API. #210

Merged
merged 6 commits into from
Jul 12, 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
1 change: 1 addition & 0 deletions include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#define TLE_BASE_TYPE_IN "pg_tle_base_type_in"
#define TLE_BASE_TYPE_OUT "pg_tle_base_type_out"
#define TLE_OPERATOR_FUNC "pg_tle_operator_func"

/*
* TLE_BASE_TYPE_SIZE_LIMIT is the maximum allowed size of pg_tle type.
Expand Down
60 changes: 60 additions & 0 deletions pg_tle--1.0.4--1.0.5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,38 @@ END;
$_pgtleie_$
LANGUAGE plpgsql STRICT;

CREATE FUNCTION pgtle.create_operator_func
(
typenamespace regnamespace,
typename name,
opfunc regprocedure
)
RETURNS void
SET search_path TO 'pgtle'
STRICT
AS 'MODULE_PATHNAME', 'pg_tle_create_operator_func'
LANGUAGE C;

CREATE FUNCTION pgtle.create_operator_func_if_not_exists
(
typenamespace regnamespace,
typename name,
opfunc regprocedure
)
RETURNS boolean
SET search_path TO 'pgtle'
AS $_pgtleie_$
BEGIN
PERFORM pgtle.create_operator_func(typenamespace, typename, opfunc);
RETURN TRUE;
EXCEPTION
-- only catch the duplicate_object exception, let all other exceptions pass through.
WHEN duplicate_object THEN
RETURN FALSE;
END;
$_pgtleie_$
LANGUAGE plpgsql STRICT;

REVOKE EXECUTE ON FUNCTION pgtle.create_shell_type
(
typenamespace regnamespace,
Expand Down Expand Up @@ -105,6 +137,20 @@ REVOKE EXECUTE ON FUNCTION pgtle.create_base_type_if_not_exists
internallength int4
) FROM PUBLIC;

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

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

GRANT EXECUTE ON FUNCTION pgtle.create_shell_type
(
typenamespace regnamespace,
Expand Down Expand Up @@ -134,3 +180,17 @@ GRANT EXECUTE ON FUNCTION pgtle.create_base_type_if_not_exists
outfunc regprocedure,
internallength int4
) TO pgtle_admin;

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

GRANT EXECUTE ON FUNCTION pgtle.create_operator_func_if_not_exists
(
typenamespace regnamespace,
typename name,
opfunc regprocedure
) TO pgtle_admin;
60 changes: 60 additions & 0 deletions pg_tle--1.0.5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,38 @@ END;
$_pgtleie_$
LANGUAGE plpgsql STRICT;

CREATE FUNCTION pgtle.create_operator_func
(
typenamespace regnamespace,
typename name,
opfunc regprocedure
)
RETURNS void
SET search_path TO 'pgtle'
STRICT
AS 'MODULE_PATHNAME', 'pg_tle_create_operator_func'
LANGUAGE C;

CREATE FUNCTION pgtle.create_operator_func_if_not_exists
(
typenamespace regnamespace,
typename name,
opfunc regprocedure
)
RETURNS boolean
SET search_path TO 'pgtle'
AS $_pgtleie_$
BEGIN
PERFORM pgtle.create_operator_func(typenamespace, typename, opfunc);
RETURN TRUE;
EXCEPTION
-- only catch the duplicate_object exception, let all other exceptions pass through.
WHEN duplicate_object THEN
RETURN FALSE;
END;
$_pgtleie_$
LANGUAGE plpgsql STRICT;

REVOKE EXECUTE ON FUNCTION pgtle.create_shell_type
(
typenamespace regnamespace,
Expand Down Expand Up @@ -502,6 +534,20 @@ REVOKE EXECUTE ON FUNCTION pgtle.create_base_type_if_not_exists
internallength int4
) FROM PUBLIC;

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

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

GRANT EXECUTE ON FUNCTION pgtle.create_shell_type
(
typenamespace regnamespace,
Expand Down Expand Up @@ -532,6 +578,20 @@ GRANT EXECUTE ON FUNCTION pgtle.create_base_type_if_not_exists
internallength int4
) TO pgtle_admin;

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

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

CREATE TYPE pgtle.pg_tle_features as ENUM ('passcheck');
CREATE TYPE pgtle.password_types as ENUM ('PASSWORD_TYPE_PLAINTEXT', 'PASSWORD_TYPE_MD5', 'PASSWORD_TYPE_SCRAM_SHA_256');

Expand Down
Loading