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
5dd528a2
Commit
5dd528a2
authored
Feb 08, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update lengths for fields in MYSQL_FIELD
client/mysql.cc: Use field->name_length sql/lex.h: fix after merge
parent
e751d298
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
30 deletions
+51
-30
client/mysql.cc
client/mysql.cc
+2
-2
libmysql/libmysql.c
libmysql/libmysql.c
+49
-27
sql/lex.h
sql/lex.h
+0
-1
No files found.
client/mysql.cc
View file @
5dd528a2
...
@@ -1786,7 +1786,7 @@ print_table_data(MYSQL_RES *result)
...
@@ -1786,7 +1786,7 @@ print_table_data(MYSQL_RES *result)
separator
.
copy
(
"+"
,
1
,
system_charset_info
);
separator
.
copy
(
"+"
,
1
,
system_charset_info
);
while
((
field
=
mysql_fetch_field
(
result
)))
while
((
field
=
mysql_fetch_field
(
result
)))
{
{
uint
length
=
column_names
?
(
uint
)
strlen
(
field
->
name
)
:
0
;
uint
length
=
column_names
?
field
->
name_length
:
0
;
if
(
quick
)
if
(
quick
)
length
=
max
(
length
,
field
->
length
);
length
=
max
(
length
,
field
->
length
);
else
else
...
@@ -1928,7 +1928,7 @@ print_table_data_vertically(MYSQL_RES *result)
...
@@ -1928,7 +1928,7 @@ print_table_data_vertically(MYSQL_RES *result)
while
((
field
=
mysql_fetch_field
(
result
)))
while
((
field
=
mysql_fetch_field
(
result
)))
{
{
uint
length
=
(
uint
)
strlen
(
field
->
name
)
;
uint
length
=
field
->
name_length
;
if
(
length
>
max_length
)
if
(
length
>
max_length
)
max_length
=
length
;
max_length
=
length
;
field
->
max_length
=
length
;
field
->
max_length
=
length
;
...
...
libmysql/libmysql.c
View file @
5dd528a2
...
@@ -114,7 +114,7 @@ static sig_handler pipe_sig_handler(int sig);
...
@@ -114,7 +114,7 @@ static sig_handler pipe_sig_handler(int sig);
static
ulong
mysql_sub_escape_string
(
CHARSET_INFO
*
charset_info
,
char
*
to
,
static
ulong
mysql_sub_escape_string
(
CHARSET_INFO
*
charset_info
,
char
*
to
,
const
char
*
from
,
ulong
length
);
const
char
*
from
,
ulong
length
);
static
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_list
);
static
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_list
);
static
void
fetch_lengths
(
ulong
*
to
,
MYSQL_ROW
column
,
uint
field_count
);
static
my_bool
org_my_init_done
=
0
;
static
my_bool
org_my_init_done
=
0
;
int
STDCALL
mysql_server_init
(
int
argc
__attribute__
((
unused
)),
int
STDCALL
mysql_server_init
(
int
argc
__attribute__
((
unused
)),
...
@@ -1158,6 +1158,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
...
@@ -1158,6 +1158,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
{
{
MYSQL_ROWS
*
row
;
MYSQL_ROWS
*
row
;
MYSQL_FIELD
*
field
,
*
result
;
MYSQL_FIELD
*
field
,
*
result
;
ulong
lengths
[
8
];
/* Max of fields */
DBUG_ENTER
(
"unpack_fields"
);
DBUG_ENTER
(
"unpack_fields"
);
field
=
result
=
(
MYSQL_FIELD
*
)
alloc_root
(
alloc
,
field
=
result
=
(
MYSQL_FIELD
*
)
alloc_root
(
alloc
,
...
@@ -1174,11 +1175,19 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
...
@@ -1174,11 +1175,19 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
for
(
row
=
data
->
data
;
row
;
row
=
row
->
next
,
field
++
)
for
(
row
=
data
->
data
;
row
;
row
=
row
->
next
,
field
++
)
{
{
uchar
*
pos
;
uchar
*
pos
;
fetch_lengths
(
&
lengths
[
0
],
row
->
data
,
default_value
?
7
:
6
);
field
->
db
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
0
]);
field
->
db
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
0
]);
field
->
table
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
1
]);
field
->
table
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
1
]);
field
->
org_table
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
2
]);
field
->
org_table
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
2
]);
field
->
name
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
3
]);
field
->
name
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
3
]);
field
->
org_name
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
4
]);
field
->
org_name
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
4
]);
field
->
db_length
=
lengths
[
0
];
field
->
table_length
=
lengths
[
1
];
field
->
org_table_length
=
lengths
[
2
];
field
->
name_length
=
lengths
[
3
];
field
->
org_name_length
=
lengths
[
4
];
/* Unpack fixed length parts */
/* Unpack fixed length parts */
pos
=
(
uchar
*
)
row
->
data
[
5
];
pos
=
(
uchar
*
)
row
->
data
[
5
];
field
->
charsetnr
=
uint2korr
(
pos
);
field
->
charsetnr
=
uint2korr
(
pos
);
...
@@ -1190,10 +1199,10 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
...
@@ -1190,10 +1199,10 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
if
(
INTERNAL_NUM_FIELD
(
field
))
if
(
INTERNAL_NUM_FIELD
(
field
))
field
->
flags
|=
NUM_FLAG
;
field
->
flags
|=
NUM_FLAG
;
if
(
default_value
&&
row
->
data
[
6
])
if
(
default_value
&&
row
->
data
[
6
])
{
field
->
def
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
8
]);
field
->
def
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
8
]);
else
field
->
def_length
=
lengths
[
6
];
field
->
def
=
0
;
}
field
->
max_length
=
0
;
}
}
}
}
#ifndef DELETE_SUPPORT_OF_4_0_PROTOCOL
#ifndef DELETE_SUPPORT_OF_4_0_PROTOCOL
...
@@ -1202,11 +1211,15 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
...
@@ -1202,11 +1211,15 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
/* old protocol, for backward compatibility */
/* old protocol, for backward compatibility */
for
(
row
=
data
->
data
;
row
;
row
=
row
->
next
,
field
++
)
for
(
row
=
data
->
data
;
row
;
row
=
row
->
next
,
field
++
)
{
{
fetch_lengths
(
&
lengths
[
0
],
row
->
data
,
default_value
?
6
:
5
);
field
->
org_table
=
field
->
table
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
0
]);
field
->
org_table
=
field
->
table
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
0
]);
field
->
name
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
1
]);
field
->
name
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
1
]);
field
->
length
=
(
uint
)
uint3korr
(
row
->
data
[
2
]);
field
->
length
=
(
uint
)
uint3korr
(
row
->
data
[
2
]);
field
->
type
=
(
enum
enum_field_types
)
(
uchar
)
row
->
data
[
3
][
0
];
field
->
type
=
(
enum
enum_field_types
)
(
uchar
)
row
->
data
[
3
][
0
];
field
->
org_table_length
=
field
->
table_length
=
lengths
[
0
];
field
->
name_length
=
lengths
[
1
];
if
(
server_capabilities
&
CLIENT_LONG_FLAG
)
if
(
server_capabilities
&
CLIENT_LONG_FLAG
)
{
{
field
->
flags
=
uint2korr
(
row
->
data
[
4
]);
field
->
flags
=
uint2korr
(
row
->
data
[
4
]);
...
@@ -1220,7 +1233,10 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
...
@@ -1220,7 +1233,10 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
if
(
INTERNAL_NUM_FIELD
(
field
))
if
(
INTERNAL_NUM_FIELD
(
field
))
field
->
flags
|=
NUM_FLAG
;
field
->
flags
|=
NUM_FLAG
;
if
(
default_value
&&
row
->
data
[
5
])
if
(
default_value
&&
row
->
data
[
5
])
{
field
->
def
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
5
]);
field
->
def
=
strdup_root
(
alloc
,(
char
*
)
row
->
data
[
5
]);
field
->
def_length
=
lengths
[
5
];
}
else
else
field
->
def
=
0
;
field
->
def
=
0
;
field
->
max_length
=
0
;
field
->
max_length
=
0
;
...
@@ -2875,7 +2891,7 @@ get_info:
...
@@ -2875,7 +2891,7 @@ get_info:
mysql
->
extra_info
=
net_field_length_ll
(
&
pos
);
/* Maybe number of rec */
mysql
->
extra_info
=
net_field_length_ll
(
&
pos
);
/* Maybe number of rec */
if
(
!
(
fields
=
read_rows
(
mysql
,(
MYSQL_FIELD
*
)
0
,
5
)))
if
(
!
(
fields
=
read_rows
(
mysql
,(
MYSQL_FIELD
*
)
0
,
protocol_41
(
mysql
)
?
6
:
5
)))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
if
(
!
(
mysql
->
fields
=
unpack_fields
(
fields
,
&
mysql
->
field_alloc
,
if
(
!
(
mysql
->
fields
=
unpack_fields
(
fields
,
&
mysql
->
field_alloc
,
(
uint
)
field_count
,
0
,
(
uint
)
field_count
,
0
,
...
@@ -3122,33 +3138,37 @@ mysql_fetch_row(MYSQL_RES *res)
...
@@ -3122,33 +3138,37 @@ mysql_fetch_row(MYSQL_RES *res)
else the lengths are calculated from the offset between pointers.
else the lengths are calculated from the offset between pointers.
**************************************************************************/
**************************************************************************/
static
void
fetch_lengths
(
ulong
*
to
,
MYSQL_ROW
column
,
uint
field_count
)
{
ulong
*
prev_length
;
byte
*
start
=
0
;
MYSQL_ROW
end
;
prev_length
=
0
;
/* Keep gcc happy */
for
(
end
=
column
+
field_count
+
1
;
column
!=
end
;
column
++
,
to
++
)
{
if
(
!*
column
)
{
*
to
=
0
;
/* Null */
continue
;
}
if
(
start
)
/* Found end of prev string */
*
prev_length
=
(
ulong
)
(
*
column
-
start
-
1
);
start
=
*
column
;
prev_length
=
to
;
}
}
ulong
*
STDCALL
ulong
*
STDCALL
mysql_fetch_lengths
(
MYSQL_RES
*
res
)
mysql_fetch_lengths
(
MYSQL_RES
*
res
)
{
{
ulong
*
lengths
,
*
prev_length
;
MYSQL_ROW
column
;
byte
*
start
;
MYSQL_ROW
column
,
end
;
if
(
!
(
column
=
res
->
current_row
))
if
(
!
(
column
=
res
->
current_row
))
return
0
;
/* Something is wrong */
return
0
;
/* Something is wrong */
if
(
res
->
data
)
if
(
res
->
data
)
{
fetch_lengths
(
res
->
lengths
,
column
,
res
->
field_count
);
start
=
0
;
prev_length
=
0
;
/* Keep gcc happy */
lengths
=
res
->
lengths
;
for
(
end
=
column
+
res
->
field_count
+
1
;
column
!=
end
;
column
++
,
lengths
++
)
{
if
(
!*
column
)
{
*
lengths
=
0
;
/* Null */
continue
;
}
if
(
start
)
/* Found end of prev string */
*
prev_length
=
(
ulong
)
(
*
column
-
start
-
1
);
start
=
*
column
;
prev_length
=
lengths
;
}
}
return
res
->
lengths
;
return
res
->
lengths
;
}
}
...
@@ -3246,7 +3266,8 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
...
@@ -3246,7 +3266,8 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
end
=
strmake
(
strmake
(
buff
,
table
,
128
)
+
1
,
wild
?
wild
:
""
,
128
);
end
=
strmake
(
strmake
(
buff
,
table
,
128
)
+
1
,
wild
?
wild
:
""
,
128
);
if
(
simple_command
(
mysql
,
COM_FIELD_LIST
,
buff
,(
ulong
)
(
end
-
buff
),
1
)
||
if
(
simple_command
(
mysql
,
COM_FIELD_LIST
,
buff
,(
ulong
)
(
end
-
buff
),
1
)
||
!
(
query
=
read_rows
(
mysql
,(
MYSQL_FIELD
*
)
0
,
6
)))
!
(
query
=
read_rows
(
mysql
,(
MYSQL_FIELD
*
)
0
,
protocol_41
(
mysql
)
?
7
:
6
)))
DBUG_RETURN
(
NULL
);
DBUG_RETURN
(
NULL
);
free_old_query
(
mysql
);
free_old_query
(
mysql
);
...
@@ -3283,7 +3304,8 @@ mysql_list_processes(MYSQL *mysql)
...
@@ -3283,7 +3304,8 @@ mysql_list_processes(MYSQL *mysql)
free_old_query
(
mysql
);
free_old_query
(
mysql
);
pos
=
(
uchar
*
)
mysql
->
net
.
read_pos
;
pos
=
(
uchar
*
)
mysql
->
net
.
read_pos
;
field_count
=
(
uint
)
net_field_length
(
&
pos
);
field_count
=
(
uint
)
net_field_length
(
&
pos
);
if
(
!
(
fields
=
read_rows
(
mysql
,(
MYSQL_FIELD
*
)
0
,
5
)))
if
(
!
(
fields
=
read_rows
(
mysql
,(
MYSQL_FIELD
*
)
0
,
protocol_41
(
mysql
)
?
6
:
5
)))
DBUG_RETURN
(
NULL
);
DBUG_RETURN
(
NULL
);
if
(
!
(
mysql
->
fields
=
unpack_fields
(
fields
,
&
mysql
->
field_alloc
,
field_count
,
0
,
if
(
!
(
mysql
->
fields
=
unpack_fields
(
fields
,
&
mysql
->
field_alloc
,
field_count
,
0
,
mysql
->
server_capabilities
)))
mysql
->
server_capabilities
)))
...
...
sql/lex.h
View file @
5dd528a2
...
@@ -274,7 +274,6 @@ static SYMBOL symbols[] = {
...
@@ -274,7 +274,6 @@ static SYMBOL symbols[] = {
{
"NULL"
,
SYM
(
NULL_SYM
),
0
,
0
},
{
"NULL"
,
SYM
(
NULL_SYM
),
0
,
0
},
{
"NUMERIC"
,
SYM
(
NUMERIC_SYM
),
0
,
0
},
{
"NUMERIC"
,
SYM
(
NUMERIC_SYM
),
0
,
0
},
{
"OFFSET"
,
SYM
(
OFFSET_SYM
),
0
,
0
},
{
"OFFSET"
,
SYM
(
OFFSET_SYM
),
0
,
0
},
{
"OLD_PASSWORD"
,
SYM
(
PASSWORD
),
0
,
0
},
{
"ON"
,
SYM
(
ON
),
0
,
0
},
{
"ON"
,
SYM
(
ON
),
0
,
0
},
{
"OPEN"
,
SYM
(
OPEN_SYM
),
0
,
0
},
{
"OPEN"
,
SYM
(
OPEN_SYM
),
0
,
0
},
{
"OPTIMIZE"
,
SYM
(
OPTIMIZE
),
0
,
0
},
{
"OPTIMIZE"
,
SYM
(
OPTIMIZE
),
0
,
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