WL#3241: Truncate table in Maria

Affects: Maria-2.0 — Status: Un-Assigned — Priority: Medium

Truncate table (Empty table form all data)

MySQL does truncate by doing a create of an existing table (if table handler
supports recreate). In some circumstanes MySQL does call a handler function
'delete_all_rows' to delete all rows, but still remember things like index
statics and the last auto_increment value.

Maria will initially support recreate of table and later, if needed,
maria_delete_all_rows()

maria_delete_all_rows() can be rollbacked, TRUNCATE TABLE can't.

 TRUNCATE is done as a normal CREATE (WL#3239) but with a flag in the
log that any old files should be overwritten.

The suggested way to implement maria_delete_all_rows is as follows:

- Take a Maria table lock
- Loop over all rows and mark them deleted
- Do same with all index entries
- Instead of creating undo-purge entry's for all data, create one
'undo delete_all_rows' entry.
- Drop Maria table lock (versioning will handle conflicts)

- In case of commit:
Use delete-update handler to scan through all data and index for the
table and delete all entries marked delete by this transaction.
- In case of rollback:
Scan through all data and index for the table and remove delete marker
for all entries marked delete by this transaction.

You must be logged in to tag this worklog

No Comments yet

Votes

Not yet rated.
You must be logged in to vote.

Watches

0 members are watching this worklog
You must be logged in to track this worklog.

Provide Feedback

Please note:
HTML will be purified, but we allow for a number of HTML tags so that you have the flexibility to decorate your comment text to some extent. The comments allow the following HTML tags:

strong, b, em, blockquote, a, code, pre

To put code into your comment, simply encapsulate your code with
[code language="XXX"][/code], where XXX is any common language, for instance "PHP", "SQL", "C", etc.



You must be logged in to comment