summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-09-29 00:58:16 +0300
committerunknown <monty@donna.mysql.com>2000-09-29 00:58:16 +0300
commitc33289a3a19431b833d7fe06cbfb7f57747cc9b6 (patch)
treeb7b27884a7a1c424b00084acf096abc9155bcb32 /sql
parent3a5ab655f175d86e9c7f4eab290933ffa622eeaf (diff)
downloadmariadb-git-c33289a3a19431b833d7fe06cbfb7f57747cc9b6.tar.gz
Fixed indention, removed compiler varnings and fixed a bug
in FULLTEXT indexes. Docs/manual.texi: Removed some @ifset nushere tags which crashed the manual when using emacs client/mysql-test.c: ***MISSING WEAVE*** heap/hp_test2.c: Removed compiler warnings isam/pack_isam.c: Removed compiler warnings isam/update.c: Removed compiler warnings myisam/ft_parser.c: cleanup myisam/ft_update.c: Fixed crash when inserting a blob which was NULL myisam/mi_check.c: -e continues checking of other keys on error myisam/mi_rkey.c: cleanup myisam/myisamchk.c: cleanup myisam/myisamlog.c: Added use of rnd to make things more predictable myisammrg/myrg_rkey.c: Removed compiler warnings mysys/mf_pack.c: cleanup mysys/my_fstream.c: cleanup sql/ha_berkeley.cc: cleanup sql/handler.cc: cleanup sql/item_func.cc: cleanup sql/item_func.h: cleanup sql/net_serv.cc: cleanup sql/slave.cc: cleanup sql/sql_class.cc: cleanup sql/sql_show.cc: cleanup
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_berkeley.cc8
-rw-r--r--sql/handler.cc1
-rw-r--r--sql/item_func.cc5
-rw-r--r--sql/item_func.h2
-rw-r--r--sql/net_serv.cc1
-rw-r--r--sql/slave.cc428
-rw-r--r--sql/sql_class.cc6
-rw-r--r--sql/sql_show.cc6
8 files changed, 226 insertions, 231 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index f9ee7595433..5f156622901 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -388,7 +388,6 @@ int ha_berkeley::close(void)
bool ha_berkeley::fix_rec_buff_for_blob(ulong length)
{
- uint extra;
if (! rec_buff || length > alloced_rec_buff_length)
{
byte *newptr;
@@ -663,7 +662,7 @@ int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed,
const byte * new_row, DBT *prim_key)
{
DBT row, old_key;
- int error,new_error;
+ int error;
DBUG_ENTER("update_primary_key");
if (primary_key_changed)
@@ -705,9 +704,8 @@ int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed,
int ha_berkeley::update_row(const byte * old_row, byte * new_row)
{
- DBT row, prim_key, key, old_prim_key;
+ DBT prim_key, key, old_prim_key;
int error;
- uint keynr;
DB_TXN *sub_trans;
bool primary_key_changed;
DBUG_ENTER("update_row");
@@ -1242,7 +1240,7 @@ THR_LOCK_DATA **ha_berkeley::store_lock(THD *thd, THR_LOCK_DATA **to,
static int create_sub_table(const char *table_name, const char *sub_name,
DBTYPE type, int flags)
{
- int error,error2;
+ int error;
DB *file;
DBUG_ENTER("create_sub_table");
DBUG_PRINT("enter",("sub_name: %s",sub_name));
diff --git a/sql/handler.cc b/sql/handler.cc
index ccd958664a7..68d12a96f98 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -37,7 +37,6 @@
/* static functions defined in this file */
-static void NEAR_F set_form_timestamp(TABLE *table, byte *record);
static int NEAR_F delete_file(const char *name,const char *ext,int extflag);
ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
diff --git a/sql/item_func.cc b/sql/item_func.cc
index eada5d03079..3ea7eadd238 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -775,7 +775,10 @@ longlong Item_func_locate::val_int()
return 0; /* purecov: inspected */
}
null_value=0;
- uint start=0,start0=0;
+ uint start=0;
+#ifdef USE_MB
+ uint start0=0;
+#endif
if (arg_count == 3)
{
start=(uint) args[2]->val_int()-1;
diff --git a/sql/item_func.h b/sql/item_func.h
index 0eae4512ab4..68ec61db2c1 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -843,7 +843,7 @@ public:
FT_DOCLIST *ft_handler;
Item_func_match(List<Item> &a, Item *b): Item_real_func(b),
- fields(a), table(0), ft_handler(0), master(0) {}
+ fields(a), table(0), master(0), ft_handler(0) {}
~Item_func_match()
{
if (!master)
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index dac1fe0bd68..14bf2700378 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -412,7 +412,6 @@ net_real_write(NET *net,const char *packet,ulong len)
static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
{
- char buff[1024];
ALARM alarm_buff;
uint retry_count=0;
if (!thr_alarm_in_use(alarmed))
diff --git a/sql/slave.cc b/sql/slave.cc
index 7fcfb803ac1..f8746c78e49 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -516,7 +516,6 @@ command");
static uint read_event(MYSQL* mysql, MASTER_INFO *mi)
{
uint len = packet_error;
- NET* net = &mysql->net;
int read_errno = EINTR; // for convinience lets think we start by
// being in the interrupted state :-)
// my_real_read() will time us out
@@ -543,251 +542,250 @@ static uint read_event(MYSQL* mysql, MASTER_INFO *mi)
}
DBUG_PRINT("info",( "len=%u, net->read_pos[4] = %d\n",
- len, net->read_pos[4]));
+ len, mysql->net.read_pos[4]));
return len - 1;
}
+
static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
{
- Log_event * ev = Log_event::read_log_event((const char*)net->read_pos + 1 , event_len);
- if(ev)
- {
- switch(ev->get_type_code())
+ Log_event * ev = Log_event::read_log_event((const char*)net->read_pos + 1,
+ event_len);
+ if (ev)
+ {
+ switch(ev->get_type_code())
+ {
+ case QUERY_EVENT:
+ {
+ Query_log_event* qev = (Query_log_event*)ev;
+ int q_len = qev->q_len;
+ init_sql_alloc(&thd->mem_root, 8192,0);
+ thd->db = (char*)qev->db;
+ if(db_ok(thd->db, replicate_do_db, replicate_ignore_db))
+ {
+ thd->query = (char*)qev->query;
+ thd->set_time((time_t)qev->when);
+ thd->current_tablenr = 0;
+ VOID(pthread_mutex_lock(&LOCK_thread_count));
+ thd->query_id = query_id++;
+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
+ thd->last_nx_table = thd->last_nx_db = 0;
+ for(;;)
{
- case QUERY_EVENT:
+ thd->query_error = 0; // clear error
+ thd->last_nx_table = thd->last_nx_db = 0;
+ thd->net.last_errno = 0;
+ thd->net.last_error[0] = 0;
+ mysql_parse(thd, thd->query, q_len); // try query
+ if(!thd->query_error || slave_killed(thd)) // break if ok
+ break;
+ // if not ok
+ if(thd->last_nx_table && thd->last_nx_db)
{
- Query_log_event* qev = (Query_log_event*)ev;
- int q_len = qev->q_len;
- init_sql_alloc(&thd->mem_root, 8192,0);
- thd->db = (char*)qev->db;
- if(db_ok(thd->db, replicate_do_db, replicate_ignore_db))
- {
- thd->query = (char*)qev->query;
- thd->set_time((time_t)qev->when);
- thd->current_tablenr = 0;
- VOID(pthread_mutex_lock(&LOCK_thread_count));
- thd->query_id = query_id++;
- VOID(pthread_mutex_unlock(&LOCK_thread_count));
- thd->last_nx_table = thd->last_nx_db = 0;
- for(;;)
- {
- thd->query_error = 0; // clear error
- thd->last_nx_table = thd->last_nx_db = 0;
- thd->net.last_errno = 0;
- thd->net.last_error[0] = 0;
- mysql_parse(thd, thd->query, q_len); // try query
- if(!thd->query_error || slave_killed(thd)) // break if ok
- break;
- // if not ok
- if(thd->last_nx_table && thd->last_nx_db)
- {
- // for now, let's just fail if the table is not
- // there, and not try to be a smart alec...
+ // for now, let's just fail if the table is not
+ // there, and not try to be a smart alec...
- // if table was not there
- //if(fetch_nx_table(thd,&glob_mi))
- // try to to fetch from master
- break; // if we can't, just break
- }
- else
- break; // if failed for some other reason, bail out
-
- // if fetched the table from master successfully
- // we need to restore query info in thd because
- // fetch_nx_table executes create table
- thd->query = (char*)qev->query;
- thd->set_time((time_t)qev->when);
- thd->current_tablenr = 0;
- }
- }
- thd->db = 0;// prevent db from being freed
- thd->query = 0; // just to be sure
- close_thread_tables(thd);
- free_root(&thd->mem_root,0);
- if (thd->query_error)
- {
- sql_print_error("Slave: error running query '%s' ",
- qev->query);
- return 1;
- }
- delete ev;
-
- if(thd->fatal_error)
- {
- sql_print_error("Slave: Fatal error running query '%s' ",
- thd->query);
- return 1;
- }
-
- mi->inc_pos(event_len);
- flush_master_info(mi);
- break;
+ // if table was not there
+ //if(fetch_nx_table(thd,&glob_mi))
+ // try to to fetch from master
+ break; // if we can't, just break
}
+ else
+ break; // if failed for some other reason, bail out
+
+ // if fetched the table from master successfully
+ // we need to restore query info in thd because
+ // fetch_nx_table executes create table
+ thd->query = (char*)qev->query;
+ thd->set_time((time_t)qev->when);
+ thd->current_tablenr = 0;
+ }
+ }
+ thd->db = 0;// prevent db from being freed
+ thd->query = 0; // just to be sure
+ close_thread_tables(thd);
+ free_root(&thd->mem_root,0);
+ if (thd->query_error)
+ {
+ sql_print_error("Slave: error running query '%s' ",
+ qev->query);
+ return 1;
+ }
+ delete ev;
+
+ if(thd->fatal_error)
+ {
+ sql_print_error("Slave: Fatal error running query '%s' ",
+ thd->query);
+ return 1;
+ }
+
+ mi->inc_pos(event_len);
+ flush_master_info(mi);
+ break;
+ }
- case LOAD_EVENT:
- {
- Load_log_event* lev = (Load_log_event*)ev;
- init_sql_alloc(&thd->mem_root, 8192,0);
- thd->db = (char*)lev->db;
- thd->query = 0;
- thd->query_error = 0;
+ case LOAD_EVENT:
+ {
+ Load_log_event* lev = (Load_log_event*)ev;
+ init_sql_alloc(&thd->mem_root, 8192,0);
+ thd->db = (char*)lev->db;
+ thd->query = 0;
+ thd->query_error = 0;
- if(db_ok(thd->db, replicate_do_db, replicate_ignore_db))
- {
- thd->set_time((time_t)lev->when);
- thd->current_tablenr = 0;
- VOID(pthread_mutex_lock(&LOCK_thread_count));
- thd->query_id = query_id++;
- VOID(pthread_mutex_unlock(&LOCK_thread_count));
-
- enum enum_duplicates handle_dup = DUP_IGNORE;
- if(lev->sql_ex.opt_flags && REPLACE_FLAG)
- handle_dup = DUP_REPLACE;
- sql_exchange ex((char*)lev->fname, lev->sql_ex.opt_flags && DUMPFILE_FLAG );
- String field_term(&lev->sql_ex.field_term, 1),
- enclosed(&lev->sql_ex.enclosed, 1), line_term(&lev->sql_ex.line_term,1),
- escaped(&lev->sql_ex.escaped, 1), line_start(&lev->sql_ex.line_start, 1);
+ if(db_ok(thd->db, replicate_do_db, replicate_ignore_db))
+ {
+ thd->set_time((time_t)lev->when);
+ thd->current_tablenr = 0;
+ VOID(pthread_mutex_lock(&LOCK_thread_count));
+ thd->query_id = query_id++;
+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
+
+ enum enum_duplicates handle_dup = DUP_IGNORE;
+ if(lev->sql_ex.opt_flags && REPLACE_FLAG)
+ handle_dup = DUP_REPLACE;
+ sql_exchange ex((char*)lev->fname, lev->sql_ex.opt_flags && DUMPFILE_FLAG );
+ String field_term(&lev->sql_ex.field_term, 1),
+ enclosed(&lev->sql_ex.enclosed, 1), line_term(&lev->sql_ex.line_term,1),
+ escaped(&lev->sql_ex.escaped, 1), line_start(&lev->sql_ex.line_start, 1);
- ex.field_term = &field_term;
- if(lev->sql_ex.empty_flags & FIELD_TERM_EMPTY)
- ex.field_term->length(0);
+ ex.field_term = &field_term;
+ if(lev->sql_ex.empty_flags & FIELD_TERM_EMPTY)
+ ex.field_term->length(0);
- ex.enclosed = &enclosed;
- if(lev->sql_ex.empty_flags & ENCLOSED_EMPTY)
- ex.enclosed->length(0);
+ ex.enclosed = &enclosed;
+ if(lev->sql_ex.empty_flags & ENCLOSED_EMPTY)
+ ex.enclosed->length(0);
- ex.line_term = &line_term;
- if(lev->sql_ex.empty_flags & LINE_TERM_EMPTY)
- ex.line_term->length(0);
+ ex.line_term = &line_term;
+ if(lev->sql_ex.empty_flags & LINE_TERM_EMPTY)
+ ex.line_term->length(0);
- ex.line_start = &line_start;
- if(lev->sql_ex.empty_flags & LINE_START_EMPTY)
- ex.line_start->length(0);
+ ex.line_start = &line_start;
+ if(lev->sql_ex.empty_flags & LINE_START_EMPTY)
+ ex.line_start->length(0);
- ex.escaped = &escaped;
- if(lev->sql_ex.empty_flags & ESCAPED_EMPTY)
- ex.escaped->length(0);
+ ex.escaped = &escaped;
+ if(lev->sql_ex.empty_flags & ESCAPED_EMPTY)
+ ex.escaped->length(0);
- ex.opt_enclosed = (lev->sql_ex.opt_flags & OPT_ENCLOSED_FLAG);
- if(lev->sql_ex.empty_flags & FIELD_TERM_EMPTY)
- ex.field_term->length(0);
+ ex.opt_enclosed = (lev->sql_ex.opt_flags & OPT_ENCLOSED_FLAG);
+ if(lev->sql_ex.empty_flags & FIELD_TERM_EMPTY)
+ ex.field_term->length(0);
- ex.skip_lines = lev->skip_lines;
+ ex.skip_lines = lev->skip_lines;
- TABLE_LIST tables;
- bzero((char*) &tables,sizeof(tables));
- tables.db = thd->db;
- tables.name = tables.real_name = (char*)lev->table_name;
- tables.lock_type = TL_WRITE;
+ TABLE_LIST tables;
+ bzero((char*) &tables,sizeof(tables));
+ tables.db = thd->db;
+ tables.name = tables.real_name = (char*)lev->table_name;
+ tables.lock_type = TL_WRITE;
- if (open_tables(thd, &tables))
- {
- sql_print_error("Slave: error opening table %s ",
- tables.name);
- delete ev;
- return 1;
- }
-
- List<Item> fields;
- lev->set_fields(fields);
- thd->net.vio = net->vio;
- // mysql_load will use thd->net to read the file
- thd->net.pkt_nr = net->pkt_nr;
- // make sure the client does get confused
- // about the packet sequence
- if(mysql_load(thd, &ex, &tables, fields, handle_dup, 1,
- TL_WRITE))
- thd->query_error = 1;
- net->pkt_nr = thd->net.pkt_nr;
- }
- else // we will just ask the master to send us /dev/null if we do not want to
- // load the data :-)
- {
- (void)my_net_write(net, "\xfb/dev/null", 10);
- (void)net_flush(net);
- (void)my_net_read(net); // discard response
- send_ok(net); // the master expects it
- }
+ if (open_tables(thd, &tables))
+ {
+ sql_print_error("Slave: error opening table %s ",
+ tables.name);
+ delete ev;
+ return 1;
+ }
+
+ List<Item> fields;
+ lev->set_fields(fields);
+ thd->net.vio = net->vio;
+ // mysql_load will use thd->net to read the file
+ thd->net.pkt_nr = net->pkt_nr;
+ // make sure the client does get confused
+ // about the packet sequence
+ if(mysql_load(thd, &ex, &tables, fields, handle_dup, 1,
+ TL_WRITE))
+ thd->query_error = 1;
+ net->pkt_nr = thd->net.pkt_nr;
+ }
+ else // we will just ask the master to send us /dev/null if we do not want to
+ // load the data :-)
+ {
+ (void)my_net_write(net, "\xfb/dev/null", 10);
+ (void)net_flush(net);
+ (void)my_net_read(net); // discard response
+ send_ok(net); // the master expects it
+ }
- thd->net.vio = 0;
- thd->db = 0;// prevent db from being freed
- close_thread_tables(thd);
- if(thd->query_error)
- {
- int sql_error = thd->net.last_errno;
- if(!sql_error)
- sql_error = ER_UNKNOWN_ERROR;
+ thd->net.vio = 0;
+ thd->db = 0;// prevent db from being freed
+ close_thread_tables(thd);
+ if(thd->query_error)
+ {
+ int sql_error = thd->net.last_errno;
+ if(!sql_error)
+ sql_error = ER_UNKNOWN_ERROR;
- sql_print_error("Slave: error '%s' running load data infile ",
- ER(sql_error));
- delete ev;
- return 1;
- }
- delete ev;
+ sql_print_error("Slave: error '%s' running load data infile ",
+ ER(sql_error));
+ delete ev;
+ return 1;
+ }
+ delete ev;
- if(thd->fatal_error)
- {
- sql_print_error("Slave: Fatal error running query '%s' ",
- thd->query);
- return 1;
- }
-
- mi->inc_pos(event_len);
- flush_master_info(mi);
- break;
- }
+ if(thd->fatal_error)
+ {
+ sql_print_error("Slave: Fatal error running query '%s' ",
+ thd->query);
+ return 1;
+ }
+
+ mi->inc_pos(event_len);
+ flush_master_info(mi);
+ break;
+ }
- case START_EVENT:
- mi->inc_pos(event_len);
- flush_master_info(mi);
- break;
+ case START_EVENT:
+ mi->inc_pos(event_len);
+ flush_master_info(mi);
+ break;
- case STOP_EVENT:
- mi->inc_pos(event_len);
- flush_master_info(mi);
- break;
- case ROTATE_EVENT:
- {
- Rotate_log_event* rev = (Rotate_log_event*)ev;
- int ident_len = rev->ident_len;
- memcpy(mi->log_file_name, rev->new_log_ident,ident_len );
- mi->log_file_name[ident_len] = 0;
- mi->pos = 0;
- break;
- }
+ case STOP_EVENT:
+ mi->inc_pos(event_len);
+ flush_master_info(mi);
+ break;
+ case ROTATE_EVENT:
+ {
+ Rotate_log_event* rev = (Rotate_log_event*)ev;
+ int ident_len = rev->ident_len;
+ memcpy(mi->log_file_name, rev->new_log_ident,ident_len );
+ mi->log_file_name[ident_len] = 0;
+ mi->pos = 0;
+ break;
+ }
- case INTVAR_EVENT:
- {
- Intvar_log_event* iev = (Intvar_log_event*)ev;
- switch(iev->type)
- {
- case LAST_INSERT_ID_EVENT:
- thd->last_insert_id_used = 1;
- thd->last_insert_id = iev->val;
- break;
- case INSERT_ID_EVENT:
- thd->next_insert_id = iev->val;
- break;
+ case INTVAR_EVENT:
+ {
+ Intvar_log_event* iev = (Intvar_log_event*)ev;
+ switch(iev->type)
+ {
+ case LAST_INSERT_ID_EVENT:
+ thd->last_insert_id_used = 1;
+ thd->last_insert_id = iev->val;
+ break;
+ case INSERT_ID_EVENT:
+ thd->next_insert_id = iev->val;
+ break;
- }
- mi->inc_pos(event_len);
- flush_master_info(mi);
- break;
- }
- }
-
+ }
+ mi->inc_pos(event_len);
+ flush_master_info(mi);
+ break;
+ }
}
+
+ }
else
- {
- sql_print_error("Could not parse log event entry, check the master for binlog corruption\
+ {
+ sql_print_error("Could not parse log event entry, check the master for binlog corruption\n\
This may also be a network problem, or just a bug in the master or slave code");
- return 1;
- }
-
-
-
-return 0;
+ return 1;
+ }
+ return 0;
}
// slave thread
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 059b17c6d84..2db08045d89 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -553,11 +553,11 @@ bool select_dump::send_data(List<Item> &items)
}
while ((item=li++))
{
- Item_result result_type=item->result_type();
res=item->str_result(&tmp);
- if (!res)
+ if (!res) // If NULL
{
- if (my_b_write(&cache,(byte*) "",1)) goto err; // NULL
+ if (my_b_write(&cache,(byte*) "",1))
+ goto err;
}
else if (my_b_write(&cache,(byte*) res->ptr(),res->length()))
{
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 0fa7aaf1d88..ea6e09f6cb5 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -753,13 +753,11 @@ store_create_info(THD *thd, TABLE *table, String* packet)
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
{
- if(j)
+ if (j)
packet->append(',');
- if(key_part->field)
+ if (key_part->field)
packet->append(key_part->field->field_name);
- KEY *key=table->key_info+i;
-
if (!key_part->field ||
(key_part->length !=
table->field[key_part->fieldnr-1]->key_length() &&