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
cd5744db
Commit
cd5744db
authored
Feb 26, 2009
by
Ramil Kalimullin
Browse files
Options
Browse Files
Download
Plain Diff
Auto-merge
parents
780a0aa0
debb95ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
12 deletions
+25
-12
sql/protocol.cc
sql/protocol.cc
+16
-6
tests/mysql_client_test.c
tests/mysql_client_test.c
+9
-6
No files found.
sql/protocol.cc
View file @
cd5744db
...
...
@@ -573,7 +573,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
else
{
/* With conversion */
uint
max_char_len
;
ulonglong
max_length
;
uint32
field_length
;
int2store
(
pos
,
thd_charset
->
number
);
/*
For TEXT/BLOB columns, field_length describes the maximum data
...
...
@@ -584,12 +585,21 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
char_count * mbmaxlen, where character count is taken from the
definition of the column. In other words, the maximum number
of characters here is limited by the column definition.
When one has a LONG TEXT column with a single-byte
character set, and the connection character set is multi-byte, the
client may get fields longer than UINT_MAX32, due to
<character set column> -> <character set connection> conversion.
In that case column max length does not fit into the 4 bytes
reserved for it in the protocol.
*/
max_char_len
=
(
field
.
type
>=
(
int
)
MYSQL_TYPE_TINY_BLOB
&&
field
.
type
<=
(
int
)
MYSQL_TYPE_BLOB
)
?
field
.
length
/
item
->
collation
.
collation
->
mbminlen
:
field
.
length
/
item
->
collation
.
collation
->
mbmaxlen
;
int4store
(
pos
+
2
,
max_char_len
*
thd_charset
->
mbmaxlen
);
max_length
=
(
field
.
type
>=
MYSQL_TYPE_TINY_BLOB
&&
field
.
type
<=
MYSQL_TYPE_BLOB
)
?
field
.
length
/
item
->
collation
.
collation
->
mbminlen
:
field
.
length
/
item
->
collation
.
collation
->
mbmaxlen
;
max_length
*=
thd_charset
->
mbmaxlen
;
field_length
=
(
max_length
>
UINT_MAX32
)
?
UINT_MAX32
:
max_length
;
int4store
(
pos
+
2
,
field_length
);
}
pos
[
6
]
=
field
.
type
;
int2store
(
pos
+
7
,
field
.
flags
);
...
...
tests/mysql_client_test.c
View file @
cd5744db
...
...
@@ -723,6 +723,7 @@ static void do_verify_prepare_field(MYSQL_RES *result,
{
MYSQL_FIELD
*
field
;
CHARSET_INFO
*
cs
;
ulonglong
expected_field_length
;
if
(
!
(
field
=
mysql_fetch_field_direct
(
result
,
no
)))
{
...
...
@@ -731,6 +732,8 @@ static void do_verify_prepare_field(MYSQL_RES *result,
}
cs
=
get_charset
(
field
->
charsetnr
,
0
);
DIE_UNLESS
(
cs
);
if
((
expected_field_length
=
length
*
cs
->
mbmaxlen
)
>
UINT_MAX32
)
expected_field_length
=
UINT_MAX32
;
if
(
!
opt_silent
)
{
fprintf
(
stdout
,
"
\n
field[%d]:"
,
no
);
...
...
@@ -745,8 +748,8 @@ static void do_verify_prepare_field(MYSQL_RES *result,
fprintf
(
stdout
,
"
\n
org_table:`%s`
\t
(expected: `%s`)"
,
field
->
org_table
,
org_table
);
fprintf
(
stdout
,
"
\n
database :`%s`
\t
(expected: `%s`)"
,
field
->
db
,
db
);
fprintf
(
stdout
,
"
\n
length :`%lu`
\t
(expected: `%lu`)"
,
field
->
length
,
length
*
cs
->
mbmaxlen
);
fprintf
(
stdout
,
"
\n
length :`%lu`
\t
(expected: `%l
l
u`)"
,
field
->
length
,
expected_field_length
);
fprintf
(
stdout
,
"
\n
maxlength:`%ld`"
,
field
->
max_length
);
fprintf
(
stdout
,
"
\n
charsetnr:`%d`"
,
field
->
charsetnr
);
fprintf
(
stdout
,
"
\n
default :`%s`
\t
(expected: `%s`)"
,
...
...
@@ -782,11 +785,11 @@ static void do_verify_prepare_field(MYSQL_RES *result,
as utf8. Field length is calculated as number of characters * maximum
number of bytes a character can occupy.
*/
if
(
length
&&
field
->
length
!=
length
*
cs
->
mbmaxlen
)
if
(
length
&&
(
field
->
length
!=
expected_field_length
)
)
{
fprintf
(
stderr
,
"Expected field length: %
d, got length: %d
\n
"
,
(
int
)
(
length
*
cs
->
mbmaxlen
),
(
int
)
field
->
length
);
DIE_UNLESS
(
field
->
length
==
length
*
cs
->
mbmaxlen
);
fprintf
(
stderr
,
"Expected field length: %
llu, got length: %lu
\n
"
,
expected_field_length
,
field
->
length
);
DIE_UNLESS
(
field
->
length
==
expected_field_length
);
}
if
(
def
)
DIE_UNLESS
(
strcmp
(
field
->
def
,
def
)
==
0
);
...
...
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