summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2015-01-09 23:36:50 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2015-01-09 23:36:50 +0100
commit85c65f4e1caa0dd28bc279ee1e83712f57ba3747 (patch)
tree93ea06ef1bd6aaf459ca933b82d4349bf7bcef71
parentd4bf64556ea8f8b5f4be052d683e87727aad872d (diff)
downloadmariadb-git-85c65f4e1caa0dd28bc279ee1e83712f57ba3747.tar.gz
- 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
-rw-r--r--storage/connect/ha_connect.cc42
-rw-r--r--storage/connect/ha_connect.h5
2 files changed, 35 insertions, 12 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 9c847b1d250..d6738a0eb8b 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -714,7 +714,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
datapath= "./";
#endif // !WIN32
tdbp= NULL;
- sdvalin= NULL;
+ sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
sdvalout= NULL;
xmod= MODE_ANY;
istable= false;
@@ -1815,7 +1815,7 @@ int ha_connect::CloseTable(PGLOBAL g)
{
int rc= CntCloseTable(g, tdbp, nox, abort);
tdbp= NULL;
- sdvalin=NULL;
+ sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
sdvalout=NULL;
valid_info= false;
indexing= -1;
@@ -1969,7 +1969,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
char *fmt;
int rc= 0;
PCOL colp;
- PVAL value;
+ PVAL value, sdvalin;
Field *fp;
PTDBASE tp= (PTDBASE)tdbp;
String attribute(attr_buffer, sizeof(attr_buffer),
@@ -2012,25 +2012,45 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
value->SetValue(fp->val_real());
break;
case TYPE_DATE:
- if (!sdvalin)
- sdvalin= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
-
// Get date in the format produced by MySQL fields
switch (fp->type()) {
case MYSQL_TYPE_DATE:
- fmt= "YYYY-MM-DD";
+ if (!sdvalin2) {
+ sdvalin2= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
+ fmt= "YYYY-MM-DD";
+ ((DTVAL*)sdvalin2)->SetFormat(g, fmt, strlen(fmt));
+ } // endif sdvalin1
+
+ sdvalin= sdvalin2;
break;
case MYSQL_TYPE_TIME:
- fmt= "hh:mm:ss";
+ if (!sdvalin3) {
+ sdvalin3= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
+ fmt= "hh:mm:ss";
+ ((DTVAL*)sdvalin3)->SetFormat(g, fmt, strlen(fmt));
+ } // endif sdvalin1
+
+ sdvalin= sdvalin3;
break;
case MYSQL_TYPE_YEAR:
- fmt= "YYYY";
+ if (!sdvalin4) {
+ sdvalin4= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
+ fmt= "YYYY";
+ ((DTVAL*)sdvalin4)->SetFormat(g, fmt, strlen(fmt));
+ } // endif sdvalin1
+
+ sdvalin= sdvalin4;
break;
default:
- fmt= "YYYY-MM-DD hh:mm:ss";
+ if (!sdvalin1) {
+ sdvalin1= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
+ fmt= "YYYY-MM-DD hh:mm:ss";
+ ((DTVAL*)sdvalin1)->SetFormat(g, fmt, strlen(fmt));
+ } // endif sdvalin1
+
+ sdvalin= sdvalin1;
} // endswitch type
- ((DTVAL*)sdvalin)->SetFormat(g, fmt, strlen(fmt));
sdvalin->SetNullable(colp->IsNullable());
fp->val_str(&attribute);
sdvalin->SetValue_psz(attribute.c_ptr_safe());
diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h
index 6c3ed87d5f6..922a69a3991 100644
--- a/storage/connect/ha_connect.h
+++ b/storage/connect/ha_connect.h
@@ -543,7 +543,10 @@ protected:
query_id_t creat_query_id; // The one when handler was allocated
char *datapath; // Is the Path of DB data directory
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
bool istable; // True for table handler
char partname[64]; // The partition name