Open vt-pongrass opened 3 years ago
Hi,
Il giorno gio 29 lug 2021 alle ore 09:56 vt-pongrass < @.***> ha scritto:
Hi there,
I'm trying to replace the use of the Sybase client ODBC driver with FreeTDS's ODBC driver but I've run into a compatibility issue which prevents me from migrating to the FreeTDS driver.
In summary, the FreeTDS ODBC driver does not return a result set via SQLFetch when a batch statement is executed. The same statement works fine (ie, returns a result set) when it is executed using the Sybase ODBC driver and/or FreeTDS's tsql program.
My actual batch statement is much longer than the code shown below. I've stripped it down to the bare essentials to demonstrate the problem.
All results shown below are using the same Sybase ASA 8 database running the same server engine instance.
I'll show the output from 3 programs to try to convince you that the problem is in the FreeTDS ODBC driver.
First, when tsql is used, the correct result set is reported.
Second, when iODBC's iodbctest program is used (which in turn uses the FreeTDS ODBC driver), the result set is not reported correctly.
Third, when Sybase's dbisqlc program is used (which in turn uses the Sybase ODBC driver), the correct result set is reported.
For each program used, I have shown 2 versions of the batch statement: one that reports a result set and one that does not when the FreeTDS ODBC driver is used but does with the other programs.
These 2 versions actually produce different TDS protocol level packets from the server. I believe the FreeTDS ODBC driver mishandles the returned data and this causes the result set to not be returned.
I have saved the logs from the FreeTDS driver which shows the different packets returned but I don't know if it is necessary to post them. I'm happy to post them if need be.
Thanks in advance for any help you can provide.
- output from using the FreeTDS tsql program (I believe the ODBC driver is not used)
% TDSVER=5.0 /usr/local/freetds-1.3/bin/tsql -H 192.168.0.10 -p 2638 -U xxx -P xxx locale is "en_AU.UTF-8" locale charset is "UTF-8" using default charset "UTF-8" 1> begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end 2> go 1 null 1 NULL (1 row affected) 1 null 1 NULL
Why 4 times ??
1> begin declare @count integer select @count = count(*) from
clx.web_session if @count = 1 select 1, null else select null, 2 end 2> go null 2 NULL 2 (1 row affected) null 2 NULL 2
1> quit
- output from using the iODBC iodbctest program (iODBC loads the FreeTDS ODBC driver)
% /usr/local/iODBC/bin/iodbctest "DSN=xxx;UID=xxx;PWD=xxx" iODBC Demonstration program This program shows an interactive SQL processor Driver Manager: 03.52.1521.0607 Driver: 01.03.0000 (libtdsodbc.so)
SQL>begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end 1 null 1 **
result set 1 returned 1 rows.
SQL>begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end Statement executed. 1 rows affected.
there should be a result set shown here but the FreeTDS ODBC driver fails to return it
Indeed. Did you also try with iodbctest using Sybase ODBC ?
Can you post ODBC trace ?
SQL>^C
output from using the Sybase dbisqlc program
File Edit Command Data Options Help ┌─────────────────────────────────────Data─────────────────────────────────────┐ │ 1│ null ^ │──────┼────── ▒ │ 1│(NULL) ▒ │ v └<▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒>┘ ┌──────────────────────────────────Statistics──────────────────────────────────┐ │Procedure is executing. Use RESUME to continue. │ ┌───────────────────────────────────Command────────────────────────────────────┐ │begin ^ │ declare @c integer # │ select @c = 1 ▒ │ if @.*** select 1,null else select null,2 ▒ │end v └──────────────────────────────────────────────────────────────────────────────┘
File Edit Command Data Options Help ┌─────────────────────────────────────Data─────────────────────────────────────┐ │ null│ 2 ^ │──────┼────── ▒ │(NULL)│ 2 ▒ │ v └<▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒>┘ ┌──────────────────────────────────Statistics──────────────────────────────────┐ │Procedure is executing. Use RESUME to continue. │ ┌───────────────────────────────────Command────────────────────────────────────┐ │begin ^ │ declare @c integer # │ select @c = count(*) from clx.web_session ▒ │ if @.*** select 1,null else select null,2 ▒ │end v └──────────────────────────────────────────────────────────────────────────────┘
Frediano
Hi,
Hi, Il giorno gio 29 lug 2021 alle ore 09:56 vt-pongrass < @.***> ha scritto:
1> begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end 2> go 1 null 1 NULL (1 row affected) 1 null 1 NULL
Why 4 times ??
tsql produces this output:
1 null
1 NULL
(1 row affected)
and I then added a table to make it clearer what the output is. Hence you see 4 lines of "1 null" when viewed as raw text (instead of when viewed as formatted MarkDown).
Indeed. Did you also try with iodbctest using Sybase ODBC ?
I have now done so. The output of the first version is:
% ./iodbctest "DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_1.txt"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver: 12.00.0001 (SQL Anywhere)
SQL>begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end
1 |null
------+------
1 |******
result set 1 returned 1 rows.
SQL>quit
and the other version:
% ./iodbctest "DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/Users/vtan/ASA12_ODBC_trace_log_select_count_star.txt"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver: 12.00.0001 (SQL Anywhere)
SQL>begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end
null |2
------+------
******|2
result set 1 returned 1 rows.
SQL>quit
Can you post ODBC trace ?
certainly. This is the trace for begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end
using iodbctest and the FreeTDS ODBC driver:
** iODBC Trace file
** Trace started on Mon Aug 02 17:52:49 2021
** Driver Manager: 03.52.1521.0607
[000000.002000]
iodbctest 1043DFD40 ENTER SQLAllocHandle
SQLSMALLINT 1 (SQL_HANDLE_ENV)
SQLHANDLE 0x0 (SQL_NULL_HANDLE)
SQLHANDLE * 0x10408d000
[000000.002052]
iodbctest 1043DFD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 (SQL_HANDLE_ENV)
SQLHANDLE 0x0 (SQL_NULL_HANDLE)
SQLHANDLE * 0x10408d000 (0x137e06b10)
[000000.002098]
iodbctest 1043DFD40 ENTER SQLSetEnvAttr
SQLHENV 0x137e06b10
SQLINTEGER 200 (SQL_ATTR_ODBC_VERSION)
SQLPOINTER 0x3
SQLINTEGER * -5 (SQL_IS_UINTEGER)
[000000.002192]
iodbctest 1043DFD40 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS)
SQLHENV 0x137e06b10
SQLINTEGER 200 (SQL_ATTR_ODBC_VERSION)
SQLPOINTER 0x3
SQLINTEGER * -5 (SQL_IS_UINTEGER)
[000000.002233]
iodbctest 1043DFD40 ENTER SQLAllocHandle
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHANDLE 0x137e06b10
SQLHANDLE * 0x10408d008
[000000.002267]
iodbctest 1043DFD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHANDLE 0x137e06b10
SQLHANDLE * 0x10408d008 (0x127e04990)
[000000.002301]
iodbctest 1043DFD40 ENTER SQLSetConnectOption
SQLHDBC 0x127e04990
SQLUSMALLINT 1051 (unknown connection attribute)
SQLLEN 4362598786
[000000.002337]
iodbctest 1043DFD40 EXIT SQLSetConnectOption with return code 0 (SQL_SUCCESS)
SQLHDBC 0x127e04990
SQLUSMALLINT 1051 (unknown connection attribute)
SQLLEN 4362598786
[000000.002394]
iodbctest 1043DFD40 ENTER SQLGetInfo
SQLHDBC 0x127e04990
SQLUSMALLINT 171 (SQL_DM_VER)
SQLPOINTER 0x16bdb7371
SQLSMALLINT 255
SQLSMALLINT * 0x16bdb7178
[000000.002441]
iodbctest 1043DFD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS)
SQLHDBC 0x127e04990
SQLUSMALLINT 171 (SQL_DM_VER)
SQLPOINTER 0x16bdb7371
| 03.52.1521.0607 |
SQLSMALLINT 255
SQLSMALLINT * 0x16bdb7178 (15)
[000000.002778]
iodbctest 1043DFD40 ENTER SQLDriverConnect
SQLHDBC 0x127e04990
SQLPOINTER 0x0
SQLCHAR * 0x16bdb7590
| DSN=***;UID=***;PWD=*** |
SQLSMALLINT -3 (SQL_NTS)
SQLCHAR * 0x10408e000
SQLSMALLINT 4096
SQLSMALLINT * 0x16bdb717a
SQLUSMALLINT 1 (SQL_DRIVER_COMPLETE)
[000008.635059]
iodbctest 1043DFD40 EXIT SQLDriverConnect with return code 0 (SQL_SUCCESS)
SQLHDBC 0x127e04990
SQLPOINTER 0x0
SQLCHAR * 0x16bdb7590
SQLSMALLINT -3 (SQL_NTS)
SQLCHAR * 0x10408e000
| DSN=***;UID=***;PWD=*** |
SQLSMALLINT 4096
SQLSMALLINT * 0x16bdb717a (28)
SQLUSMALLINT 1 (SQL_DRIVER_COMPLETE)
[000008.635261]
iodbctest 1043DFD40 ENTER SQLGetInfo
SQLHDBC 0x127e04990
SQLUSMALLINT 7 (SQL_DRIVER_VER)
SQLPOINTER 0x16bdb7371
SQLSMALLINT 255
SQLSMALLINT * 0x16bdb7178
[000008.635483]
iodbctest 1043DFD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS)
SQLHDBC 0x127e04990
SQLUSMALLINT 7 (SQL_DRIVER_VER)
SQLPOINTER 0x16bdb7371
| 01.03.0000 |
SQLSMALLINT 255
SQLSMALLINT * 0x16bdb7178 (10)
[000008.635636]
iodbctest 1043DFD40 ENTER SQLGetInfo
SQLHDBC 0x127e04990
SQLUSMALLINT 6 (SQL_DRIVER_NAME)
SQLPOINTER 0x16bdb7371
SQLSMALLINT 255
SQLSMALLINT * 0x16bdb7178
[000008.635765]
iodbctest 1043DFD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS)
SQLHDBC 0x127e04990
SQLUSMALLINT 6 (SQL_DRIVER_NAME)
SQLPOINTER 0x16bdb7371
| libtdsodbc.so |
SQLSMALLINT 255
SQLSMALLINT * 0x16bdb7178 (13)
[000008.635992]
iodbctest 1043DFD40 ENTER SQLGetFunctions
SQLHDBC 0x127e04990
SQLUSMALLINT 999 (SQL_API_ODBC3_ALL_FUNCTIONS)
[000008.636044]
iodbctest 1043DFD40 EXIT SQLGetFunctions with return code 0 (SQL_SUCCESS)
SQLHDBC 0x127e04990
SQLUSMALLINT 999 (SQL_API_ODBC3_ALL_FUNCTIONS)
SQLUSMALLINT * 0x16bdb717c
[000008.636092]
iodbctest 1043DFD40 ENTER SQLAllocHandle
SQLSMALLINT 3 (SQL_HANDLE_STMT)
SQLHANDLE 0x127e04990
SQLHANDLE * 0x10408d010
[000008.636273]
iodbctest 1043DFD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3 (SQL_HANDLE_STMT)
SQLHANDLE 0x127e04990
SQLHANDLE * 0x10408d010 (0x107f04740)
[000017.024071]
iodbctest 1043DFD40 ENTER SQLPrepare
SQLHSTMT 0x107f04740
SQLCHAR * 0x16bdb6990
| begin declare @count integer select @cou |
| nt = 1 if @count = 1 select 1, null else |
| select null, 2 end |
SQLINTEGER -3 (SQL_NTS)
[000018.604799]
iodbctest 1043DFD40 EXIT SQLPrepare with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
SQLCHAR * 0x16bdb6990
SQLINTEGER -3 (SQL_NTS)
[000018.604959]
iodbctest 1043DFD40 ENTER SQLExecute
SQLHSTMT 0x107f04740
[000022.496477]
iodbctest 1043DFD40 EXIT SQLExecute with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
[000022.496592]
iodbctest 1043DFD40 ENTER SQLNumResultCols
SQLHSTMT 0x107f04740
SQLSMALLINT * 0x16bdb54dc
[000022.496703]
iodbctest 1043DFD40 EXIT SQLNumResultCols with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
SQLSMALLINT * 0x16bdb54dc (2)
[000022.496815]
iodbctest 1043DFD40 ENTER SQLDescribeCol
SQLHSTMT 0x107f04740
SQLUSMALLINT 1
SQLCHAR * 0x16bdb54de
SQLSMALLINT 50
SQLSMALLINT * 0x0
SQLSMALLINT * 0x16bdb54da
SQLULEN * 0x16bdb54d0
SQLSMALLINT * 0x16bdb54c6
SQLSMALLINT * 0x16bdb54c4
[000022.497076]
iodbctest 1043DFD40 EXIT SQLDescribeCol with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
SQLUSMALLINT 1
SQLCHAR * 0x16bdb54de
| 1 |
SQLSMALLINT 50
SQLSMALLINT * 0x0
SQLSMALLINT * 0x16bdb54da (SQL_SMALLINT)
SQLULEN * 0x16bdb54d0 (5)
SQLSMALLINT * 0x16bdb54c6 (0)
SQLSMALLINT * 0x16bdb54c4 (SQL_NO_NULLS)
[000022.497288]
iodbctest 1043DFD40 ENTER SQLDescribeCol
SQLHSTMT 0x107f04740
SQLUSMALLINT 2
SQLCHAR * 0x16bdb54de
SQLSMALLINT 50
SQLSMALLINT * 0x0
SQLSMALLINT * 0x16bdb54da
SQLULEN * 0x16bdb54d0
SQLSMALLINT * 0x16bdb54c6
SQLSMALLINT * 0x16bdb54c4
[000022.497483]
iodbctest 1043DFD40 EXIT SQLDescribeCol with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
SQLUSMALLINT 2
SQLCHAR * 0x16bdb54de
| null |
SQLSMALLINT 50
SQLSMALLINT * 0x0
SQLSMALLINT * 0x16bdb54da (SQL_SMALLINT)
SQLULEN * 0x16bdb54d0 (5)
SQLSMALLINT * 0x16bdb54c6 (0)
SQLSMALLINT * 0x16bdb54c4 (SQL_NULLABLE)
[000022.497748]
iodbctest 1043DFD40 ENTER SQLFetchScroll
SQLHSTMT 0x107f04740
SQLUSMALLINT 1 (SQL_FETCH_NEXT)
SQLLEN 1
[000022.498054]
iodbctest 1043DFD40 EXIT SQLFetchScroll with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
SQLUSMALLINT 1 (SQL_FETCH_NEXT)
SQLLEN 1
[000022.498185]
iodbctest 1043DFD40 ENTER SQLGetData
SQLHSTMT 0x107f04740
SQLUSMALLINT 1
SQLSMALLINT 1 (SQL_C_CHAR)
SQLPOINTER 0x16bdb6590
SQLLEN 1024
SQLLEN * 0x16bdb54c8
[000022.498445]
iodbctest 1043DFD40 EXIT SQLGetData with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
SQLUSMALLINT 1
SQLSMALLINT 1 (SQL_C_CHAR)
SQLPOINTER 0x16bdb6590
| 1 |
SQLLEN 1024
SQLLEN * 0x16bdb54c8 (1)
[000022.498632]
iodbctest 1043DFD40 ENTER SQLGetData
SQLHSTMT 0x107f04740
SQLUSMALLINT 2
SQLSMALLINT 1 (SQL_C_CHAR)
SQLPOINTER 0x16bdb6590
SQLLEN 1024
SQLLEN * 0x16bdb54c8
[000022.498722]
iodbctest 1043DFD40 EXIT SQLGetData with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
SQLUSMALLINT 2
SQLSMALLINT 1 (SQL_C_CHAR)
SQLPOINTER 0x16bdb6590
SQLLEN 1024
SQLLEN * 0x16bdb54c8 (-1)
[000022.498876]
iodbctest 1043DFD40 ENTER SQLFetchScroll
SQLHSTMT 0x107f04740
SQLUSMALLINT 1 (SQL_FETCH_NEXT)
SQLLEN 1
[000022.499029]
iodbctest 1043DFD40 EXIT SQLFetchScroll with return code 100 (SQL_NO_DATA_FOUND)
SQLHSTMT 0x107f04740
SQLUSMALLINT 1 (SQL_FETCH_NEXT)
SQLLEN 1
[000022.499079]
iodbctest 1043DFD40 ENTER SQLMoreResults
SQLHSTMT 0x107f04740
[000022.499359]
iodbctest 1043DFD40 EXIT SQLMoreResults with return code 100 (SQL_NO_DATA_FOUND)
SQLHSTMT 0x107f04740
[000022.499394]
iodbctest 1043DFD40 ENTER SQLCloseCursor
SQLHSTMT 0x107f04740
[000022.499464]
iodbctest 1043DFD40 EXIT SQLCloseCursor with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
[000072.150380]
iodbctest 1043DFD40 ENTER SQLCloseCursor
SQLHSTMT 0x107f04740
[000072.152153]
iodbctest 1043DFD40 EXIT SQLCloseCursor with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x107f04740
[000072.152212]
iodbctest 1043DFD40 ENTER SQLFreeHandle
SQLSMALLINT 3 (SQL_HANDLE_STMT)
SQLHSTMT 0x107f04740
[000078.930755]
iodbctest 1043DFD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3 (SQL_HANDLE_STMT)
SQLHSTMT 0x107f04740
[000078.930905]
iodbctest 1043DFD40 ENTER SQLDisconnect
SQLHDBC 0x127e04990
[000080.067519]
iodbctest 1043DFD40 EXIT SQLDisconnect with return code 0 (SQL_SUCCESS)
SQLHDBC 0x127e04990
[000080.067603]
iodbctest 1043DFD40 ENTER SQLFreeHandle
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHDBC 0x127e04990
[000080.067837]
iodbctest 1043DFD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHDBC 0x127e04990
[000080.067921]
iodbctest 1043DFD40 ENTER SQLFreeHandle
SQLSMALLINT 1 (SQL_HANDLE_ENV)
SQLHENV 0x137e06b10
[000080.067998]
iodbctest 1043DFD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 (SQL_HANDLE_ENV)
SQLHENV 0x137e06b10
** Trace finished on Mon Aug 02 17:54:09 2021
and this is the trace for begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end
using iodbctest and the FreeTDS ODBC driver:
** iODBC Trace file
** Trace started on Mon Aug 02 17:56:36 2021
** Driver Manager: 03.52.1521.0607
[000000.001547]
iodbctest 10312FD40 ENTER SQLAllocHandle
SQLSMALLINT 1 (SQL_HANDLE_ENV)
SQLHANDLE 0x0 (SQL_NULL_HANDLE)
SQLHANDLE * 0x102fe5000
[000000.001627]
iodbctest 10312FD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 (SQL_HANDLE_ENV)
SQLHANDLE 0x0 (SQL_NULL_HANDLE)
SQLHANDLE * 0x102fe5000 (0x123f04080)
[000000.001684]
iodbctest 10312FD40 ENTER SQLSetEnvAttr
SQLHENV 0x123f04080
SQLINTEGER 200 (SQL_ATTR_ODBC_VERSION)
SQLPOINTER 0x3
SQLINTEGER * -5 (SQL_IS_UINTEGER)
[000000.001834]
iodbctest 10312FD40 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS)
SQLHENV 0x123f04080
SQLINTEGER 200 (SQL_ATTR_ODBC_VERSION)
SQLPOINTER 0x3
SQLINTEGER * -5 (SQL_IS_UINTEGER)
[000000.001884]
iodbctest 10312FD40 ENTER SQLAllocHandle
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHANDLE 0x123f04080
SQLHANDLE * 0x102fe5008
[000000.001926]
iodbctest 10312FD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHANDLE 0x123f04080
SQLHANDLE * 0x102fe5008 (0x123e07230)
[000000.001969]
iodbctest 10312FD40 ENTER SQLSetConnectOption
SQLHDBC 0x123e07230
SQLUSMALLINT 1051 (unknown connection attribute)
SQLLEN 4345133442
[000000.002011]
iodbctest 10312FD40 EXIT SQLSetConnectOption with return code 0 (SQL_SUCCESS)
SQLHDBC 0x123e07230
SQLUSMALLINT 1051 (unknown connection attribute)
SQLLEN 4345133442
[000000.002111]
iodbctest 10312FD40 ENTER SQLGetInfo
SQLHDBC 0x123e07230
SQLUSMALLINT 171 (SQL_DM_VER)
SQLPOINTER 0x16ce5f371
SQLSMALLINT 255
SQLSMALLINT * 0x16ce5f178
[000000.002169]
iodbctest 10312FD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS)
SQLHDBC 0x123e07230
SQLUSMALLINT 171 (SQL_DM_VER)
SQLPOINTER 0x16ce5f371
| 03.52.1521.0607 |
SQLSMALLINT 255
SQLSMALLINT * 0x16ce5f178 (15)
[000000.002534]
iodbctest 10312FD40 ENTER SQLDriverConnect
SQLHDBC 0x123e07230
SQLPOINTER 0x0
SQLCHAR * 0x16ce5f590
| DSN=***;UID=***;PWD=*** |
SQLSMALLINT -3 (SQL_NTS)
SQLCHAR * 0x102fe6000
SQLSMALLINT 4096
SQLSMALLINT * 0x16ce5f17a
SQLUSMALLINT 1 (SQL_DRIVER_COMPLETE)
[000002.022623]
iodbctest 10312FD40 EXIT SQLDriverConnect with return code 0 (SQL_SUCCESS)
SQLHDBC 0x123e07230
SQLPOINTER 0x0
SQLCHAR * 0x16ce5f590
SQLSMALLINT -3 (SQL_NTS)
SQLCHAR * 0x102fe6000
| DSN=***;UID=***;PWD=*** |
SQLSMALLINT 4096
SQLSMALLINT * 0x16ce5f17a (28)
SQLUSMALLINT 1 (SQL_DRIVER_COMPLETE)
[000002.022856]
iodbctest 10312FD40 ENTER SQLGetInfo
SQLHDBC 0x123e07230
SQLUSMALLINT 7 (SQL_DRIVER_VER)
SQLPOINTER 0x16ce5f371
SQLSMALLINT 255
SQLSMALLINT * 0x16ce5f178
[000002.023060]
iodbctest 10312FD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS)
SQLHDBC 0x123e07230
SQLUSMALLINT 7 (SQL_DRIVER_VER)
SQLPOINTER 0x16ce5f371
| 01.03.0000 |
SQLSMALLINT 255
SQLSMALLINT * 0x16ce5f178 (10)
[000002.023218]
iodbctest 10312FD40 ENTER SQLGetInfo
SQLHDBC 0x123e07230
SQLUSMALLINT 6 (SQL_DRIVER_NAME)
SQLPOINTER 0x16ce5f371
SQLSMALLINT 255
SQLSMALLINT * 0x16ce5f178
[000002.023358]
iodbctest 10312FD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS)
SQLHDBC 0x123e07230
SQLUSMALLINT 6 (SQL_DRIVER_NAME)
SQLPOINTER 0x16ce5f371
| libtdsodbc.so |
SQLSMALLINT 255
SQLSMALLINT * 0x16ce5f178 (13)
[000002.023572]
iodbctest 10312FD40 ENTER SQLGetFunctions
SQLHDBC 0x123e07230
SQLUSMALLINT 999 (SQL_API_ODBC3_ALL_FUNCTIONS)
[000002.023638]
iodbctest 10312FD40 EXIT SQLGetFunctions with return code 0 (SQL_SUCCESS)
SQLHDBC 0x123e07230
SQLUSMALLINT 999 (SQL_API_ODBC3_ALL_FUNCTIONS)
SQLUSMALLINT * 0x16ce5f17c
[000002.023700]
iodbctest 10312FD40 ENTER SQLAllocHandle
SQLSMALLINT 3 (SQL_HANDLE_STMT)
SQLHANDLE 0x123e07230
SQLHANDLE * 0x102fe5010
[000002.023921]
iodbctest 10312FD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3 (SQL_HANDLE_STMT)
SQLHANDLE 0x123e07230
SQLHANDLE * 0x102fe5010 (0x113e04460)
[000012.807891]
iodbctest 10312FD40 ENTER SQLPrepare
SQLHSTMT 0x113e04460
SQLCHAR * 0x16ce5e990
| begin declare @count integer select @cou |
| nt = count(*) from clx.web_session if @c |
| ount = 1 select 1, null else select null |
| , 2 end |
SQLINTEGER -3 (SQL_NTS)
[000012.850417]
iodbctest 10312FD40 EXIT SQLPrepare with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x113e04460
SQLCHAR * 0x16ce5e990
SQLINTEGER -3 (SQL_NTS)
[000012.850572]
iodbctest 10312FD40 ENTER SQLExecute
SQLHSTMT 0x113e04460
[000014.118149]
iodbctest 10312FD40 EXIT SQLExecute with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x113e04460
[000014.118255]
iodbctest 10312FD40 ENTER SQLNumResultCols
SQLHSTMT 0x113e04460
SQLSMALLINT * 0x16ce5d4dc
[000014.118355]
iodbctest 10312FD40 EXIT SQLNumResultCols with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x113e04460
SQLSMALLINT * 0x16ce5d4dc (0)
[000014.118430]
iodbctest 10312FD40 ENTER SQLRowCount
SQLHSTMT 0x113e04460
SQLLEN * 0x16ce5d4b8
[000014.118572]
iodbctest 10312FD40 EXIT SQLRowCount with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x113e04460
SQLLEN * 0x16ce5d4b8 (1)
[000014.118721]
iodbctest 10312FD40 ENTER SQLCloseCursor
SQLHSTMT 0x113e04460
[000014.135749]
iodbctest 10312FD40 EXIT SQLCloseCursor with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x113e04460
[000016.579191]
iodbctest 10312FD40 ENTER SQLCloseCursor
SQLHSTMT 0x113e04460
[000016.579468]
iodbctest 10312FD40 EXIT SQLCloseCursor with return code 0 (SQL_SUCCESS)
SQLHSTMT 0x113e04460
[000016.579555]
iodbctest 10312FD40 ENTER SQLFreeHandle
SQLSMALLINT 3 (SQL_HANDLE_STMT)
SQLHSTMT 0x113e04460
[000016.623479]
iodbctest 10312FD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3 (SQL_HANDLE_STMT)
SQLHSTMT 0x113e04460
[000016.623576]
iodbctest 10312FD40 ENTER SQLDisconnect
SQLHDBC 0x123e07230
[000018.287542]
iodbctest 10312FD40 EXIT SQLDisconnect with return code 0 (SQL_SUCCESS)
SQLHDBC 0x123e07230
[000018.287642]
iodbctest 10312FD40 ENTER SQLFreeHandle
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHDBC 0x123e07230
[000018.287818]
iodbctest 10312FD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHDBC 0x123e07230
[000018.287896]
iodbctest 10312FD40 ENTER SQLFreeHandle
SQLSMALLINT 1 (SQL_HANDLE_ENV)
SQLHENV 0x123f04080
[000018.287970]
iodbctest 10312FD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 (SQL_HANDLE_ENV)
SQLHENV 0x123f04080
** Trace finished on Mon Aug 02 17:56:54 2021
and this is the trace for begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end
using iodbctest and the Sybase ASA12 ODBC driver:
03/07/2021 18:26:35.113329
Enter SQLDriverConnect:
SQLHDBC 0xfbc04460
SQLHWND 0x00000000
SQLCHAR * 0x0x7ffeeb03e5f0 [DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_1.txt]
SQLSMALLINT -3
SQLCHAR * 0x0x104bc3150
SQLSMALLINT 4096
SQLSMALLINT * 0x0x7ffeeb03e2ec
SQLUSMALLINT 1
03/07/2021 18:26:35.121869
Exit SQLDriverConnect: return code 0 ( SQL_SUCCESS ):
SQLHDBC 0xfbc04460
SQLHWND 0x00000000
SQLCHAR * 0x0x7ffeeb03e5f0 [DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_1.txt]
SQLSMALLINT -3
SQLCHAR * 0x0x104bc3150 [DSN=xxx;UID=xxx;PWD=xxx]
SQLSMALLINT 4096
SQLSMALLINT * 0x0x7ffeeb03e2ec [26]
SQLUSMALLINT 1
03/07/2021 18:26:35.121893
Enter SQLGetInfo:
SQLHDBC 0xfbc04460
SQLUSMALLINT 7
SQLPOINTER 0x0x7ffeeb03e4f0
SQLSMALLINT 255
SQLSMALLINT * 0x0x7ffeeb03e2ee
03/07/2021 18:26:35.121905
Exit SQLGetInfo: return code 0 ( SQL_SUCCESS ):
SQLHDBC 0xfbc04460
SQLUSMALLINT 7
SQLPOINTER 0x0x7ffeeb03e4f0
SQLSMALLINT 255
SQLSMALLINT * 0x0x7ffeeb03e2ee [10]
03/07/2021 18:26:35.121923
Enter SQLGetInfo:
SQLHDBC 0xfbc04460
SQLUSMALLINT 6
SQLPOINTER 0x0x7ffeeb03e4f0
SQLSMALLINT 255
SQLSMALLINT * 0x0x7ffeeb03e2ee
03/07/2021 18:26:35.121931
Exit SQLGetInfo: return code 0 ( SQL_SUCCESS ):
SQLHDBC 0xfbc04460
SQLUSMALLINT 6
SQLPOINTER 0x0x7ffeeb03e4f0
SQLSMALLINT 255
SQLSMALLINT * 0x0x7ffeeb03e2ee [12]
03/07/2021 18:26:35.121967
Enter SQLGetFunctions:
SQLHDBC 0xfbc04460
SQLUSMALLINT 999
SQLUSMALLINT * 0x0x7ffeeb03e2f0 [58160]
03/07/2021 18:26:35.121974
Exit SQLGetFunctions: return code -1 ( SQL_ERROR ):
SQLHDBC 0xfbc04460
SQLUSMALLINT 999
SQLUSMALLINT * 0x0x7ffeeb03e2f0 [58160]
03/07/2021 18:26:36.398471
Enter SQLPrepare:
SQLHSTMT 0xfbe01930
SQLCHAR * 0x0x7ffeeb03d9f0 [begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end]
SQLINTEGER -3
03/07/2021 18:26:36.398943
Exit SQLPrepare: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xfbe01930
SQLCHAR * 0x0x7ffeeb03d9f0 [begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end]
SQLINTEGER -3
03/07/2021 18:26:36.398977
Enter SQLExecute:
SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.399433
Exit SQLExecute: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.399470
Enter SQLNumResultCols:
SQLHSTMT 0xfbe01930
SQLSMALLINT * 0x0x7ffeeb03c52e
03/07/2021 18:26:36.399485
Exit SQLNumResultCols: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xfbe01930
SQLSMALLINT * 0x0x7ffeeb03c52e [2]
03/07/2021 18:26:36.399511
Enter SQLDescribeCol:
SQLHSTMT 0xfbe01930
SQLUSMALLINT 1
SQLCHAR * 0x0x7ffeeb03c530
SQLSMALLINT 50
SQLSMALLINT * 0x0x000000
SQLSMALLINT * 0x0x7ffeeb03c52a [-21102]
SQLULEN * 0x0x7ffeeb03c520
SQLSMALLINT * 0x0x7ffeeb03c52c
SQLSMALLINT * 0x0x7ffeeb03c51e
03/07/2021 18:26:36.399539
Exit SQLDescribeCol: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xfbe01930
SQLUSMALLINT 1
SQLCHAR * 0x0x7ffeeb03c530 [1]
SQLSMALLINT 50
SQLSMALLINT * 0x0x000000
SQLSMALLINT * 0x0x7ffeeb03c52a [5]
SQLULEN * 0x0x7ffeeb03c520 [5]
SQLSMALLINT * 0x0x7ffeeb03c52c [0]
SQLSMALLINT * 0x0x7ffeeb03c51e [0]
03/07/2021 18:26:36.399560
Enter SQLDescribeCol:
SQLHSTMT 0xfbe01930
SQLUSMALLINT 2
SQLCHAR * 0x0x7ffeeb03c530
SQLSMALLINT 50
SQLSMALLINT * 0x0x000000
SQLSMALLINT * 0x0x7ffeeb03c52a [5]
SQLULEN * 0x0x7ffeeb03c520
SQLSMALLINT * 0x0x7ffeeb03c52c
SQLSMALLINT * 0x0x7ffeeb03c51e
03/07/2021 18:26:36.399576
Exit SQLDescribeCol: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xfbe01930
SQLUSMALLINT 2
SQLCHAR * 0x0x7ffeeb03c530 [null]
SQLSMALLINT 50
SQLSMALLINT * 0x0x000000
SQLSMALLINT * 0x0x7ffeeb03c52a [5]
SQLULEN * 0x0x7ffeeb03c520 [5]
SQLSMALLINT * 0x0x7ffeeb03c52c [0]
SQLSMALLINT * 0x0x7ffeeb03c51e [1]
03/07/2021 18:26:36.399635
Enter SQLFetchScroll:
SQLHSTMT 0xfbe01930
SQLSMALLINT 1
SQLLEN 1
03/07/2021 18:26:36.399792
Exit SQLFetchScroll: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xfbe01930
SQLSMALLINT 1
SQLLEN 1
03/07/2021 18:26:36.399816
Enter SQLGetData:
SQLHSTMT 0xfbe01930
SQLUSMALLINT 1
SQLSMALLINT 1
SQLPOINTER 0x0x7ffeeb03d5f0
SQLLEN 1024
SQLLEN * 0x0x7ffeeb03c500
03/07/2021 18:26:36.400011
Exit SQLGetData: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xfbe01930
SQLUSMALLINT 1
SQLSMALLINT 1
SQLPOINTER 0x0x7ffeeb03d5f0
SQLLEN 1024
SQLLEN * 0x0x7ffeeb03c500 [1]
03/07/2021 18:26:36.400045
Enter SQLGetData:
SQLHSTMT 0xfbe01930
SQLUSMALLINT 2
SQLSMALLINT 1
SQLPOINTER 0x0x7ffeeb03d5f0
SQLLEN 1024
SQLLEN * 0x0x7ffeeb03c500
03/07/2021 18:26:36.400173
Exit SQLGetData: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xfbe01930
SQLUSMALLINT 2
SQLSMALLINT 1
SQLPOINTER 0x0x7ffeeb03d5f0
SQLLEN 1024
SQLLEN * 0x0x7ffeeb03c500 [-1]
03/07/2021 18:26:36.400221
Enter SQLFetchScroll:
SQLHSTMT 0xfbe01930
SQLSMALLINT 1
SQLLEN 1
03/07/2021 18:26:36.400368
Exit SQLFetchScroll: return code 100 ( SQL_NO_DATA ):
SQLHSTMT 0xfbe01930
SQLSMALLINT 1
SQLLEN 1
03/07/2021 18:26:36.400414
Enter SQLMoreResults:
SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.400690
Exit SQLMoreResults: return code 100 ( SQL_NO_DATA ):
SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.400728
Enter SQLCloseCursor:
SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.400746
Exit SQLCloseCursor: return code -1 ( SQL_ERROR ):
SQLHSTMT 0xfbe01930
03/07/2021 18:26:38.398357
Enter SQLCloseCursor:
SQLHSTMT 0xfbe01930
03/07/2021 18:26:38.398396
Exit SQLCloseCursor: return code -1 ( SQL_ERROR ):
SQLHSTMT 0xfbe01930
03/07/2021 18:26:38.398414
Enter SQLFreeHandle:
SQLSMALLINT 3
SQLHANDLE 0xfbe01930
03/07/2021 18:26:38.398441
Exit SQLFreeHandle: return code 0 ( SQL_SUCCESS ):
SQLSMALLINT 3
SQLHANDLE 0xfbe01930
03/07/2021 18:26:38.398454
Enter SQLDisconnect:
SQLHDBC 0xfbc04460
03/07/2021 18:26:38.398882
Exit SQLDisconnect: return code 0 ( SQL_SUCCESS ):
SQLHDBC 0xfbc04460
and this is the trace for begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end
using iodbctest and the Sybase ASA12 ODBC driver:
03/07/2021 18:27:25.279098
Enter SQLDriverConnect:
SQLHDBC 0xb6404460
SQLHWND 0x00000000
SQLCHAR * 0x0x7ffee92fc5f0 [DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_count_star.txt]
SQLSMALLINT -3
SQLCHAR * 0x0x106905150
SQLSMALLINT 4096
SQLSMALLINT * 0x0x7ffee92fc2ec
SQLUSMALLINT 1
03/07/2021 18:27:25.286322
Exit SQLDriverConnect: return code 0 ( SQL_SUCCESS ):
SQLHDBC 0xb6404460
SQLHWND 0x00000000
SQLCHAR * 0x0x7ffee92fc5f0 [DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_count_star.txt]
SQLSMALLINT -3
SQLCHAR * 0x0x106905150 [DSN=xxx;UID=xxx;PWD=xxx]
SQLSMALLINT 4096
SQLSMALLINT * 0x0x7ffee92fc2ec [26]
SQLUSMALLINT 1
03/07/2021 18:27:25.286348
Enter SQLGetInfo:
SQLHDBC 0xb6404460
SQLUSMALLINT 7
SQLPOINTER 0x0x7ffee92fc4f0
SQLSMALLINT 255
SQLSMALLINT * 0x0x7ffee92fc2ee
03/07/2021 18:27:25.286361
Exit SQLGetInfo: return code 0 ( SQL_SUCCESS ):
SQLHDBC 0xb6404460
SQLUSMALLINT 7
SQLPOINTER 0x0x7ffee92fc4f0
SQLSMALLINT 255
SQLSMALLINT * 0x0x7ffee92fc2ee [10]
03/07/2021 18:27:25.286383
Enter SQLGetInfo:
SQLHDBC 0xb6404460
SQLUSMALLINT 6
SQLPOINTER 0x0x7ffee92fc4f0
SQLSMALLINT 255
SQLSMALLINT * 0x0x7ffee92fc2ee
03/07/2021 18:27:25.286390
Exit SQLGetInfo: return code 0 ( SQL_SUCCESS ):
SQLHDBC 0xb6404460
SQLUSMALLINT 6
SQLPOINTER 0x0x7ffee92fc4f0
SQLSMALLINT 255
SQLSMALLINT * 0x0x7ffee92fc2ee [12]
03/07/2021 18:27:25.286428
Enter SQLGetFunctions:
SQLHDBC 0xb6404460
SQLUSMALLINT 999
SQLUSMALLINT * 0x0x7ffee92fc2f0 [49968]
03/07/2021 18:27:25.286436
Exit SQLGetFunctions: return code -1 ( SQL_ERROR ):
SQLHDBC 0xb6404460
SQLUSMALLINT 999
SQLUSMALLINT * 0x0x7ffee92fc2f0 [49968]
03/07/2021 18:27:33.348168
Enter SQLPrepare:
SQLHSTMT 0xb65015b0
SQLCHAR * 0x0x7ffee92fb9f0 [begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end]
SQLINTEGER -3
03/07/2021 18:27:33.348633
Exit SQLPrepare: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xb65015b0
SQLCHAR * 0x0x7ffee92fb9f0 [begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end]
SQLINTEGER -3
03/07/2021 18:27:33.348667
Enter SQLExecute:
SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.349443
Exit SQLExecute: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.349490
Enter SQLNumResultCols:
SQLHSTMT 0xb65015b0
SQLSMALLINT * 0x0x7ffee92fa52e
03/07/2021 18:27:33.349505
Exit SQLNumResultCols: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xb65015b0
SQLSMALLINT * 0x0x7ffee92fa52e [2]
03/07/2021 18:27:33.349530
Enter SQLDescribeCol:
SQLHSTMT 0xb65015b0
SQLUSMALLINT 1
SQLCHAR * 0x0x7ffee92fa530
SQLSMALLINT 50
SQLSMALLINT * 0x0x000000
SQLSMALLINT * 0x0x7ffee92fa52a [-21102]
SQLULEN * 0x0x7ffee92fa520
SQLSMALLINT * 0x0x7ffee92fa52c
SQLSMALLINT * 0x0x7ffee92fa51e
03/07/2021 18:27:33.349559
Exit SQLDescribeCol: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xb65015b0
SQLUSMALLINT 1
SQLCHAR * 0x0x7ffee92fa530 [null]
SQLSMALLINT 50
SQLSMALLINT * 0x0x000000
SQLSMALLINT * 0x0x7ffee92fa52a [5]
SQLULEN * 0x0x7ffee92fa520 [5]
SQLSMALLINT * 0x0x7ffee92fa52c [0]
SQLSMALLINT * 0x0x7ffee92fa51e [1]
03/07/2021 18:27:33.349580
Enter SQLDescribeCol:
SQLHSTMT 0xb65015b0
SQLUSMALLINT 2
SQLCHAR * 0x0x7ffee92fa530
SQLSMALLINT 50
SQLSMALLINT * 0x0x000000
SQLSMALLINT * 0x0x7ffee92fa52a [5]
SQLULEN * 0x0x7ffee92fa520
SQLSMALLINT * 0x0x7ffee92fa52c
SQLSMALLINT * 0x0x7ffee92fa51e
03/07/2021 18:27:33.349612
Exit SQLDescribeCol: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xb65015b0
SQLUSMALLINT 2
SQLCHAR * 0x0x7ffee92fa530 [2]
SQLSMALLINT 50
SQLSMALLINT * 0x0x000000
SQLSMALLINT * 0x0x7ffee92fa52a [5]
SQLULEN * 0x0x7ffee92fa520 [5]
SQLSMALLINT * 0x0x7ffee92fa52c [0]
SQLSMALLINT * 0x0x7ffee92fa51e [0]
03/07/2021 18:27:33.349646
Enter SQLFetchScroll:
SQLHSTMT 0xb65015b0
SQLSMALLINT 1
SQLLEN 1
03/07/2021 18:27:33.349791
Exit SQLFetchScroll: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xb65015b0
SQLSMALLINT 1
SQLLEN 1
03/07/2021 18:27:33.349814
Enter SQLGetData:
SQLHSTMT 0xb65015b0
SQLUSMALLINT 1
SQLSMALLINT 1
SQLPOINTER 0x0x7ffee92fb5f0
SQLLEN 1024
SQLLEN * 0x0x7ffee92fa500
03/07/2021 18:27:33.349984
Exit SQLGetData: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xb65015b0
SQLUSMALLINT 1
SQLSMALLINT 1
SQLPOINTER 0x0x7ffee92fb5f0
SQLLEN 1024
SQLLEN * 0x0x7ffee92fa500 [-1]
03/07/2021 18:27:33.350037
Enter SQLGetData:
SQLHSTMT 0xb65015b0
SQLUSMALLINT 2
SQLSMALLINT 1
SQLPOINTER 0x0x7ffee92fb5f0
SQLLEN 1024
SQLLEN * 0x0x7ffee92fa500
03/07/2021 18:27:33.350189
Exit SQLGetData: return code 0 ( SQL_SUCCESS ):
SQLHSTMT 0xb65015b0
SQLUSMALLINT 2
SQLSMALLINT 1
SQLPOINTER 0x0x7ffee92fb5f0
SQLLEN 1024
SQLLEN * 0x0x7ffee92fa500 [1]
03/07/2021 18:27:33.350230
Enter SQLFetchScroll:
SQLHSTMT 0xb65015b0
SQLSMALLINT 1
SQLLEN 1
03/07/2021 18:27:33.350374
Exit SQLFetchScroll: return code 100 ( SQL_NO_DATA ):
SQLHSTMT 0xb65015b0
SQLSMALLINT 1
SQLLEN 1
03/07/2021 18:27:33.350414
Enter SQLMoreResults:
SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.350689
Exit SQLMoreResults: return code 100 ( SQL_NO_DATA ):
SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.350741
Enter SQLCloseCursor:
SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.350759
Exit SQLCloseCursor: return code -1 ( SQL_ERROR ):
SQLHSTMT 0xb65015b0
03/07/2021 18:27:36.388025
Enter SQLCloseCursor:
SQLHSTMT 0xb65015b0
03/07/2021 18:27:36.388063
Exit SQLCloseCursor: return code -1 ( SQL_ERROR ):
SQLHSTMT 0xb65015b0
03/07/2021 18:27:36.388081
Enter SQLFreeHandle:
SQLSMALLINT 3
SQLHANDLE 0xb65015b0
03/07/2021 18:27:36.388107
Exit SQLFreeHandle: return code 0 ( SQL_SUCCESS ):
SQLSMALLINT 3
SQLHANDLE 0xb65015b0
03/07/2021 18:27:36.388120
Enter SQLDisconnect:
SQLHDBC 0xb6404460
03/07/2021 18:27:36.388509
Exit SQLDisconnect: return code 0 ( SQL_SUCCESS ):
SQLHDBC 0xb6404460
I have also attached these trace logs.
Again, thanks for any help you can provide.
FreeTDS_ODBC_trace_log_select_1.txt FreeTDS_ODBC_trace_log_select_count_star.txt ASA12_ODBC_trace_log_select_1.txt ASA12_ODBC_trace_log_select_count_star.txt
Hi, I saw the logs, thanks.
Some consideration
Consider that the format of the query sent by FreeTDS can be slightly different (the sql query is the same but a prepared query format can be different from a plain query).
Looking at the past, these empty recordset are not well seen by multiple tools, I think adding an option to remove them would be helpful.
Regards, Frediano
Il giorno mar 3 ago 2021 alle ore 09:43 vt-pongrass < @.***> ha scritto:
Hi,
Hi, Il giorno gio 29 lug 2021 alle ore 09:56 vt-pongrass < @.***> ha scritto:
1> begin declare @count https://github.com/count integer select @count https://github.com/count = 1 if @count https://github.com/count = 1 select 1, null else select null, 2 end 2> go 1 null 1 NULL (1 row affected) 1 null 1 NULL
Why 4 times ??
tsql produces this output:
1 null 1 NULL (1 row affected)
and I then added a table to make it clearer what the output is. Hence you see 4 lines of "1 null" when viewed as raw text (instead of when viewed as formatted MarkDown).
Indeed. Did you also try with iodbctest using Sybase ODBC ?
I have now done so. The output of the first version is:
% ./iodbctest "DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_1.txt" iODBC Demonstration program This program shows an interactive SQL processor Driver: 12.00.0001 (SQL Anywhere)
SQL>begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end
1 |null ------+------ 1 |**
result set 1 returned 1 rows.
SQL>quit
and the other version:
% ./iodbctest "DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/Users/vtan/ASA12_ODBC_trace_log_select_count_star.txt" iODBC Demonstration program This program shows an interactive SQL processor Driver: 12.00.0001 (SQL Anywhere)
SQL>begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end
null |2 ------+------ **|2
result set 1 returned 1 rows.
SQL>quit
Can you post ODBC trace ?
certainly. This is the trace for begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end using iodbctest and the FreeTDS ODBC driver:
iODBC Trace file Trace started on Mon Aug 02 17:52:49 2021 ** Driver Manager: 03.52.1521.0607
[000000.002000] iodbctest 1043DFD40 ENTER SQLAllocHandle SQLSMALLINT 1 (SQL_HANDLE_ENV) SQLHANDLE 0x0 (SQL_NULL_HANDLE) SQLHANDLE * 0x10408d000
[000000.002052] iodbctest 1043DFD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 1 (SQL_HANDLE_ENV) SQLHANDLE 0x0 (SQL_NULL_HANDLE) SQLHANDLE * 0x10408d000 (0x137e06b10)
[000000.002098] iodbctest 1043DFD40 ENTER SQLSetEnvAttr SQLHENV 0x137e06b10 SQLINTEGER 200 (SQL_ATTR_ODBC_VERSION) SQLPOINTER 0x3 SQLINTEGER * -5 (SQL_IS_UINTEGER)
[000000.002192] iodbctest 1043DFD40 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS) SQLHENV 0x137e06b10 SQLINTEGER 200 (SQL_ATTR_ODBC_VERSION) SQLPOINTER 0x3 SQLINTEGER * -5 (SQL_IS_UINTEGER)
[000000.002233] iodbctest 1043DFD40 ENTER SQLAllocHandle SQLSMALLINT 2 (SQL_HANDLE_DBC) SQLHANDLE 0x137e06b10 SQLHANDLE * 0x10408d008
[000000.002267] iodbctest 1043DFD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 2 (SQL_HANDLE_DBC) SQLHANDLE 0x137e06b10 SQLHANDLE * 0x10408d008 (0x127e04990)
[000000.002301] iodbctest 1043DFD40 ENTER SQLSetConnectOption SQLHDBC 0x127e04990 SQLUSMALLINT 1051 (unknown connection attribute) SQLLEN 4362598786
[000000.002337] iodbctest 1043DFD40 EXIT SQLSetConnectOption with return code 0 (SQL_SUCCESS) SQLHDBC 0x127e04990 SQLUSMALLINT 1051 (unknown connection attribute) SQLLEN 4362598786
[000000.002394] iodbctest 1043DFD40 ENTER SQLGetInfo SQLHDBC 0x127e04990 SQLUSMALLINT 171 (SQL_DM_VER) SQLPOINTER 0x16bdb7371 SQLSMALLINT 255 SQLSMALLINT * 0x16bdb7178
[000000.002441] iodbctest 1043DFD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS) SQLHDBC 0x127e04990 SQLUSMALLINT 171 (SQL_DM_VER) SQLPOINTER 0x16bdb7371 | 03.52.1521.0607 | SQLSMALLINT 255 SQLSMALLINT * 0x16bdb7178 (15)
[000000.002778] iodbctest 1043DFD40 ENTER SQLDriverConnect SQLHDBC 0x127e04990 SQLPOINTER 0x0 SQLCHAR * 0x16bdb7590 | DSN=;UID=;PWD=** | SQLSMALLINT -3 (SQL_NTS) SQLCHAR 0x10408e000 SQLSMALLINT 4096 SQLSMALLINT * 0x16bdb717a SQLUSMALLINT 1 (SQL_DRIVER_COMPLETE)
[000008.635059] iodbctest 1043DFD40 EXIT SQLDriverConnect with return code 0 (SQL_SUCCESS) SQLHDBC 0x127e04990 SQLPOINTER 0x0 SQLCHAR 0x16bdb7590 SQLSMALLINT -3 (SQL_NTS) SQLCHAR 0x10408e000 | DSN=;UID=;PWD=** | SQLSMALLINT 4096 SQLSMALLINT 0x16bdb717a (28) SQLUSMALLINT 1 (SQL_DRIVER_COMPLETE)
[000008.635261] iodbctest 1043DFD40 ENTER SQLGetInfo SQLHDBC 0x127e04990 SQLUSMALLINT 7 (SQL_DRIVER_VER) SQLPOINTER 0x16bdb7371 SQLSMALLINT 255 SQLSMALLINT * 0x16bdb7178
[000008.635483] iodbctest 1043DFD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS) SQLHDBC 0x127e04990 SQLUSMALLINT 7 (SQL_DRIVER_VER) SQLPOINTER 0x16bdb7371 | 01.03.0000 | SQLSMALLINT 255 SQLSMALLINT * 0x16bdb7178 (10)
[000008.635636] iodbctest 1043DFD40 ENTER SQLGetInfo SQLHDBC 0x127e04990 SQLUSMALLINT 6 (SQL_DRIVER_NAME) SQLPOINTER 0x16bdb7371 SQLSMALLINT 255 SQLSMALLINT * 0x16bdb7178
[000008.635765] iodbctest 1043DFD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS) SQLHDBC 0x127e04990 SQLUSMALLINT 6 (SQL_DRIVER_NAME) SQLPOINTER 0x16bdb7371 | libtdsodbc.so | SQLSMALLINT 255 SQLSMALLINT * 0x16bdb7178 (13)
[000008.635992] iodbctest 1043DFD40 ENTER SQLGetFunctions SQLHDBC 0x127e04990 SQLUSMALLINT 999 (SQL_API_ODBC3_ALL_FUNCTIONS)
[000008.636044] iodbctest 1043DFD40 EXIT SQLGetFunctions with return code 0 (SQL_SUCCESS) SQLHDBC 0x127e04990 SQLUSMALLINT 999 (SQL_API_ODBC3_ALL_FUNCTIONS) SQLUSMALLINT * 0x16bdb717c
[000008.636092] iodbctest 1043DFD40 ENTER SQLAllocHandle SQLSMALLINT 3 (SQL_HANDLE_STMT) SQLHANDLE 0x127e04990 SQLHANDLE * 0x10408d010
[000008.636273] iodbctest 1043DFD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 3 (SQL_HANDLE_STMT) SQLHANDLE 0x127e04990 SQLHANDLE * 0x10408d010 (0x107f04740)
[000017.024071] iodbctest 1043DFD40 ENTER SQLPrepare SQLHSTMT 0x107f04740 SQLCHAR * 0x16bdb6990 | begin declare @count integer select @cou | | nt = 1 if @count = 1 select 1, null else | | select null, 2 end | SQLINTEGER -3 (SQL_NTS)
[000018.604799] iodbctest 1043DFD40 EXIT SQLPrepare with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740 SQLCHAR * 0x16bdb6990 SQLINTEGER -3 (SQL_NTS)
[000018.604959] iodbctest 1043DFD40 ENTER SQLExecute SQLHSTMT 0x107f04740
[000022.496477] iodbctest 1043DFD40 EXIT SQLExecute with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740
[000022.496592] iodbctest 1043DFD40 ENTER SQLNumResultCols SQLHSTMT 0x107f04740 SQLSMALLINT * 0x16bdb54dc
[000022.496703] iodbctest 1043DFD40 EXIT SQLNumResultCols with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740 SQLSMALLINT * 0x16bdb54dc (2)
[000022.496815] iodbctest 1043DFD40 ENTER SQLDescribeCol SQLHSTMT 0x107f04740 SQLUSMALLINT 1 SQLCHAR 0x16bdb54de SQLSMALLINT 50 SQLSMALLINT 0x0 SQLSMALLINT 0x16bdb54da SQLULEN 0x16bdb54d0 SQLSMALLINT 0x16bdb54c6 SQLSMALLINT 0x16bdb54c4
[000022.497076] iodbctest 1043DFD40 EXIT SQLDescribeCol with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740 SQLUSMALLINT 1 SQLCHAR 0x16bdb54de | 1 | SQLSMALLINT 50 SQLSMALLINT 0x0 SQLSMALLINT 0x16bdb54da (SQL_SMALLINT) SQLULEN 0x16bdb54d0 (5) SQLSMALLINT 0x16bdb54c6 (0) SQLSMALLINT 0x16bdb54c4 (SQL_NO_NULLS)
[000022.497288] iodbctest 1043DFD40 ENTER SQLDescribeCol SQLHSTMT 0x107f04740 SQLUSMALLINT 2 SQLCHAR 0x16bdb54de SQLSMALLINT 50 SQLSMALLINT 0x0 SQLSMALLINT 0x16bdb54da SQLULEN 0x16bdb54d0 SQLSMALLINT 0x16bdb54c6 SQLSMALLINT 0x16bdb54c4
[000022.497483] iodbctest 1043DFD40 EXIT SQLDescribeCol with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740 SQLUSMALLINT 2 SQLCHAR 0x16bdb54de | null | SQLSMALLINT 50 SQLSMALLINT 0x0 SQLSMALLINT 0x16bdb54da (SQL_SMALLINT) SQLULEN 0x16bdb54d0 (5) SQLSMALLINT 0x16bdb54c6 (0) SQLSMALLINT 0x16bdb54c4 (SQL_NULLABLE)
[000022.497748] iodbctest 1043DFD40 ENTER SQLFetchScroll SQLHSTMT 0x107f04740 SQLUSMALLINT 1 (SQL_FETCH_NEXT) SQLLEN 1
[000022.498054] iodbctest 1043DFD40 EXIT SQLFetchScroll with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740 SQLUSMALLINT 1 (SQL_FETCH_NEXT) SQLLEN 1
[000022.498185] iodbctest 1043DFD40 ENTER SQLGetData SQLHSTMT 0x107f04740 SQLUSMALLINT 1 SQLSMALLINT 1 (SQL_C_CHAR) SQLPOINTER 0x16bdb6590 SQLLEN 1024 SQLLEN * 0x16bdb54c8
[000022.498445] iodbctest 1043DFD40 EXIT SQLGetData with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740 SQLUSMALLINT 1 SQLSMALLINT 1 (SQL_C_CHAR) SQLPOINTER 0x16bdb6590 | 1 | SQLLEN 1024 SQLLEN * 0x16bdb54c8 (1)
[000022.498632] iodbctest 1043DFD40 ENTER SQLGetData SQLHSTMT 0x107f04740 SQLUSMALLINT 2 SQLSMALLINT 1 (SQL_C_CHAR) SQLPOINTER 0x16bdb6590 SQLLEN 1024 SQLLEN * 0x16bdb54c8
[000022.498722] iodbctest 1043DFD40 EXIT SQLGetData with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740 SQLUSMALLINT 2 SQLSMALLINT 1 (SQL_C_CHAR) SQLPOINTER 0x16bdb6590 SQLLEN 1024 SQLLEN * 0x16bdb54c8 (-1)
[000022.498876] iodbctest 1043DFD40 ENTER SQLFetchScroll SQLHSTMT 0x107f04740 SQLUSMALLINT 1 (SQL_FETCH_NEXT) SQLLEN 1
[000022.499029] iodbctest 1043DFD40 EXIT SQLFetchScroll with return code 100 (SQL_NO_DATA_FOUND) SQLHSTMT 0x107f04740 SQLUSMALLINT 1 (SQL_FETCH_NEXT) SQLLEN 1
[000022.499079] iodbctest 1043DFD40 ENTER SQLMoreResults SQLHSTMT 0x107f04740
[000022.499359] iodbctest 1043DFD40 EXIT SQLMoreResults with return code 100 (SQL_NO_DATA_FOUND) SQLHSTMT 0x107f04740
[000022.499394] iodbctest 1043DFD40 ENTER SQLCloseCursor SQLHSTMT 0x107f04740
[000022.499464] iodbctest 1043DFD40 EXIT SQLCloseCursor with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740
[000072.150380] iodbctest 1043DFD40 ENTER SQLCloseCursor SQLHSTMT 0x107f04740
[000072.152153] iodbctest 1043DFD40 EXIT SQLCloseCursor with return code 0 (SQL_SUCCESS) SQLHSTMT 0x107f04740
[000072.152212] iodbctest 1043DFD40 ENTER SQLFreeHandle SQLSMALLINT 3 (SQL_HANDLE_STMT) SQLHSTMT 0x107f04740
[000078.930755] iodbctest 1043DFD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 3 (SQL_HANDLE_STMT) SQLHSTMT 0x107f04740
[000078.930905] iodbctest 1043DFD40 ENTER SQLDisconnect SQLHDBC 0x127e04990
[000080.067519] iodbctest 1043DFD40 EXIT SQLDisconnect with return code 0 (SQL_SUCCESS) SQLHDBC 0x127e04990
[000080.067603] iodbctest 1043DFD40 ENTER SQLFreeHandle SQLSMALLINT 2 (SQL_HANDLE_DBC) SQLHDBC 0x127e04990
[000080.067837] iodbctest 1043DFD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 2 (SQL_HANDLE_DBC) SQLHDBC 0x127e04990
[000080.067921] iodbctest 1043DFD40 ENTER SQLFreeHandle SQLSMALLINT 1 (SQL_HANDLE_ENV) SQLHENV 0x137e06b10
[000080.067998] iodbctest 1043DFD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 1 (SQL_HANDLE_ENV) SQLHENV 0x137e06b10
** Trace finished on Mon Aug 02 17:54:09 2021
and this is the trace for begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end using iodbctest and the FreeTDS ODBC driver:
iODBC Trace file Trace started on Mon Aug 02 17:56:36 2021 ** Driver Manager: 03.52.1521.0607
[000000.001547] iodbctest 10312FD40 ENTER SQLAllocHandle SQLSMALLINT 1 (SQL_HANDLE_ENV) SQLHANDLE 0x0 (SQL_NULL_HANDLE) SQLHANDLE * 0x102fe5000
[000000.001627] iodbctest 10312FD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 1 (SQL_HANDLE_ENV) SQLHANDLE 0x0 (SQL_NULL_HANDLE) SQLHANDLE * 0x102fe5000 (0x123f04080)
[000000.001684] iodbctest 10312FD40 ENTER SQLSetEnvAttr SQLHENV 0x123f04080 SQLINTEGER 200 (SQL_ATTR_ODBC_VERSION) SQLPOINTER 0x3 SQLINTEGER * -5 (SQL_IS_UINTEGER)
[000000.001834] iodbctest 10312FD40 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS) SQLHENV 0x123f04080 SQLINTEGER 200 (SQL_ATTR_ODBC_VERSION) SQLPOINTER 0x3 SQLINTEGER * -5 (SQL_IS_UINTEGER)
[000000.001884] iodbctest 10312FD40 ENTER SQLAllocHandle SQLSMALLINT 2 (SQL_HANDLE_DBC) SQLHANDLE 0x123f04080 SQLHANDLE * 0x102fe5008
[000000.001926] iodbctest 10312FD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 2 (SQL_HANDLE_DBC) SQLHANDLE 0x123f04080 SQLHANDLE * 0x102fe5008 (0x123e07230)
[000000.001969] iodbctest 10312FD40 ENTER SQLSetConnectOption SQLHDBC 0x123e07230 SQLUSMALLINT 1051 (unknown connection attribute) SQLLEN 4345133442
[000000.002011] iodbctest 10312FD40 EXIT SQLSetConnectOption with return code 0 (SQL_SUCCESS) SQLHDBC 0x123e07230 SQLUSMALLINT 1051 (unknown connection attribute) SQLLEN 4345133442
[000000.002111] iodbctest 10312FD40 ENTER SQLGetInfo SQLHDBC 0x123e07230 SQLUSMALLINT 171 (SQL_DM_VER) SQLPOINTER 0x16ce5f371 SQLSMALLINT 255 SQLSMALLINT * 0x16ce5f178
[000000.002169] iodbctest 10312FD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS) SQLHDBC 0x123e07230 SQLUSMALLINT 171 (SQL_DM_VER) SQLPOINTER 0x16ce5f371 | 03.52.1521.0607 | SQLSMALLINT 255 SQLSMALLINT * 0x16ce5f178 (15)
[000000.002534] iodbctest 10312FD40 ENTER SQLDriverConnect SQLHDBC 0x123e07230 SQLPOINTER 0x0 SQLCHAR * 0x16ce5f590 | DSN=;UID=;PWD=** | SQLSMALLINT -3 (SQL_NTS) SQLCHAR 0x102fe6000 SQLSMALLINT 4096 SQLSMALLINT * 0x16ce5f17a SQLUSMALLINT 1 (SQL_DRIVER_COMPLETE)
[000002.022623] iodbctest 10312FD40 EXIT SQLDriverConnect with return code 0 (SQL_SUCCESS) SQLHDBC 0x123e07230 SQLPOINTER 0x0 SQLCHAR 0x16ce5f590 SQLSMALLINT -3 (SQL_NTS) SQLCHAR 0x102fe6000 | DSN=;UID=;PWD=** | SQLSMALLINT 4096 SQLSMALLINT 0x16ce5f17a (28) SQLUSMALLINT 1 (SQL_DRIVER_COMPLETE)
[000002.022856] iodbctest 10312FD40 ENTER SQLGetInfo SQLHDBC 0x123e07230 SQLUSMALLINT 7 (SQL_DRIVER_VER) SQLPOINTER 0x16ce5f371 SQLSMALLINT 255 SQLSMALLINT * 0x16ce5f178
[000002.023060] iodbctest 10312FD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS) SQLHDBC 0x123e07230 SQLUSMALLINT 7 (SQL_DRIVER_VER) SQLPOINTER 0x16ce5f371 | 01.03.0000 | SQLSMALLINT 255 SQLSMALLINT * 0x16ce5f178 (10)
[000002.023218] iodbctest 10312FD40 ENTER SQLGetInfo SQLHDBC 0x123e07230 SQLUSMALLINT 6 (SQL_DRIVER_NAME) SQLPOINTER 0x16ce5f371 SQLSMALLINT 255 SQLSMALLINT * 0x16ce5f178
[000002.023358] iodbctest 10312FD40 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS) SQLHDBC 0x123e07230 SQLUSMALLINT 6 (SQL_DRIVER_NAME) SQLPOINTER 0x16ce5f371 | libtdsodbc.so | SQLSMALLINT 255 SQLSMALLINT * 0x16ce5f178 (13)
[000002.023572] iodbctest 10312FD40 ENTER SQLGetFunctions SQLHDBC 0x123e07230 SQLUSMALLINT 999 (SQL_API_ODBC3_ALL_FUNCTIONS)
[000002.023638] iodbctest 10312FD40 EXIT SQLGetFunctions with return code 0 (SQL_SUCCESS) SQLHDBC 0x123e07230 SQLUSMALLINT 999 (SQL_API_ODBC3_ALL_FUNCTIONS) SQLUSMALLINT * 0x16ce5f17c
[000002.023700] iodbctest 10312FD40 ENTER SQLAllocHandle SQLSMALLINT 3 (SQL_HANDLE_STMT) SQLHANDLE 0x123e07230 SQLHANDLE * 0x102fe5010
[000002.023921] iodbctest 10312FD40 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 3 (SQL_HANDLE_STMT) SQLHANDLE 0x123e07230 SQLHANDLE * 0x102fe5010 (0x113e04460)
[000012.807891] iodbctest 10312FD40 ENTER SQLPrepare SQLHSTMT 0x113e04460 SQLCHAR 0x16ce5e990 | begin declare @count integer select @cou | | nt = count() from clx.web_session if @c | | ount = 1 select 1, null else select null | | , 2 end | SQLINTEGER -3 (SQL_NTS)
[000012.850417] iodbctest 10312FD40 EXIT SQLPrepare with return code 0 (SQL_SUCCESS) SQLHSTMT 0x113e04460 SQLCHAR * 0x16ce5e990 SQLINTEGER -3 (SQL_NTS)
[000012.850572] iodbctest 10312FD40 ENTER SQLExecute SQLHSTMT 0x113e04460
[000014.118149] iodbctest 10312FD40 EXIT SQLExecute with return code 0 (SQL_SUCCESS) SQLHSTMT 0x113e04460
[000014.118255] iodbctest 10312FD40 ENTER SQLNumResultCols SQLHSTMT 0x113e04460 SQLSMALLINT * 0x16ce5d4dc
[000014.118355] iodbctest 10312FD40 EXIT SQLNumResultCols with return code 0 (SQL_SUCCESS) SQLHSTMT 0x113e04460 SQLSMALLINT * 0x16ce5d4dc (0)
[000014.118430] iodbctest 10312FD40 ENTER SQLRowCount SQLHSTMT 0x113e04460 SQLLEN * 0x16ce5d4b8
[000014.118572] iodbctest 10312FD40 EXIT SQLRowCount with return code 0 (SQL_SUCCESS) SQLHSTMT 0x113e04460 SQLLEN * 0x16ce5d4b8 (1)
[000014.118721] iodbctest 10312FD40 ENTER SQLCloseCursor SQLHSTMT 0x113e04460
[000014.135749] iodbctest 10312FD40 EXIT SQLCloseCursor with return code 0 (SQL_SUCCESS) SQLHSTMT 0x113e04460
[000016.579191] iodbctest 10312FD40 ENTER SQLCloseCursor SQLHSTMT 0x113e04460
[000016.579468] iodbctest 10312FD40 EXIT SQLCloseCursor with return code 0 (SQL_SUCCESS) SQLHSTMT 0x113e04460
[000016.579555] iodbctest 10312FD40 ENTER SQLFreeHandle SQLSMALLINT 3 (SQL_HANDLE_STMT) SQLHSTMT 0x113e04460
[000016.623479] iodbctest 10312FD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 3 (SQL_HANDLE_STMT) SQLHSTMT 0x113e04460
[000016.623576] iodbctest 10312FD40 ENTER SQLDisconnect SQLHDBC 0x123e07230
[000018.287542] iodbctest 10312FD40 EXIT SQLDisconnect with return code 0 (SQL_SUCCESS) SQLHDBC 0x123e07230
[000018.287642] iodbctest 10312FD40 ENTER SQLFreeHandle SQLSMALLINT 2 (SQL_HANDLE_DBC) SQLHDBC 0x123e07230
[000018.287818] iodbctest 10312FD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 2 (SQL_HANDLE_DBC) SQLHDBC 0x123e07230
[000018.287896] iodbctest 10312FD40 ENTER SQLFreeHandle SQLSMALLINT 1 (SQL_HANDLE_ENV) SQLHENV 0x123f04080
[000018.287970] iodbctest 10312FD40 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 1 (SQL_HANDLE_ENV) SQLHENV 0x123f04080
** Trace finished on Mon Aug 02 17:56:54 2021
and this is the trace for begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end using iodbctest and the Sybase ASA12 ODBC driver:
03/07/2021 18:26:35.113329 Enter SQLDriverConnect: SQLHDBC 0xfbc04460 SQLHWND 0x00000000 SQLCHAR 0x0x7ffeeb03e5f0 [DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_1.txt] SQLSMALLINT -3 SQLCHAR 0x0x104bc3150 SQLSMALLINT 4096 SQLSMALLINT * 0x0x7ffeeb03e2ec SQLUSMALLINT 1
03/07/2021 18:26:35.121869 Exit SQLDriverConnect: return code 0 ( SQL_SUCCESS ): SQLHDBC 0xfbc04460 SQLHWND 0x00000000 SQLCHAR 0x0x7ffeeb03e5f0 [DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_1.txt] SQLSMALLINT -3 SQLCHAR 0x0x104bc3150 [DSN=xxx;UID=xxx;PWD=xxx] SQLSMALLINT 4096 SQLSMALLINT * 0x0x7ffeeb03e2ec [26] SQLUSMALLINT 1
03/07/2021 18:26:35.121893 Enter SQLGetInfo: SQLHDBC 0xfbc04460 SQLUSMALLINT 7 SQLPOINTER 0x0x7ffeeb03e4f0 SQLSMALLINT 255 SQLSMALLINT * 0x0x7ffeeb03e2ee
03/07/2021 18:26:35.121905 Exit SQLGetInfo: return code 0 ( SQL_SUCCESS ): SQLHDBC 0xfbc04460 SQLUSMALLINT 7 SQLPOINTER 0x0x7ffeeb03e4f0 SQLSMALLINT 255 SQLSMALLINT * 0x0x7ffeeb03e2ee [10]
03/07/2021 18:26:35.121923 Enter SQLGetInfo: SQLHDBC 0xfbc04460 SQLUSMALLINT 6 SQLPOINTER 0x0x7ffeeb03e4f0 SQLSMALLINT 255 SQLSMALLINT * 0x0x7ffeeb03e2ee
03/07/2021 18:26:35.121931 Exit SQLGetInfo: return code 0 ( SQL_SUCCESS ): SQLHDBC 0xfbc04460 SQLUSMALLINT 6 SQLPOINTER 0x0x7ffeeb03e4f0 SQLSMALLINT 255 SQLSMALLINT * 0x0x7ffeeb03e2ee [12]
03/07/2021 18:26:35.121967 Enter SQLGetFunctions: SQLHDBC 0xfbc04460 SQLUSMALLINT 999 SQLUSMALLINT * 0x0x7ffeeb03e2f0 [58160]
03/07/2021 18:26:35.121974 Exit SQLGetFunctions: return code -1 ( SQL_ERROR ): SQLHDBC 0xfbc04460 SQLUSMALLINT 999 SQLUSMALLINT * 0x0x7ffeeb03e2f0 [58160]
03/07/2021 18:26:36.398471 Enter SQLPrepare: SQLHSTMT 0xfbe01930 SQLCHAR * 0x0x7ffeeb03d9f0 [begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end] SQLINTEGER -3
03/07/2021 18:26:36.398943 Exit SQLPrepare: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xfbe01930 SQLCHAR * 0x0x7ffeeb03d9f0 [begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end] SQLINTEGER -3
03/07/2021 18:26:36.398977 Enter SQLExecute: SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.399433 Exit SQLExecute: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.399470 Enter SQLNumResultCols: SQLHSTMT 0xfbe01930 SQLSMALLINT * 0x0x7ffeeb03c52e
03/07/2021 18:26:36.399485 Exit SQLNumResultCols: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xfbe01930 SQLSMALLINT * 0x0x7ffeeb03c52e [2]
03/07/2021 18:26:36.399511 Enter SQLDescribeCol: SQLHSTMT 0xfbe01930 SQLUSMALLINT 1 SQLCHAR 0x0x7ffeeb03c530 SQLSMALLINT 50 SQLSMALLINT 0x0x000000 SQLSMALLINT 0x0x7ffeeb03c52a [-21102] SQLULEN 0x0x7ffeeb03c520 SQLSMALLINT 0x0x7ffeeb03c52c SQLSMALLINT 0x0x7ffeeb03c51e
03/07/2021 18:26:36.399539 Exit SQLDescribeCol: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xfbe01930 SQLUSMALLINT 1 SQLCHAR 0x0x7ffeeb03c530 [1] SQLSMALLINT 50 SQLSMALLINT 0x0x000000 SQLSMALLINT 0x0x7ffeeb03c52a [5] SQLULEN 0x0x7ffeeb03c520 [5] SQLSMALLINT 0x0x7ffeeb03c52c [0] SQLSMALLINT 0x0x7ffeeb03c51e [0]
03/07/2021 18:26:36.399560 Enter SQLDescribeCol: SQLHSTMT 0xfbe01930 SQLUSMALLINT 2 SQLCHAR 0x0x7ffeeb03c530 SQLSMALLINT 50 SQLSMALLINT 0x0x000000 SQLSMALLINT 0x0x7ffeeb03c52a [5] SQLULEN 0x0x7ffeeb03c520 SQLSMALLINT 0x0x7ffeeb03c52c SQLSMALLINT 0x0x7ffeeb03c51e
03/07/2021 18:26:36.399576 Exit SQLDescribeCol: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xfbe01930 SQLUSMALLINT 2 SQLCHAR 0x0x7ffeeb03c530 [null] SQLSMALLINT 50 SQLSMALLINT 0x0x000000 SQLSMALLINT 0x0x7ffeeb03c52a [5] SQLULEN 0x0x7ffeeb03c520 [5] SQLSMALLINT 0x0x7ffeeb03c52c [0] SQLSMALLINT 0x0x7ffeeb03c51e [1]
03/07/2021 18:26:36.399635 Enter SQLFetchScroll: SQLHSTMT 0xfbe01930 SQLSMALLINT 1 SQLLEN 1
03/07/2021 18:26:36.399792 Exit SQLFetchScroll: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xfbe01930 SQLSMALLINT 1 SQLLEN 1
03/07/2021 18:26:36.399816 Enter SQLGetData: SQLHSTMT 0xfbe01930 SQLUSMALLINT 1 SQLSMALLINT 1 SQLPOINTER 0x0x7ffeeb03d5f0 SQLLEN 1024 SQLLEN * 0x0x7ffeeb03c500
03/07/2021 18:26:36.400011 Exit SQLGetData: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xfbe01930 SQLUSMALLINT 1 SQLSMALLINT 1 SQLPOINTER 0x0x7ffeeb03d5f0 SQLLEN 1024 SQLLEN * 0x0x7ffeeb03c500 [1]
03/07/2021 18:26:36.400045 Enter SQLGetData: SQLHSTMT 0xfbe01930 SQLUSMALLINT 2 SQLSMALLINT 1 SQLPOINTER 0x0x7ffeeb03d5f0 SQLLEN 1024 SQLLEN * 0x0x7ffeeb03c500
03/07/2021 18:26:36.400173 Exit SQLGetData: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xfbe01930 SQLUSMALLINT 2 SQLSMALLINT 1 SQLPOINTER 0x0x7ffeeb03d5f0 SQLLEN 1024 SQLLEN * 0x0x7ffeeb03c500 [-1]
03/07/2021 18:26:36.400221 Enter SQLFetchScroll: SQLHSTMT 0xfbe01930 SQLSMALLINT 1 SQLLEN 1
03/07/2021 18:26:36.400368 Exit SQLFetchScroll: return code 100 ( SQL_NO_DATA ): SQLHSTMT 0xfbe01930 SQLSMALLINT 1 SQLLEN 1
03/07/2021 18:26:36.400414 Enter SQLMoreResults: SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.400690 Exit SQLMoreResults: return code 100 ( SQL_NO_DATA ): SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.400728 Enter SQLCloseCursor: SQLHSTMT 0xfbe01930
03/07/2021 18:26:36.400746 Exit SQLCloseCursor: return code -1 ( SQL_ERROR ): SQLHSTMT 0xfbe01930
03/07/2021 18:26:38.398357 Enter SQLCloseCursor: SQLHSTMT 0xfbe01930
03/07/2021 18:26:38.398396 Exit SQLCloseCursor: return code -1 ( SQL_ERROR ): SQLHSTMT 0xfbe01930
03/07/2021 18:26:38.398414 Enter SQLFreeHandle: SQLSMALLINT 3 SQLHANDLE 0xfbe01930
03/07/2021 18:26:38.398441 Exit SQLFreeHandle: return code 0 ( SQL_SUCCESS ): SQLSMALLINT 3 SQLHANDLE 0xfbe01930
03/07/2021 18:26:38.398454 Enter SQLDisconnect: SQLHDBC 0xfbc04460
03/07/2021 18:26:38.398882 Exit SQLDisconnect: return code 0 ( SQL_SUCCESS ): SQLHDBC 0xfbc04460
and this is the trace for begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end using iodbctest and the Sybase ASA12 ODBC driver:
03/07/2021 18:27:25.279098 Enter SQLDriverConnect: SQLHDBC 0xb6404460 SQLHWND 0x00000000 SQLCHAR 0x0x7ffee92fc5f0 [DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_count_star.txt] SQLSMALLINT -3 SQLCHAR 0x0x106905150 SQLSMALLINT 4096 SQLSMALLINT * 0x0x7ffee92fc2ec SQLUSMALLINT 1
03/07/2021 18:27:25.286322 Exit SQLDriverConnect: return code 0 ( SQL_SUCCESS ): SQLHDBC 0xb6404460 SQLHWND 0x00000000 SQLCHAR 0x0x7ffee92fc5f0 [DSN=xxx;UID=xxx;PWD=xxx;TraceLevel=HIGH;TraceLog=/xxx/ASA12_ODBC_trace_log_select_count_star.txt] SQLSMALLINT -3 SQLCHAR 0x0x106905150 [DSN=xxx;UID=xxx;PWD=xxx] SQLSMALLINT 4096 SQLSMALLINT * 0x0x7ffee92fc2ec [26] SQLUSMALLINT 1
03/07/2021 18:27:25.286348 Enter SQLGetInfo: SQLHDBC 0xb6404460 SQLUSMALLINT 7 SQLPOINTER 0x0x7ffee92fc4f0 SQLSMALLINT 255 SQLSMALLINT * 0x0x7ffee92fc2ee
03/07/2021 18:27:25.286361 Exit SQLGetInfo: return code 0 ( SQL_SUCCESS ): SQLHDBC 0xb6404460 SQLUSMALLINT 7 SQLPOINTER 0x0x7ffee92fc4f0 SQLSMALLINT 255 SQLSMALLINT * 0x0x7ffee92fc2ee [10]
03/07/2021 18:27:25.286383 Enter SQLGetInfo: SQLHDBC 0xb6404460 SQLUSMALLINT 6 SQLPOINTER 0x0x7ffee92fc4f0 SQLSMALLINT 255 SQLSMALLINT * 0x0x7ffee92fc2ee
03/07/2021 18:27:25.286390 Exit SQLGetInfo: return code 0 ( SQL_SUCCESS ): SQLHDBC 0xb6404460 SQLUSMALLINT 6 SQLPOINTER 0x0x7ffee92fc4f0 SQLSMALLINT 255 SQLSMALLINT * 0x0x7ffee92fc2ee [12]
03/07/2021 18:27:25.286428 Enter SQLGetFunctions: SQLHDBC 0xb6404460 SQLUSMALLINT 999 SQLUSMALLINT * 0x0x7ffee92fc2f0 [49968]
03/07/2021 18:27:25.286436 Exit SQLGetFunctions: return code -1 ( SQL_ERROR ): SQLHDBC 0xb6404460 SQLUSMALLINT 999 SQLUSMALLINT * 0x0x7ffee92fc2f0 [49968]
03/07/2021 18:27:33.348168 Enter SQLPrepare: SQLHSTMT 0xb65015b0 SQLCHAR 0x0x7ffee92fb9f0 [begin declare @count integer select @count = count() from clx.web_session if @count = 1 select 1, null else select null, 2 end] SQLINTEGER -3
03/07/2021 18:27:33.348633 Exit SQLPrepare: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xb65015b0 SQLCHAR 0x0x7ffee92fb9f0 [begin declare @count integer select @count = count() from clx.web_session if @count = 1 select 1, null else select null, 2 end] SQLINTEGER -3
03/07/2021 18:27:33.348667 Enter SQLExecute: SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.349443 Exit SQLExecute: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.349490 Enter SQLNumResultCols: SQLHSTMT 0xb65015b0 SQLSMALLINT * 0x0x7ffee92fa52e
03/07/2021 18:27:33.349505 Exit SQLNumResultCols: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xb65015b0 SQLSMALLINT * 0x0x7ffee92fa52e [2]
03/07/2021 18:27:33.349530 Enter SQLDescribeCol: SQLHSTMT 0xb65015b0 SQLUSMALLINT 1 SQLCHAR 0x0x7ffee92fa530 SQLSMALLINT 50 SQLSMALLINT 0x0x000000 SQLSMALLINT 0x0x7ffee92fa52a [-21102] SQLULEN 0x0x7ffee92fa520 SQLSMALLINT 0x0x7ffee92fa52c SQLSMALLINT 0x0x7ffee92fa51e
03/07/2021 18:27:33.349559 Exit SQLDescribeCol: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xb65015b0 SQLUSMALLINT 1 SQLCHAR 0x0x7ffee92fa530 [null] SQLSMALLINT 50 SQLSMALLINT 0x0x000000 SQLSMALLINT 0x0x7ffee92fa52a [5] SQLULEN 0x0x7ffee92fa520 [5] SQLSMALLINT 0x0x7ffee92fa52c [0] SQLSMALLINT 0x0x7ffee92fa51e [1]
03/07/2021 18:27:33.349580 Enter SQLDescribeCol: SQLHSTMT 0xb65015b0 SQLUSMALLINT 2 SQLCHAR 0x0x7ffee92fa530 SQLSMALLINT 50 SQLSMALLINT 0x0x000000 SQLSMALLINT 0x0x7ffee92fa52a [5] SQLULEN 0x0x7ffee92fa520 SQLSMALLINT 0x0x7ffee92fa52c SQLSMALLINT 0x0x7ffee92fa51e
03/07/2021 18:27:33.349612 Exit SQLDescribeCol: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xb65015b0 SQLUSMALLINT 2 SQLCHAR 0x0x7ffee92fa530 [2] SQLSMALLINT 50 SQLSMALLINT 0x0x000000 SQLSMALLINT 0x0x7ffee92fa52a [5] SQLULEN 0x0x7ffee92fa520 [5] SQLSMALLINT 0x0x7ffee92fa52c [0] SQLSMALLINT 0x0x7ffee92fa51e [0]
03/07/2021 18:27:33.349646 Enter SQLFetchScroll: SQLHSTMT 0xb65015b0 SQLSMALLINT 1 SQLLEN 1
03/07/2021 18:27:33.349791 Exit SQLFetchScroll: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xb65015b0 SQLSMALLINT 1 SQLLEN 1
03/07/2021 18:27:33.349814 Enter SQLGetData: SQLHSTMT 0xb65015b0 SQLUSMALLINT 1 SQLSMALLINT 1 SQLPOINTER 0x0x7ffee92fb5f0 SQLLEN 1024 SQLLEN * 0x0x7ffee92fa500
03/07/2021 18:27:33.349984 Exit SQLGetData: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xb65015b0 SQLUSMALLINT 1 SQLSMALLINT 1 SQLPOINTER 0x0x7ffee92fb5f0 SQLLEN 1024 SQLLEN * 0x0x7ffee92fa500 [-1]
03/07/2021 18:27:33.350037 Enter SQLGetData: SQLHSTMT 0xb65015b0 SQLUSMALLINT 2 SQLSMALLINT 1 SQLPOINTER 0x0x7ffee92fb5f0 SQLLEN 1024 SQLLEN * 0x0x7ffee92fa500
03/07/2021 18:27:33.350189 Exit SQLGetData: return code 0 ( SQL_SUCCESS ): SQLHSTMT 0xb65015b0 SQLUSMALLINT 2 SQLSMALLINT 1 SQLPOINTER 0x0x7ffee92fb5f0 SQLLEN 1024 SQLLEN * 0x0x7ffee92fa500 [1]
03/07/2021 18:27:33.350230 Enter SQLFetchScroll: SQLHSTMT 0xb65015b0 SQLSMALLINT 1 SQLLEN 1
03/07/2021 18:27:33.350374 Exit SQLFetchScroll: return code 100 ( SQL_NO_DATA ): SQLHSTMT 0xb65015b0 SQLSMALLINT 1 SQLLEN 1
03/07/2021 18:27:33.350414 Enter SQLMoreResults: SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.350689 Exit SQLMoreResults: return code 100 ( SQL_NO_DATA ): SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.350741 Enter SQLCloseCursor: SQLHSTMT 0xb65015b0
03/07/2021 18:27:33.350759 Exit SQLCloseCursor: return code -1 ( SQL_ERROR ): SQLHSTMT 0xb65015b0
03/07/2021 18:27:36.388025 Enter SQLCloseCursor: SQLHSTMT 0xb65015b0
03/07/2021 18:27:36.388063 Exit SQLCloseCursor: return code -1 ( SQL_ERROR ): SQLHSTMT 0xb65015b0
03/07/2021 18:27:36.388081 Enter SQLFreeHandle: SQLSMALLINT 3 SQLHANDLE 0xb65015b0
03/07/2021 18:27:36.388107 Exit SQLFreeHandle: return code 0 ( SQL_SUCCESS ): SQLSMALLINT 3 SQLHANDLE 0xb65015b0
03/07/2021 18:27:36.388120 Enter SQLDisconnect: SQLHDBC 0xb6404460
03/07/2021 18:27:36.388509 Exit SQLDisconnect: return code 0 ( SQL_SUCCESS ): SQLHDBC 0xb6404460
I have also attached these trace logs.
Again, thanks for any help you can provide.
FreeTDS_ODBC_trace_log_select_1.txt https://github.com/FreeTDS/freetds/files/6922744/FreeTDS_ODBC_trace_log_select_1.txt FreeTDS_ODBC_trace_log_select_count_star.txt https://github.com/FreeTDS/freetds/files/6922745/FreeTDS_ODBC_trace_log_select_count_star.txt ASA12_ODBC_trace_log_select_1.txt https://github.com/FreeTDS/freetds/files/6922749/ASA12_ODBC_trace_log_select_1.txt ASA12_ODBC_trace_log_select_count_star.txt https://github.com/FreeTDS/freetds/files/6922750/ASA12_ODBC_trace_log_select_count_star.txt
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/FreeTDS/freetds/issues/409#issuecomment-891656789, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHWP2F4XJXIIZCTMPTGPZTT26T2XANCNFSM5BGAKGOA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
Hi Frediano,
my apologies but this is a long reply. It needs to be because it has a detailed discussion of 2 trace logs.
Some consideration
- ODBC 3 (ODBC 2 is obsolete probably since last millennium) allows empty record sets (so number of columns 0 but rows), you can handle them using SQLMoreResults. FreeTDS is returning this but the isql tool seems to behave like it was ODBC 2 assuming there is no more data. So in this case it seems to me that isql is trashing part of the results;
I believe this is not the case. The iodbctest program I used with the FreeTDS ODBC driver is a stock build from the latest release of iODBC. It is definitely using the ODBC 3.0 API.
- Sybase driver is not returning an empty recordset. That's one difference. I know MS driver returns empty recordsets too;
I have to disagree. In the trace log I present below, I believe the Sybase driver is returning a non-empty result set.
I remind you that both versions of the batch statement are supposed to result in exactly 1 result set being returned to the driver and then on to the client program. I believe the problem is that the FreeTDS driver does not return 1 (non-empty) result set but instead it returns a "zero result sets" result for the "select count(*)" version.
I believe the FreeTDS driver is doing this because it is misinterpreting or mishandling the packet data returned from the server. I believe the FreeTDS 'tsql' program does not mishandle the packet data which is why it correctly prints the result set for both batch statements whereas the FreeTDS ODBC Driver is mishandling the returned data for the "select count(*)" version. Please keep reading.
- it's not clear why the 2 queries behave differently and not return both the empty recordset or not in a coherent fashion.
again, I don't believe this is the correct interpretation of what is happening.
Based on what I see in the FreeTDS trace log, I still believe that the FreeTDS ODBC Driver is interpreting the packet data from ASA12 incorrectly and this causes it to return a "no result set" message back to the caller (the client program). In particular, I can see that the reply packets from the two different batch statements I have presented are being processed differently by the FreeTDS driver and this causes the problem I have described. I will attach the FreeTDS trace logs below so you can inspect them and see that the reply packets are not being handled the same in the "select count(*)" version compared to the "select 1" version.
Consider that the format of the query sent by FreeTDS can be slightly different (the sql query is the same but a prepared query format can be different from a plain query).
I can't comment on whether this is occurring or not but I don't believe it is relevant to this problem.
Looking at the past, these empty recordset are not well seen by multiple tools, I think adding an option to remove them would be helpful.
Again, I don't believe this is the case. I believe the root cause is incorrect reply packet handling by the FreeTDS ODBC driver.
OK, here is the trace log for the "select 1" statement:
log.c:187:Starting log file for FreeTDS 1.3
on 2021-07-29 17:20:50 with debug flags 0x4fff.
iconv.c:365:tds_iconv_open(0x13201cee0, UTF-8)
iconv.c:196:local name for ISO-8859-1 is ISO-8859-1
iconv.c:196:local name for UTF-8 is UTF-8
iconv.c:196:local name for UCS-2LE is UCS-2LE
iconv.c:196:local name for UCS-2BE is UCS-2BE
iconv.c:387:setting up conversions for client charset "UTF-8"
iconv.c:389:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:428:tds_iconv_open: done
net.c:391:Connecting with protocol version 5.0
net.c:318:Connecting to 192.168.0.10 port 2638
net.c:340:tds_setup_socket: connect(2) returned "Operation now in progress"
net.c:528:tds_open_socket() succeeded
packet.c:852:Sending packet
0000 02 00 02 00 00 00 00 00-xx xx xx xx xx xx xx xx |........ xxxxxxxx|
0010 xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx |xxxxxxxx xxxxxxxx|
0020 xx xx 00 00 00 00 1a xx-xx xx 00 00 00 00 00 00 |xx.....x xx......|
0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0040 00 00 00 00 00 03 xx xx-xx 00 00 00 00 00 00 00 |......xx x.......|
0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0060 00 00 00 00 03 33 37 32-39 38 00 00 00 00 00 00 |.....372 98......|
0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0080 00 00 00 05 03 01 06 0a-09 01 00 00 00 00 00 00 |........ ........|
0090 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00b0 00 00 00 31 39 32 2e 31-36 38 2e 30 2e 31 30 00 |...192.1 68.0.10.|
00c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00d0 00 0c 00 03 xx xx xx 00-00 00 00 00 00 00 00 00 |....xxx. ........|
00e0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00f0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0100 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0110 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01b0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01d0 00 05 05 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01e0 00 05 00 00 00 00 0d 11-75 73 5f 65 6e 67 6c 69 |........ us_engli|
01f0 73 68 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |sh...... ........|
packet.c:852:Sending packet
0000 02 01 00 6b 00 00 00 00-00 00 00 00 00 00 0a 00 |...k.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0030 00 00 00 00 00 00 00 00-00 00 00 00 01 35 31 32 |........ .....512|
0040 00 00 00 03 00 00 00 00-e2 20 00 01 0e 00 00 60 |........ ‚ .....`|
0050 08 81 81 e8 0f 6d 7f ff-ff ff fe 02 0e 00 00 00 |...Ë.m.ˇ ˇˇ˛.....|
0060 00 00 00 00 00 00 02 68-00 00 00 |.......h ...|
token.c:418:tds_process_login_tokens()
packet.c:410:Received packet
0000 04 01 00 63 00 00 00 00-e3 07 00 03 04 75 74 66 |...c.... „....utf|
0010 38 00 e3 09 00 04 03 35-31 32 03 35 31 32 ad 16 |8.„....5 12.512≠.|
0020 00 05 05 00 00 00 0c 53-51 4c 20 41 6e 79 77 68 |.......S QL Anywh|
0030 65 72 65 0c 00 00 00 e2-20 00 01 0e 00 00 60 08 |ere....‚ .....`.|
0040 01 81 e8 0e 61 01 ff ff-fe e6 02 0e ff ff 00 00 |..Ë.a.ˇˇ ˛Ê..ˇˇ..|
0050 00 01 fe 67 00 e6 68 00-00 0a fd 00 00 01 00 00 |..˛g.Êh. ..˝.....|
0060 00 00 00 - |...|
token.c:422:looking for login token, got e3(ENVCHANGE)
token.c:131:tds_process_default_tokens() marker is e3(ENVCHANGE)
token.c:2305:server indicated charset change to "utf8"
iconv.c:825:setting server single-byte charset to "UTF-8"
token.c:422:looking for login token, got e3(ENVCHANGE)
token.c:131:tds_process_default_tokens() marker is e3(ENVCHANGE)
token.c:2289:changing block size from 512 to 512
token.c:422:looking for login token, got ad(LOGINACK)
token.c:348:server reports TDS version 5.0.0.0
token.c:350:Product name for 0x5000000 is unknown
token.c:384:Product version C000000
token.c:422:looking for login token, got e2(CAPABILITY)
token.c:131:tds_process_default_tokens() marker is e2(CAPABILITY)
token.c:422:looking for login token, got fd(DONE)
token.c:131:tds_process_default_tokens() marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
token.c:445:tds_process_login_tokens() returning TDS_SUCCESS
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 1c 00 00 00 00-21 0f 00 00 00 00 73 65 |........ !.....se|
0010 6c 65 63 74 20 40 40 73-70 69 64 20 |lect @@s pid |
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x13201d030, 0x16d14308c, 0x16d143088, 0x500)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 38 00 00 00 00-61 1d 00 00 00 01 00 06 |...8.... a.......|
0010 40 40 73 70 69 64 00 00-00 06 40 40 73 70 69 64 |@@spid.. ..@@spid|
0020 00 00 00 00 07 00 00 00-38 00 d1 3d 00 00 00 fd |........ 8.—=...˝|
0030 10 00 01 00 01 00 00 00- |........|
token.c:570:processing result tokens. marker is 61(ROWFMT2)
token.c:1790:tds5_process_result2
mem.c:656:tds_free_all_results()
token.c:1814:num_cols=1
token.c:1880:col 0:
token.c:1881: column_name=[@@spid]
token.c:1887: flags=0 utype=7 type=56 server type 56 varint=0
token.c:1891: colsize=4 prec=0 scale=0
token.c:570:processing result tokens. marker is d1(ROW)
token.c:1955:tds_process_row(): reading column 0
data.c:723:tds_get_data: type 56, varint size 0
data.c:767:tds_get_data(): wire column size is 4
util.c:179:Changed query state from READING to PENDING
token.c:555:tds_process_tokens(0x13201d030, 0x16d14308c, 0x16d143088, 0x500)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 1
token.c:2119: rows_affected = 1
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
token.c:555:tds_process_tokens(0x13201d030, 0x16d14308c, 0x16d143088, 0x500)
token.c:558:tds_process_tokens() state is COMPLETED
odbc.c:5954:SQLGetInfoW(0x132809400, 23, 0x132004908, 2, 0x0)
odbc.c:5186:_SQLGetInfo(0x132809400, 23, 0x132004908, 2, 0x0)
odbc.c:5954:SQLGetInfoW(0x132809400, 24, 0x13200490a, 2, 0x0)
odbc.c:5186:_SQLGetInfo(0x132809400, 24, 0x13200490a, 2, 0x0)
odbc.c:5954:SQLGetInfoW(0x132809400, 7, 0x133008200, 1020, 0x16d14b1a8)
odbc.c:5186:_SQLGetInfo(0x132809400, 7, 0x133008200, 1020, 0x16d14b1a8)
odbc.c:5954:SQLGetInfoW(0x132809400, 6, 0x133008200, 1020, 0x16d14b1a8)
odbc.c:5186:_SQLGetInfo(0x132809400, 6, 0x133008200, 1020, 0x16d14b1a8)
odbc.c:5019:SQLGetFunctions: fFunction is 999
odbc.c:1531:SQLAllocHandle(3, 0x132809400, 0x130e04e98)
odbc.c:1706:_SQLAllocStmt(0x132809400, 0x130e04e98)
odbc.c:4521:SQLGetStmtAttr(0x130e05010, 10010, 0x130e054e8, 0, 0x0)
odbc.c:4521:SQLGetStmtAttr(0x130e05010, 10011, 0x130e05528, 0, 0x0)
odbc.c:4521:SQLGetStmtAttr(0x130e05010, 10012, 0x130e05568, 0, 0x0)
odbc.c:4521:SQLGetStmtAttr(0x130e05010, 10013, 0x130e055a8, 0, 0x0)
odbc_export.h:837:SQLPrepareW(0x130e05010, begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end, -3)
odbc.c:4606:Creating prepared statement
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 7d 00 00 00 00-e7 72 00 01 00 0a 69 6f |...}.... Ár....io|
0010 70 38 6b 39 39 30 30 30-63 00 62 65 67 69 6e 20 |p8k99000 c.begin |
0020 64 65 63 6c 61 72 65 20-40 63 6f 75 6e 74 20 69 |declare @count i|
0030 6e 74 65 67 65 72 20 73-65 6c 65 63 74 20 40 63 |nteger s elect @c|
0040 6f 75 6e 74 20 3d 20 31-20 69 66 20 40 63 6f 75 |ount = 1 if @cou|
0050 6e 74 20 3d 20 31 20 73-65 6c 65 63 74 20 31 2c |nt = 1 s elect 1,|
0060 20 6e 75 6c 6c 20 65 6c-73 65 20 73 65 6c 65 63 | null el se selec|
0070 74 20 6e 75 6c 6c 2c 20-32 20 65 6e 64 |t null, 2 end|
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x13201d030, 0x16d14934c, 0x16d149348, 0x104)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 52 00 00 00 00-e7 0d 00 20 00 0a 69 6f |...R.... Á.. ..io|
0010 70 38 6b 39 39 30 30 30-61 2c 00 00 00 02 00 01 |p8k99000 a,......|
0020 31 00 00 00 01 31 20 00-00 00 06 00 00 00 26 02 |1....1 . ......&.|
0030 00 04 6e 75 6c 6c 00 00-00 04 6e 75 6c 6c 20 00 |..null.. ..null .|
0040 00 00 06 00 00 00 26 02-00 fd 00 00 01 00 00 00 |......&. .˝......|
0050 00 00 - |..|
token.c:570:processing result tokens. marker is e7(TDS5_DYNAMIC)
token.c:570:processing result tokens. marker is 61(ROWFMT2)
token.c:1790:tds5_process_result2
mem.c:656:tds_free_all_results()
token.c:1814:num_cols=2
token.c:1880:col 0:
token.c:1881: column_name=[1]
token.c:1887: flags=20 utype=6 type=38 server type 38 varint=1
token.c:1891: colsize=2 prec=0 scale=0
token.c:1880:col 1:
token.c:1881: column_name=[null]
token.c:1887: flags=20 utype=6 type=38 server type 38 varint=1
token.c:1891: colsize=2 prec=0 scale=0
util.c:179:Changed query state from READING to PENDING
odbc.c:3053:odbc_populate_ird(): [0] stmt->tds = 0x13201d030, stmt->tds->current_results = 0x13201ce30, stmt->tds->param_info = 0x0
odbc.c:3061:odbc_populate_ird(): [1] num_cols := 2
odbc.c:3071:odbc_populate_ird(): [3] num_cols := 2
descriptor.c:124:desc_alloc_records(normal): desc->header.sql_desc_count @ 0x130e052b8 := 2
token.c:555:tds_process_tokens(0x13201d030, 0x16d14934c, 0x16d149348, 0x104)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
token.c:555:tds_process_tokens(0x13201d030, 0x16d14934c, 0x16d149348, 0x104)
token.c:558:tds_process_tokens() state is COMPLETED
odbc.c:3587:SQLExecute(0x130e05010)
prepare_query.c:208:parsing 0 parameters
odbc.c:3284:_SQLExecute(0x130e05010)
odbc.c:3301:_SQLExecute() starting with state 0
odbc.c:3405:End prepare, execute
query.c:1636:tds_submit_execute()
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 1a 00 00 00 00-e7 0f 00 02 00 0a 69 6f |........ Á.....io|
0010 70 38 6b 39 39 30 30 30-00 00 |p8k99000 ..|
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x13201d030, 0x16d14930c, 0x16d149308, 0x6914)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 82 00 00 00 00-e7 0d 00 20 00 0a 69 6f |........ Á.. ..io|
0010 70 38 6b 39 39 30 30 30-fd 01 00 01 00 00 00 00 |p8k99000 ˝.......|
0020 00 fd 01 00 01 00 00 00-00 00 fd 01 00 01 00 00 |.˝...... ..˝.....|
0030 00 00 00 61 2b 00 00 00-02 00 01 31 00 00 00 01 |...a+... ...1....|
0040 31 00 00 00 00 06 00 00-00 34 00 04 6e 75 6c 6c |1....... .4..null|
0050 00 00 00 04 6e 75 6c 6c-20 00 00 00 06 00 00 00 |....null .......|
0060 26 02 00 d1 01 00 00 fd-11 00 01 00 01 00 00 00 |&..—...˝ ........|
0070 fd 01 00 01 00 00 00 00-00 fd 00 00 01 00 00 00 |˝....... .˝......|
0080 00 00 - |..|
token.c:570:processing result tokens. marker is e7(TDS5_DYNAMIC)
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3671:odbc_process_tokens: processed TDS_DONE_RESULT
token.c:555:tds_process_tokens(0x13201d030, 0x16d14930c, 0x16d149308, 0x26914)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3671:odbc_process_tokens: processed TDS_DONE_RESULT
token.c:555:tds_process_tokens(0x13201d030, 0x16d14930c, 0x16d149308, 0x26914)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3671:odbc_process_tokens: processed TDS_DONE_RESULT
token.c:555:tds_process_tokens(0x13201d030, 0x16d14930c, 0x16d149308, 0x26914)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is 61(ROWFMT2)
token.c:1790:tds5_process_result2
mem.c:656:tds_free_all_results()
token.c:1814:num_cols=2
token.c:1880:col 0:
token.c:1881: column_name=[1]
token.c:1887: flags=0 utype=6 type=52 server type 52 varint=0
token.c:1891: colsize=2 prec=0 scale=0
token.c:1880:col 1:
token.c:1881: column_name=[null]
token.c:1887: flags=20 utype=6 type=38 server type 38 varint=1
token.c:1891: colsize=2 prec=0 scale=0
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4049, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3698:odbc_process_tokens: returning result_type 4049
odbc.c:3447:_SQLExecute: odbc_process_tokens returned result_type 4049
token.c:555:tds_process_tokens(0x13201d030, 0x16d14930c, 0x16d149308, 0x6914)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is d1(ROW)
token.c:676:tds_process_tokens::SET_RETURN stopping on current token
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4040, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3698:odbc_process_tokens: returning result_type 4040
odbc.c:3447:_SQLExecute: odbc_process_tokens returned result_type 4040
odbc.c:3053:odbc_populate_ird(): [0] stmt->tds = 0x13201d030, stmt->tds->current_results = 0x130e055c0, stmt->tds->param_info = 0x0
odbc.c:3061:odbc_populate_ird(): [1] num_cols := 2
odbc.c:3071:odbc_populate_ird(): [3] num_cols := 2
descriptor.c:124:desc_alloc_records(normal): desc->header.sql_desc_count @ 0x130e052b8 := 2
odbc.c:3610:SQLExecute returns SQL_SUCCESS
odbc.c:4543:SQLNumResultCols(0x130e05010, 0x16d1493fe)
odbc.c:4543:SQLNumResultCols(0x130e05010, 0x16d14944e)
odbc_export.h:529:SQLDescribeColW(0x130e05010, 1, 0x130e05a30, 50, 0x0, 0x16d14950a, 0x16d149500, 0x16d1494f6, 0x16d1494f4)
odbc_export.h:529:SQLDescribeColW(0x130e05010, 2, 0x130e05a30, 50, 0x0, 0x16d14950a, 0x16d149500, 0x16d1494f6, 0x16d1494f4)
odbc.c:4062:SQLFetchScroll(0x130e05010, 1, 1)
odbc.c:3763:_SQLFetch(0x130e05010, 1, 1)
odbc.c:3835:_SQLFetch(): tds 0x13201d030, stmt->row_status 4, NOT_IN_ROW 0
odbc.c:3843:_SQLFetch(): stmt->ird->header.sql_desc_count @ 0x130e052b8 = 2
token.c:555:tds_process_tokens(0x13201d030, 0x16d1492ac, 0x16d1492a8, 0x6508)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is d1(ROW)
token.c:1955:tds_process_row(): reading column 0
data.c:723:tds_get_data: type 52, varint size 0
data.c:767:tds_get_data(): wire column size is 2
token.c:1955:tds_process_row(): reading column 1
data.c:723:tds_get_data: type 38, varint size 1
data.c:767:tds_get_data(): wire column size is -1
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4040, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3698:odbc_process_tokens: returning result_type 4040
odbc.c:4927:SQLGetData(0x130e05010, 1, 1, 0x16d14a5c0, 1024, 0x16d1494f8)
convert_tds2sql.c:293:odbc_tds2sql: src is 52 dest = 1
convert_tds2sql.c:429:odbc_tds2sql: outputting character data destlen = 1024
odbc.c:4927:SQLGetData(0x130e05010, 2, 1, 0x16d14a5c0, 1024, 0x16d1494f8)
odbc.c:4062:SQLFetchScroll(0x130e05010, 1, 1)
odbc.c:3763:_SQLFetch(0x130e05010, 1, 1)
odbc.c:3835:_SQLFetch(): tds 0x13201d030, stmt->row_status 1, NOT_IN_ROW 0
odbc.c:3843:_SQLFetch(): stmt->ird->header.sql_desc_count @ 0x130e052b8 = 2
token.c:555:tds_process_tokens(0x13201d030, 0x16d1492ac, 0x16d1492a8, 0x6508)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 1
token.c:2119: rows_affected = 1
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=10, TDS_DONE_ERROR=0
odbc.c:3668:odbc_process_tokens: row_count=1
odbc.c:3901:SQLFetch: NO_DATA_FOUND
odbc.c:893:SQLMoreResults(0x130e05010)
token.c:555:tds_process_tokens(0x13201d030, 0x16d14936c, 0x16d149368, 0x15914)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3671:odbc_process_tokens: processed TDS_DONE_RESULT
token.c:555:tds_process_tokens(0x13201d030, 0x16d14936c, 0x16d149368, 0x35914)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3671:odbc_process_tokens: processed TDS_DONE_RESULT
token.c:555:tds_process_tokens(0x13201d030, 0x16d14936c, 0x16d149368, 0x35914)
token.c:558:tds_process_tokens() state is COMPLETED
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 1
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:919:SQLMoreResults: result_type=4046, row_count=-1, lastrc=0
mem.c:656:tds_free_all_results()
odbc.c:3053:odbc_populate_ird(): [0] stmt->tds = 0x13201d030, stmt->tds->current_results = 0x0, stmt->tds->param_info = 0x0
odbc.c:930:SQLMoreResults: row_status=0
odbc.c:932:SQLMoreResults: row_count=-1, lastrc=0
odbc.c:4280:SQLCloseCursor(0x130e05010)
odbc.c:4178:_SQLFreeStmt(0x130e05010, 0, 0)
odbc.c:4280:SQLCloseCursor(0x130e05010)
odbc.c:4178:_SQLFreeStmt(0x130e05010, 0, 0)
odbc.c:4078:SQLFreeHandle(3, 0x130e05010)
odbc.c:4178:_SQLFreeStmt(0x130e05010, 1, 0)
query.c:1806:tds_submit_unprepare() iop8k99000
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 1a 00 00 00 00-e7 0f 00 04 00 0a 69 6f |........ Á.....io|
0010 70 38 6b 39 39 30 30 30-00 00 |p8k99000 ..|
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x13201d030, 0x16d14b86c, 0x16d14b868, 0x100)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 21 00 00 00 00-e7 0d 00 20 00 0a 69 6f |...!.... Á.. ..io|
0010 70 38 6b 39 39 30 30 30-fd 00 00 01 00 00 00 00 |p8k99000 ˝.......|
0020 00 - |.|
token.c:570:processing result tokens. marker is e7(TDS5_DYNAMIC)
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
mem.c:225:tds_dynamic_deallocated() : freeing dynamic_id iop8k99000
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
token.c:555:tds_process_tokens(0x13201d030, 0x16d14b86c, 0x16d14b868, 0x100)
token.c:558:tds_process_tokens() state is COMPLETED
odbc.c:2334:SQLDisconnect(0x132809400)
query.c:3757:tds_disconnect()
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 0a 00 00 00 00-71 00 |........ q.|
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x13201d030, 0x16d14b8dc, 0x16d14b8d8, 0x100)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 11 00 00 00 00-fd 00 00 00 00 00 00 00 |........ ˝.......|
0010 00 - |.|
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
token.c:555:tds_process_tokens(0x13201d030, 0x16d14b8dc, 0x16d14b8d8, 0x100)
token.c:558:tds_process_tokens() state is COMPLETED
util.c:179:Changed query state from IDLE to DEAD
mem.c:656:tds_free_all_results()
odbc.c:4078:SQLFreeHandle(2, 0x132809400)
odbc.c:4104:_SQLFreeConnect(0x132809400)
bcp.c:673:_bcp_free_storage(0x132809400)
odbc.c:4078:SQLFreeHandle(1, 0x13201c1d0)
odbc.c:4151:_SQLFreeEnv(0x13201c1d0)
and here is the trace log for the "select count(*)" statement:
log.c:187:Starting log file for FreeTDS 1.3
on 2021-07-29 17:28:06 with debug flags 0x4fff.
iconv.c:365:tds_iconv_open(0x12560b140, UTF-8)
iconv.c:196:local name for ISO-8859-1 is ISO-8859-1
iconv.c:196:local name for UTF-8 is UTF-8
iconv.c:196:local name for UCS-2LE is UCS-2LE
iconv.c:196:local name for UCS-2BE is UCS-2BE
iconv.c:387:setting up conversions for client charset "UTF-8"
iconv.c:389:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:428:tds_iconv_open: done
net.c:391:Connecting with protocol version 5.0
net.c:318:Connecting to 192.168.0.10 port 2638
net.c:340:tds_setup_socket: connect(2) returned "Operation now in progress"
net.c:528:tds_open_socket() succeeded
packet.c:852:Sending packet
0000 02 00 02 00 00 00 00 00-xx xx xx xx xx xx xx xx |........ xxxxxxxx|
0010 xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx |xxxxxxxx xxxxxxxx|
0020 xx xx 00 00 00 00 1a xx-xx xx 00 00 00 00 00 00 |xx.....x xx......|
0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0040 00 00 00 00 00 03 xx xx-xx 00 00 00 00 00 00 00 |......xx x.......|
0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0060 00 00 00 00 03 33 37 33-30 37 00 00 00 00 00 00 |.....373 07......|
0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0080 00 00 00 05 03 01 06 0a-09 01 00 00 00 00 00 00 |........ ........|
0090 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00b0 00 00 00 31 39 32 2e 31-36 38 2e 30 2e 31 30 00 |...192.1 68.0.10.|
00c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00d0 00 0c 00 03 xx xx xx 00-00 00 00 00 00 00 00 00 |....xxx. ........|
00e0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00f0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0100 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0110 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01b0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01d0 00 05 05 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01e0 00 05 00 00 00 00 0d 11-75 73 5f 65 6e 67 6c 69 |........ us_engli|
01f0 73 68 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |sh...... ........|
packet.c:852:Sending packet
0000 02 01 00 6b 00 00 00 00-00 00 00 00 00 00 0a 00 |...k.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0030 00 00 00 00 00 00 00 00-00 00 00 00 01 35 31 32 |........ .....512|
0040 00 00 00 03 00 00 00 00-e2 20 00 01 0e 00 00 60 |........ ‚ .....`|
0050 08 81 81 e8 0f 6d 7f ff-ff ff fe 02 0e 00 00 00 |...Ë.m.ˇ ˇˇ˛.....|
0060 00 00 00 00 00 00 02 68-00 00 00 |.......h ...|
token.c:418:tds_process_login_tokens()
packet.c:410:Received packet
0000 04 01 00 63 00 00 00 00-e3 07 00 03 04 75 74 66 |...c.... „....utf|
0010 38 00 e3 09 00 04 03 35-31 32 03 35 31 32 ad 16 |8.„....5 12.512≠.|
0020 00 05 05 00 00 00 0c 53-51 4c 20 41 6e 79 77 68 |.......S QL Anywh|
0030 65 72 65 0c 00 00 00 e2-20 00 01 0e 00 00 60 08 |ere....‚ .....`.|
0040 01 81 e8 0e 61 01 ff ff-fe e6 02 0e ff ff 00 00 |..Ë.a.ˇˇ ˛Ê..ˇˇ..|
0050 00 01 fe 67 00 e6 68 00-00 0a fd 00 00 01 00 00 |..˛g.Êh. ..˝.....|
0060 00 00 00 - |...|
token.c:422:looking for login token, got e3(ENVCHANGE)
token.c:131:tds_process_default_tokens() marker is e3(ENVCHANGE)
token.c:2305:server indicated charset change to "utf8"
iconv.c:825:setting server single-byte charset to "UTF-8"
token.c:422:looking for login token, got e3(ENVCHANGE)
token.c:131:tds_process_default_tokens() marker is e3(ENVCHANGE)
token.c:2289:changing block size from 512 to 512
token.c:422:looking for login token, got ad(LOGINACK)
token.c:348:server reports TDS version 5.0.0.0
token.c:350:Product name for 0x5000000 is unknown
token.c:384:Product version C000000
token.c:422:looking for login token, got e2(CAPABILITY)
token.c:131:tds_process_default_tokens() marker is e2(CAPABILITY)
token.c:422:looking for login token, got fd(DONE)
token.c:131:tds_process_default_tokens() marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
token.c:445:tds_process_login_tokens() returning TDS_SUCCESS
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 1c 00 00 00 00-21 0f 00 00 00 00 73 65 |........ !.....se|
0010 6c 65 63 74 20 40 40 73-70 69 64 20 |lect @@s pid |
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd4f08c, 0x16fd4f088, 0x500)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 38 00 00 00 00-61 1d 00 00 00 01 00 06 |...8.... a.......|
0010 40 40 73 70 69 64 00 00-00 06 40 40 73 70 69 64 |@@spid.. ..@@spid|
0020 00 00 00 00 07 00 00 00-38 00 d1 3e 00 00 00 fd |........ 8.—>...˝|
0030 10 00 01 00 01 00 00 00- |........|
token.c:570:processing result tokens. marker is 61(ROWFMT2)
token.c:1790:tds5_process_result2
mem.c:656:tds_free_all_results()
token.c:1814:num_cols=1
token.c:1880:col 0:
token.c:1881: column_name=[@@spid]
token.c:1887: flags=0 utype=7 type=56 server type 56 varint=0
token.c:1891: colsize=4 prec=0 scale=0
token.c:570:processing result tokens. marker is d1(ROW)
token.c:1955:tds_process_row(): reading column 0
data.c:723:tds_get_data: type 56, varint size 0
data.c:767:tds_get_data(): wire column size is 4
util.c:179:Changed query state from READING to PENDING
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd4f08c, 0x16fd4f088, 0x500)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 1
token.c:2119: rows_affected = 1
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd4f08c, 0x16fd4f088, 0x500)
token.c:558:tds_process_tokens() state is COMPLETED
odbc.c:5954:SQLGetInfoW(0x12580b400, 23, 0x125606f88, 2, 0x0)
odbc.c:5186:_SQLGetInfo(0x12580b400, 23, 0x125606f88, 2, 0x0)
odbc.c:5954:SQLGetInfoW(0x12580b400, 24, 0x125606f8a, 2, 0x0)
odbc.c:5186:_SQLGetInfo(0x12580b400, 24, 0x125606f8a, 2, 0x0)
odbc.c:5954:SQLGetInfoW(0x12580b400, 7, 0x127008200, 1020, 0x16fd571a8)
odbc.c:5186:_SQLGetInfo(0x12580b400, 7, 0x127008200, 1020, 0x16fd571a8)
odbc.c:5954:SQLGetInfoW(0x12580b400, 6, 0x127008200, 1020, 0x16fd571a8)
odbc.c:5186:_SQLGetInfo(0x12580b400, 6, 0x127008200, 1020, 0x16fd571a8)
odbc.c:5019:SQLGetFunctions: fFunction is 999
odbc.c:1531:SQLAllocHandle(3, 0x12580b400, 0x126804468)
odbc.c:1706:_SQLAllocStmt(0x12580b400, 0x126804468)
odbc.c:4521:SQLGetStmtAttr(0x1268045e0, 10010, 0x126804ab8, 0, 0x0)
odbc.c:4521:SQLGetStmtAttr(0x1268045e0, 10011, 0x126804af8, 0, 0x0)
odbc.c:4521:SQLGetStmtAttr(0x1268045e0, 10012, 0x126804b38, 0, 0x0)
odbc.c:4521:SQLGetStmtAttr(0x1268045e0, 10013, 0x126804b78, 0, 0x0)
odbc_export.h:837:SQLPrepareW(0x1268045e0, begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end, -3)
odbc.c:4606:Creating prepared statement
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 99 00 00 00 00-e7 8e 00 01 00 0a 63 62 |........ Á.....cb|
0010 6b 6b 70 34 39 30 30 30-7f 00 62 65 67 69 6e 20 |kkp49000 ..begin |
0020 64 65 63 6c 61 72 65 20-40 63 6f 75 6e 74 20 69 |declare @count i|
0030 6e 74 65 67 65 72 20 73-65 6c 65 63 74 20 40 63 |nteger s elect @c|
0040 6f 75 6e 74 20 3d 20 63-6f 75 6e 74 28 2a 29 20 |ount = c ount(*) |
0050 66 72 6f 6d 20 63 6c 78-2e 77 65 62 5f 73 65 73 |from clx .web_ses|
0060 73 69 6f 6e 20 69 66 20-40 63 6f 75 6e 74 20 3d |sion if @count =|
0070 20 31 20 73 65 6c 65 63-74 20 31 2c 20 6e 75 6c | 1 selec t 1, nul|
0080 6c 20 65 6c 73 65 20 73-65 6c 65 63 74 20 6e 75 |l else s elect nu|
0090 6c 6c 2c 20 32 20 65 6e-64 |ll, 2 en d|
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd5534c, 0x16fd55348, 0x104)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 52 00 00 00 00-e7 0d 00 20 00 0a 63 62 |...R.... Á.. ..cb|
0010 6b 6b 70 34 39 30 30 30-61 2c 00 00 00 02 00 01 |kkp49000 a,......|
0020 31 00 00 00 01 31 20 00-00 00 06 00 00 00 26 02 |1....1 . ......&.|
0030 00 04 6e 75 6c 6c 00 00-00 04 6e 75 6c 6c 20 00 |..null.. ..null .|
0040 00 00 06 00 00 00 26 02-00 fd 00 00 01 00 00 00 |......&. .˝......|
0050 00 00 - |..|
token.c:570:processing result tokens. marker is e7(TDS5_DYNAMIC)
token.c:570:processing result tokens. marker is 61(ROWFMT2)
token.c:1790:tds5_process_result2
mem.c:656:tds_free_all_results()
token.c:1814:num_cols=2
token.c:1880:col 0:
token.c:1881: column_name=[1]
token.c:1887: flags=20 utype=6 type=38 server type 38 varint=1
token.c:1891: colsize=2 prec=0 scale=0
token.c:1880:col 1:
token.c:1881: column_name=[null]
token.c:1887: flags=20 utype=6 type=38 server type 38 varint=1
token.c:1891: colsize=2 prec=0 scale=0
util.c:179:Changed query state from READING to PENDING
odbc.c:3053:odbc_populate_ird(): [0] stmt->tds = 0x12560b5b0, stmt->tds->current_results = 0x1269043b0, stmt->tds->param_info = 0x0
odbc.c:3061:odbc_populate_ird(): [1] num_cols := 2
odbc.c:3071:odbc_populate_ird(): [3] num_cols := 2
descriptor.c:124:desc_alloc_records(normal): desc->header.sql_desc_count @ 0x126804888 := 2
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd5534c, 0x16fd55348, 0x104)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd5534c, 0x16fd55348, 0x104)
token.c:558:tds_process_tokens() state is COMPLETED
odbc.c:3587:SQLExecute(0x1268045e0)
prepare_query.c:208:parsing 0 parameters
odbc.c:3284:_SQLExecute(0x1268045e0)
odbc.c:3301:_SQLExecute() starting with state 0
odbc.c:3405:End prepare, execute
query.c:1636:tds_submit_execute()
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 1a 00 00 00 00-e7 0f 00 02 00 0a 63 62 |........ Á.....cb|
0010 6b 6b 70 34 39 30 30 30-00 00 |kkp49000 ..|
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd5530c, 0x16fd55308, 0x6914)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 79 00 00 00 00-e7 0d 00 20 00 0a 63 62 |...y.... Á.. ..cb|
0010 6b 6b 70 34 39 30 30 30-fd 01 00 01 00 00 00 00 |kkp49000 ˝.......|
0020 00 fd 11 00 01 00 01 00-00 00 61 2b 00 00 00 02 |.˝...... ..a+....|
0030 00 04 6e 75 6c 6c 00 00-00 04 6e 75 6c 6c 20 00 |..null.. ..null .|
0040 00 00 06 00 00 00 26 02-00 01 32 00 00 00 01 32 |......&. ..2....2|
0050 00 00 00 00 06 00 00 00-34 00 d1 00 02 00 fd 11 |........ 4.—...˝.|
0060 00 01 00 01 00 00 00 fd-01 00 01 00 00 00 00 00 |.......˝ ........|
0070 fd 00 00 01 00 00 00 00-00 |˝....... .|
token.c:570:processing result tokens. marker is e7(TDS5_DYNAMIC)
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3671:odbc_process_tokens: processed TDS_DONE_RESULT
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd5530c, 0x16fd55308, 0x26914)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 1
token.c:2119: rows_affected = 1
util.c:179:Changed query state from READING to PENDING
odbc.c:3625:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3626: result_type=4052, TDS_DONE_COUNT=10, TDS_DONE_ERROR=0
odbc.c:3668:odbc_process_tokens: row_count=1
odbc.c:3447:_SQLExecute: odbc_process_tokens returned result_type 4052
odbc.c:3053:odbc_populate_ird(): [0] stmt->tds = 0x12560b5b0, stmt->tds->current_results = 0x0, stmt->tds->param_info = 0x0
odbc.c:3610:SQLExecute returns SQL_SUCCESS
odbc.c:4543:SQLNumResultCols(0x1268045e0, 0x16fd553fe)
odbc.c:4543:SQLNumResultCols(0x1268045e0, 0x16fd5544e)
odbc.c:4624:_SQLRowCount(0x1268045e0, 0x16fd554e8), 1 rows
odbc.c:4635:SQLRowCount returns 0, row count 1
odbc.c:4280:SQLCloseCursor(0x1268045e0)
odbc.c:4178:_SQLFreeStmt(0x1268045e0, 0, 0)
query.c:2031:tds_send_cancel: not in_cancel and not idle
query.c:2078:tds_send_cancel: sending cancel packet
packet.c:852:Sending packet
0000 06 01 00 08 00 00 00 00- |........|
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd553ac, 0x0, 0x0)
util.c:179:Changed query state from PENDING to READING
token.c:570:processing result tokens. marker is 61(ROWFMT2)
token.c:1790:tds5_process_result2
mem.c:656:tds_free_all_results()
token.c:1814:num_cols=2
token.c:1880:col 0:
token.c:1881: column_name=[null]
token.c:1887: flags=20 utype=6 type=38 server type 38 varint=1
token.c:1891: colsize=2 prec=0 scale=0
token.c:1880:col 1:
token.c:1881: column_name=[2]
token.c:1887: flags=0 utype=6 type=52 server type 52 varint=0
token.c:1891: colsize=2 prec=0 scale=0
token.c:570:processing result tokens. marker is d1(ROW)
token.c:1955:tds_process_row(): reading column 0
data.c:723:tds_get_data: type 38, varint size 1
data.c:767:tds_get_data(): wire column size is -1
token.c:1955:tds_process_row(): reading column 1
data.c:723:tds_get_data: type 52, varint size 0
data.c:767:tds_get_data(): wire column size is 2
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 1
token.c:2119: rows_affected = 1
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
packet.c:410:Received packet
0000 04 01 00 11 00 00 00 00-fd 20 00 01 00 00 00 00 |........ ˝ ......|
0010 00 - |.|
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 1
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
odbc.c:4280:SQLCloseCursor(0x1268045e0)
odbc.c:4178:_SQLFreeStmt(0x1268045e0, 0, 0)
odbc.c:4078:SQLFreeHandle(3, 0x1268045e0)
odbc.c:4178:_SQLFreeStmt(0x1268045e0, 1, 0)
query.c:1806:tds_submit_unprepare() cbkkp49000
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 1a 00 00 00 00-e7 0f 00 04 00 0a 63 62 |........ Á.....cb|
0010 6b 6b 70 34 39 30 30 30-00 00 |kkp49000 ..|
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd5786c, 0x16fd57868, 0x100)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 21 00 00 00 00-e7 0d 00 20 00 0a 63 62 |...!.... Á.. ..cb|
0010 6b 6b 70 34 39 30 30 30-fd 00 00 01 00 00 00 00 |kkp49000 ˝.......|
0020 00 - |.|
token.c:570:processing result tokens. marker is e7(TDS5_DYNAMIC)
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
mem.c:225:tds_dynamic_deallocated() : freeing dynamic_id cbkkp49000
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd5786c, 0x16fd57868, 0x100)
token.c:558:tds_process_tokens() state is COMPLETED
odbc.c:2334:SQLDisconnect(0x12580b400)
query.c:3757:tds_disconnect()
mem.c:656:tds_free_all_results()
util.c:179:Changed query state from IDLE to WRITING
packet.c:852:Sending packet
0000 0f 01 00 0a 00 00 00 00-71 00 |........ q.|
util.c:179:Changed query state from WRITING to PENDING
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd578dc, 0x16fd578d8, 0x100)
util.c:179:Changed query state from PENDING to READING
packet.c:410:Received packet
0000 04 01 00 11 00 00 00 00-fd 00 00 00 00 00 00 00 |........ ˝.......|
0010 00 - |.|
token.c:570:processing result tokens. marker is fd(DONE)
token.c:2100:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
token.c:2122:tds_process_end() state set to TDS_IDLE
util.c:179:Changed query state from READING to IDLE
util.c:83:logic error: cannot change query state from IDLE to PENDING
util.c:179:Changed query state from IDLE to IDLE
token.c:555:tds_process_tokens(0x12560b5b0, 0x16fd578dc, 0x16fd578d8, 0x100)
token.c:558:tds_process_tokens() state is COMPLETED
util.c:179:Changed query state from IDLE to DEAD
mem.c:656:tds_free_all_results()
odbc.c:4078:SQLFreeHandle(2, 0x12580b400)
odbc.c:4104:_SQLFreeConnect(0x12580b400)
bcp.c:673:_bcp_free_storage(0x12580b400)
odbc.c:4078:SQLFreeHandle(1, 0x12560a040)
odbc.c:4151:_SQLFreeEnv(0x12560a040)
Now up to the SQLExecute call on line 204 in the "select 1" and line 206 in the "select count(*)" logs, the processing by the driver appears to be correct.
The 2 logs diverge in the handling of the reply packet when SQLExecute is called. The "select 1" log shows a result set being detected in lines 244-248:
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2119: rows_affected = 0
which results in the 2 columns of the result set being processed on lines 270-278:
token.c:1814:num_cols=2
token.c:1880:col 0:
token.c:1881: column_name=[1]
token.c:1887: flags=0 utype=6 type=52 server type 52 varint=0
token.c:1891: colsize=2 prec=0 scale=0
token.c:1880:col 1:
token.c:1881: column_name=[null]
token.c:1887: flags=20 utype=6 type=38 server type 38 varint=1
token.c:1891: colsize=2 prec=0 scale=0
In contrast, the "select count(*)" log shows no result set being detected in lines 245-249:
token.c:2100:tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 1
token.c:2119: rows_affected = 1
which causes no further processing and the SQLExecute call exits on line 256:
odbc.c:3610:SQLExecute returns SQL_SUCCESS
this in turn causes the caller to close the cursor (and free the statement) and the driver in turn sends a cancel packet, as seen in lines 261-264:
odbc.c:4280:SQLCloseCursor(0x1268045e0)
odbc.c:4178:_SQLFreeStmt(0x1268045e0, 0, 0)
query.c:2031:tds_send_cancel: not in_cancel and not idle
query.c:2078:tds_send_cancel: sending cancel packet
after this is done, the driver then performs more processing of the column descriptions on lines 273-281:
token.c:1814:num_cols=2
token.c:1880:col 0:
token.c:1881: column_name=[null]
token.c:1887: flags=20 utype=6 type=38 server type 38 varint=1
token.c:1891: colsize=2 prec=0 scale=0
token.c:1880:col 1:
token.c:1881: column_name=[2]
token.c:1887: flags=0 utype=6 type=52 server type 52 varint=0
token.c:1891: colsize=2 prec=0 scale=0
and it then receives the result set data for row 0 on lines 307-309:
packet.c:410:Received packet
0000 04 01 00 11 00 00 00 00-fd 20 00 01 00 00 00 00 |........ ˝ ......|
0010 00 - |.|
but it cannot handle it because it's in the wrong state as seen on line 319:
util.c:83:logic error: cannot change query state from IDLE to PENDING
and this is then followed by closing the connection.
It is because of this sequence in the log files that I believe that this is a problem with the handling of the reply packet by the FreeTDS ODBC driver and this is why I don't believe it has something to do with ODBC 2.x vs ODBC 3.x APIs.
I don't know enough about the TDS protocol to know why or where the driver is going wrong, but I can deduce from the logs that it is indeed the driver that is mishandling the reply data.
Again, thank you for your patience with this and I again thank you for any help you can provide to have this issue fixed.
Here are the same log files as attachments:
Hi there,
I'm trying to replace the use of the Sybase client ODBC driver with FreeTDS's ODBC driver but I've run into a compatibility issue which prevents me from migrating to the FreeTDS driver.
In summary, the FreeTDS ODBC driver does not return a result set via SQLFetch when a batch statement is executed. The same statement works fine (ie, returns a result set) when it is executed using the Sybase ODBC driver and/or FreeTDS's tsql program.
My actual batch statement is much longer than the code shown below. I've stripped it down to the bare essentials to demonstrate the problem.
All results shown below are using the same Sybase ASA 8 database running the same server engine instance.
I'll show the output from 3 programs to try to convince you that the problem is in the FreeTDS ODBC driver.
First, when tsql is used, the correct result set is reported.
Second, when iODBC's iodbctest program is used (which in turn uses the FreeTDS ODBC driver), the result set is not reported correctly.
Third, when Sybase's dbisqlc program is used (which in turn uses the Sybase ODBC driver), the correct result set is reported.
For each program used, I have shown 2 versions of the batch statement: one that reports a result set and one that does not when the FreeTDS ODBC driver is used but does with the other programs.
These 2 versions actually produce different TDS protocol level packets from the server. I believe the FreeTDS ODBC driver mishandles the returned data and this causes the result set to not be returned.
I have saved the logs from the FreeTDS driver which shows the different packets returned but I don't know if it is necessary to post them. I'm happy to post them if need be.
Thanks in advance for any help you can provide.
% TDSVER=5.0 /usr/local/freetds-1.3/bin/tsql -H 192.168.0.10 -p 2638 -U xxx -P xxx locale is "en_AU.UTF-8" locale charset is "UTF-8" using default charset "UTF-8" 1>
begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end
2>go
1 null 1 NULL (1 row affected)1>
begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end
2>go
null 2 NULL 2 (1 row affected)1>
quit
% /usr/local/iODBC/bin/iodbctest "DSN=xxx;UID=xxx;PWD=xxx" iODBC Demonstration program This program shows an interactive SQL processor Driver Manager: 03.52.1521.0607 Driver: 01.03.0000 (libtdsodbc.so)
SQL>
begin declare @count integer select @count = 1 if @count = 1 select 1, null else select null, 2 end
result set 1 returned 1 rows.
SQL>
begin declare @count integer select @count = count(*) from clx.web_session if @count = 1 select 1, null else select null, 2 end
Statement executed. 1 rows affected.there should be a result set shown here but the FreeTDS ODBC driver fails to return it
SQL>
^C