pg.ddx.io  GitHub: postgresql-interfaces/psqlodbc (issues + PRs as email threads)  
help / color / mirror / Atom feed
From: davecramer (@davecramer) <noreply+davecramer@github.com>
To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com>
Subject: Re: [postgresql-interfaces/psqlodbc] PR #237: Fix SQLSTATE fallback for STMT_STRING_CONVERSION_ERROR
Date: Thu, 05 Nov 2026 20:59:55 +0000
Message-ID: <gh-postgresql-interfaces-psqlodbc-237-c6669339466@github.com> (raw)
In-Reply-To: <gh-postgresql-interfaces-psqlodbc-237@github.com>
References: <gh-postgresql-interfaces-psqlodbc-237@github.com>

One more request: could you add a regression test, so the mapping stays covered?

The error comes from the Unicode driver when it fetches text into `SQL_C_CHAR` and the client's locale encoding differs from the connection's (UTF-8). It converts the value to the locale's encoding, and that fails for a character the locale can't represent (`localize_needed` in `setup_getdataclass`, convert.c). So a test could:

1. Call `setlocale(LC_ALL, "C")`, or another locale that can't represent the character, before `test_connect()`.
2. Fetch a text value containing such a character into `SQL_C_CHAR`, for example `SELECT '€'::text` read with `SQLGetData`.
3. Check that the call returns `SQL_ERROR` with SQLSTATE 22018.

`test/src/wchar-char-test.c` shows the pattern for locale-dependent tests. It sets the locale before connecting, and prints fixed output and exits when it can't run in that environment, for example with the ANSI driver (`IsAnsi()`) or on a platform where it can't control the locale. The new test would need the same, with its expected output in `test/expected/` and an entry in `test/tests`.

view thread (6+ messages)  latest in thread

Message-ID: <gh-postgresql-interfaces-psqlodbc-237-c6669339466@github.com>
Permalink:  ../gh-postgresql-interfaces-psqlodbc-237-c6669339466@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox