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
9c031fc2
Commit
9c031fc2
authored
Oct 01, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20716 Unify make_table_field() and make_table_field_from_def() for integer and real types
parent
4b5a7674
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
146 deletions
+39
-146
sql/field.cc
sql/field.cc
+12
-0
sql/field.h
sql/field.h
+1
-0
sql/sql_type.cc
sql/sql_type.cc
+16
-106
sql/sql_type.h
sql/sql_type.h
+10
-40
No files found.
sql/field.cc
View file @
9c031fc2
...
...
@@ -10562,6 +10562,18 @@ Column_definition_attributes::Column_definition_attributes(const Field *field)
{}
Column_definition_attributes
::
Column_definition_attributes
(
const
Type_all_attributes
&
attr
)
:
length
(
attr
.
max_length
),
decimals
(
attr
.
decimals
),
unireg_check
(
Field
::
NONE
),
interval
(
attr
.
get_typelib
()),
charset
(
attr
.
collation
.
collation
),
srid
(
0
),
pack_flag
(
attr
.
unsigned_flag
?
0
:
FIELDFLAG_DECIMAL
)
{}
/** Create a field suitable for create of table. */
Column_definition
::
Column_definition
(
THD
*
thd
,
Field
*
old_field
,
...
...
sql/field.h
View file @
9c031fc2
...
...
@@ -4806,6 +4806,7 @@ class Column_definition_attributes
pack_flag
(
0
)
{
}
Column_definition_attributes
(
const
Field
*
field
);
Column_definition_attributes
(
const
Type_all_attributes
&
attr
);
Field
*
make_field
(
TABLE_SHARE
*
share
,
MEM_ROOT
*
mem_root
,
const
Record_addr
*
rec
,
const
Type_handler
*
handler
,
...
...
sql/sql_type.cc
View file @
9c031fc2
...
...
@@ -3459,76 +3459,16 @@ Field *Type_handler::make_and_init_table_field(MEM_ROOT *root,
}
Field
*
Type_handler_
tiny
::
make_table_field
(
MEM_ROOT
*
root
,
Field
*
Type_handler_
int_result
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
{
DBUG_ASSERT
(
is_unsigned
()
==
attr
.
unsigned_flag
);
return
new
(
root
)
Field_tiny
(
addr
.
ptr
(),
attr
.
max_char_length
(),
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
}
Field
*
Type_handler_short
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
{
DBUG_ASSERT
(
is_unsigned
()
==
attr
.
unsigned_flag
);
return
new
(
root
)
Field_short
(
addr
.
ptr
(),
attr
.
max_char_length
(),
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
}
Field
*
Type_handler_int24
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
{
DBUG_ASSERT
(
is_unsigned
()
==
attr
.
unsigned_flag
);
return
new
(
root
)
Field_medium
(
addr
.
ptr
(),
attr
.
max_char_length
(),
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
}
Field
*
Type_handler_long
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
{
DBUG_ASSERT
(
is_unsigned
()
==
attr
.
unsigned_flag
);
return
new
(
root
)
Field_long
(
addr
.
ptr
(),
attr
.
max_char_length
(),
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
}
Field
*
Type_handler_longlong
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
{
DBUG_ASSERT
(
is_unsigned
()
==
attr
.
unsigned_flag
);
return
new
(
root
)
Field_longlong
(
addr
.
ptr
(),
attr
.
max_char_length
(),
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
Column_definition_attributes
dattr
(
attr
);
return
make_table_field_from_def
(
share
,
root
,
name
,
addr
,
Bit_addr
(),
&
dattr
,
0
);
}
...
...
@@ -3547,31 +3487,16 @@ Field *Type_handler_vers_trx_id::make_table_field(MEM_ROOT *root,
}
Field
*
Type_handler_float
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
{
return
new
(
root
)
Field_float
(
addr
.
ptr
(),
attr
.
max_char_length
(),
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
,
(
uint8
)
attr
.
decimals
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
}
Field
*
Type_handler_double
::
make_table_field
(
MEM_ROOT
*
root
,
Field
*
Type_handler_real_result
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
{
return
new
(
root
)
Field_double
(
addr
.
ptr
(),
attr
.
max_char_length
(),
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
,
(
uint8
)
attr
.
decimals
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
Column_definition_attributes
dattr
(
attr
);
return
make_table_field_from_def
(
share
,
root
,
name
,
addr
,
Bit_addr
(),
&
dattr
,
0
);
}
...
...
@@ -3590,11 +3515,9 @@ Type_handler_olddecimal::make_table_field(MEM_ROOT *root,
in make_field() in field.cc, to open old tables with old decimal.
*/
DBUG_ASSERT
(
0
);
return
new
(
root
)
Field_decimal
(
addr
.
ptr
(),
attr
.
max_length
,
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
,
(
uint8
)
attr
.
decimals
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
Column_definition_attributes
dattr
(
attr
);
return
make_table_field_from_def
(
share
,
root
,
name
,
addr
,
Bit_addr
(),
&
dattr
,
0
);
}
...
...
@@ -3646,19 +3569,6 @@ Type_handler_newdecimal::make_table_field(MEM_ROOT *root,
}
Field
*
Type_handler_year
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
{
return
new
(
root
)
Field_year
(
addr
.
ptr
(),
attr
.
max_length
,
addr
.
null_ptr
(),
addr
.
null_bit
(),
Field
::
NONE
,
name
);
}
Field
*
Type_handler_null
::
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
...
...
sql/sql_type.h
View file @
9c031fc2
...
...
@@ -4391,6 +4391,11 @@ class Type_handler_real_result: public Type_handler_numeric
}
virtual
~
Type_handler_real_result
()
{}
const
Type_handler
*
type_handler_for_comparison
()
const
override
;
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
void
Column_definition_reuse_fix_attributes
(
THD
*
thd
,
Column_definition
*
c
,
const
Field
*
field
)
...
...
@@ -4751,6 +4756,11 @@ class Type_handler_int_result: public Type_handler_numeric
bool
subquery_type_allows_materialization
(
const
Item
*
inner
,
const
Item
*
outer
)
const
override
;
Field
*
make_num_distinct_aggregator_field
(
MEM_ROOT
*
,
const
Item
*
)
const
override
;
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
void
make_sort_key
(
uchar
*
to
,
Item
*
item
,
const
SORT_FIELD_ATTR
*
sort_field
,
Sort_param
*
param
)
const
override
;
void
...
...
@@ -5122,11 +5132,6 @@ class Type_handler_tiny: public Type_handler_general_purpose_int
handler
*
file
,
ulonglong
table_flags
)
const
override
{
return
Column_definition_prepare_stage2_legacy_num
(
c
,
MYSQL_TYPE_TINY
);
}
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
Field
*
make_schema_field
(
MEM_ROOT
*
root
,
TABLE
*
table
,
const
Record_addr
&
addr
,
...
...
@@ -5181,11 +5186,6 @@ class Type_handler_short: public Type_handler_general_purpose_int
handler
*
file
,
ulonglong
table_flags
)
const
override
{
return
Column_definition_prepare_stage2_legacy_num
(
c
,
MYSQL_TYPE_SHORT
);
}
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
Field
*
make_schema_field
(
MEM_ROOT
*
root
,
TABLE
*
table
,
const
Record_addr
&
addr
,
...
...
@@ -5240,11 +5240,6 @@ class Type_handler_long: public Type_handler_general_purpose_int
handler
*
file
,
ulonglong
table_flags
)
const
override
{
return
Column_definition_prepare_stage2_legacy_num
(
c
,
MYSQL_TYPE_LONG
);
}
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
Field
*
make_schema_field
(
MEM_ROOT
*
root
,
TABLE
*
table
,
const
Record_addr
&
addr
,
...
...
@@ -5315,11 +5310,6 @@ class Type_handler_longlong: public Type_handler_general_purpose_int
{
return
Column_definition_prepare_stage2_legacy_num
(
c
,
MYSQL_TYPE_LONGLONG
);
}
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
Field
*
make_schema_field
(
MEM_ROOT
*
root
,
TABLE
*
table
,
const
Record_addr
&
addr
,
...
...
@@ -5386,11 +5376,6 @@ class Type_handler_int24: public Type_handler_general_purpose_int
handler
*
file
,
ulonglong
table_flags
)
const
override
{
return
Column_definition_prepare_stage2_legacy_num
(
c
,
MYSQL_TYPE_INT24
);
}
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
Field
*
make_table_field_from_def
(
TABLE_SHARE
*
share
,
MEM_ROOT
*
mem_root
,
const
LEX_CSTRING
*
name
,
...
...
@@ -5441,11 +5426,6 @@ class Type_handler_year: public Type_handler_int_result
handler
*
file
,
ulonglong
table_flags
)
const
override
{
return
Column_definition_prepare_stage2_legacy_num
(
c
,
MYSQL_TYPE_YEAR
);
}
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
Field
*
make_table_field_from_def
(
TABLE_SHARE
*
share
,
MEM_ROOT
*
mem_root
,
const
LEX_CSTRING
*
name
,
...
...
@@ -5557,11 +5537,6 @@ class Type_handler_float: public Type_handler_real_result
handler
*
file
,
ulonglong
table_flags
)
const
override
{
return
Column_definition_prepare_stage2_legacy_real
(
c
,
MYSQL_TYPE_FLOAT
);
}
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
Field
*
make_schema_field
(
MEM_ROOT
*
root
,
TABLE
*
table
,
const
Record_addr
&
addr
,
...
...
@@ -5617,11 +5592,6 @@ class Type_handler_double: public Type_handler_real_result
handler
*
file
,
ulonglong
table_flags
)
const
override
{
return
Column_definition_prepare_stage2_legacy_real
(
c
,
MYSQL_TYPE_DOUBLE
);
}
Field
*
make_table_field
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE_SHARE
*
share
)
const
override
;
Field
*
make_schema_field
(
MEM_ROOT
*
root
,
TABLE
*
table
,
const
Record_addr
&
addr
,
...
...
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