| 1 | /* Copyright (c) 2016, 2026, Oracle and/or its affiliates. |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or modify |
| 4 | it under the terms of the GNU General Public License, version 2.0, |
| 5 | as published by the Free Software Foundation. |
| 6 | |
| 7 | This program is designed to work with certain software (including |
| 8 | but not limited to OpenSSL) that is licensed under separate terms, |
| 9 | as designated in a particular file or component or in included license |
| 10 | documentation. The authors of MySQL hereby grant you an additional |
| 11 | permission to link the program and your derivative works with the |
| 12 | separately licensed software that they have either included with |
| 13 | the program or referenced in the documentation. |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License, version 2.0, for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with this program; if not, write to the Free Software |
| 22 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 | */ |
| 24 | |
| 25 | #include "my_config.h" |
| 26 | |
| 27 | #include <gtest/gtest.h> |
| 28 | |
| 29 | #include "sql/mysqld.h" |
| 30 | #include "unittest/gunit/parsertest.h" |
| 31 | |
| 32 | namespace character_set_deprecation_unittest { |
| 33 | |
| 34 | /** |
| 35 | Test testing the hypothetical situation that the National character |
| 36 | set is not "utf8". There should not be any warning in that case, which |
| 37 | parse(const char*) makes sure of. The set-up involves changing a global |
| 38 | variable, so we can't test it in MTR. |
| 39 | */ |
| 40 | class CharacterSetDeprecationTest : public ParserTest { |
| 41 | protected: |
| 42 | void SetUp() override { |
| 43 | ParserTest::SetUp(); |
| 44 | thd()->lex->will_contextualize = false; |
| 45 | m_saved_cs = national_charset_info; |
| 46 | national_charset_info = &my_charset_bin; |
| 47 | } |
| 48 | |
| 49 | void TearDown() override { |
| 50 | ParserTest::TearDown(); |
| 51 | national_charset_info = m_saved_cs; |
| 52 | } |
| 53 | |
| 54 | private: |
| 55 | CHARSET_INFO *m_saved_cs; |
| 56 | }; |
| 57 | |
| 58 | TEST_F(CharacterSetDeprecationTest, National) { |
| 59 | parse("SELECT n'abc'"); |
| 60 | parse("CREATE TABLE t ( a NATIONAL CHAR(1) )"); |
| 61 | parse("CREATE TABLE t ( a NCHAR(1) )"); |
| 62 | parse("CREATE TABLE t ( a NVARCHAR(1) )"); |
| 63 | } |
| 64 | |
| 65 | } // namespace character_set_deprecation_unittest |