summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2019-12-04 23:37:04 +0200
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2019-12-04 23:37:04 +0200
commita3514c50dc8a517531e76233065eb0d84bde4b9f (patch)
treecb6833d8011ed69f311fa5ae99eb54d08dc0049c /sql/table.cc
parentcfa76e7750e8ef7eedc3cd55a1126b90abade054 (diff)
downloadmariadb-git-10.3-vicentiu.tar.gz
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc62
1 files changed, 34 insertions, 28 deletions
diff --git a/sql/table.cc b/sql/table.cc
index c64fb8ca821..1966c68898f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1804,6 +1804,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
Field::utype unireg_check;
const Type_handler *handler;
uint32 flags= 0;
+ bool handle_field_as_mysql_json= false;
if (new_frm_ver >= 3)
{
@@ -1856,36 +1857,39 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
}
-/*
- Special handling to be able to read MySQL JSON types when
- converting a MySQL table (MyISAM) to MariaDB table.
-*/
- if (share->mysql_version >= 50700 &&
- share->mysql_version < 100000 &&
- strpos[13] == (uchar) MYSQL_TYPE_VIRTUAL)
- {
- if(thd->lex->sql_command != SQLCOM_ALTER_TABLE) /* ||
- thd->lex->alter_info.flags != ALTER_RECREATE ||
- thd->lex->alter_info.flags != )
- */
- {
- // Raise an error for every operation expect `alter table <table_name> force`
- mysql_table_to_upgrade=1;
- goto err;
- }
- field_type= MYSQL_TYPE_LONG_BLOB;
- }
- else if ((uchar)field_type == (uchar)MYSQL_TYPE_VIRTUAL)
+ if ((uchar)field_type == (uchar)MYSQL_TYPE_VIRTUAL)
{
- if (!interval_nr) // Expect non-null expression
- goto err;
/*
- MariaDB version 10.0 version.
- The interval_id byte in the .frm file stores the length of the
- expression statement for a virtual column.
+ Special handling to be able to read MySQL JSON types when
+ converting a MySQL table to a MariaDB table. MYSQL_TYPE_VIRTUAL
+ has the same value as MySQL's JSON type number, which we should
+ interpret as a special long blob.
*/
- vcol_info_length= interval_nr;
- interval_nr= 0;
+ if (unlikely(share->mysql_version >= 50700 &&
+ share->mysql_version < 100000))
+ {
+ if(thd->lex->sql_command != SQLCOM_ALTER_TABLE ||
+ thd->lex->alter_info.flags != ALTER_RECREATE)
+ {
+ // Raise an error for every operation except `alter table force`.
+ mysql_table_to_upgrade=1;
+ goto err;
+ }
+ handle_field_as_mysql_json= true;
+ field_type= MYSQL_TYPE_LONG_BLOB;
+ }
+ else
+ {
+ if (!interval_nr) // Expect non-null expression
+ goto err;
+ /*
+ MariaDB version 10.0 version.
+ The interval_id byte in the .frm file stores the length of the
+ expression statement for a virtual column.
+ */
+ vcol_info_length= interval_nr;
+ interval_nr= 0;
+ }
}
if (!comment_length)
@@ -2067,7 +2071,9 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
unireg_check= (Field::utype) MTYP_TYPENR(unireg_type);
name.str= fieldnames.type_names[i];
name.length= strlen(name.str);
- if (!(handler= Type_handler::get_handler_by_real_type(field_type)))
+ if (handle_field_as_mysql_json)
+ handler= &type_handler_mysql_json;
+ else if (!(handler= Type_handler::get_handler_by_real_type(field_type)))
goto err; // Not supported field type
*field_ptr= reg_field=
make_field(share, &share->mem_root, record+recpos, (uint32) field_length,