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

DB-1218 - remove *.so file extension from PostgreSQL extensions #19

Merged
merged 1 commit into from
Oct 23, 2024
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
2 changes: 1 addition & 1 deletion currency.control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# currency extension
comment = 'Custom PostgreSQL currency type'
default_version = '0.0.4'
default_version = '0.0.5'
relocatable = true
requires = 'plpgsql'
64 changes: 64 additions & 0 deletions sql/currency--0.0.4--0.0.5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
CREATE FUNCTION supported_currencies()
RETURNS SETOF currency
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_in(cstring)
RETURNS currency
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_out(currency)
RETURNS cstring
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_recv(internal)
RETURNS currency
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_send(currency)
RETURNS bytea
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_lt(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_le(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_eq(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_neq(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_ge(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_gt(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION hash_currency(currency)
RETURNS integer
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_cmp(currency, currency)
RETURNS int4
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;
203 changes: 203 additions & 0 deletions sql/currency--0.0.5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@

CREATE TYPE currency;

CREATE FUNCTION supported_currencies()
RETURNS SETOF currency
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_in(cstring)
RETURNS currency
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_out(currency)
RETURNS cstring
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_recv(internal)
RETURNS currency
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE FUNCTION currency_send(currency)
RETURNS bytea
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE TYPE currency (
internallength = 1,
input = currency_in,
output = currency_out,
send = currency_send,
receive = currency_recv,
alignment = char,
PASSEDBYVALUE
);

COMMENT ON TYPE currency
IS '1-byte ISO 4217 Currency Code';

CREATE FUNCTION currency_lt(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION currency_lt(currency, currency) IS 'implementation of < operator';

CREATE FUNCTION currency_le(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION currency_le(currency, currency) IS 'implementation of <= operator';

CREATE FUNCTION currency_eq(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION currency_eq(currency, currency) IS 'implementation of = operator';

CREATE FUNCTION currency_neq(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION currency_neq(currency, currency) IS 'implementation of <> operator';

CREATE FUNCTION currency_ge(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION currency_ge(currency, currency) IS 'implementation of >= operator';

CREATE FUNCTION currency_gt(currency, currency)
RETURNS BOOL
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION currency_gt(currency, currency) IS 'implementation of > operator';

CREATE FUNCTION hash_currency(currency)
RETURNS integer
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

COMMENT ON FUNCTION hash_currency(currency) IS 'hash';

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

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

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

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

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

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

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

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

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

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

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

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

CREATE FUNCTION currency_cmp(currency, currency)
RETURNS int4
AS '$libdir/currency'
LANGUAGE C IMMUTABLE STRICT;

CREATE OPERATOR CLASS currency_ops
DEFAULT FOR TYPE currency USING btree AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 currency_cmp(currency, currency);

CREATE OPERATOR CLASS currency_ops
DEFAULT FOR TYPE currency USING hash AS
OPERATOR 1 = ,
FUNCTION 1 hash_currency(currency);

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 currency_in(cstring) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_out(currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_recv(internal) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_send(currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_eq(currency, currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_neq(currency, currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_lt(currency, currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_le(currency, currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_gt(currency, currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_ge(currency, currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION currency_cmp(currency, currency) PARALLEL SAFE $E$;
EXECUTE $E$ ALTER FUNCTION hash_currency(currency) PARALLEL SAFE $E$;
END IF;
END;
$$;

26 changes: 13 additions & 13 deletions sql/pg-currency.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ CREATE TYPE currency;

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

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

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

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

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

CREATE TYPE currency (
Expand All @@ -40,49 +40,49 @@ COMMENT ON TYPE currency

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

COMMENT ON FUNCTION currency_lt(currency, currency) IS 'implementation of < operator';

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

COMMENT ON FUNCTION currency_le(currency, currency) IS 'implementation of <= operator';

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

COMMENT ON FUNCTION currency_eq(currency, currency) IS 'implementation of = operator';

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

COMMENT ON FUNCTION currency_neq(currency, currency) IS 'implementation of <> operator';

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

COMMENT ON FUNCTION currency_ge(currency, currency) IS 'implementation of >= operator';

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

COMMENT ON FUNCTION currency_gt(currency, currency) IS 'implementation of > operator';

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

COMMENT ON FUNCTION hash_currency(currency) IS 'hash';
Expand Down Expand Up @@ -162,7 +162,7 @@ COMMENT ON OPERATOR <>(currency, currency) IS 'not equal';

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

CREATE OPERATOR CLASS currency_ops
Expand Down
Loading