-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support customized alignment and storage for pg_tle create type API (#…
…266) In the previous version, we used default int4 alignment and plain storage (non-TOASTable). The data will always be stored in-line and not compressed. An error will be reported if the value exceeds the limit: ERROR: row is too big: size xxx, maximum size xxx. With this change, users can customize the alignment and storage strategies. Compression or out-of-line storage can be used depending on the storage strategy (https://www.postgresql.org/docs/current/storage-toast.html). The default alignment is int4 while the default storage is plain, compatible with previous versions.
- Loading branch information
Showing
7 changed files
with
740 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* 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 | ||
|
||
DROP FUNCTION pgtle.create_base_type CASCADE; | ||
DROP FUNCTION pgtle.create_base_type_if_not_exists CASCADE; | ||
|
||
CREATE FUNCTION pgtle.create_base_type | ||
( | ||
typenamespace regnamespace, | ||
typename name, | ||
infunc regprocedure, | ||
outfunc regprocedure, | ||
internallength int4, | ||
alignment text default 'int4', | ||
storage text default 'plain' | ||
) | ||
RETURNS void | ||
SET search_path TO 'pgtle' | ||
STRICT | ||
AS 'MODULE_PATHNAME', 'pg_tle_create_base_type_with_storage' | ||
LANGUAGE C; | ||
|
||
CREATE FUNCTION pgtle.create_base_type_if_not_exists | ||
( | ||
typenamespace regnamespace, | ||
typename name, | ||
infunc regprocedure, | ||
outfunc regprocedure, | ||
internallength int4, | ||
alignment text default 'int4', | ||
storage text default 'plain' | ||
) | ||
RETURNS boolean | ||
SET search_path TO 'pgtle' | ||
AS $_pgtleie_$ | ||
BEGIN | ||
PERFORM pgtle.create_base_type(typenamespace, typename, infunc, outfunc, internallength, alignment, storage); | ||
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_base_type | ||
( | ||
typenamespace regnamespace, | ||
typename name, | ||
infunc regprocedure, | ||
outfunc regprocedure, | ||
internallength int4, | ||
alignment text, | ||
storage text | ||
) FROM PUBLIC; | ||
|
||
REVOKE EXECUTE ON FUNCTION pgtle.create_base_type_if_not_exists | ||
( | ||
typenamespace regnamespace, | ||
typename name, | ||
infunc regprocedure, | ||
outfunc regprocedure, | ||
internallength int4, | ||
alignment text, | ||
storage text | ||
) FROM PUBLIC; | ||
|
||
GRANT EXECUTE ON FUNCTION pgtle.create_base_type | ||
( | ||
typenamespace regnamespace, | ||
typename name, | ||
infunc regprocedure, | ||
outfunc regprocedure, | ||
internallength int4, | ||
alignment text, | ||
storage text | ||
) TO pgtle_admin; | ||
|
||
GRANT EXECUTE ON FUNCTION pgtle.create_base_type_if_not_exists | ||
( | ||
typenamespace regnamespace, | ||
typename name, | ||
infunc regprocedure, | ||
outfunc regprocedure, | ||
internallength int4, | ||
alignment text, | ||
storage text | ||
) TO pgtle_admin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.