12
12
/*
13
13
* GUC parameters
14
14
*/
15
- bool pgfdw_two_phase_commit = false;
16
- bool pgfdw_skip_commit_phase = false;
17
- bool pgfdw_track_xact_commits = true;
18
- bool pgfdw_use_read_committed = false;
15
+ static bool pgfdw_two_phase_commit = false;
16
+ static bool pgfdw_skip_commit_phase = false;
17
+ static bool pgfdw_track_xact_commits = true;
18
+ static bool pgfdw_use_read_committed = false;
19
19
20
20
/*
21
21
* Global variables
22
22
*/
23
-
24
23
/*
25
24
* This flag indicates whether the current local transaction uses
26
25
* the read committed isolation level when starting remote transactions.
@@ -38,12 +37,38 @@ bool pgfdw_use_read_committed_in_xact = false;
38
37
* accesses to remote servers, which is not allowed when the read committed
39
38
* isolation level is used for remote transactions.
40
39
*/
41
- CommandId pgfdw_last_cid = InvalidCommandId ;
40
+ static CommandId pgfdw_last_cid = InvalidCommandId ;
41
+
42
+ /*
43
+ * Private macros
44
+ */
45
+ /*
46
+ * Construct the prepared transaction command like PREPARE TRANSACTION
47
+ * that's issued to the foreign server. It consists of full transaction ID,
48
+ * user mapping OID, process ID and cluster name.
49
+ */
50
+ #define PreparedXactCommand (sql , cmd , entry ) \
51
+ snprintf(sql, sizeof(sql), "%s 'pgfdw_" UINT64_FORMAT "_%u_%d_%s'", \
52
+ cmd, U64FromFullTransactionId(entry->fxid), \
53
+ (Oid) entry->key, MyProcPid, \
54
+ (*cluster_name == '\0') ? "null" : cluster_name)
42
55
43
56
/*
44
57
* Private functions
45
58
*/
59
+ static void pgfdw_abort_cleanup_with_sql (ConnCacheEntry * entry ,
60
+ const char * sql , bool toplevel );
61
+ static void pgfdw_prepare_xacts (ConnCacheEntry * entry ,
62
+ List * * pending_entries_prepare );
63
+ static void pgfdw_finish_prepare_cleanup (List * * pending_entries_prepare );
46
64
static void pgfdw_cleanup_pending_entries (List * * pending_entries_prepare );
65
+ static void pgfdw_commit_prepared (ConnCacheEntry * entry ,
66
+ List * * pending_entries_commit_prepared );
67
+ static void pgfdw_finish_commit_prepared_cleanup (
68
+ List * pending_entries_commit_prepared );
69
+ static bool pgfdw_rollback_prepared (ConnCacheEntry * entry );
70
+ static void pgfdw_deallocate_all (ConnCacheEntry * entry );
71
+ static void pgfdw_insert_xact_commits (List * umids );
47
72
48
73
/*
49
74
* Define GUC parameters for postgres_fdw_plus.
@@ -110,7 +135,7 @@ pgfdw_abort_cleanup(ConnCacheEntry *entry, bool toplevel)
110
135
pgfdw_abort_cleanup_with_sql (entry , sql , toplevel );
111
136
}
112
137
113
- void
138
+ static void
114
139
pgfdw_abort_cleanup_with_sql (ConnCacheEntry * entry , const char * sql ,
115
140
bool toplevel )
116
141
{
@@ -351,7 +376,7 @@ pgfdw_xact_two_phase(XactEvent event)
351
376
return true;
352
377
}
353
378
354
- void
379
+ static void
355
380
pgfdw_prepare_xacts (ConnCacheEntry * entry , List * * pending_entries_prepare )
356
381
{
357
382
char sql [256 ];
@@ -373,7 +398,7 @@ pgfdw_prepare_xacts(ConnCacheEntry *entry, List **pending_entries_prepare)
373
398
entry -> changing_xact_state = false;
374
399
}
375
400
376
- void
401
+ static void
377
402
pgfdw_finish_prepare_cleanup (List * * pending_entries_prepare )
378
403
{
379
404
ConnCacheEntry * entry ;
@@ -433,7 +458,7 @@ pgfdw_cleanup_pending_entries(List **pending_entries_prepare)
433
458
* pending_entries_prepare = NIL ;
434
459
}
435
460
436
- void
461
+ static void
437
462
pgfdw_commit_prepared (ConnCacheEntry * entry ,
438
463
List * * pending_entries_commit_prepared )
439
464
{
@@ -470,7 +495,7 @@ pgfdw_commit_prepared(ConnCacheEntry *entry,
470
495
pgfdw_deallocate_all (entry );
471
496
}
472
497
473
- void
498
+ static void
474
499
pgfdw_finish_commit_prepared_cleanup (List * pending_entries_commit_prepared )
475
500
{
476
501
ConnCacheEntry * entry ;
@@ -509,7 +534,7 @@ pgfdw_finish_commit_prepared_cleanup(List *pending_entries_commit_prepared)
509
534
}
510
535
}
511
536
512
- bool
537
+ static bool
513
538
pgfdw_rollback_prepared (ConnCacheEntry * entry )
514
539
{
515
540
char sql [256 ];
@@ -534,7 +559,7 @@ pgfdw_rollback_prepared(ConnCacheEntry *entry)
534
559
* Do a DEALLOCATE ALL to make sure we get rid of all prepared statements.
535
560
* See comments in pgfdw_xact_callback().
536
561
*/
537
- void
562
+ static void
538
563
pgfdw_deallocate_all (ConnCacheEntry * entry )
539
564
{
540
565
if (entry -> have_prep_stmt && entry -> have_error )
@@ -564,7 +589,7 @@ pgfdw_deallocate_all(ConnCacheEntry *entry)
564
589
* If the transaction is rollbacked, the record inserted by this function
565
590
* obviously gets unvisiable.
566
591
*/
567
- void
592
+ static void
568
593
pgfdw_insert_xact_commits (List * umids )
569
594
{
570
595
Datum values [PGFDW_PLUS_XACT_COMMITS_COLS ];
0 commit comments