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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
ff0b7e4d
Commit
ff0b7e4d
authored
Jun 15, 2005
by
igor@rurik.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Manual merge
parents
38aa20d3
316815f4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
9 deletions
+51
-9
mysql-test/r/cast.result
mysql-test/r/cast.result
+8
-0
mysql-test/t/cast.test
mysql-test/t/cast.test
+11
-0
sql/field.cc
sql/field.cc
+29
-8
sql/field.h
sql/field.h
+3
-1
No files found.
mysql-test/r/cast.result
View file @
ff0b7e4d
...
@@ -344,6 +344,14 @@ select cast(s1 as decimal(7,2)) from t1;
...
@@ -344,6 +344,14 @@ select cast(s1 as decimal(7,2)) from t1;
cast(s1 as decimal(7,2))
cast(s1 as decimal(7,2))
111111.00
111111.00
drop table t1;
drop table t1;
CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
mt mediumtext, lt longtext);
INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05');
SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
CAST(v AS DECIMAL) CAST(tt AS DECIMAL) CAST(t AS DECIMAL) CAST(mt AS DECIMAL) CAST(lt AS DECIMAL)
1.01 2.02 3.03 4.04 5.05
DROP TABLE t1;
select cast(NULL as decimal(6)) as t1;
select cast(NULL as decimal(6)) as t1;
t1
t1
NULL
NULL
mysql-test/t/cast.test
View file @
ff0b7e4d
...
@@ -170,6 +170,17 @@ select cast(s1 as decimal(7,2)) from t1;
...
@@ -170,6 +170,17 @@ select cast(s1 as decimal(7,2)) from t1;
drop
table
t1
;
drop
table
t1
;
#
#
# Test for bug #11283: field conversion from varchar, and text types to decimal
#
CREATE
TABLE
t1
(
v
varchar
(
10
),
tt
tinytext
,
t
text
,
mt
mediumtext
,
lt
longtext
);
INSERT
INTO
t1
VALUES
(
'1.01'
,
'2.02'
,
'3.03'
,
'4.04'
,
'5.05'
);
SELECT
CAST
(
v
AS
DECIMAL
),
CAST
(
tt
AS
DECIMAL
),
CAST
(
t
AS
DECIMAL
),
CAST
(
mt
AS
DECIMAL
),
CAST
(
lt
AS
DECIMAL
)
from
t1
;
DROP
TABLE
t1
;
# Bug @10237 (CAST(NULL DECIMAL) crashes server)
# Bug @10237 (CAST(NULL DECIMAL) crashes server)
#
#
select
cast
(
NULL
as
decimal
(
6
))
as
t1
;
select
cast
(
NULL
as
decimal
(
6
))
as
t1
;
...
...
sql/field.cc
View file @
ff0b7e4d
...
@@ -5956,14 +5956,6 @@ longlong Field_string::val_int(void)
...
@@ -5956,14 +5956,6 @@ longlong Field_string::val_int(void)
}
}
my_decimal
*
Field_longstr
::
val_decimal
(
my_decimal
*
decimal_value
)
{
str2my_decimal
(
E_DEC_FATAL_ERROR
,
ptr
,
field_length
,
charset
(),
decimal_value
);
return
decimal_value
;
}
String
*
Field_string
::
val_str
(
String
*
val_buffer
__attribute__
((
unused
)),
String
*
Field_string
::
val_str
(
String
*
val_buffer
__attribute__
((
unused
)),
String
*
val_ptr
)
String
*
val_ptr
)
{
{
...
@@ -5975,6 +5967,14 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
...
@@ -5975,6 +5967,14 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
}
}
my_decimal
*
Field_string
::
val_decimal
(
my_decimal
*
decimal_value
)
{
str2my_decimal
(
E_DEC_FATAL_ERROR
,
ptr
,
field_length
,
charset
(),
decimal_value
);
return
decimal_value
;
}
int
Field_string
::
cmp
(
const
char
*
a_ptr
,
const
char
*
b_ptr
)
int
Field_string
::
cmp
(
const
char
*
a_ptr
,
const
char
*
b_ptr
)
{
{
uint
a_len
,
b_len
;
uint
a_len
,
b_len
;
...
@@ -6288,6 +6288,15 @@ String *Field_varstring::val_str(String *val_buffer __attribute__((unused)),
...
@@ -6288,6 +6288,15 @@ String *Field_varstring::val_str(String *val_buffer __attribute__((unused)),
}
}
my_decimal
*
Field_varstring
::
val_decimal
(
my_decimal
*
decimal_value
)
{
uint
length
=
length_bytes
==
1
?
(
uint
)
(
uchar
)
*
ptr
:
uint2korr
(
ptr
);
str2my_decimal
(
E_DEC_FATAL_ERROR
,
ptr
+
length_bytes
,
length
,
charset
(),
decimal_value
);
return
decimal_value
;
}
int
Field_varstring
::
cmp
(
const
char
*
a_ptr
,
const
char
*
b_ptr
)
int
Field_varstring
::
cmp
(
const
char
*
a_ptr
,
const
char
*
b_ptr
)
{
{
uint
a_length
,
b_length
;
uint
a_length
,
b_length
;
...
@@ -6906,6 +6915,18 @@ String *Field_blob::val_str(String *val_buffer __attribute__((unused)),
...
@@ -6906,6 +6915,18 @@ String *Field_blob::val_str(String *val_buffer __attribute__((unused)),
}
}
my_decimal
*
Field_blob
::
val_decimal
(
my_decimal
*
decimal_value
)
{
char
*
blob
;
memcpy_fixed
(
&
blob
,
ptr
+
packlength
,
sizeof
(
char
*
));
if
(
!
blob
)
blob
=
""
;
str2my_decimal
(
E_DEC_FATAL_ERROR
,
blob
,
get_length
(
ptr
),
charset
(),
decimal_value
);
return
decimal_value
;
}
int
Field_blob
::
cmp
(
const
char
*
a
,
uint32
a_length
,
const
char
*
b
,
int
Field_blob
::
cmp
(
const
char
*
a
,
uint32
a_length
,
const
char
*
b
,
uint32
b_length
)
uint32
b_length
)
{
{
...
...
sql/field.h
View file @
ff0b7e4d
...
@@ -381,7 +381,6 @@ public:
...
@@ -381,7 +381,6 @@ public:
field_name_arg
,
table_arg
,
charset
)
field_name_arg
,
table_arg
,
charset
)
{}
{}
my_decimal
*
val_decimal
(
my_decimal
*
);
int
store_decimal
(
const
my_decimal
*
d
);
int
store_decimal
(
const
my_decimal
*
d
);
};
};
...
@@ -993,6 +992,7 @@ public:
...
@@ -993,6 +992,7 @@ public:
double
val_real
(
void
);
double
val_real
(
void
);
longlong
val_int
(
void
);
longlong
val_int
(
void
);
String
*
val_str
(
String
*
,
String
*
);
String
*
val_str
(
String
*
,
String
*
);
my_decimal
*
val_decimal
(
my_decimal
*
);
int
cmp
(
const
char
*
,
const
char
*
);
int
cmp
(
const
char
*
,
const
char
*
);
void
sort_string
(
char
*
buff
,
uint
length
);
void
sort_string
(
char
*
buff
,
uint
length
);
void
sql_type
(
String
&
str
)
const
;
void
sql_type
(
String
&
str
)
const
;
...
@@ -1051,6 +1051,7 @@ public:
...
@@ -1051,6 +1051,7 @@ public:
double
val_real
(
void
);
double
val_real
(
void
);
longlong
val_int
(
void
);
longlong
val_int
(
void
);
String
*
val_str
(
String
*
,
String
*
);
String
*
val_str
(
String
*
,
String
*
);
my_decimal
*
val_decimal
(
my_decimal
*
);
int
cmp
(
const
char
*
,
const
char
*
);
int
cmp
(
const
char
*
,
const
char
*
);
void
sort_string
(
char
*
buff
,
uint
length
);
void
sort_string
(
char
*
buff
,
uint
length
);
void
get_key_image
(
char
*
buff
,
uint
length
,
imagetype
type
);
void
get_key_image
(
char
*
buff
,
uint
length
,
imagetype
type
);
...
@@ -1106,6 +1107,7 @@ public:
...
@@ -1106,6 +1107,7 @@ public:
double
val_real
(
void
);
double
val_real
(
void
);
longlong
val_int
(
void
);
longlong
val_int
(
void
);
String
*
val_str
(
String
*
,
String
*
);
String
*
val_str
(
String
*
,
String
*
);
my_decimal
*
val_decimal
(
my_decimal
*
);
int
cmp
(
const
char
*
,
const
char
*
);
int
cmp
(
const
char
*
,
const
char
*
);
int
cmp
(
const
char
*
a
,
uint32
a_length
,
const
char
*
b
,
uint32
b_length
);
int
cmp
(
const
char
*
a
,
uint32
a_length
,
const
char
*
b
,
uint32
b_length
);
int
cmp_binary
(
const
char
*
a
,
const
char
*
b
,
uint32
max_length
=~
0L
);
int
cmp_binary
(
const
char
*
a
,
const
char
*
b
,
uint32
max_length
=~
0L
);
...
...
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