mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
41536fcefe
tree to get rid of multiple typos in CS comments and unify the patch. configure.in: CSV is compiled in by default now include/my_base.h: add new ha_extra flag for the log tables mysql-test/include/im_check_os.inc: we should only run im tests if csv is on for now: im relies on mysqld options available only in csv build. mysql-test/include/system_db_struct.inc: check log tables structure mysql-test/lib/init_db.sql: create log tables when running tests. mysql-test/mysql-test-run.pl: Add old logs flag to IM tests. As IM could only deal with old logs (this feature is not needed with log tables) mysql-test/r/connect.result: update result mysql-test/r/csv.result: update result mysql-test/r/im_utils.result: update result mysql-test/r/information_schema.result: update result mysql-test/r/mysqlcheck.result: update result mysql-test/r/show_check.result: update result mysql-test/r/system_mysql_db.result: update result mysql-test/t/connect.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/csv.test: add tests for concurrent insert (the functionality is added to CSV in this patch) mysql-test/t/information_schema.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/mysqlcheck.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/show_check.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/system_mysql_db.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/system_mysql_db_fix.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables scripts/mysql_create_system_tables.sh: new system tables: slow_log and general_log scripts/mysql_fix_privilege_tables.sql: add new log tables: use an SP to create them for non-csv build to work fine. sql/ha_myisam.cc: move locking-related checks to the hanlder sql/ha_myisam.h: new function declared sql/handler.h: new virtual function is added: we should check for handler-related locking issues in the handler sql/lock.cc: from now on we check for handler-related locking issues in the handler itself rather then in lock.cc sql/log.cc: Add log tables support, refactoring: there are log event handlers with common interface. They are used by the LOGGER class, which is responsible for their initialization, cleanup and managment. Logging to the tables provided by one of the log event handler types. sql/log.h: declare new log classes sql/log_event.cc: convert old logging routines calls to use new API sql/mysql_priv.h: define common log routines and objects sql/mysqld.cc: Add support for the log tables. Their initalization, cleanup and specific options. sql/share/errmsg.txt: add new error messages for the log tables sql/slave.cc: convert old logging routines calls to use new API sql/sql_base.cc: TABLE objects used by the logger should be skipped during refreshes (as log tables are always opened and locked). fix table_is_used to skip them. This is needed for FLUSH LOGS to work sql/sql_db.cc: convert old logging routines calls to use new API sql/sql_delete.cc: fix TRUNCATE to work with log tables sql/sql_parse.cc: command_name is now an array of LEX_STRINGs sql/sql_prepare.cc: convert old logging routines calls to use new API sql/sql_show.cc: convert old logging routines calls to use new API sql/sql_table.cc: don't reoped the log tables for admin purposes sql/table.cc: mark log tables as such during the open sql/table.h: add log-related info storage/csv/ha_tina.cc: add support for concurrent insert (see bk commit - 5.1 tree (petr:1.1910) for standalone patch), add log tables-specific csv table handling. storage/csv/ha_tina.h: enable concurrent insert for CSV, add log table flag mysql-test/r/log_tables.result: New BitKeeper file ``mysql-test/r/log_tables.result'' mysql-test/t/log_tables.test: New BitKeeper file ``mysql-test/t/log_tables.test''
150 lines
4.9 KiB
C++
150 lines
4.9 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; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
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 */
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <my_dir.h>
|
|
|
|
#define DEFAULT_CHAIN_LENGTH 512
|
|
|
|
typedef struct st_tina_share {
|
|
char *table_name;
|
|
byte *mapped_file; /* mapped region of file */
|
|
uint table_name_length, use_count;
|
|
/*
|
|
Below flag is needed to make log tables work with concurrent insert.
|
|
For more details see comment to ha_tina::update_status.
|
|
*/
|
|
my_bool is_log_table;
|
|
MY_STAT file_stat; /* Stat information for the data file */
|
|
File data_file; /* Current open data file */
|
|
/*
|
|
Here we save the length of the file for readers. This is updated by
|
|
inserts, updates and deletes. The var is initialized along with the
|
|
share initialization.
|
|
*/
|
|
off_t saved_data_file_length;
|
|
pthread_mutex_t mutex;
|
|
THR_LOCK lock;
|
|
} TINA_SHARE;
|
|
|
|
typedef struct tina_set {
|
|
off_t begin;
|
|
off_t end;
|
|
};
|
|
|
|
class ha_tina: public handler
|
|
{
|
|
THR_LOCK_DATA lock; /* MySQL lock */
|
|
TINA_SHARE *share; /* Shared lock info */
|
|
off_t current_position; /* Current position in the file during a file scan */
|
|
off_t next_position; /* Next position in the file scan */
|
|
off_t local_saved_data_file_length; /* save position for reads */
|
|
byte byte_buffer[IO_SIZE];
|
|
String buffer;
|
|
/*
|
|
The chain contains "holes" in the file, occured because of
|
|
deletes/updates. It is used in rnd_end() to get rid of them
|
|
in the end of the query.
|
|
*/
|
|
tina_set chain_buffer[DEFAULT_CHAIN_LENGTH];
|
|
tina_set *chain;
|
|
tina_set *chain_ptr;
|
|
byte chain_alloced;
|
|
uint32 chain_size;
|
|
bool records_is_known;
|
|
|
|
public:
|
|
ha_tina(TABLE_SHARE *table_arg);
|
|
~ha_tina()
|
|
{
|
|
if (chain_alloced)
|
|
my_free((gptr)chain,0);
|
|
}
|
|
const char *table_type() const { return "CSV"; }
|
|
const char *index_type(uint inx) { return "NONE"; }
|
|
const char **bas_ext() const;
|
|
ulong table_flags() const
|
|
{
|
|
return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT |
|
|
HA_NO_AUTO_INCREMENT );
|
|
}
|
|
ulong index_flags(uint idx, uint part, bool all_parts) const
|
|
{
|
|
/* We will never have indexes so this will never be called(AKA we return zero) */
|
|
return 0;
|
|
}
|
|
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
|
|
uint max_keys() const { return 0; }
|
|
uint max_key_parts() const { return 0; }
|
|
uint max_key_length() const { return 0; }
|
|
/*
|
|
Called in test_quick_select to determine if indexes should be used.
|
|
*/
|
|
virtual double scan_time() { return (double) (records+deleted) / 20.0+10; }
|
|
/* The next method will never be called */
|
|
virtual bool fast_key_read() { return 1;}
|
|
/*
|
|
TODO: return actual upper bound of number of records in the table.
|
|
(e.g. save number of records seen on full table scan and/or use file size
|
|
as upper bound)
|
|
*/
|
|
ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; }
|
|
|
|
virtual bool check_if_locking_is_allowed(THD *thd, TABLE *table, uint count);
|
|
int open(const char *name, int mode, uint test_if_locked);
|
|
int close(void);
|
|
int write_row(byte * buf);
|
|
int update_row(const byte * old_data, byte * new_data);
|
|
int delete_row(const byte * buf);
|
|
int index_read(byte * buf, const byte * key,
|
|
uint key_len, enum ha_rkey_function find_flag);
|
|
int index_read_idx(byte * buf, uint idx, const byte * key,
|
|
uint key_len, enum ha_rkey_function find_flag);
|
|
int index_next(byte * buf);
|
|
int index_prev(byte * buf);
|
|
int index_first(byte * buf);
|
|
int index_last(byte * buf);
|
|
int rnd_init(bool scan=1);
|
|
int rnd_next(byte *buf);
|
|
int rnd_pos(byte * buf, byte *pos);
|
|
int rnd_end();
|
|
void position(const byte *record);
|
|
void info(uint);
|
|
int extra(enum ha_extra_function operation);
|
|
int reset(void);
|
|
int external_lock(THD *thd, int lock_type);
|
|
int delete_all_rows(void);
|
|
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
|
|
|
|
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
|
|
enum thr_lock_type lock_type);
|
|
|
|
/*
|
|
These functions used to get/update status of the handler.
|
|
Needed to enable concurrent inserts.
|
|
*/
|
|
void get_status();
|
|
void update_status();
|
|
|
|
/* The following methods were added just for TINA */
|
|
int encode_quote(byte *buf);
|
|
int find_current_row(byte *buf);
|
|
int chain_append();
|
|
};
|
|
|
|
int tina_end(ha_panic_function type);
|
|
|