Message-ID: From: "JacoboSanchez (@JacoboSanchez)" To: "postgresql-interfaces/psqlodbc" Date: Fri, 13 Dec 2024 18:47:11 +0000 Subject: [postgresql-interfaces/psqlodbc] issue #82: Is this expected a bind to BIGINT to be surrounded by quotes? List-Id: X-GitHub-Author-Id: 11249890 X-GitHub-Author-Login: JacoboSanchez X-GitHub-Issue: 82 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-State: open X-GitHub-Type: issue X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/issues/82 Content-Type: text/plain; charset=utf-8 I was testing the folowing: * Prepare a statement with a parameter ``` odbct32w 7d60-31c0 ENTER SQLPrepareW HSTMT 0x00000000020DAFA0 WCHAR * 0x000000000053C320 [ 50] "select * from public.testview where longfield < ?" SDWORD 50 odbct32w 7d60-31c0 EXIT SQLPrepareW with return code 0 (SQL_SUCCESS) HSTMT 0x00000000020DAFA0 WCHAR * 0x000000000053C320 [ 50] "select * from public.testview where longfield < ?" SDWORD 50 ``` * Bind the parameter to BIGINT: ``` odbct32w 7d60-31c0 ENTER SQLBindParameter HSTMT 0x00000000020DAFA0 UWORD 1 SWORD 1 SWORD 99 SWORD -5 SQLULEN 0 SWORD 0 PTR 0x0000000001F30000 SQLLEN 0 SQLLEN * 0x0000000002DD0000 odbct32w 7d60-31c0 EXIT SQLBindParameter with return code 0 (SQL_SUCCESS) HSTMT 0x00000000020DAFA0 UWORD 1 SWORD 1 SWORD 99 SWORD -5 SQLULEN 0 SWORD 0 PTR 0x0000000001F30000 SQLLEN 0 SQLLEN * 0x0000000002DD0000 (4294967293) ``` When I execute I see that the executed sentence does contain the number quoted. Example (probably not exactly from the same test than previous trace logs): `[14.554]PQsendQuery: 00000000005B4DB0 'BEGIN;declare "SQL_CUR000000000053DB60" cursor with hold for select * from public.testview where longfield< '5545';fetch 10000 in "SQL_CUR000000000053DB60"' ` I think the reason for SQL_INTEGER and SQL_SMALLINT not being quoted (or quoted with ::int4) is [in convert.c#L5310](https://github.com/postgresql-interfaces/psqlodbc/blob/72943916325e2443fdb85fa5d1e053d9ef72f683/convert.c#L5310) but I don't figure out why this is not the same for SQL_BIGINT. It is not throwing an error but does not seems correct to me to use a text literal there