Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit400fc6b

Browse files
committed
Add min() and max() aggregates for xid8.
Bump catalog version.Author: Ken KatoReviewed-by: Kyotaro Horiguchi, Fujii MasaoDiscussion:https://postgr.es/m/47d77b18c44f87f8222c4c7a3e2dee6b@oss.nttdata.com
1 parentadbd00f commit400fc6b

File tree

7 files changed

+59
-5
lines changed

7 files changed

+59
-5
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19973,7 +19973,7 @@ SELECT NULLIF(value, '(none)') ...
1997319973
values. Available for any numeric, string, date/time, or enum type,
1997419974
as well as <type>inet</type>, <type>interval</type>,
1997519975
<type>money</type>, <type>oid</type>, <type>pg_lsn</type>,
19976-
<type>tid</type>,
19976+
<type>tid</type>, <type>xid8</type>,
1997719977
and arrays of any of these types.
1997819978
</para></entry>
1997919979
<entry>Yes</entry>
@@ -19992,7 +19992,7 @@ SELECT NULLIF(value, '(none)') ...
1999219992
values. Available for any numeric, string, date/time, or enum type,
1999319993
as well as <type>inet</type>, <type>interval</type>,
1999419994
<type>money</type>, <type>oid</type>, <type>pg_lsn</type>,
19995-
<type>tid</type>,
19995+
<type>tid</type>, <type>xid8</type>,
1999619996
and arrays of any of these types.
1999719997
</para></entry>
1999819998
<entry>Yes</entry>

‎src/backend/utils/adt/xid.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,30 @@ xid8cmp(PG_FUNCTION_ARGS)
286286
PG_RETURN_INT32(-1);
287287
}
288288

289+
Datum
290+
xid8_larger(PG_FUNCTION_ARGS)
291+
{
292+
FullTransactionIdfxid1=PG_GETARG_FULLTRANSACTIONID(0);
293+
FullTransactionIdfxid2=PG_GETARG_FULLTRANSACTIONID(1);
294+
295+
if (FullTransactionIdFollows(fxid1,fxid2))
296+
PG_RETURN_FULLTRANSACTIONID(fxid1);
297+
else
298+
PG_RETURN_FULLTRANSACTIONID(fxid2);
299+
}
300+
301+
Datum
302+
xid8_smaller(PG_FUNCTION_ARGS)
303+
{
304+
FullTransactionIdfxid1=PG_GETARG_FULLTRANSACTIONID(0);
305+
FullTransactionIdfxid2=PG_GETARG_FULLTRANSACTIONID(1);
306+
307+
if (FullTransactionIdPrecedes(fxid1,fxid2))
308+
PG_RETURN_FULLTRANSACTIONID(fxid1);
309+
else
310+
PG_RETURN_FULLTRANSACTIONID(fxid2);
311+
}
312+
289313
/*****************************************************************************
290314
* COMMAND IDENTIFIER ROUTINES *
291315
*****************************************************************************/

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO202202031
56+
#defineCATALOG_VERSION_NO202202101
5757

5858
#endif

‎src/include/catalog/pg_aggregate.dat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@
149149
{ aggfnoid => 'max(pg_lsn)', aggtransfn => 'pg_lsn_larger',
150150
aggcombinefn => 'pg_lsn_larger', aggsortop => '>(pg_lsn,pg_lsn)',
151151
aggtranstype => 'pg_lsn' },
152+
{ aggfnoid => 'max(xid8)', aggtransfn => 'xid8_larger',
153+
aggcombinefn => 'xid8_larger', aggsortop => '>(xid8,xid8)',
154+
aggtranstype => 'xid8' },
152155

153156
# min
154157
{ aggfnoid => 'min(int8)', aggtransfn => 'int8smaller',
@@ -214,6 +217,9 @@
214217
{ aggfnoid => 'min(pg_lsn)', aggtransfn => 'pg_lsn_smaller',
215218
aggcombinefn => 'pg_lsn_smaller', aggsortop => '<(pg_lsn,pg_lsn)',
216219
aggtranstype => 'pg_lsn' },
220+
{ aggfnoid => 'min(xid8)', aggtransfn => 'xid8_smaller',
221+
aggcombinefn => 'xid8_smaller', aggsortop => '<(xid8,xid8)',
222+
aggtranstype => 'xid8' },
217223

218224
# count
219225
{ aggfnoid => 'count(any)', aggtransfn => 'int8inc_any',

‎src/include/catalog/pg_proc.dat

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@
203203
{ oid => '5071', descr => 'convert xid8 to xid',
204204
proname => 'xid', prorettype => 'xid', proargtypes => 'xid8',
205205
prosrc => 'xid8toxid' },
206+
{ oid => '5097', descr => 'larger of two',
207+
proname => 'xid8_larger', prorettype => 'xid8', proargtypes => 'xid8 xid8',
208+
prosrc => 'xid8_larger' },
209+
{ oid => '5098', descr => 'smaller of two',
210+
proname => 'xid8_smaller', prorettype => 'xid8', proargtypes => 'xid8 xid8',
211+
prosrc => 'xid8_smaller' },
206212
{ oid => '69',
207213
proname => 'cideq', proleakproof => 't', prorettype => 'bool',
208214
proargtypes => 'cid cid', prosrc => 'cideq' },
@@ -6564,6 +6570,9 @@
65646570
{ oid => '4189', descr => 'maximum value of all pg_lsn input values',
65656571
proname => 'max', prokind => 'a', proisstrict => 'f', prorettype => 'pg_lsn',
65666572
proargtypes => 'pg_lsn', prosrc => 'aggregate_dummy' },
6573+
{ oid => '5099', descr => 'maximum value of all xid8 input values',
6574+
proname => 'max', prokind => 'a', proisstrict => 'f', prorettype => 'xid8',
6575+
proargtypes => 'xid8', prosrc => 'aggregate_dummy' },
65676576

65686577
{ oid => '2131', descr => 'minimum value of all bigint input values',
65696578
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'int8',
@@ -6631,6 +6640,9 @@
66316640
{ oid => '4190', descr => 'minimum value of all pg_lsn input values',
66326641
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'pg_lsn',
66336642
proargtypes => 'pg_lsn', prosrc => 'aggregate_dummy' },
6643+
{ oid => '5100', descr => 'minimum value of all xid8 input values',
6644+
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'xid8',
6645+
proargtypes => 'xid8', prosrc => 'aggregate_dummy' },
66346646

66356647
# count has two forms: count(any) and count(*)
66366648
{ oid => '2147',

‎src/test/regress/expected/xid.out

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,16 @@ select xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1');
129129
-1 | 0 | 1
130130
(1 row)
131131

132-
--xid8 has btreeandhash opclasses
132+
--min()andmax() for xid8
133133
create table xid8_t1 (x xid8);
134+
insert into xid8_t1 values ('0'), ('010'), ('42'), ('0xffffffffffffffff'), ('-1');
135+
select min(x), max(x) from xid8_t1;
136+
min | max
137+
-----+----------------------
138+
0 | 18446744073709551615
139+
(1 row)
140+
141+
-- xid8 has btree and hash opclasses
134142
create index on xid8_t1 using btree(x);
135143
create index on xid8_t1 using hash(x);
136144
drop table xid8_t1;

‎src/test/regress/sql/xid.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ select '1'::xid8 >= '2'::xid8, '2'::xid8 >= '2'::xid8, '2'::xid8 >= '1'::xid8;
4141
-- we also have a 3way compare for btrees
4242
select xid8cmp('1','2'), xid8cmp('2','2'), xid8cmp('2','1');
4343

44-
--xid8 has btreeandhash opclasses
44+
--min()andmax() for xid8
4545
createtablexid8_t1 (x xid8);
46+
insert into xid8_t1values ('0'), ('010'), ('42'), ('0xffffffffffffffff'), ('-1');
47+
selectmin(x),max(x)from xid8_t1;
48+
49+
-- xid8 has btree and hash opclasses
4650
createindexon xid8_t1 using btree(x);
4751
createindexon xid8_t1 using hash(x);
4852
droptable xid8_t1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp