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
7450cb7f
Commit
7450cb7f
authored
Jul 25, 2016
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
re-fix vcols on demand, not always for every SELECT
parent
cd51c7fb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
+32
-2
sql/item.cc
sql/item.cc
+3
-0
sql/sql_base.cc
sql/sql_base.cc
+2
-2
sql/table.cc
sql/table.cc
+25
-0
sql/table.h
sql/table.h
+2
-0
No files found.
sql/item.cc
View file @
7450cb7f
...
...
@@ -5219,6 +5219,8 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
}
#endif
fixed
=
1
;
if
(
field
->
vcol_info
)
fix_session_vcol_expr_for_read
(
thd
,
field
,
field
->
vcol_info
);
if
(
thd
->
variables
.
sql_mode
&
MODE_ONLY_FULL_GROUP_BY
&&
!
outer_fixed
&&
!
thd
->
lex
->
in_sum_func
&&
thd
->
lex
->
current_select
->
cur_pos_in_select_list
!=
UNDEF_POS
&&
...
...
@@ -8231,6 +8233,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
set_field
(
def_field
);
if
(
field
->
default_value
)
{
fix_session_vcol_expr_for_read
(
thd
,
field
,
field
->
default_value
);
if
(
thd
->
mark_used_columns
!=
MARK_COLUMNS_NONE
)
field
->
default_value
->
expr_item
->
walk
(
&
Item
::
register_field_in_read_map
,
1
,
0
);
IF_DBUG
(
def_field
->
is_stat_field
=
1
,);
// a hack to fool ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED
...
...
sql/sql_base.cc
View file @
7450cb7f
...
...
@@ -4697,7 +4697,8 @@ static bool fix_all_session_vcol_exprs(THD *thd, TABLE_LIST *tables)
table
=
table
->
next_global
)
{
TABLE
*
t
=
table
->
table
;
if
(
!
table
->
placeholder
()
&&
t
->
s
->
vcols_need_refixing
)
if
(
!
table
->
placeholder
()
&&
t
->
s
->
vcols_need_refixing
&&
table
->
lock_type
>=
TL_WRITE_ALLOW_WRITE
)
{
if
(
table
->
security_ctx
)
thd
->
security_ctx
=
table
->
security_ctx
;
...
...
@@ -4711,7 +4712,6 @@ static bool fix_all_session_vcol_exprs(THD *thd, TABLE_LIST *tables)
fix_session_vcol_expr
(
thd
,
(
*
df
)
->
default_value
))
goto
err
;
if
(
table
->
lock_type
>=
TL_WRITE_ALLOW_WRITE
)
for
(
Virtual_column_info
**
cc
=
t
->
check_constraints
;
cc
&&
*
cc
;
cc
++
)
if
(
fix_session_vcol_expr
(
thd
,
(
*
cc
)))
goto
err
;
...
...
sql/table.cc
View file @
7450cb7f
...
...
@@ -2543,7 +2543,11 @@ static bool fix_vcol_expr(THD *thd, Virtual_column_info *vcol)
DBUG_RETURN
(
0
);
}
/** rerun fix_fields for vcols that returns time- or session- dependent values
@note this is done for all vcols for INSERT/UPDATE/DELETE,
and only as needed for SELECTs.
*/
bool
fix_session_vcol_expr
(
THD
*
thd
,
Virtual_column_info
*
vcol
)
{
DBUG_ENTER
(
"fix_session_vcol_expr"
);
...
...
@@ -2556,6 +2560,27 @@ bool fix_session_vcol_expr(THD *thd, Virtual_column_info *vcol)
}
/** invoke fix_session_vcol_expr for a vcol
@note this is called for generated column or a DEFAULT expression from
their corresponding fix_fields on SELECT.
*/
bool
fix_session_vcol_expr_for_read
(
THD
*
thd
,
Field
*
field
,
Virtual_column_info
*
vcol
)
{
DBUG_ENTER
(
"fix_session_vcol_expr_for_read"
);
TABLE_LIST
*
tl
=
field
->
table
->
pos_in_table_list
;
if
(
!
tl
||
tl
->
lock_type
>=
TL_WRITE_ALLOW_WRITE
)
DBUG_RETURN
(
0
);
Security_context
*
save_security_ctx
=
thd
->
security_ctx
;
if
(
tl
->
security_ctx
)
thd
->
security_ctx
=
tl
->
security_ctx
;
bool
res
=
fix_session_vcol_expr
(
thd
,
vcol
);
thd
->
security_ctx
=
save_security_ctx
;
DBUG_RETURN
(
res
);
}
/*
@brief
Perform semantic analysis of the defining expression for a virtual column
...
...
sql/table.h
View file @
7450cb7f
...
...
@@ -2620,6 +2620,8 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
uint
ha_open_flags
,
TABLE
*
outparam
,
bool
is_create_table
);
bool
fix_session_vcol_expr
(
THD
*
thd
,
Virtual_column_info
*
vcol
);
bool
fix_session_vcol_expr_for_read
(
THD
*
thd
,
Field
*
field
,
Virtual_column_info
*
vcol
);
Virtual_column_info
*
unpack_vcol_info_from_frm
(
THD
*
thd
,
MEM_ROOT
*
mem_root
,
TABLE
*
table
,
Field
*
field
,
...
...
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