pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: bogdan.gureev@gmail.com
Subject: BUG #16752: ODBC driver makes the input SQL query invalid
Date: Mon, 30 Nov 2020 09:09:51 +0000
Message-ID: <16752-8b1c831fd94a7d3f@postgresql.org> (raw)

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



Message-ID: <16752-8b1c831fd94a7d3f@postgresql.org>
Permalink:  ../16752-8b1c831fd94a7d3f@postgresql.org/
Also on:    postgresql.org/message-id/16752-8b1c831fd94a7d3f@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, bogdan.gureev@gmail.com
  Subject: Re: BUG #16752: ODBC driver makes the input SQL query invalid
  In-Reply-To: <16752-8b1c831fd94a7d3f@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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