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
5e356ce7
Commit
5e356ce7
authored
Oct 02, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20721 Implement sql_type() for Field_real and Field_int
parent
9c031fc2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
80 deletions
+31
-80
sql/field.cc
sql/field.cc
+29
-73
sql/field.h
sql/field.h
+2
-7
No files found.
sql/field.cc
View file @
5e356ce7
...
@@ -3637,6 +3637,17 @@ int Field_int::store_time_dec(const MYSQL_TIME *ltime, uint dec_arg)
...
@@ -3637,6 +3637,17 @@ int Field_int::store_time_dec(const MYSQL_TIME *ltime, uint dec_arg)
}
}
void
Field_int
::
sql_type
(
String
&
res
)
const
{
CHARSET_INFO
*
cs
=
res
.
charset
();
Name
name
=
type_handler
()
->
type_handler_signed
()
->
name
();
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"%.*s(%d)"
,
(
int
)
name
.
length
(),
name
.
ptr
(),
(
int
)
field_length
));
add_zerofill_and_unsigned
(
res
);
}
/****************************************************************************
/****************************************************************************
** tiny int
** tiny int
****************************************************************************/
****************************************************************************/
...
@@ -3789,14 +3800,6 @@ void Field_tiny::sort_string(uchar *to,uint length __attribute__((unused)))
...
@@ -3789,14 +3800,6 @@ void Field_tiny::sort_string(uchar *to,uint length __attribute__((unused)))
to
[
0
]
=
(
char
)
(
ptr
[
0
]
^
(
uchar
)
128
);
/* Revers signbit */
to
[
0
]
=
(
char
)
(
ptr
[
0
]
^
(
uchar
)
128
);
/* Revers signbit */
}
}
void
Field_tiny
::
sql_type
(
String
&
res
)
const
{
CHARSET_INFO
*
cs
=
res
.
charset
();
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"tinyint(%d)"
,(
int
)
field_length
));
add_zerofill_and_unsigned
(
res
);
}
/****************************************************************************
/****************************************************************************
Field type short int (2 byte)
Field type short int (2 byte)
****************************************************************************/
****************************************************************************/
...
@@ -3962,15 +3965,6 @@ void Field_short::sort_string(uchar *to,uint length __attribute__((unused)))
...
@@ -3962,15 +3965,6 @@ void Field_short::sort_string(uchar *to,uint length __attribute__((unused)))
to
[
1
]
=
ptr
[
0
];
to
[
1
]
=
ptr
[
0
];
}
}
void
Field_short
::
sql_type
(
String
&
res
)
const
{
CHARSET_INFO
*
cs
=
res
.
charset
();
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"smallint(%d)"
,(
int
)
field_length
));
add_zerofill_and_unsigned
(
res
);
}
/****************************************************************************
/****************************************************************************
Field type medium int (3 byte)
Field type medium int (3 byte)
****************************************************************************/
****************************************************************************/
...
@@ -4161,14 +4155,6 @@ void Field_medium::sort_string(uchar *to,uint length __attribute__((unused)))
...
@@ -4161,14 +4155,6 @@ void Field_medium::sort_string(uchar *to,uint length __attribute__((unused)))
}
}
void
Field_medium
::
sql_type
(
String
&
res
)
const
{
CHARSET_INFO
*
cs
=
res
.
charset
();
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"mediumint(%d)"
,(
int
)
field_length
));
add_zerofill_and_unsigned
(
res
);
}
/****************************************************************************
/****************************************************************************
** long int
** long int
****************************************************************************/
****************************************************************************/
...
@@ -4334,14 +4320,6 @@ void Field_long::sort_string(uchar *to,uint length __attribute__((unused)))
...
@@ -4334,14 +4320,6 @@ void Field_long::sort_string(uchar *to,uint length __attribute__((unused)))
}
}
void
Field_long
::
sql_type
(
String
&
res
)
const
{
CHARSET_INFO
*
cs
=
res
.
charset
();
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"int(%d)"
,(
int
)
field_length
));
add_zerofill_and_unsigned
(
res
);
}
/****************************************************************************
/****************************************************************************
Field type longlong int (8 bytes)
Field type longlong int (8 bytes)
****************************************************************************/
****************************************************************************/
...
@@ -4485,14 +4463,6 @@ void Field_longlong::sort_string(uchar *to,uint length __attribute__((unused)))
...
@@ -4485,14 +4463,6 @@ void Field_longlong::sort_string(uchar *to,uint length __attribute__((unused)))
}
}
void
Field_longlong
::
sql_type
(
String
&
res
)
const
{
CHARSET_INFO
*
cs
=
res
.
charset
();
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"bigint(%d)"
,(
int
)
field_length
));
add_zerofill_and_unsigned
(
res
);
}
void
Field_longlong
::
set_max
()
void
Field_longlong
::
set_max
()
{
{
DBUG_ASSERT
(
marked_for_write_or_computed
());
DBUG_ASSERT
(
marked_for_write_or_computed
());
...
@@ -4663,22 +4633,6 @@ Binlog_type_info Field_float::binlog_type_info() const
...
@@ -4663,22 +4633,6 @@ Binlog_type_info Field_float::binlog_type_info() const
}
}
void
Field_float
::
sql_type
(
String
&
res
)
const
{
if
(
dec
>=
FLOATING_POINT_DECIMALS
)
{
res
.
set_ascii
(
STRING_WITH_LEN
(
"float"
));
}
else
{
CHARSET_INFO
*
cs
=
res
.
charset
();
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"float(%d,%d)"
,(
int
)
field_length
,
dec
));
}
add_zerofill_and_unsigned
(
res
);
}
/****************************************************************************
/****************************************************************************
double precision floating point numbers
double precision floating point numbers
****************************************************************************/
****************************************************************************/
...
@@ -4900,6 +4854,24 @@ Item *Field_real::get_equal_const_item(THD *thd, const Context &ctx,
...
@@ -4900,6 +4854,24 @@ Item *Field_real::get_equal_const_item(THD *thd, const Context &ctx,
}
}
void
Field_real
::
sql_type
(
String
&
res
)
const
{
const
Name
name
=
type_handler
()
->
name
();
if
(
dec
>=
FLOATING_POINT_DECIMALS
)
{
res
.
set_ascii
(
name
.
ptr
(),
name
.
length
());
}
else
{
CHARSET_INFO
*
cs
=
res
.
charset
();
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"%.*s(%d,%d)"
,
(
int
)
name
.
length
(),
name
.
ptr
(),
(
int
)
field_length
,
dec
));
}
add_zerofill_and_unsigned
(
res
);
}
String
*
Field_double
::
val_str
(
String
*
val_buffer
,
String
*
Field_double
::
val_str
(
String
*
val_buffer
,
String
*
val_ptr
__attribute__
((
unused
)))
String
*
val_ptr
__attribute__
((
unused
)))
{
{
...
@@ -4975,22 +4947,6 @@ Binlog_type_info Field_double::binlog_type_info() const
...
@@ -4975,22 +4947,6 @@ Binlog_type_info Field_double::binlog_type_info() const
}
}
void
Field_double
::
sql_type
(
String
&
res
)
const
{
CHARSET_INFO
*
cs
=
res
.
charset
();
if
(
dec
>=
FLOATING_POINT_DECIMALS
)
{
res
.
set_ascii
(
STRING_WITH_LEN
(
"double"
));
}
else
{
res
.
length
(
cs
->
cset
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"double(%d,%d)"
,(
int
)
field_length
,
dec
));
}
add_zerofill_and_unsigned
(
res
);
}
/**
/**
TIMESTAMP type holds datetime values in range from 1970-01-01 00:00:01 UTC to
TIMESTAMP type holds datetime values in range from 1970-01-01 00:00:01 UTC to
2038-01-01 00:00:00 UTC stored as number of seconds since Unix
2038-01-01 00:00:00 UTC stored as number of seconds since Unix
...
...
sql/field.h
View file @
5e356ce7
...
@@ -2136,6 +2136,7 @@ class Field_real :public Field_num {
...
@@ -2136,6 +2136,7 @@ class Field_real :public Field_num {
Information_schema_numeric_attributes
(
field_length
)
:
Information_schema_numeric_attributes
(
field_length
)
:
Information_schema_numeric_attributes
(
field_length
,
dec
);
Information_schema_numeric_attributes
(
field_length
,
dec
);
}
}
void
sql_type
(
String
&
str
)
const
override
;
int
save_in_field
(
Field
*
to
)
override
{
return
to
->
store
(
val_real
());
}
int
save_in_field
(
Field
*
to
)
override
{
return
to
->
store
(
val_real
());
}
bool
memcpy_field_possible
(
const
Field
*
from
)
const
override
bool
memcpy_field_possible
(
const
Field
*
from
)
const
override
{
{
...
@@ -2372,6 +2373,7 @@ class Field_int :public Field_num
...
@@ -2372,6 +2373,7 @@ class Field_int :public Field_num
uint32
prec
=
type_limits_int
()
->
precision
();
uint32
prec
=
type_limits_int
()
->
precision
();
return
Information_schema_numeric_attributes
(
prec
,
0
);
return
Information_schema_numeric_attributes
(
prec
,
0
);
}
}
void
sql_type
(
String
&
str
)
const
override
;
SEL_ARG
*
get_mm_leaf
(
RANGE_OPT_PARAM
*
param
,
KEY_PART
*
key_part
,
SEL_ARG
*
get_mm_leaf
(
RANGE_OPT_PARAM
*
param
,
KEY_PART
*
key_part
,
const
Item_bool_func
*
cond
,
const
Item_bool_func
*
cond
,
scalar_comparison_op
op
,
Item
*
value
)
override
scalar_comparison_op
op
,
Item
*
value
)
override
...
@@ -2410,7 +2412,6 @@ class Field_tiny :public Field_int
...
@@ -2410,7 +2412,6 @@ class Field_tiny :public Field_int
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
uint32
pack_length
()
const
override
{
return
1
;
}
uint32
pack_length
()
const
override
{
return
1
;
}
void
sql_type
(
String
&
str
)
const
override
;
const
Type_limits_int
*
type_limits_int
()
const
override
const
Type_limits_int
*
type_limits_int
()
const
override
{
{
return
type_handler_priv
()
->
type_limits_int
();
return
type_handler_priv
()
->
type_limits_int
();
...
@@ -2472,7 +2473,6 @@ class Field_short :public Field_int
...
@@ -2472,7 +2473,6 @@ class Field_short :public Field_int
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
uint32
pack_length
()
const
override
{
return
2
;
}
uint32
pack_length
()
const
override
{
return
2
;
}
void
sql_type
(
String
&
str
)
const
override
;
const
Type_limits_int
*
type_limits_int
()
const
override
const
Type_limits_int
*
type_limits_int
()
const
override
{
{
return
type_handler_priv
()
->
type_limits_int
();
return
type_handler_priv
()
->
type_limits_int
();
...
@@ -2518,7 +2518,6 @@ class Field_medium :public Field_int
...
@@ -2518,7 +2518,6 @@ class Field_medium :public Field_int
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
uint32
pack_length
()
const
override
{
return
3
;
}
uint32
pack_length
()
const
override
{
return
3
;
}
void
sql_type
(
String
&
str
)
const
override
;
const
Type_limits_int
*
type_limits_int
()
const
override
const
Type_limits_int
*
type_limits_int
()
const
override
{
{
return
type_handler_priv
()
->
type_limits_int
();
return
type_handler_priv
()
->
type_limits_int
();
...
@@ -2569,7 +2568,6 @@ class Field_long :public Field_int
...
@@ -2569,7 +2568,6 @@ class Field_long :public Field_int
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
uint32
pack_length
()
const
override
{
return
4
;
}
uint32
pack_length
()
const
override
{
return
4
;
}
void
sql_type
(
String
&
str
)
const
override
;
const
Type_limits_int
*
type_limits_int
()
const
override
const
Type_limits_int
*
type_limits_int
()
const
override
{
{
return
type_handler_priv
()
->
type_limits_int
();
return
type_handler_priv
()
->
type_limits_int
();
...
@@ -2629,7 +2627,6 @@ class Field_longlong :public Field_int
...
@@ -2629,7 +2627,6 @@ class Field_longlong :public Field_int
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
int
cmp
(
const
uchar
*
,
const
uchar
*
)
const
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
uint32
pack_length
()
const
override
{
return
8
;
}
uint32
pack_length
()
const
override
{
return
8
;
}
void
sql_type
(
String
&
str
)
const
override
;
const
Type_limits_int
*
type_limits_int
()
const
override
const
Type_limits_int
*
type_limits_int
()
const
override
{
{
return
type_handler_priv
()
->
type_limits_int
();
return
type_handler_priv
()
->
type_limits_int
();
...
@@ -2731,7 +2728,6 @@ class Field_float :public Field_real {
...
@@ -2731,7 +2728,6 @@ class Field_float :public Field_real {
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
uint32
pack_length
()
const
override
{
return
sizeof
(
float
);
}
uint32
pack_length
()
const
override
{
return
sizeof
(
float
);
}
uint
row_pack_length
()
const
override
{
return
pack_length
();
}
uint
row_pack_length
()
const
override
{
return
pack_length
();
}
void
sql_type
(
String
&
str
)
const
override
;
ulonglong
get_max_int_value
()
const
override
ulonglong
get_max_int_value
()
const
override
{
{
/*
/*
...
@@ -2796,7 +2792,6 @@ class Field_double :public Field_real {
...
@@ -2796,7 +2792,6 @@ class Field_double :public Field_real {
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
uint32
pack_length
()
const
override
{
return
sizeof
(
double
);
}
uint32
pack_length
()
const
override
{
return
sizeof
(
double
);
}
uint
row_pack_length
()
const
override
{
return
pack_length
();
}
uint
row_pack_length
()
const
override
{
return
pack_length
();
}
void
sql_type
(
String
&
str
)
const
override
;
ulonglong
get_max_int_value
()
const
override
ulonglong
get_max_int_value
()
const
override
{
{
/*
/*
...
...
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