Hi internals,

There seems to be an error in the handling of pdo_dblib's TDS protocol version, 
so I'm thinking of fixing these. Through this email, I would like to discuss 
the appropriate time and method for correction.

— For your reference —
There are several derivatives of "SQL Server", with Microsoft SQL Server being 
the most popular. These communicate using the TDS protocol. However, the TDS 
protocol standards are not strictly unified, and the Sybase protocol and 
Microsoft SQL Server have different standards, so each is defined as a 
different "version" of the TDS protocol.
Therefore, pdo_dblib allows the user to specify a "version" for dsn and select 
which protocol version to use.
— End —

The related issue:
https://github.com/php/php-src/issues/13475

The types and details of protocol versions are explained in the FreeTDS user 
guide:
https://www.freetds.org/userguide/ChoosingTdsProtocol.html

Summarize the explanation.

4.2: Available for older Sybase and Microsoft SQL Servers
5.0: Available for new Sybase
7.0 - 7.4: Available for new Microsoft SQL Server

Notes:
- There's actually a version too called 4.6, which appears to be for Open SQL 
Server. However, I plan to explore this in a little more detail.
- It seems that there are two types of 5.0, so I will investigate this as well.

Now take a look at the pdo_dblib implementation in php-src:
https://github.com/php/php-src/blob/ffc6f192a8f475dfdff942bb22f509d1eefd0847/ext/pdo_dblib/dblib_driver.c#L447

Excerpt the incorrect part:
```
{"5.0",DBVERSION_70} /* FIXME: This does not work with Sybase, but environ will 
*/
{"6.0",DBVERSION_70}
{"8.0",DBVERSION_72}
{"10.0",DBVERSION_100}
```

`DBVERSION_70` (meaning 7.0) is specified for 5.0 and 6.0. And as far as I can 
tell, there is no version called 6.0. (`DBVERSION_60` is also not defined.)

There is also no version 8.0, but according to the FreeTDS user guide, it 
appears that versions of FreeTDS older than 1.3 can specify this, as 7.1 was 
originally planned to be released as 8.0. However, PHP treats 8.0 as an alias 
for 7.2 rather than 7.1, which is incorrect anyway.

`DBVERSION_50`, which would be used for 5.0, is also not defined, but according 
to the following page, `DBVERSION_100` means 5.0.
https://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc20155_1251/html/newfesd/BABHHDEI.htm

Excerpt:

> DBVERSION_100 — DB-Library is running with TDS version 5.0 protocol

So remove 6.0, 8.0 and 10.0 and 5.0 should look like this:
```
{"5.0",DBVERSION_100}
```

These changes are definitely a BC break. Therefore, I would appreciate any 
feedback you may have, including which versions should I make changes to?

Regards.

Saki

Reply via email to