diff options
author | unknown <patg@krsna.patg.net> | 2005-07-15 17:33:47 -0700 |
---|---|---|
committer | unknown <patg@krsna.patg.net> | 2005-07-15 17:33:47 -0700 |
commit | d887a6924e618562c2a2b80d66a142d29ab81cbd (patch) | |
tree | 5b7890ff544d61910557283851233d154fac5f6b /sql/ha_federated.h | |
parent | d49ddbd70548ce348fde81bcecc9ebbe11fa0704 (diff) | |
download | mariadb-git-d887a6924e618562c2a2b80d66a142d29ab81cbd.tar.gz |
This is the same patch as 1.1937, with small variable declaration changes, memory
deallocation cleanup
mysql-test/r/federated.result:
new test results
mysql-test/t/federated.test:
New tests, and added explains per Timour's suggestion. This will keep
track of whether changes have been made to the optimiser that might affect
Federated.
Also changed the error codes to federated error codes in the error tests
sql/ha_federated.cc:
1. Not using MAX_REMOTE_SIZE, so removed
2. Changed all defines that were IO_SIZE to FEDERATED_QUERY_BUFFER_SIZE
3. Now using Federated Error Codes
4. Implemented ::info (gets valid 'records' number)
5. Implemented ::read_range_first - now uses indexes in range operations
6. Better allocation in get_share
7. Cleaned up memory bug in get_share
8. Better initial query "SELECT * FROM t1 WHERE 1=0" for check_foreign_data_src
9. emit_key_part_name and emit_key_part_element for read_range_first to not
have redundancy
10. Made sure all 'append's pass length, and use append("") to ensure proper
null termination of strings being built.
11. Better message creation. If ER_QUERY_ON_FOREIGN_DATA_SRC, I also pass
the actual error code and message from the foreign data src.
12. Cleaned up how the result set and share->scheme is freed.
sql/share/errmsg.txt:
New Federated error messages that are more tailored to the type of information
we want to see when federated has an error.
mysql-test/include/federated.inc:
New bitkeeper file, include file for separating setup from main test suite
mysql-test/include/federated_cleanup.inc:
New BitKeeper file ``mysql-test/include/federated_cleanup.inc''
sql/ha_federated.h:
Added comments where needed, one was already commented about
Diffstat (limited to 'sql/ha_federated.h')
-rw-r--r-- | sql/ha_federated.h | 80 |
1 files changed, 50 insertions, 30 deletions
diff --git a/sql/ha_federated.h b/sql/ha_federated.h index f084976718c..e8bebe81768 100644 --- a/sql/ha_federated.h +++ b/sql/ha_federated.h @@ -26,16 +26,16 @@ #endif #include <mysql.h> -//#include <client.h> + +#define FEDERATED_QUERY_BUFFER_SIZE STRING_BUFFER_USUAL_SIZE * 5 +#define FEDERATED_RECORDS_IN_RANGE 2 /* FEDERATED_SHARE is a structure that will be shared amoung all open handlers The example implements the minimum of what you will probably need. */ typedef struct st_federated_share { - char *table_name; - char *table_base_name; - /* + /* the primary select query to be used in rnd_init */ char *select_query; @@ -47,11 +47,12 @@ typedef struct st_federated_share { char *username; char *password; char *database; + char *table_name; char *table; char *socket; char *sport; - int port; - uint table_name_length,table_base_name_length,use_count; + ushort port; + uint table_name_length,use_count; pthread_mutex_t mutex; THR_LOCK lock; } FEDERATED_SHARE; @@ -63,7 +64,7 @@ class ha_federated: public handler { THR_LOCK_DATA lock; /* MySQL lock */ FEDERATED_SHARE *share; /* Shared lock info */ - MYSQL *mysql; + MYSQL *mysql; /* MySQL connection */ MYSQL_RES *result; bool scan_flag; uint ref_length; @@ -77,11 +78,13 @@ private: */ uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row); bool create_where_from_key(String *to, KEY *key_info, - const byte *key, uint key_length); + const key_range *start_key, + const key_range *end_key, + bool records_in_range); public: ha_federated(TABLE *table): handler(table), - mysql(0), result(0), scan_flag(0), + mysql(0), result(0), scan_flag(0), ref_length(sizeof(MYSQL_ROW_OFFSET)), current_position(0) { } @@ -94,20 +97,20 @@ public: The name of the index type that will be used for display don't implement this method unless you really have indexes */ + // perhaps get index type const char *index_type(uint inx) { return "REMOTE"; } const char **bas_ext() const; /* This is a list of flags that says what the storage engine implements. The current table flags are documented in handler.h - Serg: Double check these (Brian) - // FIX add blob support */ ulong table_flags() const { - return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT | - HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | - HA_AUTO_PART_KEY | HA_CAN_INDEX_BLOBS); + /* fix server to be able to get remote server table flags */ + return (HA_NOT_EXACT_COUNT | + HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | HA_REC_NOT_IN_SEQ | + HA_AUTO_PART_KEY | HA_CAN_INDEX_BLOBS| HA_NO_PREFIX_CHAR_KEYS); } /* This is a bitmap of flags that says how the storage engine @@ -119,29 +122,40 @@ public: If all_parts it's set, MySQL want to know the flags for the combined index up to and including 'part'. */ + /* fix server to be able to get remote server index flags */ ulong index_flags(uint inx, uint part, bool all_parts) const { - return (HA_READ_NEXT); - // return (HA_READ_NEXT | HA_ONLY_WHOLE_INDEX); + return (HA_READ_NEXT | HA_READ_RANGE | HA_READ_AFTER_KEY); } uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; } uint max_supported_keys() const { return MAX_KEY; } - uint max_supported_key_parts() const { return 1024; } - uint max_supported_key_length() const { return 1024; } + uint max_supported_key_parts() const { return MAX_REF_PARTS; } + uint max_supported_key_length() const { return MAX_KEY_LENGTH; } /* Called in test_quick_select to determine if indexes should be used. + Normally, we need to know number of blocks . For federated we need to + know number of blocks on remote side, and number of packets and blocks + on the network side (?) + Talk to Kostja about this - how to get the + number of rows * ... + disk scan time on other side (block size, size of the row) + network time ... + The reason for "records * 1000" is that such a large number forces + this to use indexes " */ - virtual double scan_time() + double scan_time() { - DBUG_PRINT("ha_federated::scan_time", - ("rows %d", records)); return (double)(records*2); + DBUG_PRINT("info", + ("records %d", records)); return (double)(records*1000); } /* The next method will never be called if you do not implement indexes. */ - virtual double read_time(uint index, uint ranges, ha_rows rows) - { return (double) rows / 20.0+1; } + double read_time(uint index, uint ranges, ha_rows rows) + { + return (double) rows / 20.0+1; + } + const key_map *keys_to_use_for_scanning() { return &key_map_full; } /* Everything below are methods that we implment in ha_federated.cc. @@ -151,16 +165,20 @@ public: int open(const char *name, int mode, uint test_if_locked); // required int close(void); // required - int write_row(byte * buf); - int update_row(const byte * old_data, byte * new_data); - int delete_row(const byte * buf); + int write_row(byte *buf); + int update_row(const byte *old_data, byte *new_data); + int delete_row(const byte *buf); int index_init(uint keynr); - int index_read(byte * buf, const byte * key, + 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, + 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_next(byte *buf); int index_end(); + int read_range_first(const key_range *start_key, + const key_range *end_key, + bool eq_range, bool sorted); + int read_range_next(); /* unlike index_init(), rnd_init() can be called two times without rnd_end() in between (it only makes sense if scan=1). @@ -172,13 +190,15 @@ public: int rnd_init(bool scan); //required int rnd_end(); int rnd_next(byte *buf); //required - int rnd_pos(byte * buf, byte *pos); //required + int rnd_pos(byte *buf, byte *pos); //required void position(const byte *record); //required void info(uint); //required int delete_all_rows(void); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); //required + ha_rows records_in_range(uint inx, key_range *start_key, + key_range *end_key); THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); //required |