The most basic storage engines implement read-only table scanning. Such engines might be used to support SQL queries of logs and other data files that are populated outside of MySQL.
The implementation of the methods in this section provide the first steps toward the creation of more advanced storage engines.
The following shows the method calls made during a nine-row table scan of the CSV engine:
Implementing the store_lock() Method
The store_lock() method is called before any reading or writing is performed.
Before adding the lock into the table lock handler mysqld calls store lock with the requested locks.Store lock can modify the lock level, for example change blocking write lock to non-blocking, ignore the lock (if we don't want to use MySQL table locks at all) or add locks for many tables (like we do when we are using a MERGE handler).
When releasing locks, store_lock() is also called. In this case, one usually doesn't have to do any-thing.
If the argument of store_lock is TL_IGNORE, it means that MySQL requests the handler to store the same lock level as the last time.
The potential lock types are defined in includes/thr_lock.h and are copied here:
Actual lock handling will vary depending on your locking implementation and you may choose to implement some or none of the requested lock types, substituting your own methods as appropriate. The following is the minimal implementation, for a storage engine that does not need to downgrade locks:
See also ha_myisammrg::store_lock() for a more complex implementation.
Implementing the external_lock() Method
The external_lock() method is called at the start of a statement or when a LOCK TABLES statement is issued.
Examples of using external_lock() can be found in the sql/ha_innodb.cc file, but most storage engines can simply return 0, as is the case with the EXAMPLE storage engine:
Implementing the rnd_init() Method
The method called before any table scan is the rnd_init() method. The rnd_init() method is used to prepare for a table scan, resetting counters and pointers to the start of the table.
The following example is from the CSV storage engine:
MySQL Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
A Guided Tour Of The Mysql Source Code
Important Algorithms And Structures
How Mysql Performs Different Selects
How Mysql Transforms Subqueries
Mysql Client/server Protocol
Prepared Statements And Stored Routines
Myisam Storage Engine
Innodb Storage Engine
Writing A Custom Storage Engine
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.