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
22f3ebe4
Commit
22f3ebe4
authored
Jan 11, 2024
by
Anel Husakovic
Committed by
Anel
Jan 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-32235: mysql_json cannot be used on newly created table
Closes PR #2839 Reviewer: cvicentiu@mariadb.org
parent
9a5f85dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
8 deletions
+40
-8
mysql-test/main/mysql_json_table_recreate.result
mysql-test/main/mysql_json_table_recreate.result
+12
-6
mysql-test/main/mysql_json_table_recreate.test
mysql-test/main/mysql_json_table_recreate.test
+15
-2
sql/sql_table.cc
sql/sql_table.cc
+13
-0
No files found.
mysql-test/main/mysql_json_table_recreate.result
View file @
22f3ebe4
...
...
@@ -181,12 +181,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1;
create table t1(j mysql_json);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`j` mysql_json /* JSON from MySQL 5.7 */ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1;
ERROR HY000: Cannot create table `test`.`t1`: Run mariadb-upgrade, to upgrade table with mysql_json type.
create table `testjson` (
`t` json /* JSON from MySQL 5.7*/ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
...
...
@@ -211,5 +206,16 @@ testjson CREATE TABLE `testjson` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table testjson;
#
# MDEV-32235: mysql_json cannot be used on newly created table
#
CREATE TABLE t(j mysql_json);
ERROR HY000: Cannot create table `test`.`t`: Run mariadb-upgrade, to upgrade table with mysql_json type.
CREATE TABLE IF NOT EXISTS t(j mysql_json);
ERROR HY000: Cannot create table `test`.`t`: Run mariadb-upgrade, to upgrade table with mysql_json type.
CREATE OR REPLACE TABLE t(j mysql_json);
ERROR HY000: Cannot create table `test`.`t`: Run mariadb-upgrade, to upgrade table with mysql_json type.
CREATE TEMPORARY TABLE t(j mysql_json);
ERROR HY000: Cannot create table `test`.`t`: Run mariadb-upgrade, to upgrade table with mysql_json type.
#
# End of 10.5 tests
#
mysql-test/main/mysql_json_table_recreate.test
View file @
22f3ebe4
...
...
@@ -97,9 +97,8 @@ drop table mysql_json_test_big;
create
table
t1
(
j
json
);
show
create
table
t1
;
drop
table
t1
;
--
error
ER_CANT_CREATE_TABLE
create
table
t1
(
j
mysql_json
);
show
create
table
t1
;
drop
table
t1
;
# `json` type should not have character set and collation other than utf8mb4_bin
--
error
ER_PARSE_ERROR
create
table
`testjson`
(
...
...
@@ -121,6 +120,20 @@ create table `testjson` (
show
create
table
testjson
;
drop
table
testjson
;
--
echo
#
--
echo
# MDEV-32235: mysql_json cannot be used on newly created table
--
echo
#
--
error
ER_CANT_CREATE_TABLE
CREATE
TABLE
t
(
j
mysql_json
);
--
error
ER_CANT_CREATE_TABLE
CREATE
TABLE
IF
NOT
EXISTS
t
(
j
mysql_json
);
--
error
ER_CANT_CREATE_TABLE
CREATE
OR
REPLACE
TABLE
t
(
j
mysql_json
);
--
error
ER_CANT_CREATE_TABLE
CREATE
TEMPORARY
TABLE
t
(
j
mysql_json
);
--
echo
#
--
echo
# End of 10.5 tests
--
echo
#
sql/sql_table.cc
View file @
22f3ebe4
...
...
@@ -3657,6 +3657,19 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if
(
sql_field
->
vcol_info
)
sql_field
->
flags
&=
~
NOT_NULL_FLAG
;
if
(
sql_field
->
real_field_type
()
==
MYSQL_TYPE_BLOB
&&
thd
->
lex
->
sql_command
==
SQLCOM_CREATE_TABLE
)
{
if
(
!
strcmp
(
sql_field
->
type_handler
()
->
name
().
ptr
(),
"MYSQL_JSON"
))
{
my_printf_error
(
ER_CANT_CREATE_TABLE
,
"Cannot create table %`s.%`s: "
"Run mariadb-upgrade, "
"to upgrade table with mysql_json type."
,
MYF
(
0
),
alter_info
->
db
.
str
,
alter_info
->
table_name
.
str
);
DBUG_RETURN
(
TRUE
);
}
}
/*
Initialize length from its original value (number of characters),
which was set in the parser. This is necessary if we're
...
...
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