2006-12-31 02:29:11 +01:00
|
|
|
/* Copyright (C) 2006 MySQL AB
|
2006-05-03 15:00:38 +02:00
|
|
|
|
|
|
|
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
|
2006-12-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-05-03 15:00:38 +02:00
|
|
|
|
|
|
|
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
|
2006-12-31 02:29:11 +01:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
2006-05-03 15:00:38 +02:00
|
|
|
|
|
|
|
#ifndef RPL_UTILITY_H
|
|
|
|
#define RPL_UTILITY_H
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
#error "Don't include this C++ header file from a non-C++ file!"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mysql_priv.h"
|
|
|
|
|
2007-02-26 17:44:55 +01:00
|
|
|
struct st_relay_log_info;
|
|
|
|
typedef st_relay_log_info RELAY_LOG_INFO;
|
|
|
|
|
2006-05-03 15:00:38 +02:00
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
/**
|
2006-05-03 15:00:38 +02:00
|
|
|
A table definition from the master.
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
The responsibilities of this class is:
|
2006-09-13 19:25:12 +02:00
|
|
|
- Extract and decode table definition data from the table map event
|
2006-05-03 15:00:38 +02:00
|
|
|
- Check if table definition in table map is compatible with table
|
|
|
|
definition on slave
|
2006-09-13 19:25:12 +02:00
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
Currently, the only field type data available is an array of the
|
|
|
|
type operators that are present in the table map event.
|
2006-09-13 19:25:12 +02:00
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
@todo Add type operands to this structure to allow detection of
|
|
|
|
difference between, e.g., BIT(5) and BIT(10).
|
2006-05-03 15:00:38 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
class table_def
|
|
|
|
{
|
|
|
|
public:
|
2007-01-26 19:29:57 +01:00
|
|
|
/**
|
2006-09-13 19:25:12 +02:00
|
|
|
Convenience declaration of the type of the field type data in a
|
|
|
|
table map event.
|
|
|
|
*/
|
2006-05-03 15:00:38 +02:00
|
|
|
typedef unsigned char field_type;
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
/**
|
2006-09-13 19:25:12 +02:00
|
|
|
Constructor.
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
@param types Array of types
|
|
|
|
@param size Number of elements in array 'types'
|
2007-07-30 00:10:42 +02:00
|
|
|
@param field_metadata Array of extra information about fields
|
|
|
|
@param metadata_size Size of the field_metadata array
|
|
|
|
@param null_bitmap The bitmap of fields that can be null
|
2006-09-13 19:25:12 +02:00
|
|
|
*/
|
2007-07-30 00:10:42 +02:00
|
|
|
table_def(field_type *types, ulong size, uchar *field_metadata,
|
|
|
|
int metadata_size, uchar *null_bitmap)
|
|
|
|
: m_size(size), m_type(0),
|
|
|
|
m_field_metadata(0), m_null_bits(0), m_memory(NULL)
|
2006-05-03 15:00:38 +02:00
|
|
|
{
|
2007-07-30 00:10:42 +02:00
|
|
|
m_memory= (uchar *)my_multi_malloc(MYF(MY_WME),
|
2007-08-03 17:12:00 +02:00
|
|
|
&m_type, size,
|
|
|
|
&m_field_metadata,
|
|
|
|
size * sizeof(uint16),
|
|
|
|
&m_null_bits, (size + 7) / 8,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
bzero(m_field_metadata, size * sizeof(uint16));
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
if (m_type)
|
|
|
|
memcpy(m_type, types, size);
|
|
|
|
else
|
|
|
|
m_size= 0;
|
2007-07-30 00:10:42 +02:00
|
|
|
/*
|
|
|
|
Extract the data from the table map into the field metadata array
|
|
|
|
iff there is field metadata. The variable metadata_size will be
|
|
|
|
0 if we are replicating from an older version server since no field
|
|
|
|
metadata was written to the table map. This can also happen if
|
|
|
|
there were no fields in the master that needed extra metadata.
|
|
|
|
*/
|
|
|
|
if (m_size && metadata_size)
|
|
|
|
{
|
|
|
|
int index= 0;
|
|
|
|
for (unsigned int i= 0; i < m_size; i++)
|
|
|
|
{
|
|
|
|
switch (m_type[i]) {
|
|
|
|
case MYSQL_TYPE_TINY_BLOB:
|
|
|
|
case MYSQL_TYPE_BLOB:
|
|
|
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
|
|
|
case MYSQL_TYPE_LONG_BLOB:
|
|
|
|
case MYSQL_TYPE_DOUBLE:
|
|
|
|
case MYSQL_TYPE_FLOAT:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
These types store a single byte.
|
|
|
|
*/
|
|
|
|
m_field_metadata[i]= (uchar)field_metadata[index];
|
|
|
|
index++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MYSQL_TYPE_SET:
|
|
|
|
case MYSQL_TYPE_ENUM:
|
|
|
|
case MYSQL_TYPE_STRING:
|
|
|
|
{
|
|
|
|
short int x= field_metadata[index++] << 8U; // real_type
|
|
|
|
x = x + field_metadata[index++]; // pack or field length
|
|
|
|
m_field_metadata[i]= x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MYSQL_TYPE_BIT:
|
|
|
|
{
|
|
|
|
short int x= field_metadata[index++];
|
|
|
|
x = x + (field_metadata[index++] << 8U);
|
|
|
|
m_field_metadata[i]= x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MYSQL_TYPE_VARCHAR:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
These types store two bytes.
|
|
|
|
*/
|
|
|
|
char *ptr= (char *)&field_metadata[index];
|
|
|
|
m_field_metadata[i]= sint2korr(ptr);
|
2007-07-30 23:39:54 +02:00
|
|
|
index= index + 2;
|
2007-07-30 00:10:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MYSQL_TYPE_NEWDECIMAL:
|
|
|
|
{
|
|
|
|
short int x= field_metadata[index++] << 8U; // precision
|
|
|
|
x = x + field_metadata[index++]; // decimals
|
|
|
|
m_field_metadata[i]= x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
m_field_metadata[i]= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_size && null_bitmap)
|
|
|
|
memcpy(m_null_bits, null_bitmap, (m_size + 7) / 8);
|
2006-05-03 15:00:38 +02:00
|
|
|
}
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
~table_def() {
|
2007-07-30 00:10:42 +02:00
|
|
|
my_free(m_memory, MYF(0));
|
2007-01-26 19:29:57 +01:00
|
|
|
#ifndef DBUG_OFF
|
|
|
|
m_type= 0;
|
|
|
|
m_size= 0;
|
|
|
|
#endif
|
|
|
|
}
|
2006-09-13 19:25:12 +02:00
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
/**
|
|
|
|
Return the number of fields there is type data for.
|
2006-09-13 19:25:12 +02:00
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
@return The number of fields that there is type data for.
|
2006-09-13 19:25:12 +02:00
|
|
|
*/
|
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
2007-05-10 11:59:39 +02:00
|
|
|
ulong size() const { return m_size; }
|
2006-09-13 19:25:12 +02:00
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
|
2006-09-13 19:25:12 +02:00
|
|
|
/*
|
|
|
|
Return a representation of the type data for one field.
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
@param index Field index to return data for
|
2006-09-13 19:25:12 +02:00
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
@return Will return a representation of the type data for field
|
|
|
|
<code>index</code>. Currently, only the type identifier is
|
|
|
|
returned.
|
2006-09-13 19:25:12 +02:00
|
|
|
*/
|
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
2007-05-10 11:59:39 +02:00
|
|
|
field_type type(ulong index) const
|
2007-01-26 19:29:57 +01:00
|
|
|
{
|
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
2007-05-10 11:59:39 +02:00
|
|
|
DBUG_ASSERT(index < m_size);
|
2007-01-26 19:29:57 +01:00
|
|
|
return m_type[index];
|
|
|
|
}
|
2006-05-03 15:00:38 +02:00
|
|
|
|
2007-07-30 00:10:42 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
This function allows callers to get the extra field data from the
|
|
|
|
table map for a given field. If there is no metadata for that field
|
|
|
|
or there is no extra metadata at all, the function returns 0.
|
|
|
|
|
|
|
|
The function returns the value for the field metadata for column at
|
|
|
|
position indicated by index. As mentioned, if the field was a type
|
|
|
|
that stores field metadata, that value is returned else zero (0) is
|
|
|
|
returned. This method is used in the unpack() methods of the
|
|
|
|
corresponding fields to properly extract the data from the binary log
|
|
|
|
in the event that the master's field is smaller than the slave.
|
|
|
|
*/
|
|
|
|
uint16 field_metadata(uint index) const
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(index < m_size);
|
|
|
|
if (m_field_metadata)
|
|
|
|
return m_field_metadata[index];
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function returns whether the field on the master can be null.
|
|
|
|
This value is derived from field->maybe_null().
|
|
|
|
*/
|
|
|
|
my_bool maybe_null(uint index) const
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(index < m_size);
|
|
|
|
return ((m_null_bits[(index / 8)] &
|
|
|
|
(1 << (index % 8))) == (1 << (index %8)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function returns the field size in raw bytes based on the type
|
|
|
|
and the encoded field data from the master's raw data. This method can
|
|
|
|
be used for situations where the slave needs to skip a column (e.g.,
|
|
|
|
WL#3915) or needs to advance the pointer for the fields in the raw
|
|
|
|
data from the master to a specific column.
|
|
|
|
*/
|
|
|
|
uint32 calc_field_size(uint col, uchar *master_data);
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
/**
|
2006-09-13 19:25:12 +02:00
|
|
|
Decide if the table definition is compatible with a table.
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
Compare the definition with a table to see if it is compatible
|
|
|
|
with it.
|
2006-09-13 19:25:12 +02:00
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
A table definition is compatible with a table if:
|
2006-09-13 19:25:12 +02:00
|
|
|
- the columns types of the table definition is a (not
|
|
|
|
necessarily proper) prefix of the column type of the table, or
|
|
|
|
- the other way around
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
@param rli Pointer to relay log info
|
|
|
|
@param table Pointer to table to compare with.
|
|
|
|
|
|
|
|
@retval 1 if the table definition is not compatible with @c table
|
|
|
|
@retval 0 if the table definition is compatible with @c table
|
2006-09-13 19:25:12 +02:00
|
|
|
*/
|
2006-11-10 15:10:41 +01:00
|
|
|
int compatible_with(RELAY_LOG_INFO const *rli, TABLE *table) const;
|
2006-05-03 15:00:38 +02:00
|
|
|
|
|
|
|
private:
|
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
2007-05-10 11:59:39 +02:00
|
|
|
ulong m_size; // Number of elements in the types array
|
2006-09-13 19:25:12 +02:00
|
|
|
field_type *m_type; // Array of type descriptors
|
2007-07-30 23:39:54 +02:00
|
|
|
uint16 *m_field_metadata;
|
2007-07-30 00:10:42 +02:00
|
|
|
uchar *m_null_bits;
|
|
|
|
uchar *m_memory;
|
2006-05-03 15:00:38 +02:00
|
|
|
};
|
|
|
|
|
2007-01-26 19:29:57 +01:00
|
|
|
/**
|
|
|
|
Extend the normal table list with a few new fields needed by the
|
|
|
|
slave thread, but nowhere else.
|
|
|
|
*/
|
|
|
|
struct RPL_TABLE_LIST
|
2007-07-16 22:59:21 +02:00
|
|
|
: public TABLE_LIST
|
2007-01-26 19:29:57 +01:00
|
|
|
{
|
2007-02-26 17:44:55 +01:00
|
|
|
bool m_tabledef_valid;
|
2007-01-26 19:29:57 +01:00
|
|
|
table_def m_tabledef;
|
|
|
|
};
|
|
|
|
|
2006-05-03 15:00:38 +02:00
|
|
|
#endif /* RPL_UTILITY_H */
|