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
d1f37633
Commit
d1f37633
authored
Nov 08, 2016
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: non-deterministic vcols in indexes
parent
6b0f4c24
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
9 deletions
+73
-9
mysql-test/suite/vcol/inc/vcol_keys.inc
mysql-test/suite/vcol/inc/vcol_keys.inc
+23
-2
mysql-test/suite/vcol/r/vcol_keys_innodb.result
mysql-test/suite/vcol/r/vcol_keys_innodb.result
+18
-2
mysql-test/suite/vcol/r/vcol_keys_myisam.result
mysql-test/suite/vcol/r/vcol_keys_myisam.result
+18
-2
sql/sql_table.cc
sql/sql_table.cc
+14
-3
No files found.
mysql-test/suite/vcol/inc/vcol_keys.inc
View file @
d1f37633
...
...
@@ -157,6 +157,27 @@ drop table t1;
--
echo
# - vcol_ins_upd.inc
--
echo
# - vcol_select.inc
--
echo
#
--
echo
# TODO: CHECK
#
# Restrictions when indexed:
#
--
error
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create
table
t1
(
a
int
,
b
timestamp
as
(
now
()),
key
(
b
));
create
table
t1
(
a
int
,
b
timestamp
as
(
now
()));
--
error
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter
table
t1
add
index
(
b
);
drop
table
t1
;
--
error
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create
table
t1
(
a
int
,
b
varchar
(
100
)
as
(
user
()),
key
(
b
));
create
table
t1
(
a
int
,
b
varchar
(
100
)
as
(
user
()));
--
error
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter
table
t1
add
index
(
b
);
drop
table
t1
;
--
error
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create
table
t1
(
a
int
,
b
double
as
(
rand
()),
key
(
b
));
create
table
t1
(
a
int
,
b
double
as
(
rand
()));
--
error
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter
table
t1
add
index
(
b
);
drop
table
t1
;
mysql-test/suite/vcol/r/vcol_keys_innodb.result
View file @
d1f37633
...
...
@@ -150,5 +150,21 @@ drop table t1;
# on virtual columns can be found in:
# - vcol_ins_upd.inc
# - vcol_select.inc
#
# TODO: CHECK
create table t1 (a int, b timestamp as (now()), key (b));
ERROR HY000: Function or expression 'current_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create table t1 (a int, b timestamp as (now()));
alter table t1 add index (b);
ERROR HY000: Function or expression 'current_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1;
create table t1 (a int, b varchar(100) as (user()), key (b));
ERROR HY000: Function or expression 'user()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create table t1 (a int, b varchar(100) as (user()));
alter table t1 add index (b);
ERROR HY000: Function or expression 'user()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1;
create table t1 (a int, b double as (rand()), key (b));
ERROR HY000: Function or expression 'rand()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create table t1 (a int, b double as (rand()));
alter table t1 add index (b);
ERROR HY000: Function or expression 'rand()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1;
mysql-test/suite/vcol/r/vcol_keys_myisam.result
View file @
d1f37633
...
...
@@ -260,5 +260,21 @@ drop table t1;
# on virtual columns can be found in:
# - vcol_ins_upd.inc
# - vcol_select.inc
#
# TODO: CHECK
create table t1 (a int, b timestamp as (now()), key (b));
ERROR HY000: Function or expression 'current_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create table t1 (a int, b timestamp as (now()));
alter table t1 add index (b);
ERROR HY000: Function or expression 'current_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1;
create table t1 (a int, b varchar(100) as (user()), key (b));
ERROR HY000: Function or expression 'user()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create table t1 (a int, b varchar(100) as (user()));
alter table t1 add index (b);
ERROR HY000: Function or expression 'user()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1;
create table t1 (a int, b double as (rand()), key (b));
ERROR HY000: Function or expression 'rand()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create table t1 (a int, b double as (rand()));
alter table t1 add index (b);
ERROR HY000: Function or expression 'rand()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1;
sql/sql_table.cc
View file @
d1f37633
...
...
@@ -3877,10 +3877,21 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
}
#endif
if
(
key
->
type
==
Key
::
PRIMARY
&&
sql_field
->
vcol_info
)
if
(
sql_field
->
vcol_info
)
{
my_error
(
ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN
,
MYF
(
0
));
DBUG_RETURN
(
TRUE
);
if
(
key
->
type
==
Key
::
PRIMARY
)
{
my_error
(
ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN
,
MYF
(
0
));
DBUG_RETURN
(
TRUE
);
}
if
(
sql_field
->
vcol_info
->
flags
&
VCOL_NOT_STRICTLY_DETERMINISTIC
)
{
/* use check_expression() to report an error */
check_expression
(
sql_field
->
vcol_info
,
sql_field
->
field_name
,
VCOL_GENERATED_STORED
);
DBUG_ASSERT
(
thd
->
is_error
());
DBUG_RETURN
(
TRUE
);
}
}
if
(
!
(
sql_field
->
flags
&
NOT_NULL_FLAG
))
{
...
...
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