diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2013-03-23 19:47:51 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2013-03-23 19:47:51 +0100 |
commit | 6a15b5f870585f4d35316a4851e1bf5264cf1918 (patch) | |
tree | eb5a1cbca76f2e175122466d23de2259ec13cf10 | |
parent | aa881ad59322568e3fbf93405d32643fd40bed16 (diff) | |
download | mariadb-git-6a15b5f870585f4d35316a4851e1bf5264cf1918.tar.gz |
- 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
-rw-r--r-- | storage/connect/global.h | 1 | ||||
-rw-r--r-- | storage/connect/ha_connect.cc | 34 | ||||
-rw-r--r-- | storage/connect/ha_connect.h | 1 | ||||
-rw-r--r-- | storage/connect/plugutil.c | 1 |
4 files changed, 30 insertions, 7 deletions
diff --git a/storage/connect/global.h b/storage/connect/global.h index 778f5cab2e9..f6296862738 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -219,6 +219,7 @@ typedef struct _global { /* Global structure */ PACTIVITY Activityp, ActivityStart; char Message[MAX_STR]; short Trace; + int Createas; /* To pass info to created table */ int jump_level; jmp_buf jumper[MAX_JUMP + 2]; } GLOBAL; diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 7b8fbb6eb5f..c6b72b46ee8 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -545,7 +545,6 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) valid_query_id= 0; creat_query_id= (table && table->in_use) ? table->in_use->query_id : 0; stop= false; - createas= false; indexing= -1; data_file_name= NULL; index_file_name= NULL; @@ -1065,8 +1064,7 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) pcf->Length= 256; // BLOB? if (fop) { - // Offset must be set to default when the table is created AS select - pcf->Offset= (createas) ? -1 : fop->offset; + pcf->Offset= fop->offset; // pcf->Freq= fop->freq; pcf->Datefmt= (char*)fop->dateformat; pcf->Fieldfmt= (char*)fop->fieldformat; @@ -3052,7 +3050,6 @@ int ha_connect::external_lock(THD *thd, int lock_type) if (newmode == MODE_WRITE) { switch (thd->lex->sql_command) { case SQLCOM_CREATE_TABLE: - createas= true; case SQLCOM_INSERT: case SQLCOM_LOAD: case SQLCOM_INSERT_SELECT: @@ -3098,8 +3095,9 @@ int ha_connect::external_lock(THD *thd, int lock_type) } else if (newmode == MODE_READ) { switch (thd->lex->sql_command) { - case SQLCOM_INSERT: case SQLCOM_CREATE_TABLE: + g->Createas= 1; // To tell created table to ignore FLAG + case SQLCOM_INSERT: case SQLCOM_LOAD: case SQLCOM_INSERT_SELECT: // case SQLCOM_REPLACE: @@ -3695,8 +3693,32 @@ bool ha_connect::pre_create(THD *thd, HA_CREATE_INFO *create_info, } // endif supfnc // 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; + } // endif elements if (ok) { char *length, *decimals, *cnm, *rem; diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index c2786e851c6..52361ba7122 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -395,7 +395,6 @@ protected: XINFO xinfo; // The table info structure bool valid_info; // True if xinfo is valid bool stop; // Used when creating index - bool createas; // True for CREATE TABLE ... AS SELECT int indexing; // Type of indexing for CONNECT #if !defined(MARIADB) PTOS table_options; diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 2455e73b1d2..0a0d48f67e4 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -150,6 +150,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize) } else { g->Sarea_Size = worksize; g->Trace = 0; + g->Createas = 0; g->Activityp = g->ActivityStart = NULL; strcpy(g->Message, ""); |