Skip to Content.
Sympa Menu

freetds - [freetds] ODBC datetime literal

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Richard Krehbiel" <richard.krehbiel AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] ODBC datetime literal
  • Date: Wed, 15 Mar 2006 08:19:13 -0500

I've been porting some Windows code that uses ODBC to Linux (Fedora
core 4, freetds 0.63), and I must congratulate you guys; the freetds
ODBC package works remarkably well.

But there is one thing...

We have a number of bits of code that compose datetime literals using
a format like the following:

{ts'2006-03-15 08:10:41.000'}

When I feed this to the freetds odbc driver, it messes up the native
SQL. I tracked it down to src/odbc/native.c. It expects a space
following the "ts", but the first space in our literal is in the
middle of the timestamp string.

I'd like to suggest the following patch (composed against 0.64RC1),
that looks for a non-alphabetic char instead:

--- native.c.old 2006-02-24 16:14:25.000000000 -0500
+++ native.c 2006-03-14 13:57:41.000000000 -0500
@@ -139,8 +139,8 @@
if (!pcall) {
/* assume syntax in the form {type ...} */
- p = strchr(s, ' ');
- if (!p)
- break;
- s = p + 1;
+ while(isalpha(*s))
+ s++;
+ while(TDS_ISSPACE(*s))
+ s++;
} else {
if (*s == '?' && stmt)



  • [freetds] ODBC datetime literal, Richard Krehbiel, 03/15/2006

Archive powered by MHonArc 2.6.24.

Top of Page