summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2019-02-04 09:37:39 +1000
committerSergei Golubchik <serg@mariadb.org>2019-02-21 14:57:09 +0100
commit6294516a56b3ae3d4b72326a61cfe9fe014b56c7 (patch)
treefe22a6a2cf2a46135c1a2c7734b6911cd43e43e9 /sql/unireg.cc
parentb2bd52290a4faeb2646b25fc3950542e41f33050 (diff)
downloadmariadb-git-6294516a56b3ae3d4b72326a61cfe9fe014b56c7.tar.gz
MDEV-16975 Application-time periods: ALTER TABLE
* implicit period constraint is hidden and cannot be dropped independently * create...like and create...select support
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 9d4b7b93f0a..ab3ac0dabca 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -143,6 +143,14 @@ bool has_extra2_field_flags(List<Create_field> &create_fields)
return false;
}
+static inline
+uchar* store_str(uchar *buf, const Lex_ident &str)
+{
+ int2store(buf, str.length);
+ memcpy(buf + frm_ident_len_size, str.str, str.length);
+ return buf + str.length + frm_ident_len_size;
+}
+
/**
Create a frm (table definition) file
@@ -170,8 +178,11 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
ulong data_offset;
uint options_len;
uint gis_extra2_len= 0;
- uint period_info_len= create_info->period_info.name.length
- + 2 * frm_fieldno_size;
+ size_t period_info_len= create_info->period_info.name
+ ? create_info->period_info.name.length
+ + create_info->period_info.constr->name.length
+ + 2 * frm_ident_len_size + 2 * frm_fieldno_size
+ : 0;
uchar fileinfo[FRM_HEADER_SIZE],forminfo[FRM_FORMINFO_SIZE];
const partition_info *part_info= IF_PARTITIONING(thd->work_part_info, 0);
bool error;
@@ -351,14 +362,12 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
#endif /*HAVE_SPATIAL*/
// PERIOD
- if (create_info->period_info.name)
+ if (create_info->period_info.is_set())
{
*pos++= EXTRA2_APPLICATION_TIME_PERIOD;
-
- Lex_ident &period_name= create_info->period_info.name;
pos= extra2_write_len(pos, period_info_len);
- memcpy(pos, period_name.str, period_name.length);
- pos+= period_name.length;
+ pos= store_str(pos, create_info->period_info.name);
+ pos= store_str(pos, create_info->period_info.constr->name);
int2store(pos, get_fieldno_by_name(create_info, create_fields,
create_info->period_info.period.start));