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
bf8ae812
Commit
bf8ae812
authored
May 16, 2020
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/10.1' into 10.2
Also, adding 10.2 related changes for MDEV-22579
parents
3f12a596
3df29727
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
14 deletions
+149
-14
mysql-test/suite/vcol/r/vcol_misc.result
mysql-test/suite/vcol/r/vcol_misc.result
+52
-0
mysql-test/suite/vcol/t/vcol_misc.test
mysql-test/suite/vcol/t/vcol_misc.test
+61
-0
sql/item.h
sql/item.h
+28
-0
sql/sql_base.cc
sql/sql_base.cc
+8
-14
No files found.
mysql-test/suite/vcol/r/vcol_misc.result
View file @
bf8ae812
...
...
@@ -407,6 +407,26 @@ aaa
Warnings:
Warning 1918 Encountered illegal value '\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7' when converting to DOUBLE
#
# MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
#
SET sql_mode=STRICT_ALL_TABLES;
CREATE OR REPLACE TABLE t1 (
a INT NOT NULL DEFAULT 10,
b INT AS (a+1) VIRTUAL
) ENGINE=MyISAM;
INSERT INTO t1 (b) VALUES (10);
ERROR HY000: The value specified for generated column 'b' in table 't1' has been ignored
INSERT INTO t1 (b) VALUES (DEFAULT(a));
ERROR HY000: The value specified for generated column 'b' in table 't1' has been ignored
INSERT INTO t1 (b) VALUES (DEFAULT);
INSERT INTO t1 VALUES (10,10);
ERROR HY000: The value specified for generated column 'b' in table 't1' has been ignored
INSERT INTO t1 VALUES (10,DEFAULT(a));
ERROR HY000: The value specified for generated column 'b' in table 't1' has been ignored
INSERT INTO t1 VALUES (10, DEFAULT);
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# End of 10.1 tests
#
#
...
...
@@ -461,5 +481,37 @@ Warning 1264 Out of range value for column 'vi' at row 1
DROP TABLE t1;
SET @sql_mode=@old_sql_mode;
#
# MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
# 10.2+ specific part
#
SET sql_mode=STRICT_ALL_TABLES;
CREATE OR REPLACE TABLE t1 (
a INT NOT NULL DEFAULT 10,
b INT AS (a+1) VIRTUAL
) ENGINE=MyISAM;
EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING DEFAULT;
EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING IGNORE;
INSERT INTO t1 (b) VALUES (DEFAULT);
INSERT INTO t1 (b) VALUES (IGNORE);
SELECT * FROM t1;
a b
10 11
10 11
10 11
10 11
DELETE FROM t1;
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(10,?)' USING DEFAULT;
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(11,?)' USING IGNORE;
INSERT INTO t1 VALUES (12,DEFAULT);
INSERT INTO t1 VALUES (13,IGNORE);
SELECT * FROM t1;
a b
10 11
11 12
12 13
13 14
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# End of 10.2 tests
#
mysql-test/suite/vcol/t/vcol_misc.test
View file @
bf8ae812
...
...
@@ -368,6 +368,36 @@ SELECT COLUMN_GET(@aaa, 'price' AS DECIMAL) aaa;
SELECT
COLUMN_GET
(
@
aaa
,
'price'
AS
INT
)
aaa
;
SELECT
COLUMN_GET
(
@
aaa
,
'price'
AS
DOUBLE
)
aaa
;
--
echo
#
--
echo
# MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
--
echo
#
SET
sql_mode
=
STRICT_ALL_TABLES
;
CREATE
OR
REPLACE
TABLE
t1
(
a
INT
NOT
NULL
DEFAULT
10
,
b
INT
AS
(
a
+
1
)
VIRTUAL
)
ENGINE
=
MyISAM
;
# Testing with a column list
--
error
ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
INSERT
INTO
t1
(
b
)
VALUES
(
10
);
--
error
ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
INSERT
INTO
t1
(
b
)
VALUES
(
DEFAULT
(
a
));
INSERT
INTO
t1
(
b
)
VALUES
(
DEFAULT
);
# Testing without a column list
--
error
ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
INSERT
INTO
t1
VALUES
(
10
,
10
);
--
error
ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
INSERT
INTO
t1
VALUES
(
10
,
DEFAULT
(
a
));
INSERT
INTO
t1
VALUES
(
10
,
DEFAULT
);
DROP
TABLE
t1
;
SET
sql_mode
=
DEFAULT
;
--
echo
#
--
echo
# End of 10.1 tests
--
echo
#
...
...
@@ -425,6 +455,37 @@ REPLACE INTO t1 (pk,i) VALUES (1,2);
DROP
TABLE
t1
;
SET
@
sql_mode
=@
old_sql_mode
;
--
echo
#
--
echo
# MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
--
echo
# 10.2+ specific part
--
echo
#
SET
sql_mode
=
STRICT_ALL_TABLES
;
CREATE
OR
REPLACE
TABLE
t1
(
a
INT
NOT
NULL
DEFAULT
10
,
b
INT
AS
(
a
+
1
)
VIRTUAL
)
ENGINE
=
MyISAM
;
# Testing with column list
EXECUTE
IMMEDIATE
'INSERT INTO t1 (b) VALUES(?)'
USING
DEFAULT
;
EXECUTE
IMMEDIATE
'INSERT INTO t1 (b) VALUES(?)'
USING
IGNORE
;
INSERT
INTO
t1
(
b
)
VALUES
(
DEFAULT
);
INSERT
INTO
t1
(
b
)
VALUES
(
IGNORE
);
SELECT
*
FROM
t1
;
DELETE
FROM
t1
;
# Testing without column list
EXECUTE
IMMEDIATE
'INSERT INTO t1 VALUES(10,?)'
USING
DEFAULT
;
EXECUTE
IMMEDIATE
'INSERT INTO t1 VALUES(11,?)'
USING
IGNORE
;
INSERT
INTO
t1
VALUES
(
12
,
DEFAULT
);
INSERT
INTO
t1
VALUES
(
13
,
IGNORE
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
SET
sql_mode
=
DEFAULT
;
--
echo
#
--
echo
# End of 10.2 tests
--
echo
#
sql/item.h
View file @
bf8ae812
...
...
@@ -1301,6 +1301,13 @@ class Item: public Value_source,
a constant expression. Used in the optimizer to propagate basic constants.
*/
virtual
bool
basic_const_item
()
const
{
return
0
;
}
/*
Determines if the expression is allowed as
a virtual column assignment source:
INSERT INTO t1 (vcol) VALUES (10) -> error
INSERT INTO t1 (vcol) VALUES (NULL) -> ok
*/
virtual
bool
vcol_assignment_allowed_value
()
const
{
return
false
;
}
/* cloning of constant items (0 if it is not const) */
virtual
Item
*
clone_item
(
THD
*
thd
)
{
return
0
;
}
virtual
Item
*
build_clone
(
THD
*
thd
,
MEM_ROOT
*
mem_root
)
{
return
get_copy
(
thd
,
mem_root
);
}
...
...
@@ -2900,6 +2907,7 @@ class Item_null :public Item_basic_constant
collation
.
set
(
cs
,
DERIVATION_IGNORABLE
,
MY_REPERTOIRE_ASCII
);
}
enum
Type
type
()
const
{
return
NULL_ITEM
;
}
bool
vcol_assignment_allowed_value
()
const
{
return
true
;
}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
{
return
null_eq
(
item
);
}
double
val_real
();
longlong
val_int
();
...
...
@@ -3082,6 +3090,25 @@ class Item_param :public Item_basic_value,
*/
enum
enum_indicator_type
indicator
;
bool
vcol_assignment_allowed_value
()
const
{
switch
(
state
)
{
case
NULL_VALUE
:
case
DEFAULT_VALUE
:
case
IGNORE_VALUE
:
return
true
;
case
NO_VALUE
:
case
INT_VALUE
:
case
REAL_VALUE
:
case
STRING_VALUE
:
case
TIME_VALUE
:
case
LONG_DATA_VALUE
:
case
DECIMAL_VALUE
:
break
;
}
return
false
;
}
/*
A buffer for string and long data values. Historically all allocated
values returned from val_str() were treated as eligible to
...
...
@@ -5372,6 +5399,7 @@ class Item_default_value : public Item_field
(
const
char
*
)
NULL
),
arg
(
NULL
),
cached_field
(
NULL
)
{}
enum
Type
type
()
const
{
return
DEFAULT_VALUE_ITEM
;
}
bool
vcol_assignment_allowed_value
()
const
{
return
arg
==
NULL
;
}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
bool
fix_fields
(
THD
*
,
Item
**
);
void
cleanup
();
...
...
sql/sql_base.cc
View file @
bf8ae812
...
...
@@ -8042,10 +8042,8 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
if
(
table
->
next_number_field
&&
rfield
->
field_index
==
table
->
next_number_field
->
field_index
)
table
->
auto_increment_field_not_null
=
TRUE
;
Item
::
Type
type
=
value
->
type
();
if
(
rfield
->
vcol_info
&&
type
!=
Item
::
DEFAULT_VALUE_ITEM
&&
type
!=
Item
::
NULL_ITEM
&&
!
value
->
vcol_assignment_allowed_value
()
&&
table
->
s
->
table_category
!=
TABLE_CATEGORY_TEMPORARY
)
{
push_warning_printf
(
thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
...
...
@@ -8289,18 +8287,14 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
value
=
v
++
;
if
(
field
->
field_index
==
autoinc_index
)
table
->
auto_increment_field_not_null
=
TRUE
;
if
(
field
->
vcol_info
)
if
(
field
->
vcol_info
&&
!
value
->
vcol_assignment_allowed_value
()
&&
table
->
s
->
table_category
!=
TABLE_CATEGORY_TEMPORARY
)
{
Item
::
Type
type
=
value
->
type
();
if
(
type
!=
Item
::
DEFAULT_VALUE_ITEM
&&
type
!=
Item
::
NULL_ITEM
&&
table
->
s
->
table_category
!=
TABLE_CATEGORY_TEMPORARY
)
{
push_warning_printf
(
thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
,
ER_THD
(
thd
,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
),
field
->
field_name
,
table
->
s
->
table_name
.
str
);
}
push_warning_printf
(
thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
,
ER_THD
(
thd
,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
),
field
->
field_name
,
table
->
s
->
table_name
.
str
);
}
if
(
use_value
)
...
...
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