/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to docs/mssql.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2008-07-17 14:57:10 UTC
  • Revision ID: csa@dside.dyndns.org-20080717145710-awa4zpdh2a19lqbi
Documentation and configuration updates

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
The following configuration is used to access MSSQL servers
2
 
 a) PDO_ODBC
3
 
 b) unixODBC
4
 
 c) FreeTDS
 
2
 a) PDO_ODBC (PhP 5.2.6 + fixes)
 
3
 b) unixODBC (2.2.12)
 
4
 c) FreeTDS (0.82 + fixes)
 
5
 d) MS SQL Server 2005
5
6
 
6
 
Existing problems
 
7
Mandatory Patches
7
8
-----------------
8
 
a) PhP PDO/ODBC driver incorrectly handles long binary fields in the queries 
9
 
 (resulting in "Out of memory" error). This is a fix. Php bug #42765
10
 
 http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_blob.patch
 
9
 - PhP PDO/ODBC driver incorrectly handles long binary fields in the queries 
 
10
 (resulting in "Out of memory" error). This is a fix. Php bug #42765.
 
11
 The patch against php-5.2.6 (mandatory if BLOB data is used):
 
12
    http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_blob.patch
11
13
 
12
 
b) unixODBC (at least up to 2.2.12) expects pointer on 32 bit interger as
 
14
 - unixODBC (at least up to 2.2.12) expects pointer on 32 bit interger as
13
15
 last parameter of SQLBindCol call (MSDN defines SQLLEN). However, the php
14
16
 on Linux 64 bit platform is passing 64 bit integer. This causes crash.
15
 
 Patched on php side:
16
 
 http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch
17
 
 
18
 
c) FreeTDS (at least up to 0.82) ODBC driver is corrupting data if 
19
 
 SQLGetData is called multiple times on a single column and 
20
 
 BINARY->CHAR data conversion have been involved. 
21
 
 http://dside.dyndns.org/projects/patches.dir/freetds-0.82-odbc-csa2.patch 
22
 
 
23
 
d) PHP PDO/ODBC driver doesn't support PDO::ATTR_TIMEOUT attribute and, 
24
 
 therefore it takes too long to detect inaccessible servers.
25
 
 Php Bug #45287
26
 
 http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_timeout.patch
 
17
 Unfortunately, it is really hard work to fix it on unixODBC side (expected in 
 
18
 2.2.13). Therefore, the parts of the problem which is involving PDO/ODBC 
 
19
 misbehaviour is fixed on PhP side.
 
20
 The patch against php-5.2.6 (mandatory):
 
21
    http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch
 
22
 
 
23
 - FreeTDS (0.82 and earlier) ODBC driver is corrupting data if SQLGetData is 
 
24
 called multiple times on a single column and  BINARY->CHAR data conversion 
 
25
 has been involved. 
 
26
 The patch agains FreeTDS-0.82 (mandatory if BLOB data bigger than 512 bytes
 
27
 is used):
 
28
    http://dside.dyndns.org/projects/patches.dir/freetds-0.82-odbc-csa2.patch 
 
29
 
 
30
Optional Patches
 
31
----------------
 
32
 - PhP (5.2.6 and earlier) PDO/ODBC driver is ignoring PDO::ATTR_TIMEOUT 
 
33
 attribute, what causes extremly long delays trying to access dead / unreachable
 
34
 servers. Php bug #45287. 
 
35
 The patch agains php-5.2.6 (optional, recommended):
 
36
    http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_timeout.patch
27
37
 
28
 
e) FreeTDS uses SQL_ATTR_CONNECTION_TIMEOUT instead SQL_ATTR_LOGIN_TIMEOUT
 
38
 - FreeTDS uses SQL_ATTR_CONNECTION_TIMEOUT instead SQL_ATTR_LOGIN_TIMEOUT
29
39
 on connection initialization. This do not causing big problems, but
30
40
 violites ODBC specification.
 
41
 The patch against php-5.2.6 (optional):
31
42
 http://dside.dyndns.org/projects/patches.dir/freetds-ds-connect_timeout.patch
32
43
 
33
 
f) Be aware what PDO/ODBC returns BINARY blobs converted to ASCII hexdecimal 
 
44
 - Be aware what PDO/ODBC returns BINARY blobs converted to ASCII hexdecimal 
34
45
 representation. I decieded against patching this behaviour in driver code, 
35
46
 but just taking care in php code.
36
47
 However, to insert data in the binary blob, it is neccesary to provide the 
37
48
 data in binary form. 
38
49
 
 
50
Known problems
 
51
--------------
 
52
 - PhP (5.2.6) PDO/ODBC driver incorrectly handles PDO::PARAM_LOB parameters if 
 
53
 $length attribute is set. No fix is available upto now, just avoid setting the
 
54
 $length attribute.
 
55
 
 
56
 - Either PDO/ODBC module or FreeTDS is sending all the data (with exception of
 
57
 PDO::PARAM_LOB) to MSSQL server using TEXT variables. However, MSSQL is not 
 
58
 able to make implicit conversion of TEXT variables. 
 
59
 This causes troubles while writing INSERT queries. The problem could be 
 
60
 avoided by making explicit conversion to size-limit CHAR type in INSERT 
 
61
 query. Like this:
 
62
    INSERT INTO ... (intcol) VALUE(CONVERT(CHAR(64), ?));
 
63
    
 
64
 - after 'prepare' call, the query (at least INSERT one) could be 'execute' 
 
65
 only 65535 times. Afterwars, strange excpetion is emerges. Just repraparing
 
66
 is not helpful. It's necessary to close PDO connection and open it again.
 
67
 
 
68
Reciptes
 
69
-------- 
 
70
 - Inserting the datetime values into MSSQL database is quite tricky, I'm
 
71
 using following procedure:
 
72
  * Setting date format:
 
73
    $dbh->query("set dateformat ymd");
 
74
  * Formating date string:
 
75
    $sqltime = strftime("%Y-%m-%d %H:%M:%S", floor($tm));
 
76
  * Preparing SQL query:
 
77
    ... VALUES( ... CONVERT(DATETIME, CONVERT(CHAR(20), ?), 111) ... ) ...
 
78
 
 
79
 
39
80
More Infos
40
81
----------
41
82
 - FreeTDS ODBC driver is not implementing SQLDescribeType interface. Therefore,