|
17 | 17 | bool decompress_cache_print = false;
|
18 | 18 | struct DecompressCacheStats decompress_cache_stats;
|
19 | 19 | static ExplainOneQuery_hook_type prev_ExplainOneQuery_hook = NULL;
|
| 20 | +static bool ExplainOneQuery_hook_initialized = false; |
20 | 21 |
|
21 | 22 | #if PG17_LT
|
22 | 23 | /*
|
@@ -72,7 +73,11 @@ static void
|
72 | 73 | explain_decompression(Query *query, int cursorOptions, IntoClause *into, ExplainState *es,
|
73 | 74 | const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
|
74 | 75 | {
|
75 |
| - standard_ExplainOneQuery(query, cursorOptions, into, es, queryString, params, queryEnv); |
| 76 | + if (prev_ExplainOneQuery_hook) |
| 77 | + prev_ExplainOneQuery_hook(query, cursorOptions, into, es, queryString, params, queryEnv); |
| 78 | + else |
| 79 | + standard_ExplainOneQuery(query, cursorOptions, into, es, queryString, params, queryEnv); |
| 80 | + |
76 | 81 | if (decompress_cache_print)
|
77 | 82 | {
|
78 | 83 | const bool has_decompress_data = decompress_cache_stats.decompressions > 0 ||
|
@@ -130,6 +135,14 @@ tsl_process_explain_def(DefElem *opt)
|
130 | 135 | void
|
131 | 136 | _arrow_cache_explain_init(void)
|
132 | 137 | {
|
133 |
| - prev_ExplainOneQuery_hook = ExplainOneQuery_hook; |
134 |
| - ExplainOneQuery_hook = explain_decompression; |
| 138 | + /* |
| 139 | + * TSL init might be reexecuted so we need to make |
| 140 | + * sure to not initialize hook multiple times |
| 141 | + */ |
| 142 | + if (!ExplainOneQuery_hook_initialized) |
| 143 | + { |
| 144 | + ExplainOneQuery_hook_initialized = true; |
| 145 | + prev_ExplainOneQuery_hook = ExplainOneQuery_hook; |
| 146 | + ExplainOneQuery_hook = explain_decompression; |
| 147 | + } |
135 | 148 | }
|
0 commit comments