zeroshade opened a new pull request, #4442:
URL: https://github.com/apache/arrow-adbc/pull/4442

   ## What
   
   A duplicate *quoted* key in a connection profile (for example, two
   `"redshift.db_name"` entries) produced a confusing parse error that
   doubled the first two characters of the key name:
   
   ```
   cannot redefine existing string '"reredshift.db_name" '
   ```
   
   instead of naming `redshift.db_name`.
   
   ## Root cause
   
   The bug is in the vendored toml++ (v3.4.0). `parse_string()` advances two
   characters to detect a `"""` multi-line delimiter and appends them to the
   parser's diagnostics `recording_buffer`. When the string turns out to be
   single-line, `go_back(2u)` rewinds the read cursor but does **not** trim 
those
   two characters from `recording_buffer`, so the lookahead bytes are duplicated
   when a redefinition error renders the key via `to_sv(recording_buffer)`. It
   only affects *quoted* keys (the path through the basic/literal string 
parser);
   bare dotted keys are unaffected.
   
   ## Fix
   
   Backport the upstream fix into both vendored copies
   (`c/vendor/toml++/toml.hpp` and 
`go/adbc/drivermgr/vendored/toml++/toml.hpp`).
   The fix snapshots `recording_buffer.length()` before the lookahead and 
restores
   it after `go_back(2u)`.
   
   - Upstream issue: https://github.com/marzer/tomlplusplus/issues/300
   - Upstream PR: https://github.com/marzer/tomlplusplus/pull/302
   - Upstream commit: `f22f035fe2d63e2be3d266d8f100e7812a9ab9bd`
   
   The fix is not in any tagged toml++ release yet (latest is v3.4.0), so it is
   backported here. It re-applies cleanly when the vendored copy is next 
updated.
   
   ## Testing
   
   Adds `ConnectionProfiles.DuplicateQuotedKey` to
   `c/driver_manager/adbc_driver_manager_test.cc`, which writes a profile with a
   duplicate quoted key and asserts the resulting error names `redshift.db_name`
   and not the doubled `reredshift` form. Passes locally
   (`--gtest_filter=ConnectionProfiles.DuplicateQuotedKey`).
   


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