2010-01-07 06:42:07 +01:00
|
|
|
/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
2004-05-11 22:23:49 +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-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2004-05-11 22:23:49 +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
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
@file
|
|
|
|
|
|
|
|
@brief
|
|
|
|
Text .frm files management routines
|
|
|
|
*/
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_priv.h"
|
|
|
|
#include "parse_file.h"
|
|
|
|
#include "unireg.h" // CREATE_MODE
|
|
|
|
#include "sql_table.h" // build_table_filename
|
2004-05-11 22:23:49 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <m_ctype.h>
|
|
|
|
#include <my_sys.h>
|
|
|
|
#include <my_dir.h>
|
|
|
|
|
2008-09-30 14:50:28 +02:00
|
|
|
/* from sql_db.cc */
|
|
|
|
extern long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path);
|
|
|
|
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Write string with escaping.
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param file IO_CACHE for record
|
|
|
|
@param val_s string for writing
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
FALSE OK
|
|
|
|
@retval
|
|
|
|
TRUE error
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
static my_bool
|
|
|
|
write_escaped_string(IO_CACHE *file, LEX_STRING *val_s)
|
|
|
|
{
|
|
|
|
char *eos= val_s->str + val_s->length;
|
|
|
|
char *ptr= val_s->str;
|
|
|
|
|
|
|
|
for (; ptr < eos; ptr++)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Should be in sync with read_escaped_string() and
|
2004-09-07 14:29:46 +02:00
|
|
|
parse_quoted_escaped_string()
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
switch(*ptr) {
|
|
|
|
case '\\': // escape character
|
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
|
|
|
if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\\\")))
|
2004-05-11 22:23:49 +02:00
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case '\n': // parameter value delimiter
|
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
|
|
|
if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\n")))
|
2004-05-11 22:23:49 +02:00
|
|
|
return TRUE;
|
|
|
|
break;
|
2004-10-07 00:45:06 +02:00
|
|
|
case '\0': // problem for some string processing utilities
|
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
|
|
|
if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\0")))
|
2004-05-11 22:23:49 +02:00
|
|
|
return TRUE;
|
|
|
|
break;
|
2004-10-07 00:45:06 +02:00
|
|
|
case 26: // problem for windows utilities (Ctrl-Z)
|
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
|
|
|
if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\z")))
|
2004-05-11 22:23:49 +02:00
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case '\'': // list of string delimiter
|
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
|
|
|
if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\\'")))
|
2004-05-11 22:23:49 +02:00
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
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
|
|
|
if (my_b_append(file, (const uchar *)ptr, 1))
|
2004-05-11 22:23:49 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Write parameter value to IO_CACHE.
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param file pointer to IO_CACHE structure for writing
|
|
|
|
@param base pointer to data structure
|
|
|
|
@param parameter pointer to parameter descriptor
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
FALSE OK
|
|
|
|
@retval
|
|
|
|
TRUE error
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
|
2004-05-11 22:23:49 +02:00
|
|
|
static my_bool
|
2008-11-14 18:37:27 +01:00
|
|
|
write_parameter(IO_CACHE *file, uchar* base, File_option *parameter)
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
char num_buf[20]; // buffer for numeric operations
|
|
|
|
// string for numeric operations
|
|
|
|
String num(num_buf, sizeof(num_buf), &my_charset_bin);
|
|
|
|
DBUG_ENTER("write_parameter");
|
|
|
|
|
|
|
|
switch (parameter->type) {
|
|
|
|
case FILE_OPTIONS_STRING:
|
|
|
|
{
|
|
|
|
LEX_STRING *val_s= (LEX_STRING *)(base + parameter->offset);
|
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
|
|
|
if (my_b_append(file, (const uchar *)val_s->str, val_s->length))
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FILE_OPTIONS_ESTRING:
|
|
|
|
{
|
|
|
|
if (write_escaped_string(file, (LEX_STRING *)(base + parameter->offset)))
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FILE_OPTIONS_ULONGLONG:
|
|
|
|
{
|
|
|
|
num.set(*((ulonglong *)(base + parameter->offset)), &my_charset_bin);
|
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
|
|
|
if (my_b_append(file, (const uchar *)num.ptr(), num.length()))
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FILE_OPTIONS_TIMESTAMP:
|
|
|
|
{
|
|
|
|
/* string have to be allocated already */
|
|
|
|
LEX_STRING *val_s= (LEX_STRING *)(base + parameter->offset);
|
2007-07-30 10:33:50 +02:00
|
|
|
time_t tm= my_time(0);
|
2004-05-11 22:23:49 +02:00
|
|
|
|
|
|
|
get_date(val_s->str, GETDATE_DATE_TIME|GETDATE_GMT|GETDATE_FIXEDLENGTH,
|
|
|
|
tm);
|
|
|
|
val_s->length= PARSE_FILE_TIMESTAMPLENGTH;
|
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
|
|
|
if (my_b_append(file, (const uchar *)val_s->str,
|
2004-07-16 21:48:56 +02:00
|
|
|
PARSE_FILE_TIMESTAMPLENGTH))
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FILE_OPTIONS_STRLIST:
|
|
|
|
{
|
|
|
|
List_iterator_fast<LEX_STRING> it(*((List<LEX_STRING>*)
|
|
|
|
(base + parameter->offset)));
|
|
|
|
bool first= 1;
|
|
|
|
LEX_STRING *str;
|
|
|
|
while ((str= it++))
|
|
|
|
{
|
2004-09-07 14:29:46 +02:00
|
|
|
// We need ' ' after string to detect list continuation
|
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
|
|
|
if ((!first && my_b_append(file, (const uchar *)STRING_WITH_LEN(" "))) ||
|
|
|
|
my_b_append(file, (const uchar *)STRING_WITH_LEN("\'")) ||
|
2004-09-07 14:29:46 +02:00
|
|
|
write_escaped_string(file, str) ||
|
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
|
|
|
my_b_append(file, (const uchar *)STRING_WITH_LEN("\'")))
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
first= 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-07-28 21:39:11 +02:00
|
|
|
case FILE_OPTIONS_ULLLIST:
|
|
|
|
{
|
|
|
|
List_iterator_fast<ulonglong> it(*((List<ulonglong>*)
|
|
|
|
(base + parameter->offset)));
|
|
|
|
bool first= 1;
|
|
|
|
ulonglong *val;
|
|
|
|
while ((val= it++))
|
|
|
|
{
|
|
|
|
num.set(*val, &my_charset_bin);
|
|
|
|
// We need ' ' after string to detect list continuation
|
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
|
|
|
if ((!first && my_b_append(file, (const uchar *)STRING_WITH_LEN(" "))) ||
|
|
|
|
my_b_append(file, (const uchar *)num.ptr(), num.length()))
|
2005-07-28 21:39:11 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
first= 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2004-05-11 22:23:49 +02:00
|
|
|
default:
|
|
|
|
DBUG_ASSERT(0); // never should happened
|
|
|
|
}
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Write new .frm.
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param dir directory where put .frm
|
|
|
|
@param file_name .frm file name
|
|
|
|
@param type .frm type string (VIEW, TABLE)
|
|
|
|
@param base base address for parameter reading (structure like
|
|
|
|
TABLE)
|
|
|
|
@param parameters parameters description
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
FALSE OK
|
|
|
|
@retval
|
|
|
|
TRUE error
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
|
2004-05-11 22:23:49 +02:00
|
|
|
my_bool
|
|
|
|
sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
|
|
|
|
const LEX_STRING *type,
|
2008-11-14 18:37:27 +01:00
|
|
|
uchar* base, File_option *parameters)
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
File handler;
|
|
|
|
IO_CACHE file;
|
|
|
|
char path[FN_REFLEN+1]; // +1 to put temporary file name for sure
|
|
|
|
int path_end;
|
2004-07-16 21:48:56 +02:00
|
|
|
File_option *param;
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_ENTER("sql_create_definition_file");
|
|
|
|
DBUG_PRINT("enter", ("Dir: %s, file: %s, base 0x%lx",
|
2006-01-24 15:37:56 +01:00
|
|
|
dir ? dir->str : "(null)",
|
|
|
|
file_name->str, (ulong) base));
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2005-12-31 06:01:26 +01:00
|
|
|
if (dir)
|
|
|
|
{
|
2007-02-23 12:13:55 +01:00
|
|
|
fn_format(path, file_name->str, dir->str, "", MY_UNPACK_FILENAME);
|
2005-12-31 06:01:26 +01:00
|
|
|
path_end= strlen(path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
if not dir is passed, it means file_name is a full path,
|
|
|
|
including dir name, file name itself, and an extension,
|
|
|
|
and with unpack_filename() executed over it.
|
|
|
|
*/
|
2009-06-19 10:24:43 +02:00
|
|
|
path_end= strxnmov(path, sizeof(path) - 1, file_name->str, NullS) - path;
|
2005-12-31 06:01:26 +01:00
|
|
|
}
|
2004-05-11 22:23:49 +02:00
|
|
|
|
|
|
|
// temporary file name
|
|
|
|
path[path_end]='~';
|
|
|
|
path[path_end+1]= '\0';
|
2010-01-07 06:42:07 +01:00
|
|
|
if ((handler= mysql_file_create(key_file_fileparser,
|
|
|
|
path, CREATE_MODE, O_RDWR | O_TRUNC,
|
|
|
|
MYF(MY_WME))) <= 0)
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (init_io_cache(&file, handler, 0, SEQ_READ_APPEND, 0L, 0, MYF(MY_WME)))
|
|
|
|
goto err_w_file;
|
|
|
|
|
|
|
|
// write header (file signature)
|
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
|
|
|
if (my_b_append(&file, (const uchar *)STRING_WITH_LEN("TYPE=")) ||
|
|
|
|
my_b_append(&file, (const uchar *)type->str, type->length) ||
|
|
|
|
my_b_append(&file, (const uchar *)STRING_WITH_LEN("\n")))
|
2004-05-11 22:23:49 +02:00
|
|
|
goto err_w_file;
|
|
|
|
|
|
|
|
// write parameters to temporary file
|
2004-07-16 21:48:56 +02:00
|
|
|
for (param= parameters; param->name.str; param++)
|
2004-05-11 22:23:49 +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
|
|
|
if (my_b_append(&file, (const uchar *)param->name.str,
|
2004-07-16 21:48:56 +02:00
|
|
|
param->name.length) ||
|
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
|
|
|
my_b_append(&file, (const uchar *)STRING_WITH_LEN("=")) ||
|
2008-11-14 18:25:57 +01:00
|
|
|
write_parameter(&file, base, param) ||
|
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
|
|
|
my_b_append(&file, (const uchar *)STRING_WITH_LEN("\n")))
|
2004-05-11 22:23:49 +02:00
|
|
|
goto err_w_cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end_io_cache(&file))
|
|
|
|
goto err_w_file;
|
|
|
|
|
2009-01-14 17:11:31 +01:00
|
|
|
if (opt_sync_frm) {
|
2010-01-07 06:42:07 +01:00
|
|
|
if (mysql_file_sync(handler, MYF(MY_WME)))
|
2009-01-14 17:11:31 +01:00
|
|
|
goto err_w_file;
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if (mysql_file_close(handler, MYF(MY_WME)))
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
path[path_end]='\0';
|
|
|
|
|
|
|
|
{
|
|
|
|
// rename temporary file
|
|
|
|
char path_to[FN_REFLEN];
|
|
|
|
memcpy(path_to, path, path_end+1);
|
|
|
|
path[path_end]='~';
|
2010-01-07 06:42:07 +01:00
|
|
|
if (mysql_file_rename(key_file_fileparser, path, path_to, MYF(MY_WME)))
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
err_w_cache:
|
|
|
|
end_io_cache(&file);
|
|
|
|
err_w_file:
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_file_close(handler, MYF(MY_WME));
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Renames a frm file (including backups) in same schema.
|
2005-09-18 21:43:28 +02:00
|
|
|
|
2008-09-30 15:16:11 +02:00
|
|
|
@thd thread handler
|
2007-10-11 20:37:45 +02:00
|
|
|
@param schema name of given schema
|
|
|
|
@param old_name original file name
|
2009-04-13 15:09:10 +02:00
|
|
|
@param new_db new schema
|
2007-10-11 20:37:45 +02:00
|
|
|
@param new_name new file name
|
2005-09-18 21:43:28 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
0 OK
|
|
|
|
@retval
|
|
|
|
1 Error (only if renaming of frm failed)
|
2005-09-18 21:43:28 +02:00
|
|
|
*/
|
2008-09-30 14:50:28 +02:00
|
|
|
my_bool rename_in_schema_file(THD *thd,
|
|
|
|
const char *schema, const char *old_name,
|
2009-04-13 15:09:10 +02:00
|
|
|
const char *new_db, const char *new_name)
|
2005-09-18 21:43:28 +02:00
|
|
|
{
|
2009-06-19 10:24:43 +02:00
|
|
|
char old_path[FN_REFLEN + 1], new_path[FN_REFLEN + 1], arc_path[FN_REFLEN + 1];
|
2005-09-18 21:43:28 +02:00
|
|
|
|
2006-10-16 19:42:03 +02:00
|
|
|
build_table_filename(old_path, sizeof(old_path) - 1,
|
|
|
|
schema, old_name, reg_ext, 0);
|
|
|
|
build_table_filename(new_path, sizeof(new_path) - 1,
|
2009-04-13 15:09:10 +02:00
|
|
|
new_db, new_name, reg_ext, 0);
|
2005-09-18 21:43:28 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if (mysql_file_rename(key_file_frm, old_path, new_path, MYF(MY_WME)))
|
2005-09-18 21:43:28 +02:00
|
|
|
return 1;
|
|
|
|
|
2008-09-30 14:50:28 +02:00
|
|
|
/* check if arc_dir exists: disabled unused feature (see bug #17823). */
|
2006-10-16 19:42:03 +02:00
|
|
|
build_table_filename(arc_path, sizeof(arc_path) - 1, schema, "arc", "", 0);
|
2005-09-18 21:43:28 +02:00
|
|
|
|
2008-09-30 14:50:28 +02:00
|
|
|
{ // remove obsolete 'arc' directory and files if any
|
|
|
|
MY_DIR *new_dirp;
|
|
|
|
if ((new_dirp = my_dir(arc_path, MYF(MY_DONT_SORT))))
|
|
|
|
{
|
|
|
|
DBUG_PRINT("my",("Archive subdir found: %s", arc_path));
|
|
|
|
(void) mysql_rm_arc_files(thd, new_dirp, arc_path);
|
|
|
|
}
|
|
|
|
}
|
2005-09-18 21:43:28 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Prepare frm to parse (read to memory).
|
|
|
|
|
|
|
|
@param file_name path & filename to .frm file
|
|
|
|
@param mem_root MEM_ROOT for buffer allocation
|
|
|
|
@param bad_format_errors send errors on bad content
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@note
|
|
|
|
returned pointer + 1 will be type of .frm
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@return
|
2004-05-11 22:23:49 +02:00
|
|
|
0 - error
|
2007-10-11 20:37:45 +02:00
|
|
|
@return
|
2004-05-11 22:23:49 +02:00
|
|
|
parser object
|
|
|
|
*/
|
|
|
|
|
|
|
|
File_parser *
|
|
|
|
sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
|
|
|
|
bool bad_format_errors)
|
|
|
|
{
|
|
|
|
MY_STAT stat_info;
|
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
|
|
|
size_t len;
|
2004-05-11 22:23:49 +02:00
|
|
|
char *end, *sign;
|
|
|
|
File_parser *parser;
|
|
|
|
File file;
|
2005-11-23 21:45:02 +01:00
|
|
|
DBUG_ENTER("sql_parse_prepare");
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if (!mysql_file_stat(key_file_fileparser,
|
|
|
|
file_name->str, &stat_info, MYF(MY_WME)))
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stat_info.st_size > INT_MAX-1)
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_FPARSER_TOO_BIG_FILE, MYF(0), file_name->str);
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(parser= new(mem_root) File_parser))
|
|
|
|
{
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (!(parser->buff= (char*) alloc_root(mem_root, stat_info.st_size+1)))
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if ((file= mysql_file_open(key_file_fileparser, file_name->str,
|
|
|
|
O_RDONLY | O_SHARE, MYF(MY_WME))) < 0)
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if ((len= mysql_file_read(file, (uchar *)parser->buff,
|
|
|
|
stat_info.st_size, MYF(MY_WME))) ==
|
2004-05-11 22:23:49 +02:00
|
|
|
MY_FILE_ERROR)
|
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_file_close(file, MYF(MY_WME));
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
if (mysql_file_close(file, MYF(MY_WME)))
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
end= parser->end= parser->buff + len;
|
2004-10-07 00:45:06 +02:00
|
|
|
*end= '\0'; // barrier for more simple parsing
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2004-10-07 00:45:06 +02:00
|
|
|
// 7 = 5 (TYPE=) + 1 (letter at least of type name) + 1 ('\n')
|
2004-05-11 22:23:49 +02:00
|
|
|
if (len < 7 ||
|
|
|
|
parser->buff[0] != 'T' ||
|
|
|
|
parser->buff[1] != 'Y' ||
|
|
|
|
parser->buff[2] != 'P' ||
|
|
|
|
parser->buff[3] != 'E' ||
|
|
|
|
parser->buff[4] != '=')
|
|
|
|
goto frm_error;
|
|
|
|
|
|
|
|
// skip signature;
|
|
|
|
parser->file_type.str= sign= parser->buff + 5;
|
|
|
|
while (*sign >= 'A' && *sign <= 'Z' && sign < end)
|
|
|
|
sign++;
|
|
|
|
if (*sign != '\n')
|
|
|
|
goto frm_error;
|
|
|
|
parser->file_type.length= sign - parser->file_type.str;
|
|
|
|
// EOS for file signature just for safety
|
|
|
|
*sign= '\0';
|
|
|
|
|
|
|
|
parser->start= sign + 1;
|
|
|
|
parser->content_ok= 1;
|
|
|
|
|
|
|
|
DBUG_RETURN(parser);
|
|
|
|
|
|
|
|
frm_error:
|
|
|
|
if (bad_format_errors)
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_FPARSER_BAD_HEADER, MYF(0), file_name->str);
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DBUG_RETURN(parser); // upper level have to check parser->ok()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
parse LEX_STRING.
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param ptr pointer on string beginning
|
|
|
|
@param end pointer on symbol after parsed string end (still owned
|
|
|
|
by buffer and can be accessed
|
|
|
|
@param mem_root MEM_ROOT for parameter allocation
|
|
|
|
@param str pointer on string, where results should be stored
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
0 error
|
|
|
|
@retval
|
|
|
|
\# pointer on symbol after string
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
|
2004-05-11 22:23:49 +02:00
|
|
|
static char *
|
|
|
|
parse_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str)
|
|
|
|
{
|
|
|
|
// get string length
|
|
|
|
char *eol= strchr(ptr, '\n');
|
|
|
|
|
|
|
|
if (eol >= end)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
str->length= eol - ptr;
|
|
|
|
|
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
|
|
|
if (!(str->str= strmake_root(mem_root, ptr, str->length)))
|
2004-05-11 22:23:49 +02:00
|
|
|
return 0;
|
|
|
|
return eol+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
read escaped string from ptr to eol in already allocated str.
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param ptr pointer on string beginning
|
|
|
|
@param eol pointer on character after end of string
|
|
|
|
@param str target string
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
FALSE OK
|
|
|
|
@retval
|
|
|
|
TRUE error
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
my_bool
|
|
|
|
read_escaped_string(char *ptr, char *eol, LEX_STRING *str)
|
|
|
|
{
|
|
|
|
char *write_pos= str->str;
|
|
|
|
|
2005-06-01 15:35:09 +02:00
|
|
|
for (; ptr < eol; ptr++, write_pos++)
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
char c= *ptr;
|
|
|
|
if (c == '\\')
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
if (ptr >= eol)
|
|
|
|
return TRUE;
|
|
|
|
/*
|
|
|
|
Should be in sync with write_escaped_string() and
|
2004-09-07 14:29:46 +02:00
|
|
|
parse_quoted_escaped_string()
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
switch(*ptr) {
|
|
|
|
case '\\':
|
|
|
|
*write_pos= '\\';
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
*write_pos= '\n';
|
|
|
|
break;
|
|
|
|
case '0':
|
|
|
|
*write_pos= '\0';
|
|
|
|
break;
|
|
|
|
case 'z':
|
|
|
|
*write_pos= 26;
|
|
|
|
break;
|
|
|
|
case '\'':
|
|
|
|
*write_pos= '\'';
|
2004-10-08 13:16:03 +02:00
|
|
|
break;
|
2004-05-11 22:23:49 +02:00
|
|
|
default:
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*write_pos= c;
|
|
|
|
}
|
|
|
|
str->str[str->length= write_pos-str->str]= '\0'; // just for safety
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
parse \\n delimited escaped string.
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param ptr pointer on string beginning
|
|
|
|
@param end pointer on symbol after parsed string end (still owned
|
|
|
|
by buffer and can be accessed
|
|
|
|
@param mem_root MEM_ROOT for parameter allocation
|
|
|
|
@param str pointer on string, where results should be stored
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
0 error
|
|
|
|
@retval
|
|
|
|
\# pointer on symbol after string
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
|
2006-03-27 23:01:51 +02:00
|
|
|
char *
|
2004-05-11 22:23:49 +02:00
|
|
|
parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str)
|
|
|
|
{
|
|
|
|
char *eol= strchr(ptr, '\n');
|
|
|
|
|
|
|
|
if (eol == 0 || eol >= end ||
|
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
|
|
|
!(str->str= (char*) alloc_root(mem_root, (eol - ptr) + 1)) ||
|
2004-05-11 22:23:49 +02:00
|
|
|
read_escaped_string(ptr, eol, str))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return eol+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
parse '' delimited escaped string.
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param ptr pointer on string beginning
|
|
|
|
@param end pointer on symbol after parsed string end (still owned
|
|
|
|
by buffer and can be accessed
|
|
|
|
@param mem_root MEM_ROOT for parameter allocation
|
|
|
|
@param str pointer on string, where results should be stored
|
2004-05-11 22:23:49 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
0 error
|
|
|
|
@retval
|
|
|
|
\# pointer on symbol after string
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
static char *
|
2004-09-07 14:29:46 +02:00
|
|
|
parse_quoted_escaped_string(char *ptr, char *end,
|
2004-05-11 22:23:49 +02:00
|
|
|
MEM_ROOT *mem_root, LEX_STRING *str)
|
|
|
|
{
|
|
|
|
char *eol;
|
|
|
|
uint result_len= 0;
|
|
|
|
bool escaped= 0;
|
|
|
|
|
|
|
|
// starting '
|
|
|
|
if (*(ptr++) != '\'')
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// find ending '
|
|
|
|
for (eol= ptr; (*eol != '\'' || escaped) && eol < end; eol++)
|
|
|
|
{
|
|
|
|
if (!(escaped= (*eol == '\\' && !escaped)))
|
|
|
|
result_len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// process string
|
|
|
|
if (eol >= end ||
|
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
|
|
|
!(str->str= (char*) alloc_root(mem_root, result_len + 1)) ||
|
2004-05-11 22:23:49 +02:00
|
|
|
read_escaped_string(ptr, eol, str))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return eol+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
2005-11-20 19:47:07 +01:00
|
|
|
Parser for FILE_OPTIONS_ULLLIST type value.
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param[in,out] ptr pointer to parameter
|
|
|
|
@param[in] end end of the configuration
|
|
|
|
@param[in] line pointer to the line begining
|
|
|
|
@param[in] base base address for parameter writing (structure
|
|
|
|
like TABLE)
|
|
|
|
@param[in] parameter description
|
|
|
|
@param[in] mem_root MEM_ROOT for parameters allocation
|
2005-11-20 19:47:07 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
bool get_file_options_ulllist(char *&ptr, char *end, char *line,
|
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
|
|
|
uchar* base, File_option *parameter,
|
2005-11-20 19:47:07 +01:00
|
|
|
MEM_ROOT *mem_root)
|
|
|
|
{
|
|
|
|
List<ulonglong> *nlist= (List<ulonglong>*)(base + parameter->offset);
|
|
|
|
ulonglong *num;
|
|
|
|
nlist->empty();
|
|
|
|
// list parsing
|
|
|
|
while (ptr < end)
|
|
|
|
{
|
|
|
|
int not_used;
|
|
|
|
char *num_end= end;
|
|
|
|
if (!(num= (ulonglong*)alloc_root(mem_root, sizeof(ulonglong))) ||
|
|
|
|
nlist->push_back(num, mem_root))
|
|
|
|
goto nlist_err;
|
|
|
|
*num= my_strtoll10(ptr, &num_end, ¬_used);
|
|
|
|
ptr= num_end;
|
|
|
|
switch (*ptr) {
|
|
|
|
case '\n':
|
|
|
|
goto end_of_nlist;
|
|
|
|
case ' ':
|
|
|
|
// we cant go over buffer bounds, because we have \0 at the end
|
|
|
|
ptr++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto nlist_err_w_message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end_of_nlist:
|
|
|
|
if (*(ptr++) != '\n')
|
|
|
|
goto nlist_err;
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
nlist_err_w_message:
|
|
|
|
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), parameter->name.str, line);
|
|
|
|
nlist_err:
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
parse parameters.
|
|
|
|
|
|
|
|
@param base base address for parameter writing (structure like
|
|
|
|
TABLE)
|
|
|
|
@param mem_root MEM_ROOT for parameters allocation
|
|
|
|
@param parameters parameters description
|
|
|
|
@param required number of required parameters in above list. If the file
|
|
|
|
contains more parameters than "required", they will
|
|
|
|
be ignored. If the file contains less parameters
|
|
|
|
then "required", non-existing parameters will
|
|
|
|
remain their values.
|
|
|
|
@param hook hook called for unknown keys
|
|
|
|
@param hook_data some data specific for the hook
|
|
|
|
|
|
|
|
@retval
|
|
|
|
FALSE OK
|
|
|
|
@retval
|
|
|
|
TRUE error
|
2004-05-11 22:23:49 +02:00
|
|
|
*/
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
|
2004-05-11 22:23:49 +02:00
|
|
|
my_bool
|
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
|
|
|
File_parser::parse(uchar* base, MEM_ROOT *mem_root,
|
2005-11-20 19:47:07 +01:00
|
|
|
struct File_option *parameters, uint required,
|
|
|
|
Unknown_key_hook *hook)
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
uint first_param= 0, found= 0;
|
2005-11-20 19:47:07 +01:00
|
|
|
char *ptr= start;
|
2004-05-11 22:23:49 +02:00
|
|
|
char *eol;
|
|
|
|
LEX_STRING *str;
|
|
|
|
List<LEX_STRING> *list;
|
|
|
|
DBUG_ENTER("File_parser::parse");
|
|
|
|
|
|
|
|
while (ptr < end && found < required)
|
|
|
|
{
|
|
|
|
char *line= ptr;
|
|
|
|
if (*ptr == '#')
|
|
|
|
{
|
|
|
|
// it is comment
|
|
|
|
if (!(ptr= strchr(ptr, '\n')))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_FPARSER_EOF_IN_COMMENT, MYF(0), line);
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
File_option *parameter= parameters+first_param,
|
|
|
|
*parameters_end= parameters+required;
|
|
|
|
int len= 0;
|
2005-06-01 15:35:09 +02:00
|
|
|
for (; parameter < parameters_end; parameter++)
|
2004-05-11 22:23:49 +02:00
|
|
|
{
|
|
|
|
len= parameter->name.length;
|
|
|
|
// check length
|
|
|
|
if (len < (end-ptr) && ptr[len] != '=')
|
|
|
|
continue;
|
|
|
|
// check keyword
|
|
|
|
if (memcmp(parameter->name.str, ptr, len) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parameter < parameters_end)
|
|
|
|
{
|
|
|
|
found++;
|
|
|
|
/*
|
|
|
|
if we found first parameter, start search from next parameter
|
|
|
|
next time.
|
|
|
|
(this small optimisation should work, because they should be
|
|
|
|
written in same order)
|
|
|
|
*/
|
|
|
|
if (parameter == parameters+first_param)
|
|
|
|
first_param++;
|
|
|
|
|
|
|
|
// get value
|
|
|
|
ptr+= (len+1);
|
|
|
|
switch (parameter->type) {
|
|
|
|
case FILE_OPTIONS_STRING:
|
|
|
|
{
|
|
|
|
if (!(ptr= parse_string(ptr, end, mem_root,
|
|
|
|
(LEX_STRING *)(base +
|
|
|
|
parameter->offset))))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
|
|
|
|
parameter->name.str, line);
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FILE_OPTIONS_ESTRING:
|
|
|
|
{
|
|
|
|
if (!(ptr= parse_escaped_string(ptr, end, mem_root,
|
|
|
|
(LEX_STRING *)
|
|
|
|
(base + parameter->offset))))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
|
|
|
|
parameter->name.str, line);
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FILE_OPTIONS_ULONGLONG:
|
|
|
|
if (!(eol= strchr(ptr, '\n')))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
|
|
|
|
parameter->name.str, line);
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2004-07-10 10:17:35 +02:00
|
|
|
{
|
|
|
|
int not_used;
|
|
|
|
*((ulonglong*)(base + parameter->offset))=
|
|
|
|
my_strtoll10(ptr, 0, ¬_used);
|
|
|
|
}
|
2004-05-11 22:23:49 +02:00
|
|
|
ptr= eol+1;
|
|
|
|
break;
|
|
|
|
case FILE_OPTIONS_TIMESTAMP:
|
|
|
|
{
|
|
|
|
/* string have to be allocated already */
|
|
|
|
LEX_STRING *val= (LEX_STRING *)(base + parameter->offset);
|
|
|
|
/* yyyy-mm-dd HH:MM:SS = 19(PARSE_FILE_TIMESTAMPLENGTH) characters */
|
|
|
|
if (ptr[PARSE_FILE_TIMESTAMPLENGTH] != '\n')
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
|
|
|
|
parameter->name.str, line);
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
memcpy(val->str, ptr, PARSE_FILE_TIMESTAMPLENGTH);
|
|
|
|
val->str[val->length= PARSE_FILE_TIMESTAMPLENGTH]= '\0';
|
|
|
|
ptr+= (PARSE_FILE_TIMESTAMPLENGTH+1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FILE_OPTIONS_STRLIST:
|
|
|
|
{
|
2004-11-09 02:58:44 +01:00
|
|
|
list= (List<LEX_STRING>*)(base + parameter->offset);
|
2005-07-28 21:39:11 +02:00
|
|
|
|
2004-05-11 22:23:49 +02:00
|
|
|
list->empty();
|
|
|
|
// list parsing
|
|
|
|
while (ptr < end)
|
|
|
|
{
|
|
|
|
if (!(str= (LEX_STRING*)alloc_root(mem_root,
|
|
|
|
sizeof(LEX_STRING))) ||
|
2004-11-09 02:58:44 +01:00
|
|
|
list->push_back(str, mem_root))
|
2004-05-11 22:23:49 +02:00
|
|
|
goto list_err;
|
2005-07-18 14:33:18 +02:00
|
|
|
if (!(ptr= parse_quoted_escaped_string(ptr, end, mem_root, str)))
|
2004-05-11 22:23:49 +02:00
|
|
|
goto list_err_w_message;
|
|
|
|
switch (*ptr) {
|
|
|
|
case '\n':
|
|
|
|
goto end_of_list;
|
|
|
|
case ' ':
|
|
|
|
// we cant go over buffer bounds, because we have \0 at the end
|
|
|
|
ptr++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto list_err_w_message;
|
|
|
|
}
|
|
|
|
}
|
2005-07-28 21:39:11 +02:00
|
|
|
|
|
|
|
end_of_list:
|
2004-05-11 22:23:49 +02:00
|
|
|
if (*(ptr++) != '\n')
|
|
|
|
goto list_err;
|
|
|
|
break;
|
|
|
|
|
2005-07-28 21:39:11 +02:00
|
|
|
list_err_w_message:
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
|
|
|
|
parameter->name.str, line);
|
2005-07-28 21:39:11 +02:00
|
|
|
list_err:
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2005-07-28 21:39:11 +02:00
|
|
|
case FILE_OPTIONS_ULLLIST:
|
2005-11-20 19:47:07 +01:00
|
|
|
if (get_file_options_ulllist(ptr, end, line, base,
|
|
|
|
parameter, mem_root))
|
|
|
|
DBUG_RETURN(TRUE);
|
2005-07-28 21:39:11 +02:00
|
|
|
break;
|
2004-05-11 22:23:49 +02:00
|
|
|
default:
|
|
|
|
DBUG_ASSERT(0); // never should happened
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-20 19:47:07 +01:00
|
|
|
ptr= line;
|
|
|
|
if (hook->process_unknown_string(ptr, base, mem_root, end))
|
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
// skip unknown parameter
|
|
|
|
if (!(ptr= strchr(ptr, '\n')))
|
|
|
|
{
|
|
|
|
my_error(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER, MYF(0), line);
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
ptr++;
|
2004-05-11 22:23:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-06 16:56:39 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
NOTE: if we read less than "required" parameters, it is still Ok.
|
|
|
|
Probably, we've just read the file of the previous version, which
|
|
|
|
contains less parameters.
|
|
|
|
*/
|
|
|
|
|
2004-05-11 22:23:49 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
2005-11-20 19:47:07 +01:00
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Dummy unknown key hook.
|
2005-11-20 19:47:07 +01:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param[in,out] unknown_key reference on the line with unknown
|
|
|
|
parameter and the parsing point
|
|
|
|
@param[in] base base address for parameter writing
|
|
|
|
(structure like TABLE)
|
|
|
|
@param[in] mem_root MEM_ROOT for parameters allocation
|
|
|
|
@param[in] end the end of the configuration
|
2005-11-20 19:47:07 +01:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@note
|
2005-11-20 19:47:07 +01:00
|
|
|
This hook used to catch no longer supported keys and process them for
|
|
|
|
backward compatibility, but it will not slow down processing of modern
|
|
|
|
format files.
|
|
|
|
This hook does nothing except debug output.
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2005-11-20 19:47:07 +01:00
|
|
|
FALSE OK
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2005-11-20 19:47:07 +01:00
|
|
|
TRUE Error
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
File_parser_dummy_hook::process_unknown_string(char *&unknown_key,
|
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
|
|
|
uchar* base, MEM_ROOT *mem_root,
|
2005-11-20 19:47:07 +01:00
|
|
|
char *end)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("file_parser_dummy_hook::process_unknown_string");
|
2006-01-05 23:47:49 +01:00
|
|
|
DBUG_PRINT("info", ("Unknown key: '%60s'", unknown_key));
|
2005-11-20 19:47:07 +01:00
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|