1 #ifndef SQL_SCHEMA_H_INCLUDED
2 #define SQL_SCHEMA_H_INCLUDED
3 /*
4  Copyright (c) 2020, MariaDB Corporation.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; version 2 of the License.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335  USA */
18 
19 #include "mysqld.h"
20 #include "lex_string.h"
21 
22 class Schema
23 {
24   LEX_CSTRING m_name;
25 public:
Schema(const LEX_CSTRING & name)26   Schema(const LEX_CSTRING &name)
27    :m_name(name)
28   { }
~Schema()29   virtual ~Schema() { }
name()30   const LEX_CSTRING &name() const { return m_name; }
map_data_type(THD * thd,const Type_handler * src)31   virtual const Type_handler *map_data_type(THD *thd, const Type_handler *src)
32                                             const
33   {
34     return src;
35   }
36   /*
37     For now we have *hard-coded* compatibility schemas:
38       schema_mariadb, schema_oracle, schema_maxdb.
39     But eventually we'll turn then into real databases on disk.
40     So the code below compares names according to the filesystem
41     case sensitivity, like it is done for regular databases.
42 
43     Note, this is different to information_schema, whose name
44     is always case insensitive. This is intentional!
45     The assymetry will be gone when we'll implement SQL standard
46     regular and delimited identifiers.
47   */
eq_name(const LEX_CSTRING & name)48   bool eq_name(const LEX_CSTRING &name) const
49   {
50 #if MYSQL_VERSION_ID > 100500
51 #error Remove the old code
52     return !table_alias_charset->strnncoll(m_name.str, m_name.length,
53                                            name.str, name.length);
54 #else
55     // Please remove this when merging to 10.5
56     return !table_alias_charset->coll->strnncoll(table_alias_charset,
57                                                  (const uchar *) m_name.str,
58                                                  m_name.length,
59                                                  (const uchar *) name.str,
60                                                  name.length, FALSE);
61 #endif
62   }
63   static Schema *find_by_name(const LEX_CSTRING &name);
64   static Schema *find_implied(THD *thd);
65 };
66 
67 
68 extern Schema mariadb_schema;
69 
70 #endif // SQL_SCHEMA_H_INCLUDED
71