16
16
#include "access/xact.h"
17
17
#include "catalog/pg_type.h"
18
18
#include "parser/scansup.h"
19
+ #include "storage/proc.h"
19
20
#include "utils/builtins.h"
20
21
#include "utils/datum.h"
21
22
#include "utils/lsyscache.h"
@@ -2467,38 +2468,63 @@ processChanges(Action action)
2467
2468
static void
2468
2469
compatibility_check (void )
2469
2470
{
2471
+ /*
2472
+ * | Edition | ConnPool | ATX | COMPAT_CHECK |
2473
+ * -------------------------------------------
2474
+ * | std 9.6 | no | no | no |
2475
+ * | std 10 | no | no | yes |
2476
+ * | std 11 | no | no | yes |
2477
+ * | std 12 | no | no | yes |
2478
+ * | std 13 | no | no | yes |
2479
+ * | ee 9.6 | no | yes | no |
2480
+ * | ee 10 | no | yes | yes |
2481
+ * | ee 11 | yes | yes | yes |
2482
+ * | ee 12 | yes | yes | yes |
2483
+ * | ee 13 | yes | yes | yes |
2484
+ */
2470
2485
#ifdef PGPRO_EE
2471
2486
2487
+ /* All the ee have ATX. */
2488
+ # define ATX_CHECK (getNestLevelATX() != 0)
2489
+ /* ee10 and less does not have connpool. */
2490
+ # if (PG_VERSION_NUM >= 110000 )
2491
+ # define CONNPOOL_CHECK (!IsDedicatedBackend)
2492
+ # else
2493
+ # define CONNPOOL_CHECK (false)
2494
+ # endif
2495
+
2472
2496
# if (PG_VERSION_NUM < 100000 )
2473
2497
/*
2474
2498
* This versions does not have dedicated macro to check compatibility.
2475
- * So, use simple check here.
2499
+ * So, use simple check here for ATX .
2476
2500
*/
2477
- # define PG_COMPATIBILITY_CHECK (name ) \
2478
- if (getNestLevelATX() != 0) \
2479
- elog(ERROR, "%s extension is not compatible with autonomous " \
2480
- "transactions and connection pooling", name);
2501
+ if (ATX_CHECK )
2502
+ {
2503
+ freeStatsLists ();
2504
+ elog (ERROR , "pg_variables extension is not compatible with "
2505
+ "autonomous transactions" );
2506
+ }
2481
2507
# else
2482
2508
/*
2483
- * Since ee12 there is PG_COMPATIBILITY_CHECK macro to check compatibility.
2509
+ * Since ee10 there is PG_COMPATIBILITY_CHECK macro to check compatibility.
2484
2510
* But for some reasons it may not be present at the moment.
2485
2511
* So, if PG_COMPATIBILITY_CHECK macro is not present pg_variables are
2486
2512
* always compatible.
2487
2513
*/
2488
- # ifndef PG_COMPATIBILITY_CHECK
2489
- # define PG_COMPATIBILITY_CHECK_LOCK
2490
- # define PG_COMPATIBILITY_CHECK ( name )
2491
- # endif
2514
+ # ifdef PG_COMPATIBILITY_CHECK
2515
+ {
2516
+ if ( ATX_CHECK || CONNPOOL_CHECK )
2517
+ freeStatsLists ();
2492
2518
2493
- PG_COMPATIBILITY_CHECK ("pg_variables" );
2519
+ PG_COMPATIBILITY_CHECK ("pg_variables" );
2520
+ }
2521
+ # endif /* PG_COMPATIBILITY_CHECK */
2522
+ # endif /* PG_VERSION_NUM */
2494
2523
2495
- # ifdef PG_COMPATIBILITY_CHECK_LOCK
2496
- # undef PG_COMPATIBILITY_CHECK_LOCK
2497
- # undef PG_COMPATIBILITY_CHECK
2498
- # endif
2499
- # endif
2524
+ # undef ATX_CHECK
2525
+ # undef CONNPOOL_CHECK
2500
2526
2501
- #endif
2527
+ #endif /* PGPRO_EE */
2502
2528
}
2503
2529
2504
2530
/*
@@ -2513,8 +2539,8 @@ pgvSubTransCallback(SubXactEvent event, SubTransactionId mySubid,
2513
2539
switch (event )
2514
2540
{
2515
2541
case SUBXACT_EVENT_START_SUB :
2516
- compatibility_check ();
2517
2542
pushChangesStack ();
2543
+ compatibility_check ();
2518
2544
break ;
2519
2545
case SUBXACT_EVENT_COMMIT_SUB :
2520
2546
processChanges (RELEASE_SAVEPOINT );
0 commit comments