Bug #74477 [Opn->Nab]: can not connect to sybase with pdo_dblib

From: Date: Tue, 23 May 2017 15:18:34 +0000
Subject: Bug #74477 [Opn->Nab]: can not connect to sybase with pdo_dblib
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209238@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74477&edit=1

 ID:                 74477
 Updated by:         adambaratz@php.net
 Reported by:        fuzzywy at 163 dot com
 Summary:            can not connect to sybase with pdo_dblib
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            PDO DBlib
 Operating System:   centos7
 PHP Version:        7.1.4
 Block user comment: N
 Private report:     N

 New Comment:

Closing as this doesn't appear to be related to pdo_dblib.


Previous Comments:
------------------------------------------------------------------------
[2017-05-16 11:29:32] adambaratz@php.net

It's hard to say what's going on here. Very little has changed in pdo_dblib between 5.5
and 7.1. That said, there are differences in the logs.

This happens in 5.5:
09:53:54.630614 14500 (net.c:741):Sending packet
0000 0f 01 00 21 00 00 00 00-21 14 00 00 00 00 73 65 |...!.... !.....se|
0010 74 20 74 65 78 74 73 69-7a 65 20 36 34 35 31 32 |t textsi ze 64512|
0020 20                     -                        | |


This happens in 7.1:
net.c:741:Sending packet
0000 0f 01 00 2c 00 00 00 00-21 1f 00 00 00 00 73 65 |...,.... !.....se|
0010 74 20 74 65 78 74 73 69-7a 65 20 36 34 35 31 32 |t textsi ze 64512|
0020 20 75 73 65 20 5b 64 77-68 64 62 5d             | use [dw hdb]|

After that packet is the error that results in the PDO exception. I see two differences: two !
(instead of , and !), invoking USE right after the SET. In 5.5, USE is invoked earlier.

My guess is that there was some build difference that's causing the connection to be made
differently. You could double-check your PHP build settings and see if anything stands out. Another
thing you could try would be upgrading to FreeTDS 1.0. Newer versions have a slightly different way
of selecting the database:
https://github.com/php/php-src/blob/PHP-7.1.4/ext/pdo_dblib/dblib_driver.c#L415

Maybe that would cause this issue to go away.

I'm not sure what other help I can offer. I don't have access to a Sybase server, so
it's difficult to do any testing of my own. Sorry you're having this problem with
pdo_dblib. I realize this must be a frustrating thing to have to deal with on your end.

------------------------------------------------------------------------
[2017-05-16 01:58:28] fuzzywy at 163 dot com

The log file which connect by pdo_dblib in php-5.5.15
================================
09:53:54.580743 14500 (log.c:196):Starting log file for FreeTDS 0.91
        on 2017-05-16 09:53:54 with debug flags 0xffff.
09:53:54.580768 14500 (iconv.c:330):tds_iconv_open(0x1e54100, UTF-8)
09:53:54.580783 14500 (iconv.c:187):local name for ISO-8859-1 is ISO-8859-1
09:53:54.580787 14500 (iconv.c:187):local name for UTF-8 is UTF-8
09:53:54.580789 14500 (iconv.c:187):local name for UCS-2LE is UCS-2LE
09:53:54.580792 14500 (iconv.c:187):local name for UCS-2BE is UCS-2BE
09:53:54.580794 14500 (iconv.c:349):setting up conversions for client charset "UTF-8"
09:53:54.580798 14500 (iconv.c:351):preparing iconv for "UTF-8" <->
"UCS-2LE" conversion
09:53:54.580801 14500 (iconv.c:391):preparing iconv for "ISO-8859-1" <->
"ISO-8859-1" conversion
09:53:54.580804 14500 (iconv.c:394):tds_iconv_open: done
09:53:54.580811 14500 (net.c:205):Connecting to 10.40.57.148 port 2640 (TDS version 5.0)
09:53:54.580849 14500 (net.c:270):tds_open_socket: connect(2) returned "Operation now in
progress"
09:53:54.583468 14500 (net.c:310):tds_open_socket() succeeded
09:53:54.583482 14500 (util.c:156):Changed query state from DEAD to IDLE
09:53:54.583489 14500 (net.c:741):Sending packet
0000 02 00 02 00 00 00 00 00-4d 61 73 74 65 72 00 00 |........ Master..|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0020 00 00 00 00 00 00 06 64-63 62 6f 00 00 00 00 00 |.......d cbo.....|
0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0040 00 00 00 00 00 04 64 63-62 6f 00 00 00 00 00 00 |......dc bo......|
0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0060 00 00 00 00 04 31 34 35-30 30 00 00 00 00 00 00 |.....145 00......|
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 50 48 50 20-47 65 6e 65 72 69 63 20 |....PHP  Generic |
00a0 44 42 2d 6c 69 62 00 00-00 00 00 00 00 00 00 00 |DB-lib.. ........|
00b0 00 00 12 31 30 2e 34 30-2e 35 37 2e 31 34 38 3a |...10.40 .57.148:|
00c0 32 36 34 30 00 00 00 00-00 00 00 00 00 00 00 00 |2640.... ........|
00d0 00 11 00 04 64 63 62 6f-00 00 00 00 00 00 00 00 |....dcbo ........|
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 06 05 00 00 00 44 42-2d 4c 69 62 72 61 72 79 |......DB -Library|
01e0 0a 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...... ........|

09:53:54.583568 14500 (net.c:741):Sending packet
0000 02 01 00 61 00 00 00 00-00 00 00 00 00 00 0a 00 |...a.... ........|
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-e2 16 00 01 09 00 08 0e |........ ........|
0050 6d 7f ff ff ff fe 02 09-00 00 00 00 02 68 00 00 |m....... .....h..|
0060 00                     -                        |.|

09:53:54.583591 14500 (token.c:328):tds_process_login_tokens()
09:53:54.589622 14500 (net.c:555):Received header
0000 04 01 00 59 00 00 00 00-                        |...Y....|

09:53:54.589637 14500 (net.c:609):Received packet
0000 04 01 00 59 00 00 00 00-e3 07 00 03 04 75 74 66 |...Y.... .....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 10 00 00 00 e2-16 00 01 09 00 08 0e 61 |ere..... .......a|
0040 01 ff ff fe e6 02 09 07-fe 3f 9e e6 68 00 00 0a |........ .?..h...|
0050 fd 00 00 01 00 e0 59 17-00                      |......Y. .|

09:53:54.630485 14500 (token.c:337):looking for login token, got  e3(ENVCHANGE)
09:53:54.630497 14500 (token.c:122):tds_process_default_tokens() marker is e3(ENVCHANGE)
09:53:54.630508 14500 (token.c:2493):server indicated charset change to "utf8"
09:53:54.630517 14500 (iconv.c:988):setting server single-byte charset to "UTF-8"
09:53:54.630524 14500 (dblib.c:327):db_env_chg(0x1e54100, 3, , utf8)
09:53:54.630529 14500 (token.c:337):looking for login token, got  e3(ENVCHANGE)
09:53:54.630534 14500 (token.c:122):tds_process_default_tokens() marker is e3(ENVCHANGE)
09:53:54.630538 14500 (token.c:2477):changing block size from 512 to 512
09:53:54.630542 14500 (dblib.c:327):db_env_chg(0x1e54100, 4, 512, 512)
09:53:54.630547 14500 (token.c:337):looking for login token, got  ad(LOGINACK)
09:53:54.630551 14500 (token.c:373):server reports TDS version 5.0.0.0
09:53:54.630555 14500 (token.c:375):Product name for 0x5000000 is unknown
09:53:54.630559 14500 (token.c:337):looking for login token, got  e2(CAPABILITY)
09:53:54.630564 14500 (token.c:122):tds_process_default_tokens() marker is e2(CAPABILITY)
09:53:54.630568 14500 (token.c:337):looking for login token, got  fd(DONE)
09:53:54.630573 14500 (token.c:122):tds_process_default_tokens() marker is fd(DONE)
09:53:54.630579 14500 (token.c:2339):tds_process_end: more_results = 0
                was_cancelled = 0
                error = 0
                done_count_valid = 0
09:53:54.630583 14500 (token.c:2355):tds_process_end() state set to TDS_IDLE
09:53:54.630587 14500 (token.c:2370):                rows_affected = 1530336
09:53:54.630591 14500 (token.c:438):tds_process_login_tokens() returning TDS_SUCCEED
09:53:54.630600 14500 (mem.c:615):tds_free_all_results()
09:53:54.630605 14500 (util.c:156):Changed query state from IDLE to QUERYING
09:53:54.630609 14500 (util.c:156):Changed query state from QUERYING to PENDING
09:53:54.630614 14500 (net.c:741):Sending packet
0000 0f 01 00 21 00 00 00 00-21 14 00 00 00 00 73 65 |...!.... !.....se|
0010 74 20 74 65 78 74 73 69-7a 65 20 36 34 35 31 32 |t textsi ze 64512|
0020 20                     -                        | |

09:53:54.630639 14500 (token.c:540):tds_process_tokens(0x1e54100, 0x7ffc5a301844, 0x7ffc5a301840,
0x100)
09:53:54.630645 14500 (util.c:156):Changed query state from PENDING to READING
09:53:54.646789 14500 (net.c:555):Received header
0000 04 01 00 11 00 00 00 00-                        |........|

09:53:54.646802 14500 (net.c:609):Received packet
0000 04 01 00 11 00 00 00 00-fd 00 00 01 00 00 00 00 |........ ........|
0010 00                     -                        |.|

09:53:54.646814 14500 (token.c:555):processing result tokens.  marker is  fd(DONE)
09:53:54.646819 14500 (token.c:2339):tds_process_end: more_results = 0
                was_cancelled = 0
                error = 0
                done_count_valid = 0
09:53:54.646824 14500 (token.c:2355):tds_process_end() state set to TDS_IDLE
09:53:54.646828 14500 (util.c:156):Changed query state from READING to IDLE
09:53:54.646832 14500 (token.c:2370):                rows_affected = 0
09:53:54.646836 14500 (util.c:104):logic error: cannot change query state from IDLE to PENDING
09:53:54.646840 14500 (token.c:540):tds_process_tokens(0x1e54100, 0x7ffc5a301844, 0x7ffc5a301840,
0x100)
09:53:54.646845 14500 (token.c:543):tds_process_tokens() state is COMPLETED
09:53:54.646850 14500 (dblib.c:239):dblib_add_connection(0x7fed67e43660, 0x1e54100)
09:53:54.646856 14500 (dblib.c:1398):dbuse(0x1e535c0, dwhdb)
09:53:54.646861 14500 (dblib.c:1312):dbcmd(0x1e535c0, use [dwhdb])
09:53:54.646870 14500 (dblib.c:1319):dbcmd() bufsz = 0
09:53:54.646879 14500 (dblib.c:1369):dbsqlexec(0x1e535c0)
09:53:54.646884 14500 (dblib.c:6862):dbsqlsend(0x1e535c0)
09:53:54.646889 14500 (mem.c:615):tds_free_all_results()
09:53:54.646893 14500 (util.c:156):Changed query state from IDLE to QUERYING
09:53:54.646897 14500 (util.c:156):Changed query state from QUERYING to PENDING
09:53:54.646901 14500 (net.c:741):Sending packet
0000 0f 01 00 19 00 00 00 00-21 0c 00 00 00 00 75 73 |........ !.....us|
0010 65 20 5b 64 77 68 64 62-5d                      |e [dwhdb ]|

09:53:54.646922 14500 (dblib.c:4639):dbsqlok(0x1e535c0)
09:53:54.646927 14500 (dblib.c:4669):dbsqlok() not done, calling tds_process_tokens()
09:53:54.646931 14500 (token.c:540):tds_process_tokens(0x1e54100, 0x7ffc5a301cbc, 0x7ffc5a301cb8,
0x6914)
09:53:54.646936 14500 (util.c:156):Changed query state from PENDING to READING
09:53:54.655803 14500 (net.c:555):Received header
0000 04 01 00 11 00 00 00 00-                        |........|

09:53:54.655816 14500 (net.c:609):Received packet
0000 04 01 00 11 00 00 00 00-fd 00 00 01 00 00 00 00 |........ ........|
0010 00                     -                        |.|

09:53:54.655826 14500 (token.c:555):processing result tokens.  marker is  fd(DONE)
09:53:54.655830 14500 (token.c:2339):tds_process_end: more_results = 0
                was_cancelled = 0
                error = 0
                done_count_valid = 0
09:53:54.655835 14500 (token.c:2355):tds_process_end() state set to TDS_IDLE
09:53:54.655839 14500 (util.c:156):Changed query state from READING to IDLE
09:53:54.655843 14500 (token.c:2370):                rows_affected = 0
09:53:54.655847 14500 (util.c:104):logic error: cannot change query state from IDLE to PENDING
09:53:54.655853 14500 (dblib.c:4707):dbsqlok() end status is SUCCEED
09:53:54.655857 14500 (dblib.c:4718):dbsqlok() end status was success
09:53:54.655863 14500 (dblib.c:1668):dbresults(0x1e535c0)
09:53:54.655867 14500 (dblib.c:1674):dbresults: dbresults_state is 5 (_DB_RES_SUCCEED)
09:53:54.655871 14500 (dblib.c:1657):dbresults returning 1 (SUCCEED)
09:53:54.655876 14500 (dblib.c:5854):dbcanquery(0x1e535c0)
09:53:54.655880 14500 (token.c:540):tds_process_tokens(0x1e54100, 0x7ffc5a301cdc, (nil), 0x108)
09:53:54.656060 14500 (token.c:543):tds_process_tokens() state is COMPLETED
09:53:54.656070 14500 (dblib.c:1443):dbclose(0x1e535c0)
09:53:54.656074 14500 (dblib.c:258):dblib_del_connection(0x7fed67e43660, 0x1e54100)
09:53:54.656079 14500 (mem.c:615):tds_free_all_results()
09:53:54.656097 14500 (util.c:156):Changed query state from IDLE to DEAD
09:53:54.656104 14500 (dblib.c:305):dblib_release_tds_ctx(1)
09:53:54.656112 14500 (dblib.c:5882):dbfreebuf(0x1e535c0)
09:53:54.656117 14500 (dblib.c:739):dbloginfree(0x1e53410)
09:53:54.656720 14500 (dblib.c:1512):dbexit(void)
09:53:54.656995 14500 (dblib.c:1512):dbexit(void)
09:53:54.657007 14500 (dblib.c:305):dblib_release_tds_ctx(1)

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=74477


--
Edit this bug report at https://bugs.php.net/bug.php?id=74477&edit=1


Thread (14 messages)

« previous php.bugs (#209238) next »