Skip to content

Fix placeholder cast truncated from parameter 1000 on - #221

Merged
davecramer merged 1 commit into
postgresql-interfaces:mainfrom
vltr:fix-placeholder-cast-truncation
Oct 12, 2026
Merged

davecramer merged 1 commit into
postgresql-interfaces:mainfrom
vltr:fix-placeholder-cast-truncation

Conversation

@vltr

@vltr vltr commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #220.

ResolveOneParam() writes each placeholder, with its cast, into a 16-byte buffer (pnum[16]). From parameter number 1000 on, "$1000::timestamp" does not fit and is cut to "$1000::timestam", so the statement fails with type "timestam" does not exist. This widens the buffer to 32 bytes.

The new test, many-params-test, binds 1000 SQL_TYPE_TIMESTAMP parameters with UseServerSidePrepare=1 and reads back column 1000. It fails with the error above without the fix and passes with it.

Tested:

  • Linux (Debian, PostgreSQL 17, built the way linux.yml builds): the full suite passes with the fix; the new test fails without it.
  • Windows: the MSBuild workflow on my fork passes for x64, x86 and arm64, with the new test included: https://github.com/vltr/psqlodbc/actions/runs/37953677678 (that run builds 18.00.0004 plus this commit and the OpenSSL 3.5.9 bump from main).
  • Our back office: the same patched 18.00.0004 build runs the ADO batch insert that hit the bug, and it works again.

I used Claude Code for the initial scan of the problem and to write the test and the patch; it helps get the job done faster.

ResolveOneParam() writes each placeholder with its cast into a
16-byte buffer, so "$1000::timestamp" was cut to "$1000::timestam"
and execution failed with: type "timestam" does not exist.
Widen the buffer to 32 bytes and add a test with 1000 timestamp
parameters.
@davecramer
davecramer merged commit bb536a1 into postgresql-interfaces:main Oct 12, 2026
8 checks passed
@vltr
vltr deleted the fix-placeholder-cast-truncation branch October 12, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Placeholder cast truncated to ::timestam from parameter number 1000 on

2 participants