~ubuntu-branches/ubuntu/lucid/postgresql-8.4/lucid-security

« back to all changes in this revision

Viewing changes to src/test/regress/sql/txid.sql

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- txid_snapshot data type and related functions
 
2
 
 
3
-- i/o
 
4
select '12:13:'::txid_snapshot;
 
5
select '12:18:14,16'::txid_snapshot;
 
6
 
 
7
-- errors
 
8
select '31:12:'::txid_snapshot;
 
9
select '0:1:'::txid_snapshot;
 
10
select '12:13:0'::txid_snapshot;
 
11
select '12:16:14,13'::txid_snapshot;
 
12
select '12:16:14,14'::txid_snapshot;
 
13
 
 
14
create temp table snapshot_test (
 
15
        nr      integer,
 
16
        snap    txid_snapshot
 
17
);
 
18
 
 
19
insert into snapshot_test values (1, '12:13:');
 
20
insert into snapshot_test values (2, '12:20:13,15,18');
 
21
insert into snapshot_test values (3, '100001:100009:100005,100007,100008');
 
22
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');
 
23
select snap from snapshot_test order by nr;
 
24
 
 
25
select  txid_snapshot_xmin(snap),
 
26
        txid_snapshot_xmax(snap),
 
27
        txid_snapshot_xip(snap)
 
28
from snapshot_test order by nr;
 
29
 
 
30
select id, txid_visible_in_snapshot(id, snap)
 
31
from snapshot_test, generate_series(11, 21) id
 
32
where nr = 2;
 
33
 
 
34
-- test bsearch
 
35
select id, txid_visible_in_snapshot(id, snap)
 
36
from snapshot_test, generate_series(90, 160) id
 
37
where nr = 4;
 
38
 
 
39
-- test current values also
 
40
select txid_current() >= txid_snapshot_xmin(txid_current_snapshot());
 
41
 
 
42
-- we can't assume current is always less than xmax, however
 
43
 
 
44
select txid_visible_in_snapshot(txid_current(), txid_current_snapshot());
 
45
 
 
46
-- test 64bitness
 
47
 
 
48
select txid_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013';
 
49
select txid_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013');
 
50
select txid_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013');
 
51
 
 
52
-- test 64bit overflow
 
53
SELECT txid_snapshot '1:9223372036854775807:3';
 
54
SELECT txid_snapshot '1:9223372036854775808:3';