summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqltest.c22
-rw-r--r--include/my_sys.h2
-rw-r--r--include/mysql.h1
-rw-r--r--innobase/srv/srv0start.c13
-rw-r--r--libmysql/libmysql.c10
-rw-r--r--libmysql/libmysql.def1
-rw-r--r--myisam/myisam_ftdump.c2
-rw-r--r--myisam/myisamchk.c2
-rw-r--r--myisam/rt_test.c3
-rw-r--r--mysys/hash.c57
-rw-r--r--mysys/my_bitmap.c4
-rw-r--r--mysys/my_gethwaddr.c2
-rw-r--r--ndb/src/ndbapi/ndberror.c3
-rw-r--r--regex/regcomp.c2
-rw-r--r--regex/regcomp.ih2
-rw-r--r--sql-common/client.c2
-rw-r--r--sql/examples/ha_archive.cc5
-rw-r--r--sql/field.cc25
-rw-r--r--sql/ha_innodb.cc4
-rw-r--r--sql/ha_ndbcluster.cc116
-rw-r--r--sql/ha_ndbcluster.h6
-rw-r--r--sql/handler.cc38
-rw-r--r--sql/item.cc64
-rw-r--r--sql/item_cmpfunc.cc4
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/item_strfunc.cc39
-rw-r--r--sql/log_event.h2
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/sql_acl.cc47
-rw-r--r--sql/sql_base.cc13
-rw-r--r--sql/sql_help.cc2
-rw-r--r--sql/sql_lex.cc12
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_prepare.cc4
-rw-r--r--sql/sql_select.cc32
-rw-r--r--sql/sql_show.cc49
-rw-r--r--sql/sql_string.cc3
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/sql_yacc.yy4
-rw-r--r--strings/Makefile.am2
-rw-r--r--strings/xml.c7
-rw-r--r--tests/client_test.c14
43 files changed, 373 insertions, 261 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index d2d110c7954..deaaa4dca16 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -58,13 +58,6 @@
#include <stdarg.h>
#include <sys/stat.h>
#include <violite.h>
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 256
-#endif
#define MAX_QUERY 131072
#define MAX_VAR_NAME 256
@@ -2105,10 +2098,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
embedded_server_arg_count=1;
embedded_server_args[0]= (char*) "";
}
- embedded_server_args[embedded_server_arg_count++]=
- my_strdup(argument, MYF(MY_FAE));
- if (embedded_server_arg_count == MAX_SERVER_ARGS ||
- !embedded_server_args[embedded_server_arg_count-1])
+ if (embedded_server_arg_count == MAX_SERVER_ARGS-1 ||
+ !(embedded_server_args[embedded_server_arg_count++]=
+ my_strdup(argument, MYF(MY_FAE))))
{
die("Can't use server argument");
}
@@ -2166,7 +2158,7 @@ char* safe_str_append(char* buf, const char* str, int size)
void str_to_file(const char* fname, char* str, int size)
{
int fd;
- char buff[MAXPATHLEN];
+ char buff[FN_REFLEN];
if (!test_if_hard_path(fname))
{
strxmov(buff, opt_basedir, fname, NullS);
@@ -2979,10 +2971,10 @@ static void timer_output(void)
{
if (timer_file)
{
- char buf[1024];
+ char buf[32], *end;
ulonglong timer= timer_now() - timer_start;
- sprintf(buf,"%llu",timer);
- str_to_file(timer_file,buf,strlen(buf));
+ end= longlong2str(timer, buf, 10);
+ str_to_file(timer_file,buf, (int) (end-buf));
}
}
diff --git a/include/my_sys.h b/include/my_sys.h
index 271e0ea0bcb..01a7482e4d0 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -726,7 +726,7 @@ extern void my_free_lock(byte *ptr,myf flags);
#endif
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
-#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; } while(0)
+#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size);
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
diff --git a/include/mysql.h b/include/mysql.h
index cf5af6ce189..1c886020fdb 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -506,6 +506,7 @@ char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
unsigned long *length));
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int STDCALL mysql_thread_safe(void);
+my_bool STDCALL mysql_embedded(void);
MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con);
MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
const char* host,
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index 8e48034e09c..9709f5235de 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -95,6 +95,19 @@ static char* srv_monitor_file_name;
#define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
#define SRV_MAX_N_PENDING_SYNC_IOS 100
+
+/* Avoid warnings when using purify */
+
+#ifdef HAVE_purify
+static int inno_bcmp(register const char *s1, register const char *s2,
+ register uint len)
+{
+ while (len-- != 0 && *s1++ == *s2++) ;
+ return len+1;
+}
+#define memcmp(A,B,C) inno_bcmp((A),(B),(C))
+#endif
+
/*************************************************************************
Reads the data files and their sizes from a character string given in
the .cnf file. */
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index ef926e2f93d..deb09c856ec 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1516,6 +1516,16 @@ uint STDCALL mysql_thread_safe(void)
#endif
}
+
+my_bool STDCALL mysql_embedded(void)
+{
+#ifdef EMBEDDED_LIBRARY
+ return 1;
+#else
+ return 0;
+#endif
+}
+
/****************************************************************************
Some support functions
****************************************************************************/
diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def
index 38ac9505e4b..bc91e90a41c 100644
--- a/libmysql/libmysql.def
+++ b/libmysql/libmysql.def
@@ -144,3 +144,4 @@ EXPORTS
mysql_rpl_probe
mysql_rpl_query_type
mysql_slave_query
+ mysql_embedded
diff --git a/myisam/myisam_ftdump.c b/myisam/myisam_ftdump.c
index 8219c19848a..54b2cc77965 100644
--- a/myisam/myisam_ftdump.c
+++ b/myisam/myisam_ftdump.c
@@ -68,7 +68,7 @@ int main(int argc,char *argv[])
struct { MI_INFO *info; } aio0, *aio=&aio0; /* for GWS_IN_USE */
MY_INIT(argv[0]);
- if (error=handle_options(&argc, &argv, my_long_options, get_one_option))
+ if ((error= handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(error);
if (count || dump)
verbose=0;
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index 98cbc838d31..6c0c30b7056 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -1695,7 +1695,7 @@ err:
static my_bool not_killed= 0;
-volatile my_bool *killed_ptr(MI_CHECK *param)
+volatile my_bool *killed_ptr(MI_CHECK *param __attribute__((unused)))
{
return &not_killed; /* always NULL */
}
diff --git a/myisam/rt_test.c b/myisam/rt_test.c
index 5e883e223b3..4f04aa11fce 100644
--- a/myisam/rt_test.c
+++ b/myisam/rt_test.c
@@ -425,6 +425,7 @@ static void create_record1(char *record,uint rownr)
}
}
+#ifdef NOT_USED
static void create_record0(char *record,uint rownr)
{
@@ -447,6 +448,8 @@ static void create_record0(char *record,uint rownr)
}
}
+#endif
+
static void create_record(char *record,uint rownr)
{
int i;
diff --git a/mysys/hash.c b/mysys/hash.c
index 6f2788ddce7..cf0f1d2dde6 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -72,19 +72,48 @@ _hash_init(HASH *hash,CHARSET_INFO *charset,
}
-void hash_free(HASH *hash)
+/*
+ Call hash->free on all elements in hash.
+
+ SYNOPSIS
+ hash_free_elements()
+ hash hash table
+
+ NOTES:
+ Sets records to 0
+*/
+
+static inline void hash_free_elements(HASH *hash)
{
- DBUG_ENTER("hash_free");
if (hash->free)
{
- uint i,records;
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
- for (i=0,records=hash->records ; i < records ; i++)
- (*hash->free)(data[i].data);
- hash->free=0;
+ HASH_LINK *end= data + hash->records;
+ while (data < end)
+ (*hash->free)((data++)->data);
}
- delete_dynamic(&hash->array);
hash->records=0;
+}
+
+
+/*
+ Free memory used by hash.
+
+ SYNOPSIS
+ hash_free()
+ hash the hash to delete elements of
+
+ NOTES: Hash can't be reused wuthing calling hash_init again.
+*/
+
+void hash_free(HASH *hash)
+{
+ DBUG_ENTER("hash_free");
+ DBUG_PRINT("enter",("hash: 0x%lxd",hash));
+
+ hash_free_elements(hash);
+ hash->free= 0;
+ delete_dynamic(&hash->array);
DBUG_VOID_RETURN;
}
@@ -94,21 +123,17 @@ void hash_free(HASH *hash)
SYNOPSIS
hash_reset()
- hash the hash to delete elements of
+ hash the hash to delete elements of
*/
void hash_reset(HASH *hash)
{
DBUG_ENTER("hash_reset");
- if (hash->free)
- {
- HASH_LINK *link= dynamic_element(&hash->array, 0, HASH_LINK*);
- HASH_LINK *end= link + hash->records;
- for (; link < end; ++link)
- (*hash->free)(link->data);
- }
+ DBUG_PRINT("enter",("hash: 0x%lxd",hash));
+
+ hash_free_elements(hash);
reset_dynamic(&hash->array);
- hash->records= 0;
+ /* Set row pointers so that the hash can be reused at once */
hash->blength= 1;
hash->current_record= NO_RECORD;
DBUG_VOID_RETURN;
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 3a09255b0b0..ca75842ffcf 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -38,7 +38,7 @@
#include <m_string.h>
-inline void bitmap_lock(MY_BITMAP *map)
+static inline void bitmap_lock(MY_BITMAP *map)
{
#ifdef THREAD
if (map->mutex)
@@ -47,7 +47,7 @@ inline void bitmap_lock(MY_BITMAP *map)
}
-inline void bitmap_unlock(MY_BITMAP *map)
+static inline void bitmap_unlock(MY_BITMAP *map)
{
#ifdef THREAD
if (map->mutex)
diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c
index 72f1cb975c4..222abe81933 100644
--- a/mysys/my_gethwaddr.c
+++ b/mysys/my_gethwaddr.c
@@ -107,7 +107,7 @@ my_bool my_gethwaddr(uchar *to __attribute__((unused)))
}
#endif
-#else MAIN
+#else /* MAIN */
int main(int argc __attribute__((unused)),char **argv)
{
uchar mac[6];
diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c
index 49fbe32d098..fffef023fbc 100644
--- a/ndb/src/ndbapi/ndberror.c
+++ b/ndb/src/ndbapi/ndberror.c
@@ -492,6 +492,7 @@ static
const
int NbClassification = sizeof(StatusClassificationMapping)/sizeof(ErrorStatusClassification);
+#ifdef NOT_USED
/**
* Complete all fields of an NdbError given the error code
* and details
@@ -507,7 +508,7 @@ set(ndberror_struct * error, int code, const char * details, ...){
va_end(ap);
}
}
-
+#endif
void
ndberror_update(ndberror_struct * error){
diff --git a/regex/regcomp.c b/regex/regcomp.c
index 31899609e3c..5f0351c32aa 100644
--- a/regex/regcomp.c
+++ b/regex/regcomp.c
@@ -1183,6 +1183,7 @@ register cset *cs;
return(n);
}
+#ifdef USE_ORIG_REGEX_CODE
/*
- mcadd - add a collating element to a cset
== static void mcadd(register struct parse *p, register cset *cs, \
@@ -1209,6 +1210,7 @@ register char *cp;
(void) strcpy(cs->multis + oldend - 1, cp);
cs->multis[cs->smultis - 1] = '\0';
}
+#endif
#ifdef NOT_USED
/*
diff --git a/regex/regcomp.ih b/regex/regcomp.ih
index 32f1f6e89eb..5deba89217a 100644
--- a/regex/regcomp.ih
+++ b/regex/regcomp.ih
@@ -27,7 +27,9 @@ static void freeset(register struct parse *p, register cset *cs);
static int freezeset(register struct parse *p, register cset *cs);
static int firstch(register struct parse *p, register cset *cs);
static int nch(register struct parse *p, register cset *cs);
+#ifdef USE_ORIG_REGEX_CODE
static void mcadd(register struct parse *p, register cset *cs, register char *cp);
+#endif
#ifdef NOT_USED
static void mcsub(register cset *cs, register char *cp);
static int mcin(register cset *cs, register char *cp);
diff --git a/sql-common/client.c b/sql-common/client.c
index 43e116eb0b6..9fca38f3857 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -2249,7 +2249,7 @@ static void mysql_close_free(MYSQL *mysql)
stmt_list pointer to mysql->stmts
*/
-void mysql_detach_stmt_list(LIST **stmt_list)
+void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)))
{
#ifdef MYSQL_CLIENT
/* Reset connection handle in all prepared statements. */
diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc
index c7d08772109..6fbfb3f9f9d 100644
--- a/sql/examples/ha_archive.cc
+++ b/sql/examples/ha_archive.cc
@@ -103,14 +103,15 @@
rows - This is an unsigned long long which is the number of rows in the data
file.
check point - Reserved for future use
- dirty - Status of the file, whether or not its values are the latest. This flag
- is what causes a repair to occur
+ dirty - Status of the file, whether or not its values are the latest. This
+ flag is what causes a repair to occur
The data file:
check - Just an int of 254 to make sure that the the file we are opening was
never corrupted.
version - The current version of the file format.
data - The data is stored in a "row +blobs" format.
+*/
/* Variables for archive share methods */
pthread_mutex_t archive_mutex;
diff --git a/sql/field.cc b/sql/field.cc
index 3dc1375dff3..e7e8ec736ef 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -304,14 +304,11 @@ bool Field::field_cast_compatible(Field::field_cast_enum type)
{
DBUG_ASSERT(type != FIELD_CAST_STOP);
Field::field_cast_enum *array= field_cast_array[field_cast_type()];
- uint i= 0;
- Field::field_cast_enum tp;
- do
+ while (*array != FIELD_CAST_STOP)
{
- tp= array[i++];
- if (tp == type)
+ if (*(array++) == type)
return 1;
- } while (tp != FIELD_CAST_STOP);
+ }
return 0;
}
@@ -4438,13 +4435,9 @@ char *Field_string::pack(char *to, const char *from, uint max_length)
while (end > from && end[-1] == ' ')
end--;
length= (end-from);
+ *to++= (char) (uchar) length;
if (field_length > 255)
- {
- int2store(to, length);
- to+= 2;
- }
- else
- *to++= (char) (uchar) length;
+ *to++= (char) (uchar) (length >> 8);
memcpy(to, from, (int) length);
return to+length;
}
@@ -4459,13 +4452,9 @@ char *Field_string::pack_key(char *to, const char *from, uint max_length)
set_if_smaller(length, char_length);
while (length && from[length-1] == ' ')
length--;
+ *to++= (char) (uchar) length;
if (field_length > 255)
- {
- int2store(to, length);
- to+= 2;
- }
- else
- *to++= (char) (uchar) length;
+ *to++= (char) (uchar) (length >> 8);
memcpy(to, from, length);
return to+length;
}
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 35a51837449..133ea3c9c7c 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -878,7 +878,7 @@ innobase_init(void)
Note that when using the embedded server, the datadirectory is not
necessarily the current directory of this program. */
- if (mysql_embedded) {
+ if (mysqld_embedded) {
default_path = mysql_real_data_home;
fil_path_to_mysql_datadir = mysql_real_data_home;
} else {
@@ -1016,7 +1016,7 @@ innobase_init(void)
srv_max_n_open_files = (ulint) innobase_open_files;
srv_innodb_status = (ibool) innobase_create_status_file;
- srv_print_verbose_log = mysql_embedded ? 0 : 1;
+ srv_print_verbose_log = mysqld_embedded ? 0 : 1;
/* Store the default charset-collation number of this MySQL
installation */
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index fbfe5c5e872..61316317691 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -65,7 +65,7 @@ typedef NdbDictionary::Table NDBTAB;
typedef NdbDictionary::Index NDBINDEX;
typedef NdbDictionary::Dictionary NDBDICT;
-bool ndbcluster_inited= false;
+bool ndbcluster_inited= FALSE;
static Ndb* g_ndb= NULL;
static Ndb_cluster_connection* g_ndb_cluster_connection= NULL;
@@ -151,8 +151,10 @@ inline
int execute_no_commit(ha_ndbcluster *h, NdbConnection *trans)
{
int m_batch_execute= 0;
- if (false && m_batch_execute)
+#ifdef NOT_USED
+ if (m_batch_execute)
return 0;
+#endif
return trans->execute(NoCommit,AbortOnError,1);
}
@@ -160,8 +162,10 @@ inline
int execute_commit(ha_ndbcluster *h, NdbConnection *trans)
{
int m_batch_execute= 0;
- if (false && m_batch_execute)
+#ifdef NOT_USED
+ if (m_batch_execute)
return 0;
+#endif
return trans->execute(Commit,AbortOnError,1);
}
@@ -169,8 +173,10 @@ inline
int execute_no_commit_ie(ha_ndbcluster *h, NdbConnection *trans)
{
int m_batch_execute= 0;
- if (false && m_batch_execute)
+#ifdef NOT_USED
+ if (m_batch_execute)
return 0;
+#endif
return trans->execute(NoCommit,IgnoreError,1);
}
@@ -331,7 +337,7 @@ bool ha_ndbcluster::get_error_message(int error,
Ndb *ndb= ((Thd_ndb*)current_thd->transaction.thd_ndb)->ndb;
if (!ndb)
- DBUG_RETURN(false);
+ DBUG_RETURN(FALSE);
const NdbError err= ndb->getNdbError(error);
bool temporary= err.status==NdbError::TemporaryError;
@@ -372,12 +378,12 @@ static inline bool ndb_supported_type(enum_field_types type)
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
- return true;
+ return TRUE;
case MYSQL_TYPE_NULL:
case MYSQL_TYPE_GEOMETRY:
break;
}
- return false;
+ return FALSE;
}
@@ -471,7 +477,7 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field,
DBUG_DUMP("value", (char*)blob_ptr, min(blob_len, 26));
if (set_blob_value)
- *set_blob_value= true;
+ *set_blob_value= TRUE;
// No callback needed to write value
DBUG_RETURN(ndb_blob->setValue(blob_ptr, blob_len) != 0);
}
@@ -614,24 +620,24 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field,
bool ha_ndbcluster::uses_blob_value(bool all_fields)
{
if (table->blob_fields == 0)
- return false;
+ return FALSE;
if (all_fields)
- return true;
+ return TRUE;
{
uint no_fields= table->fields;
int i;
- THD *thd= current_thd;
+ THD *thd= table->in_use;
// They always put blobs at the end..
for (i= no_fields - 1; i >= 0; i--)
{
Field *field= table->field[i];
if (thd->query_id == field->query_id)
{
- return true;
+ return TRUE;
}
}
}
- return false;
+ return FALSE;
}
@@ -650,7 +656,7 @@ int ha_ndbcluster::get_metadata(const char *path)
NDBDICT *dict= m_ndb->getDictionary();
const NDBTAB *tab;
int error;
- bool invalidating_ndb_table= false;
+ bool invalidating_ndb_table= FALSE;
DBUG_ENTER("get_metadata");
DBUG_PRINT("enter", ("m_tabname: %s, path: %s", m_tabname, path));
@@ -681,7 +687,7 @@ int ha_ndbcluster::get_metadata(const char *path)
{
DBUG_PRINT("info", ("Invalidating table"));
dict->invalidateTable(m_tabname);
- invalidating_ndb_table= true;
+ invalidating_ndb_table= TRUE;
}
else
{
@@ -692,12 +698,12 @@ int ha_ndbcluster::get_metadata(const char *path)
DBUG_DUMP("pack_data", (char*)pack_data, pack_length);
DBUG_DUMP("frm", (char*)tab->getFrmData(), tab->getFrmLength());
error= 3;
- invalidating_ndb_table= false;
+ invalidating_ndb_table= FALSE;
}
}
else
{
- invalidating_ndb_table= false;
+ invalidating_ndb_table= FALSE;
}
my_free((char*)data, MYF(0));
my_free((char*)pack_data, MYF(0));
@@ -760,7 +766,7 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
error= create_ordered_index(index_name, key_info);
break;
default:
- DBUG_ASSERT(false);
+ DBUG_ASSERT(FALSE);
break;
}
if (error)
@@ -1174,7 +1180,7 @@ inline int ha_ndbcluster::next_result(byte *buf)
if (execute_no_commit(this,trans) != 0)
DBUG_RETURN(ndb_err(trans));
ops_pending= 0;
- blobs_pending= false;
+ blobs_pending= FALSE;
}
check= cursor->nextResult(contact_ndb);
if (check == 0)
@@ -1639,7 +1645,7 @@ int ha_ndbcluster::write_row(byte *record)
if (has_auto_increment)
{
- skip_auto_increment= false;
+ skip_auto_increment= FALSE;
update_auto_increment();
skip_auto_increment= !auto_increment_column_changed;
}
@@ -1649,14 +1655,14 @@ int ha_ndbcluster::write_row(byte *record)
}
// Set non-key attribute(s)
- bool set_blob_value= false;
+ bool set_blob_value= FALSE;
for (i= 0; i < table->fields; i++)
{
Field *field= table->field[i];
if (!(field->flags & PRI_KEY_FLAG) &&
set_ndb_value(op, field, i, &set_blob_value))
{
- skip_auto_increment= true;
+ skip_auto_increment= TRUE;
ERR_RETURN(op->getNdbError());
}
}
@@ -1670,7 +1676,7 @@ int ha_ndbcluster::write_row(byte *record)
*/
rows_inserted++;
no_uncommitted_rows_update(1);
- bulk_insert_not_flushed= true;
+ bulk_insert_not_flushed= TRUE;
if ((rows_to_insert == 1) ||
((rows_inserted % bulk_insert_rows) == 0) ||
set_blob_value)
@@ -1681,12 +1687,12 @@ int ha_ndbcluster::write_row(byte *record)
"rows_inserted:%d, bulk_insert_rows: %d",
(int)rows_inserted, (int)bulk_insert_rows));
- bulk_insert_not_flushed= false;
+ bulk_insert_not_flushed= FALSE;
if (thd->transaction.on)
{
if (execute_no_commit(this,trans) != 0)
{
- skip_auto_increment= true;
+ skip_auto_increment= TRUE;
no_uncommitted_rows_execute_failure();
DBUG_RETURN(ndb_err(trans));
}
@@ -1695,7 +1701,7 @@ int ha_ndbcluster::write_row(byte *record)
{
if (execute_commit(this,trans) != 0)
{
- skip_auto_increment= true;
+ skip_auto_increment= TRUE;
no_uncommitted_rows_execute_failure();
DBUG_RETURN(ndb_err(trans));
}
@@ -1709,11 +1715,11 @@ int ha_ndbcluster::write_row(byte *record)
DBUG_PRINT("info",
("Trying to set next auto increment value to %lu",
(ulong) next_val));
- if (m_ndb->setAutoIncrementValue((const NDBTAB *) m_table, next_val, true))
+ if (m_ndb->setAutoIncrementValue((const NDBTAB *) m_table, next_val, TRUE))
DBUG_PRINT("info",
("Setting next auto increment value to %u", next_val));
}
- skip_auto_increment= true;
+ skip_auto_increment= TRUE;
DBUG_RETURN(0);
}
@@ -1817,8 +1823,8 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
if (!(op= cursor->updateTuple()))
ERR_RETURN(trans->getNdbError());
ops_pending++;
- if (uses_blob_value(false))
- blobs_pending= true;
+ if (uses_blob_value(FALSE))
+ blobs_pending= TRUE;
}
else
{
@@ -1974,7 +1980,7 @@ void ha_ndbcluster::unpack_record(byte* buf)
else
{
NdbBlob* ndb_blob= (*value).blob;
- bool isNull= true;
+ bool isNull= TRUE;
int ret= ndb_blob->getNull(isNull);
DBUG_ASSERT(ret == 0);
if (isNull)
@@ -2042,7 +2048,7 @@ void ha_ndbcluster::print_results()
else
{
ndb_blob= value.blob;
- bool isNull= true;
+ bool isNull= TRUE;
ndb_blob->getNull(isNull);
if (isNull) {
fprintf(DBUG_FILE, "NULL\n");
@@ -2219,7 +2225,7 @@ int ha_ndbcluster::index_read(byte *buf,
break;
default:
case UNDEFINED_INDEX:
- DBUG_ASSERT(false);
+ DBUG_ASSERT(FALSE);
DBUG_RETURN(1);
break;
}
@@ -2228,7 +2234,7 @@ int ha_ndbcluster::index_read(byte *buf,
start_key.key = key;
start_key.length = key_len;
start_key.flag = find_flag;
- error= ordered_index_scan(&start_key, 0, true, buf);
+ error= ordered_index_scan(&start_key, 0, TRUE, buf);
DBUG_RETURN(error == HA_ERR_END_OF_FILE ? HA_ERR_KEY_NOT_FOUND : error);
}
@@ -2270,7 +2276,7 @@ int ha_ndbcluster::index_first(byte *buf)
// Start the ordered index scan and fetch the first row
// Only HA_READ_ORDER indexes get called by index_first
- DBUG_RETURN(ordered_index_scan(0, 0, true, buf));
+ DBUG_RETURN(ordered_index_scan(0, 0, TRUE, buf));
}
@@ -2279,9 +2285,9 @@ int ha_ndbcluster::index_last(byte *buf)
DBUG_ENTER("index_last");
statistic_increment(ha_read_last_count,&LOCK_status);
int res;
- if((res= ordered_index_scan(0, 0, true, buf)) == 0){
+ if((res= ordered_index_scan(0, 0, TRUE, buf)) == 0){
NdbResultSet *cursor= m_active_cursor;
- while((res= cursor->nextResult(true)) == 0);
+ while((res= cursor->nextResult(TRUE)) == 0);
if(res == 1){
unpack_record(buf);
table->status= 0;
@@ -2629,8 +2635,8 @@ int ha_ndbcluster::extra(enum ha_extra_function operation)
case HA_EXTRA_NO_IGNORE_DUP_KEY:
DBUG_PRINT("info", ("HA_EXTRA_NO_IGNORE_DUP_KEY"));
DBUG_PRINT("info", ("Turning OFF use of write instead of insert"));
- m_use_write= false;
- m_ignore_dup_key_not_supported= false;
+ m_use_write= FALSE;
+ m_ignore_dup_key_not_supported= FALSE;
break;
case HA_EXTRA_RETRIEVE_ALL_COLS: /* Retrieve all columns, not just those
where field->query_id is the same as
@@ -2716,7 +2722,7 @@ int ha_ndbcluster::end_bulk_insert()
DBUG_PRINT("info", ("Sending inserts to NDB, "\
"rows_inserted:%d, bulk_insert_rows: %d",
rows_inserted, bulk_insert_rows));
- bulk_insert_not_flushed= false;
+ bulk_insert_not_flushed= FALSE;
if (execute_no_commit(this,trans) != 0) {
no_uncommitted_rows_execute_failure();
my_errno= error= ndb_err(trans);
@@ -3258,7 +3264,7 @@ static int create_ndb_column(NDBCOL &col,
col.setAutoIncrementInitialValue(value);
}
else
- col.setAutoIncrement(false);
+ col.setAutoIncrement(FALSE);
return 0;
}
@@ -3328,7 +3334,7 @@ int ha_ndbcluster::create(const char *name,
col.setName("$PK");
col.setType(NdbDictionary::Column::Bigunsigned);
col.setLength(1);
- col.setNullable(false);
+ col.setNullable(FALSE);
col.setPrimaryKey(TRUE);
col.setAutoIncrement(TRUE);
tab.addColumn(col);
@@ -3363,7 +3369,7 @@ int ha_ndbcluster::create_ordered_index(const char *name,
KEY *key_info)
{
DBUG_ENTER("create_ordered_index");
- DBUG_RETURN(create_index(name, key_info, false));
+ DBUG_RETURN(create_index(name, key_info, FALSE));
}
int ha_ndbcluster::create_unique_index(const char *name,
@@ -3371,7 +3377,7 @@ int ha_ndbcluster::create_unique_index(const char *name,
{
DBUG_ENTER("create_unique_index");
- DBUG_RETURN(create_index(name, key_info, true));
+ DBUG_RETURN(create_index(name, key_info, TRUE));
}
@@ -3397,7 +3403,7 @@ int ha_ndbcluster::create_index(const char *name,
{
ndb_index.setType(NdbDictionary::Index::OrderedIndex);
// TODO Only temporary ordered indexes supported
- ndb_index.setLogging(false);
+ ndb_index.setLogging(FALSE);
}
ndb_index.setTable(m_tabname);
@@ -3560,15 +3566,15 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
HA_AUTO_PART_KEY |
HA_NO_PREFIX_CHAR_KEYS),
m_share(0),
- m_use_write(false),
- m_ignore_dup_key_not_supported(false),
+ m_use_write(FALSE),
+ m_ignore_dup_key_not_supported(FALSE),
retrieve_all_fields(FALSE),
rows_to_insert(1),
rows_inserted(0),
bulk_insert_rows(1024),
- bulk_insert_not_flushed(false),
+ bulk_insert_not_flushed(FALSE),
ops_pending(0),
- skip_auto_increment(true),
+ skip_auto_increment(TRUE),
blobs_pending(0),
blobs_buffer(0),
blobs_buffer_size(0),
@@ -3979,9 +3985,9 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
table_list.db= (char*) db;
table_list.alias=table_list.real_name=(char*)file_name;
(void)mysql_rm_table_part2(thd, &table_list,
- /* if_exists */ true,
- /* drop_temporary */ false,
- /* dont_log_query*/ true);
+ /* if_exists */ TRUE,
+ /* drop_temporary */ FALSE,
+ /* dont_log_query*/ TRUE);
}
}
@@ -3990,7 +3996,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
while ((file_name=it2++))
{
DBUG_PRINT("info", ("Table %s need discovery", name));
- if (ha_create_table_from_engine(thd, db, file_name, true) == 0)
+ if (ha_create_table_from_engine(thd, db, file_name, TRUE) == 0)
files->push_back(thd->strdup(file_name));
}
@@ -4057,7 +4063,7 @@ bool ndbcluster_init()
if (ndb_discover_tables() != 0)
DBUG_RETURN(TRUE);
#endif
- DBUG_RETURN(false);
+ DBUG_RETURN(FALSE);
}
@@ -4415,7 +4421,7 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
Uint64 sum_rows= 0;
Uint64 sum_commits= 0;
- while((check= rs->nextResult(true)) == 0)
+ while((check= rs->nextResult(TRUE)) == 0)
{
sum_rows+= rows;
sum_commits+= commits;
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index 16862559b74..8224d1c4167 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -139,12 +139,12 @@ class ha_ndbcluster: public handler
bool low_byte_first() const
{
#ifdef WORDS_BIGENDIAN
- return false;
+ return FALSE;
#else
- return true;
+ return TRUE;
#endif
}
- bool has_transactions() { return true; }
+ bool has_transactions() { return TRUE; }
const char* index_type(uint key_number) {
switch (get_index_type(key_number)) {
diff --git a/sql/handler.cc b/sql/handler.cc
index e59358d44bf..0e3153b09d6 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1105,6 +1105,11 @@ void handler::print_error(int error, myf errflag)
break;
case HA_ERR_NO_SUCH_TABLE:
{
+ /*
+ We have to use path to find database name instead of using
+ table->table_cache_key because if the table didn't exist, then
+ table_cache_key was not set up
+ */
char *db;
char buff[FN_REFLEN];
uint length=dirname_part(buff,table->path);
@@ -1276,23 +1281,26 @@ int ha_create_table_from_engine(THD* thd,
const char *name,
bool create_if_found)
{
- int error= 0;
- const void* frmblob = NULL;
- uint frmlen = 0;
+ int error;
+ const void *frmblob;
+ uint frmlen;
char path[FN_REFLEN];
HA_CREATE_INFO create_info;
TABLE table;
DBUG_ENTER("ha_create_table_from_engine");
- DBUG_PRINT("enter", ("db: %s, name: %s", db, name));
- DBUG_PRINT("enter", ("create_if_found: %d", create_if_found));
+ DBUG_PRINT("enter", ("name '%s'.'%s' create_if_found: %d",
+ db, name, create_if_found));
bzero((char*) &create_info,sizeof(create_info));
if ((error= ha_discover(thd, db, name, &frmblob, &frmlen)))
DBUG_RETURN(error);
+ /*
+ Table exists in handler
+ frmblob and frmlen are set
+ */
- // Table exists in handler
- if (create_if_found)
+ if (create_if_found)
{
(void)strxnmov(path,FN_REFLEN,mysql_data_home,"/",db,"/",name,NullS);
// Save the frm file
@@ -1309,9 +1317,7 @@ int ha_create_table_from_engine(THD* thd,
!(table.file->table_flags() & HA_FILE_BASED))
{
/* Ensure that handler gets name in lower case */
- strmov(path, name);
my_casedn_str(files_charset_info, path);
- name= path;
}
error=table.file->create(path,&table,&create_info);
@@ -1319,8 +1325,7 @@ int ha_create_table_from_engine(THD* thd,
}
err_end:
- if (frmblob)
- my_free((char*) frmblob,MYF(0));
+ my_free((char*) frmblob, MYF(MY_ALLOW_ZERO));
DBUG_RETURN(error);
}
@@ -1429,10 +1434,14 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache,
/*
Try to discover one table from handler(s)
+
+ RETURN
+ 0 ok. In this case *frmblob and *frmlen are set
+ 1 error. frmblob and frmlen may not be set
*/
-int ha_discover(THD* thd, const char* db, const char* name,
- const void** frmblob, uint* frmlen)
+int ha_discover(THD *thd, const char *db, const char *name,
+ const void **frmblob, uint *frmlen)
{
int error= 1; // Table does not exist in any handler
DBUG_ENTER("ha_discover");
@@ -1470,6 +1479,8 @@ ha_find_files(THD *thd,const char *db,const char *path,
}
+#ifdef NOT_YET_USED
+
/*
Ask handler if the table exists in engine
@@ -1491,6 +1502,7 @@ int ha_table_exists(THD* thd, const char* db, const char* name)
DBUG_RETURN(error);
}
+#endif
/*
diff --git a/sql/item.cc b/sql/item.cc
index 304579d65a2..b37d0aed1ae 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1196,7 +1196,7 @@ bool Item_ref_null_helper::get_date(TIME *ltime, uint fuzzydate)
static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
Item_ident *item)
{
- // store pointer on SELECT_LEX from wich item is dependent
+ // store pointer on SELECT_LEX from which item is dependent
item->depended_from= last;
current->mark_as_dependent(last);
if (thd->lex->describe & DESCRIBE_EXTENDED)
@@ -1872,10 +1872,11 @@ bool Item_field::send(Protocol *protocol, String *buffer)
return protocol->store(result_field);
}
+
/*
This is used for HAVING clause
Find field in select list having the same name
- */
+*/
bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
{
@@ -1904,8 +1905,9 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
REPORT_ALL_ERRORS ), &not_used)) ==
(Item **)not_found_item)
{
- upward_lookup= 1;
Field *tmp= (Field*) not_found_field;
+ SELECT_LEX *last= 0;
+ upward_lookup= 1;
/*
We can't find table field in select list of current select,
consequently we have to find it in outer subselect(s).
@@ -1915,7 +1917,6 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
mention of table name, but if we join tables in one list it will
cause error ER_NON_UNIQ_ERROR in find_item_in_list.
*/
- SELECT_LEX *last=0;
for ( ; sl ; sl= (prev_unit= sl->master_unit())->outer_select())
{
last= sl;
@@ -1967,9 +1968,9 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
if (!ref)
return 1;
- else if (!tmp)
+ if (!tmp)
return -1;
- else if (ref == (Item **)not_found_item && tmp == not_found_field)
+ if (ref == (Item **)not_found_item && tmp == not_found_field)
{
if (upward_lookup)
{
@@ -1984,31 +1985,33 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
*(thd->lex->current_select->get_item_list()),
&counter, REPORT_ALL_ERRORS, &not_used);
}
- ref= 0;
+ ref= 0; // Safety
return 1;
}
- else if (tmp != not_found_field)
+ if (tmp != not_found_field)
{
- ref= 0; // To prevent "delete *ref;" on ~Item_ref() of this item
- Item_field* fld= new Item_field(tmp);
- if (!fld)
+ Item_field* fld;
+ /*
+ Set ref to 0 as we are replacing this item with the found item
+ and this will ensure we get an error if this item would be
+ used elsewhere
+ */
+ ref= 0; // Safety
+ if (!(fld= new Item_field(tmp)))
return 1;
thd->change_item_tree(reference, fld);
mark_as_dependent(thd, last, thd->lex->current_select, fld);
return 0;
}
- else
+ if (!(*ref)->fixed)
{
- if (!(*ref)->fixed)
- {
- my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,
- "forward reference in item list");
- return -1;
- }
- mark_as_dependent(thd, last, thd->lex->current_select,
- this);
- ref= last->ref_pointer_array + counter;
+ my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,
+ "forward reference in item list");
+ return -1;
}
+ mark_as_dependent(thd, last, thd->lex->current_select,
+ this);
+ ref= last->ref_pointer_array + counter;
}
else if (!ref)
return 1;
@@ -2523,12 +2526,13 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
uint32 new_length= real_length(item);
bool use_new_field= 0, use_expression_type= 0;
Item_result new_result_type= type_convertor[item_type][item->result_type()];
+ bool item_is_a_field= item->type() == Item::FIELD_ITEM;
/*
Check if both items point to fields: in this case we
can adjust column types of result table in the union smartly.
*/
- if (field_example && item->type() == Item::FIELD_ITEM)
+ if (field_example && item_is_a_field)
{
Field *field= ((Item_field *)item)->field;
/* Can 'field_example' field store data of the column? */
@@ -2545,23 +2549,25 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
!is_attr_compatible(this, item));
}
}
- else if (field_example || item->type() == Item::FIELD_ITEM)
+ else if (field_example || item_is_a_field)
{
/*
Expression types can't be mixed with field types, we have to use
expression types.
*/
+ use_new_field= 1; // make next if test easier
use_expression_type= 1;
}
/* Check whether size/type of the result item should be changed */
- if (use_new_field || use_expression_type ||
+ if (use_new_field ||
(new_result_type != item_type) || (new_length > max_length) ||
(!maybe_null && item->maybe_null) ||
(item_type == STRING_RESULT &&
collation.collation != item->collation.collation))
{
- if (use_expression_type || item->type() != Item::FIELD_ITEM)
+ const char *old_cs,*old_derivation;
+ if (use_expression_type || !item_is_a_field)
field_example= 0;
else
{
@@ -2572,8 +2578,8 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
field_example= ((Item_field*) item)->field;
}
- const char *old_cs= collation.collation->name,
- *old_derivation= collation.derivation_name();
+ old_cs= collation.collation->name;
+ old_derivation= collation.derivation_name();
if (item_type == STRING_RESULT && collation.aggregate(item->collation))
{
my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0),
@@ -2593,12 +2599,12 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
return 0;
}
+
uint32 Item_type_holder::real_length(Item *item)
{
if (item->type() == Item::FIELD_ITEM)
- {
return ((Item_field *)item)->max_disp_length();
- }
+
switch (item->result_type())
{
case STRING_RESULT:
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 248b56fe064..f6730c84979 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -859,6 +859,10 @@ void Item_func_between::fix_length_and_dec()
Field *field=((Item_field*) args[0])->field;
if (field->can_be_compared_as_longlong())
{
+ /*
+ The following can't be recoded with || as convert_constant_item
+ changes the argument
+ */
if (convert_constant_item(thd, field,&args[1]))
cmp_type=INT_RESULT; // Works for all types.
if (convert_constant_item(thd, field,&args[2]))
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index dcc32441e88..69528099aa1 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -845,7 +845,7 @@ public:
char escape;
Item_func_like(Item *a,Item *b, Item *escape_arg)
- :Item_bool_func2(a,b), canDoTurboBM(false), pattern(0), pattern_len(0),
+ :Item_bool_func2(a,b), canDoTurboBM(FALSE), pattern(0), pattern_len(0),
bmGs(0), bmBc(0), escape_item(escape_arg) {}
longlong val_int();
enum Functype functype() const { return LIKE_FUNC; }
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 301836fa839..d78a3ac88a4 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2709,41 +2709,40 @@ longlong Item_func_crc32::val_int()
String *Item_func_compress::val_str(String *str)
{
+ int err= Z_OK, code;
+ ulong new_size;
+ String *res;
+ Byte *body;
+ char *tmp, *last_char;
DBUG_ASSERT(fixed == 1);
- String *res= args[0]->val_str(str);
- if (!res)
+
+ if (!(res= args[0]->val_str(str)))
{
null_value= 1;
return 0;
}
if (res->is_empty()) return res;
- int err= Z_OK;
- int code;
-
/*
- citation from zlib.h (comment for compress function):
+ Citation from zlib.h (comment for compress function):
Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least 0.1% larger than
- sourceLen plus 12 bytes.
-
- Proportion 120/100 founded by Sinisa with help of procedure
- compress(compress(compress(...)))
- I.e. zlib give number 'at least'..
+ the byte length of the source buffer. Upon entry, destLen is the total
+ size of the destination buffer, which must be at least 0.1% larger than
+ sourceLen plus 12 bytes.
+ We assume here that the buffer can't grow more than .25 %.
*/
- ulong new_size= res->length() + res->length() / 5 + 12;
+ new_size= res->length() + res->length() / 5 + 12;
- // Will check new_size overflow: new_size <= res->length()
- if (((uint32) new_size <= res->length()) ||
+ // Check new_size overflow: new_size <= res->length()
+ if (((uint32) (new_size+5) <= res->length()) ||
buffer.realloc((uint32) new_size + 4 + 1))
{
null_value= 1;
return 0;
}
- Byte *body= ((Byte*)buffer.ptr()) + 4;
+ body= ((Byte*)buffer.ptr()) + 4;
// As far as we have checked res->is_empty() we can use ptr()
if ((err= compress(body, &new_size,
@@ -2755,11 +2754,11 @@ String *Item_func_compress::val_str(String *str)
return 0;
}
- char *tmp= (char*)buffer.ptr(); // int4store is a macro; avoid side effects
+ tmp= (char*)buffer.ptr(); // int4store is a macro; avoid side effects
int4store(tmp, res->length() & 0x3FFFFFFF);
- /* This is for the stupid char fields which trim ' ': */
- char *last_char= ((char*)body)+new_size-1;
+ /* This is to ensure that things works for CHAR fields, which trim ' ': */
+ last_char= ((char*)body)+new_size-1;
if (*last_char == ' ')
{
*++last_char= '.';
diff --git a/sql/log_event.h b/sql/log_event.h
index 28d1f44df92..8070c334d8b 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -571,7 +571,7 @@ public:
{
fname= afname;
fname_len= alen;
- local_fname= true;
+ local_fname= TRUE;
}
/* fname doesn't point to memory inside Log_event::temp_buf */
int check_fname_outside_temp_buf()
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 1a0879c6347..e94d436b135 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -897,7 +897,7 @@ extern uint test_flags,select_errors,ha_open_options;
extern uint protocol_version, mysqld_port, dropping_tables;
extern uint delay_key_write_options, lower_case_table_names;
extern bool opt_endinfo, using_udf_functions, locked_in_memory;
-extern bool opt_using_transactions, mysql_embedded;
+extern bool opt_using_transactions, mysqld_embedded;
extern bool using_update_log, opt_large_files, server_id_supplied;
extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log;
extern bool opt_disable_networking, opt_skip_show_db;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d7d0f637ec2..878b7bf7e92 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -449,9 +449,9 @@ pthread_cond_t eventShutdown;
#endif
#ifndef EMBEDDED_LIBRARY
-bool mysql_embedded=0;
+bool mysqld_embedded=0;
#else
-bool mysql_embedded=1;
+bool mysqld_embedded=1;
#endif
#ifndef DBUG_OFF
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index fc252c1f5ac..b7eecac4e48 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -2398,7 +2398,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
table_list->db,
table_list->real_name,
rights, column_priv, revoke_grant))
- { // Crashend table ??
+ {
+ /* Should only happen if table is crashed */
result= -1; /* purecov: deadcode */
}
else if (tables[2].table)
@@ -3636,12 +3637,17 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
if (!strcmp(lex_user->user.str,user) &&
!my_strcasecmp(system_charset_info, lex_user->host.str, host))
{
- if (replace_db_table(tables[1].table, acl_db->db, *lex_user, ~0, 1))
- result= -1;
- else
+ if (!replace_db_table(tables[1].table, acl_db->db, *lex_user, ~0, 1))
+ {
+ /*
+ Don't increment counter as replace_db_table deleted the
+ current element in acl_db's and shifted the higher elements down
+ */
continue;
+ }
+ result= -1; // Something went wrong
}
- ++counter;
+ counter++;
}
/* Remove column access */
@@ -3664,26 +3670,27 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
~0, 0, 1))
{
result= -1;
+ continue;
}
else
{
- if (grant_table->cols)
- {
- List<LEX_COLUMN> columns;
- if (replace_column_table(grant_table,tables[3].table, *lex_user,
- columns,
- grant_table->db,
- grant_table->tname,
- ~0, 1))
- result= -1;
- else
- continue;
- }
- else
- continue;
+ if (!grant_table->cols)
+ continue;
+ List<LEX_COLUMN> columns;
+ if (replace_column_table(grant_table,tables[3].table, *lex_user,
+ columns,
+ grant_table->db,
+ grant_table->tname,
+ ~0, 1))
+ result= -1;
+ /*
+ Safer to do continue here as replace_table_table changed
+ column_priv_hash and we want to test the current element
+ */
+ continue;
}
}
- ++counter;
+ counter++;
}
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 31b2ab9ea89..55e6a75b4b4 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1368,7 +1368,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
*/
if (discover_retry_count++ != 0)
goto err;
- if (ha_create_table_from_engine(thd, db, name, true) != 0)
+ if (ha_create_table_from_engine(thd, db, name, TRUE) != 0)
goto err;
thd->clear_error(); // Clear error message
@@ -2846,8 +2846,15 @@ void flush_tables()
/*
-** Mark all entries with the table as deleted to force an reopen of the table
-** Returns true if the table is in use by another thread
+ Mark all entries with the table as deleted to force an reopen of the table
+
+ The table will be closed (not stored in cache) by the current thread when
+ close_thread_tables() is called.
+
+ RETURN
+ 0 This thread now have exclusive access to this table and no other thread
+ can access the table until close_thread_tables() is called.
+ 1 Table is in use by another thread
*/
bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index eabe66d33bf..ffaaafc26e6 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -746,7 +746,7 @@ int mysqld_help(THD *thd, const char *mask)
select,&subcategories_list);
delete select;
String *cat= categories_list.head();
- if (send_header_2(protocol, true) ||
+ if (send_header_2(protocol, TRUE) ||
send_variant_2_list(mem_root,protocol,&topics_list, "N",cat) ||
send_variant_2_list(mem_root,protocol,&subcategories_list,"Y",cat))
goto end;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 856742d13bc..679ffb2140e 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -477,7 +477,6 @@ inline static uint int_token(const char *str,uint length)
int yylex(void *arg, void *yythd)
{
reg1 uchar c;
- bool space_ignored;
int tokval, result_state;
uint length;
enum my_lex_states state;
@@ -560,6 +559,7 @@ int yylex(void *arg, void *yythd)
/* Fall through */
case MY_LEX_IDENT_OR_BIN: // TODO: Add binary string handling
case MY_LEX_IDENT:
+ uchar *start;
#if defined(USE_MB) && defined(USE_MB_IDENT)
if (use_mb(cs))
{
@@ -596,12 +596,16 @@ int yylex(void *arg, void *yythd)
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
}
length= (uint) (lex->ptr - lex->tok_start)-1;
- space_ignored= FALSE;
+ start= lex->ptr;
if (lex->ignore_space)
{
- for (; state_map[c] == MY_LEX_SKIP ; space_ignored= TRUE, c= yyGet());
+ /*
+ If we find a space then this can't be an identifier. We notice this
+ below by checking start != lex->ptr.
+ */
+ for (; state_map[c] == MY_LEX_SKIP ; c= yyGet());
}
- if (! space_ignored && c == '.' && ident_map[yyPeek()])
+ if (start == lex->ptr && c == '.' && ident_map[yyPeek()])
lex->next_state=MY_LEX_IDENT_SEP;
else
{ // '(' must follow directly if function
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e7a013e19ea..8df0dd681db 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -894,7 +894,7 @@ static int check_connection(THD *thd)
x_free(thd->user);
if (!(thd->user= my_strdup(user, MYF(0))))
return (ER_OUT_OF_RESOURCES);
- return check_user(thd, COM_CONNECT, passwd, passwd_len, db, true);
+ return check_user(thd, COM_CONNECT, passwd, passwd_len, db, TRUE);
}
@@ -4767,7 +4767,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
acl_reload(thd);
grant_reload(thd);
if (mqh_used)
- reset_mqh(thd,(LEX_USER *) NULL,true);
+ reset_mqh(thd,(LEX_USER *) NULL,TRUE);
}
#endif
if (options & REFRESH_LOG)
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 27d98fdfeba..1bd359ec9ec 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1781,7 +1781,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
goto set_params_data_err;
#endif
thd->protocol= &thd->protocol_prep; // Switch to binary protocol
- execute_stmt(thd, stmt, &expanded_query, true);
+ execute_stmt(thd, stmt, &expanded_query, TRUE);
thd->protocol= &thd->protocol_simple; // Use normal protocol
DBUG_VOID_RETURN;
@@ -1834,7 +1834,7 @@ void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name)
my_error(ER_WRONG_ARGUMENTS, MYF(0), "EXECUTE");
send_error(thd);
}
- execute_stmt(thd, stmt, &expanded_query, false);
+ execute_stmt(thd, stmt, &expanded_query, FALSE);
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 638ed229a70..df74a946b5c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6911,10 +6911,23 @@ part_of_refkey(TABLE *table,Field *field)
/*****************************************************************************
Test if one can use the key to resolve ORDER BY
- Returns: 1 if key is ok.
- 0 if key can't be used
- -1 if reverse key can be used
- used_key_parts is set to key parts used if length != 0
+
+ SYNOPSIS
+ test_if_order_by_key()
+ order Sort order
+ table Table to sort
+ idx Index to check
+ used_key_parts Return value for used key parts.
+
+
+ NOTES
+ used_key_parts is set to correct key parts used if return value != 0
+ (On other cases, used_key_part may be changed)
+
+ RETURN
+ 1 key is ok.
+ 0 Key can't be used
+ -1 Reverse key can be used
*****************************************************************************/
static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
@@ -6943,16 +6956,17 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
DBUG_RETURN(0);
/* set flag to 1 if we can use read-next on key, else to -1 */
- flag= ((order->asc == !(key_part->key_part_flag & HA_REVERSE_SORT)) ? 1 : -1);
+ flag= ((order->asc == !(key_part->key_part_flag & HA_REVERSE_SORT)) ?
+ 1 : -1);
if (reverse && flag != reverse)
DBUG_RETURN(0);
reverse=flag; // Remember if reverse
key_part++;
}
- uint tmp= (uint) (key_part - table->key_info[idx].key_part);
- if (reverse == -1 && !(table->file->index_flags(idx,tmp-1, 1) & HA_READ_PREV))
- DBUG_RETURN(0);
- *used_key_parts= tmp;
+ *used_key_parts= (uint) (key_part - table->key_info[idx].key_part);
+ if (reverse == -1 && !(table->file->index_flags(idx, *used_key_parts-1, 1) &
+ HA_READ_PREV))
+ reverse= 0; // Index can't be used
DBUG_RETURN(reverse);
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index c5cd2860e03..e030db2caf7 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1136,7 +1136,7 @@ static const char *require_quotes(const char *name, uint name_length)
for ( ; name < end ; name++)
{
uchar chr= (uchar) *name;
- length= my_mbcharlen(system_charset_info, (uchar) chr);
+ length= my_mbcharlen(system_charset_info, chr);
if (length == 1 && !system_charset_info->ident_map[chr])
return name;
}
@@ -1148,25 +1148,29 @@ void
append_identifier(THD *thd, String *packet, const char *name, uint length)
{
const char *name_end;
+ char quote_char;
int q= get_quote_char_for_identifier(thd, name, length);
- if (q == EOF) {
+ if (q == EOF)
+ {
packet->append(name, length, system_charset_info);
return;
}
- char quote_char= q;
-
- /* The identifier must be quoted as it includes a quote character */
+ /*
+ The identifier must be quoted as it includes a quote character or
+ it's a keyword
+ */
packet->reserve(length*2 + 2);
+ quote_char= (char) q;
packet->append(&quote_char, 1, system_charset_info);
for (name_end= name+length ; name < name_end ; name+= length)
{
- char chr= *name;
- length= my_mbcharlen(system_charset_info, (uchar) chr);
- if (length == 1 && chr == quote_char)
+ uchar chr= (uchar) *name;
+ length= my_mbcharlen(system_charset_info, chr);
+ if (length == 1 && chr == (uchar) quote_char)
packet->append(&quote_char, 1, system_charset_info);
packet->append(name, length, packet->charset());
}
@@ -1174,8 +1178,25 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
}
-/* Get the quote character for displaying an identifier.
- If no quote character is needed, return EOF. */
+/*
+ Get the quote character for displaying an identifier.
+
+ SYNOPSIS
+ get_quote_char_for_identifier()
+ thd Thread handler
+ name name to quote
+ length length of name
+
+ IMPLEMENTATION
+ If name is a keyword or includes a special character, then force
+ quoting.
+ Otherwise identifier is quoted only if the option OPTION_QUOTE_SHOW_CREATE
+ is set.
+
+ RETURN
+ EOF No quote character is needed
+ # Quote character
+*/
int get_quote_char_for_identifier(THD *thd, const char *name, uint length)
{
@@ -1183,10 +1204,9 @@ int get_quote_char_for_identifier(THD *thd, const char *name, uint length)
!require_quotes(name, length) &&
!(thd->options & OPTION_QUOTE_SHOW_CREATE))
return EOF;
- else if (thd->variables.sql_mode & MODE_ANSI_QUOTES)
+ if (thd->variables.sql_mode & MODE_ANSI_QUOTES)
return '"';
- else
- return '`';
+ return '`';
}
@@ -1195,10 +1215,9 @@ int get_quote_char_for_identifier(THD *thd, const char *name, uint length)
static void append_directory(THD *thd, String *packet, const char *dir_type,
const char *filename)
{
- uint length;
if (filename && !(thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
{
- length= dirname_length(filename);
+ uint length= dirname_length(filename);
packet->append(' ');
packet->append(dir_type);
packet->append(" DIRECTORY='", 12);
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 1ec0faafa8f..1044dc4e58e 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -537,7 +537,8 @@ uint32 String::numchars()
int String::charpos(int i,uint32 offset)
{
- if (i<0) return i;
+ if (i <= 0)
+ return i;
return str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,i);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 65e23c7ba1d..d2de24b0d2a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -223,7 +223,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
(void) unpack_filename(path,path);
}
if (drop_temporary ||
- (access(path,F_OK) && ha_create_table_from_engine(thd,db,alias,true)))
+ (access(path,F_OK) && ha_create_table_from_engine(thd,db,alias,TRUE)))
{
if (if_exists)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c1513dd55e2..d9a21baf84e 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -843,14 +843,14 @@ prepare_src:
THD *thd=YYTHD;
LEX *lex= thd->lex;
lex->prepared_stmt_code= $1;
- lex->prepared_stmt_code_is_varref= false;
+ lex->prepared_stmt_code_is_varref= FALSE;
}
| '@' ident_or_text
{
THD *thd=YYTHD;
LEX *lex= thd->lex;
lex->prepared_stmt_code= $2;
- lex->prepared_stmt_code_is_varref= true;
+ lex->prepared_stmt_code_is_varref= TRUE;
};
execute:
diff --git a/strings/Makefile.am b/strings/Makefile.am
index be51e48ef8d..d17a4f598a6 100644
--- a/strings/Makefile.am
+++ b/strings/Makefile.am
@@ -57,7 +57,7 @@ EXTRA_DIST = ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-win1250ch.c \
t_ctype.h
libmystrings_a_LIBADD=
-conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c
+conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
conf_to_src_LDADD=
#force static linking of conf_to_src - essential when linking against
#custom installation of libc
diff --git a/strings/xml.c b/strings/xml.c
index 7d7839e1603..6ba52ea41a8 100644
--- a/strings/xml.c
+++ b/strings/xml.c
@@ -81,10 +81,11 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a)
a->beg=p->cur;
a->end=p->cur;
- if (!memcmp(p->cur,"<!--",4))
+ if (!bcmp(p->cur,"<!--",4))
{
- for( ; (p->cur < p->end) && memcmp(p->cur, "-->", 3); p->cur++);
- if(!memcmp(p->cur, "-->", 3))
+ for( ; (p->cur < p->end) && bcmp(p->cur, "-->", 3); p->cur++)
+ {}
+ if (!bcmp(p->cur, "-->", 3))
p->cur+=3;
a->end=p->cur;
lex=MY_XML_COMMENT;
diff --git a/tests/client_test.c b/tests/client_test.c
index 0b30cc3386d..eb97c0ce949 100644
--- a/tests/client_test.c
+++ b/tests/client_test.c
@@ -26,14 +26,6 @@
#include <mysql.h>
#include <my_getopt.h>
#include <m_string.h>
-#ifdef HAVE_SYS_PARAM_H
-/* Include to get MAXPATHLEN */
-#include <sys/param.h>
-#endif
-
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 256
-#endif
#define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */
@@ -6652,8 +6644,8 @@ static void test_frm_bug()
MYSQL_RES *result;
MYSQL_ROW row;
FILE *test_file;
- char data_dir[MAXPATHLEN];
- char test_frm[MAXPATHLEN];
+ char data_dir[FN_REFLEN];
+ char test_frm[FN_REFLEN];
int rc;
myheader("test_frm_bug");
@@ -6674,7 +6666,7 @@ static void test_frm_bug()
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= data_dir;
- bind[0].buffer_length= MAXPATHLEN;
+ bind[0].buffer_length= FN_REFLEN;
bind[0].is_null= 0;
bind[0].length= 0;
bind[1]= bind[0];