mirror of
https://github.com/MariaDB/server.git
synced 2025-01-24 15:54:37 +01:00
f252f9248a
The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c BitKeeper/etc/ignore: added libmysqld/ha_ndbcluster_cond.cc --- added debian/defs.mk debian/control client/completion_hash.cc: Remove not needed casts client/my_readline.h: Remove some old types client/mysql.cc: Simplify types client/mysql_upgrade.c: Remove some old types Update call to dirname_part client/mysqladmin.cc: Remove some old types client/mysqlbinlog.cc: Remove some old types Change some buffers to be uchar to avoid casts client/mysqlcheck.c: Remove some old types client/mysqldump.c: Remove some old types Remove some not needed casts Change some string lengths to size_t client/mysqlimport.c: Remove some old types client/mysqlshow.c: Remove some old types client/mysqlslap.c: Remove some old types Remove some not needed casts client/mysqltest.c: Removed some old types Removed some not needed casts Updated hash-get-key function arguments Updated parameters to dirname_part() client/readline.cc: Removed some old types Removed some not needed casts Changed some string lengths to use size_t client/sql_string.cc: Removed some old types dbug/dbug.c: Removed some old types Changed some string lengths to use size_t Changed some prototypes to avoid casts extra/comp_err.c: Removed some old types extra/innochecksum.c: Removed some old types extra/my_print_defaults.c: Removed some old types extra/mysql_waitpid.c: Removed some old types extra/perror.c: Removed some old types extra/replace.c: Removed some old types Updated parameters to dirname_part() extra/resolve_stack_dump.c: Removed some old types extra/resolveip.c: Removed some old types include/config-win.h: Removed some old types include/decimal.h: Changed binary strings to be uchar* instead of char* include/ft_global.h: Removed some old types include/hash.h: Removed some old types include/heap.h: Removed some old types Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable include/keycache.h: Removed some old types include/m_ctype.h: Removed some old types Changed some string lengths to use size_t Changed character length functions to return uint unsigned char -> uchar include/m_string.h: Removed some old types Changed some string lengths to use size_t include/my_alloc.h: Changed some string lengths to use size_t include/my_base.h: Removed some old types include/my_dbug.h: Removed some old types Changed some string lengths to use size_t Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage include/my_getopt.h: Removed some old types include/my_global.h: Removed old types: my_size_t -> size_t byte -> uchar gptr -> uchar * include/my_list.h: Removed some old types include/my_nosys.h: Removed some old types include/my_pthread.h: Removed some old types include/my_sys.h: Removed some old types Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read() Changed some string lengths to use size_t my_malloc() / my_free() now uses void * Updated parameters to dirname_part() & my_uncompress() include/my_tree.h: Removed some old types include/my_trie.h: Removed some old types include/my_user.h: Changed some string lengths to use size_t include/my_vle.h: Removed some old types include/my_xml.h: Removed some old types Changed some string lengths to use size_t include/myisam.h: Removed some old types include/myisammrg.h: Removed some old types include/mysql.h: Removed some old types Changed byte streams to use uchar* instead of char* include/mysql_com.h: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts include/queues.h: Removed some old types include/sql_common.h: Removed some old types include/sslopt-longopts.h: Removed some old types include/violite.h: Removed some old types Changed some string lengths to use size_t libmysql/client_settings.h: Removed some old types libmysql/libmysql.c: Removed some old types libmysql/manager.c: Removed some old types libmysqld/emb_qcache.cc: Removed some old types libmysqld/emb_qcache.h: Removed some old types libmysqld/lib_sql.cc: Removed some old types Removed some not needed casts Changed some buffers to be uchar* to avoid casts true -> TRUE, false -> FALSE mysys/array.c: Removed some old types mysys/charset.c: Changed some string lengths to use size_t mysys/checksum.c: Include zlib to get definition for crc32 Removed some old types mysys/default.c: Removed some old types Changed some string lengths to use size_t mysys/default_modify.c: Changed some string lengths to use size_t Removed some not needed casts mysys/hash.c: Removed some old types Changed some string lengths to use size_t Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function. hash_element now takes 'ulong' as the index type (cleanup) mysys/list.c: Removed some old types mysys/mf_cache.c: Changed some string lengths to use size_t mysys/mf_dirname.c: Removed some old types Changed some string lengths to use size_t Added argument to dirname_part() to avoid calculation of length for 'to' mysys/mf_fn_ext.c: Removed some old types Updated parameters to dirname_part() mysys/mf_format.c: Removed some old types Changed some string lengths to use size_t mysys/mf_getdate.c: Removed some old types mysys/mf_iocache.c: Removed some old types Changed some string lengths to use size_t Changed calculation of 'max_length' to be done the same way in all functions mysys/mf_iocache2.c: Removed some old types Changed some string lengths to use size_t Clean up comments Removed not needed indentation mysys/mf_keycache.c: Removed some old types mysys/mf_keycaches.c: Removed some old types mysys/mf_loadpath.c: Removed some old types mysys/mf_pack.c: Removed some old types Changed some string lengths to use size_t Removed some not needed casts Removed very old VMS code Updated parameters to dirname_part() Use result of dirnam_part() to remove call to strcat() mysys/mf_path.c: Removed some old types mysys/mf_radix.c: Removed some old types mysys/mf_same.c: Removed some old types mysys/mf_sort.c: Removed some old types mysys/mf_soundex.c: Removed some old types mysys/mf_strip.c: Removed some old types mysys/mf_tempdir.c: Removed some old types mysys/mf_unixpath.c: Removed some old types mysys/mf_wfile.c: Removed some old types mysys/mulalloc.c: Removed some old types mysys/my_alloc.c: Removed some old types Changed some string lengths to use size_t Use void* as type for allocated memory area Removed some not needed casts Changed argument 'Size' to 'length' according coding guidelines mysys/my_chsize.c: Changed some buffers to be uchar* to avoid casts mysys/my_compress.c: More comments Removed some old types Changed string lengths to use size_t Changed arguments to my_uncompress() to make them easier to understand Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) Changed type of 'pack_data' argument to packfrm() to avoid casts. mysys/my_conio.c: Changed some string lengths to use size_t mysys/my_create.c: Removed some old types mysys/my_div.c: Removed some old types mysys/my_error.c: Removed some old types mysys/my_fopen.c: Removed some old types mysys/my_fstream.c: Removed some old types Changed some string lengths to use size_t writen -> written mysys/my_getopt.c: Removed some old types mysys/my_getwd.c: Removed some old types More comments mysys/my_init.c: Removed some old types mysys/my_largepage.c: Removed some old types Changed some string lengths to use size_t mysys/my_lib.c: Removed some old types mysys/my_lockmem.c: Removed some old types mysys/my_malloc.c: Removed some old types Changed malloc(), free() and related functions to use void * Changed all functions to use size_t mysys/my_memmem.c: Indentation cleanup mysys/my_once.c: Removed some old types Changed malloc(), free() and related functions to use void * mysys/my_open.c: Removed some old types mysys/my_pread.c: Removed some old types Changed all functions to use size_t Added comment for how my_pread() / my_pwrite() are supposed to work. Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. (If we ever would really need this, it should be enabled only with a flag argument) mysys/my_quick.c: Removed some old types Changed all functions to use size_t mysys/my_read.c: Removed some old types Changed all functions to use size_t mysys/my_realloc.c: Removed some old types Use void* as type for allocated memory area Changed all functions to use size_t mysys/my_static.c: Removed some old types mysys/my_static.h: Removed some old types mysys/my_vle.c: Removed some old types mysys/my_wincond.c: Removed some old types mysys/my_windac.c: Removed some old types mysys/my_write.c: Removed some old types Changed all functions to use size_t mysys/ptr_cmp.c: Removed some old types Changed all functions to use size_t mysys/queues.c: Removed some old types mysys/safemalloc.c: Removed some old types Changed malloc(), free() and related functions to use void * Changed all functions to use size_t mysys/string.c: Removed some old types Changed all functions to use size_t mysys/testhash.c: Removed some old types mysys/thr_alarm.c: Removed some old types mysys/thr_lock.c: Removed some old types mysys/tree.c: Removed some old types mysys/trie.c: Removed some old types mysys/typelib.c: Removed some old types plugin/daemon_example/daemon_example.cc: Removed some old types regex/reginit.c: Removed some old types server-tools/instance-manager/buffer.cc: Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/buffer.h: Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/commands.cc: Removed some old types Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/instance_map.cc: Removed some old types Changed some string lengths to use size_t Changed buffer to be of type uchar* server-tools/instance-manager/instance_options.cc: Changed buffer to be of type uchar* Replaced alloc_root + strcpy() with strdup_root() server-tools/instance-manager/mysql_connection.cc: Changed buffer to be of type uchar* server-tools/instance-manager/options.cc: Removed some old types server-tools/instance-manager/parse.cc: Changed some string lengths to use size_t server-tools/instance-manager/parse.h: Removed some old types Changed some string lengths to use size_t server-tools/instance-manager/protocol.cc: Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t server-tools/instance-manager/protocol.h: Changed some string lengths to use size_t server-tools/instance-manager/user_map.cc: Removed some old types Changed some string lengths to use size_t sql/derror.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/discover.cc: Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts sql/event_data_objects.cc: Removed some old types Added missing casts for alloc() and sprintf() sql/event_db_repository.cc: Changed some buffers to be uchar* to avoid casts Added missing casts for sprintf() sql/event_queue.cc: Removed some old types sql/field.cc: Removed some old types Changed memory buffers to be uchar* Changed some string lengths to use size_t Removed a lot of casts Safety fix in Field_blob::val_decimal() to not access zero pointer sql/field.h: Removed some old types Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes). Changed some string lengths to use size_t Removed some not needed casts Changed val_xxx(xxx, new_ptr) to take const pointers sql/field_conv.cc: Removed some old types Added casts required because memory area pointers are now uchar* sql/filesort.cc: Initalize variable that was used unitialized in error conditions sql/gen_lex_hash.cc: Removed some old types Changed memory buffers to be uchar* Changed some string lengths to use size_t Removed a lot of casts Safety fix in Field_blob::val_decimal() to not access zero pointer sql/gstream.h: Added required cast sql/ha_ndbcluster.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts Added required casts Removed some not needed casts sql/ha_ndbcluster.h: Removed some old types sql/ha_ndbcluster_binlog.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake() Changed some string lengths to use size_t Added missing casts for alloc() and sprintf() sql/ha_ndbcluster_binlog.h: Removed some old types sql/ha_ndbcluster_cond.cc: Removed some old types Removed some not needed casts sql/ha_ndbcluster_cond.h: Removed some old types sql/ha_partition.cc: Removed some old types Changed prototype for change_partition() to avoid casts sql/ha_partition.h: Removed some old types sql/handler.cc: Removed some old types Changed some string lengths to use size_t sql/handler.h: Removed some old types Changed some string lengths to use size_t Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts sql/hash_filo.h: Removed some old types Changed all functions to use size_t sql/hostname.cc: Removed some old types sql/item.cc: Removed some old types Changed some string lengths to use size_t Use strmake() instead of memdup() to create a null terminated string. Updated calls to new Field() sql/item.h: Removed some old types Changed malloc(), free() and related functions to use void * Changed some buffers to be uchar* to avoid casts sql/item_cmpfunc.cc: Removed some old types Changed some buffers to be uchar* to avoid casts sql/item_cmpfunc.h: Removed some old types sql/item_create.cc: Removed some old types sql/item_func.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added test for failing alloc() in init_result_field() Remove old confusing comment Fixed compiler warning sql/item_func.h: Removed some old types sql/item_row.cc: Removed some old types sql/item_row.h: Removed some old types sql/item_strfunc.cc: Include zlib (needed becasue we call crc32) Removed some old types sql/item_strfunc.h: Removed some old types Changed some types to match new function prototypes sql/item_subselect.cc: Removed some old types sql/item_subselect.h: Removed some old types sql/item_sum.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/item_sum.h: Removed some old types sql/item_timefunc.cc: Removed some old types Changed some string lengths to use size_t sql/item_timefunc.h: Removed some old types sql/item_xmlfunc.cc: Changed some string lengths to use size_t sql/item_xmlfunc.h: Removed some old types sql/key.cc: Removed some old types Removed some not needed casts sql/lock.cc: Removed some old types Added some cast to my_multi_malloc() arguments for safety sql/log.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Changed usage of pwrite() to not assume it holds the cursor position for the file Made usage of my_read() safer sql/log_event.cc: Removed some old types Added checking of return value of malloc() in pack_info() Changed some buffers to be uchar* to avoid casts Removed some 'const' to avoid casts Added missing casts for alloc() and sprintf() Added required casts Removed some not needed casts Added some cast to my_multi_malloc() arguments for safety sql/log_event.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/log_event_old.cc: Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/log_event_old.h: Changed some buffers to be uchar* to avoid casts sql/mf_iocache.cc: Removed some old types sql/my_decimal.cc: Changed memory area to use uchar* sql/my_decimal.h: Changed memory area to use uchar* sql/mysql_priv.h: Removed some old types Changed malloc(), free() and related functions to use void * Changed some string lengths to use size_t Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow Changed some buffers to be uchar* to avoid casts sql/mysqld.cc: Removed some old types sql/net_serv.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Ensure that vio_read()/vio_write() return values are stored in a size_t variable Removed some not needed casts sql/opt_range.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/opt_range.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/opt_sum.cc: Removed some old types Removed some not needed casts sql/parse_file.cc: Removed some old types Changed some string lengths to use size_t Changed alloc_root + memcpy + set end 0 -> strmake_root() sql/parse_file.h: Removed some old types sql/partition_info.cc: Removed some old types Added missing casts for alloc() Changed some buffers to be uchar* to avoid casts sql/partition_info.h: Changed some buffers to be uchar* to avoid casts sql/protocol.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/protocol.h: Removed some old types Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/records.cc: Removed some old types sql/repl_failsafe.cc: Removed some old types Changed some string lengths to use size_t Added required casts sql/rpl_filter.cc: Removed some old types Updated hash-get-key function arguments Changed some string lengths to use size_t sql/rpl_filter.h: Changed some string lengths to use size_t sql/rpl_injector.h: Removed some old types sql/rpl_record.cc: Removed some old types Removed some not needed casts Changed some buffers to be uchar* to avoid casts sql/rpl_record.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/rpl_record_old.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/rpl_record_old.h: Removed some old types Changed some buffers to be uchar* to avoid cast sql/rpl_rli.cc: Removed some old types sql/rpl_tblmap.cc: Removed some old types sql/rpl_tblmap.h: Removed some old types sql/rpl_utility.cc: Removed some old types sql/rpl_utility.h: Removed some old types Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length sql/set_var.cc: Removed some old types Updated parameters to dirname_part() sql/set_var.h: Removed some old types sql/slave.cc: Removed some old types Changed some string lengths to use size_t sql/slave.h: Removed some old types sql/sp.cc: Removed some old types Added missing casts for printf() sql/sp.h: Removed some old types Updated hash-get-key function arguments sql/sp_cache.cc: Removed some old types Added missing casts for printf() Updated hash-get-key function arguments sql/sp_head.cc: Removed some old types Added missing casts for alloc() and printf() Added required casts Updated hash-get-key function arguments sql/sp_head.h: Removed some old types sql/sp_pcontext.cc: Removed some old types sql/sp_pcontext.h: Removed some old types sql/sql_acl.cc: Removed some old types Changed some string lengths to use size_t Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added required casts sql/sql_analyse.cc: Changed some buffers to be uchar* to avoid casts sql/sql_analyse.h: Changed some buffers to be uchar* to avoid casts sql/sql_array.h: Removed some old types sql/sql_base.cc: Removed some old types Updated hash-get-key function arguments sql/sql_binlog.cc: Removed some old types Added missing casts for printf() sql/sql_cache.cc: Removed some old types Updated hash-get-key function arguments Removed some not needed casts Changed some string lengths to use size_t sql/sql_cache.h: Removed some old types Removed reference to not existing function cache_key() Updated hash-get-key function arguments sql/sql_class.cc: Removed some old types Updated hash-get-key function arguments Added missing casts for alloc() Updated hash-get-key function arguments Moved THD::max_row_length() to table.cc (as it's not depending on THD) Removed some not needed casts sql/sql_class.h: Removed some old types Changed malloc(), free() and related functions to use void * Removed some not needed casts Changed some string lengths to use size_t Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD sql/sql_connect.cc: Removed some old types Added required casts sql/sql_db.cc: Removed some old types Removed some not needed casts Added some cast to my_multi_malloc() arguments for safety Added missing casts for alloc() sql/sql_delete.cc: Removed some old types sql/sql_handler.cc: Removed some old types Updated hash-get-key function arguments Added some cast to my_multi_malloc() arguments for safety sql/sql_help.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_insert.cc: Removed some old types Added missing casts for alloc() and printf() sql/sql_lex.cc: Removed some old types sql/sql_lex.h: Removed some old types Removed some not needed casts sql/sql_list.h: Removed some old types Removed some not needed casts sql/sql_load.cc: Removed some old types Removed compiler warning sql/sql_manager.cc: Removed some old types sql/sql_map.cc: Removed some old types sql/sql_map.h: Removed some old types sql/sql_olap.cc: Removed some old types sql/sql_parse.cc: Removed some old types Trivial move of code lines to make things more readable Changed some string lengths to use size_t Added missing casts for alloc() sql/sql_partition.cc: Removed some old types Removed compiler warnings about not used functions Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_partition.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/sql_plugin.cc: Removed some old types Added missing casts for alloc() Updated hash-get-key function arguments sql/sql_prepare.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Added missing casts for alloc() and printf() sql-common/client.c: Removed some old types Changed some memory areas to use uchar* sql-common/my_user.c: Changed some string lengths to use size_t sql-common/pack.c: Changed some buffers to be uchar* to avoid casts sql/sql_repl.cc: Added required casts Changed some buffers to be uchar* to avoid casts Changed some string lengths to use size_t sql/sql_select.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some old types sql/sql_select.h: Removed some old types Changed some buffers to be uchar* to avoid casts sql/sql_servers.cc: Removed some old types Updated hash-get-key function arguments sql/sql_show.cc: Removed some old types Added missing casts for alloc() Removed some not needed casts sql/sql_string.cc: Removed some old types Added required casts sql/sql_table.cc: Removed some old types Removed compiler warning about not used variable Changed some buffers to be uchar* to avoid casts Removed some not needed casts sql/sql_test.cc: Removed some old types sql/sql_trigger.cc: Removed some old types Added missing casts for alloc() sql/sql_udf.cc: Removed some old types Updated hash-get-key function arguments sql/sql_union.cc: Removed some old types sql/sql_update.cc: Removed some old types Removed some not needed casts sql/sql_view.cc: Removed some old types sql/sql_yacc.yy: Removed some old types Changed some string lengths to use size_t Added missing casts for alloc() sql/stacktrace.c: Removed some old types sql/stacktrace.h: Removed some old types sql/structs.h: Removed some old types sql/table.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts Removed setting of LEX_STRING() arguments in declaration Added required casts More function comments Moved max_row_length() here from sql_class.cc/sql_class.h sql/table.h: Removed some old types Changed some string lengths to use size_t sql/thr_malloc.cc: Use void* as type for allocated memory area Changed all functions to use size_t sql/tzfile.h: Changed some buffers to be uchar* to avoid casts sql/tztime.cc: Changed some buffers to be uchar* to avoid casts Updated hash-get-key function arguments Added missing casts for alloc() Removed some not needed casts sql/uniques.cc: Removed some old types Removed some not needed casts sql/unireg.cc: Removed some old types Changed some buffers to be uchar* to avoid casts Removed some not needed casts Added missing casts for alloc() storage/archive/archive_reader.c: Removed some old types storage/archive/azio.c: Removed some old types Removed some not needed casts storage/archive/ha_archive.cc: Removed some old types Changed type for 'frmblob' in archive_discover() to match handler Updated hash-get-key function arguments Removed some not needed casts storage/archive/ha_archive.h: Removed some old types storage/blackhole/ha_blackhole.cc: Removed some old types storage/blackhole/ha_blackhole.h: Removed some old types storage/csv/ha_tina.cc: Removed some old types Updated hash-get-key function arguments Changed some buffers to be uchar* to avoid casts storage/csv/ha_tina.h: Removed some old types Removed some not needed casts storage/csv/transparent_file.cc: Removed some old types Changed type of 'bytes_read' to be able to detect read errors Fixed indentation storage/csv/transparent_file.h: Removed some old types storage/example/ha_example.cc: Removed some old types Updated hash-get-key function arguments storage/example/ha_example.h: Removed some old types storage/federated/ha_federated.cc: Removed some old types Updated hash-get-key function arguments Removed some not needed casts storage/federated/ha_federated.h: Removed some old types storage/heap/_check.c: Changed some buffers to be uchar* to avoid casts storage/heap/_rectest.c: Removed some old types storage/heap/ha_heap.cc: Removed some old types storage/heap/ha_heap.h: Removed some old types storage/heap/heapdef.h: Removed some old types storage/heap/hp_block.c: Removed some old types Changed some string lengths to use size_t storage/heap/hp_clear.c: Removed some old types storage/heap/hp_close.c: Removed some old types storage/heap/hp_create.c: Removed some old types storage/heap/hp_delete.c: Removed some old types storage/heap/hp_hash.c: Removed some old types storage/heap/hp_info.c: Removed some old types storage/heap/hp_open.c: Removed some old types storage/heap/hp_rfirst.c: Removed some old types storage/heap/hp_rkey.c: Removed some old types storage/heap/hp_rlast.c: Removed some old types storage/heap/hp_rnext.c: Removed some old types storage/heap/hp_rprev.c: Removed some old types storage/heap/hp_rrnd.c: Removed some old types storage/heap/hp_rsame.c: Removed some old types storage/heap/hp_scan.c: Removed some old types storage/heap/hp_test1.c: Removed some old types storage/heap/hp_test2.c: Removed some old types storage/heap/hp_update.c: Removed some old types storage/heap/hp_write.c: Removed some old types Changed some string lengths to use size_t storage/innobase/handler/ha_innodb.cc: Removed some old types Updated hash-get-key function arguments Added missing casts for alloc() and printf() Removed some not needed casts storage/innobase/handler/ha_innodb.h: Removed some old types storage/myisam/ft_boolean_search.c: Removed some old types storage/myisam/ft_nlq_search.c: Removed some old types storage/myisam/ft_parser.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/ft_static.c: Removed some old types storage/myisam/ft_stopwords.c: Removed some old types storage/myisam/ft_update.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/ftdefs.h: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/fulltext.h: Removed some old types storage/myisam/ha_myisam.cc: Removed some old types storage/myisam/ha_myisam.h: Removed some old types storage/myisam/mi_cache.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/mi_check.c: Removed some old types storage/myisam/mi_checksum.c: Removed some old types storage/myisam/mi_close.c: Removed some old types storage/myisam/mi_create.c: Removed some old types storage/myisam/mi_delete.c: Removed some old types storage/myisam/mi_delete_all.c: Removed some old types storage/myisam/mi_dynrec.c: Removed some old types storage/myisam/mi_extra.c: Removed some old types storage/myisam/mi_key.c: Removed some old types storage/myisam/mi_locking.c: Removed some old types storage/myisam/mi_log.c: Removed some old types storage/myisam/mi_open.c: Removed some old types Removed some not needed casts Check argument of my_write()/my_pwrite() in functions returning int Added casting of string lengths to size_t storage/myisam/mi_packrec.c: Removed some old types Changed some buffers to be uchar* to avoid casts storage/myisam/mi_page.c: Removed some old types storage/myisam/mi_preload.c: Removed some old types storage/myisam/mi_range.c: Removed some old types storage/myisam/mi_rfirst.c: Removed some old types storage/myisam/mi_rkey.c: Removed some old types storage/myisam/mi_rlast.c: Removed some old types storage/myisam/mi_rnext.c: Removed some old types storage/myisam/mi_rnext_same.c: Removed some old types storage/myisam/mi_rprev.c: Removed some old types storage/myisam/mi_rrnd.c: Removed some old types storage/myisam/mi_rsame.c: Removed some old types storage/myisam/mi_rsamepos.c: Removed some old types storage/myisam/mi_scan.c: Removed some old types storage/myisam/mi_search.c: Removed some old types storage/myisam/mi_static.c: Removed some old types storage/myisam/mi_statrec.c: Removed some old types storage/myisam/mi_test1.c: Removed some old types storage/myisam/mi_test2.c: Removed some old types storage/myisam/mi_test3.c: Removed some old types storage/myisam/mi_unique.c: Removed some old types storage/myisam/mi_update.c: Removed some old types storage/myisam/mi_write.c: Removed some old types storage/myisam/myisam_ftdump.c: Removed some old types storage/myisam/myisamchk.c: Removed some old types storage/myisam/myisamdef.h: Removed some old types storage/myisam/myisamlog.c: Removed some old types Indentation fix storage/myisam/myisampack.c: Removed some old types storage/myisam/rt_index.c: Removed some old types storage/myisam/rt_split.c: Removed some old types storage/myisam/sort.c: Removed some old types storage/myisam/sp_defs.h: Removed some old types storage/myisam/sp_key.c: Removed some old types storage/myisammrg/ha_myisammrg.cc: Removed some old types storage/myisammrg/ha_myisammrg.h: Removed some old types storage/myisammrg/myrg_close.c: Removed some old types storage/myisammrg/myrg_def.h: Removed some old types storage/myisammrg/myrg_delete.c: Removed some old types storage/myisammrg/myrg_open.c: Removed some old types Updated parameters to dirname_part() storage/myisammrg/myrg_queue.c: Removed some old types storage/myisammrg/myrg_rfirst.c: Removed some old types storage/myisammrg/myrg_rkey.c: Removed some old types storage/myisammrg/myrg_rlast.c: Removed some old types storage/myisammrg/myrg_rnext.c: Removed some old types storage/myisammrg/myrg_rnext_same.c: Removed some old types storage/myisammrg/myrg_rprev.c: Removed some old types storage/myisammrg/myrg_rrnd.c: Removed some old types storage/myisammrg/myrg_rsame.c: Removed some old types storage/myisammrg/myrg_update.c: Removed some old types storage/myisammrg/myrg_write.c: Removed some old types storage/ndb/include/util/ndb_opts.h: Removed some old types storage/ndb/src/cw/cpcd/main.cpp: Removed some old types storage/ndb/src/kernel/vm/Configuration.cpp: Removed some old types storage/ndb/src/mgmclient/main.cpp: Removed some old types storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Removed some old types Removed old disabled code storage/ndb/src/mgmsrv/main.cpp: Removed some old types storage/ndb/src/ndbapi/NdbBlob.cpp: Removed some old types storage/ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variable storage/ndb/src/ndbapi/NdbOperationInt.cpp: Added required casts storage/ndb/src/ndbapi/NdbScanOperation.cpp: Added required casts storage/ndb/tools/delete_all.cpp: Removed some old types storage/ndb/tools/desc.cpp: Removed some old types storage/ndb/tools/drop_index.cpp: Removed some old types storage/ndb/tools/drop_tab.cpp: Removed some old types storage/ndb/tools/listTables.cpp: Removed some old types storage/ndb/tools/ndb_config.cpp: Removed some old types storage/ndb/tools/restore/consumer_restore.cpp: Changed some buffers to be uchar* to avoid casts with new defintion of packfrm() storage/ndb/tools/restore/restore_main.cpp: Removed some old types storage/ndb/tools/select_all.cpp: Removed some old types storage/ndb/tools/select_count.cpp: Removed some old types storage/ndb/tools/waiter.cpp: Removed some old types strings/bchange.c: Changed function to use uchar * and size_t strings/bcmp.c: Changed function to use uchar * and size_t strings/bmove512.c: Changed function to use uchar * and size_t strings/bmove_upp.c: Changed function to use uchar * and size_t strings/ctype-big5.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-bin.c: Changed functions to use size_t strings/ctype-cp932.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-czech.c: Fixed indentation Changed functions to use size_t strings/ctype-euc_kr.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-eucjpms.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-gb2312.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-gbk.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-latin1.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-mb.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-simple.c: Changed functions to use size_t Simpler loops for caseup/casedown unsigned int -> uint unsigned char -> uchar strings/ctype-sjis.c: Changed functions to use size_t Changed character length functions to return uint strings/ctype-tis620.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-uca.c: Changed functions to use size_t unsigned char -> uchar strings/ctype-ucs2.c: Moved inclusion of stdarg.h to other includes usigned char -> uchar Changed functions to use size_t Changed character length functions to return uint strings/ctype-ujis.c: Changed functions to use size_t Changed character length functions to return uint unsigned char -> uchar strings/ctype-utf8.c: Changed functions to use size_t unsigned char -> uchar Indentation fixes strings/ctype-win1250ch.c: Indentation fixes Changed functions to use size_t strings/ctype.c: Changed functions to use size_t strings/decimal.c: Changed type for memory argument to uchar * strings/do_ctype.c: Indentation fixes strings/my_strtoll10.c: unsigned char -> uchar strings/my_vsnprintf.c: Changed functions to use size_t strings/r_strinstr.c: Removed some old types Changed functions to use size_t strings/str_test.c: Removed some old types strings/strappend.c: Changed functions to use size_t strings/strcont.c: Removed some old types strings/strfill.c: Removed some old types strings/strinstr.c: Changed functions to use size_t strings/strlen.c: Changed functions to use size_t strings/strmake.c: Changed functions to use size_t strings/strnlen.c: Changed functions to use size_t strings/strnmov.c: Changed functions to use size_t strings/strto.c: unsigned char -> uchar strings/strtod.c: Changed functions to use size_t strings/strxnmov.c: Changed functions to use size_t strings/xml.c: Changed functions to use size_t Indentation fixes tests/mysql_client_test.c: Removed some old types tests/thread_test.c: Removed some old types vio/test-ssl.c: Removed some old types vio/test-sslclient.c: Removed some old types vio/test-sslserver.c: Removed some old types vio/vio.c: Removed some old types vio/vio_priv.h: Removed some old types Changed vio_read()/vio_write() to work with size_t vio/viosocket.c: Changed vio_read()/vio_write() to work with size_t Indentation fixes vio/viossl.c: Changed vio_read()/vio_write() to work with size_t Indentation fixes vio/viosslfactories.c: Removed some old types vio/viotest-ssl.c: Removed some old types win/README: More explanations
1657 lines
44 KiB
C++
1657 lines
44 KiB
C++
/* Copyright (C) 2003 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#ifdef USE_PRAGMA_IMPLEMENTATION
|
|
#pragma implementation // gcc: Class implementation
|
|
#endif
|
|
|
|
#include "mysql_priv.h"
|
|
#include <myisam.h>
|
|
|
|
#include "ha_archive.h"
|
|
#include <my_dir.h>
|
|
|
|
#include <mysql/plugin.h>
|
|
|
|
/*
|
|
First, if you want to understand storage engines you should look at
|
|
ha_example.cc and ha_example.h.
|
|
|
|
This example was written as a test case for a customer who needed
|
|
a storage engine without indexes that could compress data very well.
|
|
So, welcome to a completely compressed storage engine. This storage
|
|
engine only does inserts. No replace, deletes, or updates. All reads are
|
|
complete table scans. Compression is done through a combination of packing
|
|
and making use of the zlib library
|
|
|
|
We keep a file pointer open for each instance of ha_archive for each read
|
|
but for writes we keep one open file handle just for that. We flush it
|
|
only if we have a read occur. azip handles compressing lots of records
|
|
at once much better then doing lots of little records between writes.
|
|
It is possible to not lock on writes but this would then mean we couldn't
|
|
handle bulk inserts as well (that is if someone was trying to read at
|
|
the same time since we would want to flush).
|
|
|
|
A "meta" file is kept alongside the data file. This file serves two purpose.
|
|
The first purpose is to track the number of rows in the table. The second
|
|
purpose is to determine if the table was closed properly or not. When the
|
|
meta file is first opened it is marked as dirty. It is opened when the table
|
|
itself is opened for writing. When the table is closed the new count for rows
|
|
is written to the meta file and the file is marked as clean. If the meta file
|
|
is opened and it is marked as dirty, it is assumed that a crash occured. At
|
|
this point an error occurs and the user is told to rebuild the file.
|
|
A rebuild scans the rows and rewrites the meta file. If corruption is found
|
|
in the data file then the meta file is not repaired.
|
|
|
|
At some point a recovery method for such a drastic case needs to be divised.
|
|
|
|
Locks are row level, and you will get a consistant read.
|
|
|
|
For performance as far as table scans go it is quite fast. I don't have
|
|
good numbers but locally it has out performed both Innodb and MyISAM. For
|
|
Innodb the question will be if the table can be fit into the buffer
|
|
pool. For MyISAM its a question of how much the file system caches the
|
|
MyISAM file. With enough free memory MyISAM is faster. Its only when the OS
|
|
doesn't have enough memory to cache entire table that archive turns out
|
|
to be any faster.
|
|
|
|
Examples between MyISAM (packed) and Archive.
|
|
|
|
Table with 76695844 identical rows:
|
|
29680807 a_archive.ARZ
|
|
920350317 a.MYD
|
|
|
|
|
|
Table with 8991478 rows (all of Slashdot's comments):
|
|
1922964506 comment_archive.ARZ
|
|
2944970297 comment_text.MYD
|
|
|
|
|
|
TODO:
|
|
Allow users to set compression level.
|
|
Allow adjustable block size.
|
|
Implement versioning, should be easy.
|
|
Allow for errors, find a way to mark bad rows.
|
|
Add optional feature so that rows can be flushed at interval (which will cause less
|
|
compression but may speed up ordered searches).
|
|
Checkpoint the meta file to allow for faster rebuilds.
|
|
Option to allow for dirty reads, this would lower the sync calls, which would make
|
|
inserts a lot faster, but would mean highly arbitrary reads.
|
|
|
|
-Brian
|
|
*/
|
|
|
|
/* Variables for archive share methods */
|
|
pthread_mutex_t archive_mutex;
|
|
static HASH archive_open_tables;
|
|
|
|
/* The file extension */
|
|
#define ARZ ".ARZ" // The data file
|
|
#define ARN ".ARN" // Files used during an optimize call
|
|
#define ARM ".ARM" // Meta file (deprecated)
|
|
|
|
/*
|
|
uchar + uchar
|
|
*/
|
|
#define DATA_BUFFER_SIZE 2 // Size of the data used in the data file
|
|
#define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption
|
|
|
|
/* Static declarations for handerton */
|
|
static handler *archive_create_handler(handlerton *hton,
|
|
TABLE_SHARE *table,
|
|
MEM_ROOT *mem_root);
|
|
int archive_discover(handlerton *hton, THD* thd, const char *db,
|
|
const char *name,
|
|
uchar **frmblob,
|
|
size_t *frmlen);
|
|
|
|
/*
|
|
Number of rows that will force a bulk insert.
|
|
*/
|
|
#define ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT 2
|
|
|
|
/*
|
|
Size of header used for row
|
|
*/
|
|
#define ARCHIVE_ROW_HEADER_SIZE 4
|
|
|
|
static handler *archive_create_handler(handlerton *hton,
|
|
TABLE_SHARE *table,
|
|
MEM_ROOT *mem_root)
|
|
{
|
|
return new (mem_root) ha_archive(hton, table);
|
|
}
|
|
|
|
/*
|
|
Used for hash table that tracks open tables.
|
|
*/
|
|
static uchar* archive_get_key(ARCHIVE_SHARE *share, size_t *length,
|
|
my_bool not_used __attribute__((unused)))
|
|
{
|
|
*length=share->table_name_length;
|
|
return (uchar*) share->table_name;
|
|
}
|
|
|
|
|
|
/*
|
|
Initialize the archive handler.
|
|
|
|
SYNOPSIS
|
|
archive_db_init()
|
|
void *
|
|
|
|
RETURN
|
|
FALSE OK
|
|
TRUE Error
|
|
*/
|
|
|
|
int archive_db_init(void *p)
|
|
{
|
|
DBUG_ENTER("archive_db_init");
|
|
handlerton *archive_hton;
|
|
|
|
archive_hton= (handlerton *)p;
|
|
archive_hton->state= SHOW_OPTION_YES;
|
|
archive_hton->db_type= DB_TYPE_ARCHIVE_DB;
|
|
archive_hton->create= archive_create_handler;
|
|
archive_hton->flags= HTON_NO_FLAGS;
|
|
archive_hton->discover= archive_discover;
|
|
|
|
if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST))
|
|
goto error;
|
|
if (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
|
|
(hash_get_key) archive_get_key, 0, 0))
|
|
{
|
|
VOID(pthread_mutex_destroy(&archive_mutex));
|
|
}
|
|
else
|
|
{
|
|
DBUG_RETURN(FALSE);
|
|
}
|
|
error:
|
|
DBUG_RETURN(TRUE);
|
|
}
|
|
|
|
/*
|
|
Release the archive handler.
|
|
|
|
SYNOPSIS
|
|
archive_db_done()
|
|
void
|
|
|
|
RETURN
|
|
FALSE OK
|
|
*/
|
|
|
|
int archive_db_done(void *p)
|
|
{
|
|
hash_free(&archive_open_tables);
|
|
VOID(pthread_mutex_destroy(&archive_mutex));
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
ha_archive::ha_archive(handlerton *hton, TABLE_SHARE *table_arg)
|
|
:handler(hton, table_arg), delayed_insert(0), bulk_insert(0)
|
|
{
|
|
/* Set our original buffer from pre-allocated memory */
|
|
buffer.set((char *)byte_buffer, IO_SIZE, system_charset_info);
|
|
|
|
/* The size of the offset value we will use for position() */
|
|
ref_length= sizeof(my_off_t);
|
|
archive_reader_open= FALSE;
|
|
}
|
|
|
|
int archive_discover(handlerton *hton, THD* thd, const char *db,
|
|
const char *name,
|
|
uchar **frmblob,
|
|
size_t *frmlen)
|
|
{
|
|
DBUG_ENTER("archive_discover");
|
|
DBUG_PRINT("archive_discover", ("db: %s, name: %s", db, name));
|
|
azio_stream frm_stream;
|
|
char az_file[FN_REFLEN];
|
|
char *frm_ptr;
|
|
MY_STAT file_stat;
|
|
|
|
fn_format(az_file, name, db, ARZ, MY_REPLACE_EXT | MY_UNPACK_FILENAME);
|
|
|
|
if (!(my_stat(az_file, &file_stat, MYF(0))))
|
|
goto err;
|
|
|
|
if (!(azopen(&frm_stream, az_file, O_RDONLY|O_BINARY)))
|
|
{
|
|
if (errno == EROFS || errno == EACCES)
|
|
DBUG_RETURN(my_errno= errno);
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
}
|
|
|
|
if (frm_stream.frm_length == 0)
|
|
goto err;
|
|
|
|
frm_ptr= (char *)my_malloc(sizeof(char) * frm_stream.frm_length, MYF(0));
|
|
azread_frm(&frm_stream, frm_ptr);
|
|
azclose(&frm_stream);
|
|
|
|
*frmlen= frm_stream.frm_length;
|
|
*frmblob= (uchar*) frm_ptr;
|
|
|
|
DBUG_RETURN(0);
|
|
err:
|
|
my_errno= 0;
|
|
DBUG_RETURN(1);
|
|
}
|
|
|
|
/*
|
|
This method reads the header of a datafile and returns whether or not it was successful.
|
|
*/
|
|
int ha_archive::read_data_header(azio_stream *file_to_read)
|
|
{
|
|
int error;
|
|
unsigned long ret;
|
|
uchar data_buffer[DATA_BUFFER_SIZE];
|
|
DBUG_ENTER("ha_archive::read_data_header");
|
|
|
|
if (azrewind(file_to_read) == -1)
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
if (file_to_read->version >= 3)
|
|
DBUG_RETURN(0);
|
|
/* Everything below this is just legacy to version 2< */
|
|
|
|
DBUG_PRINT("ha_archive", ("Reading legacy data header"));
|
|
|
|
ret= azread(file_to_read, data_buffer, DATA_BUFFER_SIZE, &error);
|
|
|
|
if (ret != DATA_BUFFER_SIZE)
|
|
{
|
|
DBUG_PRINT("ha_archive", ("Reading, expected %d got %lu",
|
|
DATA_BUFFER_SIZE, ret));
|
|
DBUG_RETURN(1);
|
|
}
|
|
|
|
if (error)
|
|
{
|
|
DBUG_PRINT("ha_archive", ("Compression error (%d)", error));
|
|
DBUG_RETURN(1);
|
|
}
|
|
|
|
DBUG_PRINT("ha_archive", ("Check %u", data_buffer[0]));
|
|
DBUG_PRINT("ha_archive", ("Version %u", data_buffer[1]));
|
|
|
|
if ((data_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) &&
|
|
(data_buffer[1] != (uchar)ARCHIVE_VERSION))
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
/*
|
|
We create the shared memory space that we will use for the open table.
|
|
No matter what we try to get or create a share. This is so that a repair
|
|
table operation can occur.
|
|
|
|
See ha_example.cc for a longer description.
|
|
*/
|
|
ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
|
|
{
|
|
uint length;
|
|
DBUG_ENTER("ha_archive::get_share");
|
|
|
|
pthread_mutex_lock(&archive_mutex);
|
|
length=(uint) strlen(table_name);
|
|
|
|
if (!(share=(ARCHIVE_SHARE*) hash_search(&archive_open_tables,
|
|
(uchar*) table_name,
|
|
length)))
|
|
{
|
|
char *tmp_name;
|
|
azio_stream archive_tmp;
|
|
|
|
if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
|
|
&share, sizeof(*share),
|
|
&tmp_name, length+1,
|
|
NullS))
|
|
{
|
|
pthread_mutex_unlock(&archive_mutex);
|
|
*rc= HA_ERR_OUT_OF_MEM;
|
|
DBUG_RETURN(NULL);
|
|
}
|
|
|
|
share->use_count= 0;
|
|
share->table_name_length= length;
|
|
share->table_name= tmp_name;
|
|
share->crashed= FALSE;
|
|
share->archive_write_open= FALSE;
|
|
fn_format(share->data_file_name, table_name, "",
|
|
ARZ, MY_REPLACE_EXT | MY_UNPACK_FILENAME);
|
|
strmov(share->table_name, table_name);
|
|
DBUG_PRINT("ha_archive", ("Data File %s",
|
|
share->data_file_name));
|
|
/*
|
|
We will use this lock for rows.
|
|
*/
|
|
VOID(pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST));
|
|
|
|
/*
|
|
We read the meta file, but do not mark it dirty. Since we are not
|
|
doing a write we won't mark it dirty (and we won't open it for
|
|
anything but reading... open it for write and we will generate null
|
|
compression writes).
|
|
*/
|
|
if (!(azopen(&archive_tmp, share->data_file_name, O_RDONLY|O_BINARY)))
|
|
{
|
|
DBUG_RETURN(NULL);
|
|
}
|
|
stats.auto_increment_value= archive_tmp.auto_increment;
|
|
share->rows_recorded= (ha_rows)archive_tmp.rows;
|
|
share->crashed= archive_tmp.dirty;
|
|
azclose(&archive_tmp);
|
|
|
|
VOID(my_hash_insert(&archive_open_tables, (uchar*) share));
|
|
thr_lock_init(&share->lock);
|
|
}
|
|
share->use_count++;
|
|
DBUG_PRINT("ha_archive", ("archive table %.*s has %d open handles now",
|
|
share->table_name_length, share->table_name,
|
|
share->use_count));
|
|
if (share->crashed)
|
|
*rc= HA_ERR_CRASHED_ON_USAGE;
|
|
pthread_mutex_unlock(&archive_mutex);
|
|
|
|
DBUG_RETURN(share);
|
|
}
|
|
|
|
|
|
/*
|
|
Free the share.
|
|
See ha_example.cc for a description.
|
|
*/
|
|
int ha_archive::free_share()
|
|
{
|
|
int rc= 0;
|
|
DBUG_ENTER("ha_archive::free_share");
|
|
DBUG_PRINT("ha_archive",
|
|
("archive table %.*s has %d open handles on entrance",
|
|
share->table_name_length, share->table_name,
|
|
share->use_count));
|
|
|
|
pthread_mutex_lock(&archive_mutex);
|
|
if (!--share->use_count)
|
|
{
|
|
hash_delete(&archive_open_tables, (uchar*) share);
|
|
thr_lock_delete(&share->lock);
|
|
VOID(pthread_mutex_destroy(&share->mutex));
|
|
/*
|
|
We need to make sure we don't reset the crashed state.
|
|
If we open a crashed file, wee need to close it as crashed unless
|
|
it has been repaired.
|
|
Since we will close the data down after this, we go on and count
|
|
the flush on close;
|
|
*/
|
|
if (share->archive_write_open)
|
|
{
|
|
if (azclose(&(share->archive_write)))
|
|
rc= 1;
|
|
}
|
|
my_free((uchar*) share, MYF(0));
|
|
}
|
|
pthread_mutex_unlock(&archive_mutex);
|
|
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
int ha_archive::init_archive_writer()
|
|
{
|
|
DBUG_ENTER("ha_archive::init_archive_writer");
|
|
/*
|
|
It is expensive to open and close the data files and since you can't have
|
|
a gzip file that can be both read and written we keep a writer open
|
|
that is shared amoung all open tables.
|
|
*/
|
|
if (!(azopen(&(share->archive_write), share->data_file_name,
|
|
O_RDWR|O_BINARY)))
|
|
{
|
|
DBUG_PRINT("ha_archive", ("Could not open archive write file"));
|
|
share->crashed= TRUE;
|
|
DBUG_RETURN(1);
|
|
}
|
|
share->archive_write_open= TRUE;
|
|
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
int ha_archive::init_archive_reader()
|
|
{
|
|
DBUG_ENTER("ha_archive::init_archive_reader");
|
|
/*
|
|
It is expensive to open and close the data files and since you can't have
|
|
a gzip file that can be both read and written we keep a writer open
|
|
that is shared amoung all open tables.
|
|
*/
|
|
if (!archive_reader_open)
|
|
{
|
|
if (!(azopen(&archive, share->data_file_name, O_RDONLY|O_BINARY)))
|
|
{
|
|
DBUG_PRINT("ha_archive", ("Could not open archive read file"));
|
|
share->crashed= TRUE;
|
|
DBUG_RETURN(1);
|
|
}
|
|
archive_reader_open= TRUE;
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
/*
|
|
We just implement one additional file extension.
|
|
*/
|
|
static const char *ha_archive_exts[] = {
|
|
ARZ,
|
|
NullS
|
|
};
|
|
|
|
const char **ha_archive::bas_ext() const
|
|
{
|
|
return ha_archive_exts;
|
|
}
|
|
|
|
|
|
/*
|
|
When opening a file we:
|
|
Create/get our shared structure.
|
|
Init out lock.
|
|
We open the file we will read from.
|
|
*/
|
|
int ha_archive::open(const char *name, int mode, uint open_options)
|
|
{
|
|
int rc= 0;
|
|
DBUG_ENTER("ha_archive::open");
|
|
|
|
DBUG_PRINT("ha_archive", ("archive table was opened for crash: %s",
|
|
(open_options & HA_OPEN_FOR_REPAIR) ? "yes" : "no"));
|
|
share= get_share(name, &rc);
|
|
|
|
if (rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR))
|
|
{
|
|
/* purecov: begin inspected */
|
|
free_share();
|
|
DBUG_RETURN(rc);
|
|
/* purecov: end */
|
|
}
|
|
else if (rc == HA_ERR_OUT_OF_MEM)
|
|
{
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
DBUG_ASSERT(share);
|
|
|
|
record_buffer= create_record_buffer(table->s->reclength +
|
|
ARCHIVE_ROW_HEADER_SIZE);
|
|
|
|
if (!record_buffer)
|
|
{
|
|
free_share();
|
|
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
|
}
|
|
|
|
thr_lock_data_init(&share->lock, &lock, NULL);
|
|
|
|
DBUG_PRINT("ha_archive", ("archive table was crashed %s",
|
|
rc == HA_ERR_CRASHED_ON_USAGE ? "yes" : "no"));
|
|
if (rc == HA_ERR_CRASHED_ON_USAGE && open_options & HA_OPEN_FOR_REPAIR)
|
|
{
|
|
DBUG_RETURN(0);
|
|
}
|
|
else
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
|
|
/*
|
|
Closes the file.
|
|
|
|
SYNOPSIS
|
|
close();
|
|
|
|
IMPLEMENTATION:
|
|
|
|
We first close this storage engines file handle to the archive and
|
|
then remove our reference count to the table (and possibly free it
|
|
as well).
|
|
|
|
RETURN
|
|
0 ok
|
|
1 Error
|
|
*/
|
|
|
|
int ha_archive::close(void)
|
|
{
|
|
int rc= 0;
|
|
DBUG_ENTER("ha_archive::close");
|
|
|
|
destroy_record_buffer(record_buffer);
|
|
|
|
/* First close stream */
|
|
if (archive_reader_open)
|
|
{
|
|
if (azclose(&archive))
|
|
rc= 1;
|
|
}
|
|
/* then also close share */
|
|
rc|= free_share();
|
|
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
|
|
/*
|
|
We create our data file here. The format is pretty simple.
|
|
You can read about the format of the data file above.
|
|
Unlike other storage engines we do not "pack" our data. Since we
|
|
are about to do a general compression, packing would just be a waste of
|
|
CPU time. If the table has blobs they are written after the row in the order
|
|
of creation.
|
|
*/
|
|
|
|
int ha_archive::create(const char *name, TABLE *table_arg,
|
|
HA_CREATE_INFO *create_info)
|
|
{
|
|
char name_buff[FN_REFLEN];
|
|
char linkname[FN_REFLEN];
|
|
int error;
|
|
azio_stream create_stream; /* Archive file we are working with */
|
|
File frm_file; /* File handler for readers */
|
|
MY_STAT file_stat; // Stat information for the data file
|
|
uchar *frm_ptr;
|
|
|
|
DBUG_ENTER("ha_archive::create");
|
|
|
|
stats.auto_increment_value= (create_info->auto_increment_value ?
|
|
create_info->auto_increment_value -1 :
|
|
(ulonglong) 0);
|
|
|
|
for (uint key= 0; key < table_arg->s->keys; key++)
|
|
{
|
|
KEY *pos= table_arg->key_info+key;
|
|
KEY_PART_INFO *key_part= pos->key_part;
|
|
KEY_PART_INFO *key_part_end= key_part + pos->key_parts;
|
|
|
|
for (; key_part != key_part_end; key_part++)
|
|
{
|
|
Field *field= key_part->field;
|
|
|
|
if (!(field->flags & AUTO_INCREMENT_FLAG))
|
|
{
|
|
error= -1;
|
|
DBUG_PRINT("ha_archive", ("Index error in creating archive table"));
|
|
goto error;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
We reuse name_buff since it is available.
|
|
*/
|
|
if (create_info->data_file_name && create_info->data_file_name[0] != '#')
|
|
{
|
|
DBUG_PRINT("ha_archive", ("archive will create stream file %s",
|
|
create_info->data_file_name));
|
|
|
|
fn_format(name_buff, create_info->data_file_name, "", ARZ,
|
|
MY_REPLACE_EXT | MY_UNPACK_FILENAME);
|
|
fn_format(linkname, name, "", ARZ,
|
|
MY_REPLACE_EXT | MY_UNPACK_FILENAME);
|
|
}
|
|
else
|
|
{
|
|
fn_format(name_buff, name, "", ARZ,
|
|
MY_REPLACE_EXT | MY_UNPACK_FILENAME);
|
|
linkname[0]= 0;
|
|
}
|
|
|
|
/*
|
|
There is a chance that the file was "discovered". In this case
|
|
just use whatever file is there.
|
|
*/
|
|
if (!(my_stat(name_buff, &file_stat, MYF(0))))
|
|
{
|
|
my_errno= 0;
|
|
if (!(azopen(&create_stream, name_buff, O_CREAT|O_RDWR|O_BINARY)))
|
|
{
|
|
error= errno;
|
|
goto error2;
|
|
}
|
|
|
|
if (linkname[0])
|
|
my_symlink(name_buff, linkname, MYF(0));
|
|
fn_format(name_buff, name, "", ".frm",
|
|
MY_REPLACE_EXT | MY_UNPACK_FILENAME);
|
|
|
|
/*
|
|
Here is where we open up the frm and pass it to archive to store
|
|
*/
|
|
if ((frm_file= my_open(name_buff, O_RDONLY, MYF(0))) > 0)
|
|
{
|
|
if (!my_fstat(frm_file, &file_stat, MYF(MY_WME)))
|
|
{
|
|
frm_ptr= (uchar *)my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0));
|
|
if (frm_ptr)
|
|
{
|
|
my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0));
|
|
azwrite_frm(&create_stream, (char *)frm_ptr, file_stat.st_size);
|
|
my_free((uchar*)frm_ptr, MYF(0));
|
|
}
|
|
}
|
|
my_close(frm_file, MYF(0));
|
|
}
|
|
|
|
if (create_info->comment.str)
|
|
azwrite_comment(&create_stream, create_info->comment.str,
|
|
create_info->comment.length);
|
|
|
|
/*
|
|
Yes you need to do this, because the starting value
|
|
for the autoincrement may not be zero.
|
|
*/
|
|
create_stream.auto_increment= stats.auto_increment_value;
|
|
if (azclose(&create_stream))
|
|
{
|
|
error= errno;
|
|
goto error2;
|
|
}
|
|
}
|
|
else
|
|
my_errno= 0;
|
|
|
|
DBUG_PRINT("ha_archive", ("Creating File %s", name_buff));
|
|
DBUG_PRINT("ha_archive", ("Creating Link %s", linkname));
|
|
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
error2:
|
|
delete_table(name);
|
|
error:
|
|
/* Return error number, if we got one */
|
|
DBUG_RETURN(error ? error : -1);
|
|
}
|
|
|
|
/*
|
|
This is where the actual row is written out.
|
|
*/
|
|
int ha_archive::real_write_row(uchar *buf, azio_stream *writer)
|
|
{
|
|
my_off_t written;
|
|
unsigned int r_pack_length;
|
|
DBUG_ENTER("ha_archive::real_write_row");
|
|
|
|
/* We pack the row for writing */
|
|
r_pack_length= pack_row(buf);
|
|
|
|
written= azwrite(writer, record_buffer->buffer, r_pack_length);
|
|
if (written != r_pack_length)
|
|
{
|
|
DBUG_PRINT("ha_archive", ("Wrote %d bytes expected %d",
|
|
(uint32) written,
|
|
(uint32)r_pack_length));
|
|
DBUG_RETURN(-1);
|
|
}
|
|
|
|
if (!delayed_insert || !bulk_insert)
|
|
share->dirty= TRUE;
|
|
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
/*
|
|
Calculate max length needed for row. This includes
|
|
the bytes required for the length in the header.
|
|
*/
|
|
|
|
uint32 ha_archive::max_row_length(const uchar *buf)
|
|
{
|
|
uint32 length= (uint32)(table->s->reclength + table->s->fields*2);
|
|
length+= ARCHIVE_ROW_HEADER_SIZE;
|
|
|
|
uint *ptr, *end;
|
|
for (ptr= table->s->blob_field, end=ptr + table->s->blob_fields ;
|
|
ptr != end ;
|
|
ptr++)
|
|
{
|
|
length += 2 + ((Field_blob*)table->field[*ptr])->get_length();
|
|
}
|
|
|
|
return length;
|
|
}
|
|
|
|
|
|
unsigned int ha_archive::pack_row(uchar *record)
|
|
{
|
|
uchar *ptr;
|
|
|
|
DBUG_ENTER("ha_archive::pack_row");
|
|
|
|
|
|
if (fix_rec_buff(max_row_length(record)))
|
|
DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */
|
|
|
|
/* Copy null bits */
|
|
memcpy(record_buffer->buffer+ARCHIVE_ROW_HEADER_SIZE,
|
|
record, table->s->null_bytes);
|
|
ptr= record_buffer->buffer + table->s->null_bytes + ARCHIVE_ROW_HEADER_SIZE;
|
|
|
|
for (Field **field=table->field ; *field ; field++)
|
|
{
|
|
if (!((*field)->is_null()))
|
|
ptr= (*field)->pack(ptr, record + (*field)->offset(record));
|
|
}
|
|
|
|
int4store(record_buffer->buffer, (int)(ptr - record_buffer->buffer -
|
|
ARCHIVE_ROW_HEADER_SIZE));
|
|
DBUG_PRINT("ha_archive",("Pack row length %u", (unsigned int)
|
|
(ptr - record_buffer->buffer -
|
|
ARCHIVE_ROW_HEADER_SIZE)));
|
|
|
|
DBUG_RETURN((unsigned int) (ptr - record_buffer->buffer));
|
|
}
|
|
|
|
|
|
/*
|
|
Look at ha_archive::open() for an explanation of the row format.
|
|
Here we just write out the row.
|
|
|
|
Wondering about start_bulk_insert()? We don't implement it for
|
|
archive since it optimizes for lots of writes. The only save
|
|
for implementing start_bulk_insert() is that we could skip
|
|
setting dirty to true each time.
|
|
*/
|
|
int ha_archive::write_row(uchar *buf)
|
|
{
|
|
int rc;
|
|
uchar *read_buf= NULL;
|
|
ulonglong temp_auto;
|
|
uchar *record= table->record[0];
|
|
DBUG_ENTER("ha_archive::write_row");
|
|
|
|
if (share->crashed)
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
if (!share->archive_write_open)
|
|
if (init_archive_writer())
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
ha_statistic_increment(&SSV::ha_write_count);
|
|
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
|
|
table->timestamp_field->set_time();
|
|
pthread_mutex_lock(&share->mutex);
|
|
|
|
if (table->next_number_field && record == table->record[0])
|
|
{
|
|
KEY *mkey= &table->s->key_info[0]; // We only support one key right now
|
|
update_auto_increment();
|
|
temp_auto= table->next_number_field->val_int();
|
|
|
|
/*
|
|
We don't support decremening auto_increment. They make the performance
|
|
just cry.
|
|
*/
|
|
if (temp_auto <= share->archive_write.auto_increment &&
|
|
mkey->flags & HA_NOSAME)
|
|
{
|
|
rc= HA_ERR_FOUND_DUPP_KEY;
|
|
goto error;
|
|
}
|
|
#ifdef DEAD_CODE
|
|
/*
|
|
Bad news, this will cause a search for the unique value which is very
|
|
expensive since we will have to do a table scan which will lock up
|
|
all other writers during this period. This could perhaps be optimized
|
|
in the future.
|
|
*/
|
|
{
|
|
/*
|
|
First we create a buffer that we can use for reading rows, and can pass
|
|
to get_row().
|
|
*/
|
|
if (!(read_buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
|
|
{
|
|
rc= HA_ERR_OUT_OF_MEM;
|
|
goto error;
|
|
}
|
|
/*
|
|
All of the buffer must be written out or we won't see all of the
|
|
data
|
|
*/
|
|
azflush(&(share->archive_write), Z_SYNC_FLUSH);
|
|
/*
|
|
Set the position of the local read thread to the beginning postion.
|
|
*/
|
|
if (read_data_header(&archive))
|
|
{
|
|
rc= HA_ERR_CRASHED_ON_USAGE;
|
|
goto error;
|
|
}
|
|
|
|
Field *mfield= table->next_number_field;
|
|
|
|
while (!(get_row(&archive, read_buf)))
|
|
{
|
|
if (!memcmp(read_buf + mfield->offset(record),
|
|
table->next_number_field->ptr,
|
|
mfield->max_display_length()))
|
|
{
|
|
rc= HA_ERR_FOUND_DUPP_KEY;
|
|
goto error;
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
else
|
|
{
|
|
if (temp_auto > share->archive_write.auto_increment)
|
|
stats.auto_increment_value= share->archive_write.auto_increment=
|
|
temp_auto;
|
|
}
|
|
}
|
|
|
|
/*
|
|
Notice that the global auto_increment has been increased.
|
|
In case of a failed row write, we will never try to reuse the value.
|
|
*/
|
|
share->rows_recorded++;
|
|
rc= real_write_row(buf, &(share->archive_write));
|
|
error:
|
|
pthread_mutex_unlock(&share->mutex);
|
|
if (read_buf)
|
|
my_free((uchar*) read_buf, MYF(0));
|
|
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
|
|
void ha_archive::get_auto_increment(ulonglong offset, ulonglong increment,
|
|
ulonglong nb_desired_values,
|
|
ulonglong *first_value,
|
|
ulonglong *nb_reserved_values)
|
|
{
|
|
*nb_reserved_values= 1;
|
|
*first_value= share->archive_write.auto_increment + 1;
|
|
}
|
|
|
|
/* Initialized at each key walk (called multiple times unlike rnd_init()) */
|
|
int ha_archive::index_init(uint keynr, bool sorted)
|
|
{
|
|
DBUG_ENTER("ha_archive::index_init");
|
|
active_index= keynr;
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
/*
|
|
No indexes, so if we get a request for an index search since we tell
|
|
the optimizer that we have unique indexes, we scan
|
|
*/
|
|
int ha_archive::index_read(uchar *buf, const uchar *key,
|
|
uint key_len, enum ha_rkey_function find_flag)
|
|
{
|
|
int rc;
|
|
DBUG_ENTER("ha_archive::index_read");
|
|
rc= index_read_idx(buf, active_index, key, key_len, find_flag);
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
|
|
int ha_archive::index_read_idx(uchar *buf, uint index, const uchar *key,
|
|
uint key_len, enum ha_rkey_function find_flag)
|
|
{
|
|
int rc;
|
|
bool found= 0;
|
|
KEY *mkey= &table->s->key_info[index];
|
|
current_k_offset= mkey->key_part->offset;
|
|
current_key= key;
|
|
current_key_len= key_len;
|
|
|
|
|
|
DBUG_ENTER("ha_archive::index_read_idx");
|
|
|
|
rc= rnd_init(TRUE);
|
|
|
|
if (rc)
|
|
goto error;
|
|
|
|
while (!(get_row(&archive, buf)))
|
|
{
|
|
if (!memcmp(current_key, buf + current_k_offset, current_key_len))
|
|
{
|
|
found= 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (found)
|
|
DBUG_RETURN(0);
|
|
|
|
error:
|
|
DBUG_RETURN(rc ? rc : HA_ERR_END_OF_FILE);
|
|
}
|
|
|
|
|
|
int ha_archive::index_next(uchar * buf)
|
|
{
|
|
bool found= 0;
|
|
|
|
DBUG_ENTER("ha_archive::index_next");
|
|
|
|
while (!(get_row(&archive, buf)))
|
|
{
|
|
if (!memcmp(current_key, buf+current_k_offset, current_key_len))
|
|
{
|
|
found= 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
DBUG_RETURN(found ? 0 : HA_ERR_END_OF_FILE);
|
|
}
|
|
|
|
/*
|
|
All calls that need to scan the table start with this method. If we are told
|
|
that it is a table scan we rewind the file to the beginning, otherwise
|
|
we assume the position will be set.
|
|
*/
|
|
|
|
int ha_archive::rnd_init(bool scan)
|
|
{
|
|
DBUG_ENTER("ha_archive::rnd_init");
|
|
|
|
if (share->crashed)
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
init_archive_reader();
|
|
|
|
/* We rewind the file so that we can read from the beginning if scan */
|
|
if (scan)
|
|
{
|
|
DBUG_PRINT("info", ("archive will retrieve %llu rows",
|
|
(unsigned long long) scan_rows));
|
|
stats.records= 0;
|
|
|
|
/*
|
|
If dirty, we lock, and then reset/flush the data.
|
|
I found that just calling azflush() doesn't always work.
|
|
*/
|
|
pthread_mutex_lock(&share->mutex);
|
|
scan_rows= share->rows_recorded;
|
|
if (share->dirty == TRUE)
|
|
{
|
|
if (share->dirty == TRUE)
|
|
{
|
|
DBUG_PRINT("ha_archive", ("archive flushing out rows for scan"));
|
|
azflush(&(share->archive_write), Z_SYNC_FLUSH);
|
|
share->dirty= FALSE;
|
|
}
|
|
}
|
|
pthread_mutex_unlock(&share->mutex);
|
|
|
|
if (read_data_header(&archive))
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
/*
|
|
This is the method that is used to read a row. It assumes that the row is
|
|
positioned where you want it.
|
|
*/
|
|
int ha_archive::get_row(azio_stream *file_to_read, uchar *buf)
|
|
{
|
|
int rc;
|
|
DBUG_ENTER("ha_archive::get_row");
|
|
DBUG_PRINT("ha_archive", ("Picking version for get_row() %d -> %d",
|
|
(uchar)file_to_read->version,
|
|
ARCHIVE_VERSION));
|
|
if (file_to_read->version == ARCHIVE_VERSION)
|
|
rc= get_row_version3(file_to_read, buf);
|
|
else
|
|
rc= get_row_version2(file_to_read, buf);
|
|
|
|
DBUG_PRINT("ha_archive", ("Return %d\n", rc));
|
|
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
/* Reallocate buffer if needed */
|
|
bool ha_archive::fix_rec_buff(unsigned int length)
|
|
{
|
|
DBUG_ENTER("ha_archive::fix_rec_buff");
|
|
DBUG_PRINT("ha_archive", ("Fixing %u for %u",
|
|
length, record_buffer->length));
|
|
DBUG_ASSERT(record_buffer->buffer);
|
|
|
|
if (length > record_buffer->length)
|
|
{
|
|
uchar *newptr;
|
|
if (!(newptr=(uchar*) my_realloc((uchar*) record_buffer->buffer,
|
|
length,
|
|
MYF(MY_ALLOW_ZERO_PTR))))
|
|
DBUG_RETURN(1);
|
|
record_buffer->buffer= newptr;
|
|
record_buffer->length= length;
|
|
}
|
|
|
|
DBUG_ASSERT(length <= record_buffer->length);
|
|
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
int ha_archive::unpack_row(azio_stream *file_to_read, uchar *record)
|
|
{
|
|
DBUG_ENTER("ha_archive::unpack_row");
|
|
|
|
unsigned int read;
|
|
int error;
|
|
uchar size_buffer[ARCHIVE_ROW_HEADER_SIZE];
|
|
unsigned int row_len;
|
|
|
|
/* First we grab the length stored */
|
|
read= azread(file_to_read, size_buffer, ARCHIVE_ROW_HEADER_SIZE, &error);
|
|
|
|
if (error == Z_STREAM_ERROR || (read && read < ARCHIVE_ROW_HEADER_SIZE))
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
/* If we read nothing we are at the end of the file */
|
|
if (read == 0 || read != ARCHIVE_ROW_HEADER_SIZE)
|
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
|
|
|
row_len= uint4korr(size_buffer);
|
|
DBUG_PRINT("ha_archive",("Unpack row length %u -> %u", row_len,
|
|
(unsigned int)table->s->reclength));
|
|
fix_rec_buff(row_len);
|
|
DBUG_ASSERT(row_len <= record_buffer->length);
|
|
|
|
read= azread(file_to_read, record_buffer->buffer, row_len, &error);
|
|
|
|
DBUG_ASSERT(row_len == read);
|
|
|
|
if (read != row_len || error)
|
|
{
|
|
DBUG_RETURN(-1);
|
|
}
|
|
|
|
/* Copy null bits */
|
|
const uchar *ptr= record_buffer->buffer;
|
|
memcpy(record, ptr, table->s->null_bytes);
|
|
ptr+= table->s->null_bytes;
|
|
for (Field **field=table->field ; *field ; field++)
|
|
{
|
|
if (!((*field)->is_null()))
|
|
{
|
|
ptr= (*field)->unpack(record + (*field)->offset(table->record[0]), ptr);
|
|
}
|
|
}
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
int ha_archive::get_row_version3(azio_stream *file_to_read, uchar *buf)
|
|
{
|
|
DBUG_ENTER("ha_archive::get_row_version3");
|
|
|
|
int returnable= unpack_row(file_to_read, buf);
|
|
|
|
DBUG_RETURN(returnable);
|
|
}
|
|
|
|
|
|
int ha_archive::get_row_version2(azio_stream *file_to_read, uchar *buf)
|
|
{
|
|
unsigned int read;
|
|
int error;
|
|
uint *ptr, *end;
|
|
char *last;
|
|
size_t total_blob_length= 0;
|
|
MY_BITMAP *read_set= table->read_set;
|
|
DBUG_ENTER("ha_archive::get_row_version2");
|
|
|
|
read= azread(file_to_read, (voidp)buf, table->s->reclength, &error);
|
|
|
|
/* If we read nothing we are at the end of the file */
|
|
if (read == 0)
|
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
|
|
|
if (read != table->s->reclength)
|
|
{
|
|
DBUG_PRINT("ha_archive::get_row_version2", ("Read %u bytes expected %u",
|
|
read,
|
|
(unsigned int)table->s->reclength));
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
}
|
|
|
|
if (error == Z_STREAM_ERROR || error == Z_DATA_ERROR )
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
/*
|
|
If the record is the wrong size, the file is probably damaged, unless
|
|
we are dealing with a delayed insert or a bulk insert.
|
|
*/
|
|
if ((ulong) read != table->s->reclength)
|
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
|
|
|
/* Calculate blob length, we use this for our buffer */
|
|
for (ptr= table->s->blob_field, end=ptr + table->s->blob_fields ;
|
|
ptr != end ;
|
|
ptr++)
|
|
{
|
|
if (bitmap_is_set(read_set,
|
|
(((Field_blob*) table->field[*ptr])->field_index)))
|
|
total_blob_length += ((Field_blob*) table->field[*ptr])->get_length();
|
|
}
|
|
|
|
/* Adjust our row buffer if we need be */
|
|
buffer.alloc(total_blob_length);
|
|
last= (char *)buffer.ptr();
|
|
|
|
/* Loop through our blobs and read them */
|
|
for (ptr= table->s->blob_field, end=ptr + table->s->blob_fields ;
|
|
ptr != end ;
|
|
ptr++)
|
|
{
|
|
size_t size= ((Field_blob*) table->field[*ptr])->get_length();
|
|
if (size)
|
|
{
|
|
if (bitmap_is_set(read_set,
|
|
((Field_blob*) table->field[*ptr])->field_index))
|
|
{
|
|
read= azread(file_to_read, last, size, &error);
|
|
|
|
if (error)
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
if ((size_t) read != size)
|
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
|
((Field_blob*) table->field[*ptr])->set_ptr(size, (uchar*) last);
|
|
last += size;
|
|
}
|
|
else
|
|
{
|
|
(void)azseek(file_to_read, size, SEEK_CUR);
|
|
}
|
|
}
|
|
}
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
/*
|
|
Called during ORDER BY. Its position is either from being called sequentially
|
|
or by having had ha_archive::rnd_pos() called before it is called.
|
|
*/
|
|
|
|
int ha_archive::rnd_next(uchar *buf)
|
|
{
|
|
int rc;
|
|
DBUG_ENTER("ha_archive::rnd_next");
|
|
|
|
if (share->crashed)
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
if (!scan_rows)
|
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
|
scan_rows--;
|
|
|
|
ha_statistic_increment(&SSV::ha_read_rnd_next_count);
|
|
current_position= aztell(&archive);
|
|
rc= get_row(&archive, buf);
|
|
|
|
|
|
if (rc != HA_ERR_END_OF_FILE)
|
|
stats.records++;
|
|
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
|
|
/*
|
|
Thanks to the table flag HA_REC_NOT_IN_SEQ this will be called after
|
|
each call to ha_archive::rnd_next() if an ordering of the rows is
|
|
needed.
|
|
*/
|
|
|
|
void ha_archive::position(const uchar *record)
|
|
{
|
|
DBUG_ENTER("ha_archive::position");
|
|
my_store_ptr(ref, ref_length, current_position);
|
|
DBUG_VOID_RETURN;
|
|
}
|
|
|
|
|
|
/*
|
|
This is called after a table scan for each row if the results of the
|
|
scan need to be ordered. It will take *pos and use it to move the
|
|
cursor in the file so that the next row that is called is the
|
|
correctly ordered row.
|
|
*/
|
|
|
|
int ha_archive::rnd_pos(uchar * buf, uchar *pos)
|
|
{
|
|
DBUG_ENTER("ha_archive::rnd_pos");
|
|
ha_statistic_increment(&SSV::ha_read_rnd_next_count);
|
|
current_position= (my_off_t)my_get_ptr(pos, ref_length);
|
|
(void)azseek(&archive, current_position, SEEK_SET);
|
|
|
|
DBUG_RETURN(get_row(&archive, buf));
|
|
}
|
|
|
|
/*
|
|
This method repairs the meta file. It does this by walking the datafile and
|
|
rewriting the meta file. Currently it does this by calling optimize with
|
|
the extended flag.
|
|
*/
|
|
int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt)
|
|
{
|
|
DBUG_ENTER("ha_archive::repair");
|
|
check_opt->flags= T_EXTEND;
|
|
int rc= optimize(thd, check_opt);
|
|
|
|
if (rc)
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_REPAIR);
|
|
|
|
share->crashed= FALSE;
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
/*
|
|
The table can become fragmented if data was inserted, read, and then
|
|
inserted again. What we do is open up the file and recompress it completely.
|
|
*/
|
|
int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
|
|
{
|
|
DBUG_ENTER("ha_archive::optimize");
|
|
int rc= 0;
|
|
azio_stream writer;
|
|
char writer_filename[FN_REFLEN];
|
|
|
|
init_archive_reader();
|
|
|
|
// now we close both our writer and our reader for the rename
|
|
if (share->archive_write_open)
|
|
{
|
|
azclose(&(share->archive_write));
|
|
share->archive_write_open= FALSE;
|
|
}
|
|
|
|
/* Lets create a file to contain the new data */
|
|
fn_format(writer_filename, share->table_name, "", ARN,
|
|
MY_REPLACE_EXT | MY_UNPACK_FILENAME);
|
|
|
|
if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY)))
|
|
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
|
|
/*
|
|
An extended rebuild is a lot more effort. We open up each row and re-record it.
|
|
Any dead rows are removed (aka rows that may have been partially recorded).
|
|
|
|
As of Archive format 3, this is the only type that is performed, before this
|
|
version it was just done on T_EXTEND
|
|
*/
|
|
if (1)
|
|
{
|
|
DBUG_PRINT("ha_archive", ("archive extended rebuild"));
|
|
|
|
/*
|
|
Now we will rewind the archive file so that we are positioned at the
|
|
start of the file.
|
|
*/
|
|
rc= read_data_header(&archive);
|
|
|
|
/*
|
|
On success of writing out the new header, we now fetch each row and
|
|
insert it into the new archive file.
|
|
*/
|
|
if (!rc)
|
|
{
|
|
share->rows_recorded= 0;
|
|
stats.auto_increment_value= share->archive_write.auto_increment= 0;
|
|
my_bitmap_map *org_bitmap= dbug_tmp_use_all_columns(table, table->read_set);
|
|
|
|
while (!(rc= get_row(&archive, table->record[0])))
|
|
{
|
|
real_write_row(table->record[0], &writer);
|
|
/*
|
|
Long term it should be possible to optimize this so that
|
|
it is not called on each row.
|
|
*/
|
|
if (table->found_next_number_field)
|
|
{
|
|
Field *field= table->found_next_number_field;
|
|
ulonglong auto_value=
|
|
(ulonglong) field->val_int(table->record[0] +
|
|
field->offset(table->record[0]));
|
|
if (share->archive_write.auto_increment < auto_value)
|
|
stats.auto_increment_value= share->archive_write.auto_increment=
|
|
auto_value;
|
|
}
|
|
}
|
|
|
|
dbug_tmp_restore_column_map(table->read_set, org_bitmap);
|
|
share->rows_recorded= (ha_rows)writer.rows;
|
|
}
|
|
|
|
DBUG_PRINT("info", ("recovered %llu archive rows",
|
|
(unsigned long long)share->rows_recorded));
|
|
|
|
DBUG_PRINT("ha_archive", ("recovered %llu archive rows",
|
|
(unsigned long long)share->rows_recorded));
|
|
|
|
if (rc && rc != HA_ERR_END_OF_FILE)
|
|
goto error;
|
|
}
|
|
|
|
azclose(&writer);
|
|
share->dirty= FALSE;
|
|
|
|
azclose(&archive);
|
|
|
|
// make the file we just wrote be our data file
|
|
rc = my_rename(writer_filename,share->data_file_name,MYF(0));
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
error:
|
|
DBUG_PRINT("ha_archive", ("Failed to recover, error was %d", rc));
|
|
azclose(&writer);
|
|
|
|
DBUG_RETURN(rc);
|
|
}
|
|
|
|
/*
|
|
Below is an example of how to setup row level locking.
|
|
*/
|
|
THR_LOCK_DATA **ha_archive::store_lock(THD *thd,
|
|
THR_LOCK_DATA **to,
|
|
enum thr_lock_type lock_type)
|
|
{
|
|
if (lock_type == TL_WRITE_DELAYED)
|
|
delayed_insert= TRUE;
|
|
else
|
|
delayed_insert= FALSE;
|
|
|
|
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
|
|
{
|
|
/*
|
|
Here is where we get into the guts of a row level lock.
|
|
If TL_UNLOCK is set
|
|
If we are not doing a LOCK TABLE or DISCARD/IMPORT
|
|
TABLESPACE, then allow multiple writers
|
|
*/
|
|
|
|
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
|
|
lock_type <= TL_WRITE) && !thd_in_lock_tables(thd)
|
|
&& !thd_tablespace_op(thd))
|
|
lock_type = TL_WRITE_ALLOW_WRITE;
|
|
|
|
/*
|
|
In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
|
|
MySQL would use the lock TL_READ_NO_INSERT on t2, and that
|
|
would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
|
|
to t2. Convert the lock to a normal read lock to allow
|
|
concurrent inserts to t2.
|
|
*/
|
|
|
|
if (lock_type == TL_READ_NO_INSERT && !thd_in_lock_tables(thd))
|
|
lock_type = TL_READ;
|
|
|
|
lock.type=lock_type;
|
|
}
|
|
|
|
*to++= &lock;
|
|
|
|
return to;
|
|
}
|
|
|
|
void ha_archive::update_create_info(HA_CREATE_INFO *create_info)
|
|
{
|
|
DBUG_ENTER("ha_archive::update_create_info");
|
|
|
|
ha_archive::info(HA_STATUS_AUTO);
|
|
if (create_info->used_fields & HA_CREATE_USED_AUTO)
|
|
{
|
|
/*
|
|
Internally Archive keeps track of last used, not next used.
|
|
To make the output look like MyISAM we add 1 here.
|
|
|
|
This is not completely compatible with MYISAM though, since
|
|
MyISAM will record on "SHOW CREATE TABLE" the last position,
|
|
where we will report the original position the table was
|
|
created with.
|
|
*/
|
|
create_info->auto_increment_value= stats.auto_increment_value + 1;
|
|
}
|
|
|
|
if (!(my_readlink(share->real_path, share->data_file_name, MYF(0))))
|
|
create_info->data_file_name= share->real_path;
|
|
|
|
DBUG_VOID_RETURN;
|
|
}
|
|
|
|
|
|
/*
|
|
Hints for optimizer, see ha_tina for more information
|
|
*/
|
|
int ha_archive::info(uint flag)
|
|
{
|
|
DBUG_ENTER("ha_archive::info");
|
|
/*
|
|
This should be an accurate number now, though bulk and delayed inserts can
|
|
cause the number to be inaccurate.
|
|
*/
|
|
stats.records= share->rows_recorded;
|
|
stats.deleted= 0;
|
|
/* Costs quite a bit more to get all information */
|
|
if (flag & HA_STATUS_TIME)
|
|
{
|
|
MY_STAT file_stat; // Stat information for the data file
|
|
|
|
VOID(my_stat(share->data_file_name, &file_stat, MYF(MY_WME)));
|
|
|
|
stats.mean_rec_length= table->s->reclength + buffer.alloced_length();
|
|
stats.data_file_length= file_stat.st_size;
|
|
stats.create_time= file_stat.st_ctime;
|
|
stats.update_time= file_stat.st_mtime;
|
|
stats.max_data_file_length= share->rows_recorded * stats.mean_rec_length;
|
|
}
|
|
stats.delete_length= 0;
|
|
stats.index_file_length=0;
|
|
|
|
if (flag & HA_STATUS_AUTO)
|
|
{
|
|
init_archive_reader();
|
|
azflush(&archive, Z_SYNC_FLUSH);
|
|
stats.auto_increment_value= archive.auto_increment;
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
/*
|
|
This method tells us that a bulk insert operation is about to occur. We set
|
|
a flag which will keep write_row from saying that its data is dirty. This in
|
|
turn will keep selects from causing a sync to occur.
|
|
Basically, yet another optimizations to keep compression working well.
|
|
*/
|
|
void ha_archive::start_bulk_insert(ha_rows rows)
|
|
{
|
|
DBUG_ENTER("ha_archive::start_bulk_insert");
|
|
if (!rows || rows >= ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT)
|
|
bulk_insert= TRUE;
|
|
DBUG_VOID_RETURN;
|
|
}
|
|
|
|
|
|
/*
|
|
Other side of start_bulk_insert, is end_bulk_insert. Here we turn off the bulk insert
|
|
flag, and set the share dirty so that the next select will call sync for us.
|
|
*/
|
|
int ha_archive::end_bulk_insert()
|
|
{
|
|
DBUG_ENTER("ha_archive::end_bulk_insert");
|
|
bulk_insert= FALSE;
|
|
share->dirty= TRUE;
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
/*
|
|
We cancel a truncate command. The only way to delete an archive table is to drop it.
|
|
This is done for security reasons. In a later version we will enable this by
|
|
allowing the user to select a different row format.
|
|
*/
|
|
int ha_archive::delete_all_rows()
|
|
{
|
|
DBUG_ENTER("ha_archive::delete_all_rows");
|
|
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
|
|
}
|
|
|
|
/*
|
|
We just return state if asked.
|
|
*/
|
|
bool ha_archive::is_crashed() const
|
|
{
|
|
DBUG_ENTER("ha_archive::is_crashed");
|
|
DBUG_RETURN(share->crashed);
|
|
}
|
|
|
|
/*
|
|
Simple scan of the tables to make sure everything is ok.
|
|
*/
|
|
|
|
int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
|
|
{
|
|
int rc= 0;
|
|
uchar *buf;
|
|
const char *old_proc_info;
|
|
ha_rows count= share->rows_recorded;
|
|
DBUG_ENTER("ha_archive::check");
|
|
|
|
old_proc_info= thd_proc_info(thd, "Checking table");
|
|
/* Flush any waiting data */
|
|
azflush(&(share->archive_write), Z_SYNC_FLUSH);
|
|
|
|
/*
|
|
First we create a buffer that we can use for reading rows, and can pass
|
|
to get_row().
|
|
*/
|
|
if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
|
|
rc= HA_ERR_OUT_OF_MEM;
|
|
|
|
/*
|
|
Now we will rewind the archive file so that we are positioned at the
|
|
start of the file.
|
|
*/
|
|
init_archive_reader();
|
|
|
|
if (!rc)
|
|
read_data_header(&archive);
|
|
|
|
if (!rc)
|
|
while (!(rc= get_row(&archive, buf)))
|
|
count--;
|
|
|
|
my_free((char*)buf, MYF(0));
|
|
|
|
thd_proc_info(thd, old_proc_info);
|
|
|
|
if ((rc && rc != HA_ERR_END_OF_FILE) || count)
|
|
{
|
|
share->crashed= FALSE;
|
|
DBUG_RETURN(HA_ADMIN_CORRUPT);
|
|
}
|
|
else
|
|
{
|
|
DBUG_RETURN(HA_ADMIN_OK);
|
|
}
|
|
}
|
|
|
|
/*
|
|
Check and repair the table if needed.
|
|
*/
|
|
bool ha_archive::check_and_repair(THD *thd)
|
|
{
|
|
HA_CHECK_OPT check_opt;
|
|
DBUG_ENTER("ha_archive::check_and_repair");
|
|
|
|
check_opt.init();
|
|
|
|
DBUG_RETURN(repair(thd, &check_opt));
|
|
}
|
|
|
|
archive_record_buffer *ha_archive::create_record_buffer(unsigned int length)
|
|
{
|
|
DBUG_ENTER("ha_archive::create_record_buffer");
|
|
archive_record_buffer *r;
|
|
if (!(r=
|
|
(archive_record_buffer*) my_malloc(sizeof(archive_record_buffer),
|
|
MYF(MY_WME))))
|
|
{
|
|
DBUG_RETURN(NULL); /* purecov: inspected */
|
|
}
|
|
r->length= (int)length;
|
|
|
|
if (!(r->buffer= (uchar*) my_malloc(r->length,
|
|
MYF(MY_WME))))
|
|
{
|
|
my_free((char*) r, MYF(MY_ALLOW_ZERO_PTR));
|
|
DBUG_RETURN(NULL); /* purecov: inspected */
|
|
}
|
|
|
|
DBUG_RETURN(r);
|
|
}
|
|
|
|
void ha_archive::destroy_record_buffer(archive_record_buffer *r)
|
|
{
|
|
DBUG_ENTER("ha_archive::destroy_record_buffer");
|
|
my_free((char*) r->buffer, MYF(MY_ALLOW_ZERO_PTR));
|
|
my_free((char*) r, MYF(MY_ALLOW_ZERO_PTR));
|
|
DBUG_VOID_RETURN;
|
|
}
|
|
|
|
struct st_mysql_storage_engine archive_storage_engine=
|
|
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
|
|
|
|
mysql_declare_plugin(archive)
|
|
{
|
|
MYSQL_STORAGE_ENGINE_PLUGIN,
|
|
&archive_storage_engine,
|
|
"ARCHIVE",
|
|
"Brian Aker, MySQL AB",
|
|
"Archive storage engine",
|
|
PLUGIN_LICENSE_GPL,
|
|
archive_db_init, /* Plugin Init */
|
|
archive_db_done, /* Plugin Deinit */
|
|
0x0300 /* 3.0 */,
|
|
NULL, /* status variables */
|
|
NULL, /* system variables */
|
|
NULL /* config options */
|
|
}
|
|
mysql_declare_plugin_end;
|
|
|