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
4bfdc6c9
Commit
4bfdc6c9
authored
May 07, 2005
by
mronstrom@mysql.com[mikron]
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wl2445.patch
parent
daff7c94
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
14 deletions
+148
-14
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+1
-0
sql/handler.h
sql/handler.h
+20
-0
sql/sql_delete.cc
sql/sql_delete.cc
+20
-2
sql/sql_update.cc
sql/sql_update.cc
+107
-12
No files found.
sql/ha_ndbcluster.cc
View file @
4bfdc6c9
...
@@ -4212,6 +4212,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
...
@@ -4212,6 +4212,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
m_table_info
(
NULL
),
m_table_info
(
NULL
),
m_table_flags
(
HA_REC_NOT_IN_SEQ
|
m_table_flags
(
HA_REC_NOT_IN_SEQ
|
HA_NULL_IN_KEY
|
HA_NULL_IN_KEY
|
HA_CAN_SCAN_UPDATED_INDEX
|
HA_AUTO_PART_KEY
|
HA_AUTO_PART_KEY
|
HA_NO_PREFIX_CHAR_KEYS
|
HA_NO_PREFIX_CHAR_KEYS
|
HA_NEED_READ_RANGE_BUFFER
|
HA_NEED_READ_RANGE_BUFFER
|
...
...
sql/handler.h
View file @
4bfdc6c9
...
@@ -87,6 +87,7 @@
...
@@ -87,6 +87,7 @@
#define HA_NO_VARCHAR (1 << 27)
#define HA_NO_VARCHAR (1 << 27)
#define HA_CAN_BIT_FIELD (1 << 28)
/* supports bit fields */
#define HA_CAN_BIT_FIELD (1 << 28)
/* supports bit fields */
#define HA_NEED_READ_RANGE_BUFFER (1 << 29)
/* for read_multi_range */
#define HA_NEED_READ_RANGE_BUFFER (1 << 29)
/* for read_multi_range */
#define HA_CAN_SCAN_UPDATED_INDEX (1 << 31)
/* bits in index_flags(index_number) for what you can do with index */
/* bits in index_flags(index_number) for what you can do with index */
...
@@ -567,6 +568,25 @@ class handler :public Sql_alloc
...
@@ -567,6 +568,25 @@ class handler :public Sql_alloc
{
return
HA_ERR_WRONG_COMMAND
;
}
{
return
HA_ERR_WRONG_COMMAND
;
}
virtual
int
delete_row
(
const
byte
*
buf
)
virtual
int
delete_row
(
const
byte
*
buf
)
{
return
HA_ERR_WRONG_COMMAND
;
}
{
return
HA_ERR_WRONG_COMMAND
;
}
virtual
bool
start_bulk_update
()
{
return
FALSE
;
}
virtual
bool
start_bulk_delete
()
{
return
FALSE
;
}
virtual
int
bulk_update_row
(
const
byte
*
old_data
,
byte
*
new_data
,
uint
*
dup_key_found
)
{
DBUG_ASSERT
(
FALSE
);
return
HA_ERR_WRONG_COMMAND
;
}
virtual
int
exec_bulk_update
(
uint
*
dup_key_found
)
{
DBUG_ASSERT
(
FALSE
);
return
HA_ERR_WRONG_COMMAND
;
}
virtual
void
end_bulk_update
()
{
return
;
}
virtual
int
end_bulk_delete
()
{
DBUG_ASSERT
(
FALSE
);
return
HA_ERR_WRONG_COMMAND
;
}
virtual
int
index_read
(
byte
*
buf
,
const
byte
*
key
,
virtual
int
index_read
(
byte
*
buf
,
const
byte
*
key
,
uint
key_len
,
enum
ha_rkey_function
find_flag
)
uint
key_len
,
enum
ha_rkey_function
find_flag
)
{
return
HA_ERR_WRONG_COMMAND
;
}
{
return
HA_ERR_WRONG_COMMAND
;
}
...
...
sql/sql_delete.cc
View file @
4bfdc6c9
...
@@ -32,7 +32,8 @@
...
@@ -32,7 +32,8 @@
bool
mysql_delete
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
COND
*
conds
,
bool
mysql_delete
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
COND
*
conds
,
SQL_LIST
*
order
,
ha_rows
limit
,
ulong
options
)
SQL_LIST
*
order
,
ha_rows
limit
,
ulong
options
)
{
{
int
error
;
bool
will_batch
;
int
error
,
loc_error
;
TABLE
*
table
;
TABLE
*
table
;
SQL_SELECT
*
select
=
0
;
SQL_SELECT
*
select
=
0
;
READ_RECORD
info
;
READ_RECORD
info
;
...
@@ -171,6 +172,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
...
@@ -171,6 +172,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
deleted
=
0L
;
deleted
=
0L
;
init_ftfuncs
(
thd
,
select_lex
,
1
);
init_ftfuncs
(
thd
,
select_lex
,
1
);
thd
->
proc_info
=
"updating"
;
thd
->
proc_info
=
"updating"
;
will_batch
=
table
->
file
->
start_bulk_delete
();
while
(
!
(
error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
&&
while
(
!
(
error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
&&
!
thd
->
net
.
report_error
)
!
thd
->
net
.
report_error
)
{
{
...
@@ -215,6 +217,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
...
@@ -215,6 +217,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
}
}
if
(
thd
->
killed
&&
!
error
)
if
(
thd
->
killed
&&
!
error
)
error
=
1
;
// Aborted
error
=
1
;
// Aborted
if
(
will_batch
&&
(
loc_error
=
table
->
file
->
end_bulk_delete
()))
{
if
(
error
!=
1
)
table
->
file
->
print_error
(
loc_error
,
MYF
(
0
));
error
=
1
;
}
thd
->
proc_info
=
"end"
;
thd
->
proc_info
=
"end"
;
end_read_record
(
&
info
);
end_read_record
(
&
info
);
free_io_cache
(
table
);
// Will not do any harm
free_io_cache
(
table
);
// Will not do any harm
...
@@ -579,7 +587,8 @@ void multi_delete::send_error(uint errcode,const char *err)
...
@@ -579,7 +587,8 @@ void multi_delete::send_error(uint errcode,const char *err)
int
multi_delete
::
do_deletes
(
bool
from_send_error
)
int
multi_delete
::
do_deletes
(
bool
from_send_error
)
{
{
int
local_error
=
0
,
counter
=
0
;
int
local_error
=
0
,
counter
=
0
,
error
;
bool
will_batch
;
DBUG_ENTER
(
"do_deletes"
);
DBUG_ENTER
(
"do_deletes"
);
if
(
from_send_error
)
if
(
from_send_error
)
...
@@ -614,6 +623,7 @@ int multi_delete::do_deletes(bool from_send_error)
...
@@ -614,6 +623,7 @@ int multi_delete::do_deletes(bool from_send_error)
been deleted by foreign key handling
been deleted by foreign key handling
*/
*/
info
.
ignore_not_found_rows
=
1
;
info
.
ignore_not_found_rows
=
1
;
will_batch
=
table
->
file
->
start_bulk_delete
();
while
(
!
(
local_error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
)
while
(
!
(
local_error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
)
{
{
if
((
local_error
=
table
->
file
->
delete_row
(
table
->
record
[
0
])))
if
((
local_error
=
table
->
file
->
delete_row
(
table
->
record
[
0
])))
...
@@ -623,6 +633,14 @@ int multi_delete::do_deletes(bool from_send_error)
...
@@ -623,6 +633,14 @@ int multi_delete::do_deletes(bool from_send_error)
}
}
deleted
++
;
deleted
++
;
}
}
if
(
will_batch
&&
(
error
=
table
->
file
->
end_bulk_delete
()))
{
if
(
!
local_error
)
{
local_error
=
error
;
table
->
file
->
print_error
(
local_error
,
MYF
(
0
));
}
}
end_read_record
(
&
info
);
end_read_record
(
&
info
);
if
(
thd
->
killed
&&
!
local_error
)
if
(
thd
->
killed
&&
!
local_error
)
local_error
=
1
;
local_error
=
1
;
...
...
sql/sql_update.cc
View file @
4bfdc6c9
...
@@ -117,10 +117,10 @@ int mysql_update(THD *thd,
...
@@ -117,10 +117,10 @@ int mysql_update(THD *thd,
{
{
bool
using_limit
=
limit
!=
HA_POS_ERROR
;
bool
using_limit
=
limit
!=
HA_POS_ERROR
;
bool
safe_update
=
thd
->
options
&
OPTION_SAFE_UPDATES
;
bool
safe_update
=
thd
->
options
&
OPTION_SAFE_UPDATES
;
bool
used_key_is_modified
,
transactional_table
;
bool
used_key_is_modified
,
transactional_table
,
will_batch
;
int
res
;
int
res
;
int
error
=
0
;
int
error
=
0
,
loc_error
;
uint
used_index
;
uint
used_index
,
dup_key_found
;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
uint
want_privilege
;
uint
want_privilege
;
#endif
#endif
...
@@ -262,7 +262,8 @@ int mysql_update(THD *thd,
...
@@ -262,7 +262,8 @@ int mysql_update(THD *thd,
else
else
used_key_is_modified
=
0
;
used_key_is_modified
=
0
;
if
(
used_key_is_modified
||
order
)
if
((
used_key_is_modified
&&
!
(
table
->
file
->
table_flags
()
&
HA_CAN_SCAN_UPDATED_INDEX
))
||
order
)
{
{
/*
/*
We can't update table directly; We must first search after all
We can't update table directly; We must first search after all
...
@@ -392,7 +393,7 @@ int mysql_update(THD *thd,
...
@@ -392,7 +393,7 @@ int mysql_update(THD *thd,
(
thd
->
variables
.
sql_mode
&
(
thd
->
variables
.
sql_mode
&
(
MODE_STRICT_TRANS_TABLES
|
(
MODE_STRICT_TRANS_TABLES
|
MODE_STRICT_ALL_TABLES
)));
MODE_STRICT_ALL_TABLES
)));
will_batch
=
table
->
file
->
start_bulk_update
();
while
(
!
(
error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
)
while
(
!
(
error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
)
{
{
if
(
!
(
select
&&
select
->
skip_record
()))
if
(
!
(
select
&&
select
->
skip_record
()))
...
@@ -404,7 +405,8 @@ int mysql_update(THD *thd,
...
@@ -404,7 +405,8 @@ int mysql_update(THD *thd,
found
++
;
found
++
;
if
(
table
->
triggers
)
if
(
table
->
triggers
)
table
->
triggers
->
process_triggers
(
thd
,
TRG_EVENT_UPDATE
,
TRG_ACTION_BEFORE
);
table
->
triggers
->
process_triggers
(
thd
,
TRG_EVENT_UPDATE
,
TRG_ACTION_BEFORE
);
if
(
compare_record
(
table
,
query_id
))
if
(
compare_record
(
table
,
query_id
))
{
{
...
@@ -420,8 +422,47 @@ int mysql_update(THD *thd,
...
@@ -420,8 +422,47 @@ int mysql_update(THD *thd,
break
;
break
;
}
}
}
}
if
(
!
(
error
=
table
->
file
->
update_row
((
byte
*
)
table
->
record
[
1
],
if
(
will_batch
)
(
byte
*
)
table
->
record
[
0
])))
{
/*
Typically a batched handler can execute the batched jobs when:
1) When specifically told to do so
2) When it is not a good idea to batch anymore
3) When it is necessary to send batch for other reasons
(One such reason is when READ's must be performed)
1) is covered by exec_bulk_update calls.
2) and 3) is handled by the bulk_update_row method.
bulk_update_row can execute the updates including the one
defined in the bulk_update_row or not including the row
in the call. This is up to the handler implementation and can
vary from call to call.
The dup_key_found reports the number of duplicate keys found
in those updates actually executed. It only reports those if
the extra call with HA_EXTRA_IGNORE_DUP_KEY have been issued.
If this hasn't been issued it returns an error code and can
ignore this number. Thus any handler that implements batching
for UPDATE IGNORE must also handle this extra call properly.
If a duplicate key is found on the record included in this
call then it should be included in the count of dup_key_found
and error should be set to 0 (only if these errors are ignored).
*/
error
=
table
->
file
->
bulk_update_row
(
table
->
record
[
0
],
table
->
record
[
1
],
&
dup_key_found
);
limit
+=
dup_key_found
;
updated
-=
dup_key_found
;
}
else
{
/* Non-batched update */
error
=
table
->
file
->
update_row
((
byte
*
)
table
->
record
[
1
],
(
byte
*
)
table
->
record
[
0
]);
}
if
(
!
error
)
{
{
updated
++
;
updated
++
;
thd
->
no_trans_update
=
!
transactional_table
;
thd
->
no_trans_update
=
!
transactional_table
;
...
@@ -434,22 +475,76 @@ int mysql_update(THD *thd,
...
@@ -434,22 +475,76 @@ int mysql_update(THD *thd,
break
;
break
;
}
}
}
}
if
(
table
->
triggers
)
if
(
table
->
triggers
)
table
->
triggers
->
process_triggers
(
thd
,
TRG_EVENT_UPDATE
,
TRG_ACTION_AFTER
);
table
->
triggers
->
process_triggers
(
thd
,
TRG_EVENT_UPDATE
,
TRG_ACTION_AFTER
);
if
(
!--
limit
&&
using_limit
)
if
(
!--
limit
&&
using_limit
)
{
/*
We have reached end-of-file in most common situations where no
batching has occurred and if batching was supposed to occur but
no updates were made and finally when the batch execution was
performed without error and without finding any duplicate keys.
If the batched updates were performed with errors we need to
check and if no error but duplicate key's found we need to
continue since those are not counted for in limit.
*/
if
(
will_batch
&&
((
error
=
table
->
file
->
exec_bulk_update
(
&
dup_key_found
))
||
!
dup_key_found
))
{
if
(
error
)
{
/*
The handler should not report error of duplicate keys if they
are ignored. This is a requirement on batching handlers.
*/
table
->
file
->
print_error
(
error
,
MYF
(
0
));
error
=
1
;
break
;
}
/*
Either an error was found and we are ignoring errors or there
were duplicate keys found. In both cases we need to correct
the counters and continue the loop.
*/
limit
=
dup_key_found
;
//limit is 0 when we get here so need to +
updated
-=
dup_key_found
;
}
else
{
{
error
=
-
1
;
// Simulate end of file
error
=
-
1
;
// Simulate end of file
break
;
break
;
}
}
}
}
}
else
else
table
->
file
->
unlock_row
();
table
->
file
->
unlock_row
();
thd
->
row_count
++
;
thd
->
row_count
++
;
}
}
dup_key_found
=
0
;
if
(
thd
->
killed
&&
!
error
)
if
(
thd
->
killed
&&
!
error
)
error
=
1
;
// Aborted
error
=
1
;
// Aborted
else
if
(
will_batch
&&
(
loc_error
=
table
->
file
->
exec_bulk_update
(
&
dup_key_found
)))
/*
An error has occurred when a batched update was performed and returned
an error indication. It cannot be an allowed duplicate key error since
we require the batching handler to treat this as a normal behavior.
Otherwise we simply remove the number of duplicate keys records found
in the batched update.
*/
{
thd
->
fatal_error
();
table
->
file
->
print_error
(
loc_error
,
MYF
(
0
));
error
=
1
;
}
else
updated
-=
dup_key_found
;
if
(
will_batch
)
table
->
file
->
end_bulk_update
();
end_read_record
(
&
info
);
end_read_record
(
&
info
);
free_io_cache
(
table
);
// If ORDER BY
free_io_cache
(
table
);
// If ORDER BY
delete
select
;
delete
select
;
...
...
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