Commit 6a15b5f8 authored by Olivier Bertrand's avatar Olivier Bertrand

- Wrong FLAG values transmitted to created table by the AS SELECT table:

  It is not enough to ignore the flags while populating the table. They have
  to be removed from the definition in pre_create. The issue is to pass the
  info from the selected table handler to the created table handler.
  It is done via the only common item between them: the GLOBAL structure.

modified:
  storage/connect/global.h
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
  storage/connect/plugutil.c
parent aa881ad5
...@@ -219,6 +219,7 @@ typedef struct _global { /* Global structure */ ...@@ -219,6 +219,7 @@ typedef struct _global { /* Global structure */
PACTIVITY Activityp, ActivityStart; PACTIVITY Activityp, ActivityStart;
char Message[MAX_STR]; char Message[MAX_STR];
short Trace; short Trace;
int Createas; /* To pass info to created table */
int jump_level; int jump_level;
jmp_buf jumper[MAX_JUMP + 2]; jmp_buf jumper[MAX_JUMP + 2];
} GLOBAL; } GLOBAL;
......
...@@ -545,7 +545,6 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) ...@@ -545,7 +545,6 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
valid_query_id= 0; valid_query_id= 0;
creat_query_id= (table && table->in_use) ? table->in_use->query_id : 0; creat_query_id= (table && table->in_use) ? table->in_use->query_id : 0;
stop= false; stop= false;
createas= false;
indexing= -1; indexing= -1;
data_file_name= NULL; data_file_name= NULL;
index_file_name= NULL; index_file_name= NULL;
...@@ -1065,8 +1064,7 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) ...@@ -1065,8 +1064,7 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf)
pcf->Length= 256; // BLOB? pcf->Length= 256; // BLOB?
if (fop) { if (fop) {
// Offset must be set to default when the table is created AS select pcf->Offset= fop->offset;
pcf->Offset= (createas) ? -1 : fop->offset;
// pcf->Freq= fop->freq; // pcf->Freq= fop->freq;
pcf->Datefmt= (char*)fop->dateformat; pcf->Datefmt= (char*)fop->dateformat;
pcf->Fieldfmt= (char*)fop->fieldformat; pcf->Fieldfmt= (char*)fop->fieldformat;
...@@ -3052,7 +3050,6 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -3052,7 +3050,6 @@ int ha_connect::external_lock(THD *thd, int lock_type)
if (newmode == MODE_WRITE) { if (newmode == MODE_WRITE) {
switch (thd->lex->sql_command) { switch (thd->lex->sql_command) {
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
createas= true;
case SQLCOM_INSERT: case SQLCOM_INSERT:
case SQLCOM_LOAD: case SQLCOM_LOAD:
case SQLCOM_INSERT_SELECT: case SQLCOM_INSERT_SELECT:
...@@ -3098,8 +3095,9 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -3098,8 +3095,9 @@ int ha_connect::external_lock(THD *thd, int lock_type)
} else if (newmode == MODE_READ) { } else if (newmode == MODE_READ) {
switch (thd->lex->sql_command) { switch (thd->lex->sql_command) {
case SQLCOM_INSERT:
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
g->Createas= 1; // To tell created table to ignore FLAG
case SQLCOM_INSERT:
case SQLCOM_LOAD: case SQLCOM_LOAD:
case SQLCOM_INSERT_SELECT: case SQLCOM_INSERT_SELECT:
// case SQLCOM_REPLACE: // case SQLCOM_REPLACE:
...@@ -3695,8 +3693,32 @@ bool ha_connect::pre_create(THD *thd, HA_CREATE_INFO *create_info, ...@@ -3695,8 +3693,32 @@ bool ha_connect::pre_create(THD *thd, HA_CREATE_INFO *create_info,
} // endif supfnc } // endif supfnc
// Test whether columns must be specified // Test whether columns must be specified
if (alter_info->create_list.elements) if (alter_info->create_list.elements) {
if (g->Createas) {
// This table is created AS SELECT
// The sourcetable FLAG values have been passed to the created
// table columns but they must be removed to get default offsets.
List_iterator<Create_field> it(alter_info->create_list);
Create_field *field;
engine_option_value *vop, *pop;
while ((field= it++))
for (pop= NULL, vop= field->option_list; vop; vop= vop->next)
if (!stricmp(vop->name.str, "FLAG")) {
if (pop)
pop->next= vop->next;
else
field->option_list= vop->next;
break;
} else
pop= vop;
g->Createas= 0;
} // endif Createas
return false; return false;
} // endif elements
if (ok) { if (ok) {
char *length, *decimals, *cnm, *rem; char *length, *decimals, *cnm, *rem;
......
...@@ -395,7 +395,6 @@ protected: ...@@ -395,7 +395,6 @@ protected:
XINFO xinfo; // The table info structure XINFO xinfo; // The table info structure
bool valid_info; // True if xinfo is valid bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index bool stop; // Used when creating index
bool createas; // True for CREATE TABLE ... AS SELECT
int indexing; // Type of indexing for CONNECT int indexing; // Type of indexing for CONNECT
#if !defined(MARIADB) #if !defined(MARIADB)
PTOS table_options; PTOS table_options;
......
...@@ -150,6 +150,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize) ...@@ -150,6 +150,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
} else { } else {
g->Sarea_Size = worksize; g->Sarea_Size = worksize;
g->Trace = 0; g->Trace = 0;
g->Createas = 0;
g->Activityp = g->ActivityStart = NULL; g->Activityp = g->ActivityStart = NULL;
strcpy(g->Message, ""); strcpy(g->Message, "");
......
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