Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
7355f7b1
Commit
7355f7b1
authored
Apr 07, 2022
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding MTR tests to cover how keywords of different kinds behave in various contexts
parent
e9735a81
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
498 additions
and
0 deletions
+498
-0
mysql-test/main/keywords.result
mysql-test/main/keywords.result
+421
-0
mysql-test/main/keywords.test
mysql-test/main/keywords.test
+77
-0
No files found.
mysql-test/main/keywords.result
View file @
7355f7b1
This diff is collapsed.
Click to expand it.
mysql-test/main/keywords.test
View file @
7355f7b1
...
...
@@ -295,3 +295,80 @@ BEGIN NOT ATOMIC
END
$$
DELIMITER
;
$$
--
echo
#
--
echo
# Testing various keywords in various contexts
--
echo
#
DELIMITER
$$
;
CREATE
PROCEDURE
p1
(
query
TEXT
,
var
TEXT
)
BEGIN
DECLARE
errmsg
TEXT
DEFAULT
''
;
DECLARE
CONTINUE
HANDLER
FOR
SQLEXCEPTION
BEGIN
GET
DIAGNOSTICS
CONDITION
1
errmsg
=
MESSAGE_TEXT
;
SET
errmsg
=
REPLACE
(
errmsg
,
'You have an error in your SQL '
,
'..'
);
SET
errmsg
=
REPLACE
(
errmsg
,
'; check the manual that corresponds to your MariaDB server version for the right syntax to use'
,
'..'
);
END
;
SET
query
=
REPLACE
(
query
,
'$(VAR)'
,
var
);
EXECUTE
IMMEDIATE
query
;
SELECT
CONCAT
(
query
,
'; -- '
,
LEFT
(
COALESCE
(
errmsg
,
''
),
40
))
AS
`--------`
;
END
;
$$
CREATE
PROCEDURE
p2
(
query
TEXT
)
BEGIN
FOR
row
IN
(
SELECT
word
FROM
t1
ORDER
BY
category
,
word
)
DO
CALL
p1
(
query
,
row
.
word
);
END
FOR
;
END
;
$$
DELIMITER
;
$$
CREATE
TABLE
t1
(
word
TEXT
,
category
TEXT
);
INSERT
INTO
t1
VALUES
(
'non_keyword'
,
'00 Simple identifier'
);
INSERT
INTO
t1
VALUES
(
'lpad'
,
'01 Built-in native function'
);
INSERT
INTO
t1
VALUES
(
'rpad'
,
'01 Built-in native function'
);
INSERT
INTO
t1
VALUES
(
'adddate'
,
'02 function_call_nonkeyword'
);
INSERT
INTO
t1
VALUES
(
'substr'
,
'02 function_call_nonkeyword'
);
INSERT
INTO
t1
VALUES
(
'substring'
,
'02 function_call_nonkeyword'
);
INSERT
INTO
t1
VALUES
(
'trim_oracle'
,
'02 function_call_nonkeyword'
);
INSERT
INTO
t1
VALUES
(
'ascii'
,
'03 function_call_conflict'
);
INSERT
INTO
t1
VALUES
(
'replace'
,
'03 function_call_conflict'
);
INSERT
INTO
t1
VALUES
(
'weight_string'
,
'03 function_call_conflict'
);
INSERT
INTO
t1
VALUES
(
'char'
,
'04 function_call_keyword'
);
INSERT
INTO
t1
VALUES
(
'trim'
,
'04 function_call_keyword'
);
INSERT
INTO
t1
VALUES
(
'year'
,
'04 function_call_keyword'
);
INSERT
INTO
t1
VALUES
(
'create'
,
'05 Reserved keyword'
);
CALL
p2
(
'SELECT @@$(VAR)'
);
CALL
p2
(
'SELECT @@global.$(VAR)'
);
CALL
p2
(
'SELECT @@global.$(VAR)()'
);
CALL
p2
(
'SELECT $(VAR)()'
);
CALL
p2
(
'SELECT test.$(VAR)()'
);
CALL
p2
(
'SELECT $(VAR) FROM t1'
);
CALL
p2
(
'SELECT t1.$(VAR) FROM t1'
);
CALL
p2
(
'DROP TABLE $(VAR)'
);
CALL
p2
(
'DROP TABLE test.$(VAR)'
);
CALL
p2
(
'CREATE FUNCTION $(VAR)() RETURNS OOPS'
);
CALL
p2
(
'CREATE FUNCTION test.$(VAR)() RETURNS OOPS'
);
CALL
p2
(
'DROP FUNCTION $(VAR)'
);
CALL
p2
(
'DROP FUNCTION test.$(VAR)'
);
DROP
TABLE
t1
;
DROP
PROCEDURE
p1
;
DROP
PROCEDURE
p2
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment