[freetds] MS-SQL ntext fields?

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Wed Jan 3 03:24:38 EST 2007


> 
> After building a new web server and pulling my content over from its
> predecessor, I'm having a strange problem with some of my PHP scripts.
> I'm not certain it's a freetds bug, but I have a hunch that it is.
> Here's what's happening:
> 
> * PHP scripts containing certain queries are segfaulting unless I
> comment out the odbc_result() calls to certain fields in the query
> results.  

Here a gdb backtrace would help.

> * The fields only break the queries if they are non-null - querying
> records with null values in those fields works fine
> * The fields in question don't have much in common.  Some are varchar,
> some are text...

Try to select varchar only than ntext only.

> * If I run the same query through isql without involving PHP 
> or the web
> server, it runs fine! BUT...
> * If I try it in tsql, it fails with this message:
> 
> Msg 4004, Level 16, State 1, Server VOYAGER, Line 1
> Unicode data in a Unicode-only collation or ntext data cannot 
> be sent to
> clients using DB-Library (such as ISQL) or ODBC version 3.7 
> or earlier.
> 

tsql do not use odbc.ini so it use default protocol version (probably
4.2) which do not support n-types so server complaints.
Prepend TDSVER=8.0 like

TDSVER=8.0 tsql -Sserver -Uuser -Ppassword

> * Tsql runs the queries fine if I remove all references to 
> ntext fields.
> BUT...
> * The ntext fields that tsql objects to are NOT the fields that I find
> are breaking in the PHP scripts.
> 
> Here are the specs of my server:
> AMD-64 
> 2GB RAM (over 1GB shows free at the moment)
> CentOS 4.4 for x86-64
> freetds 0.64 built from source, configured with manual 
> reference to the
> location of unixODBC
> unixODBC 2.2.11 built from source
> php 4.3.9-3.22
> Apache 2.0.52-28 ent.centos4
> 
> And I'm connecting to MS-SQL 2000 on a Windows SBS 2003 box.  
> 
> Here's the relevant section of odbc.ini:
> [Voyager]
> DRIVER          = /usr/lib/libtdsodbc.so
> DESCRIPTION     = SQL Server 2000 on Voyager
> TRACE           = no
> SERVER          = voyager.experienceplus.com
> APP             = FreeTDS/unixODBC on WWW2
> UID             = xxxxx
> DATABASE        = XPlus
> PORT            = 1433
> TDS_VERSION     = 8.0
> 

This is a freetds.conf-less configuration so isql and php using odbc do
not use freetds.conf

> And here's the relevant stuff from freetds.conf:
> [global]
> 
>         tds version = 4.2
> 
> ;       initial block size = 512
> 
> ;       swap broken dates = no
> ;       swap broken money = no
> 
> ;       dump file = /tmp/freetds.log
> ;       debug flags = 0xffff
> 
> ;       timeout = 10
> ;       connect timeout = 10
> 
>         text size = 64512
> [Voyager]
>        host = voyager.experienceplus.com
>        port = 1433
>        tds version = 8.0
> 

this is used by tsql. Strange that tsql is not using version 8.0...

> Anyone who has insight into this problem will earn my gratitude and a
> virtual pat on the back. Thanks,
> 
> (and by the way, are the semicolons in freetds.conf comment 
> characters?)
> 

bye
  freddy77



More information about the FreeTDS mailing list