Croway opened a new pull request, #24815:
URL: https://github.com/apache/camel/pull/24815

   ## Backport of #24655
   
   Cherry-pick of #24655 onto `camel-4.18.x`.
   
   **Original PR:** #24655 - CAMEL-24044: camel-sql - Fix Postgres aggregation 
repositories binding version without a placeholder
   **Original author:** @Croway
   **Target branch:** `camel-4.18.x`
   
   ### Conflict resolution
   
   The upgrade guide entry (`camel-4x-upgrade-guide-4_22.adoc`) was removed 
from the backport since it does not exist on the 4.18.x branch — per project 
guidelines, upgrade guide entries for backported changes belong on `main`.
   
   The `camel-test-infra-postgres` dependency was updated to use 
`<type>test-jar</type>` because on this branch the service classes 
(`PostgresService`, `PostgresServiceFactory`) are still in `src/test/java` 
(they were moved to `src/main/java` on `main`).
   
   ### Original description
   
   Since the CAMEL-7810 optimistic-locking refactor (Camel 3.4), 
`PostgresAggregationRepository.insert()` built `INSERT INTO t(exchange, id, 
...) ON CONFLICT DO NOTHING` without the `version` column while the base 
`insertHelper` binds blob, key **and version** — one more bound parameter than 
placeholders, so every `add()` failed with `The column index is out of range` 
(verified against real PostgreSQL). With `storeBodyAsText=true` the version was 
silently bound into the `body` placeholder before failing. 
`ClusteredPostgresAggregationRepository` had the same defect in its 
completed-table insert (every `remove()` failed at completion) and never wrote 
the `instance_id` column, so instance-scoped recovery could never match any row.
   
   Changes:
   - Include the `version` column in both Postgres `INSERT` statements and pass 
the actual version instead of the hardcoded `1L`
   - Clustered variant additionally writes `instance_id` when `completed && 
recoveryByInstance`
   - New integration tests against real PostgreSQL 
(`camel-test-infra-postgres`) covering the full 
add/get/update/remove/recover/confirm lifecycle, `storeBodyAsText`, and 
instance-scoped recovery with two nodes — these fail on current `main` and pass 
with the fix
   - Fixed the stale `INSERT` example in the component docs and added an 
upgrade-guide entry (the aggregation tables need the `version BIGINT` column, 
as `JdbcAggregationRepository` already required for reads/updates)
   
   _Claude Code on behalf of Croway_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to