Skip Menu |

This queue is for tickets about the DBD-Sybase CPAN distribution.

Report information
The Basics
Id: 123718
Status: new
Priority: 0/
Queue: DBD-Sybase

People
Owner: Nobody in particular
Requestors: ZHENYZ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.15
Fixed in: (no value)



Subject: BIGDATETIME to ISO conversion broken with syb_date_fmt
DBD::Sybase's support for BIGDATETIME is not complete, and syb_date_fmt('ISO') does not work for BIGDATETIME columns. Attached is a patch based on version 1.15.
Subject: patch.diff
--- dbdimp.c.orig 2017-10-20 04:38:32.000000002 -0400 +++ dbdimp.c 2017-10-25 04:58:20.000000002 -0400 @@ -3259,7 +3259,28 @@ &imp_sth->coldata[i].indicator); break; #endif - +#if defined(CS_BIGDATETIME_TYPE) + case CS_BIGDATETIME_TYPE: + imp_sth->datafmt[i].maxlength = sizeof(CS_BIGDATETIME); + imp_sth->datafmt[i].format = CS_FMT_UNUSED; + imp_sth->coldata[i].type = CS_BIGDATETIME_TYPE; + imp_sth->datafmt[i].datatype = CS_BIGDATETIME_TYPE; + retcode = ct_bind(imp_sth->cmd, (i + 1), &imp_sth->datafmt[i], + &imp_sth->coldata[i].value.d, + &imp_sth->coldata[i].valuelen, + &imp_sth->coldata[i].indicator); + break; + case CS_BIGTIME_TYPE: + imp_sth->datafmt[i].maxlength = sizeof(CS_BIGTIME); + imp_sth->datafmt[i].format = CS_FMT_UNUSED; + imp_sth->coldata[i].type = CS_BIGTIME_TYPE; + imp_sth->datafmt[i].datatype = CS_BIGTIME_TYPE; + retcode = ct_bind(imp_sth->cmd, (i + 1), &imp_sth->datafmt[i], + &imp_sth->coldata[i].value.t, + &imp_sth->coldata[i].valuelen, + &imp_sth->coldata[i].indicator); + break; +#endif case CS_CHAR_TYPE: case CS_LONGCHAR_TYPE: case CS_VARCHAR_TYPE: @@ -3603,6 +3624,14 @@ case CS_DATETIME4_TYPE: bytes = sizeof(CS_DATETIME4); break; +#if defined(CS_BIGDATETIME_TYPE) + case CS_BIGDATETIME_TYPE: + bytes = sizeof(CS_BIGDATETIME); + break; + case CS_BIGTIME_TYPE: + bytes = sizeof(CS_BIGTIME); + break; +#endif case CS_MONEY_TYPE: bytes = sizeof(CS_MONEY); break; @@ -4164,6 +4193,9 @@ sv_catpvn(sv, imp_sth->coldata[i].value.c, len); break; case CS_DATETIME_TYPE: +#if defined(CS_BIGDATETIME_TYPE) + case CS_BIGDATETIME_TYPE: +#endif len = datetime2str(&imp_sth->coldata[i].value.dt, &imp_sth->datafmt[i], buff, DATE_BUFF_LEN, imp_dbh->dateFmt, LOCALE(imp_dbh)); @@ -4177,6 +4209,9 @@ sv_setpvn(sv, buff, len); break; case CS_TIME_TYPE: +#if defined(CS_BIGTIME_TYPE) + case CS_BIGTIME_TYPE: +#endif len = time2str(&imp_sth->coldata[i].value.t, &imp_sth->datafmt[i], buff, DATE_BUFF_LEN, imp_dbh->dateFmt, LOCALE(imp_dbh)); @@ -4912,19 +4947,39 @@ return len - 1; } else { - CS_DATEREC rec; - cs_dt_crack(context, CS_DATETIME_TYPE, dt, &rec); - if (type == 2) { - sprintf(buff, "%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d.%3.3dZ", - rec.dateyear, rec.datemonth + 1, rec.datedmonth, - rec.datehour, rec.dateminute, rec.datesecond, - rec.datemsecond); - } else { - sprintf(buff, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%3.3d", - rec.dateyear, rec.datemonth + 1, rec.datedmonth, - rec.datehour, rec.dateminute, rec.datesecond, - rec.datemsecond); - } + #if defined(CS_BIGDATETIME_TYPE) + if ((int)(srcfmt->datatype) == CS_BIGDATETIME_TYPE) { + CS_DATEREC rec; + cs_dt_crack(context, CS_BIGDATETIME_TYPE, dt, &rec); + if (type == 2) { + sprintf(buff, "%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d.%6.6dZ", + rec.dateyear, rec.datemonth + 1, rec.datedmonth, + rec.datehour, rec.dateminute, rec.datesecond, + rec.datesecfrac); + } else { + sprintf(buff, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%6.6d", + rec.dateyear, rec.datemonth + 1, rec.datedmonth, + rec.datehour, rec.dateminute, rec.datesecond, + rec.datesecfrac); + } + } + else + #endif + { + CS_DATEREC rec; + cs_dt_crack(context, CS_DATETIME_TYPE, dt, &rec); + if (type == 2) { + sprintf(buff, "%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d.%3.3dZ", + rec.dateyear, rec.datemonth + 1, rec.datedmonth, + rec.datehour, rec.dateminute, rec.datesecond, + rec.datemsecond); + } else { + sprintf(buff, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%3.3d", + rec.dateyear, rec.datemonth + 1, rec.datedmonth, + rec.datehour, rec.dateminute, rec.datesecond, + rec.datemsecond); + } + } return strlen(buff); } @@ -4981,19 +5036,39 @@ return len - 1; } else { - CS_DATEREC rec; - cs_dt_crack(context, CS_TIME_TYPE, t, &rec); - if (type == 2) { - sprintf(buff, "%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d.%3.3dZ", - rec.dateyear, rec.datemonth + 1, rec.datedmonth, - rec.datehour, rec.dateminute, rec.datesecond, - rec.datemsecond); - } else { - sprintf(buff, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%3.3d", - rec.dateyear, rec.datemonth + 1, rec.datedmonth, - rec.datehour, rec.dateminute, rec.datesecond, - rec.datemsecond); - } + #if defined(CS_BIGTIME_TYPE) + if ((int)(srcfmt->datatype) == CS_BIGTIME_TYPE) { + CS_DATEREC rec; + cs_dt_crack(context, CS_BIGTIME_TYPE, t, &rec); + if (type == 2) { + sprintf(buff, "%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d.%6.6dZ", + rec.dateyear, rec.datemonth + 1, rec.datedmonth, + rec.datehour, rec.dateminute, rec.datesecond, + rec.datesecfrac); + } else { + sprintf(buff, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%6.6d", + rec.dateyear, rec.datemonth + 1, rec.datedmonth, + rec.datehour, rec.dateminute, rec.datesecond, + rec.datesecfrac); + } + } + else + #endif + { + CS_DATEREC rec; + cs_dt_crack(context, CS_TIME_TYPE, t, &rec); + if (type == 2) { + sprintf(buff, "%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d.%3.3dZ", + rec.dateyear, rec.datemonth + 1, rec.datedmonth, + rec.datehour, rec.dateminute, rec.datesecond, + rec.datemsecond); + } else { + sprintf(buff, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%3.3d", + rec.dateyear, rec.datemonth + 1, rec.datedmonth, + rec.datehour, rec.dateminute, rec.datesecond, + rec.datemsecond); + } + } return strlen(buff); } @@ -5637,9 +5712,15 @@ #endif case CS_DATETIME_TYPE: case CS_DATETIME4_TYPE: +#if defined(CS_BIGDATETIME_TYPE) + case CS_BIGDATETIME_TYPE: +#endif return 9; #if defined(CS_TIME_TYPE) case CS_TIME_TYPE: +#if defined(CS_BIGTIME_TYPE) + case CS_BIGTIME_TYPE: +#endif return 10; #endif case CS_MONEY_TYPE: