Bug #74477 [Com]: can not connect to sybase with pdo_dblib

From: Date: Tue, 02 May 2017 02:11:45 +0000
Subject: Bug #74477 [Com]: can not connect to sybase with pdo_dblib
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208889@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
 Comment by:         fuzzywy at 163 dot com
 Reported by:        fuzzywy at 163 dot com
 Summary:            can not connect to sybase with pdo_dblib
 Status:             Feedback
 Type:               Bug
 Package:            PDO DBlib
 Operating System:   centos7
 PHP Version:        7.1.4
 Block user comment: N
 Private report:     N

 New Comment:

FYI, thanks!

--------------------------------------------------
log.c:196:Starting log file for FreeTDS 0.91
	on 2017-05-02 01:50:40 with debug flags 0x4fff.
iconv.c:330:tds_iconv_open(0x329e160, 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:205:Connecting to 7.140.28.88 port 26401 (TDS version 5.0)
net.c:270:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:310:tds_open_socket() succeeded
util.c:156:Changed query state from DEAD to IDLE
net.c:741:Sending packet
0000 02 00 02 00 00 00 00 00-70 72 6f 6d 6f 74 65 2e |........ promote.|
0010 63 61 63 68 65 2d 64 6e-73 2e 6c 6f 63 61 6c 00 |cache-dn s.local.|
0020 00 00 00 00 00 00 17 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 33 37 35-33 00 00 00 00 00 00 00 |.....375 3.......|
0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0080 00 00 00 04 03 01 06 0a-09 01 00 00 00 00 00 00 |........ ........|
0090 00 00 00 00 50 48 50 20-66 72 65 65 74 64 73 00 |....PHP  freetds.|
00a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00b0 00 00 0b 37 2e 31 34 30-2e 32 38 2e 38 38 3a 32 |...7.140 .28.88:2|
00c0 36 34 30 31 00 00 00 00-00 00 00 00 00 00 00 00 |6401.... ........|
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...... ........|

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                     -                        |.|

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

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 7c 89 19-00                      |.....|.. .|

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 "utf8"
iconv.c:988:setting server single-byte charset to "UTF-8"
dblib.c:327:db_env_chg(0x329e160, 3, , utf8)
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(0x329e160, 4, 512, 512)
token.c:337:looking for login token, got  ad(LOGINACK)
token.c:373:server reports TDS version 5.0.0.0
token.c:375:Product name for 0x5000000 is unknown
token.c:337:looking for login token, got  e2(CAPABILITY)
token.c:122:tds_process_default_tokens() marker is e2(CAPABILITY)
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 = 1673596
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: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]|

token.c:540:tds_process_tokens(0x329e160, 0x7fff3db37d64, 0x7fff3db37d60, 0x100)
util.c:156:Changed query state from PENDING to READING
net.c:555:Received header
0000 04 01 00 63 00 00 00 00-                        |...c....|

net.c:609:Received packet
0000 04 01 00 63 00 00 00 00-e5 4f 00 66 00 00 00 00 |...c.... .O.f....|
0010 0f 05 34 32 57 30 34 00-01 00 3a 00 53 51 4c 20 |..42W04. ..:.SQL |
0020 41 6e 79 77 68 65 72 65-20 45 72 72 6f 72 20 2d |Anywhere  Error -|
0030 31 33 31 3a 20 53 79 6e-74 61 78 20 65 72 72 6f |131: Syn tax erro|
0040 72 20 6e 65 61 72 20 27-75 73 65 27 20 6f 6e 20 |r near ' use' on |
0050 6c 69 6e 65 20 31 00 00-00 00 fd 02 00 01 00 00 |line 1.. ........|
0060 00 00 00               -                        |...|

token.c:555:processing result tokens.  marker is  e5(EED)
token.c:122:tds_process_default_tokens() marker is e5(EED)
token.c:2588:tds_process_msg() reading message 102 from server
token.c:2661:tds_process_msg() calling client msg handler
dbutil.c:85:_dblib_handle_info_message(0x32933f0, 0x329e160, 0x7fff3db37bb0)
dbutil.c:86:msgno 102: "SQL Anywhere Error -131: Syntax error near 'use' on line
1"
dblib.c:5780:dbgetuserdata(0x329d660)
dblib.c:5780:dbgetuserdata(0x329d660)
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 = 1
		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(0x329e160, 0x7fff3db37d64, 0x7fff3db37d60, 0x100)
token.c:543:tds_process_tokens() state is COMPLETED
dblib.c:1443:dbclose(0x329d660)
dblib.c:258:dblib_del_connection(0x7ff3a4ad0660, 0x329e160)
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to DEAD
dblib.c:305:dblib_release_tds_ctx(1)
dblib.c:5882:dbfreebuf(0x329d660)
dblib.c:739:dbloginfree(0x329d490)
dblib.c:1512:dbexit(void)
dblib.c:305:dblib_release_tds_ctx(1)


Previous Comments:
------------------------------------------------------------------------
[2017-04-28 17:29:11] adambaratz@php.net

Are you familiar with TDSDUMP environment variable?
http://www.freetds.org/userguide/logging.htm

Try doing this for both PHP versions:
TDSDUMP="freetds.log" php -r "new
PDO('dblib:host=7.140.28.88:26401;dbname=dwhdb','dcbo','dcbo');"

If you share both log files, I might be able to help debug.

------------------------------------------------------------------------
[2017-04-25 00:56:46] fuzzywy at 163 dot com

I've been aware of the issue so i checked the source code in 5.5.15
(in which version my program works well).

https://github.com/php/php-src/blob/PHP-5.5.15/ext/pdo_dblib/dblib_driver.c

It's same as the code in 7.1.4 that there's a comment in version 5.0。

And i also test it in 7.0.x, change the global tds version in my freetds.conf to 4.2, both can not
work。

------------------------------------------------------------------------
[2017-04-24 18:59:01] adambaratz@php.net

Is it possible to use a different TDS version? There's a comment in the source suggesting that
5.0 isn't supported:
https://github.com/php/php-src/blob/PHP-7.1.4/ext/pdo_dblib/dblib_driver.c#L312

If that doesn't work, it would help to know if this was a regression between PHP versions. I
don't have a local instance of Sybase, so this may be difficult to help debug, but that might
point the way.

------------------------------------------------------------------------
[2017-04-20 07:45:27] fuzzywy at 163 dot com

Description:
------------
The problem is that i can connect sybase with freetds, while pdo_dblib get error.

===
freetds.conf
[sybase]
        host = 7.140.28.88
        port = 26401
        tds version = 5.0

===
test script
php -r "new
PDO('dblib:host=7.140.28.88:26401;dbname=dwhdb','dcbo','dcbo');"



Expected result:
----------------
connect to sybase server

Actual result:
--------------
PDOException thrown
Fatal error: Uncaught PDOException: SQLSTATE[HY000] General SQL Server error: Check messages from
the SQL Server (severity 15) in Command line code:1


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



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


Thread (14 messages)

« previous php.bugs (#208889) next »