Skip to content

Commit 0cdc116

Browse files
kevgsmidenok
authored andcommitted
SQL, IB: various refactoring [#337]
1 parent 4dd8736 commit 0cdc116

File tree

23 files changed

+267
-183
lines changed

23 files changed

+267
-183
lines changed

include/mysql_com.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ enum enum_indicator_type
198198
#define VERS_SYS_END_FLAG (1 << 28) /* autogenerated column declared with
199199
`generated always as row end`
200200
(see II.a SQL Standard).*/
201-
#define VERS_OPTIMIZED_UPDATE_FLAG (1 << 29) /* column that doesn't support
201+
#define VERS_UPDATE_UNVERSIONED_FLAG (1 << 29) /* column that doesn't support
202202
system versioning when table
203203
itself supports it*/
204204
#define HIDDEN_FLAG (1 << 31) /* hide from SELECT * */

sql/field.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,11 @@ class Field: public Value_source
14551455
return flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG);
14561456
}
14571457

1458+
bool vers_update_unversioned() const
1459+
{
1460+
return flags & VERS_UPDATE_UNVERSIONED_FLAG;
1461+
}
1462+
14581463
virtual bool vers_trx_id() const
14591464
{
14601465
return false;

sql/handler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6859,7 +6859,7 @@ bool Vers_parse_info::check_and_fix_implicit(
68596859
!with_system_versioning) ||
68606860
f->versioning == Column_definition::WITHOUT_VERSIONING)
68616861
{
6862-
f->flags|= VERS_OPTIMIZED_UPDATE_FLAG;
6862+
f->flags|= VERS_UPDATE_UNVERSIONED_FLAG;
68636863
}
68646864
}
68656865

@@ -6999,7 +6999,7 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
69996999
while (Create_field *f= it++)
70007000
{
70017001
if (f->versioning == Column_definition::WITHOUT_VERSIONING)
7002-
f->flags|= VERS_OPTIMIZED_UPDATE_FLAG;
7002+
f->flags|= VERS_UPDATE_UNVERSIONED_FLAG;
70037003

70047004
if (f->change.str && (start == f->change || end == f->change))
70057005
{

sql/item.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10384,7 +10384,7 @@ Item *Item_field::vers_optimized_fields_transformer(THD *thd, uchar *)
1038410384
if (!field)
1038510385
return this;
1038610386

10387-
if (field->flags & VERS_OPTIMIZED_UPDATE_FLAG && context &&
10387+
if (field->vers_update_unversioned() && context &&
1038810388
field->table->pos_in_table_list &&
1038910389
field->table->pos_in_table_list->vers_conditions)
1039010390
{

sql/sql_class.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,6 @@ extern "C" void thd_kill_timeout(THD* thd)
710710
mysql_mutex_unlock(&thd->LOCK_thd_data);
711711
}
712712

713-
Time_zone * thd_get_timezone(THD * thd)
714-
{
715-
DBUG_ASSERT(thd && thd->variables.time_zone);
716-
return thd->variables.time_zone;
717-
}
718-
719713
void thd_vers_update_trt(THD * thd, bool value)
720714
{
721715
thd->vers_update_trt= value;

sql/sql_class.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ extern bool volatile shutdown_in_progress;
155155

156156
extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd);
157157
extern "C" size_t thd_query_safe(MYSQL_THD thd, char *buf, size_t buflen);
158+
void thd_vers_update_trt(THD *thd, bool value);
158159

159160
/**
160161
@class CSET_STRING
@@ -4564,6 +4565,8 @@ class THD :public Statement,
45644565
/* Handling of timeouts for commands */
45654566
thr_timer_t query_timer;
45664567

4568+
// Storage engine may set this to true is we want to write a row to
4569+
// transaction_registry table on transaction commit.
45674570
bool vers_update_trt;
45684571

45694572
public:

sql/sql_select.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16743,7 +16743,7 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
1674316743
HIDDEN_FLAG |
1674416744
VERS_SYS_START_FLAG |
1674516745
VERS_SYS_END_FLAG |
16746-
VERS_OPTIMIZED_UPDATE_FLAG));
16746+
VERS_UPDATE_UNVERSIONED_FLAG));
1674716747
if (org_field->maybe_null() || (item && item->maybe_null))
1674816748
new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join
1674916749
if (org_field->type() == MYSQL_TYPE_VAR_STRING ||

sql/sql_show.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2188,7 +2188,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
21882188
packet->append(def_value.ptr(), def_value.length(), system_charset_info);
21892189
}
21902190

2191-
if (field->flags & VERS_OPTIMIZED_UPDATE_FLAG)
2191+
if (field->vers_update_unversioned())
21922192
{
21932193
packet->append(STRING_WITH_LEN(" WITHOUT SYSTEM VERSIONING"));
21942194
}

sql/sql_update.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static bool check_has_vers_fields(List<Item> &items)
161161
while (Item *item= it++)
162162
{
163163
if (Item_field *item_field= item->field_for_view_update())
164-
if (!(item_field->field->flags & VERS_OPTIMIZED_UPDATE_FLAG))
164+
if (!item_field->field->vers_update_unversioned())
165165
return true;
166166
}
167167
return false;

sql/table.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
20512051
{
20522052
uchar flags= *extra2_field_flags++;
20532053
if (flags & VERS_OPTIMIZED_UPDATE)
2054-
reg_field->flags|= VERS_OPTIMIZED_UPDATE_FLAG;
2054+
reg_field->flags|= VERS_UPDATE_UNVERSIONED_FLAG;
20552055
if (flags & HIDDEN)
20562056
reg_field->flags|= HIDDEN_FLAG;
20572057
}
@@ -8527,7 +8527,8 @@ void TR_table::store(uint field_id, timeval ts)
85278527

85288528
void TR_table::store_data(ulonglong trx_id, ulonglong commit_id, timeval commit_ts)
85298529
{
8530-
timeval start_time= {thd->start_time, thd->start_time_sec_part};
8530+
timeval start_time= {static_cast<int>(thd->start_time),
8531+
static_cast<int>(thd->start_time_sec_part)};
85318532
store(FLD_TRX_ID, trx_id);
85328533
store(FLD_COMMIT_ID, commit_id);
85338534
store(FLD_BEGIN_TS, start_time);

0 commit comments

Comments
 (0)