Re: dbcanquery() with pdo_dblib

Adam Baratz <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CADxrgCP+0hLLrdozqHLuQa2hx-+gzm_L42aAW2WYq-FyKq1p6w@mail.gmail.com>
Thanks, see attached. I [redacted] the auth transmission.

On Fri, Jun 17, 2016 at 4:16 AM, Thompson, William <[email protected]
> wrote:

> Hi Adam,
>
> I don't think you've misunderstood what dbcanquery is supposed to do. The
> Sybase documentation says that it is equivalent to calling dbnextrow until
> it reurns NO_MORE_ROWS, which is pretty much what you've replicated.
> So it looks like our implementation of dbcanquery() isn't exactly the same
> as doing that...
>
> It's difficult to see what might be happening without a debug log
> Can you run your test of dbcanquery() with TDSDUMP logging set? And then
> post with the log attached?
> See http://www.freetds.org/userguide/logging.htm
>
> Cheers,
>
> Bill
>
>
> -----Original Message-----
> From: FreeTDS [mailto:[email protected]] On Behalf Of
> Adam Baratz
> Sent: 16 June 2016 17:19
> To: [email protected]
> Subject: [freetds] dbcanquery() with pdo_dblib
>
> Hi,
>
> I'm looking at fixing this bug with the PHP pdo_dblib extension:
> https://bugs.php.net/bug.php?id=67130
>
> I have it built to use FreeTDS to communicate with MSSQL.
>
> My understanding from the docs is that dbcanquery() does what's needed
> here. Basically, it should be called before using dbresults() to get the
> next rowset[1]. However, that doesn't seem to resolve the issue. The call
> succeeds, but the call to dbresults() will then fail. What I've found works
> is fetching the rows manually:
>
> RETCODE ret = SUCCESS;
>
> while (ret == SUCCESS) {
> ret = dbnextrow(H->link);
> }
>
> I don't want to do anything with these rows, so I'd rather not do this. Am
> I missing something basic about how dbcanquery() is supposed to be used?
>
> Thanks,
> Adam
>
> ---
> [1]
>
> https://github.com/php/php-src/blob/aed42496534fe54c5c0ce64fe0ca5c9d801d6161/ext/pdo_dblib/dblib_stmt.c#L144
> _______________________________________________
> FreeTDS mailing list
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
> ----------------------------------------------------------------------
> This message, and any attachments, is for the intended recipient(s) only,
> may contain information that is privileged, confidential and/or proprietary
> and subject to important terms and conditions available at
> http://www.bankofamerica.com/emaildisclaimer.   If you are not the
> intended recipient, please delete this message.
> _______________________________________________
> FreeTDS mailing list
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
>

_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
freetds.log (application/octet-stream, 10.5 KB)
log.c:196:Starting log file for FreeTDS 0.91
	on 2016-06-17 14:52:44 with debug flags 0x4fff.
config.c:714:Setting 'dump_file' to '/vagrant/freetds.log' from $TDSDUMP.
iconv.c:330:tds_iconv_open(0x2bcb070, UTF-8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
iconv.c:349:setting up conversions for client charset "UTF-8"
iconv.c:351:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:391:preparing iconv for "ISO-8859-1" <-> "ISO-8859-1" conversion
iconv.c:394:tds_iconv_open: done
net.c:207:Connecting to 10.24.30.12 port 1433 (TDS version 4.2)
net.c:272:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:312:tds_open_socket() succeeded
util.c:156:Changed query state from DEAD to IDLE
net.c:743:Sending packet
[redacted]

net.c:743:Sending packet
0000 02 01 00 4c 00 00 00 00-00 00 00 00 00 00 0a 00 |...L.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 75 74 66 |........ .....utf|
0020 38 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |8....... ........|
0030 00 00 00 00 00 00 00 00-00 00 00 04 01 35 31 32 |........ .....512|
0040 00 00 00 03 00 00 00 00-00 00 00 00             |........ ....|

token.c:328:tds_process_login_tokens()
net.c:557:Received header
0000 04 01 00 9c 04 92 01 00-                        |........|

net.c:611:Received packet
[redacted]

token.c:337:looking for login token, got  e3(ENVCHANGE)
token.c:122:tds_process_default_tokens() marker is e3(ENVCHANGE)
dblib.c:327:db_env_chg(0x2bcb070, 1, master, master)
token.c:337:looking for login token, got  ab(INFO)
token.c:122:tds_process_default_tokens() marker is ab(INFO)
token.c:2588:tds_process_msg() reading message 5701 from server
token.c:2661:tds_process_msg() calling client msg handler
dbutil.c:85:_dblib_handle_info_message(0x2b808e0, 0x2bcb070, 0x7ffd20b12e50)
dbutil.c:86:msgno 5701: "Changed database context to 'master'."
token.c:2674:tds_process_msg() returning TDS_SUCCEED
token.c:337:looking for login token, got  e3(ENVCHANGE)
token.c:122:tds_process_default_tokens() marker is e3(ENVCHANGE)
token.c:2493:server indicated charset change to "iso_1"
iconv.c:988:setting server single-byte charset to "ISO-8859-1"
dblib.c:327:db_env_chg(0x2bcb070, 3, , iso_1)
token.c:337:looking for login token, got  ad(LOGINACK)
token.c:373:server reports TDS version 4.2.0.0
token.c:375:Product name for 0x4020000 is unknown
token.c:337:looking for login token, got  e3(ENVCHANGE)
token.c:122:tds_process_default_tokens() marker is e3(ENVCHANGE)
token.c:2477:changing block size from 512 to 512
dblib.c:327:db_env_chg(0x2bcb070, 4, 512, 512)
token.c:337:looking for login token, got  fd(DONE)
token.c:122:tds_process_default_tokens() marker is fd(DONE)
token.c:2339:tds_process_end: more_results = 0
		was_cancelled = 0
		error = 0
		done_count_valid = 0
token.c:2355:tds_process_end() state set to TDS_IDLE
token.c:2370:                rows_affected = 0
token.c:438:tds_process_login_tokens() returning TDS_SUCCEED
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
util.c:156:Changed query state from QUERYING to PENDING
net.c:743:Sending packet
[redacted]

token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b12f48, 0x7ffd20b12f4c, 0x100)
util.c:156:Changed query state from PENDING to READING
net.c:557:Received header
0000 04 01 00 74 04 92 01 00-                        |...t....|

net.c:611:Received packet
[redacted]

token.c:555:processing result tokens.  marker is  fd(DONE)
token.c:2339:tds_process_end: more_results = 1
		was_cancelled = 0
		error = 0
		done_count_valid = 0
token.c:2370:                rows_affected = 0
util.c:156:Changed query state from READING to PENDING
token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b12f48, 0x7ffd20b12f4c, 0x100)
util.c:156:Changed query state from PENDING to READING
token.c:555:processing result tokens.  marker is  e3(ENVCHANGE)
token.c:122:tds_process_default_tokens() marker is e3(ENVCHANGE)
dblib.c:327:db_env_chg(0x2bcb070, 1, master, csn_product)
token.c:555:processing result tokens.  marker is  ab(INFO)
token.c:122:tds_process_default_tokens() marker is ab(INFO)
token.c:2588:tds_process_msg() reading message 5701 from server
token.c:2661:tds_process_msg() calling client msg handler
dbutil.c:85:_dblib_handle_info_message(0x2b808e0, 0x2bcb070, 0x7ffd20b12dd0)
dbutil.c:86:msgno 5701: "Changed database context to 'csn_product'."
token.c:2674:tds_process_msg() returning TDS_SUCCEED
token.c:555:processing result tokens.  marker is  fd(DONE)
token.c:2339:tds_process_end: more_results = 0
		was_cancelled = 0
		error = 0
		done_count_valid = 0
token.c:2355:tds_process_end() state set to TDS_IDLE
util.c:156:Changed query state from READING to IDLE
token.c:2370:                rows_affected = 0
util.c:104:logic error: cannot change query state from IDLE to PENDING
token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b12f48, 0x7ffd20b12f4c, 0x100)
token.c:543:tds_process_tokens() state is COMPLETED
dblib.c:239:dblib_add_connection(0x7f83f278f8c0, 0x2bcb070)
dblib.c:4317:dbsetopt(0x2bca5b0, 17, 2147483647, -1)
dblib.c:4432:UNIMPLEMENTED dbsetopt(option = 17)
dblib.c:4317:dbsetopt(0x2bca5b0, 35, 1, -1)
dblib.c:5762:dbsetuserdata(0x2bca5b0, 0x7f83f44033c8)
dblib.c:3196:dbcancel(0x2bca5b0)
query.c:2155:tds_send_cancel: not in_cancel and idle
dblib.c:1312:dbcmd(0x2bca5b0, SELECT 1; SELECT 2)
dblib.c:1319:dbcmd() bufsz = 0
dblib.c:1369:dbsqlexec(0x2bca5b0)
dblib.c:6862:dbsqlsend(0x2bca5b0)
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
util.c:156:Changed query state from QUERYING to PENDING
net.c:743:Sending packet
0000 01 01 00 21 00 00 00 00-73 65 74 20 71 75 6f 74 |...!.... set quot|
0010 65 64 5f 69 64 65 6e 74-69 66 69 65 72 20 6f 6e |ed_ident ifier on|
0020 0a                     -                        |.|

token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b136cc, (nil), 0x6914)
util.c:156:Changed query state from PENDING to READING
net.c:557:Received header
0000 04 01 00 11 04 92 01 00-                        |........|

net.c:611:Received packet
0000 04 01 00 11 04 92 01 00-fd 00 00 fd 00 00 00 00 |........ ........|
0010 00                     -                        |.|

token.c:555:processing result tokens.  marker is  fd(DONE)
token.c:2339:tds_process_end: more_results = 0
		was_cancelled = 0
		error = 0
		done_count_valid = 0
token.c:2355:tds_process_end() state set to TDS_IDLE
util.c:156:Changed query state from READING to IDLE
token.c:2370:                rows_affected = 0
util.c:104:logic error: cannot change query state from IDLE to PENDING
token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b136cc, (nil), 0x6914)
token.c:543:tds_process_tokens() state is COMPLETED
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
util.c:156:Changed query state from QUERYING to PENDING
net.c:743:Sending packet
0000 01 01 00 1a 00 00 00 00-53 45 4c 45 43 54 20 31 |........ SELECT 1|
0010 3b 20 53 45 4c 45 43 54-20 32                   |; SELECT  2|

dblib.c:4639:dbsqlok(0x2bca5b0)
dblib.c:4669:dbsqlok() not done, calling tds_process_tokens()
token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b137d8, 0x7ffd20b137dc, 0x6914)
util.c:156:Changed query state from PENDING to READING
net.c:557:Received header
0000 04 01 00 3c 04 92 01 00-                        |...<....|

net.c:611:Received packet
0000 04 01 00 3c 04 92 01 00-a0 01 00 00 a1 05 00 07 |...<.... ........|
0010 00 20 00 38 d1 01 00 00-00 fd 11 00 c1 00 01 00 |. .8.... ........|
0020 00 00 a0 01 00 00 a1 05-00 07 00 20 00 38 d1 02 |........ ... .8..|
0030 00 00 00 fd 10 00 c1 00-01 00 00 00             |........ ....|

token.c:555:processing result tokens.  marker is  a0(COLNAME)
mem.c:615:tds_free_all_results()
token.c:555:processing result tokens.  marker is  a1(COLFMT)
token.c:1025:processing result. type = 56(int), varint_size 0
util.c:156:Changed query state from READING to PENDING
dblib.c:4700:dbsqlok() found result token
dblib.c:1668:dbresults(0x2bca5b0)
dblib.c:1674:dbresults: dbresults_state is 1 (_DB_RES_RESULTSET_EMPTY)
token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b13798, 0x7ffd20b1379c, 0x6914)
util.c:156:Changed query state from PENDING to READING
token.c:555:processing result tokens.  marker is  d1(ROW)
token.c:666:tds_process_tokens::SET_RETURN stopping on current token
util.c:156:Changed query state from READING to PENDING
dblib.c:1695:dbresults() tds_process_tokens returned 1 (TDS_SUCCEED),
			result_type TDS_ROW_RESULT
dblib.c:1657:dbresults returning 1 (SUCCEED)
dblib.c:2761:dbcount(0x2bca5b0)
dblib.c:1813:dbnumcols(0x2bca5b0)
dblib.c:1839:dbcolname(0x2bca5b0, 1)
dblib.c:3056:dbcollen(0x2bca5b0, 1)
dblib.c:2018:dbnextrow(0x2bca5b0)
dblib.c:2031:dbnextrow() dbresults_state = 2 (_DB_RES_RESULTSET_ROWS)
token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b1352c, (nil), 0x1508)
util.c:156:Changed query state from PENDING to READING
token.c:555:processing result tokens.  marker is  d1(ROW)
token.c:2304:tds_process_row(): reading column 0 
token.c:2049:tds_get_data: type 56, varint size 0
token.c:2110:tds_get_data(): wire column size is 4 
util.c:156:Changed query state from READING to PENDING
buffering.h:306:buffer_transfer_bound_data(0x2bca5c0 4040 -1 0x2bca5b0 0)
dblib.c:2100:leaving dbnextrow() returning REG_ROW/MORE_ROWS
dblib.c:2831:dbcoltype(0x2bca5b0, 1)
dblib.c:3162:dbdata(0x2bca5b0, 1)
dblib.c:3133:dbdatlen(0x2bca5b0, 1)
dblib.c:3142:dbdatlen() type = 56, len= 4
dblib.c:5854:dbcanquery(0x2bca5b0)
token.c:540:tds_process_tokens(0x2bcb070, 0x7ffd20b1382c, (nil), 0x108)
util.c:156:Changed query state from PENDING to READING
token.c:555:processing result tokens.  marker is  fd(DONE)
token.c:2339:tds_process_end: more_results = 1
		was_cancelled = 0
		error = 0
		done_count_valid = 1
token.c:2370:                rows_affected = 1
util.c:156:Changed query state from READING to PENDING
dblib.c:1668:dbresults(0x2bca5b0)
dblib.c:1674:dbresults: dbresults_state is 2 (_DB_RES_RESULTSET_ROWS)
dblib.c:7929:dbperror(0x2bca5b0, 20019, 0)
dblib.c:7981:20019: "Attempt to initiate a new Adaptive Server operation with results pending"
dblib.c:5780:dbgetuserdata(0x2bca5b0)
dblib.c:8002:"Attempt to initiate a new Adaptive Server operation with results pending", client returns 2 (INT_CANCEL)
dblib.c:1657:dbresults returning 0 (FAIL)
dblib.c:1443:dbclose(0x2bca5b0)
dblib.c:258:dblib_del_connection(0x7f83f278f8c0, 0x2bcb070)
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from PENDING to DEAD
dblib.c:305:dblib_release_tds_ctx(1)
dblib.c:5882:dbfreebuf(0x2bca5b0)
dblib.c:739:dbloginfree(0x2b6a290)
dblib.c:1512:dbexit(void)
dblib.c:305:dblib_release_tds_ctx(1)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.