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
81e4b9b3
Commit
81e4b9b3
authored
Feb 15, 2019
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc cleanups
parent
7ec3a4d7
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
95 additions
and
100 deletions
+95
-100
sql/sql_lex.h
sql/sql_lex.h
+3
-3
sql/sql_table.cc
sql/sql_table.cc
+40
-50
sql/sql_table.h
sql/sql_table.h
+2
-2
sql/sql_update.cc
sql/sql_update.cc
+1
-2
sql/sql_yacc.yy
sql/sql_yacc.yy
+2
-2
sql/sql_yacc_ora.yy
sql/sql_yacc_ora.yy
+2
-2
sql/table.cc
sql/table.cc
+5
-7
sql/table.h
sql/table.h
+5
-0
sql/unireg.cc
sql/unireg.cc
+33
-30
sql/unireg.h
sql/unireg.h
+2
-2
No files found.
sql/sql_lex.h
View file @
81e4b9b3
...
...
@@ -4191,10 +4191,10 @@ struct LEX: public Query_tables_list
void
add_key_to_list
(
LEX_CSTRING
*
field_name
,
enum
Key
::
Keytype
type
,
bool
check_exists
);
// Add a constraint as a part of CREATE TABLE or ALTER TABLE
bool
add_constraint
(
const
LEX_CSTRING
*
name
,
Virtual_column_info
*
constr
,
bool
add_constraint
(
const
LEX_CSTRING
&
name
,
Virtual_column_info
*
constr
,
bool
if_not_exists
)
{
constr
->
name
=
*
name
;
constr
->
name
=
name
;
constr
->
flags
=
if_not_exists
?
Alter_info
::
CHECK_CONSTRAINT_IF_NOT_EXISTS
:
0
;
alter_info
.
check_constraint_list
.
push_back
(
constr
);
...
...
@@ -4293,7 +4293,7 @@ struct LEX: public Query_tables_list
info
.
constr
->
expr
=
lt_creator
.
create
(
thd
,
create_item_ident_nosp
(
thd
,
&
start
),
create_item_ident_nosp
(
thd
,
&
end
));
add_constraint
(
&
null_clex_str
,
info
.
constr
,
false
);
add_constraint
(
null_clex_str
,
info
.
constr
,
false
);
return
0
;
}
...
...
sql/sql_table.cc
View file @
81e4b9b3
This diff is collapsed.
Click to expand it.
sql/sql_table.h
View file @
81e4b9b3
...
...
@@ -198,8 +198,8 @@ int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *db,
int
create_table_mode
,
TABLE_LIST
*
table
);
handler
*
mysql_create_frm_image
(
THD
*
thd
,
const
LEX_CSTRING
*
db
,
const
LEX_CSTRING
*
table_name
,
const
LEX_CSTRING
&
db
,
const
LEX_CSTRING
&
table_name
,
HA_CREATE_INFO
*
create_info
,
Alter_info
*
alter_info
,
int
create_table_mode
,
...
...
sql/sql_update.cc
View file @
81e4b9b3
...
...
@@ -1356,8 +1356,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN
(
TRUE
);
if
(
setup_tables_and_check_access
(
thd
,
&
select_lex
->
context
,
&
select_lex
->
top_join_list
,
table_list
,
&
select_lex
->
top_join_list
,
table_list
,
select_lex
->
leaf_tables
,
FALSE
,
UPDATE_ACL
,
SELECT_ACL
,
TRUE
)
||
setup_conds
(
thd
,
table_list
,
select_lex
->
leaf_tables
,
conds
)
||
...
...
sql/sql_yacc.yy
View file @
81e4b9b3
...
...
@@ -6636,7 +6636,7 @@ key_def:
constraint_def:
opt_constraint check_constraint
{
Lex->add_constraint(
&
$1, $2, FALSE);
Lex->add_constraint($1, $2, FALSE);
}
;
...
...
@@ -8350,7 +8350,7 @@ alter_list_item:
| ADD CONSTRAINT IF_SYM not EXISTS field_ident check_constraint
{
Lex->alter_info.flags|= ALTER_ADD_CHECK_CONSTRAINT;
Lex->add_constraint(
&
$6, $7, TRUE);
Lex->add_constraint($6, $7, TRUE);
}
| CHANGE opt_column opt_if_exists_table_element field_ident
field_spec opt_place
...
...
sql/sql_yacc_ora.yy
View file @
81e4b9b3
...
...
@@ -6571,7 +6571,7 @@ key_def:
constraint_def:
opt_constraint check_constraint
{
Lex->add_constraint(
&
$1, $2, FALSE);
Lex->add_constraint($1, $2, FALSE);
}
;
...
...
@@ -8364,7 +8364,7 @@ alter_list_item:
| ADD CONSTRAINT IF_SYM not EXISTS field_ident check_constraint
{
Lex->alter_info.flags|= ALTER_ADD_CHECK_CONSTRAINT;
Lex->add_constraint(
&
$6, $7, TRUE);
Lex->add_constraint($6, $7, TRUE);
}
| CHANGE opt_column opt_if_exists_table_element field_ident
field_spec opt_place
...
...
sql/table.cc
View file @
81e4b9b3
...
...
@@ -1366,8 +1366,8 @@ void TABLE::find_constraint_correlated_indexes()
bool
TABLE_SHARE
::
init_period_from_extra2
(
period_info_t
&
period
,
const
uchar
*
data
)
{
period
.
start_fieldno
=
uint2korr
(
data
);
period
.
end_fieldno
=
uint2korr
(
data
+
frm_fieldno_size
);
period
.
start_fieldno
=
read_frm_fieldno
(
data
);
period
.
end_fieldno
=
read_frm_fieldno
(
data
+
frm_fieldno_size
);
return
period
.
start_fieldno
>=
fields
||
period
.
end_fieldno
>=
fields
;
}
...
...
@@ -1419,18 +1419,16 @@ bool read_extra2(const uchar *frm_image, size_t len, extra2_fields *fields)
fields
->
options
.
length
=
length
;
break
;
case
EXTRA2_DEFAULT_PART_ENGINE
:
fields
->
engine
.
set
((
char
*
)
extra2
,
length
);
fields
->
engine
.
set
((
c
onst
c
har
*
)
extra2
,
length
);
break
;
case
EXTRA2_GIS
:
#ifdef HAVE_SPATIAL
if
(
fields
->
gis
.
str
)
DBUG_RETURN
(
true
);
fields
->
gis
.
str
=
extra2
;
fields
->
gis
.
length
=
length
;
#endif
/*HAVE_SPATIAL*/
break
;
case
EXTRA2_PERIOD_FOR_SYSTEM_TIME
:
if
(
fields
->
system_period
||
length
!=
2
*
sizeof
(
uint16
)
)
if
(
fields
->
system_period
||
length
!=
2
*
frm_fieldno_size
)
DBUG_RETURN
(
true
);
fields
->
system_period
=
extra2
;
break
;
...
...
@@ -3014,7 +3012,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
thd
->
lex
->
create_info
.
tabledef_version
=
tabledef_version
;
promote_first_timestamp_column
(
&
thd
->
lex
->
alter_info
.
create_list
);
file
=
mysql_create_frm_image
(
thd
,
&
db
,
&
table_name
,
file
=
mysql_create_frm_image
(
thd
,
db
,
table_name
,
&
thd
->
lex
->
create_info
,
&
thd
->
lex
->
alter_info
,
C_ORDINARY_CREATE
,
&
unused1
,
&
unused2
,
&
frm
);
error
|=
file
==
0
;
...
...
sql/table.h
View file @
81e4b9b3
...
...
@@ -1783,6 +1783,11 @@ class IS_table_read_plan;
/** number of bytes used by field positional indexes in frm */
constexpr
uint
frm_fieldno_size
=
2
;
static
inline
uint16
read_frm_fieldno
(
const
uchar
*
data
)
{
return
uint2korr
(
data
);
}
static
inline
void
store_frm_fieldno
(
const
uchar
*
data
,
uint16
fieldno
)
{
int2store
(
data
,
fieldno
);
}
/** number of bytes used by identifier length in frm */
constexpr
uint
frm_ident_len_size
=
2
;
...
...
sql/unireg.cc
View file @
81e4b9b3
...
...
@@ -73,18 +73,18 @@ static uchar *extra2_write_len(uchar *pos, size_t len)
}
static
uchar
*
extra2_write
(
uchar
*
pos
,
enum
extra2_frm_value_type
type
,
const
LEX_CSTRING
*
str
)
const
LEX_CSTRING
&
str
)
{
*
pos
++
=
type
;
pos
=
extra2_write_len
(
pos
,
str
->
length
);
memcpy
(
pos
,
str
->
str
,
str
->
length
);
return
pos
+
str
->
length
;
pos
=
extra2_write_len
(
pos
,
str
.
length
);
memcpy
(
pos
,
str
.
str
,
str
.
length
);
return
pos
+
str
.
length
;
}
static
uchar
*
extra2_write
(
uchar
*
pos
,
enum
extra2_frm_value_type
type
,
LEX_CUSTRING
*
str
)
const
LEX_CUSTRING
&
str
)
{
return
extra2_write
(
pos
,
type
,
reinterpret_cast
<
LEX_CSTRING
*>
(
str
));
return
extra2_write
(
pos
,
type
,
*
reinterpret_cast
<
const
LEX_CSTRING
*>
(
&
str
));
}
static
uchar
*
extra2_write_field_properties
(
uchar
*
pos
,
...
...
@@ -106,10 +106,9 @@ static uchar *extra2_write_field_properties(uchar *pos,
return
pos
;
}
static
uint16
static
uint16
get_fieldno_by_name
(
HA_CREATE_INFO
*
create_info
,
List
<
Create_field
>
&
create_fields
,
const
Lex_ident
field_name
)
const
Lex_ident
&
field_name
)
{
List_iterator
<
Create_field
>
it
(
create_fields
);
Create_field
*
sql_field
=
NULL
;
...
...
@@ -151,6 +150,11 @@ uchar* store_str(uchar *buf, const Lex_ident &str)
return
buf
+
str
.
length
+
frm_ident_len_size
;
}
static
size_t
extra2_size_needed
(
size_t
len
)
{
return
1
+
(
len
>
255
?
3
:
1
)
+
len
;
}
/**
Create a frm (table definition) file
...
...
@@ -166,7 +170,7 @@ uchar* store_str(uchar *buf, const Lex_ident &str)
or null LEX_CUSTRING (str==0) in case of an error.
*/
LEX_CUSTRING
build_frm_image
(
THD
*
thd
,
const
LEX_CSTRING
*
table
,
LEX_CUSTRING
build_frm_image
(
THD
*
thd
,
const
LEX_CSTRING
&
table
,
HA_CREATE_INFO
*
create_info
,
List
<
Create_field
>
&
create_fields
,
uint
keys
,
KEY
*
key_info
,
handler
*
db_file
)
...
...
@@ -245,7 +249,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
DBUG_PRINT
(
"info"
,
(
"Options length: %u"
,
options_len
));
if
(
validate_comment_length
(
thd
,
&
create_info
->
comment
,
TABLE_COMMENT_MAXLEN
,
ER_TOO_LONG_TABLE_COMMENT
,
table
->
str
))
ER_TOO_LONG_TABLE_COMMENT
,
table
.
str
))
DBUG_RETURN
(
frm
);
/*
If table comment is longer than TABLE_COMMENT_INLINE_MAXLEN bytes,
...
...
@@ -279,31 +283,30 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
prepare_frm_header
(
thd
,
reclength
,
fileinfo
,
create_info
,
keys
,
key_info
);
/* one byte for a type, one or three for a length */
size_t
extra2_size
=
1
+
1
+
create_info
->
tabledef_version
.
length
;
size_t
extra2_size
=
extra2_size_needed
(
create_info
->
tabledef_version
.
length
)
;
if
(
options_len
)
extra2_size
+=
1
+
(
options_len
>
255
?
3
:
1
)
+
options_len
;
extra2_size
+=
extra2_size_needed
(
options_len
)
;
if
(
part_info
)
extra2_size
+=
1
+
1
+
hton_name
(
part_info
->
default_engine_type
)
->
length
;
extra2_size
+=
extra2_size_needed
(
hton_name
(
part_info
->
default_engine_type
)
->
length
)
;
if
(
gis_extra2_len
)
extra2_size
+=
1
+
(
gis_extra2_len
>
255
?
3
:
1
)
+
gis_extra2_len
;
extra2_size
+=
extra2_size_needed
(
gis_extra2_len
)
;
if
(
create_info
->
versioned
())
{
extra2_size
+=
1
+
1
+
2
*
sizeof
(
uint16
);
extra2_size
+=
extra2_size_needed
(
2
*
frm_fieldno_size
);
}
if
(
create_info
->
period_info
.
name
)
{
extra2_size
+=
1
+
(
period_info_len
>
255
?
3
:
1
)
+
period_info_len
;
extra2_size
+=
extra2_size_needed
(
period_info_len
)
;
}
bool
has_extra2_field_flags_
=
has_extra2_field_flags
(
create_fields
);
if
(
has_extra2_field_flags_
)
{
extra2_size
+=
1
+
(
create_fields
.
elements
>
255
?
3
:
1
)
+
create_fields
.
elements
;
extra2_size
+=
extra2_size_needed
(
create_fields
.
elements
);
}
key_buff_length
=
uint4korr
(
fileinfo
+
47
);
...
...
@@ -325,7 +328,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
if
(
frm
.
length
>
FRM_MAX_SIZE
||
create_info
->
expression_length
>
UINT_MAX32
)
{
my_error
(
ER_TABLE_DEFINITION_TOO_BIG
,
MYF
(
0
),
table
->
str
);
my_error
(
ER_TABLE_DEFINITION_TOO_BIG
,
MYF
(
0
),
table
.
str
);
DBUG_RETURN
(
frm
);
}
...
...
@@ -338,11 +341,11 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
pos
=
frm_ptr
+
64
;
compile_time_assert
(
EXTRA2_TABLEDEF_VERSION
!=
'/'
);
pos
=
extra2_write
(
pos
,
EXTRA2_TABLEDEF_VERSION
,
&
create_info
->
tabledef_version
);
create_info
->
tabledef_version
);
if
(
part_info
)
pos
=
extra2_write
(
pos
,
EXTRA2_DEFAULT_PART_ENGINE
,
hton_name
(
part_info
->
default_engine_type
));
*
hton_name
(
part_info
->
default_engine_type
));
if
(
options_len
)
{
...
...
@@ -369,10 +372,10 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
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
,
store_frm_fieldno
(
pos
,
get_fieldno_by_name
(
create_info
,
create_fields
,
create_info
->
period_info
.
period
.
start
));
pos
+=
frm_fieldno_size
;
int2store
(
pos
,
get_fieldno_by_name
(
create_info
,
create_fields
,
store_frm_fieldno
(
pos
,
get_fieldno_by_name
(
create_info
,
create_fields
,
create_info
->
period_info
.
period
.
end
));
pos
+=
frm_fieldno_size
;
}
...
...
@@ -380,13 +383,13 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
if
(
create_info
->
versioned
())
{
*
pos
++=
EXTRA2_PERIOD_FOR_SYSTEM_TIME
;
*
pos
++=
2
*
sizeof
(
uint16
)
;
int2store
(
pos
,
get_fieldno_by_name
(
create_info
,
create_fields
,
*
pos
++=
2
*
frm_fieldno_size
;
store_frm_fieldno
(
pos
,
get_fieldno_by_name
(
create_info
,
create_fields
,
create_info
->
vers_info
.
as_row
.
start
));
pos
+=
sizeof
(
uint16
)
;
int2store
(
pos
,
get_fieldno_by_name
(
create_info
,
create_fields
,
pos
+=
frm_fieldno_size
;
store_frm_fieldno
(
pos
,
get_fieldno_by_name
(
create_info
,
create_fields
,
create_info
->
vers_info
.
as_row
.
end
));
pos
+=
sizeof
(
uint16
)
;
pos
+=
frm_fieldno_size
;
}
if
(
has_extra2_field_flags_
)
...
...
@@ -402,7 +405,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table,
my_printf_error
(
ER_CANT_CREATE_TABLE
,
"Cannot create table %`s: index information is too long. "
"Decrease number of indexes or use shorter index names or shorter comments."
,
MYF
(
0
),
table
->
str
);
MYF
(
0
),
table
.
str
);
goto
err
;
}
...
...
sql/unireg.h
View file @
81e4b9b3
...
...
@@ -170,8 +170,8 @@ enum extra2_frm_value_type {
EXTRA2_TABLEDEF_VERSION
=
0
,
EXTRA2_DEFAULT_PART_ENGINE
=
1
,
EXTRA2_GIS
=
2
,
EXTRA2_APPLICATION_TIME_PERIOD
=
3
,
EXTRA2_PERIOD_FOR_SYSTEM_TIME
=
4
,
EXTRA2_APPLICATION_TIME_PERIOD
=
8
,
#define EXTRA2_ENGINE_IMPORTANT 128
...
...
@@ -187,7 +187,7 @@ int rea_create_table(THD *thd, LEX_CUSTRING *frm,
const
char
*
path
,
const
char
*
db
,
const
char
*
table_name
,
HA_CREATE_INFO
*
create_info
,
handler
*
file
,
bool
no_ha_create_table
);
LEX_CUSTRING
build_frm_image
(
THD
*
thd
,
const
LEX_CSTRING
*
table
,
LEX_CUSTRING
build_frm_image
(
THD
*
thd
,
const
LEX_CSTRING
&
table
,
HA_CREATE_INFO
*
create_info
,
List
<
Create_field
>
&
create_fields
,
uint
keys
,
KEY
*
key_info
,
handler
*
db_file
);
...
...
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