summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com/narttu.mysql.fi>2006-12-15 00:51:37 +0200
committerunknown <monty@mysql.com/narttu.mysql.fi>2006-12-15 00:51:37 +0200
commitf00257ddd0a2f392f9b80c9cd5c405017e3a9d63 (patch)
tree142bd488523fec48817d9fb2194f1a608eec00fc /sql/field.cc
parent25226de9ea52d06667c2c7fbd99f5cd014764241 (diff)
downloadmariadb-git-f00257ddd0a2f392f9b80c9cd5c405017e3a9d63.tar.gz
Fixed compiler warnings detected by option -Wshadow and -Wunused:
- Removed not used variables and functions - Added #ifdef around code that is not used - Renamed variables and functions to avoid conflicts - Removed some not used arguments Fixed some class/struct warnings in ndb Added define IS_LONGDATA() to simplify code in libmysql.c I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes BUILD/SETUP.sh: Added printing of unused functions and variables. Made it easy to test compiling with -Wshadow BUILD/compile-pentium-gcov: Added warnings Mark binary with -gcov client/mysql.cc: Fixed warnings found with gcc -Wshadow client/mysql_upgrade.c: Fixed warnings found with gcc -Wshadow client/mysqlbinlog.cc: Fixed warnings found with gcc -Wshadow client/mysqldump.c: Fixed warnings found with gcc -Wshadow client/mysqltest.c: Fixed warnings found with gcc -Wshadow client/sql_string.cc: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.cc client/sql_string.h: Fixed warnings found with gcc -Wshadow Merged with sql/sql_string.h cmd-line-utils/readline/display.c: Fixed compiler warning cmd-line-utils/readline/histexpand.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/input.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/text.c: Fixed warnings found with gcc -Wshadow cmd-line-utils/readline/vi_mode.c: Fixed warnings found with gcc -Wshadow dbug/dbug_analyze.c: Fixed warnings found with gcc -Wshadow extra/my_print_defaults.c: Prefixed defaults_extra_file and defaults_group_suffix with 'my' to avoid conflicts with similar named local variables extra/yassl/include/buffer.hpp: Fixed compiler warnings extra/yassl/include/crypto_wrapper.hpp: Fixed compiler warnings extra/yassl/include/yassl_imp.hpp: Fixed compiler warnings extra/yassl/include/yassl_int.hpp: Fixed compiler warnings extra/yassl/src/crypto_wrapper.cpp: Fixed compiler warnings extra/yassl/taocrypt/benchmark/benchmark.cpp: Fixed warnings found with gcc -Wshadow extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/des.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hash.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/hmac.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modarith.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/modes.hpp: Fixed compiler warnings extra/yassl/taocrypt/include/rsa.hpp: Fixed compiler warnings extra/yassl/taocrypt/mySTL/list.hpp: Fixed compiler warnings extra/yassl/taocrypt/src/aes.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/algebra.cpp: Fixed compiler warnings extra/yassl/taocrypt/src/asn.cpp: Fixed compiler warnings extra/yassl/taocrypt/test/test.cpp: Fixed compiler warnings extra/yassl/testsuite/testsuite.cpp: Fixed compiler warnings include/m_ctype.h: Fixed warnings found with gcc -Wshadow include/my_pthread.h: Fixed warnings found with gcc -Wshadow include/my_sys.h: Fixed warnings found with gcc -Wshadow include/my_time.h: Fixed warnings found with gcc -Wshadow include/mysql.h: Fixed warnings found with gcc -Wshadow Added define IS_LONGDATA() to simplify code in libmysql.c libmysql/libmysql.c: Fixed warnings found with gcc -Wshadow (Mostly replaced bind -> my_bind and time -> my_time) libmysqld/lib_sql.cc: Removed not used variables and labels myisam/ft_boolean_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_open.c: Fixed warnings found with gcc -Wshadow myisam/mi_search.c: Fixed warnings found with gcc -Wshadow myisam/mi_unique.c: Fixed compiler warning myisam/myisampack.c: Fixed warnings found with gcc -Wshadow myisam/rt_index.c: Remove not used variables myisam/sort.c: Fixed warnings found with gcc -Wshadow mysql-test/r/mysqlcheck.result: Remove databases and tables possible left by previous test mysql-test/r/mysqltest.result: New test results mysql-test/t/mysql.test: Coverage tests mysql-test/t/mysqlbinlog.test: Coverage tests mysql-test/t/mysqlcheck.test: Remove databases and tables possible left by previous test mysql-test/t/mysqltest.test: Coverage tests mysys/default.c: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions mysys/mf_iocache2.c: Fixed warnings found with gcc -Wshadow mysys/mf_keycache.c: Fixed warnings found with gcc -Wshadow mysys/my_bitmap.c: Fixed warnings found with gcc -Wshadow mysys/sha1.c: Fixed warnings found with gcc -Wshadow ndb/include/kernel/signaldata/ArbitSignalData.hpp: Fixed compiler warning ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings ndb/include/ndbapi/NdbReceiver.hpp: Fixed warnings found with gcc -Wshadow ndb/include/transporter/TransporterDefinitions.hpp: Fixed compiler warning ndb/include/util/InputStream.hpp: Fixed compiler warning ndb/include/util/OutputStream.hpp: Fixed compiler warning ndb/include/util/SimpleProperties.hpp: Fixed compiler warning ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning ndb/include/util/SocketServer.hpp: Fixed compiler warning ndb/src/common/mgmcommon/ConfigRetriever.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/portlib/NdbTick.c: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/SHM_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/transporter/TCP_Transporter.hpp: Fixed compiler warning ndb/src/common/transporter/Transporter.cpp: Removed not used variable ndb/src/common/transporter/TransporterRegistry.cpp: Removed not used variable ndb/src/common/util/Bitmask.cpp: Moved function to avoid warnings of not used function ndb/src/common/util/ConfigValues.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/File.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/Properties.cpp: Fixed warnings found with gcc -Wshadow ndb/src/common/util/SocketClient.cpp: Fixed wrong return value ndb/src/common/util/random.c: Fixed warnings found with gcc -Wshadow ndb/src/common/util/socket_io.cpp: Fixed warnings found with gcc -Wshadow ndb/src/cw/cpcd/APIService.cpp: Removed not used variable ndb/src/cw/cpcd/main.cpp: Removed not used variables ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Removed not used variables ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Removed not used variables ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Fixed compiler warnings ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Removed not used variable ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Removed not used variables ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Removed not used variables ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Removed not used variables ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Fixed compiler warnings ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.cpp: Removed not used variables ndb/src/kernel/blocks/suma/Suma.hpp: Fixed compiler warnings ndb/src/kernel/vm/MetaData.hpp: Fixed compiler warnings ndb/src/mgmapi/LocalConfig.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmapi/mgmapi.cpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmclient/CommandInterpreter.cpp: Removed not used variables ndb/src/mgmsrv/ConfigInfo.cpp: Fixed warnings found with gcc -Wshadow Removed not used variables ndb/src/mgmsrv/ConfigInfo.hpp: Fixed warnings found with gcc -Wshadow ndb/src/mgmsrv/InitConfigFileParser.cpp: Prefixed defaults_file, defaults_group_suffix and defaults_extra_file with 'my' to avoid conflicts with local variables in some functions ndb/src/mgmsrv/MgmtSrvr.cpp: Removed not used variables and functions ndb/src/mgmsrv/MgmtSrvr.hpp: Fixed compiler warnings ndb/src/mgmsrv/Services.cpp: Removed not used variables and functions ndb/src/mgmsrv/main.cpp: Removed not used variable ndb/src/ndbapi/ClusterMgr.hpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Removed not used variables ndb/src/ndbapi/NdbBlob.cpp: Removed not used variables ndb/src/ndbapi/NdbDictionaryImpl.cpp: Removed not used variables ndb/src/ndbapi/NdbIndexOperation.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationDefine.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationExec.cpp: Removed not used variables ndb/src/ndbapi/NdbOperationSearch.cpp: Removed not used variables ndb/src/ndbapi/NdbScanFilter.cpp: Fixed compiler warning ndb/src/ndbapi/NdbScanOperation.cpp: Removed not used variables ndb/src/ndbapi/SignalSender.cpp: Removed not used variables ndb/src/ndbapi/ndb_cluster_connection.cpp: Removed not used variable ndb/tools/delete_all.cpp: Removed not used variable ndb/tools/desc.cpp: Removed not used variable ndb/tools/drop_index.cpp: Removed not used variable ndb/tools/drop_tab.cpp: Removed not used variable ndb/tools/listTables.cpp: Removed not used variable ndb/tools/ndb_config.cpp: Fixed warnings found with gcc -Wshadow Added missing puts(desc) ndb/tools/restore/Restore.hpp: Changed delimiter to define instead of static variable, as the static variable caused a LOT of compiler warnings Fixed compiler warning ndb/tools/restore/consumer.hpp: Fixed compiler warning ndb/tools/restore/restore_main.cpp: Fixed compiler warnings ndb/tools/select_all.cpp: Removed not used variables ndb/tools/select_count.cpp: Removed not used variable server-tools/instance-manager/commands.h: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Fixed compiler warnings server-tools/instance-manager/instance_options.cc: Removed not used variables server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/options.cc: Fixed compiler warnings server-tools/instance-manager/options.h: Fixed compiler warnings server-tools/instance-manager/parse.cc: Removed not used variable server-tools/instance-manager/user_map.cc: Fixed compiler warnings server-tools/instance-manager/user_map.h: Fixed compiler warnings sql/field.cc: Fixed compiler warnings sql/field.h: Fixed compiler warnings sql/filesort.cc: Fixed compiler warnings sql/ha_archive.cc: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_archive.h: Removed table and share arguments from get_share() / free_share() to get rid of compiler warnings sql/ha_federated.cc: Fixed compiler warnings sql/ha_heap.cc: Fixed compiler warnings sql/ha_myisam.cc: Fixed compiler warnings sql/ha_myisammrg.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/handler.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings sql/item.h: Fixed compiler warnings new_item() -> clone_item(), to avoid a lot of warnings with variable 'new_item' el() -> element_index() sql/item_cmpfunc.cc: Fixed compiler warnings sql/item_cmpfunc.h: Fixed compiler warnings sql/item_func.cc: Fixed compiler warnings sql/item_geofunc.cc: Fixed compiler warnings sql/item_row.h: Fixed compiler warnings sql/item_strfunc.cc: Fixed compiler warnings sql/item_subselect.cc: Fixed compiler warnings sql/item_subselect.h: Fixed compiler warnings sql/item_sum.cc: Fixed compiler warnings sql/item_timefunc.cc: Fixed compiler warnings sql/log.cc: Fixed compiler warnings More comments Added #ifdef HAVE_REPLICATION sql/log_event.cc: Fixed compiler warnings sql/log_event.h: Fixed compiler warnings sql/mysql_priv.h: query_id -> global_query_id, to avoid a lot of clashes with function and class variables start_time -> server_start_time sql/mysqld.cc: Fixed compiler warnings: - Removed not used variables - Added #ifndef EMBEDDED_LIBRARY - Fixed shadow warnings sql/net_serv.cc: Fixed compiler warnings sql/opt_range.cc: range -> last_range to avoid shadow warnings Removed not used function print_rowid() sql/opt_range.h: range -> last_range to avoid shadow warnings sql/password.c: Fixed compiler warnings sql/protocol.cc: Fixed compiler warnings sql/repl_failsafe.cc: Fixed compiler warnings sql/set_var.cc: Fixed compiler warnings sql/set_var.h: type() -> show_type() Fixed compiler warnings sql/slave.cc: Fixed compiler warnings sql/sp_head.cc: Fixed compiler warnings sql/sp_head.h: Fixed compiler warnings sql/spatial.cc: Fixed compiler warnings sql/spatial.h: length() -> geom_length() to avoid compiler warnings wkb_end -> wkb_last to avoid compiler warnings with local variables named 'wkb_end' sql/sql_cache.h: Fixed compiler warnings sql/sql_class.cc: Fixed compiler warnings sql/sql_class.h: log -> log_xid() to avoid compiler warnings Fixed shadow compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Fixed compiler warnings sql/sql_lex.cc: Fixed compiler warnings sql/sql_lex.h: res -> saved_error to make the meaning of the variable clear and avoid shadow warnings sql/sql_load.cc: Fixed compiler warnings sql/sql_parse.cc: Fixed compiler warnings sql/sql_prepare.cc: Fixed compiler warnings sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/sql_string.cc: Fixed compiler warnings sql/sql_string.h: Fixed compiler warnings sql/sql_table.cc: Fixed compiler warnings sql/sql_trigger.cc: Fixed compiler warnings sql/sql_trigger.h: table -> trigger_table to avoid warnings from local variables sql/sql_union.cc: Fixed compiler warnings (mainly res -> saved_error) sql-common/client.c: Removed not used variable sql-common/my_time.c: Removed not used variable time -> my_time sql/sql_update.cc: Removed not used variable sql/sql_view.cc: Removed not used variable sql/sql_yacc.yy: Removed not used variable sql/table.cc: Removed not used variable sql/tztime.cc: Removed not used variable sql/unireg.cc: Removed not used variable strings/ctype-bin.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-cp932.c: Fixed compiler warnings strings/ctype-eucjpms.c: Fixed compiler warnings strings/ctype-mb.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-simple.c: mblen -> mb_len to avoid compiler warnings with local variable mblen exp -> exponent strings/ctype-sjis.c: Fixed compiler warnings strings/ctype-uca.c: mblen -> mb_len to avoid compiler warnings with local variable mblen strings/ctype-ujis.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings strings/my_vsnprintf.c: Added comment strings/strtod.c: Fixed compiler warnings tests/mysql_client_test.c: Fixed compiler warnings (Biggest part of patch is to not get a conflict with global function 'bind')
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc197
1 files changed, 95 insertions, 102 deletions
diff --git a/sql/field.cc b/sql/field.cc
index e0b97e80ed4..b59684afdf0 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1392,12 +1392,12 @@ my_decimal* Field_num::val_decimal(my_decimal *decimal_value)
Field_str::Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg,
- struct st_table *table_arg,CHARSET_INFO *charset)
+ struct st_table *table_arg, CHARSET_INFO *charset_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg)
{
- field_charset=charset;
- if (charset->state & MY_CS_BINSORT)
+ field_charset= charset_arg;
+ if (charset_arg->state & MY_CS_BINSORT)
flags|=BINARY_FLAG;
field_derivation= DERIVATION_IMPLICIT;
}
@@ -1502,7 +1502,7 @@ bool Field::get_time(TIME *ltime)
Needs to be changed if/when we want to support different time formats
*/
-int Field::store_time(TIME *ltime, timestamp_type type)
+int Field::store_time(TIME *ltime, timestamp_type type_arg)
{
char buff[MAX_DATE_STRING_REP_LENGTH];
uint length= (uint) my_TIME_to_str(ltime, buff);
@@ -2197,13 +2197,13 @@ Field_new_decimal::Field_new_decimal(char *ptr_arg,
Field_new_decimal::Field_new_decimal(uint32 len_arg,
- bool maybe_null,
+ bool maybe_null_arg,
const char *name,
struct st_table *t_arg,
uint8 dec_arg,
bool unsigned_arg)
:Field_num((char*) 0, len_arg,
- maybe_null ? (uchar*) "": 0, 0,
+ maybe_null_arg ? (uchar*) "": 0, 0,
NONE, name, t_arg,
dec_arg,
0, unsigned_arg)
@@ -2306,7 +2306,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value)
int Field_new_decimal::store(const char *from, uint length,
- CHARSET_INFO *charset)
+ CHARSET_INFO *charset_arg)
{
int err;
my_decimal decimal_value;
@@ -2314,7 +2314,7 @@ int Field_new_decimal::store(const char *from, uint length,
if ((err= str2my_decimal(E_DEC_FATAL_ERROR &
~(E_DEC_OVERFLOW | E_DEC_BAD_NUM),
- from, length, charset, &decimal_value)) &&
+ from, length, charset_arg, &decimal_value)) &&
table->in_use->abort_on_warning)
{
/* Because "from" is not NUL-terminated and we use %s in the ER() */
@@ -3198,25 +3198,6 @@ void Field_medium::sql_type(String &res) const
** long int
****************************************************************************/
-/*
- A helper function to check whether the next character
- in the string "s" is MINUS SIGN.
-*/
-#ifdef HAVE_CHARSET_ucs2
-static bool test_if_minus(CHARSET_INFO *cs,
- const char *s, const char *e)
-{
- my_wc_t wc;
- return cs->cset->mb_wc(cs, &wc, (uchar*) s, (uchar*) e) > 0 && wc == '-';
-}
-#else
-/*
- If not UCS2 support is compiled then it is easier
-*/
-#define test_if_minus(cs, s, e) (*s == '-')
-#endif
-
-
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{
long store_tmp;
@@ -4807,7 +4788,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
}
-int Field_time::store_time(TIME *ltime, timestamp_type type)
+int Field_time::store_time(TIME *ltime, timestamp_type time_type)
{
long tmp= ((ltime->month ? 0 : ltime->day * 24L) + ltime->hour) * 10000L +
(ltime->minute * 100 + ltime->second);
@@ -5402,11 +5383,12 @@ int Field_newdate::store(longlong nr, bool unsigned_val)
}
-int Field_newdate::store_time(TIME *ltime,timestamp_type type)
+int Field_newdate::store_time(TIME *ltime, timestamp_type time_type)
{
long tmp;
int error= 0;
- if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME)
+ if (time_type == MYSQL_TIMESTAMP_DATE ||
+ time_type == MYSQL_TIMESTAMP_DATETIME)
{
tmp=ltime->year*16*32+ltime->month*32+ltime->day;
if (check_date(ltime, tmp != 0,
@@ -5621,7 +5603,7 @@ int Field_datetime::store(longlong nr, bool unsigned_val)
}
-int Field_datetime::store_time(TIME *ltime,timestamp_type type)
+int Field_datetime::store_time(TIME *ltime,timestamp_type time_type)
{
longlong tmp;
int error= 0;
@@ -5629,7 +5611,8 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type)
We don't perform range checking here since values stored in TIME
structure always fit into DATETIME range.
*/
- if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME)
+ if (time_type == MYSQL_TIMESTAMP_DATE ||
+ time_type == MYSQL_TIMESTAMP_DATETIME)
{
tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+
(ltime->hour*10000L+ltime->minute*100+ltime->second));
@@ -6004,32 +5987,32 @@ int Field_str::store(double nr)
char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
uint length;
bool use_scientific_notation= TRUE;
- uint char_length= field_length / charset()->mbmaxlen;
+ uint local_char_length= field_length / charset()->mbmaxlen;
/*
Check fabs(nr) against longest value that can be stored in field,
which depends on whether the value is < 1 or not, and negative or not
*/
double anr= fabs(nr);
int neg= (nr < 0.0) ? 1 : 0;
- if (char_length > 4 && char_length < 32 &&
- (anr < 1.0 ? anr > 1/(log_10[max(0,(int) char_length-neg-2)]) /* -2 for "0." */
- : anr < log_10[char_length-neg]-1))
+ if (local_char_length > 4 && local_char_length < 32 &&
+ (anr < 1.0 ? anr > 1/(log_10[max(0,(int) local_char_length-neg-2)]) /* -2 for "0." */
+ : anr < log_10[local_char_length-neg]-1))
use_scientific_notation= FALSE;
length= (uint) my_sprintf(buff, (buff, "%-.*g",
(use_scientific_notation ?
- max(0, (int)char_length-neg-5) :
- char_length),
+ max(0, (int)local_char_length-neg-5) :
+ local_char_length),
nr));
/*
+1 below is because "precision" in %g above means the
max. number of significant digits, not the output width.
Thus the width can be larger than number of significant digits by 1
(for decimal point)
- the test for char_length < 5 is for extreme cases,
+ the test for local_char_length < 5 is for extreme cases,
like inserting 500.0 in char(1)
*/
- DBUG_ASSERT(char_length < 5 || length <= char_length+1);
+ DBUG_ASSERT(local_char_length < 5 || length <= local_char_length+1);
return store((const char *) buff, length, charset());
}
@@ -6146,10 +6129,11 @@ void Field_string::sql_type(String &res) const
char *Field_string::pack(char *to, const char *from, uint max_length)
{
uint length= min(field_length,max_length);
- uint char_length= max_length/field_charset->mbmaxlen;
- if (length > char_length)
- char_length= my_charpos(field_charset, from, from+length, char_length);
- set_if_smaller(length, char_length);
+ uint local_char_length= max_length/field_charset->mbmaxlen;
+ if (length > local_char_length)
+ local_char_length= my_charpos(field_charset, from, from+length,
+ local_char_length);
+ set_if_smaller(length, local_char_length);
while (length && from[length-1] == ' ')
length--;
*to++= (char) (uchar) length;
@@ -6233,15 +6217,15 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length,
int Field_string::pack_cmp(const char *key, uint length,
my_bool insert_or_update)
{
- uint row_length, key_length;
+ uint row_length, local_key_length;
char *end;
if (length > 255)
{
- key_length= uint2korr(key);
+ local_key_length= uint2korr(key);
key+= 2;
}
else
- key_length= (uint) (uchar) *key++;
+ local_key_length= (uint) (uchar) *key++;
/* Only use 'length' of key, not field_length */
end= ptr + length;
@@ -6251,7 +6235,7 @@ int Field_string::pack_cmp(const char *key, uint length,
return field_charset->coll->strnncollsp(field_charset,
(const uchar*) ptr, row_length,
- (const uchar*) key, key_length,
+ (const uchar*) key, local_key_length,
insert_or_update);
}
@@ -6273,10 +6257,10 @@ uint Field_string::max_packed_col_length(uint max_length)
Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table,
bool keep_type)
{
- Field *new_field;
+ Field *field;
if (type() != MYSQL_TYPE_VAR_STRING || keep_type)
- new_field= Field::new_field(root, new_table, keep_type);
+ field= Field::new_field(root, new_table, keep_type);
else
{
@@ -6285,7 +6269,7 @@ Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table,
This is done to ensure that ALTER TABLE will convert old VARCHAR fields
to now VARCHAR fields.
*/
- new_field= new Field_varstring(field_length, maybe_null(),
+ field= new Field_varstring(field_length, maybe_null(),
field_name, new_table, charset());
/*
Normally orig_table is different from table only if field was created
@@ -6293,9 +6277,9 @@ Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table,
not applicable. But we still need to preserve the original field
metadata for the client-server protocol.
*/
- new_field->orig_table= orig_table;
+ field->orig_table= orig_table;
}
- return new_field;
+ return field;
}
/****************************************************************************
@@ -6436,11 +6420,11 @@ int Field_varstring::cmp(const char *a_ptr, const char *b_ptr)
int Field_varstring::key_cmp(const byte *key_ptr, uint max_key_length)
{
uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr);
- uint char_length= max_key_length / field_charset->mbmaxlen;
+ uint local_char_length= max_key_length / field_charset->mbmaxlen;
- char_length= my_charpos(field_charset, ptr + length_bytes,
- ptr + length_bytes + length, char_length);
- set_if_smaller(length, char_length);
+ local_char_length= my_charpos(field_charset, ptr + length_bytes,
+ ptr + length_bytes + length, local_char_length);
+ set_if_smaller(length, local_char_length);
return field_charset->coll->strnncollsp(field_charset,
(const uchar*) ptr + length_bytes,
length,
@@ -6550,13 +6534,14 @@ char *Field_varstring::pack(char *to, const char *from, uint max_length)
char *Field_varstring::pack_key(char *to, const char *key, uint max_length)
{
uint length= length_bytes == 1 ? (uint) (uchar) *key : uint2korr(key);
- uint char_length= ((field_charset->mbmaxlen > 1) ?
+ uint local_char_length= ((field_charset->mbmaxlen > 1) ?
max_length/field_charset->mbmaxlen : max_length);
key+= length_bytes;
- if (length > char_length)
+ if (length > local_char_length)
{
- char_length= my_charpos(field_charset, key, key+length, char_length);
- set_if_smaller(length, char_length);
+ local_char_length= my_charpos(field_charset, key, key+length,
+ local_char_length);
+ set_if_smaller(length, local_char_length);
}
*to++= (char) (length & 255);
if (max_length > 255)
@@ -6652,11 +6637,12 @@ const char *Field_varstring::unpack(char *to, const char *from)
}
-int Field_varstring::pack_cmp(const char *a, const char *b, uint key_length,
+int Field_varstring::pack_cmp(const char *a, const char *b,
+ uint key_length_arg,
my_bool insert_or_update)
{
uint a_length, b_length;
- if (key_length > 255)
+ if (key_length_arg > 255)
{
a_length=uint2korr(a); a+= 2;
b_length=uint2korr(b); b+= 2;
@@ -6673,26 +6659,28 @@ int Field_varstring::pack_cmp(const char *a, const char *b, uint key_length,
}
-int Field_varstring::pack_cmp(const char *b, uint key_length,
+int Field_varstring::pack_cmp(const char *b, uint key_length_arg,
my_bool insert_or_update)
{
char *a= ptr+ length_bytes;
uint a_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr);
uint b_length;
- uint char_length= ((field_charset->mbmaxlen > 1) ?
- key_length / field_charset->mbmaxlen : key_length);
+ uint local_char_length= ((field_charset->mbmaxlen > 1) ?
+ key_length_arg / field_charset->mbmaxlen :
+ key_length_arg);
- if (key_length > 255)
+ if (key_length_arg > 255)
{
b_length=uint2korr(b); b+= HA_KEY_BLOB_LENGTH;
}
else
b_length= (uint) (uchar) *b++;
- if (a_length > char_length)
+ if (a_length > local_char_length)
{
- char_length= my_charpos(field_charset, a, a+a_length, char_length);
- set_if_smaller(a_length, char_length);
+ local_char_length= my_charpos(field_charset, a, a+a_length,
+ local_char_length);
+ set_if_smaller(a_length, local_char_length);
}
return field_charset->coll->strnncollsp(field_charset,
@@ -6717,13 +6705,15 @@ uint Field_varstring::max_packed_col_length(uint max_length)
}
-void Field_varstring::get_key_image(char *buff, uint length, imagetype type)
+void Field_varstring::get_key_image(char *buff, uint length,
+ imagetype type_arg)
{
uint f_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr);
- uint char_length= length / field_charset->mbmaxlen;
+ uint local_char_length= length / field_charset->mbmaxlen;
char *pos= ptr+length_bytes;
- char_length= my_charpos(field_charset, pos, pos + f_length, char_length);
- set_if_smaller(f_length, char_length);
+ local_char_length= my_charpos(field_charset, pos, pos + f_length,
+ local_char_length);
+ set_if_smaller(f_length, local_char_length);
/* Key is always stored with 2 bytes */
int2store(buff,f_length);
memcpy(buff+HA_KEY_BLOB_LENGTH, pos, f_length);
@@ -7106,13 +7096,13 @@ int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr,
/* The following is used only when comparing a key */
-void Field_blob::get_key_image(char *buff, uint length, imagetype type)
+void Field_blob::get_key_image(char *buff, uint length, imagetype type_arg)
{
uint32 blob_length= get_length(ptr);
char *blob;
#ifdef HAVE_SPATIAL
- if (type == itMBR)
+ if (type_arg == itMBR)
{
const char *dummy;
MBR mbr;
@@ -7140,10 +7130,10 @@ void Field_blob::get_key_image(char *buff, uint length, imagetype type)
#endif /*HAVE_SPATIAL*/
get_ptr(&blob);
- uint char_length= length / field_charset->mbmaxlen;
- char_length= my_charpos(field_charset, blob, blob + blob_length,
- char_length);
- set_if_smaller(blob_length, char_length);
+ uint local_char_length= length / field_charset->mbmaxlen;
+ local_char_length= my_charpos(field_charset, blob, blob + blob_length,
+ local_char_length);
+ set_if_smaller(blob_length, local_char_length);
if ((uint32) length > blob_length)
{
@@ -7172,9 +7162,10 @@ int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length)
uint blob_length=get_length(ptr);
memcpy_fixed(&blob1,ptr+packlength,sizeof(char*));
CHARSET_INFO *cs= charset();
- uint char_length= max_key_length / cs->mbmaxlen;
- char_length= my_charpos(cs, blob1, blob1+blob_length, char_length);
- set_if_smaller(blob_length, char_length);
+ uint local_char_length= max_key_length / cs->mbmaxlen;
+ local_char_length= my_charpos(cs, blob1, blob1+blob_length,
+ local_char_length);
+ set_if_smaller(blob_length, local_char_length);
return Field_blob::cmp(blob1, blob_length,
(char*) key_ptr+HA_KEY_BLOB_LENGTH,
uint2korr(key_ptr));
@@ -7296,11 +7287,11 @@ const char *Field_blob::unpack(char *to, const char *from)
/* Keys for blobs are like keys on varchars */
-int Field_blob::pack_cmp(const char *a, const char *b, uint key_length,
+int Field_blob::pack_cmp(const char *a, const char *b, uint key_length_arg,
my_bool insert_or_update)
{
uint a_length, b_length;
- if (key_length > 255)
+ if (key_length_arg > 255)
{
a_length=uint2korr(a); a+=2;
b_length=uint2korr(b); b+=2;
@@ -7317,19 +7308,19 @@ int Field_blob::pack_cmp(const char *a, const char *b, uint key_length,
}
-int Field_blob::pack_cmp(const char *b, uint key_length,
+int Field_blob::pack_cmp(const char *b, uint key_length_arg,
my_bool insert_or_update)
{
char *a;
+ uint a_length, b_length;
memcpy_fixed(&a,ptr+packlength,sizeof(char*));
if (!a)
- return key_length > 0 ? -1 : 0;
- uint a_length=get_length(ptr);
- uint b_length;
+ return key_length_arg > 0 ? -1 : 0;
- if (key_length > 255)
+ a_length= get_length(ptr);
+ if (key_length_arg > 255)
{
- b_length=uint2korr(b); b+=2;
+ b_length= uint2korr(b); b+=2;
}
else
b_length= (uint) (uchar) *b++;
@@ -7346,13 +7337,14 @@ char *Field_blob::pack_key(char *to, const char *from, uint max_length)
char *save=ptr;
ptr=(char*) from;
uint32 length=get_length(); // Length of from string
- uint char_length= ((field_charset->mbmaxlen > 1) ?
+ uint local_char_length= ((field_charset->mbmaxlen > 1) ?
max_length/field_charset->mbmaxlen : max_length);
if (length)
get_ptr((char**) &from);
- if (length > char_length)
- char_length= my_charpos(field_charset, from, from+length, char_length);
- set_if_smaller(length, char_length);
+ if (length > local_char_length)
+ local_char_length= my_charpos(field_charset, from, from+length,
+ local_char_length);
+ set_if_smaller(length, local_char_length);
*to++= (uchar) length;
if (max_length > 255) // 2 byte length
*to++= (uchar) (length >> 8);
@@ -7439,7 +7431,7 @@ uint Field_blob::max_packed_col_length(uint max_length)
#ifdef HAVE_SPATIAL
-void Field_geom::get_key_image(char *buff, uint length, imagetype type)
+void Field_geom::get_key_image(char *buff, uint length, imagetype type_arg)
{
char *blob;
const char *dummy;
@@ -7537,7 +7529,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
goto err;
wkb_type= uint4korr(from + SRID_SIZE + 1);
if (wkb_type < (uint32) Geometry::wkb_point ||
- wkb_type > (uint32) Geometry::wkb_end)
+ wkb_type > (uint32) Geometry::wkb_last)
goto err;
Field_blob::store_length(length);
if (table->copy_blobs || length <= MAX_FIELD_WIDTH)
@@ -8161,7 +8153,7 @@ int Field_bit::cmp_offset(uint row_offset)
}
-void Field_bit::get_key_image(char *buff, uint length, imagetype type)
+void Field_bit::get_key_image(char *buff, uint length, imagetype type_arg)
{
if (bit_len)
{
@@ -8323,7 +8315,7 @@ void create_field::create_length_to_internal_length(void)
void create_field::init_for_tmp_table(enum_field_types sql_type_arg,
- uint32 length_arg, uint32 decimals,
+ uint32 length_arg, uint32 decimals_arg,
bool maybe_null, bool is_unsigned)
{
field_name= "";
@@ -8334,7 +8326,7 @@ void create_field::init_for_tmp_table(enum_field_types sql_type_arg,
charset= &my_charset_bin;
geom_type= Field::GEOM_GEOMETRY;
pack_flag= (FIELDFLAG_NUMBER |
- ((decimals & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT) |
+ ((decimals_arg & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT) |
(maybe_null ? FIELDFLAG_MAYBE_NULL : 0) |
(is_unsigned ? 0 : FIELDFLAG_DECIMAL));
}
@@ -9039,12 +9031,13 @@ create_field::create_field(Field *old_field,Field *orig_field)
maximum possible display length for blob
SYNOPSIS
- Field_blob::max_length()
+ Field_blob::max_display_length()
RETURN
length
*/
-uint32 Field_blob::max_length()
+
+uint32 Field_blob::max_display_length()
{
switch (packlength)
{