summaryrefslogtreecommitdiff
path: root/src/test/regress
diff options
context:
space:
mode:
authorTom Lane2007-10-13 23:06:28 +0000
committerTom Lane2007-10-13 23:06:28 +0000
commit18e3fcc31e79ab89a3c4296b33946999c0956cbb (patch)
tree72a9cbc2d3a760f0deece1be0107822201c15480 /src/test/regress
parent17333b6d0946ed71ec17d186014259ae76326d11 (diff)
Migrate the former contrib/txid module into core. This will make it easier
for Slony and Skytools to depend on it. Per discussion.
Diffstat (limited to 'src/test/regress')
-rw-r--r--src/test/regress/expected/txid.out226
-rw-r--r--src/test/regress/parallel_schedule4
-rw-r--r--src/test/regress/serial_schedule3
-rw-r--r--src/test/regress/sql/txid.sql54
4 files changed, 284 insertions, 3 deletions
diff --git a/src/test/regress/expected/txid.out b/src/test/regress/expected/txid.out
new file mode 100644
index 00000000000..59b629358a6
--- /dev/null
+++ b/src/test/regress/expected/txid.out
@@ -0,0 +1,226 @@
+-- txid_snapshot data type and related functions
+-- i/o
+select '12:13:'::txid_snapshot;
+ txid_snapshot
+---------------
+ 12:13:
+(1 row)
+
+select '12:18:14,16'::txid_snapshot;
+ txid_snapshot
+---------------
+ 12:18:14,16
+(1 row)
+
+-- errors
+select '31:12:'::txid_snapshot;
+ERROR: invalid input for txid_snapshot: "31:12:"
+select '0:1:'::txid_snapshot;
+ERROR: invalid input for txid_snapshot: "0:1:"
+select '12:13:0'::txid_snapshot;
+ERROR: invalid input for txid_snapshot: "12:13:0"
+select '12:16:14,13'::txid_snapshot;
+ERROR: invalid input for txid_snapshot: "12:16:14,13"
+select '12:16:14,14'::txid_snapshot;
+ERROR: invalid input for txid_snapshot: "12:16:14,14"
+create temp table snapshot_test (
+ nr integer,
+ snap txid_snapshot
+);
+insert into snapshot_test values (1, '12:13:');
+insert into snapshot_test values (2, '12:20:13,15,18');
+insert into snapshot_test values (3, '100001:100009:100005,100007,100008');
+insert into snapshot_test values (4, '100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131');
+select snap from snapshot_test order by nr;
+ snap
+-------------------------------------------------------------------------------------------------------------------------------------
+ 12:13:
+ 12:20:13,15,18
+ 100001:100009:100005,100007,100008
+ 100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131
+(4 rows)
+
+select txid_snapshot_xmin(snap),
+ txid_snapshot_xmax(snap),
+ txid_snapshot_xip(snap)
+from snapshot_test order by nr;
+ txid_snapshot_xmin | txid_snapshot_xmax | txid_snapshot_xip
+--------------------+--------------------+-------------------
+ 12 | 20 | 13
+ 12 | 20 | 15
+ 12 | 20 | 18
+ 100001 | 100009 | 100005
+ 100001 | 100009 | 100007
+ 100001 | 100009 | 100008
+ 100 | 150 | 101
+ 100 | 150 | 102
+ 100 | 150 | 103
+ 100 | 150 | 104
+ 100 | 150 | 105
+ 100 | 150 | 106
+ 100 | 150 | 107
+ 100 | 150 | 108
+ 100 | 150 | 109
+ 100 | 150 | 110
+ 100 | 150 | 111
+ 100 | 150 | 112
+ 100 | 150 | 113
+ 100 | 150 | 114
+ 100 | 150 | 115
+ 100 | 150 | 116
+ 100 | 150 | 117
+ 100 | 150 | 118
+ 100 | 150 | 119
+ 100 | 150 | 120
+ 100 | 150 | 121
+ 100 | 150 | 122
+ 100 | 150 | 123
+ 100 | 150 | 124
+ 100 | 150 | 125
+ 100 | 150 | 126
+ 100 | 150 | 127
+ 100 | 150 | 128
+ 100 | 150 | 129
+ 100 | 150 | 130
+ 100 | 150 | 131
+(37 rows)
+
+select id, txid_visible_in_snapshot(id, snap)
+from snapshot_test, generate_series(11, 21) id
+where nr = 2;
+ id | txid_visible_in_snapshot
+----+--------------------------
+ 11 | t
+ 12 | t
+ 13 | f
+ 14 | t
+ 15 | f
+ 16 | t
+ 17 | t
+ 18 | f
+ 19 | t
+ 20 | f
+ 21 | f
+(11 rows)
+
+-- test bsearch
+select id, txid_visible_in_snapshot(id, snap)
+from snapshot_test, generate_series(90, 160) id
+where nr = 4;
+ id | txid_visible_in_snapshot
+-----+--------------------------
+ 90 | t
+ 91 | t
+ 92 | t
+ 93 | t
+ 94 | t
+ 95 | t
+ 96 | t
+ 97 | t
+ 98 | t
+ 99 | t
+ 100 | t
+ 101 | f
+ 102 | f
+ 103 | f
+ 104 | f
+ 105 | f
+ 106 | f
+ 107 | f
+ 108 | f
+ 109 | f
+ 110 | f
+ 111 | f
+ 112 | f
+ 113 | f
+ 114 | f
+ 115 | f
+ 116 | f
+ 117 | f
+ 118 | f
+ 119 | f
+ 120 | f
+ 121 | f
+ 122 | f
+ 123 | f
+ 124 | f
+ 125 | f
+ 126 | f
+ 127 | f
+ 128 | f
+ 129 | f
+ 130 | f
+ 131 | f
+ 132 | t
+ 133 | t
+ 134 | t
+ 135 | t
+ 136 | t
+ 137 | t
+ 138 | t
+ 139 | t
+ 140 | t
+ 141 | t
+ 142 | t
+ 143 | t
+ 144 | t
+ 145 | t
+ 146 | t
+ 147 | t
+ 148 | t
+ 149 | t
+ 150 | f
+ 151 | f
+ 152 | f
+ 153 | f
+ 154 | f
+ 155 | f
+ 156 | f
+ 157 | f
+ 158 | f
+ 159 | f
+ 160 | f
+(71 rows)
+
+-- test current values also
+select txid_current() >= txid_snapshot_xmin(txid_current_snapshot());
+ ?column?
+----------
+ t
+(1 row)
+
+-- we can't assume current is always less than xmax, however
+select txid_visible_in_snapshot(txid_current(), txid_current_snapshot());
+ txid_visible_in_snapshot
+--------------------------
+ f
+(1 row)
+
+-- test 64bitness
+select txid_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013';
+ txid_snapshot
+---------------------------------------------------------------------
+ 1000100010001000:1000100010001100:1000100010001012,1000100010001013
+(1 row)
+
+select txid_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013');
+ txid_visible_in_snapshot
+--------------------------
+ f
+(1 row)
+
+select txid_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013');
+ txid_visible_in_snapshot
+--------------------------
+ t
+(1 row)
+
+-- test 64bit overflow
+SELECT txid_snapshot '1:9223372036854775807:3';
+ txid_snapshot
+-------------------------
+ 1:9223372036854775807:3
+(1 row)
+
+SELECT txid_snapshot '1:9223372036854775808:3';
+ERROR: invalid input for txid_snapshot: "1:9223372036854775808:3"
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index 4d5af5b16d5..6d33f380204 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -1,5 +1,5 @@
# ----------
-# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.44 2007/09/11 11:54:42 teodor Exp $
+# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.45 2007/10/13 23:06:27 tgl Exp $
#
# By convention, we put no more than twenty tests in any one parallel group;
# this limits the number of connections needed to run the tests.
@@ -8,7 +8,7 @@
# ----------
# The first group of parallel tests
# ----------
-test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeric uuid enum
+test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeric txid uuid enum
# Depends on things setup during char, varchar and text
test: strings
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index 856682469cc..fdb8446f657 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.41 2007/09/11 11:54:42 teodor Exp $
+# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.42 2007/10/13 23:06:27 tgl Exp $
# This should probably be in an order similar to parallel_schedule.
test: boolean
test: char
@@ -13,6 +13,7 @@ test: float4
test: float8
test: bit
test: numeric
+test: txid
test: uuid
test: enum
test: strings
diff --git a/src/test/regress/sql/txid.sql b/src/test/regress/sql/txid.sql
new file mode 100644
index 00000000000..ecae10e024d
--- /dev/null
+++ b/src/test/regress/sql/txid.sql
@@ -0,0 +1,54 @@
+-- txid_snapshot data type and related functions
+
+-- i/o
+select '12:13:'::txid_snapshot;
+select '12:18:14,16'::txid_snapshot;
+
+-- errors
+select '31:12:'::txid_snapshot;
+select '0:1:'::txid_snapshot;
+select '12:13:0'::txid_snapshot;
+select '12:16:14,13'::txid_snapshot;
+select '12:16:14,14'::txid_snapshot;
+
+create temp table snapshot_test (
+ nr integer,
+ snap txid_snapshot
+);
+
+insert into snapshot_test values (1, '12:13:');
+insert into snapshot_test values (2, '12:20:13,15,18');
+insert into snapshot_test values (3, '100001:100009:100005,100007,100008');
+insert into snapshot_test values (4, '100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131');
+select snap from snapshot_test order by nr;
+
+select txid_snapshot_xmin(snap),
+ txid_snapshot_xmax(snap),
+ txid_snapshot_xip(snap)
+from snapshot_test order by nr;
+
+select id, txid_visible_in_snapshot(id, snap)
+from snapshot_test, generate_series(11, 21) id
+where nr = 2;
+
+-- test bsearch
+select id, txid_visible_in_snapshot(id, snap)
+from snapshot_test, generate_series(90, 160) id
+where nr = 4;
+
+-- test current values also
+select txid_current() >= txid_snapshot_xmin(txid_current_snapshot());
+
+-- we can't assume current is always less than xmax, however
+
+select txid_visible_in_snapshot(txid_current(), txid_current_snapshot());
+
+-- test 64bitness
+
+select txid_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013';
+select txid_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013');
+select txid_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013');
+
+-- test 64bit overflow
+SELECT txid_snapshot '1:9223372036854775807:3';
+SELECT txid_snapshot '1:9223372036854775808:3';