1 /* Copyright (c) 2011, 2021, 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 also distributed 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 included with MySQL.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License, version 2.0, for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
22 
23 // First include (the generated) my_config.h, to get correct platform defines.
24 #include "my_config.h"
25 #include <gtest/gtest.h>
26 #include "parsertest.h"
27 #include "test_utils.h"
28 #include "thr_lock.h"
29 #include "sql_lex.h"
30 
31 namespace insert_delayed_unittest {
32 
33 using my_testing::Server_initializer;
34 using my_testing::Mock_error_handler;
35 
36 class InsertDelayed : public ParserTest
37 {
38 protected:
SetUp()39   virtual void SetUp() { initializer.SetUp(); }
TearDown()40   virtual void TearDown() { initializer.TearDown(); }
41 };
42 
TEST_F(InsertDelayed,InsertDelayed)43 TEST_F(InsertDelayed, InsertDelayed)
44 {
45   SELECT_LEX *sl1=
46     parse("INSERT INTO t1 VALUES (1)", 0);
47 
48   thr_lock_type expected_lock_type= sl1->table_list.first->lock_type;
49 
50   SELECT_LEX *sl2=
51     parse("INSERT DELAYED INTO t1 VALUES (1)", ER_WARN_LEGACY_SYNTAX_CONVERTED);
52 
53   EXPECT_EQ(expected_lock_type, sl2->table_list.first->lock_type);
54 }
55 
TEST_F(InsertDelayed,ReplaceDelayed)56 TEST_F(InsertDelayed, ReplaceDelayed)
57 {
58   SELECT_LEX *sl1=
59     parse("REPLACE INTO t1 VALUES (1)", 0);
60 
61   thr_lock_type expected_lock_type= sl1->table_list.first->lock_type;
62 
63   SELECT_LEX *sl2=
64     parse("REPLACE DELAYED INTO t1 VALUES (1)", ER_WARN_LEGACY_SYNTAX_CONVERTED);
65 
66   EXPECT_EQ(expected_lock_type, sl2->table_list.first->lock_type);
67 }
68 
69 }
70