Craig A. Berry | 20 Nov 20:53 2014

bp with empty char/varchar column broken

The following worked in 0.91 but is broken as of branch-0_92-839-gd788046.  If we bulk out a table with an
empty (but not NULL) char or varchar column that is less than 256 bytes long, 256 spaces get written to the
output file for that column.  Which then causes an overflow error if you try to bulk it back in.

I think it was e30a807 that broke it because in src/dblib/bcp.c:_bcp_exec_out we now pass a minimum of 256
as the destlen argument to dbconvert.  We used to pass -2, instructing dbconvert to null terminate without
copying anything.

I'm not sure what the correct fix is.  We could possibly pass the lesser of source length and destination
length to dbconvert in _bcp_exec_out.  

Here's a reproducer:

$ ./fisql/fisql -Smyserver -Utest
Changed database context to 'master'.
Changed language setting to us_english.
1>> use tempdb
2>> go
Changed database context to 'tempdb'.
1>> create table testbcp (tmpval varchar(10))
2>> go
1>> insert into testbcp values ('abc')
2>> go
(1 rows affected)
1>> insert into testbcp values ('')
2>> go
(1 rows affected)
1>> exit
$ ./freebcp tempdb.dbo.testbcp out tmp.bcp -Smyserver -Utest -P***** -c
(Continue reading)

Emmanuel Stapf | 15 Nov 10:33 2014

Issue with SQLDescribeCol


I've recently been testing the EiffelStore binding to ODBC against a MSSQL database. For
that I'm using unixODBC and freetds. However our code does not work due to the fact that
when calling SQLDescribeCol with almost no arguments to get the length of the column name
it does not return anything.

The code we have looks like:

  rc = SQLDescribeCol(hstmt, (SQLSMALLINT) index, NULL, 0, &indColName, NULL, NULL, NULL,

I looked at the code of SQLDescribeCol and found that in very old versions it would update
indColName and in the latest version although there is a comment at line 2009 of odbc.c
that says:

	/* cbColNameMax can be 0 (to retrieve name length) */

but nothing to that effect. Actually if you look at the following diff:

you see that the code that used to update pcbColName has disappeared from the current

Am I missing something?


(Continue reading)

Schulz-Hildebrandt, Heiner | 14 Nov 14:27 2014

ct-lib bulkcopy rowlevel locking

I am using freetds (0.91.102)  ct-lib (64 Bit) on MAC OSX 10.8 and MAC OSX 10.6.8  with Sybase 15.x server and
row-level-locking scheme (on table: my_table)
When I try to insert data into this table with bulk copy, I received the message:
Msg 4845, Level 16, State 1 Server MY_SERVER,Bulk copy failed. Client does not have the capability to bulk
copy into the data-only locked table 'my_table'.
and the command is aborted.

What can I do?

Thanks to anyone willing to help in any way.

+++ ?ber 5.000 Ausgaben t?glich +++
Mehr als 100 Medienh?user weltweit produzieren t?glich Zeitungen
und digitale Angebote mit ppi Media L?sungen

+++ Over 5,000 editions daily +++
More than 100 media companies worldwide produce newspapers
and digital products with ppi Media's solutions.
Simone Magnaschi | 12 Nov 12:40 2014

FreeTds, Dblib, SQl server2000 and the strange case of drop queries

Good morning to all.

I'm new to the mailing list, I subscribed since we're having issues on a 
new server deployment using FreeTDS. We were using FreeTDS before on a 
old server and everything was fine.

So we've got a new server with

  * Debian Wheezy 32BIT
  * PHP 5.5.18
  * FreeTDS 0.91

This PHP app needs to talk to an old SQL server 2000 server. We used the 
old code from our previous server (PHP 5.2 and older FreeTDS - can't get 
the version unfortunately). We connect to SQL server 2000 through PDO 
using dblib driver.

We're experiencing weird behaviour with the fetch function. Basically if 
we issue a query during a fetch loop on the same pdo connection object, 
the main query gets reset and next fetch call will return false even if 
there are still records to be fetched.

// Here the main query
$q = $sql7->query("SELECT TOP 5 * FROM News ORDER BY Data Desc");
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
     // Looping through the results
     echo "<h1>Main query</h1>";

(Continue reading)

Tolga Ceylan | 7 Nov 22:50 2014

freetds async usage

I know this is not possible with the current code, but I was wondering
if anybody worked on this in the past.

How hard would it be to add async support to freetds?

For example, linux/epoll support?

Tolga Ceylan
Tolga Ceylan | 30 Oct 05:10 2014

timeout handling and server msg callback

Hi All,

Recently, I've stumbled on a potential issue with the timeout handling
in ct_lib.

Given these two cases of SQL executing;

DECLARE  <at> counter int
WHILE ( <at> counter < 99999999)
    PRINT  <at> counter
    SET  <at> counter =  <at> counter + 1


DECLARE  <at> counter int
WHILE ( <at> counter < 99999999)
    SET  <at> counter =  <at> counter + 1

(only difference is print or no-print basically)

seems to affect timeout handling since this trips the ::select() (aka
tds_select) based query timeout.

In other words, continuously feeding such server messages back to the
client bypasses
the query timeout. The issue is tricky because there has to be enough
(Continue reading)

Turk, Scott A | 27 Oct 17:48 2014

Output from SQL Server database

Hi, we're having a problem with the output we're getting across an Oracle link to a SQL Server database.  The
column output appears to have inserted nulls in between each character.  The data type of the column is
nvarchar.  Our application is SQL Developer.

Any ideas on what may be going wrong?  We also use FreeTDS to link to other SQL Server databases and have not
seen this happen previously.


Scott Turk
Database Analyst, DBA
Computer Services - MIS
Missouri State University
SATurk <at><mailto:SATurk <at>>
(417) 836-6195
润青杨 | 23 Oct 16:14 2014

freetds have some ssl security problems

Hi guys,
Recently, our group are trying to find ssl security problems by static
anlysis. Now we have find some problems in freetds-bin and report this bugs
to the launchpad, but we haven't receive any responses.
Could you please take a look at this bug:
Randy Syring | 8 Oct 01:07 2014

help with "login packet rejected"

I have a system that has been running against a QA MSSQL 2005 server 
(SQL7) without problems for a day or so.  I switched it over to our 
production MSSQL 2005 server (SQL1) and I can't get connected.  My 

log.c:196:Starting log file for FreeTDS 0.91
     on 2014-10-07 19:03:24 with debug flags 0x4fff.
config.c:714:Setting 'dump_file' to '/tmp/freetds.log.2802' from $TDSDUMP.
iconv.c:330:tds_iconv_open(0x2055d20, 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" <-> "UCS-2LE" conversion
iconv.c:394:tds_iconv_open: done
net.c:205:Connecting to port 1433 (TDS version 7.1)
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 12 01 00 34 00 00 00 00-00 00 15 00 06 01 00 1b |...4.... ........|
0010 00 01 02 00 1c 00 0c 03-00 28 00 04 ff 08 00 01 |........ .(......|
0020 55 00 00 00 4d 53 53 51-4c 53 65 72 76 65 72 00 |U...MSSQ LServer.|
0030 f2 0a 00 00            -                        |....|

util.c:331:tdserror(0x1da8790, 0x2055d20, 20004, 104)
dblib.c:7929:dbperror(0x260a6a0, 20004, 104)
dblib.c:7981:20004: "Read from the server failed"
(Continue reading)

James Fisher | 7 Oct 20:18 2014

Re: SQL Anywhere 11 and FreeTDS

While reviewing the old thread I found that someone(Mr. James Lowden)
requested a tcpdump in order to capture a 'proper' disconnect but I didn't
see that the OP followed up.

I have attached mine here. If this isn't the right information, please let
me know. Thanks again to anyone willing to help.

On Mon, Oct 6, 2014 at 1:57 PM, James Fisher <ganoopluslinux <at>>

> OP:
> Hello, I am new to mailing lists, so sorry if it's bad that I am reviving
> this old thread - but I am having the same issue as this guy from several
> years back...
> I setup a few debian and ubuntu servers to talk to our database(Sybase SQL
> Anywhere 11) using sqsh and adodb(php) with FreeTDS. Once configured to
> use TDS v5.0, both sqsh and adodb can connect and execute queries on the
> database. However, when I began looking at the log on the server I found
> that each time either application disconnects, it shows a message like:
> >Connection terminated abnormally
> >Disconnected TCPIP client's AppInfo: HOST=debian-vm;PID=2605
> The database doesn't *seem* affected - as far as I can tell...
> The statements return the rows or insert the data.
(Continue reading)

Roger Hill | 4 Oct 10:04 2014

Netezza and named pipes

My first post to the list: please be gentle!

I need to copy a large volume of data every day from a Netezza database to
several other SQL server databases.

I have a solution that works: I use isql to extract to a named pipe, pass the
output through a couple of 'cut' steps to remove unwanted bits and pieces, and
then land the data on disk into a temporary file. I then use freebcp to load
it to the SQL server database. But it's convoluted, and I'm looking for a
better way.

Two questions come out of this: Firstly  I know that freebcp did not support
input from named pipes as recently as 2011; is there support for named pipes

And secondly, something like 'datacopy' between heterogeneous databases (in my
case Netezza to SQL server) would eliminate a lot of mucking about on the
intermediate box. Any chance of something like that?

Any other suggestions?

Roger Hill

Roger Hill