summaryrefslogtreecommitdiff
path: root/sql/sql_cache.h
diff options
context:
space:
mode:
authormonty@mysql.com/narttu.mysql.fi <>2007-05-10 12:59:39 +0300
committermonty@mysql.com/narttu.mysql.fi <>2007-05-10 12:59:39 +0300
commit088e2395f1833f16c2ea3f7405f604165b4aa2cc (patch)
tree6480cbef09e9dec2fa347b1899963ab3658d692f /sql/sql_cache.h
parent9078e630c64a313301cd13ce71d0854fbcf2fd0b (diff)
downloadmariadb-git-088e2395f1833f16c2ea3f7405f604165b4aa2cc.tar.gz
WL#3817: Simplify string / memory area types and make things more consistent (first part)
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
Diffstat (limited to 'sql/sql_cache.h')
-rw-r--r--sql/sql_cache.h36
1 files changed, 17 insertions, 19 deletions
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index bc00f7ea629..3c5d784ce94 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -98,7 +98,7 @@ struct Query_cache_block
void init(ulong length);
void destroy();
inline uint headers_len();
- inline gptr data(void);
+ inline uchar* data(void);
inline Query_cache_query *query();
inline Query_cache_table *table();
inline Query_cache_result *result();
@@ -128,17 +128,15 @@ struct Query_cache_query
inline ulong length() { return len; }
inline ulong add(ulong packet_len) { return(len+= packet_len); }
inline void length(ulong length_arg) { len= length_arg; }
- inline gptr query()
+ inline uchar* query()
{
- return (gptr)(((byte*)this)+
- ALIGN_SIZE(sizeof(Query_cache_query)));
+ return (((uchar*)this) + ALIGN_SIZE(sizeof(Query_cache_query)));
}
void lock_writing();
void lock_reading();
my_bool try_lock_writing();
void unlock_writing();
void unlock_reading();
- static byte *cache_key(const byte *record, uint *length, my_bool not_used);
};
@@ -164,9 +162,9 @@ struct Query_cache_table
inline void callback(qc_engine_callback fn){ callback_func= fn; }
inline ulonglong engine_data() { return engine_data_buff; }
inline void engine_data(ulonglong data_arg){ engine_data_buff= data_arg; }
- inline gptr data()
+ inline uchar* data()
{
- return (gptr)(((byte*)this)+
+ return (uchar*)(((uchar*)this)+
ALIGN_SIZE(sizeof(Query_cache_table)));
}
};
@@ -176,9 +174,9 @@ struct Query_cache_result
Query_cache_result() {} /* Remove gcc warning */
Query_cache_block *query;
- inline gptr data()
+ inline uchar* data()
{
- return (gptr)(((byte*) this)+
+ return (uchar*)(((uchar*) this)+
ALIGN_SIZE(sizeof(Query_cache_result)));
}
/* data_continue (if not whole packet contained by this block) */
@@ -189,10 +187,10 @@ struct Query_cache_result
extern "C"
{
- byte *query_cache_query_get_key(const byte *record, uint *length,
- my_bool not_used);
- byte *query_cache_table_get_key(const byte *record, uint *length,
- my_bool not_used);
+ uchar *query_cache_query_get_key(const uchar *record, size_t *length,
+ my_bool not_used);
+ uchar *query_cache_table_get_key(const uchar *record, size_t *length,
+ my_bool not_used);
}
extern "C" void query_cache_invalidate_by_MyISAM_filename(const char* filename);
@@ -261,7 +259,7 @@ protected:
till the end of a flush operation.
*/
pthread_mutex_t structure_guard_mutex;
- byte *cache; // cache memory
+ uchar *cache; // cache memory
Query_cache_block *first_block; // physical location block list
Query_cache_block *queries_blocks; // query list (LIFO)
Query_cache_block *tables_blocks;
@@ -299,7 +297,7 @@ protected:
my_bool first_block);
void invalidate_table(TABLE_LIST *table);
void invalidate_table(TABLE *table);
- void invalidate_table(byte *key, uint32 key_length);
+ void invalidate_table(uchar *key, uint32 key_length);
void invalidate_table(Query_cache_block *table_block);
TABLE_COUNTER_TYPE
register_tables_from_list(TABLE_LIST *tables_used,
@@ -324,7 +322,7 @@ protected:
ulong add_size);
void exclude_from_free_memory_list(Query_cache_block *free_block);
void insert_into_free_memory_list(Query_cache_block *new_block);
- my_bool move_by_type(byte **border, Query_cache_block **before,
+ my_bool move_by_type(uchar **border, Query_cache_block **before,
ulong *gap, Query_cache_block *i);
uint find_bin(ulong size);
void move_to_query_list_end(Query_cache_block *block);
@@ -346,16 +344,16 @@ protected:
ulong init_cache();
void make_disabled();
void free_cache();
- Query_cache_block *write_block_data(ulong data_len, gptr data,
+ Query_cache_block *write_block_data(ulong data_len, uchar* data,
ulong header_len,
Query_cache_block::block_type type,
TABLE_COUNTER_TYPE ntab = 0,
my_bool under_guard=0);
my_bool append_result_data(Query_cache_block **result,
- ulong data_len, gptr data,
+ ulong data_len, uchar* data,
Query_cache_block *parent);
my_bool write_result_data(Query_cache_block **result,
- ulong data_len, gptr data,
+ ulong data_len, uchar* data,
Query_cache_block *parent,
Query_cache_block::block_type
type=Query_cache_block::RESULT);