Bug #75326 Select statment execute twice
Submitted: 29 Dec 2014 6:41 Modified: 27 Jun 2017 4:21
Reporter: Aleksandr Kanevskiy Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.5, 5.6.21 OS:Windows
Assigned to: CPU Architecture:Any

[29 Dec 2014 6:41] Aleksandr Kanevskiy
Description:
When I pass some select statement through ODBC, it executed twice. As I understand, first time it has executed to get metadata, and second for fetch data. It's OK for pure select statement, but if I try to execute some DML function to modify data and then return some result set it will be executed twice too and DML part of function will executed twice too. It's wrong.
I call my function through oracle heterogeneous service. 

How to repeat:
Here code example:
DECLARE
  c             INTEGER;
  nr            INTEGER;
  v_sql         VARCHAR2(200);
  gv            INTEGER;
BEGIN
    SELECT sq$s2#stages.NEXTVAL INTO x_trip_number FROM dual;
    v_sql :='CALL PROCEDURE_WITH_RESULT_SET()';
    c  := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@DB_X_OWNTERM;
    DBMS_HS_PASSTHROUGH.PARSE@DB_X_OWNTERM(c, v_sql );
    nr := DBMS_HS_PASSTHROUGH.FETCH_ROW@DB_X_OWNTERM(c);
    DBMS_HS_PASSTHROUGH.GET_VALUE@DB_X_OWNTERM(c,1,gv);
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@DB_X_OWNTERM(c);
    COMMIT;
END;
[30 Dec 2014 11:39] Chiranjeevi Battula
Hello Aleksandr Kanevskiy,

Thank you for the bug report.
I tried to reproduce the issue at my end using Visual Studio 2013 (C#.Net) and MySQL ODBC 5.3.4 but couldn't trace out any issue in insert, update and select data from the table.
Could you please list out the steps you tried out at your end? Please provide repeatable test case in order for us to confirm this issue at our end.

Thanks,
Chiranjeevi.
[30 Dec 2014 11:40] Chiranjeevi Battula
sample test case

Attachment: sample test case.PNG (image/png, text), 46.58 KiB.

[30 Dec 2014 12:29] Aleksandr Kanevskiy
Have you looked in the odbc trace file?
There is no problems with insert/update/select statement. Result always correct, but there are little difference with select statement: if you will inspect trace, you will find, that select statement executed twice. But data result will return once.
That is ok with pure select. But if you will execute some dml function, it will executed two times (and data modification will made two times too), but result set will returned only one time.
[30 Dec 2014 13:46] Chiranjeevi Battula
Hello Aleksandr Kanevskiy,

Thank you for your feedback.
Verified this behavior on Visual Studio 2013 (C#.Net) and MySQL ODBC 5.3.4.

Thanks,
Chiranjeevi.
[19 Jan 2015 6:48] Aleksandr Kanevskiy
Is some progress on this request?
[24 Apr 2017 7:14] Bogdan Degtyariov
Posted by developer:
 
Sorry it took so long to get this bug processed.
However, I have not found anything that could prove that the queries were actually executed twice.
Lets have a look at this fragment from odbc.log file:

75326.vshost    c3c-1aa8	ENTER SQLExecDirectW 
		HSTMT               0x0083BFC0
		WCHAR *             0x024E50E4 [      -3] "UPDATE test set first_name='chirannew' WHERE  last_name='reddy';\ 0"
		SDWORD                    -3

75326.vshost    c3c-1aa8	EXIT  SQLExecDirectW  with return code 0 (SQL_SUCCESS)
		HSTMT               0x0083BFC0
		WCHAR *             0x024E50E4 [      -3] "UPDATE test set first_name='chirannew' WHERE  last_name='reddy';\ 0"
		SDWORD                    -3

At the first glance they might look as two update queries, but in fact they are indicating the entry point into the driver (see ENTER SQLExecDirectW) and exit with success (EXIT  SQLExecDirectW  with return code 0 (SQL_SUCCESS)). In other words, they just mark the boundaries of one UPDATE query.

The conclusion is: it is the wrong interpretation of the log information, not a bug. Hence, going forward with closing it.

Please feel free to reopen it if you have a log with two pairs of ENTER/EXIT.
Thanks.