Commit 19e9fa45 authored by Olivier Bertrand's avatar Olivier Bertrand

- Use all columns in case of INSERT so default values are generated for

  columns not specified in the statemant.

modified:
  storage/connect/ha_connect.cc
parent f81c60a4
...@@ -1322,52 +1322,55 @@ bool ha_connect::OpenTable(PGLOBAL g, bool del) ...@@ -1322,52 +1322,55 @@ bool ha_connect::OpenTable(PGLOBAL g, bool del)
break; break;
} // endswitch xmode } // endswitch xmode
// Get the list of used fields (columns) if (xmod != MODE_INSERT) {
char *p; // Get the list of used fields (columns)
unsigned int k1, k2, n1, n2; char *p;
Field* *field; unsigned int k1, k2, n1, n2;
MY_BITMAP *map= (xmod != MODE_INSERT) ? table->read_set : table->write_set; Field* *field;
MY_BITMAP *ump= (xmod == MODE_UPDATE) ? table->write_set : NULL; MY_BITMAP *map= table->read_set;
MY_BITMAP *ump= (xmod == MODE_UPDATE) ? table->write_set : NULL;
k1= k2= 0;
n1= n2= 1; // 1 is space for final null character k1= k2= 0;
n1= n2= 1; // 1 is space for final null character
for (field= table->field; *field; field++) {
if (bitmap_is_set(map, (*field)->field_index)) { for (field= table->field; *field; field++) {
n1+= (GetColNameLen(*field) + 1); if (bitmap_is_set(map, (*field)->field_index)) {
k1++; n1+= (GetColNameLen(*field) + 1);
} // endif k1++;
} // endif
if (ump && bitmap_is_set(ump, (*field)->field_index)) { if (ump && bitmap_is_set(ump, (*field)->field_index)) {
n2+= GetColNameLen(*field); n2+= GetColNameLen(*field);
k2++; k2++;
} // endif } // endif
} // endfor field } // endfor field
if (k1) { if (k1) {
p= c1= (char*)PlugSubAlloc(g, NULL, n1); p= c1= (char*)PlugSubAlloc(g, NULL, n1);
for (field= table->field; *field; field++) for (field= table->field; *field; field++)
if (bitmap_is_set(map, (*field)->field_index)) { if (bitmap_is_set(map, (*field)->field_index)) {
AddColName(p, *field); AddColName(p, *field);
p+= (strlen(p) + 1); p+= (strlen(p) + 1);
} // endif used field } // endif used field
*p= '\0'; // mark end of list
} // endif k1
*p= '\0'; // mark end of list if (k2) {
} // endif k1 p= c2= (char*)PlugSubAlloc(g, NULL, n2);
if (k2) { for (field= table->field; *field; field++)
p= c2= (char*)PlugSubAlloc(g, NULL, n2); if (bitmap_is_set(ump, (*field)->field_index)) {
AddColName(p, *field);
p+= (strlen(p) + 1);
} // endif used field
for (field= table->field; *field; field++) *p= '\0'; // mark end of list
if (bitmap_is_set(ump, (*field)->field_index)) { } // endif k2
AddColName(p, *field);
p+= (strlen(p) + 1);
} // endif used field
*p= '\0'; // mark end of list } // endif xmod
} // endif k2
// Open the table // Open the table
if (!(rc= CntOpenTable(g, tdbp, xmod, c1, c2, del, this))) { if (!(rc= CntOpenTable(g, tdbp, xmod, c1, c2, del, this))) {
...@@ -1571,7 +1574,8 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) ...@@ -1571,7 +1574,8 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
continue; // Is a virtual column possible here ??? continue; // Is a virtual column possible here ???
#endif // MARIADB #endif // MARIADB
if (bitmap_is_set(table->write_set, fp->field_index)) { if (xmod == MODE_INSERT ||
bitmap_is_set(table->write_set, fp->field_index)) {
for (colp= tp->GetSetCols(); colp; colp= colp->GetNext()) for (colp= tp->GetSetCols(); colp; colp= colp->GetNext())
if (!stricmp(colp->GetName(), fp->field_name)) if (!stricmp(colp->GetName(), fp->field_name))
break; break;
......
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