Skip to content

Commit

Permalink
Parallelism (#6)
Browse files Browse the repository at this point in the history
parallelism for 9.6
  • Loading branch information
einhverfr authored Nov 15, 2017
1 parent e5df4bf commit 24f53dc
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 4 deletions.
6 changes: 3 additions & 3 deletions META.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "language",
"abstract": "Enumerable type for languages",
"version": "0.0.1",
"maintainer": [ "Chris Travers <christravers@adjust.com>", "Manuel Kniep <[email protected]>" ],
"version": "0.0.2",
"maintainer": [ "Chris Travers <chris.travers@adjust.com>", "Manuel Kniep <[email protected]>" ],
"license": {
"PostgreSQL": "http://www.postgresql.org/about/licence"
},
Expand All @@ -17,7 +17,7 @@
"version": "1.0.0",
"url": "http://pgxn.org/meta/spec.txt"
},
"description": "This extnesion offers a one-byte storage type that works as an enum for major languages.",
"description": "This extension offers a fixed-byte storage type that works as an enum for major languages.",
"prereqs": {
"runtime": {
"requires": {
Expand Down
2 changes: 1 addition & 1 deletion language.control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# currency extension
comment = 'Custom PostgreSQL language enumeration type'
default_version = '0.0.1'
default_version = '0.0.2'
relocatable = true
requires = ''
23 changes: 23 additions & 0 deletions sql/language--0.0.1--0.0.2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@


DO $$
DECLARE version_num integer;
BEGIN
SELECT current_setting('server_version_num') INTO STRICT version_num;
IF version_num > 90600 THEN
EXECUTE $E$ ALTER FUNCTION language_in(cstring) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_out(language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_recv(internal) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_send(language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_eq(language, language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_neq(language, language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_lt(language, language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_le(language, language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_gt(language, language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_ge(language, language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION language_cmp(language, language) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION hash_language(language) PARALLEL SAFE $E$;
END IF;
END;
$$;

181 changes: 181 additions & 0 deletions sql/language--0.0.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@

CREATE TYPE language;

CREATE FUNCTION supported_languages()
RETURNS SETOF language
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION language_in(cstring)
RETURNS language
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION language_out(language)
RETURNS cstring
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION language_recv(internal)
RETURNS language
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION language_send(language)
RETURNS bytea
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

CREATE TYPE language (
internallength = 1,
input = language_in,
output = language_out,
send = language_send,
receive = language_recv,
alignment = char,
PASSEDBYVALUE
);

COMMENT ON TYPE language
IS '1-byte adjust-specific Language Code';

CREATE FUNCTION language_lt(language, language)
RETURNS BOOL
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION language_lt(language, language) IS 'implementation of < operator';

CREATE FUNCTION language_le(language, language)
RETURNS BOOL
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION language_le(language, language) IS 'implementation of <= operator';

CREATE FUNCTION language_eq(language, language)
RETURNS BOOL
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION language_eq(language, language) IS 'implementation of = operator';

CREATE FUNCTION language_neq(language, language)
RETURNS BOOL
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION language_neq(language, language) IS 'implementation of <> operator';

CREATE FUNCTION language_ge(language, language)
RETURNS BOOL
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION language_ge(language, language) IS 'implementation of >= operator';

CREATE FUNCTION language_gt(language, language)
RETURNS BOOL
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION language_gt(language, language) IS 'implementation of > operator';

CREATE FUNCTION hash_language(language)
RETURNS integer
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION hash_language(language) IS 'hash';

CREATE OPERATOR < (
leftarg = language,
rightarg = language,
procedure = language_lt,
commutator = >,
negator = >=,
restrict = scalarltsel,
join = scalarltjoinsel
);

COMMENT ON OPERATOR <(language, language) IS 'less than';

CREATE OPERATOR <= (
leftarg = language,
rightarg = language,
procedure = language_le,
commutator = >=,
negator = >,
restrict = scalarltsel,
join = scalarltjoinsel
);

COMMENT ON OPERATOR <=(language, language) IS 'less than or equal';

CREATE OPERATOR = (
leftarg = language,
rightarg = language,
procedure = language_eq,
commutator = =,
negator = <>,
restrict = eqsel,
join = eqjoinsel,
HASHES, MERGES
);

COMMENT ON OPERATOR =(language, language) IS 'equal';

CREATE OPERATOR >= (
leftarg = language,
rightarg = language,
procedure = language_ge,
commutator = <=,
negator = <,
restrict = scalargtsel,
join = scalargtjoinsel
);

COMMENT ON OPERATOR >=(language, language) IS 'greater than or equal';

CREATE OPERATOR > (
leftarg = language,
rightarg = language,
procedure = language_gt,
commutator = <,
negator = <=,
restrict = scalargtsel,
join = scalargtjoinsel
);

COMMENT ON OPERATOR >(language, language) IS 'greater than';

CREATE OPERATOR <> (
leftarg = language,
rightarg = language,
procedure = language_neq,
commutator = <>,
negator = =,
restrict = neqsel,
join = neqjoinsel
);

COMMENT ON OPERATOR <>(language, language) IS 'not equal';

CREATE FUNCTION language_cmp(language, language)
RETURNS int4
AS '$libdir/language.so'
LANGUAGE C IMMUTABLE STRICT;

CREATE OPERATOR CLASS language_ops
DEFAULT FOR TYPE language USING btree AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 language_cmp(language, language);

CREATE OPERATOR CLASS language_ops
DEFAULT FOR TYPE language USING hash AS
OPERATOR 1 = ,
FUNCTION 1 hash_language(language);
Loading

0 comments on commit 24f53dc

Please sign in to comment.