Commit 85c65f4e authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix MDEV-7427 by not reallocating the date format in ScanRecord on each inserted row.

modified:
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
parent d4bf6455
...@@ -714,7 +714,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) ...@@ -714,7 +714,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
datapath= "./"; datapath= "./";
#endif // !WIN32 #endif // !WIN32
tdbp= NULL; tdbp= NULL;
sdvalin= NULL; sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
sdvalout= NULL; sdvalout= NULL;
xmod= MODE_ANY; xmod= MODE_ANY;
istable= false; istable= false;
...@@ -1815,7 +1815,7 @@ int ha_connect::CloseTable(PGLOBAL g) ...@@ -1815,7 +1815,7 @@ int ha_connect::CloseTable(PGLOBAL g)
{ {
int rc= CntCloseTable(g, tdbp, nox, abort); int rc= CntCloseTable(g, tdbp, nox, abort);
tdbp= NULL; tdbp= NULL;
sdvalin=NULL; sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
sdvalout=NULL; sdvalout=NULL;
valid_info= false; valid_info= false;
indexing= -1; indexing= -1;
...@@ -1969,7 +1969,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) ...@@ -1969,7 +1969,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
char *fmt; char *fmt;
int rc= 0; int rc= 0;
PCOL colp; PCOL colp;
PVAL value; PVAL value, sdvalin;
Field *fp; Field *fp;
PTDBASE tp= (PTDBASE)tdbp; PTDBASE tp= (PTDBASE)tdbp;
String attribute(attr_buffer, sizeof(attr_buffer), String attribute(attr_buffer, sizeof(attr_buffer),
...@@ -2012,25 +2012,45 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) ...@@ -2012,25 +2012,45 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
value->SetValue(fp->val_real()); value->SetValue(fp->val_real());
break; break;
case TYPE_DATE: case TYPE_DATE:
if (!sdvalin)
sdvalin= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
// Get date in the format produced by MySQL fields // Get date in the format produced by MySQL fields
switch (fp->type()) { switch (fp->type()) {
case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATE:
if (!sdvalin2) {
sdvalin2= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
fmt= "YYYY-MM-DD"; fmt= "YYYY-MM-DD";
((DTVAL*)sdvalin2)->SetFormat(g, fmt, strlen(fmt));
} // endif sdvalin1
sdvalin= sdvalin2;
break; break;
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
if (!sdvalin3) {
sdvalin3= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
fmt= "hh:mm:ss"; fmt= "hh:mm:ss";
((DTVAL*)sdvalin3)->SetFormat(g, fmt, strlen(fmt));
} // endif sdvalin1
sdvalin= sdvalin3;
break; break;
case MYSQL_TYPE_YEAR: case MYSQL_TYPE_YEAR:
if (!sdvalin4) {
sdvalin4= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
fmt= "YYYY"; fmt= "YYYY";
((DTVAL*)sdvalin4)->SetFormat(g, fmt, strlen(fmt));
} // endif sdvalin1
sdvalin= sdvalin4;
break; break;
default: default:
if (!sdvalin1) {
sdvalin1= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
fmt= "YYYY-MM-DD hh:mm:ss"; fmt= "YYYY-MM-DD hh:mm:ss";
((DTVAL*)sdvalin1)->SetFormat(g, fmt, strlen(fmt));
} // endif sdvalin1
sdvalin= sdvalin1;
} // endswitch type } // endswitch type
((DTVAL*)sdvalin)->SetFormat(g, fmt, strlen(fmt));
sdvalin->SetNullable(colp->IsNullable()); sdvalin->SetNullable(colp->IsNullable());
fp->val_str(&attribute); fp->val_str(&attribute);
sdvalin->SetValue_psz(attribute.c_ptr_safe()); sdvalin->SetValue_psz(attribute.c_ptr_safe());
......
...@@ -543,7 +543,10 @@ int index_prev(uchar *buf); ...@@ -543,7 +543,10 @@ int index_prev(uchar *buf);
query_id_t creat_query_id; // The one when handler was allocated query_id_t creat_query_id; // The one when handler was allocated
char *datapath; // Is the Path of DB data directory char *datapath; // Is the Path of DB data directory
PTDB tdbp; // To table class object PTDB tdbp; // To table class object
PVAL sdvalin; // Used to convert date values PVAL sdvalin1; // Used to convert date values
PVAL sdvalin2; // Used to convert date values
PVAL sdvalin3; // Used to convert date values
PVAL sdvalin4; // Used to convert date values
PVAL sdvalout; // Used to convert date values PVAL sdvalout; // Used to convert date values
bool istable; // True for table handler bool istable; // True for table handler
char partname[64]; // The partition name char partname[64]; // The partition name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment