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
a981cfbd
Commit
a981cfbd
authored
Apr 09, 2001
by
serg@serg.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This won't be pushed either
parent
28750d03
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
73 deletions
+97
-73
mysql-test/t/handler.test
mysql-test/t/handler.test
+7
-0
sql/mysql_priv.h
sql/mysql_priv.h
+1
-1
sql/sql_handler.cc
sql/sql_handler.cc
+85
-69
sql/sql_parse.cc
sql/sql_parse.cc
+2
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+2
-2
No files found.
mysql-test/t/handler.test
View file @
a981cfbd
...
...
@@ -45,5 +45,12 @@ handler t2 read a>(18);
handler
t2
read
a
<=
(
18
);
handler
t2
read
a
<
(
18
);
handler
t2
read
a
first
limit
5
;
handler
t2
read
a
next
limit
3
;
handler
t2
read
a
prev
limit
10
;
handler
t2
read
a
>=
(
16
)
limit
4
;
handler
t2
read
a
last
limit
3
;
handler
t2
close
;
drop
table
if
exists
t1
;
sql/mysql_priv.h
View file @
a981cfbd
...
...
@@ -385,7 +385,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables);
int
mysql_ha_open
(
THD
*
thd
,
TABLE_LIST
*
tables
);
int
mysql_ha_close
(
THD
*
thd
,
TABLE_LIST
*
tables
);
int
mysql_ha_read
(
THD
*
,
TABLE_LIST
*
,
enum
enum_ha_read_modes
,
char
*
,
List
<
Item
>
*
,
enum
ha_rkey_function
);
char
*
,
List
<
Item
>
*
,
enum
ha_rkey_function
,
ha_rows
,
ha_rows
);
/* sql_base.cc */
void
set_item_name
(
Item
*
item
,
char
*
pos
,
uint
length
);
...
...
sql/sql_handler.cc
View file @
a981cfbd
...
...
@@ -38,9 +38,13 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
return
0
;
}
static
enum
enum_ha_read_modes
rkey_to_rnext
[]
=
{
RNEXT
,
RNEXT
,
RPREV
,
RNEXT
,
RPREV
,
RNEXT
,
RPREV
};
int
mysql_ha_read
(
THD
*
thd
,
TABLE_LIST
*
tables
,
enum
enum_ha_read_modes
mode
,
char
*
keyname
,
List
<
Item
>
*
key_expr
,
enum
ha_rkey_function
ha_rkey_mode
)
enum
ha_rkey_function
ha_rkey_mode
,
ha_rows
select_limit
,
ha_rows
offset_limit
)
{
int
err
;
TABLE
*
table
=
find_table_by_name
(
thd
,
tables
->
db
,
tables
->
name
);
...
...
@@ -71,13 +75,20 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
table
->
file
->
index_init
(
keyno
);
if
(
select_limit
==
thd
->
default_select_limit
)
select_limit
=
1
;
select_limit
+=
offset_limit
;
for
(
uint
num_rows
=
0
;
num_rows
<
select_limit
;
num_rows
++
)
{
switch
(
mode
)
{
case
RFIRST
:
err
=
table
->
file
->
index_first
(
table
->
record
[
0
]);
mode
=
RNEXT
;
break
;
case
RLAST
:
err
=
table
->
file
->
index_last
(
table
->
record
[
0
]);
mode
=
RPREV
;
break
;
case
RNEXT
:
err
=
table
->
file
->
index_next
(
table
->
record
[
0
]);
...
...
@@ -101,7 +112,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
if
(
!
(
key
=
sql_calloc
(
ALIGN_SIZE
(
key_len
))))
{
send_error
(
&
thd
->
net
,
ER_OUTOFMEMORY
);
exit
(
-
1
)
;
return
-
1
;
}
List_iterator
<
Item
>
it_ke
(
*
key_expr
);
for
(
i
=
0
,
buf
=
key
;
i
<
key_expr
->
elements
;
i
++
)
...
...
@@ -115,11 +126,12 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
}
err
=
table
->
file
->
index_read
(
table
->
record
[
0
],
key
,
key_len
,
ha_rkey_mode
);
mode
=
rkey_to_rnext
[(
int
)
ha_rkey_mode
];
break
;
}
default:
send_error
(
&
thd
->
net
,
ER_ILLEGAL_HA
);
exit
(
-
1
)
;
return
-
1
;
}
if
(
err
&&
err
!=
HA_ERR_KEY_NOT_FOUND
&&
err
!=
HA_ERR_END_OF_FILE
)
...
...
@@ -129,7 +141,9 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
table
->
file
->
print_error
(
err
,
MYF
(
0
));
return
-
1
;
}
send_fields
(
thd
,
list
,
1
);
if
(
num_rows
>=
offset_limit
)
{
if
(
num_rows
==
offset_limit
)
send_fields
(
thd
,
list
,
1
);
if
(
!
err
)
{
String
*
packet
=
&
thd
->
packet
;
...
...
@@ -147,6 +161,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
}
my_net_write
(
&
thd
->
net
,
(
char
*
)
packet
->
ptr
(),
packet
->
length
());
}
}
}
send_eof
(
&
thd
->
net
);
return
0
;
}
...
...
sql/sql_parse.cc
View file @
a981cfbd
...
...
@@ -2010,7 +2010,8 @@ mysql_execute_command(void)
if
(
check_db_used
(
thd
,
tables
)
||
check_table_access
(
thd
,
SELECT_ACL
,
tables
))
goto
error
;
res
=
mysql_ha_read
(
thd
,
tables
,
lex
->
ha_read_mode
,
lex
->
backup_dir
,
lex
->
insert_list
,
lex
->
ha_rkey_mode
);
lex
->
backup_dir
,
lex
->
insert_list
,
lex
->
ha_rkey_mode
,
lex
->
select_limit
,
lex
->
offset_limit
);
break
;
case
SQLCOM_BEGIN
:
...
...
sql/sql_yacc.yy
View file @
a981cfbd
...
...
@@ -201,6 +201,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token LEVEL_SYM
%token LEX_HOSTNAME
%token LIKE
%token LIMIT
%token LINES
%token LOCAL_SYM
%token LOGS_SYM
...
...
@@ -312,7 +313,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token FAST_SYM
%token FLOAT_SYM
%token INT_SYM
%token LIMIT
%token LONGBLOB
%token LONGTEXT
%token MEDIUMBLOB
...
...
@@ -2860,7 +2860,7 @@ handler:
if (!add_table_to_list($2,0,0))
YYABORT;
}
| HANDLER_SYM table_ident READ_SYM ident handler_read_function
| HANDLER_SYM table_ident READ_SYM ident handler_read_function
limit_clause
{
Lex->sql_command = SQLCOM_HA_READ;
Lex->backup_dir= $4.str;
...
...
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