[freetds] timestamp truncation?

James K. Lowden jklowden at freetds.org
Fri Nov 14 01:03:16 EST 2008


Using bsqlodbc, I get an error for the following query.  I think it's
related to conversion of a TIMESTAMP datatype.  We seem to be losing a
byte somewhere.  I'm not sure where the error is.  

bsqldb output is OK.  The problem appears to be in the ODBC layer or
perhaps between keyboard and chair.  

Results follow.  

--jkl


bsqldb output:

Data
          i  ts                          sd                           d
-----------  --  --------------------------  --------------------------
         42  00         Nov 14 2008 04:59PM         Nov 14 2008 04:58PM
Retrieving return status... none
1 rows affected


Query:

$ cat test/datetime.sql
use FreeTDS
go

create table at( i int, ts timestamp, sd smalldatetime, d datetime )
go
insert at (i, sd, d) values (42, getdate(), getdate())
select * from at
drop table at
go


Output:

$ (cd build/src/apps/ && make) && TDSDUMP=dump build/src/apps/bsqlodbc -S
varley -U jkl -P jkl -i test/datetime.sql -v -V3 2>&1 | tail -11
col     name                            type value  type name          
size    varies  
------  ------------------------------  ----------  ------------------ 
------  ------  
     1                               i           4         SQL_INTEGER    
 10      -1  
     2                              ts          -2          SQL_BINARY    
  8      -1  
     3                              sd          93  SQL_TYPE_TIMESTAMP    
 16      -1  
     4                               d          93  SQL_TYPE_TIMESTAMP    
 23      -1  
         i        ts                sd                        d
----------  --------  ----------------  -----------------------
SQLMoreResults returned SQL_NO_DATA
bsqlodbc:359: Query:
"[FreeTDS][SQL Server]Data truncated"


Log:

odbc.c:1585:SQLBindCol(0x8051000, 1, 1, 0x804e300, 10, 0x804f444)
odbc.c:1585:SQLBindCol(0x8051000, 2, 1, 0x804e330, 8, 0x804f450)
                                                  ^^^ eight
odbc.c:1585:SQLBindCol(0x8051000, 3, 1, 0x804e360, 16, 0x804f45c)
odbc.c:1585:SQLBindCol(0x8051000, 4, 1, 0x804d240, 23, 0x804f468)
odbc.c:3724:SQLFetch(0x8051000)
...
odbc.c:3360:odbc_process_tokens: tds_process_tokens returned 1
odbc.c:3361:    result_type=4040, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3431:odbc_process_tokens: returning result_type 4040
convert_tds2sql.c:152:odbc_tds2sql: src is 56 dest = 1
convert_tds2sql.c:262:odbc_tds2sql: outputting character data destlen = 10

convert_tds2sql.c:152:odbc_tds2sql: src is 173 dest = 1
convert_tds2sql.c:262:odbc_tds2sql: outputting character data destlen = 7 
	/* seven ?? */
convert_tds2sql.c:152:odbc_tds2sql: src is 58 dest = 1
convert_tds2sql.c:262:odbc_tds2sql: outputting character data destlen = 16

convert_tds2sql.c:152:odbc_tds2sql: src is 61 dest = 1
convert_tds2sql.c:262:odbc_tds2sql: outputting character data destlen = 23

error.c:409:odbc_errs_add: "Data truncated"




More information about the FreeTDS mailing list