You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.2 KiB

  1. /*
  2. Copyright (c) 2020, MariaDB Corporation.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
  13. #include "mariadb.h"
  14. #include "sql_type.h"
  15. #include "sql_schema.h"
  16. #include "sql_class.h"
  17. class Schema_oracle: public Schema
  18. {
  19. public:
  20. Schema_oracle(const LEX_CSTRING &name)
  21. :Schema(name)
  22. { }
  23. const Type_handler *map_data_type(THD *thd, const Type_handler *src)
  24. const
  25. {
  26. if (src == &type_handler_newdate)
  27. return thd->type_handler_for_datetime();
  28. return src;
  29. }
  30. };
  31. class Schema_maxdb: public Schema
  32. {
  33. public:
  34. Schema_maxdb(const LEX_CSTRING &name)
  35. :Schema(name)
  36. { }
  37. const Type_handler *map_data_type(THD *thd, const Type_handler *src)
  38. const
  39. {
  40. if (src == &type_handler_timestamp ||
  41. src == &type_handler_timestamp2)
  42. return thd->type_handler_for_datetime();
  43. return src;
  44. }
  45. };
  46. Schema mariadb_schema(Lex_cstring(STRING_WITH_LEN("mariadb_schema")));
  47. Schema_oracle oracle_schema(Lex_cstring(STRING_WITH_LEN("oracle_schema")));
  48. Schema_maxdb maxdb_schema(Lex_cstring(STRING_WITH_LEN("maxdb_schema")));
  49. Schema *Schema::find_by_name(const LEX_CSTRING &name)
  50. {
  51. DBUG_ASSERT(name.str);
  52. if (mariadb_schema.eq_name(name))
  53. return &mariadb_schema;
  54. if (oracle_schema.eq_name(name))
  55. return &oracle_schema;
  56. if (maxdb_schema.eq_name(name))
  57. return &maxdb_schema;
  58. return NULL;
  59. }
  60. Schema *Schema::find_implied(THD *thd)
  61. {
  62. if (thd->variables.sql_mode & MODE_ORACLE)
  63. return &oracle_schema;
  64. if (thd->variables.sql_mode & MODE_MAXDB)
  65. return &maxdb_schema;
  66. return &mariadb_schema;
  67. }