Skip to Content.
Sympa Menu

freetds - Re: [freetds] db-lib: support for new MS SQL 2008 data types - part 4

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] db-lib: support for new MS SQL 2008 data types - part 4
  • Date: Sun, 25 May 2014 07:31:59 +0100

2014-05-21 12:47 GMT+01:00 LacaK <lacak AT zoznam.sk>:
> Hi,
> please see attached small patches, which introduce new constant
> DATETIME2BIND used for supporting binding to local variables of type
> TDS_DATETIMEALL.
> Any comment welcome of course.
> Thanks
> -Laco.
>
>
> --- sybdb.h.ori Sun May 18 10:41:16 2014
> +++ sybdb.h Wed May 21 13:30:54 2014
> @@ -459,7 +459,7 @@ typedef int (*MHANDLEFUNC) (DBPROCESS *
> #define STRINGBIND 1
> #define NTBSTRINGBIND 2
> #define VARYCHARBIND 3
> -#define VARYBINBIND 4
> +#define VARYBINBIND 4
> #define TINYBIND 6
> #define SMALLBIND 7
> #define INTBIND 8
> @@ -474,7 +474,8 @@ typedef int (*MHANDLEFUNC) (DBPROCESS *
> #define NUMERICBIND 17
> #define DECIMALBIND 18
> #define BIGINTBIND 30
> -#define MAXBINDTYPES 31 /* keep last */
> +#define DATETIME2BIND 31
> +#define MAXBINDTYPES 32 /* keep last */
>
> #define DBPRCOLSEP 21
> #define DBPRLINELEN 22
>
> --- dblib.c.ori Sun May 18 10:41:16 2014
> +++ dblib.c Wed May 21 13:38:42 2014
> @@ -452,6 +452,7 @@ static const DBDATETIME4 null_SMALLDATET
> static const DBMONEY null_MONEY = { 0, 0 };
> static const DBMONEY4 null_SMALLMONEY = {0};
> static const DBNUMERIC null_NUMERIC = { 0, 0, {0} };
> +static const TDS_DATETIMEALL null_DATETIMEALL = { 0, 0, 0, 0 };
>
> static NULLREP default_null_representations[MAXBINDTYPES] = {
> /* CHARBIND 0 */ { NULL, 0 }
> @@ -485,7 +486,8 @@ static NULLREP default_null_representati
> /* 28 */ , { NULL, 0 }
> /* 29 */ , { NULL, 0 }
> /* BIGINTBIND 30 */ , { (BYTE*) &null_BIGINT,
> sizeof(null_BIGINT) }
> - /* MAXBINDTYPES 31 */
> + /* DATETIME2BIND 31 */ , { (BYTE*) &null_DATETIMEALL,
> sizeof(null_DATETIMEALL) }
> + /* MAXBINDTYPES 32 */
> };
>
> static int
> @@ -518,7 +520,13 @@ dbbindtype(int datatype)
>
> case SYBMONEY: return MONEYBIND;
> case SYBMONEY4: return SMALLMONEYBIND;
> -
> +
> + case SYBMSDATE:
> + case SYBMSTIME:
> + case SYBMSDATETIME2:
> + case SYBMSDATETIMEOFFSET:
> + return DATETIME2BIND;
> +
> default:
> assert(0 == "no such datatype");
> }
> @@ -2157,6 +2165,9 @@ dblib_bound_type(int bindtype)
> case DECIMALBIND:
> return SYBDECIMAL;
> break;
> + case DATETIME2BIND:
> + return SYBMSDATETIME2;
> + break;
> default:
> return -1;
> break;

Why not SYBMSDATETIMEOFFSET

> @@ -7321,6 +7332,14 @@ copy_data_to_host_var(DBPROCESS * dbproc
> memcpy(dest, src, ret);
> break;
>
> + case SYBMSDATE:
> + case SYBMSTIME:
> + case SYBMSDATETIME2:
> + case SYBMSDATETIMEOFFSET:
> + ret = sizeof(TDS_DATETIMEALL);
> + memcpy(dest, src, ret);
> + break;
> +
> default:
> break;
> }
> @@ -7427,6 +7446,12 @@ copy_data_to_host_var(DBPROCESS * dbproc
> break;
> case SYBUNIQUE:
> memcpy(dest, &(dres.u), sizeof(TDS_UNIQUE));
> + break;
> + case SYBMSDATE:
> + case SYBMSTIME:
> + case SYBMSDATETIME2:
> + case SYBMSDATETIMEOFFSET:
> + memcpy(dest, &(dres.dta), sizeof(TDS_DATETIMEALL));
> break;
> case SYBCHAR:
> case SYBVARCHAR:
>

The rest looks fine. Can I apply with the type changed or there is a
specific reason why you choose this type?

Frediano




Archive powered by MHonArc 2.6.24.

Top of Page