2005-07-23 12:06:02 +02:00
|
|
|
/* Copyright (C) 2003 MySQL AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2005-07-23 12:06:02 +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 */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ndb_config --nodes --query=nodeid --type=ndbd --host=local1
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ndb_global.h>
|
2006-09-13 23:40:28 +02:00
|
|
|
#include <ndb_opts.h>
|
|
|
|
|
2005-07-23 12:06:02 +02:00
|
|
|
#include <my_sys.h>
|
|
|
|
#include <my_getopt.h>
|
|
|
|
#include <mysql_version.h>
|
|
|
|
|
2005-09-16 00:15:47 +02:00
|
|
|
#include <netdb.h>
|
|
|
|
|
2005-07-23 12:06:02 +02:00
|
|
|
#include <NdbOut.hpp>
|
|
|
|
#include <mgmapi.h>
|
|
|
|
#include <mgmapi_configuration.hpp>
|
|
|
|
#include <ConfigInfo.hpp>
|
2006-09-14 00:12:17 +02:00
|
|
|
#include <NdbAutoPtr.hpp>
|
2005-07-23 12:06:02 +02:00
|
|
|
|
|
|
|
static int g_verbose = 0;
|
|
|
|
static int try_reconnect = 3;
|
|
|
|
|
2005-10-12 14:17:39 +02:00
|
|
|
static int g_nodes, g_connections, g_section;
|
2005-07-23 12:06:02 +02:00
|
|
|
static const char * g_query = 0;
|
|
|
|
|
|
|
|
static int g_nodeid = 0;
|
|
|
|
static const char * g_type = 0;
|
|
|
|
static const char * g_host = 0;
|
|
|
|
static const char * g_field_delimiter=",";
|
|
|
|
static const char * g_row_delimiter=" ";
|
2005-09-30 11:39:49 +02:00
|
|
|
static const char * g_config_file = 0;
|
2005-09-30 12:19:15 +02:00
|
|
|
static int g_mycnf = 0;
|
2005-07-23 12:06:02 +02:00
|
|
|
|
2006-09-04 16:33:56 +02:00
|
|
|
const char *load_default_groups[]= { "mysql_cluster",0 };
|
|
|
|
|
2006-09-13 23:40:28 +02:00
|
|
|
NDB_STD_OPTS_VARS;
|
2005-07-23 12:06:02 +02:00
|
|
|
|
2006-09-13 23:40:28 +02:00
|
|
|
int g_print_full_config;
|
2005-07-23 12:06:02 +02:00
|
|
|
|
2006-09-13 23:40:28 +02:00
|
|
|
typedef ndb_mgm_configuration_iterator Iter;
|
2005-07-23 12:06:02 +02:00
|
|
|
|
|
|
|
static struct my_option my_long_options[] =
|
|
|
|
{
|
2006-09-13 23:40:28 +02:00
|
|
|
NDB_STD_OPTS("ndb_config"),
|
2005-07-23 12:06:02 +02:00
|
|
|
{ "nodes", 256, "Print nodes",
|
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**) &g_nodes, (uchar**) &g_nodes,
|
2005-10-12 14:17:39 +02:00
|
|
|
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ "connections", 256, "Print connections",
|
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**) &g_connections, (uchar**) &g_connections,
|
2005-10-12 14:17:39 +02:00
|
|
|
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
2005-07-23 12:06:02 +02:00
|
|
|
{ "query", 'q', "Query option(s)",
|
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**) &g_query, (uchar**) &g_query,
|
2005-07-23 12:06:02 +02:00
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2005-10-12 14:17:39 +02:00
|
|
|
{ "host", 256, "Host",
|
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**) &g_host, (uchar**) &g_host,
|
2005-07-23 12:06:02 +02:00
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ "type", 258, "Type of node/connection",
|
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**) &g_type, (uchar**) &g_type,
|
2005-07-23 12:06:02 +02:00
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ "id", 258, "Nodeid",
|
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**) &g_nodeid, (uchar**) &g_nodeid,
|
2005-07-23 12:06:02 +02:00
|
|
|
0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ "nodeid", 258, "Nodeid",
|
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**) &g_nodeid, (uchar**) &g_nodeid,
|
2005-07-23 12:06:02 +02:00
|
|
|
0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ "fields", 'f', "Field separator",
|
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**) &g_field_delimiter, (uchar**) &g_field_delimiter,
|
2005-07-23 12:06:02 +02:00
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ "rows", 'r', "Row separator",
|
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**) &g_row_delimiter, (uchar**) &g_row_delimiter,
|
2005-07-23 12:06:02 +02:00
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2005-09-30 11:39:49 +02:00
|
|
|
{ "config-file", 256, "Path to config.ini",
|
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**) &g_config_file, (uchar**) &g_config_file,
|
2005-09-30 11:39:49 +02:00
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2005-09-30 12:19:15 +02:00
|
|
|
{ "mycnf", 256, "Read config from my.cnf",
|
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**) &g_mycnf, (uchar**) &g_mycnf,
|
2005-09-30 12:19:15 +02:00
|
|
|
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
2005-07-23 12:06:02 +02:00
|
|
|
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void usage()
|
|
|
|
{
|
|
|
|
char desc[] =
|
|
|
|
"This program will retreive config options for a ndb cluster\n";
|
2006-12-14 23:51:37 +01:00
|
|
|
puts(desc);
|
2005-07-23 12:06:02 +02:00
|
|
|
ndb_std_print_version();
|
2006-09-04 16:33:56 +02:00
|
|
|
print_defaults(MYSQL_CONFIG_NAME,load_default_groups);
|
|
|
|
puts("");
|
2005-07-23 12:06:02 +02:00
|
|
|
my_print_help(my_long_options);
|
|
|
|
my_print_variables(my_long_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Match/Apply framework
|
|
|
|
*/
|
|
|
|
struct Match
|
|
|
|
{
|
|
|
|
int m_key;
|
|
|
|
BaseString m_value;
|
2006-12-14 23:51:37 +01:00
|
|
|
Match() {}
|
2005-09-30 11:39:49 +02:00
|
|
|
virtual int eval(const Iter&);
|
2006-11-20 21:42:06 +01:00
|
|
|
virtual ~Match() {}
|
2005-07-23 12:06:02 +02:00
|
|
|
};
|
|
|
|
|
2005-09-16 00:15:47 +02:00
|
|
|
struct HostMatch : public Match
|
|
|
|
{
|
2006-12-14 23:51:37 +01:00
|
|
|
HostMatch() {}
|
2006-08-30 20:45:43 +02:00
|
|
|
virtual int eval(const Iter&);
|
2005-09-16 00:15:47 +02:00
|
|
|
};
|
|
|
|
|
2005-07-23 12:06:02 +02:00
|
|
|
struct Apply
|
|
|
|
{
|
|
|
|
Apply() {}
|
|
|
|
Apply(int val) { m_key = val;}
|
|
|
|
int m_key;
|
2005-09-30 11:39:49 +02:00
|
|
|
virtual int apply(const Iter&);
|
2006-11-20 21:42:06 +01:00
|
|
|
virtual ~Apply() {}
|
2005-07-23 12:06:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct NodeTypeApply : public Apply
|
|
|
|
{
|
2006-12-14 23:51:37 +01:00
|
|
|
NodeTypeApply() {}
|
2005-09-30 11:39:49 +02:00
|
|
|
virtual int apply(const Iter&);
|
2005-07-23 12:06:02 +02:00
|
|
|
};
|
|
|
|
|
2005-10-12 14:17:39 +02:00
|
|
|
struct ConnectionTypeApply : public Apply
|
|
|
|
{
|
2006-12-14 23:51:37 +01:00
|
|
|
ConnectionTypeApply() {}
|
2005-10-12 14:17:39 +02:00
|
|
|
virtual int apply(const Iter&);
|
|
|
|
};
|
|
|
|
|
2005-07-23 12:06:02 +02:00
|
|
|
static int parse_query(Vector<Apply*>&, int &argc, char**& argv);
|
|
|
|
static int parse_where(Vector<Match*>&, int &argc, char**& argv);
|
2005-09-30 11:39:49 +02:00
|
|
|
static int eval(const Iter&, const Vector<Match*>&);
|
|
|
|
static int apply(const Iter&, const Vector<Apply*>&);
|
|
|
|
static ndb_mgm_configuration* fetch_configuration();
|
|
|
|
static ndb_mgm_configuration* load_configuration();
|
|
|
|
|
2005-07-23 12:06:02 +02:00
|
|
|
int
|
|
|
|
main(int argc, char** argv){
|
|
|
|
NDB_INIT(argv[0]);
|
|
|
|
load_defaults("my",load_default_groups,&argc,&argv);
|
|
|
|
int ho_error;
|
|
|
|
if ((ho_error=handle_options(&argc, &argv, my_long_options,
|
|
|
|
ndb_std_get_one_option)))
|
|
|
|
return -1;
|
|
|
|
|
2005-10-12 14:17:39 +02:00
|
|
|
if (g_nodes && g_connections)
|
|
|
|
{
|
2005-10-12 15:19:51 +02:00
|
|
|
fprintf(stderr,
|
|
|
|
"Only one option of --nodes and --connections allowed\n");
|
|
|
|
return -1;
|
2005-10-12 14:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
g_section = CFG_SECTION_NODE; //default
|
|
|
|
if (g_connections)
|
|
|
|
g_section = CFG_SECTION_CONNECTION;
|
|
|
|
|
2005-09-30 11:39:49 +02:00
|
|
|
ndb_mgm_configuration * conf = 0;
|
2005-07-23 12:06:02 +02:00
|
|
|
|
2005-09-30 12:19:15 +02:00
|
|
|
if (g_config_file || g_mycnf)
|
2005-09-30 11:39:49 +02:00
|
|
|
conf = load_configuration();
|
|
|
|
else
|
|
|
|
conf = fetch_configuration();
|
2005-07-23 12:06:02 +02:00
|
|
|
|
2005-09-30 12:19:15 +02:00
|
|
|
if (conf == 0)
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
2005-09-30 12:19:15 +02:00
|
|
|
return -1;
|
2005-07-23 12:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Vector<Apply*> select_list;
|
|
|
|
Vector<Match*> where_clause;
|
|
|
|
|
|
|
|
if(strcmp(g_row_delimiter, "\\n") == 0)
|
|
|
|
g_row_delimiter = "\n";
|
|
|
|
if(strcmp(g_field_delimiter, "\\n") == 0)
|
|
|
|
g_field_delimiter = "\n";
|
|
|
|
|
|
|
|
if(parse_query(select_list, argc, argv))
|
|
|
|
{
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(parse_where(where_clause, argc, argv))
|
|
|
|
{
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2005-10-12 14:17:39 +02:00
|
|
|
Iter iter(* conf, g_section);
|
2005-07-23 12:06:02 +02:00
|
|
|
bool prev= false;
|
|
|
|
iter.first();
|
|
|
|
for(iter.first(); iter.valid(); iter.next())
|
|
|
|
{
|
2005-09-30 11:39:49 +02:00
|
|
|
if(eval(iter, where_clause))
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
|
|
|
if(prev)
|
|
|
|
printf("%s", g_row_delimiter);
|
|
|
|
prev= true;
|
2005-09-30 11:39:49 +02:00
|
|
|
apply(iter, select_list);
|
2005-07-23 12:06:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
int
|
|
|
|
parse_query(Vector<Apply*>& select, int &argc, char**& argv)
|
|
|
|
{
|
|
|
|
if(g_query)
|
|
|
|
{
|
|
|
|
BaseString q(g_query);
|
|
|
|
Vector<BaseString> list;
|
|
|
|
q.split(list, ",");
|
|
|
|
for(unsigned i = 0; i<list.size(); i++)
|
|
|
|
{
|
|
|
|
const char * str= list[i].c_str();
|
2005-10-12 14:17:39 +02:00
|
|
|
if(g_section == CFG_SECTION_NODE)
|
|
|
|
{
|
|
|
|
if(strcasecmp(str, "id") == 0 || strcasecmp(str, "nodeid") == 0)
|
|
|
|
{
|
|
|
|
select.push_back(new Apply(CFG_NODE_ID));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(strncasecmp(str, "host", 4) == 0)
|
|
|
|
{
|
|
|
|
select.push_back(new Apply(CFG_NODE_HOST));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(strcasecmp(str, "type") == 0)
|
|
|
|
{
|
|
|
|
select.push_back(new NodeTypeApply());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (g_section == CFG_SECTION_CONNECTION)
|
|
|
|
{
|
|
|
|
if(strcasecmp(str, "type") == 0)
|
|
|
|
{
|
|
|
|
select.push_back(new ConnectionTypeApply());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
for(int p = 0; p<ConfigInfo::m_NoOfParams; p++)
|
|
|
|
{
|
|
|
|
if(0)ndbout_c("%s %s",
|
|
|
|
ConfigInfo::m_ParamInfo[p]._section,
|
|
|
|
ConfigInfo::m_ParamInfo[p]._fname);
|
2005-10-12 14:17:39 +02:00
|
|
|
if(g_section == CFG_SECTION_CONNECTION &&
|
|
|
|
(strcmp(ConfigInfo::m_ParamInfo[p]._section, "TCP") == 0 ||
|
|
|
|
strcmp(ConfigInfo::m_ParamInfo[p]._section, "SCI") == 0 ||
|
|
|
|
strcmp(ConfigInfo::m_ParamInfo[p]._section, "SHM") == 0)
|
|
|
|
||
|
|
|
|
g_section == CFG_SECTION_NODE &&
|
|
|
|
(strcmp(ConfigInfo::m_ParamInfo[p]._section, "DB") == 0 ||
|
|
|
|
strcmp(ConfigInfo::m_ParamInfo[p]._section, "API") == 0 ||
|
|
|
|
strcmp(ConfigInfo::m_ParamInfo[p]._section, "MGM") == 0))
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
|
|
|
if(strcasecmp(ConfigInfo::m_ParamInfo[p]._fname, str) == 0)
|
|
|
|
{
|
|
|
|
select.push_back(new Apply(ConfigInfo::m_ParamInfo[p]._paramId));
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Unknown query option: %s\n", str);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
int
|
|
|
|
parse_where(Vector<Match*>& where, int &argc, char**& argv)
|
|
|
|
{
|
|
|
|
Match m;
|
|
|
|
if(g_host)
|
|
|
|
{
|
2006-12-14 23:51:37 +01:00
|
|
|
HostMatch *tmp = new HostMatch;
|
|
|
|
tmp->m_key = CFG_NODE_HOST;
|
|
|
|
tmp->m_value.assfmt("%s", g_host);
|
|
|
|
where.push_back(tmp);
|
2005-07-23 12:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(g_type)
|
|
|
|
{
|
|
|
|
m.m_key = CFG_TYPE_OF_SECTION;
|
|
|
|
m.m_value.assfmt("%d", ndb_mgm_match_node_type(g_type));
|
|
|
|
where.push_back(new Match(m));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(g_nodeid)
|
|
|
|
{
|
|
|
|
m.m_key = CFG_NODE_ID;
|
|
|
|
m.m_value.assfmt("%d", g_nodeid);
|
|
|
|
where.push_back(new Match(m));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-25 13:47:40 +02:00
|
|
|
template class Vector<Apply*>;
|
|
|
|
template class Vector<Match*>;
|
2005-07-23 12:06:02 +02:00
|
|
|
|
|
|
|
static
|
|
|
|
int
|
2005-09-30 11:39:49 +02:00
|
|
|
eval(const Iter& iter, const Vector<Match*>& where)
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
|
|
|
for(unsigned i = 0; i<where.size(); i++)
|
|
|
|
{
|
2005-09-30 11:39:49 +02:00
|
|
|
if(where[i]->eval(iter) == 0)
|
2005-07-23 12:06:02 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
int
|
2005-09-30 11:39:49 +02:00
|
|
|
apply(const Iter& iter, const Vector<Apply*>& list)
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
|
|
|
for(unsigned i = 0; i<list.size(); i++)
|
|
|
|
{
|
2005-09-30 11:39:49 +02:00
|
|
|
list[i]->apply(iter);
|
2005-07-23 12:06:02 +02:00
|
|
|
if(i + 1 != list.size())
|
|
|
|
printf("%s", g_field_delimiter);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-09-30 11:39:49 +02:00
|
|
|
Match::eval(const Iter& iter)
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
|
|
|
Uint32 val32;
|
|
|
|
Uint64 val64;
|
|
|
|
const char* valc;
|
|
|
|
if (iter.get(m_key, &val32) == 0)
|
|
|
|
{
|
2005-09-30 11:39:49 +02:00
|
|
|
if(atoi(m_value.c_str()) != (int)val32)
|
2005-07-23 12:06:02 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if(iter.get(m_key, &val64) == 0)
|
|
|
|
{
|
2005-09-30 11:39:49 +02:00
|
|
|
if(strtoll(m_value.c_str(), (char **)NULL, 10) != (long long)val64)
|
2005-07-23 12:06:02 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if(iter.get(m_key, &valc) == 0)
|
|
|
|
{
|
|
|
|
if(strcmp(m_value.c_str(), valc) != 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-09-16 00:15:47 +02:00
|
|
|
int
|
2006-08-30 20:45:43 +02:00
|
|
|
HostMatch::eval(const Iter& iter)
|
2005-09-16 00:15:47 +02:00
|
|
|
{
|
|
|
|
const char* valc;
|
|
|
|
|
|
|
|
if(iter.get(m_key, &valc) == 0)
|
|
|
|
{
|
2006-09-13 23:19:18 +02:00
|
|
|
struct hostent *h1, *h2, copy1;
|
|
|
|
char *addr1;
|
2005-09-16 00:15:47 +02:00
|
|
|
|
|
|
|
h1 = gethostbyname(m_value.c_str());
|
|
|
|
if (h1 == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-13 23:19:18 +02:00
|
|
|
// gethostbyname returns a pointer to a static structure
|
|
|
|
// so we need to copy the results before doing the next call
|
|
|
|
memcpy(©1, h1, sizeof(struct hostent));
|
|
|
|
addr1 = (char *)malloc(copy1.h_length);
|
2006-09-14 00:12:17 +02:00
|
|
|
NdbAutoPtr<char> tmp_aptr(addr1);
|
2006-09-13 23:19:18 +02:00
|
|
|
memcpy(addr1, h1->h_addr, copy1.h_length);
|
|
|
|
|
2005-09-16 00:15:47 +02:00
|
|
|
h2 = gethostbyname(valc);
|
|
|
|
if (h2 == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-13 23:19:18 +02:00
|
|
|
if (copy1.h_addrtype != h2->h_addrtype) {
|
2005-09-16 00:15:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-13 23:19:18 +02:00
|
|
|
if (copy1.h_length != h2->h_length)
|
2005-09-16 00:15:47 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-14 00:12:17 +02:00
|
|
|
return 0 == memcmp(addr1, h2->h_addr, copy1.h_length);
|
2005-09-16 00:15:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-23 12:06:02 +02:00
|
|
|
int
|
2005-09-30 11:39:49 +02:00
|
|
|
Apply::apply(const Iter& iter)
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
|
|
|
Uint32 val32;
|
|
|
|
Uint64 val64;
|
|
|
|
const char* valc;
|
|
|
|
if (iter.get(m_key, &val32) == 0)
|
|
|
|
{
|
|
|
|
printf("%u", val32);
|
|
|
|
}
|
|
|
|
else if(iter.get(m_key, &val64) == 0)
|
|
|
|
{
|
|
|
|
printf("%llu", val64);
|
|
|
|
}
|
|
|
|
else if(iter.get(m_key, &valc) == 0)
|
|
|
|
{
|
|
|
|
printf("%s", valc);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-09-30 11:39:49 +02:00
|
|
|
NodeTypeApply::apply(const Iter& iter)
|
2005-07-23 12:06:02 +02:00
|
|
|
{
|
|
|
|
Uint32 val32;
|
|
|
|
if (iter.get(CFG_TYPE_OF_SECTION, &val32) == 0)
|
|
|
|
{
|
|
|
|
printf("%s", ndb_mgm_get_node_type_alias_string((ndb_mgm_node_type)val32, 0));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2005-09-30 11:39:49 +02:00
|
|
|
|
2005-10-12 14:17:39 +02:00
|
|
|
int
|
|
|
|
ConnectionTypeApply::apply(const Iter& iter)
|
|
|
|
{
|
|
|
|
Uint32 val32;
|
|
|
|
if (iter.get(CFG_TYPE_OF_SECTION, &val32) == 0)
|
|
|
|
{
|
|
|
|
switch (val32)
|
|
|
|
{
|
|
|
|
case CONNECTION_TYPE_TCP:
|
|
|
|
printf("tcp");
|
|
|
|
break;
|
|
|
|
case CONNECTION_TYPE_SCI:
|
|
|
|
printf("sci");
|
|
|
|
break;
|
|
|
|
case CONNECTION_TYPE_SHM:
|
|
|
|
printf("shm");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("<unknown>");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-30 11:39:49 +02:00
|
|
|
ndb_mgm_configuration*
|
|
|
|
fetch_configuration()
|
|
|
|
{
|
|
|
|
ndb_mgm_configuration* conf = 0;
|
|
|
|
NdbMgmHandle mgm = ndb_mgm_create_handle();
|
|
|
|
if(mgm == NULL) {
|
|
|
|
fprintf(stderr, "Cannot create handle to management server.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ndb_mgm_set_error_stream(mgm, stderr);
|
|
|
|
|
2006-11-13 17:04:40 +01:00
|
|
|
if (ndb_mgm_set_connectstring(mgm, opt_connect_str))
|
2005-09-30 11:39:49 +02:00
|
|
|
{
|
|
|
|
fprintf(stderr, "* %5d: %s\n",
|
|
|
|
ndb_mgm_get_latest_error(mgm),
|
|
|
|
ndb_mgm_get_latest_error_msg(mgm));
|
|
|
|
fprintf(stderr,
|
|
|
|
"* %s", ndb_mgm_get_latest_error_desc(mgm));
|
|
|
|
goto noconnect;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ndb_mgm_connect(mgm, try_reconnect-1, 5, 1))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Connect failed");
|
|
|
|
fprintf(stderr, " code: %d, msg: %s\n",
|
|
|
|
ndb_mgm_get_latest_error(mgm),
|
|
|
|
ndb_mgm_get_latest_error_msg(mgm));
|
|
|
|
goto noconnect;
|
|
|
|
}
|
|
|
|
else if(g_verbose)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Connected to %s:%d\n",
|
|
|
|
ndb_mgm_get_connected_host(mgm),
|
|
|
|
ndb_mgm_get_connected_port(mgm));
|
|
|
|
}
|
|
|
|
|
|
|
|
conf = ndb_mgm_get_configuration(mgm, 0);
|
|
|
|
if(conf == 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Could not get configuration");
|
|
|
|
fprintf(stderr, "code: %d, msg: %s\n",
|
|
|
|
ndb_mgm_get_latest_error(mgm),
|
|
|
|
ndb_mgm_get_latest_error_msg(mgm));
|
|
|
|
}
|
|
|
|
else if(g_verbose)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Fetched configuration\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
ndb_mgm_disconnect(mgm);
|
|
|
|
noconnect:
|
|
|
|
ndb_mgm_destroy_handle(&mgm);
|
|
|
|
|
|
|
|
return conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <Config.hpp>
|
|
|
|
|
|
|
|
ndb_mgm_configuration*
|
|
|
|
load_configuration()
|
|
|
|
{
|
|
|
|
InitConfigFileParser parser(stderr);
|
2005-09-30 12:19:15 +02:00
|
|
|
if (g_config_file)
|
|
|
|
{
|
|
|
|
if (g_verbose)
|
|
|
|
fprintf(stderr, "Using config.ini : %s", g_config_file);
|
|
|
|
|
|
|
|
Config* conf = parser.parseConfig(g_config_file);
|
|
|
|
if (conf)
|
|
|
|
return conf->m_configValues;
|
|
|
|
}
|
|
|
|
|
2005-09-30 11:39:49 +02:00
|
|
|
if (g_verbose)
|
2005-09-30 12:19:15 +02:00
|
|
|
fprintf(stderr, "Using my.cnf");
|
2005-09-30 11:39:49 +02:00
|
|
|
|
2005-09-30 12:19:15 +02:00
|
|
|
Config* conf = parser.parse_mycnf();
|
2005-09-30 11:39:49 +02:00
|
|
|
if (conf)
|
|
|
|
return conf->m_configValues;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|