Re: Binding a BIGINT in db-libraray
Frediano Ziglio <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
2011/5/18 James K. Lowden <[email protected]>: > On Tue, 17 May 2011 22:24:50 +0100 > "Thompson, William" <[email protected]> wrote: > >> I'm trying out 0.91 for the first time... > > Welcome back! > >> well to cut a long story short, my existing application code calls >> dbbind() with a bind type of BIGINTBIND to allow bigint data to be >> bound to a long long variable. >> Is this one my er...bespoke extensions to dblib ? > > Your patch would go well here, Bill. Cf. _db_get_server_type(). > (Server type? Who names these things?) > Something like that ?? I think I have too much patches unfinished... this is a small one! Don't ask me why I skipped some numbers... I don't remember but there must be a reason! Perhaps to avoid some clash with proprietary libraries freddy77 _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds
0001-13-dblib_bigint.diff.patch
(application/octet-stream, 3.5 KB)
From dbe7e4c18c1221251bdaec05ab60fdb8fe29407e Mon Sep 17 00:00:00 2001 From: Frediano Ziglio <[email protected]> Date: Thu, 12 May 2011 00:03:58 +0200 Subject: [PATCH 01/14] 13-dblib_bigint.diff =================================================================== --- include/sybdb.h | 4 +++- src/dblib/dblib.c | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/sybdb.h b/include/sybdb.h index 4328f38..0680e1e 100644 --- a/include/sybdb.h +++ b/include/sybdb.h @@ -236,6 +236,7 @@ typedef unsigned char DBBIT; typedef unsigned char DBTINYINT; typedef tds_sysdep_int16_type DBSMALLINT; typedef tds_sysdep_int32_type DBINT; +typedef tds_sysdep_int64_type DBBIGINT; typedef unsigned char DBBINARY; typedef tds_sysdep_real32_type DBREAL; typedef tds_sysdep_real64_type DBFLT8; @@ -472,7 +473,8 @@ typedef int (*MHANDLEFUNC) (DBPROCESS * dbproc, DBINT msgno, int msgstate, int s #define BITBIND 16 #define NUMERICBIND 17 #define DECIMALBIND 18 -#define MAXBINDTYPES 19 /* keep last */ +#define BIGINTBIND 30 +#define MAXBINDTYPES 31 /* keep last */ #define DBPRCOLSEP 21 #define DBPRLINELEN 22 diff --git a/src/dblib/dblib.c b/src/dblib/dblib.c index 671b6a4..e33981b 100644 --- a/src/dblib/dblib.c +++ b/src/dblib/dblib.c @@ -437,6 +437,7 @@ static const DBBIT null_BIT = 0; static const DBTINYINT null_TINYINT = 0; static const DBSMALLINT null_SMALLINT = 0; static const DBINT null_INT = 0; +static const DBBIGINT null_BIGINT = 0; static const DBFLT8 null_FLT8 = 0; static const DBREAL null_REAL = 0; @@ -470,7 +471,19 @@ static NULLREP default_null_representations[MAXBINDTYPES] = { /* BITBIND 16 */ , { &null_BIT, sizeof(null_BIT) } /* NUMERICBIND 17 */ , { (BYTE*) &null_NUMERIC, sizeof(null_NUMERIC) } /* DECIMALBIND 18 */ , { (BYTE*) &null_NUMERIC, sizeof(null_NUMERIC) } - /* MAXBINDTYPES 19 */ + /* 19 */ , { NULL, 0 } + /* 20 */ , { NULL, 0 } + /* 21 */ , { NULL, 0 } + /* 22 */ , { NULL, 0 } + /* 23 */ , { NULL, 0 } + /* 24 */ , { NULL, 0 } + /* 25 */ , { NULL, 0 } + /* 26 */ , { NULL, 0 } + /* 27 */ , { NULL, 0 } + /* 28 */ , { NULL, 0 } + /* 29 */ , { NULL, 0 } + /* BIGINTBIND 30 */ , { (BYTE*) &null_BIGINT, sizeof(null_BIGINT) } + /* MAXBINDTYPES 31 */ }; static int @@ -499,6 +512,7 @@ dbbindtype(int datatype) case SYBINT1: return TINYBIND; case SYBINT2: return SMALLBIND; case SYBINT4: return INTBIND; + case SYBINT8: return BIGINTBIND; case SYBMONEY: return MONEYBIND; case SYBMONEY4: return SMALLMONEYBIND; @@ -558,6 +572,7 @@ dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr) case SMALLDATETIMEBIND: case SMALLMONEYBIND: case TINYBIND: + case BIGINTBIND: memcpy(varaddr, pnullrep->bindval, pnullrep->len); return SUCCEED; default: @@ -1902,6 +1917,7 @@ dbsetnull(DBPROCESS * dbproc, int bindtype, int bindlen, BYTE *bindval) case SMALLDATETIMEBIND: case SMALLMONEYBIND: case TINYBIND: + case BIGINTBIND: bindlen = (int)default_null_representations[bindtype].len; break; @@ -2106,6 +2122,9 @@ _db_get_server_type(int bindtype) case TINYBIND: return SYBINT1; break; + case BIGINTBIND: + return SYBINT8; + break; case DATETIMEBIND: return SYBDATETIME; break; -- 1.7.1