The following bug has been logged on the website:
Bug reference: 16752
Logged by: Bogdan Gureev
Email address: bogdan.gureev@gmail.com
PostgreSQL version: 13.0
Operating system: Windows 10 x64
Description:
The driver makes the input SQL SELECT query invalid when the concurrency
mode is set to SQL_CONCUR_LOCK and FOR UPDATE is unused:
==========
Case #1:
SELECT * FROM bogu_unique_column FOR UPDATE
ODBC logs:
[0.126]PQsendQuery: 000002452083F2E0 'PREPARE
"_KEYSET_0000024520867A70"(tid,tid) as SELECT * , "ctid" FROM
bogu_unique_column FOR UPDATE where ctid in ($1,$2)'
[0.127] (ERROR) 42601 'syntax error at or near "where"'
Expected:
The query is modified without syntax error
==========
Case #2:
SELECT table_for_update.col_integer FROM table_for_update FOR UPDATE
ODBC logs:
[0.162]PQsendQuery: 000002524D530790 'SELECT table_for_update.col_integer ,
"ctid", "oid" FROM table_for_update FOR UPDATE where ctid = '(0,0)';select
"ctid", "oid" from table_for_update FOR UPDATE'
[0.163] (ERROR) 42601 'syntax error at or near "where"'
Expected:
The query is modified without syntax error
==========
The exact set of attributes that are set from the source code (in the
following order):
SQLSetEnvAttr( environment, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER*)SQL_OV_ODBC3, 0 );
SQLSetConnectAttr( connection, SQL_ATTR_ASYNC_ENABLE, SQL_ASYNC_ENABLE_OFF,
SQL_IS_INTEGER );
SQLSetConnectAttr( connection, SQL_ATTR_CONNECTION_TIMEOUT, (SQLPOINTER)0,
SQL_IS_INTEGER );
SQLSetConnectAttr( connection, SQL_LOGIN_TIMEOUT, (SQLPOINTER)0,
SQL_IS_INTEGER );
SQLSetConnectAttr( connection, SQL_ATTR_AUTOCOMMIT,
(SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_IS_INTEGER );
SQLSetStmtAttr( statement, SQL_ATTR_ASYNC_ENABLE, SQL_ASYNC_ENABLE_OFF,
SQL_IS_INTEGER );
SQLSetStmtAttr( statement, SQL_ATTR_CURSOR_TYPE,
(SQLPOINTER)SQL_CURSOR_DYNAMIC, SQL_IS_INTEGER );
SQLSetStmtAttr( statement, SQL_ATTR_CONCURRENCY,
(SQLPOINTER)SQL_CONCUR_LOCK, SQL_IS_INTEGER );
SQLSetStmtAttr( statement, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)0,
SQL_IS_INTEGER );
==========
DDL for tables extracted from DBeaver:
CREATE TABLE public.bogu_unique_column (
c int4 NULL,
CONSTRAINT bogu_unique_column_c_key UNIQUE (c)
);
CREATE TABLE public.table_for_update (
id int4 NULL,
col_integer int4 NULL,
col_decimal numeric(10,2) NULL,
col_char bpchar(20) NULL,
col_date date NULL
)
WITH (
OIDS=TRUE
);
==========
I have the ODBC logs and C++ minimized source code to reproduce this problem
if you need it.
==========
No error appears without the SQL_ATTR_CONCURRENCY attribute