mirror of
https://github.com/MariaDB/server.git
synced 2025-09-13 13:47:59 +03:00
MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ... SELECT in ORACLE mode
- Adding optional qualifiers to data types: CREATE TABLE t1 (a schema.DATE); Qualifiers now work only for three pre-defined schemas: mariadb_schema oracle_schema maxdb_schema These schemas are virtual (hard-coded) for now, but may turn into real databases on disk in the future. - mariadb_schema.TYPE now always resolves to a true MariaDB data type TYPE without sql_mode specific translations. - oracle_schema.DATE translates to MariaDB DATETIME. - maxdb_schema.TIMESTAMP translates to MariaDB DATETIME. - Fixing SHOW CREATE TABLE to use a qualifier for a data type TYPE if the current sql_mode translates TYPE to something else. The above changes fix the reported problem, so this script: SET sql_mode=ORACLE; CREATE TABLE t2 AS SELECT mariadb_date_column FROM t1; is now replicated as: SET sql_mode=ORACLE; CREATE TABLE t2 (mariadb_date_column mariadb_schema.DATE); and the slave can unambiguously treat DATE as the true MariaDB DATE without ORACLE specific translation to DATETIME. Similar, SET sql_mode=MAXDB; CREATE TABLE t2 AS SELECT mariadb_timestamp_column FROM t1; is now replicated as: SET sql_mode=MAXDB; CREATE TABLE t2 (mariadb_timestamp_column mariadb_schema.TIMESTAMP); so the slave treats TIMESTAMP as the true MariaDB TIMESTAMP without MAXDB specific translation to DATETIME.
This commit is contained in:
@@ -237,6 +237,7 @@ void
|
||||
st_parsing_options::reset()
|
||||
{
|
||||
allows_variable= TRUE;
|
||||
lookup_keywords_after_qualifier= false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1539,7 +1540,10 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd)
|
||||
yylval->lex_str.str= (char*) get_ptr();
|
||||
yylval->lex_str.length= 1;
|
||||
c= yyGet(); // should be '.'
|
||||
next_state= MY_LEX_IDENT_START; // Next is ident (not keyword)
|
||||
if (lex->parsing_options.lookup_keywords_after_qualifier)
|
||||
next_state= MY_LEX_IDENT_OR_KEYWORD;
|
||||
else
|
||||
next_state= MY_LEX_IDENT_START; // Next is ident (not keyword)
|
||||
if (!ident_map[(uchar) yyPeek()]) // Probably ` or "
|
||||
next_state= MY_LEX_START;
|
||||
return((int) c);
|
||||
@@ -8286,3 +8290,31 @@ bool LEX::tvc_finalize_derived()
|
||||
current_select->linkage= DERIVED_TABLE_TYPE;
|
||||
return tvc_finalize();
|
||||
}
|
||||
|
||||
|
||||
bool LEX::map_data_type(const Lex_ident_sys_st &schema_name,
|
||||
Lex_field_type_st *type) const
|
||||
{
|
||||
const Schema *schema= schema_name.str ?
|
||||
Schema::find_by_name(schema_name) :
|
||||
Schema::find_implied(thd);
|
||||
if (!schema)
|
||||
{
|
||||
char buf[128];
|
||||
const Name type_name= type->type_handler()->name();
|
||||
my_snprintf(buf, sizeof(buf), "%.*s.%.*s",
|
||||
(int) schema_name.length, schema_name.str,
|
||||
(int) type_name.length(), type_name.ptr());
|
||||
#if MYSQL_VERSION_ID > 100500
|
||||
#error Please remove the old code
|
||||
my_error(ER_UNKNOWN_DATA_TYPE, MYF(0), buf);
|
||||
#else
|
||||
my_printf_error(ER_UNKNOWN_ERROR, "Unknown data type: '%-.64s'",
|
||||
MYF(0), buf);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
const Type_handler *mapped= schema->map_data_type(thd, type->type_handler());
|
||||
type->set_handler(mapped);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user