mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Add min() and max() aggregates for xid8.
Bump catalog version. Author: Ken Kato Reviewed-by: Kyotaro Horiguchi, Fujii Masao Discussion: https://postgr.es/m/47d77b18c44f87f8222c4c7a3e2dee6b@oss.nttdata.com
This commit is contained in:
parent
adbd00f7a5
commit
400fc6b648
@ -19973,7 +19973,7 @@ SELECT NULLIF(value, '(none)') ...
|
|||||||
values. Available for any numeric, string, date/time, or enum type,
|
values. Available for any numeric, string, date/time, or enum type,
|
||||||
as well as <type>inet</type>, <type>interval</type>,
|
as well as <type>inet</type>, <type>interval</type>,
|
||||||
<type>money</type>, <type>oid</type>, <type>pg_lsn</type>,
|
<type>money</type>, <type>oid</type>, <type>pg_lsn</type>,
|
||||||
<type>tid</type>,
|
<type>tid</type>, <type>xid8</type>,
|
||||||
and arrays of any of these types.
|
and arrays of any of these types.
|
||||||
</para></entry>
|
</para></entry>
|
||||||
<entry>Yes</entry>
|
<entry>Yes</entry>
|
||||||
@ -19992,7 +19992,7 @@ SELECT NULLIF(value, '(none)') ...
|
|||||||
values. Available for any numeric, string, date/time, or enum type,
|
values. Available for any numeric, string, date/time, or enum type,
|
||||||
as well as <type>inet</type>, <type>interval</type>,
|
as well as <type>inet</type>, <type>interval</type>,
|
||||||
<type>money</type>, <type>oid</type>, <type>pg_lsn</type>,
|
<type>money</type>, <type>oid</type>, <type>pg_lsn</type>,
|
||||||
<type>tid</type>,
|
<type>tid</type>, <type>xid8</type>,
|
||||||
and arrays of any of these types.
|
and arrays of any of these types.
|
||||||
</para></entry>
|
</para></entry>
|
||||||
<entry>Yes</entry>
|
<entry>Yes</entry>
|
||||||
|
@ -286,6 +286,30 @@ xid8cmp(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_INT32(-1);
|
PG_RETURN_INT32(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Datum
|
||||||
|
xid8_larger(PG_FUNCTION_ARGS)
|
||||||
|
{
|
||||||
|
FullTransactionId fxid1 = PG_GETARG_FULLTRANSACTIONID(0);
|
||||||
|
FullTransactionId fxid2 = PG_GETARG_FULLTRANSACTIONID(1);
|
||||||
|
|
||||||
|
if (FullTransactionIdFollows(fxid1, fxid2))
|
||||||
|
PG_RETURN_FULLTRANSACTIONID(fxid1);
|
||||||
|
else
|
||||||
|
PG_RETURN_FULLTRANSACTIONID(fxid2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Datum
|
||||||
|
xid8_smaller(PG_FUNCTION_ARGS)
|
||||||
|
{
|
||||||
|
FullTransactionId fxid1 = PG_GETARG_FULLTRANSACTIONID(0);
|
||||||
|
FullTransactionId fxid2 = PG_GETARG_FULLTRANSACTIONID(1);
|
||||||
|
|
||||||
|
if (FullTransactionIdPrecedes(fxid1, fxid2))
|
||||||
|
PG_RETURN_FULLTRANSACTIONID(fxid1);
|
||||||
|
else
|
||||||
|
PG_RETURN_FULLTRANSACTIONID(fxid2);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* COMMAND IDENTIFIER ROUTINES *
|
* COMMAND IDENTIFIER ROUTINES *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -53,6 +53,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 202202031
|
#define CATALOG_VERSION_NO 202202101
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -149,6 +149,9 @@
|
|||||||
{ aggfnoid => 'max(pg_lsn)', aggtransfn => 'pg_lsn_larger',
|
{ aggfnoid => 'max(pg_lsn)', aggtransfn => 'pg_lsn_larger',
|
||||||
aggcombinefn => 'pg_lsn_larger', aggsortop => '>(pg_lsn,pg_lsn)',
|
aggcombinefn => 'pg_lsn_larger', aggsortop => '>(pg_lsn,pg_lsn)',
|
||||||
aggtranstype => 'pg_lsn' },
|
aggtranstype => 'pg_lsn' },
|
||||||
|
{ aggfnoid => 'max(xid8)', aggtransfn => 'xid8_larger',
|
||||||
|
aggcombinefn => 'xid8_larger', aggsortop => '>(xid8,xid8)',
|
||||||
|
aggtranstype => 'xid8' },
|
||||||
|
|
||||||
# min
|
# min
|
||||||
{ aggfnoid => 'min(int8)', aggtransfn => 'int8smaller',
|
{ aggfnoid => 'min(int8)', aggtransfn => 'int8smaller',
|
||||||
@ -214,6 +217,9 @@
|
|||||||
{ aggfnoid => 'min(pg_lsn)', aggtransfn => 'pg_lsn_smaller',
|
{ aggfnoid => 'min(pg_lsn)', aggtransfn => 'pg_lsn_smaller',
|
||||||
aggcombinefn => 'pg_lsn_smaller', aggsortop => '<(pg_lsn,pg_lsn)',
|
aggcombinefn => 'pg_lsn_smaller', aggsortop => '<(pg_lsn,pg_lsn)',
|
||||||
aggtranstype => 'pg_lsn' },
|
aggtranstype => 'pg_lsn' },
|
||||||
|
{ aggfnoid => 'min(xid8)', aggtransfn => 'xid8_smaller',
|
||||||
|
aggcombinefn => 'xid8_smaller', aggsortop => '<(xid8,xid8)',
|
||||||
|
aggtranstype => 'xid8' },
|
||||||
|
|
||||||
# count
|
# count
|
||||||
{ aggfnoid => 'count(any)', aggtransfn => 'int8inc_any',
|
{ aggfnoid => 'count(any)', aggtransfn => 'int8inc_any',
|
||||||
|
@ -203,6 +203,12 @@
|
|||||||
{ oid => '5071', descr => 'convert xid8 to xid',
|
{ oid => '5071', descr => 'convert xid8 to xid',
|
||||||
proname => 'xid', prorettype => 'xid', proargtypes => 'xid8',
|
proname => 'xid', prorettype => 'xid', proargtypes => 'xid8',
|
||||||
prosrc => 'xid8toxid' },
|
prosrc => 'xid8toxid' },
|
||||||
|
{ oid => '5097', descr => 'larger of two',
|
||||||
|
proname => 'xid8_larger', prorettype => 'xid8', proargtypes => 'xid8 xid8',
|
||||||
|
prosrc => 'xid8_larger' },
|
||||||
|
{ oid => '5098', descr => 'smaller of two',
|
||||||
|
proname => 'xid8_smaller', prorettype => 'xid8', proargtypes => 'xid8 xid8',
|
||||||
|
prosrc => 'xid8_smaller' },
|
||||||
{ oid => '69',
|
{ oid => '69',
|
||||||
proname => 'cideq', proleakproof => 't', prorettype => 'bool',
|
proname => 'cideq', proleakproof => 't', prorettype => 'bool',
|
||||||
proargtypes => 'cid cid', prosrc => 'cideq' },
|
proargtypes => 'cid cid', prosrc => 'cideq' },
|
||||||
@ -6564,6 +6570,9 @@
|
|||||||
{ oid => '4189', descr => 'maximum value of all pg_lsn input values',
|
{ oid => '4189', descr => 'maximum value of all pg_lsn input values',
|
||||||
proname => 'max', prokind => 'a', proisstrict => 'f', prorettype => 'pg_lsn',
|
proname => 'max', prokind => 'a', proisstrict => 'f', prorettype => 'pg_lsn',
|
||||||
proargtypes => 'pg_lsn', prosrc => 'aggregate_dummy' },
|
proargtypes => 'pg_lsn', prosrc => 'aggregate_dummy' },
|
||||||
|
{ oid => '5099', descr => 'maximum value of all xid8 input values',
|
||||||
|
proname => 'max', prokind => 'a', proisstrict => 'f', prorettype => 'xid8',
|
||||||
|
proargtypes => 'xid8', prosrc => 'aggregate_dummy' },
|
||||||
|
|
||||||
{ oid => '2131', descr => 'minimum value of all bigint input values',
|
{ oid => '2131', descr => 'minimum value of all bigint input values',
|
||||||
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'int8',
|
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'int8',
|
||||||
@ -6631,6 +6640,9 @@
|
|||||||
{ oid => '4190', descr => 'minimum value of all pg_lsn input values',
|
{ oid => '4190', descr => 'minimum value of all pg_lsn input values',
|
||||||
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'pg_lsn',
|
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'pg_lsn',
|
||||||
proargtypes => 'pg_lsn', prosrc => 'aggregate_dummy' },
|
proargtypes => 'pg_lsn', prosrc => 'aggregate_dummy' },
|
||||||
|
{ oid => '5100', descr => 'minimum value of all xid8 input values',
|
||||||
|
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'xid8',
|
||||||
|
proargtypes => 'xid8', prosrc => 'aggregate_dummy' },
|
||||||
|
|
||||||
# count has two forms: count(any) and count(*)
|
# count has two forms: count(any) and count(*)
|
||||||
{ oid => '2147',
|
{ oid => '2147',
|
||||||
|
@ -129,8 +129,16 @@ select xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1');
|
|||||||
-1 | 0 | 1
|
-1 | 0 | 1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- xid8 has btree and hash opclasses
|
-- min() and max() for xid8
|
||||||
create table xid8_t1 (x xid8);
|
create table xid8_t1 (x xid8);
|
||||||
|
insert into xid8_t1 values ('0'), ('010'), ('42'), ('0xffffffffffffffff'), ('-1');
|
||||||
|
select min(x), max(x) from xid8_t1;
|
||||||
|
min | max
|
||||||
|
-----+----------------------
|
||||||
|
0 | 18446744073709551615
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- xid8 has btree and hash opclasses
|
||||||
create index on xid8_t1 using btree(x);
|
create index on xid8_t1 using btree(x);
|
||||||
create index on xid8_t1 using hash(x);
|
create index on xid8_t1 using hash(x);
|
||||||
drop table xid8_t1;
|
drop table xid8_t1;
|
||||||
|
@ -41,8 +41,12 @@ select '1'::xid8 >= '2'::xid8, '2'::xid8 >= '2'::xid8, '2'::xid8 >= '1'::xid8;
|
|||||||
-- we also have a 3way compare for btrees
|
-- we also have a 3way compare for btrees
|
||||||
select xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1');
|
select xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1');
|
||||||
|
|
||||||
-- xid8 has btree and hash opclasses
|
-- min() and max() for xid8
|
||||||
create table xid8_t1 (x xid8);
|
create table xid8_t1 (x xid8);
|
||||||
|
insert into xid8_t1 values ('0'), ('010'), ('42'), ('0xffffffffffffffff'), ('-1');
|
||||||
|
select min(x), max(x) from xid8_t1;
|
||||||
|
|
||||||
|
-- xid8 has btree and hash opclasses
|
||||||
create index on xid8_t1 using btree(x);
|
create index on xid8_t1 using btree(x);
|
||||||
create index on xid8_t1 using hash(x);
|
create index on xid8_t1 using hash(x);
|
||||||
drop table xid8_t1;
|
drop table xid8_t1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user