Feedback
Did this article resolve your question/issue?

   

Article

SQLExecute fails to detect duplicate index with PostgreSQL ODBC driver

Information

 
TitleSQLExecute fails to detect duplicate index with PostgreSQL ODBC driver
URL NameSQLExecute-fails-to-detect-duplicate-index-with-PostgreSQL-ODBC-driver
Article Number000111663
EnvironmentProduct: Connect for ODBC PostgreSQL driver
Version: 7.16.0233
OS: all supported platforms
Database: PostgreSQL
Application: all supported applications
Question/Problem Description
SQLExecute fails to detect duplicate index with PostgreSQL ODBC driver when statement is prepared then executed.
Steps to Reproduce
Clarifying Information
1. Create the following table:

CREATE TABLE "J33"  (ITEM_NAME VARCHAR(1024),   ITEM_ID INTEGER NOT NULL,  ITEM_PRICE DOUBLE PRECISION,  CONSTRAINT pk_item_ID33 PRIMARY KEY ( ITEM_ID ))

2. Create the following table by calling SQLPrepare/SQLExecute:

CREATE TABLE "J333"  (ITEM_NAME VARCHAR(1024),   ITEM_ID INTEGER NOT NULL,  ITEM_PRICE DOUBLE PRECISION,  CONSTRAINT pk_item_ID33 PRIMARY KEY ( ITEM_ID ))

SQLPrepare:
In:    StatementHandle = 0x045CDB18, 
StatementText = "CREATE TABLE "J333" (ITEM_NAME VARCHAR(10...", TextLength = 161
Return:    SQL_SUCCESS=0
SQLExecute:
In:    StatementHandle = 0x045CDB18
Return:    SQL_SUCCESS=0


SUCCESS is returned while an error should be returned that the index already exists.
Error Message[DataDirect][ODBC PostgreSQL Wire Protocol driver][PostgreSQL]NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pk_item_id33" for table "JFL_LEAK333"(File indexcmds.c; Line 578; Routine DefineIndex; )
Defect Number
Enhancement Number
Cause
Resolution
This issue is no longer seen when installing the latest hot fix (7.16.0251).
Refer to "Connect and Connect64 for ODBC hot fix download and install instructions" for instructions on how to download and install the hot fix.
Workaround
SQL_ERROR is returned correctly when calling SQLExecDirect instead of SQLPrepare/SQLExecute:

SQLExecDirect:
In:    hstmt = 0x045CDB18, 
szSqlStr = "CREATE TABLE "J333" (ITEM_NAME VARCHAR(1024), ...", cbSqlStr = -3
Return:    SQL_ERROR=-1
stmt:    szSqlState = "42S01", *pfNativeError = 6844183, *pcbErrorMsg = 155, *ColumnNumber = -1, *RowNumber = 1
MessageText = "[DataDirect][ODBC PostgreSQL Wire Protocol driver][PostgreSQL]ERROR: relation "pk_item_id33" already exists(File index.c; Line 768; Routine index_create; )"
stmt:    szSqlState = "01000", *pfNativeError = -1, *pcbErrorMsg = 213, *ColumnNumber = -1, *RowNumber = 1
MessageText = "[DataDirect][ODBC PostgreSQL Wire Protocol driver][PostgreSQL]NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pk_item_id33" for table "JFL_LEAK333"(File indexcmds.c; Line 578; Routine DefineIndex; )"
Notes
Last Modified Date9/19/2016 12:37 PM
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.