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

Commit4c04be9

Browse files
committed
Introduce xid8-based functions to replace txid_XXX.
The txid_XXX family of fmgr functions exposes 64 bit transaction IDs tousers as int8. Now that we have an SQL type xid8 for FullTransactionId,define a new set of functions including pg_current_xact_id() andpg_current_snapshot() based on that. Keep the old functions around too,for now.It's a bit sneaky to use the same C functions for both, but since thebinary representation is identical except for the signedness of thetype, and since older functions are the ones using the wrong signedness,and since we'll presumably drop the older ones after a reasonable periodof time, it seems reasonable to switch to FullTransactionId internallyand share the code for both.Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>Reviewed-by: Takao Fujii <btfujiitkp@oss.nttdata.com>Reviewed-by: Yoshikazu Imai <imai.yoshikazu@fujitsu.com>Reviewed-by: Mark Dilger <mark.dilger@enterprisedb.com>Discussion:https://postgr.es/m/20190725000636.666m5mad25wfbrri%40alap3.anarazel.de
1 parentaeec457 commit4c04be9

36 files changed

+871
-355
lines changed

‎contrib/test_decoding/expected/ddl.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
382382
-- test whether a known, but not yet logged toplevel xact, followed by a
383383
-- subxact commit is handled correctly
384384
BEGIN;
385-
SELECTtxid_current() !=0; -- so no fixed xid apears in the outfile
385+
SELECTpg_current_xact_id() !='0'; -- so no fixed xid apears in the outfile
386386
?column?
387387
----------
388388
t

‎contrib/test_decoding/expected/decoding_in_xact.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SET synchronous_commit = on;
33
-- fail because we're creating a slot while in an xact with xid
44
BEGIN;
5-
SELECTtxid_current() =0;
5+
SELECTpg_current_xact_id() ='0';
66
?column?
77
----------
88
f
@@ -13,7 +13,7 @@ ERROR: cannot create logical replication slot in transaction that has performed
1313
ROLLBACK;
1414
-- fail because we're creating a slot while in a subxact whose topxact has an xid
1515
BEGIN;
16-
SELECTtxid_current() =0;
16+
SELECTpg_current_xact_id() ='0';
1717
?column?
1818
----------
1919
f
@@ -50,7 +50,7 @@ CREATE TABLE nobarf(id serial primary key, data text);
5050
INSERT INTO nobarf(data) VALUES('1');
5151
-- decoding works in transaction with xid
5252
BEGIN;
53-
SELECTtxid_current() =0;
53+
SELECTpg_current_xact_id() ='0';
5454
?column?
5555
----------
5656
f

‎contrib/test_decoding/expected/oldest_xmin.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Parsed test spec with 2 sessions
22

33
starting permutation: s0_begin s0_getxid s1_begin s1_insert s0_alter s0_commit s0_checkpoint s0_get_changes s0_get_changes s1_commit s0_vacuum s0_get_changes
44
step s0_begin: BEGIN;
5-
step s0_getxid: SELECTtxid_current() IS NULL;
5+
step s0_getxid: SELECTpg_current_xact_id() IS NULL;
66
?column?
77

88
f

‎contrib/test_decoding/expected/ondisk_startup.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ Parsed test spec with 3 sessions
22

33
starting permutation: s2b s2txid s1init s3b s3txid s2alter s2c s2b s2txid s3c s2c s1insert s1checkpoint s1start s1insert s1alter s1insert s1start
44
step s2b: BEGIN;
5-
step s2txid: SELECTtxid_current() IS NULL;
5+
step s2txid: SELECTpg_current_xact_id() IS NULL;
66
?column?
77

88
f
99
step s1init: SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'test_decoding'); <waiting ...>
1010
step s3b: BEGIN;
11-
step s3txid: SELECTtxid_current() IS NULL;
11+
step s3txid: SELECTpg_current_xact_id() IS NULL;
1212
?column?
1313

1414
f
1515
step s2alter: ALTER TABLE do_write ADD COLUMN addedbys2 int;
1616
step s2c: COMMIT;
1717
step s2b: BEGIN;
18-
step s2txid: SELECTtxid_current() IS NULL;
18+
step s2txid: SELECTpg_current_xact_id() IS NULL;
1919
?column?
2020

2121
f

‎contrib/test_decoding/expected/snapshot_transfer.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Parsed test spec with 2 sessions
33
starting permutation: s0_begin s0_begin_sub0 s0_log_assignment s0_sub_get_base_snap s1_produce_new_snap s0_insert s0_end_sub0 s0_commit s0_get_changes
44
step s0_begin: BEGIN;
55
step s0_begin_sub0: SAVEPOINT s0;
6-
step s0_log_assignment: SELECTtxid_current() IS NULL;
6+
step s0_log_assignment: SELECTpg_current_xact_id() IS NULL;
77
?column?
88

99
f
@@ -26,7 +26,7 @@ stop
2626
starting permutation: s0_begin s0_begin_sub0 s0_log_assignment s0_begin_sub1 s0_sub_get_base_snap s1_produce_new_snap s0_insert s0_end_sub1 s0_end_sub0 s0_commit s0_get_changes
2727
step s0_begin: BEGIN;
2828
step s0_begin_sub0: SAVEPOINT s0;
29-
step s0_log_assignment: SELECTtxid_current() IS NULL;
29+
step s0_log_assignment: SELECTpg_current_xact_id() IS NULL;
3030
?column?
3131

3232
f

‎contrib/test_decoding/specs/oldest_xmin.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ teardown
1919
session"s0"
2020
setup {SETsynchronous_commit=on; }
2121
step"s0_begin" {BEGIN; }
22-
step"s0_getxid" {SELECTtxid_current()ISNULL; }
22+
step"s0_getxid" {SELECTpg_current_xact_id()ISNULL; }
2323
step"s0_alter" {ALTERTYPEbasketDROPATTRIBUTEmangos; }
2424
step"s0_commit" {COMMIT; }
2525
step"s0_checkpoint" {CHECKPOINT; }

‎contrib/test_decoding/specs/ondisk_startup.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ session "s2"
2525
setup {SETsynchronous_commit=on; }
2626

2727
step"s2b" {BEGIN; }
28-
step"s2txid" {SELECTtxid_current()ISNULL; }
28+
step"s2txid" {SELECTpg_current_xact_id()ISNULL; }
2929
step"s2alter" {ALTERTABLEdo_writeADDCOLUMNaddedbys2int; }
3030
step"s2c" {COMMIT; }
3131

@@ -34,7 +34,7 @@ session "s3"
3434
setup {SETsynchronous_commit=on; }
3535

3636
step"s3b" {BEGIN; }
37-
step"s3txid" {SELECTtxid_current()ISNULL; }
37+
step"s3txid" {SELECTpg_current_xact_id()ISNULL; }
3838
step"s3c" {COMMIT; }
3939

4040
# Force usage of ondisk snapshot by starting and not finishing a

‎contrib/test_decoding/specs/snapshot_transfer.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ session "s0"
2020
setup {SETsynchronous_commit=on; }
2121
step"s0_begin" {BEGIN; }
2222
step"s0_begin_sub0" {SAVEPOINTs0; }
23-
step"s0_log_assignment" {SELECTtxid_current()ISNULL; }
23+
step"s0_log_assignment" {SELECTpg_current_xact_id()ISNULL; }
2424
step"s0_begin_sub1" {SAVEPOINTs1; }
2525
step"s0_sub_get_base_snap" {INSERTINTOdummyVALUES (0); }
2626
step"s0_insert" {INSERTINTOharvestVALUES (1,2,3); }

‎contrib/test_decoding/sql/ddl.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
220220
-- test whether a known, but not yet logged toplevel xact, followed by a
221221
-- subxact commit is handled correctly
222222
BEGIN;
223-
SELECTtxid_current()!=0;-- so no fixed xid apears in the outfile
223+
SELECTpg_current_xact_id()!='0';-- so no fixed xid apears in the outfile
224224
SAVEPOINT a;
225225
INSERT INTO tr_sub(path)VALUES ('4-top-1-#1');
226226
RELEASE SAVEPOINT a;

‎contrib/test_decoding/sql/decoding_in_xact.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ SET synchronous_commit = on;
33

44
-- fail because we're creating a slot while in an xact with xid
55
BEGIN;
6-
SELECTtxid_current()=0;
6+
SELECTpg_current_xact_id()='0';
77
SELECT'init'FROM pg_create_logical_replication_slot('regression_slot','test_decoding');
88
ROLLBACK;
99

1010
-- fail because we're creating a slot while in a subxact whose topxact has an xid
1111
BEGIN;
12-
SELECTtxid_current()=0;
12+
SELECTpg_current_xact_id()='0';
1313
SAVEPOINT barf;
1414
SELECT'init'FROM pg_create_logical_replication_slot('regression_slot','test_decoding');
1515
ROLLBACK TO SAVEPOINT barf;
@@ -29,7 +29,7 @@ INSERT INTO nobarf(data) VALUES('1');
2929

3030
-- decoding works in transaction with xid
3131
BEGIN;
32-
SELECTtxid_current()=0;
32+
SELECTpg_current_xact_id()='0';
3333
-- don't show yet, haven't committed
3434
INSERT INTO nobarf(data)VALUES('2');
3535
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1');

‎doc/src/sgml/datatype.sgml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@
198198
<entry><productname>PostgreSQL</productname> Log Sequence Number</entry>
199199
</row>
200200

201+
<row>
202+
<entry><type>pg_snapshot</type></entry>
203+
<entry></entry>
204+
<entry>user-level transaction ID snapshot</entry>
205+
</row>
206+
201207
<row>
202208
<entry><type>point</type></entry>
203209
<entry></entry>
@@ -279,7 +285,7 @@
279285
<row>
280286
<entry><type>txid_snapshot</type></entry>
281287
<entry></entry>
282-
<entry>user-level transaction ID snapshot</entry>
288+
<entry>user-level transaction ID snapshot (deprecated; see <type>pg_snapshot</type>)</entry>
283289
</row>
284290

285291
<row>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp