Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgYN2-0002Ap-If for pgsql-odbc@arkaria.postgresql.org; Sun, 26 May 2013 10:40:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UgYN1-0008QK-Vg for pgsql-odbc@arkaria.postgresql.org; Sun, 26 May 2013 10:40:12 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgYMz-0008PZ-S5 for pgsql-odbc@postgresql.org; Sun, 26 May 2013 10:40:10 +0000 Received: from basicbox3.server-home.net ([195.137.212.25]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UgYMo-0004R4-3c for pgsql-odbc@postgresql.org; Sun, 26 May 2013 10:40:09 +0000 Received: from localhost (HSI-KBW-091-089-031-108.hsi2.kabelbw.de [91.89.31.108]) by basicbox3.server-home.net (Postfix) with ESMTPA id 0C67F1A203EA for ; Sun, 26 May 2013 12:39:56 +0200 (CEST) Date: Sun, 26 May 2013 12:38:53 +0200 From: Daniel Vogelbacher To: pgsql-odbc@postgresql.org Subject: SQL_ERROR on SQLExecute() when using SQL_C_NUMERIC for parameters Message-ID: <20130526103853.GA31025@pollux.home.local> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org --opJtzjQTFsWo+cga Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, when using SQLBindParameter with SQL_C_NUMERIC input, the function returns SQL_SUCCESS. But a call to SQLExecute() returns SQL_ERROR with "Syntax error on )". It seems that the psqlodbc driver did not replace the ? marker properly and an invalid statement is passed to the server. This only happens with SQL_C_NUMERIC, for other datatypes the marker gets replaced. The used statement was: INSERT INTO numtest(num1) VALUES(?); where num1 is of type NUMERIC(5,3) The driver was built from source psqlodbc-09.01.0200.tar.gz for unixODBC. Here is the odbctrace for the specific part: [ODBC][27210][1369515859.324218][SQLBindParameter.c][217] Entry: Statement =3D 0x1a908b0 Param Number =3D 1 Param Type =3D 1 C Type =3D 2 SQL_C_NUMERIC SQL Type =3D 2 SQL_NUMERIC Col Def =3D 5 Scale =3D 3 Rgb Value =3D 0x1a91210 Value Max =3D 0 StrLen Or Ind =3D 0x1a91230 [ODBC][27210][1369515859.324329][SQLBindParameter.c][397] Exit:[SQL_SUCCESS] [ODBC][27210][1369515859.324359][SQLSetDescFieldW.c][168] Entry: Descriptor =3D 0x1ab2ef0 Rec Number =3D 1 Field Ident =3D SQL_DESC_PRECISION Value =3D 0x5 Buffer Length =3D -8 [ODBC][27210][1369515859.324402][SQLSetDescFieldW.c][246] Exit:[SQL_SUCCESS] [ODBC][27210][1369515859.324421][SQLSetDescFieldW.c][168] Entry: Descriptor =3D 0x1ab2ef0 Rec Number =3D 1 Field Ident =3D SQL_DESC_SCALE Value =3D 0x3 Buffer Length =3D -8 [ODBC][27210][1369515859.324452][SQLSetDescFieldW.c][246] Exit:[SQL_SUCCESS] [ODBC][27210][1369515859.324480][SQLExecute.c][187] Entry: Statement =3D 0x1a908b0 [ODBC][27210][1369515859.328804][SQLExecute.c][348] Exit:[SQL_ERROR] DIAG [42601] FEHLER: Syntaxfehler bei ); Error while executing the query And the psqlodbc trace: [140356464904000]**** PGAPI_AllocStmt: hdbc =3D 0x1aae8d0, stmt =3D 0x1ab25= 10 [140356464904000]CC_add_statement: self=3D0x1aae8d0, stmt=3D0x1ab2510 [140356464904000][[SQLGetStmtAttr]] Handle=3D27993360 10010 [140356464904000]PGAPI_GetStmtAttr Handle=3D0x1ab2510 10010 [140356464904000][[SQLGetStmtAttr]] Handle=3D27993360 10011 [140356464904000]PGAPI_GetStmtAttr Handle=3D0x1ab2510 10011 [140356464904000][[SQLGetStmtAttr]] Handle=3D27993360 10012 [140356464904000]PGAPI_GetStmtAttr Handle=3D0x1ab2510 10012 [140356464904000][[SQLGetStmtAttr]] Handle=3D27993360 10013 [140356464904000]PGAPI_GetStmtAttr Handle=3D0x1ab2510 10013 [140356464904000][SQLPrepareW][140356464904000]PGAPI_Prepare: entering... [140356464904000]**** PGAPI_Prepare: STMT_ALLOCATED, copy [140356464904000][SQLBindParameter][140356464904000]PGAPI_BindParameter: en= tering... [140356464904000]extend_parameter_bindings: entering ... self=3D0x1ab26b8, = parameters_allocated=3D0, num_params=3D1,(nil) [140356464904000]exit extend_parameter_bindings=3D0x1a91150 [140356464904000]extend_iparameter_bindings: entering ... self=3D0x1ab2728,= parameters_allocated=3D0, num_params=3D1 [140356464904000]exit extend_iparameter_bindings=3D0x1a65fa0 [140356464904000]extend_putdata_info: entering ... self=3D0x1ab27f0, parame= ters_allocated=3D0, num_params=3D1 [140356464904000]exit extend_putdata_info=3D0x1a67310 [140356464904000]PGAPI_BindParameter: ipar=3D0, paramType=3D1, fCType=3D2, = fSqlType=3D2, cbColDef=3D5, ibScale=3D3,[140356464904000]rgbValue=3D0x1a912= 10(0), pcbValue=3D0x1a91230 [140356464904000][SQLSetDescFieldW][140356464904000]PGAPI_SetDescField h=3D= 0x1ab2688(10011) rec=3D1 field=3D1005 val=3D0x5,-8 [140356464904000][SQLSetDescFieldW][140356464904000]PGAPI_SetDescField h=3D= 0x1ab2688(10011) rec=3D1 field=3D1006 val=3D0x3,-8 [140356464904000][SQLExecute][140356464904000]PGAPI_Execute: entering...1 [140356464904000]PGAPI_Execute: clear errors... [140356464904000]PGAPI_NumParams: entering... [140356464904000]SC_scanQueryAndCountParams: entering... [140356464904000]prepareParameters was not called, prepare state:3 [140356464904000]SC_recycle_statement: self=3D 0x1ab2510 [140356464904000]PDATA_free_params: ENTER, self=3D0x1ab27f0 [140356464904000]PDATA_free_params: EXIT [140356464904000]Exec_with_parameters_resolved: copying statement params: t= rans_status=3D1, len=3D36, stmt=3D'INSERT INTO numtest(num1) VALUES(?);' [140356464904000] stmt_with_params =3D 'INSERT INTO numtest(num1) VALUES(= ?);' [140356464904000]about to begin SC_execute [140356464904000] it's NOT a select statement: stmt=3D0x1ab2510 [140356464904000]CC_send_query: conn=3D0x1aae8d0, query=3D'INSERT INTO numt= est(num1) VALUES(?);' conn=3D0x1aae8d0, query=3D'INSERT INTO numtest(num1) VALUES(?);' [140356464904000]send_query: done sending query 42bytes flushed [140356464904000]in QR_Constructor [140356464904000]exit QR_Constructor [140356464904000]read -1, global_socket_buffersize=3D4096 [140356464904000]Lasterror=3D11 [140356464904000]!!! poll ret=3D1 revents=3D1 [140356464904000]read 99, global_socket_buffersize=3D4096 [140356464904000]send_query: got id =3D 'E' [140356464904000]send_query: 'E' - SFEHLER ERROR from backend during send_query: 'SFEHLER' [140356464904000]send_query: 'E' - C42601 ERROR from backend during send_query: 'C42601' [140356464904000]send_query: 'E' - MSyntaxfehler bei =C2=BB)=C2=AB ERROR from backend during send_query: 'MSyntaxfehler bei =C2=BB)=C2=AB' [140356464904000]send_query: 'E' - P35 ERROR from backend during send_query: 'P35' [140356464904000]send_query: 'E' - Fsrc\backend\parser\scan.l ERROR from backend during send_query: 'Fsrc\backend\parser\scan.l' [140356464904000]send_query: 'E' - L1002 ERROR from backend during send_query: 'L1002' [140356464904000]send_query: 'E' - Rscanner_yyerror ERROR from backend during send_query: 'Rscanner_yyerror' [140356464904000]read -1, global_socket_buffersize=3D4096 [140356464904000]Lasterror=3D11 [140356464904000]!!! poll ret=3D1 revents=3D1 [140356464904000]read 6, global_socket_buffersize=3D4096 [140356464904000]send_query: got id =3D 'Z' [140356464904000]SC_set_Result(1ab2510, 1a90f40)[140356464904000]QResult: e= nter DESTRUCTOR STATEMENT ERROR: func=3DSC_execute, desc=3D'(null)', errnum=3D7, errmsg=3D'= Error while executing the query' [140356464904000]STATEMENT ERROR: func=3DSC_execute, desc=3D'(null)', errnu= m=3D7, errmsg=3D'Error while executing the query' ----------------------------------------------------------= -- hdbc=3D0x1aae8d0, stmt=3D0x1ab2510, result=3D0x1a90f40 prepare=3D3, internal=3D0 bindings=3D(nil), bindings_allocated=3D0 parameters=3D0x1a91150, parameters_allocated=3D1 statement_type=3D1, statement=3D'INSERT INTO numtest(num1)= VALUES(?);' stmt_with_params=3D'INSERT INTO numtest(num1) VALUES(?);' data_at_exec=3D-1, current_exec_param=3D-1, put_data=3D0 currTuple=3D-1, current_col=3D-1, lobj_fd=3D-1 maxRows=3D0, rowset_size=3D1, keyset_size=3D0, cursor_type= =3D0, scroll_concurrency=3D1 cursor_name=3D'SQL_CUR0x1ab2510' ----------------QResult Info -----------------------------= -- fields=3D0x1a91090, backend_tuples=3D(nil), tupleField=3D0= , conn=3D(nil) fetch_count=3D0, num_total_rows=3D0, num_fields=3D0, curso= r=3D'(NULL)' message=3D'FEHLER: Syntaxfehler bei =C2=BB)=C2=AB', comman= d=3D'(NULL)', notice=3D'(NULL)' status=3D7, inTuples=3D0 CONN ERROR: func=3DSC_execute, desc=3D'(null)', errnum=3D110, errmsg=3D'FEH= LER: Syntaxfehler bei =C2=BB)=C2=AB' [140356464904000]CONN ERROR: func=3DSC_execute, desc=3D'(null)', errnum=3D1= 10, errmsg=3D'FEHLER: Syntaxfehler bei =C2=BB)=C2=AB' ------------------------------------------------------------ henv=3D0x1a9cc90, conn=3D0x1aae8d0, status=3D1, num_stmts=3D16 sock=3D0x1aae730, stmts=3D0x1a9c9b0, lobj_type=3D-999 ---------------- Socket Info ------------------------------- socket=3D6, reverse=3D0, errornumber=3D0, errormsg=3D'(NULL)' buffer_in=3D27905280, buffer_out=3D27989248 buffer_filled_in=3D6, buffer_filled_out=3D0, buffer_read_in=3D6 [140356464904000]retval=3D-1 [140356464904000][SQLGetDiagRecW][140356464904000]PGAPI_GetDiagRec entering= type=3D3 rec=3D1 [140356464904000]ER_ReturnError: status =3D 7, msg =3D #FEHLER: Syntaxfehle= r bei =C2=BB)=C2=AB; Error while executing the query# [140356464904000] szSqlState =3D '42601',len=3D63, szError=3D'FE= HLER: Syntaxfehler bei =C2=BB)=C2=AB; Error while executing the query' [140356464904000]PGAPI_GetDiagRec exiting 0 [140356464904000][SQLGetDiagRecW][140356464904000]PGAPI_GetDiagRec entering= type=3D3 rec=3D2 [140356464904000]ER_ReturnError: status =3D 7, msg =3D #FEHLER: Syntaxfehle= r bei =C2=BB)=C2=AB; Error while executing the query# [140356464904000]PGAPI_GetDiagRec exiting 100 [140356464904000][SQLGetDiagRecW][140356464904000]PGAPI_GetDiagRec entering= type=3D3 rec=3D1 [140356464904000]ER_ReturnError: status =3D 7, msg =3D #FEHLER: Syntaxfehle= r bei =C2=BB)=C2=AB; Error while executing the query# [140356464904000] szSqlState =3D '42601',len=3D63, szError=3D'FE= HLER: Syntaxfehler bei =C2=BB)=C2=AB; Error while executing the query' --=20 Daniel Vogelbacher www.chaospixel.com cytrinox@freenode/ircnet/quakenet --opJtzjQTFsWo+cga Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iQIcBAEBAgAGBQJRoeY9AAoJEHJSaz8WhOPEHBkP/1+cf/bR/ELrOaK85lcZGds0 x+PgiY3TarF/TWj/aZucoMNpk0cK6S8MKx4zJ+RZJ7wzjNGEpMZuYEIF1HGYQrSO S+uYnYnWmLM6+oCyPmpKHW0AmMb5V4XI/AsUlEJghzpD9a9dN1RHJmSf2TUnw3UG jjxsvtNS7kmoFFj2JskGMho/6/5saEOG8lEkHOOOvYNVTBEj1Hed2N0EHlLG8IJU meb1nAj684HZZ+tM3BsS2M7OGi+KfS3qiex1ayCHTDutWPKCiLBH0GFg28v7kenv WtTtewyfBG24EalMbg3Xa3Mf9IRD3IxVFvrR7yXnsnDCFf0nlnfAL6OcFqQWuoxZ pv4qm35B2zl5rWv9TFGyt1bX8II+IHn2hsYDY8uqPHibGY3vpAxWAzxwrtOfoSIX bcFHI4zaDYgGB3YRQWjR+IAiZMcxogCCvk7B4qqTzNOxXz8AXH890iSqI0Zi5PPY ty9txLJRY9+JMXZMaruNZXktaRPSQjZxy+BaNNYajelKk7rsCOmCXJazc4lDx3Q/ pXXMha46RMGmR2bkwyZc6CquHmllFMigQf967keG124EsaD9eIgcZVTUBOdt4Lrl tR6N+igsoxcIv2EogZKvG+XWfvokw14jgLeQLMar5lDPMzhW+X2nfy+2DyMVWj1o wQm8MrfaWbEGhdMEbQTX =s/w3 -----END PGP SIGNATURE----- --opJtzjQTFsWo+cga--