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
fddbc989
Commit
fddbc989
authored
Dec 17, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sql_type() is now ucs2 compatible
parent
656b49e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
43 deletions
+87
-43
sql/field.cc
sql/field.cc
+87
-43
No files found.
sql/field.cc
View file @
fddbc989
...
@@ -207,10 +207,17 @@ bool Field::send_binary(Protocol *protocol)
...
@@ -207,10 +207,17 @@ bool Field::send_binary(Protocol *protocol)
void
Field_num
::
add_zerofill_and_unsigned
(
String
&
res
)
const
void
Field_num
::
add_zerofill_and_unsigned
(
String
&
res
)
const
{
{
if
(
unsigned_flag
)
uint
oldlen
=
res
.
length
();
res
.
append
(
" unsigned"
);
if
(
oldlen
<
res
.
alloced_length
())
if
(
zerofill
)
{
res
.
append
(
" zerofill"
);
uint
len
=
res
.
alloced_length
()
-
oldlen
;
char
*
end
=
(
char
*
)(
res
.
ptr
()
+
oldlen
);
CHARSET_INFO
*
cs
=
res
.
charset
();
len
=
cs
->
snprintf
(
cs
,
end
,
len
,
"%s%s"
,
unsigned_flag
?
" unsigned"
:
""
,
zerofill
?
" zerofill"
:
""
);
res
.
length
(
len
+
oldlen
);
}
}
}
void
Field_num
::
make_field
(
Send_field
*
field
)
void
Field_num
::
make_field
(
Send_field
*
field
)
...
@@ -242,12 +249,17 @@ void Field_str::make_field(Send_field *field)
...
@@ -242,12 +249,17 @@ void Field_str::make_field(Send_field *field)
void
Field_str
::
add_binary_or_charset
(
String
&
res
)
const
void
Field_str
::
add_binary_or_charset
(
String
&
res
)
const
{
{
uint
oldlen
=
res
.
length
();
if
(
oldlen
<
res
.
alloced_length
())
{
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
res
.
alloced_length
()
-
oldlen
;
char
*
end
=
(
char
*
)(
res
.
ptr
()
+
oldlen
);
if
(
binary
())
if
(
binary
())
res
.
append
(
" binary"
);
len
=
cs
->
snprintf
(
cs
,
end
,
len
,
" binary"
);
else
else
{
len
=
cs
->
snprintf
(
cs
,
end
,
len
,
" character set %s"
,
field_charset
->
name
);
res
.
append
(
" character set "
);
res
.
length
(
oldlen
+
len
);
res
.
append
(
field_charset
->
name
);
}
}
}
}
...
@@ -333,7 +345,10 @@ bool Field::optimize_range(uint idx)
...
@@ -333,7 +345,10 @@ bool Field::optimize_range(uint idx)
void
Field_null
::
sql_type
(
String
&
res
)
const
void
Field_null
::
sql_type
(
String
&
res
)
const
{
{
res
.
copy
(
"null"
,
4
,
my_charset_latin1
,
res
.
charset
());
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
;
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"null"
);
res
.
length
(
len
);
}
}
...
@@ -909,13 +924,15 @@ void Field_decimal::sort_string(char *to,uint length)
...
@@ -909,13 +924,15 @@ void Field_decimal::sort_string(char *to,uint length)
void
Field_decimal
::
sql_type
(
String
&
res
)
const
void
Field_decimal
::
sql_type
(
String
&
res
)
const
{
{
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
tmp
=
field_length
;
uint
tmp
=
field_length
;
uint
len
;
uint
len
;
if
(
!
unsigned_flag
)
if
(
!
unsigned_flag
)
tmp
--
;
tmp
--
;
if
(
dec
)
if
(
dec
)
tmp
--
;
tmp
--
;
len
=
sprintf
((
char
*
)
res
.
ptr
(),
"decimal(%d,%d)"
,
tmp
,
dec
);
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"decimal(%d,%d)"
,
tmp
,
dec
);
res
.
length
(
len
);
res
.
length
(
len
);
add_zerofill_and_unsigned
(
res
);
add_zerofill_and_unsigned
(
res
);
}
}
...
@@ -1115,7 +1132,9 @@ void Field_tiny::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -1115,7 +1132,9 @@ void Field_tiny::sort_string(char *to,uint length __attribute__((unused)))
void
Field_tiny
::
sql_type
(
String
&
res
)
const
void
Field_tiny
::
sql_type
(
String
&
res
)
const
{
{
uint
len
=
sprintf
((
char
*
)
res
.
ptr
(),
"tinyint(%d)"
,(
int
)
field_length
);
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"tinyint(%d)"
,(
int
)
field_length
);
res
.
length
(
len
);
res
.
length
(
len
);
add_zerofill_and_unsigned
(
res
);
add_zerofill_and_unsigned
(
res
);
}
}
...
@@ -1387,7 +1406,9 @@ void Field_short::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -1387,7 +1406,9 @@ void Field_short::sort_string(char *to,uint length __attribute__((unused)))
void
Field_short
::
sql_type
(
String
&
res
)
const
void
Field_short
::
sql_type
(
String
&
res
)
const
{
{
uint
len
=
sprintf
((
char
*
)
res
.
ptr
(),
"smallint(%d)"
,(
int
)
field_length
);
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"smallint(%d)"
,(
int
)
field_length
);
res
.
length
(
len
);
res
.
length
(
len
);
add_zerofill_and_unsigned
(
res
);
add_zerofill_and_unsigned
(
res
);
}
}
...
@@ -1603,7 +1624,9 @@ void Field_medium::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -1603,7 +1624,9 @@ void Field_medium::sort_string(char *to,uint length __attribute__((unused)))
void
Field_medium
::
sql_type
(
String
&
res
)
const
void
Field_medium
::
sql_type
(
String
&
res
)
const
{
{
uint
len
=
sprintf
((
char
*
)
res
.
ptr
(),
"mediumint(%d)"
,(
int
)
field_length
);
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"mediumint(%d)"
,(
int
)
field_length
);
res
.
length
(
len
);
res
.
length
(
len
);
add_zerofill_and_unsigned
(
res
);
add_zerofill_and_unsigned
(
res
);
}
}
...
@@ -1865,7 +1888,9 @@ void Field_long::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -1865,7 +1888,9 @@ void Field_long::sort_string(char *to,uint length __attribute__((unused)))
void
Field_long
::
sql_type
(
String
&
res
)
const
void
Field_long
::
sql_type
(
String
&
res
)
const
{
{
uint
len
=
sprintf
((
char
*
)
res
.
ptr
(),
"int(%d)"
,(
int
)
field_length
);
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"int(%d)"
,(
int
)
field_length
);
res
.
length
(
len
);
res
.
length
(
len
);
add_zerofill_and_unsigned
(
res
);
add_zerofill_and_unsigned
(
res
);
}
}
...
@@ -2095,7 +2120,9 @@ void Field_longlong::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -2095,7 +2120,9 @@ void Field_longlong::sort_string(char *to,uint length __attribute__((unused)))
void
Field_longlong
::
sql_type
(
String
&
res
)
const
void
Field_longlong
::
sql_type
(
String
&
res
)
const
{
{
uint
len
=
sprintf
((
char
*
)
res
.
ptr
(),
"bigint(%d)"
,(
int
)
field_length
);
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"bigint(%d)"
,(
int
)
field_length
);
res
.
length
(
len
);
res
.
length
(
len
);
add_zerofill_and_unsigned
(
res
);
add_zerofill_and_unsigned
(
res
);
}
}
...
@@ -2360,15 +2387,16 @@ bool Field_float::send_binary(Protocol *protocol)
...
@@ -2360,15 +2387,16 @@ bool Field_float::send_binary(Protocol *protocol)
void
Field_float
::
sql_type
(
String
&
res
)
const
void
Field_float
::
sql_type
(
String
&
res
)
const
{
{
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
;
uint
len
;
if
(
dec
==
NOT_FIXED_DEC
)
if
(
dec
==
NOT_FIXED_DEC
)
{
{
strmov
((
char
*
)
res
.
ptr
(),
"float"
);
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"float"
);
len
=
5
;
}
}
else
else
{
{
len
=
sprintf
((
char
*
)
res
.
ptr
(),
"float(%d,%d)"
,(
int
)
field_length
,
dec
);
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"float(%d,%d)"
,(
int
)
field_length
,
dec
);
}
}
res
.
length
(
len
);
res
.
length
(
len
);
add_zerofill_and_unsigned
(
res
);
add_zerofill_and_unsigned
(
res
);
...
@@ -2619,15 +2647,16 @@ void Field_double::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -2619,15 +2647,16 @@ void Field_double::sort_string(char *to,uint length __attribute__((unused)))
void
Field_double
::
sql_type
(
String
&
res
)
const
void
Field_double
::
sql_type
(
String
&
res
)
const
{
{
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
;
uint
len
;
if
(
dec
==
NOT_FIXED_DEC
)
if
(
dec
==
NOT_FIXED_DEC
)
{
{
strmov
((
char
*
)
res
.
ptr
(),
"double"
);
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"double"
);
len
=
6
;
}
}
else
else
{
{
len
=
sprintf
((
char
*
)
res
.
ptr
(),
"double(%d,%d)"
,(
int
)
field_length
,
dec
);
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"double(%d,%d)"
,(
int
)
field_length
,
dec
);
}
}
res
.
length
(
len
);
res
.
length
(
len
);
add_zerofill_and_unsigned
(
res
);
add_zerofill_and_unsigned
(
res
);
...
@@ -2960,7 +2989,9 @@ void Field_timestamp::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -2960,7 +2989,9 @@ void Field_timestamp::sort_string(char *to,uint length __attribute__((unused)))
void
Field_timestamp
::
sql_type
(
String
&
res
)
const
void
Field_timestamp
::
sql_type
(
String
&
res
)
const
{
{
res
.
copy
(
"timestamp"
,
9
,
my_charset_latin1
,
res
.
charset
());
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"timestamp"
);
res
.
length
(
len
);
}
}
...
@@ -3152,7 +3183,9 @@ void Field_time::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -3152,7 +3183,9 @@ void Field_time::sort_string(char *to,uint length __attribute__((unused)))
void
Field_time
::
sql_type
(
String
&
res
)
const
void
Field_time
::
sql_type
(
String
&
res
)
const
{
{
res
.
copy
(
"time"
,
4
,
my_charset_latin1
,
res
.
charset
());
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"time"
);
res
.
length
(
len
);
}
}
/****************************************************************************
/****************************************************************************
...
@@ -3242,9 +3275,10 @@ String *Field_year::val_str(String *val_buffer,
...
@@ -3242,9 +3275,10 @@ String *Field_year::val_str(String *val_buffer,
void
Field_year
::
sql_type
(
String
&
res
)
const
void
Field_year
::
sql_type
(
String
&
res
)
const
{
{
ulong
length
=
my_sprintf
((
char
*
)
res
.
ptr
(),
CHARSET_INFO
*
cs
=
res
.
charset
();
((
char
*
)
res
.
ptr
(),
"year(%d)"
,(
int
)
field_length
));
ulong
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
res
.
length
(
length
);
"year(%d)"
,(
int
)
field_length
);
res
.
length
(
len
);
}
}
...
@@ -3414,7 +3448,9 @@ void Field_date::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -3414,7 +3448,9 @@ void Field_date::sort_string(char *to,uint length __attribute__((unused)))
void
Field_date
::
sql_type
(
String
&
res
)
const
void
Field_date
::
sql_type
(
String
&
res
)
const
{
{
res
.
copy
(
"date"
,
4
,
my_charset_latin1
,
res
.
charset
());
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"date"
);
res
.
length
(
len
);
}
}
/****************************************************************************
/****************************************************************************
...
@@ -3577,7 +3613,9 @@ void Field_newdate::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -3577,7 +3613,9 @@ void Field_newdate::sort_string(char *to,uint length __attribute__((unused)))
void
Field_newdate
::
sql_type
(
String
&
res
)
const
void
Field_newdate
::
sql_type
(
String
&
res
)
const
{
{
res
.
copy
(
"date"
,
4
,
my_charset_latin1
,
res
.
charset
());
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"date"
);
res
.
length
(
len
);
}
}
...
@@ -3801,7 +3839,9 @@ void Field_datetime::sort_string(char *to,uint length __attribute__((unused)))
...
@@ -3801,7 +3839,9 @@ void Field_datetime::sort_string(char *to,uint length __attribute__((unused)))
void
Field_datetime
::
sql_type
(
String
&
res
)
const
void
Field_datetime
::
sql_type
(
String
&
res
)
const
{
{
res
.
copy
(
"datetime"
,
8
,
my_charset_latin1
,
res
.
charset
());
CHARSET_INFO
*
cs
=
res
.
charset
();
uint
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"datetime"
);
res
.
length
(
len
);
}
}
/****************************************************************************
/****************************************************************************
...
@@ -3930,13 +3970,14 @@ void Field_string::sort_string(char *to,uint length)
...
@@ -3930,13 +3970,14 @@ void Field_string::sort_string(char *to,uint length)
void
Field_string
::
sql_type
(
String
&
res
)
const
void
Field_string
::
sql_type
(
String
&
res
)
const
{
{
ulong
length
=
my_sprintf
((
char
*
)
res
.
ptr
(),
CHARSET_INFO
*
cs
=
res
.
charset
();
((
char
*
)
res
.
ptr
(),
"%s(%d)"
,
ulong
length
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"%s(%d)"
,
(
field_length
>
3
&&
(
field_length
>
3
&&
(
table
->
db_options_in_use
&
(
table
->
db_options_in_use
&
HA_OPTION_PACK_RECORD
)
?
HA_OPTION_PACK_RECORD
)
?
"varchar"
:
"char"
),
"varchar"
:
"char"
),
(
int
)
field_length
)
)
;
(
int
)
field_length
);
res
.
length
(
length
);
res
.
length
(
length
);
add_binary_or_charset
(
res
);
add_binary_or_charset
(
res
);
}
}
...
@@ -4126,9 +4167,10 @@ void Field_varstring::sort_string(char *to,uint length)
...
@@ -4126,9 +4167,10 @@ void Field_varstring::sort_string(char *to,uint length)
void
Field_varstring
::
sql_type
(
String
&
res
)
const
void
Field_varstring
::
sql_type
(
String
&
res
)
const
{
{
ulong
length
=
my_sprintf
((
char
*
)
res
.
ptr
(),
CHARSET_INFO
*
cs
=
res
.
charset
();
((
char
*
)
res
.
ptr
(),
"varchar(%u)"
,
ulong
length
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
field_length
));
res
.
alloced_length
(),
"varchar(%u)"
,
field_length
);
res
.
length
(
length
);
res
.
length
(
length
);
add_binary_or_charset
(
res
);
add_binary_or_charset
(
res
);
}
}
...
@@ -4619,20 +4661,22 @@ void Field_blob::sort_string(char *to,uint length)
...
@@ -4619,20 +4661,22 @@ void Field_blob::sort_string(char *to,uint length)
void
Field_blob
::
sql_type
(
String
&
res
)
const
void
Field_blob
::
sql_type
(
String
&
res
)
const
{
{
CHARSET_INFO
*
cs
=
res
.
charset
();
const
char
*
str
;
const
char
*
str
;
uint
len
;
switch
(
packlength
)
{
switch
(
packlength
)
{
default:
str
=
"tiny"
;
break
;
default:
str
=
"tiny"
;
break
;
case
2
:
str
=
""
;
break
;
case
2
:
str
=
""
;
break
;
case
3
:
str
=
"medium"
;
break
;
case
3
:
str
=
"medium"
;
break
;
case
4
:
str
=
"long"
;
break
;
case
4
:
str
=
"long"
;
break
;
}
}
res
.
set
(
str
,(
uint
)
strlen
(
str
),
my_charset_latin1
);
res
.
append
(
binary
()
?
"blob"
:
"text"
);
len
=
cs
->
snprintf
(
cs
,(
char
*
)
res
.
ptr
(),
res
.
alloced_length
(),
"%s%s%s%s"
,
if
(
!
binary
())
str
,
{
binary
()
?
"blob"
:
"text"
,
res
.
append
(
" character set "
);
binary
()
?
""
:
" character set "
,
res
.
append
(
field_charset
->
name
);
binary
()
?
""
:
field_charset
->
name
);
}
res
.
length
(
len
);
}
}
...
...
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