diff options
| author | Tatsuo Ishii | 2025-05-08 10:49:10 +0000 |
|---|---|---|
| committer | Tatsuo Ishii | 2025-05-08 12:19:31 +0000 |
| commit | 35a5a79d623b0ae7023437ac0360fcb2f6300d19 (patch) | |
| tree | dd440c69f39d7514c192b4af4f6992392fc39789 /src/protocol | |
| parent | 5f7d06d87256d0db53a7ec35cd13196768e31c0f (diff) | |
Fix long standing bind bug with query cache.
When a named statement is prepared, it is possible to bind then
execute without a parse message. Problem is, table oids which are
necessary to invalidate query cache at execute or COMMIT was collected
only in parse messages process (Parse()). Thus if bind is executed
without parse after previous execute, no table oids were collected,
and pgpool failed to invalidate query cache.
Fix is collecting table oids at bind time too.
Add regression test to 006.memqcache.
Problem reported by and test program provided by Achilleas Mantzios
<a.mantzios@cloud.gatewaynet.com>.
Discussion: [pgpool-general: 9427] Clarification on query results cache visibility
https://www.pgpool.net/pipermail/pgpool-general/2025-April/009430.html
Backpatch-through: v4.2
Diffstat (limited to 'src/protocol')
| -rw-r--r-- | src/protocol/pool_proto_modules.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c index 5b3e03d59..d79357211 100644 --- a/src/protocol/pool_proto_modules.c +++ b/src/protocol/pool_proto_modules.c @@ -1780,6 +1780,33 @@ Bind(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, } /* + * If query cache is enabled and we updating table, save table oids. It + * maybe possible that Parse() already collected the information but if + * Bind is called without prior parse (this could happen if named prepared + * statement is used), we miss the information. So we re-collect the + * information here. This could result in duplicate oids in oid table, but + * it's Okay. The duplication will be ignored anyway. + */ + if (pool_config->memory_cache_enabled) + { + /* + * Save table oids if we are updating the table. + */ + if (!query_context->is_parse_error) + { + int num_oids; + int *oids; + int i; + + num_oids = pool_extract_table_oids(query_context->parse_tree, + &oids); + /* Save to oid buffer */ + for (i = 0; i < num_oids; i++) + pool_add_dml_table_oid(oids[i]); + } + } + + /* * Start a transaction if necessary in replication mode */ if (REPLICATION) |
