SebTardif opened a new pull request, #4522:
URL: https://github.com/apache/logging-log4j2/pull/4522

   `JdbcAppender` writes a `ColumnMapping` literal into the INSERT text and 
does not create a placeholder for it. On `main`, `JdbcDatabaseManager` still 
took a JDBC parameter when that column's type was a date or a thread-context 
type, and it restarted parameter numbering after filling `MapMessage` values. A 
later pattern column was then stored in an earlier column.
   
   This change binds each placeholder once and skips literals. `main` reads the 
event message in `writeInternal`, so a source column sees a `MapMessage` 
without `MessageLayout`.
   
   The Log4j 2 fix is #4521 and targets `2.x` only. This pull request targets 
`main`.
   
   ## Validation
   
   Before the change, `JdbcAppenderColumnMappingMixedTest` failed on H2. The 
literal timestamp was bound as parameter 1 and written into the integer `id` 
column:
   
   ```
   insert into dsMixedLogEntry (id,stamp,level,message) values 
(?,CURRENT_TIMESTAMP,?,?)
   {1: TIMESTAMP '2026-11-23 07:15:11.455', 2: 'ERROR', 3: 'id="7" 
message="from-map"'}
   ```
   
   The driver reported `Data conversion error converting "TIMESTAMP to 
INTEGER"`.
   
   After the change, from a Java 17 JDK:
   
   ```
   ./mvnw -pl log4j-jdbc -am test -Dsurefire.failIfNoSpecifiedTests=false
   ./mvnw -pl log4j-jdbc spotless:check
   ./mvnw -N validate
   ```
   
   Spotless passed. Changelog schema validation passed. `log4j-jdbc` tests run: 
35, failures: 0. That includes the new mixed-column test and the existing 
pattern and literal tests. Full `./mvnw verify` was not run.
   
   Changelog: `src/changelog/.3.x.x/fix_jdbc_column_mapping_parameter_index.xml`
   
   ## Checklist
   
   * Base your changes on `2.x` branch if you are targeting Log4j 2; use `main` 
otherwise
   * `./mvnw verify` succeeds ([the build 
instructions](https://logging.apache.org/log4j/2.x/development.html#building))
   * Non-trivial changes contain an entry file in the `src/changelog/.3.x.x` 
directory
   * Tests are provided
   


-- 
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