summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorThomas Munro2020-04-06 23:08:14 +0000
committerThomas Munro2020-04-07 00:03:59 +0000
commitaeec457de8a8820368e343e791accffe24dc7198 (patch)
tree1e95e2de03595a459bc26717cf4a3bb22163fb83 /src/test
parent4bea576b032d6e5435ef0946194aada314e67691 (diff)
Add SQL type xid8 to expose FullTransactionId to users.
Similar to xid, but 64 bits wide. This new type is suitable for use in various system views and administration functions. Reviewed-by: Fujii Masao <[email protected]> Reviewed-by: Takao Fujii <[email protected]> Reviewed-by: Yoshikazu Imai <[email protected]> Reviewed-by: Mark Dilger <[email protected]> Discussion: https://postgr.es/m/20190725000636.666m5mad25wfbrri%40alap3.anarazel.de
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/opr_sanity.out7
-rw-r--r--src/test/regress/expected/xid.out136
-rw-r--r--src/test/regress/parallel_schedule2
-rw-r--r--src/test/regress/serial_schedule1
-rw-r--r--src/test/regress/sql/xid.sql48
5 files changed, 193 insertions, 1 deletions
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index 2efd7d7ec74..0c03afe53d2 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -832,6 +832,13 @@ macaddr8_gt(macaddr8,macaddr8)
macaddr8_ge(macaddr8,macaddr8)
macaddr8_ne(macaddr8,macaddr8)
macaddr8_cmp(macaddr8,macaddr8)
+xid8lt(xid8,xid8)
+xid8gt(xid8,xid8)
+xid8le(xid8,xid8)
+xid8ge(xid8,xid8)
+xid8eq(xid8,xid8)
+xid8ne(xid8,xid8)
+xid8cmp(xid8,xid8)
-- restore normal output mode
\a\t
-- List of functions used by libpq's fe-lobj.c
diff --git a/src/test/regress/expected/xid.out b/src/test/regress/expected/xid.out
new file mode 100644
index 00000000000..e9e1fa82591
--- /dev/null
+++ b/src/test/regress/expected/xid.out
@@ -0,0 +1,136 @@
+-- xid and xid8
+-- values in range, in octal, decimal, hex
+select '010'::xid,
+ '42'::xid,
+ '0xffffffff'::xid,
+ '-1'::xid,
+ '010'::xid8,
+ '42'::xid8,
+ '0xffffffffffffffff'::xid8,
+ '-1'::xid8;
+ xid | xid | xid | xid | xid8 | xid8 | xid8 | xid8
+-----+-----+------------+------------+------+------+----------------------+----------------------
+ 8 | 42 | 4294967295 | 4294967295 | 8 | 42 | 18446744073709551615 | 18446744073709551615
+(1 row)
+
+-- garbage values are not yet rejected (perhaps they should be)
+select ''::xid;
+ xid
+-----
+ 0
+(1 row)
+
+select 'asdf'::xid;
+ xid
+-----
+ 0
+(1 row)
+
+select ''::xid8;
+ xid8
+------
+ 0
+(1 row)
+
+select 'asdf'::xid8;
+ xid8
+------
+ 0
+(1 row)
+
+-- equality
+select '1'::xid = '1'::xid;
+ ?column?
+----------
+ t
+(1 row)
+
+select '1'::xid != '1'::xid;
+ ?column?
+----------
+ f
+(1 row)
+
+select '1'::xid8 = '1'::xid8;
+ ?column?
+----------
+ t
+(1 row)
+
+select '1'::xid8 != '1'::xid8;
+ ?column?
+----------
+ f
+(1 row)
+
+-- conversion
+select '1'::xid = '1'::xid8::xid;
+ ?column?
+----------
+ t
+(1 row)
+
+select '1'::xid != '1'::xid8::xid;
+ ?column?
+----------
+ f
+(1 row)
+
+-- we don't want relational operators for xid, due to use of modular arithmetic
+select '1'::xid < '2'::xid;
+ERROR: operator does not exist: xid < xid
+LINE 1: select '1'::xid < '2'::xid;
+ ^
+HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
+select '1'::xid <= '2'::xid;
+ERROR: operator does not exist: xid <= xid
+LINE 1: select '1'::xid <= '2'::xid;
+ ^
+HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
+select '1'::xid > '2'::xid;
+ERROR: operator does not exist: xid > xid
+LINE 1: select '1'::xid > '2'::xid;
+ ^
+HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
+select '1'::xid >= '2'::xid;
+ERROR: operator does not exist: xid >= xid
+LINE 1: select '1'::xid >= '2'::xid;
+ ^
+HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
+-- we want them for xid8 though
+select '1'::xid8 < '2'::xid8, '2'::xid8 < '2'::xid8, '2'::xid8 < '1'::xid8;
+ ?column? | ?column? | ?column?
+----------+----------+----------
+ t | f | f
+(1 row)
+
+select '1'::xid8 <= '2'::xid8, '2'::xid8 <= '2'::xid8, '2'::xid8 <= '1'::xid8;
+ ?column? | ?column? | ?column?
+----------+----------+----------
+ t | t | f
+(1 row)
+
+select '1'::xid8 > '2'::xid8, '2'::xid8 > '2'::xid8, '2'::xid8 > '1'::xid8;
+ ?column? | ?column? | ?column?
+----------+----------+----------
+ f | f | t
+(1 row)
+
+select '1'::xid8 >= '2'::xid8, '2'::xid8 >= '2'::xid8, '2'::xid8 >= '1'::xid8;
+ ?column? | ?column? | ?column?
+----------+----------+----------
+ f | t | t
+(1 row)
+
+-- we also have a 3way compare for btrees
+select xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1');
+ xid8cmp | xid8cmp | xid8cmp
+---------+---------+---------
+ -1 | 0 | 1
+(1 row)
+
+-- xid8 has btree and hash opclasses
+create table xid8_t1 (x xid8);
+create index on xid8_t1 using btree(x);
+create index on xid8_t1 using hash(x);
+drop table xid8_t1;
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index a741e89616a..95f1925072b 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -20,7 +20,7 @@ test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeri
# strings depends on char, varchar and text
# numerology depends on int2, int4, int8, float4, float8
# ----------
-test: strings numerology point lseg line box path polygon circle date time timetz timestamp timestamptz interval inet macaddr macaddr8 tstypes
+test: strings numerology point lseg line box path polygon circle date time timetz timestamp timestamptz interval inet macaddr macaddr8 tstypes xid
# ----------
# Another group of parallel tests
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index 1a6821ca46b..8ba41362202 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -10,6 +10,7 @@ test: int2
test: int4
test: int8
test: oid
+test: xid
test: float4
test: float8
test: bit
diff --git a/src/test/regress/sql/xid.sql b/src/test/regress/sql/xid.sql
new file mode 100644
index 00000000000..a4fbca51766
--- /dev/null
+++ b/src/test/regress/sql/xid.sql
@@ -0,0 +1,48 @@
+-- xid and xid8
+
+-- values in range, in octal, decimal, hex
+select '010'::xid,
+ '42'::xid,
+ '0xffffffff'::xid,
+ '-1'::xid,
+ '010'::xid8,
+ '42'::xid8,
+ '0xffffffffffffffff'::xid8,
+ '-1'::xid8;
+
+-- garbage values are not yet rejected (perhaps they should be)
+select ''::xid;
+select 'asdf'::xid;
+select ''::xid8;
+select 'asdf'::xid8;
+
+-- equality
+select '1'::xid = '1'::xid;
+select '1'::xid != '1'::xid;
+select '1'::xid8 = '1'::xid8;
+select '1'::xid8 != '1'::xid8;
+
+-- conversion
+select '1'::xid = '1'::xid8::xid;
+select '1'::xid != '1'::xid8::xid;
+
+-- we don't want relational operators for xid, due to use of modular arithmetic
+select '1'::xid < '2'::xid;
+select '1'::xid <= '2'::xid;
+select '1'::xid > '2'::xid;
+select '1'::xid >= '2'::xid;
+
+-- we want them for xid8 though
+select '1'::xid8 < '2'::xid8, '2'::xid8 < '2'::xid8, '2'::xid8 < '1'::xid8;
+select '1'::xid8 <= '2'::xid8, '2'::xid8 <= '2'::xid8, '2'::xid8 <= '1'::xid8;
+select '1'::xid8 > '2'::xid8, '2'::xid8 > '2'::xid8, '2'::xid8 > '1'::xid8;
+select '1'::xid8 >= '2'::xid8, '2'::xid8 >= '2'::xid8, '2'::xid8 >= '1'::xid8;
+
+-- we also have a 3way compare for btrees
+select xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1');
+
+-- xid8 has btree and hash opclasses
+create table xid8_t1 (x xid8);
+create index on xid8_t1 using btree(x);
+create index on xid8_t1 using hash(x);
+drop table xid8_t1;