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

Add MIN and MAX aggregate support for MONEY datatype #3410

Open
wants to merge 7 commits into
base: BABEL_5_X_DEV
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2005,3 +2005,13 @@ CREATE FUNCTION sys.smallmoneysmaller(sys.SMALLMONEY, sys.SMALLMONEY)
RETURNS sys.SMALLMONEY
AS 'babelfishpg_money', 'fixeddecimalsmaller'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE FUNCTION sys.moneylarger(sys.MONEY, sys.MONEY)
RETURNS sys.MONEY
AS 'babelfishpg_money', 'fixeddecimallarger'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE FUNCTION sys.moneysmaller(sys.MONEY, sys.MONEY)
RETURNS sys.MONEY
AS 'babelfishpg_money', 'fixeddecimalsmaller'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,17 @@ CREATE AGGREGATE sys.max(sys.smallmoney) (
COMBINEFUNC = sys.smallmoneylarger,
PARALLEL = SAFE
);

CREATE AGGREGATE sys.min(sys.money) (
SFUNC = sys.moneysmaller,
STYPE = sys.money,
COMBINEFUNC = sys.moneysmaller,
PARALLEL = SAFE
);

CREATE AGGREGATE sys.max(sys.money) (
SFUNC = sys.moneylarger,
STYPE = sys.money,
COMBINEFUNC = sys.moneylarger,
PARALLEL = SAFE
);
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,29 @@ CREATE OPERATOR sys.% (
END IF;
END $$;

CREATE OR REPLACE FUNCTION sys.moneylarger(sys.MONEY, sys.MONEY)
RETURNS sys.MONEY
AS 'babelfishpg_money', 'fixeddecimallarger'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE OR REPLACE FUNCTION sys.moneysmaller(sys.MONEY, sys.MONEY)
RETURNS sys.MONEY
AS 'babelfishpg_money', 'fixeddecimalsmaller'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE OR REPLACE AGGREGATE sys.min(sys.money) (
SFUNC = sys.moneysmaller,
STYPE = sys.money,
COMBINEFUNC = sys.moneysmaller,
PARALLEL = SAFE
);

CREATE OR REPLACE AGGREGATE sys.max(sys.money) (
SFUNC = sys.moneylarger,
STYPE = sys.money,
COMBINEFUNC = sys.moneylarger,
PARALLEL = SAFE
);

-- Reset search_path to not affect any subsequent scripts
SELECT set_config('search_path', trim(leading 'sys, ' from current_setting('search_path')), false);
4 changes: 2 additions & 2 deletions test/JDBC/expected/BABEL-3006.out
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ select cast(pg_typeof(m) as varchar(20)) d from (select min(d) as m from t3006_m
go
~~START~~
varchar
fixeddecimal
money
~~END~~

~~START~~
Expand All @@ -173,7 +173,7 @@ select cast(pg_typeof(m) as varchar(20)) d from (select max(d) as m from t3006_m
go
~~START~~
varchar
fixeddecimal
money
~~END~~

~~START~~
Expand Down
113 changes: 113 additions & 0 deletions test/JDBC/expected/money_aggregate-vu-cleanup.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
DROP PROCEDURE IF EXISTS get_column_info_p1;
GO

DROP TABLE IF EXISTS ResultTable1;
GO

DROP TABLE IF EXISTS ResultTable2;
GO

DROP TABLE IF EXISTS ResultTable3;
GO

DROP TABLE IF EXISTS ResultTable4;
GO

DROP TABLE IF EXISTS ResultTable5;
GO

DROP TABLE IF EXISTS ResultTable6;
GO

DROP TABLE IF EXISTS ResultTable7;
GO

DROP TABLE IF EXISTS ResultTable8;
GO

DROP TABLE IF EXISTS ResultTable9;
GO

DROP TABLE IF EXISTS ResultTable10;
GO

DROP TABLE IF EXISTS EmptyMoneyTable;
GO

DROP TABLE IF EXISTS ResultTableEmpty;
GO

DROP TABLE IF EXISTS ExtremeMoneyTable;
GO

DROP TABLE IF EXISTS ResultTableExtreme;
GO

DROP TABLE IF EXISTS MixedNullMoneyTable;
GO

DROP TABLE IF EXISTS ResultTableMixedNull;
GO

DROP TABLE IF EXISTS OverflowMoneyTable;
GO

DROP TABLE IF EXISTS ResultTableOverflow;
GO

DROP TABLE IF EXISTS NonMoneyTable;
GO

DROP TABLE IF EXISTS ResultTableNonMoney;
GO

-- Clean up Check Constraint Test
DROP TABLE IF EXISTS ResultTableCheck;
GO

DROP TABLE IF EXISTS CheckConstraintMoneyTable;
GO

-- Clean up Complex Dependent Objects Tests
DROP TABLE IF EXISTS ResultTableView;
GO

DROP TABLE IF EXISTS ResultTableFunction;
GO

DROP VIEW IF EXISTS MoneyView;
GO

DROP FUNCTION IF EXISTS GetTotalMoney;
GO

DROP PROCEDURE IF EXISTS InsertMoney;
GO

-- Clean up Indexed View Test
DROP TABLE IF EXISTS ResultTableIndexedView;
GO

DROP VIEW IF EXISTS IndexedMoneyView;
GO

DROP TABLE IF EXISTS IndexedViewBaseTable;
GO

DROP TABLE IF EXISTS CurrencyMoneyTable;
GO

DROP TABLE IF EXISTS ResultTableCurrency1;
GO

DROP TABLE IF EXISTS ResultTableCurrency2;
GO

DROP TABLE IF EXISTS ResultTableCurrency3;
GO

DROP TABLE IF EXISTS ResultTableCurrency4;
GO

DROP TABLE IF EXISTS TestMoneyTable;
GO
Loading