Browse Source
MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ... SELECT in ORACLE mode
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.
bb-10.3-MDEV-22543
28 changed files with 860 additions and 60 deletions
-
1libmysqld/CMakeLists.txt
-
10mysql-test/main/lowercase_fs_off.result
-
15mysql-test/main/lowercase_fs_off.test
-
1mysql-test/mysql-test-run.pl
-
65mysql-test/suite/compat/maxdb/rpl_mariadb_timestamp.result
-
34mysql-test/suite/compat/maxdb/rpl_mariadb_timestamp.test
-
53mysql-test/suite/compat/maxdb/type_timestamp.result
-
29mysql-test/suite/compat/maxdb/type_timestamp.test
-
86mysql-test/suite/compat/oracle/r/rpl_mariadb_date.result
-
150mysql-test/suite/compat/oracle/r/type_date.result
-
38mysql-test/suite/compat/oracle/t/rpl_mariadb_date.test
-
99mysql-test/suite/compat/oracle/t/type_date.test
-
1sql/CMakeLists.txt
-
13sql/field.cc
-
4sql/sql_class.cc
-
2sql/sql_class.h
-
34sql/sql_lex.cc
-
5sql/sql_lex.h
-
80sql/sql_schema.cc
-
70sql/sql_schema.h
-
7sql/sql_show.cc
-
4sql/sql_string.h
-
6sql/sql_type.cc
-
2sql/sql_type.h
-
50sql/sql_yacc.yy
-
55sql/sql_yacc_ora.yy
-
4sql/structs.h
-
2storage/test_sql_discovery/mysql-test/sql_discovery/simple.result
@ -0,0 +1,65 @@ |
|||||
|
include/master-slave.inc |
||||
|
[connection master] |
||||
|
# |
||||
|
# MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ... SELECT in ORACLE mode |
||||
|
# |
||||
|
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:00:00'); |
||||
|
SET sql_mode=DEFAULT; |
||||
|
CREATE TABLE t1 (a TIMESTAMP); |
||||
|
INSERT INTO t1 VALUES (NULL); |
||||
|
INSERT INTO t1 VALUES ('2001-01-01 10:20:30'); |
||||
|
SET sql_mode=MAXDB; |
||||
|
CREATE TABLE t2 SELECT * FROM t1; |
||||
|
SET timestamp=DEFAULT; |
||||
|
include/show_binlog_events.inc |
||||
|
Log_name Pos Event_type Server_id End_log_pos Info |
||||
|
master-bin.000001 # Gtid # # GTID #-#-# |
||||
|
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a TIMESTAMP) |
||||
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-# |
||||
|
master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (NULL) |
||||
|
master-bin.000001 # Table_map # # table_id: # (test.t1) |
||||
|
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
||||
|
master-bin.000001 # Query # # COMMIT |
||||
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-# |
||||
|
master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES ('2001-01-01 10:20:30') |
||||
|
master-bin.000001 # Table_map # # table_id: # (test.t1) |
||||
|
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
||||
|
master-bin.000001 # Query # # COMMIT |
||||
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-# |
||||
|
master-bin.000001 # Query # # use `test`; CREATE TABLE "t2" ( |
||||
|
"a" mariadb_schema.timestamp NOT NULL DEFAULT current_timestamp() |
||||
|
) |
||||
|
master-bin.000001 # Annotate_rows # # CREATE TABLE t2 SELECT * FROM t1 |
||||
|
master-bin.000001 # Table_map # # table_id: # (test.t2) |
||||
|
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
||||
|
master-bin.000001 # Query # # COMMIT |
||||
|
connection slave; |
||||
|
SELECT * FROM t1; |
||||
|
a |
||||
|
2001-01-01 10:00:00 |
||||
|
2001-01-01 10:20:30 |
||||
|
SET sql_mode=DEFAULT; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE `t1` ( |
||||
|
`a` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
SHOW CREATE TABLE t2; |
||||
|
Table Create Table |
||||
|
t2 CREATE TABLE `t2` ( |
||||
|
`a` timestamp NOT NULL DEFAULT current_timestamp() |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
SET sql_mode=MAXDB; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE "t1" ( |
||||
|
"a" mariadb_schema.timestamp NOT NULL DEFAULT current_timestamp() |
||||
|
) |
||||
|
SHOW CREATE TABLE t2; |
||||
|
Table Create Table |
||||
|
t2 CREATE TABLE "t2" ( |
||||
|
"a" mariadb_schema.timestamp NOT NULL DEFAULT current_timestamp() |
||||
|
) |
||||
|
connection master; |
||||
|
DROP TABLE t1, t2; |
||||
|
include/rpl_end.inc |
||||
@ -0,0 +1,34 @@ |
|||||
|
--source include/have_binlog_format_row.inc |
||||
|
--source include/master-slave.inc |
||||
|
|
||||
|
--echo # |
||||
|
--echo # MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ... SELECT in ORACLE mode |
||||
|
--echo # |
||||
|
|
||||
|
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:00:00'); |
||||
|
SET sql_mode=DEFAULT; |
||||
|
CREATE TABLE t1 (a TIMESTAMP); |
||||
|
INSERT INTO t1 VALUES (NULL); |
||||
|
INSERT INTO t1 VALUES ('2001-01-01 10:20:30'); |
||||
|
SET sql_mode=MAXDB; |
||||
|
CREATE TABLE t2 SELECT * FROM t1; |
||||
|
SET timestamp=DEFAULT; |
||||
|
|
||||
|
--let $binlog_file = LAST |
||||
|
source include/show_binlog_events.inc; |
||||
|
|
||||
|
|
||||
|
--sync_slave_with_master |
||||
|
SELECT * FROM t1; |
||||
|
SET sql_mode=DEFAULT; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
SHOW CREATE TABLE t2; |
||||
|
|
||||
|
SET sql_mode=MAXDB; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
SHOW CREATE TABLE t2; |
||||
|
|
||||
|
--connection master |
||||
|
DROP TABLE t1, t2; |
||||
|
|
||||
|
--source include/rpl_end.inc |
||||
@ -0,0 +1,53 @@ |
|||||
|
# |
||||
|
# MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ... SELECT in ORACLE mode |
||||
|
# |
||||
|
SET sql_mode=DEFAULT; |
||||
|
CREATE TABLE t1 ( |
||||
|
def_timestamp TIMESTAMP, |
||||
|
mdb_timestamp mariadb_schema.TIMESTAMP, |
||||
|
ora_timestamp oracle_schema.TIMESTAMP, |
||||
|
max_timestamp maxdb_schema.TIMESTAMP |
||||
|
); |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE `t1` ( |
||||
|
`def_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), |
||||
|
`mdb_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', |
||||
|
`ora_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', |
||||
|
`max_timestamp` datetime DEFAULT NULL |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
SET sql_mode=MAXDB; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE "t1" ( |
||||
|
"def_timestamp" mariadb_schema.timestamp NOT NULL DEFAULT current_timestamp(), |
||||
|
"mdb_timestamp" mariadb_schema.timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', |
||||
|
"ora_timestamp" mariadb_schema.timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', |
||||
|
"max_timestamp" datetime DEFAULT NULL |
||||
|
) |
||||
|
DROP TABLE t1; |
||||
|
SET sql_mode=MAXDB; |
||||
|
CREATE TABLE t1 ( |
||||
|
def_timestamp TIMESTAMP, |
||||
|
mdb_timestamp mariadb_schema.TIMESTAMP, |
||||
|
ora_timestamp oracle_schema.TIMESTAMP, |
||||
|
max_timestamp maxdb_schema.TIMESTAMP |
||||
|
); |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE "t1" ( |
||||
|
"def_timestamp" datetime DEFAULT NULL, |
||||
|
"mdb_timestamp" mariadb_schema.timestamp NOT NULL DEFAULT current_timestamp(), |
||||
|
"ora_timestamp" mariadb_schema.timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', |
||||
|
"max_timestamp" datetime DEFAULT NULL |
||||
|
) |
||||
|
SET sql_mode=DEFAULT; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE `t1` ( |
||||
|
`def_timestamp` datetime DEFAULT NULL, |
||||
|
`mdb_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), |
||||
|
`ora_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', |
||||
|
`max_timestamp` datetime DEFAULT NULL |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
DROP TABLE t1; |
||||
@ -0,0 +1,29 @@ |
|||||
|
--echo # |
||||
|
--echo # MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ... SELECT in ORACLE mode |
||||
|
--echo # |
||||
|
|
||||
|
|
||||
|
SET sql_mode=DEFAULT; |
||||
|
CREATE TABLE t1 ( |
||||
|
def_timestamp TIMESTAMP, |
||||
|
mdb_timestamp mariadb_schema.TIMESTAMP, |
||||
|
ora_timestamp oracle_schema.TIMESTAMP, |
||||
|
max_timestamp maxdb_schema.TIMESTAMP |
||||
|
); |
||||
|
SHOW CREATE TABLE t1; |
||||
|
SET sql_mode=MAXDB; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
DROP TABLE t1; |
||||
|
|
||||
|
|
||||
|
SET sql_mode=MAXDB; |
||||
|
CREATE TABLE t1 ( |
||||
|
def_timestamp TIMESTAMP, |
||||
|
mdb_timestamp mariadb_schema.TIMESTAMP, |
||||
|
ora_timestamp oracle_schema.TIMESTAMP, |
||||
|
max_timestamp maxdb_schema.TIMESTAMP |
||||
|
); |
||||
|
SHOW CREATE TABLE t1; |
||||
|
SET sql_mode=DEFAULT; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
DROP TABLE t1; |
||||
@ -0,0 +1,86 @@ |
|||||
|
include/master-slave.inc |
||||
|
[connection master] |
||||
|
SET SQL_MODE=DEFAULT; |
||||
|
CREATE TABLE t1 (a DATE); |
||||
|
INSERT INTO t1 VALUES (NULL); |
||||
|
INSERT INTO t1 VALUES ('2001-01-01'); |
||||
|
SET SQL_MODE= ORACLE; |
||||
|
CREATE TABLE t2 SELECT * FROM t1; |
||||
|
include/show_binlog_events.inc |
||||
|
Log_name Pos Event_type Server_id End_log_pos Info |
||||
|
master-bin.000001 # Gtid # # GTID #-#-# |
||||
|
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a DATE) |
||||
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-# |
||||
|
master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (NULL) |
||||
|
master-bin.000001 # Table_map # # table_id: # (test.t1) |
||||
|
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
||||
|
master-bin.000001 # Query # # COMMIT |
||||
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-# |
||||
|
master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES ('2001-01-01') |
||||
|
master-bin.000001 # Table_map # # table_id: # (test.t1) |
||||
|
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
||||
|
master-bin.000001 # Query # # COMMIT |
||||
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-# |
||||
|
master-bin.000001 # Query # # use `test`; CREATE TABLE "t2" ( |
||||
|
"a" mariadb_schema.date DEFAULT NULL |
||||
|
) |
||||
|
master-bin.000001 # Annotate_rows # # CREATE TABLE t2 SELECT * FROM t1 |
||||
|
master-bin.000001 # Table_map # # table_id: # (test.t2) |
||||
|
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
||||
|
master-bin.000001 # Query # # COMMIT |
||||
|
SET SQL_MODE= DEFAULT; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE `t1` ( |
||||
|
`a` date DEFAULT NULL |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
SHOW CREATE TABLE t2; |
||||
|
Table Create Table |
||||
|
t2 CREATE TABLE `t2` ( |
||||
|
`a` date DEFAULT NULL |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
SET SQL_MODE= ORACLE; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE "t1" ( |
||||
|
"a" mariadb_schema.date DEFAULT NULL |
||||
|
) |
||||
|
SHOW CREATE TABLE t2; |
||||
|
Table Create Table |
||||
|
t2 CREATE TABLE "t2" ( |
||||
|
"a" mariadb_schema.date DEFAULT NULL |
||||
|
) |
||||
|
connection slave; |
||||
|
SELECT * FROM t1; |
||||
|
a |
||||
|
NULL |
||||
|
2001-01-01 |
||||
|
SELECT * FROM t2; |
||||
|
a |
||||
|
NULL |
||||
|
2001-01-01 |
||||
|
SET SQL_MODE= DEFAULT; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE `t1` ( |
||||
|
`a` date DEFAULT NULL |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
SHOW CREATE TABLE t2; |
||||
|
Table Create Table |
||||
|
t2 CREATE TABLE `t2` ( |
||||
|
`a` date DEFAULT NULL |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
SET SQL_MODE= ORACLE; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
Table Create Table |
||||
|
t1 CREATE TABLE "t1" ( |
||||
|
"a" mariadb_schema.date DEFAULT NULL |
||||
|
) |
||||
|
SHOW CREATE TABLE t2; |
||||
|
Table Create Table |
||||
|
t2 CREATE TABLE "t2" ( |
||||
|
"a" mariadb_schema.date DEFAULT NULL |
||||
|
) |
||||
|
connection master; |
||||
|
DROP TABLE t1, t2; |
||||
|
include/rpl_end.inc |
||||
@ -0,0 +1,38 @@ |
|||||
|
--source include/have_binlog_format_row.inc |
||||
|
--source include/master-slave.inc |
||||
|
|
||||
|
SET SQL_MODE=DEFAULT; |
||||
|
CREATE TABLE t1 (a DATE); |
||||
|
INSERT INTO t1 VALUES (NULL); |
||||
|
INSERT INTO t1 VALUES ('2001-01-01'); |
||||
|
|
||||
|
SET SQL_MODE= ORACLE; |
||||
|
CREATE TABLE t2 SELECT * FROM t1; |
||||
|
|
||||
|
--let $binlog_file = LAST |
||||
|
source include/show_binlog_events.inc; |
||||
|
|
||||
|
SET SQL_MODE= DEFAULT; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
SHOW CREATE TABLE t2; |
||||
|
|
||||
|
SET SQL_MODE= ORACLE; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
SHOW CREATE TABLE t2; |
||||
|
|
||||
|
--sync_slave_with_master |
||||
|
SELECT * FROM t1; |
||||
|
SELECT * FROM t2; |
||||
|
|
||||
|
SET SQL_MODE= DEFAULT; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
SHOW CREATE TABLE t2; |
||||
|
|
||||
|
SET SQL_MODE= ORACLE; |
||||
|
SHOW CREATE TABLE t1; |
||||
|
SHOW CREATE TABLE t2; |
||||
|
|
||||
|
# Cleanup |
||||
|
--connection master |
||||
|
DROP TABLE t1, t2; |
||||
|
--source include/rpl_end.inc |
||||
@ -0,0 +1,80 @@ |
|||||
|
/*
|
||||
|
Copyright (c) 2020, MariaDB Corporation. |
||||
|
|
||||
|
This program is free software; you can redistribute it and/or modify |
||||
|
it under the terms of the GNU General Public License as published by |
||||
|
the Free Software Foundation; version 2 of the License. |
||||
|
|
||||
|
This program is distributed in the hope that it will be useful, |
||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
GNU General Public License for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License |
||||
|
along with this program; if not, write to the Free Software |
||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ |
||||
|
|
||||
|
#include "mariadb.h"
|
||||
|
#include "sql_type.h"
|
||||
|
#include "sql_schema.h"
|
||||
|
#include "sql_class.h"
|
||||
|
|
||||
|
class Schema_oracle: public Schema |
||||
|
{ |
||||
|
public: |
||||
|
Schema_oracle(const LEX_CSTRING &name) |
||||
|
:Schema(name) |
||||
|
{ } |
||||
|
const Type_handler *map_data_type(THD *thd, const Type_handler *src) |
||||
|
const |
||||
|
{ |
||||
|
if (src == &type_handler_newdate) |
||||
|
return thd->type_handler_for_datetime(); |
||||
|
return src; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
class Schema_maxdb: public Schema |
||||
|
{ |
||||
|
public: |
||||
|
Schema_maxdb(const LEX_CSTRING &name) |
||||
|
:Schema(name) |
||||
|
{ } |
||||
|
const Type_handler *map_data_type(THD *thd, const Type_handler *src) |
||||
|
const |
||||
|
{ |
||||
|
if (src == &type_handler_timestamp || |
||||
|
src == &type_handler_timestamp2) |
||||
|
return thd->type_handler_for_datetime(); |
||||
|
return src; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
Schema mariadb_schema(Lex_cstring(STRING_WITH_LEN("mariadb_schema"))); |
||||
|
Schema_oracle oracle_schema(Lex_cstring(STRING_WITH_LEN("oracle_schema"))); |
||||
|
Schema_maxdb maxdb_schema(Lex_cstring(STRING_WITH_LEN("maxdb_schema"))); |
||||
|
|
||||
|
|
||||
|
Schema *Schema::find_by_name(const LEX_CSTRING &name) |
||||
|
{ |
||||
|
DBUG_ASSERT(name.str); |
||||
|
if (mariadb_schema.eq_name(name)) |
||||
|
return &mariadb_schema; |
||||
|
if (oracle_schema.eq_name(name)) |
||||
|
return &oracle_schema; |
||||
|
if (maxdb_schema.eq_name(name)) |
||||
|
return &maxdb_schema; |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Schema *Schema::find_implied(THD *thd) |
||||
|
{ |
||||
|
if (thd->variables.sql_mode & MODE_ORACLE) |
||||
|
return &oracle_schema; |
||||
|
if (thd->variables.sql_mode & MODE_MAXDB) |
||||
|
return &maxdb_schema; |
||||
|
return &mariadb_schema; |
||||
|
} |
||||
@ -0,0 +1,70 @@ |
|||||
|
#ifndef SQL_SCHEMA_H_INCLUDED |
||||
|
#define SQL_SCHEMA_H_INCLUDED |
||||
|
/* |
||||
|
Copyright (c) 2020, MariaDB Corporation. |
||||
|
|
||||
|
This program is free software; you can redistribute it and/or modify |
||||
|
it under the terms of the GNU General Public License as published by |
||||
|
the Free Software Foundation; version 2 of the License. |
||||
|
|
||||
|
This program is distributed in the hope that it will be useful, |
||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
GNU General Public License for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License |
||||
|
along with this program; if not, write to the Free Software |
||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ |
||||
|
|
||||
|
#include "mysqld.h" |
||||
|
#include "lex_string.h" |
||||
|
|
||||
|
class Schema |
||||
|
{ |
||||
|
LEX_CSTRING m_name; |
||||
|
public: |
||||
|
Schema(const LEX_CSTRING &name) |
||||
|
:m_name(name) |
||||
|
{ } |
||||
|
virtual ~Schema() { } |
||||
|
const LEX_CSTRING &name() const { return m_name; } |
||||
|
virtual const Type_handler *map_data_type(THD *thd, const Type_handler *src) |
||||
|
const |
||||
|
{ |
||||
|
return src; |
||||
|
} |
||||
|
/* |
||||
|
For now we have *hard-coded* compatibility schemas: |
||||
|
schema_mariadb, schema_oracle, schema_maxdb. |
||||
|
But eventually we'll turn then into real databases on disk. |
||||
|
So the code below compares names according to the filesystem |
||||
|
case sensitivity, like it is done for regular databases. |
||||
|
|
||||
|
Note, this is different to information_schema, whose name |
||||
|
is always case insensitive. This is intentional! |
||||
|
The assymetry will be gone when we'll implement SQL standard |
||||
|
regular and delimited identifiers. |
||||
|
*/ |
||||
|
bool eq_name(const LEX_CSTRING &name) const |
||||
|
{ |
||||
|
#if MYSQL_VERSION_ID > 100500 |
||||
|
#error Remove the old code |
||||
|
return !table_alias_charset->strnncoll(m_name.str, m_name.length, |
||||
|
name.str, name.length); |
||||
|
#else |
||||
|
// Please remove this when merging to 10.5 |
||||
|
return !table_alias_charset->coll->strnncoll(table_alias_charset, |
||||
|
(const uchar *) m_name.str, |
||||
|
m_name.length, |
||||
|
(const uchar *) name.str, |
||||
|
name.length, FALSE); |
||||
|
#endif |
||||
|
} |
||||
|
static Schema *find_by_name(const LEX_CSTRING &name); |
||||
|
static Schema *find_implied(THD *thd); |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
extern Schema mariadb_schema; |
||||
|
|
||||
|
#endif // SQL_SCHEMA_H_INCLUDED |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue