Commit 3c82f720 authored by unknown's avatar unknown

manual merge

sql/field.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
strings/ctype-utf8.c:
  Auto merged
parents 428830c5 306ebf7b
...@@ -64,7 +64,12 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, ...@@ -64,7 +64,12 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record,
} }
/* Calculate a hash for a row */ /*
Calculate a hash for a row
TODO
Add support for bit fields
*/
ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record)
{ {
...@@ -126,9 +131,17 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) ...@@ -126,9 +131,17 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record)
return crc; return crc;
} }
/*
Returns 0 if both rows have equal unique value /*
*/ compare unique key for two rows
TODO
Add support for bit fields
RETURN
0 if both rows have equal unique value
# Rows are different
*/
int mi_unique_comp(MI_UNIQUEDEF *def, const byte *a, const byte *b, int mi_unique_comp(MI_UNIQUEDEF *def, const byte *a, const byte *b,
my_bool null_are_equal) my_bool null_are_equal)
......
...@@ -288,7 +288,7 @@ static struct my_option my_long_options[] = ...@@ -288,7 +288,7 @@ static struct my_option my_long_options[] =
static void print_version(void) static void print_version(void)
{ {
VOID(printf("%s Ver 1.22 for %s on %s\n", VOID(printf("%s Ver 1.23 for %s on %s\n",
my_progname, SYSTEM_TYPE, MACHINE_TYPE)); my_progname, SYSTEM_TYPE, MACHINE_TYPE));
NETWARE_SET_SCREEN_MODE(1); NETWARE_SET_SCREEN_MODE(1);
} }
......
...@@ -731,6 +731,27 @@ n ...@@ -731,6 +731,27 @@ n
Warnings: Warnings:
Warning 1052 Column 'n' in group statement is ambiguous Warning 1052 Column 'n' in group statement is ambiguous
DROP TABLE t1; DROP TABLE t1;
create table t1 (c1 char(3), c2 char(3));
create table t2 (c3 char(3), c4 char(3));
insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2');
insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2');
select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
group by c2;
c2
aaa
aaa
Warnings:
Warning 1052 Column 'c2' in group statement is ambiguous
show warnings;
Level Code Message
Warning 1052 Column 'c2' in group statement is ambiguous
select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
group by t1.c1;
c2
aaa
show warnings;
Level Code Message
drop table t1, t2;
CREATE TABLE t1 (a int, b int); CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1,2), (1,3); INSERT INTO t1 VALUES (1,2), (1,3);
SELECT a, b FROM t1 GROUP BY 'const'; SELECT a, b FROM t1 GROUP BY 'const';
......
...@@ -227,6 +227,9 @@ latin1_bin latin1 ...@@ -227,6 +227,9 @@ latin1_bin latin1
latin1_general_ci latin1 latin1_general_ci latin1
latin1_general_cs latin1 latin1_general_cs latin1
latin1_spanish_ci latin1 latin1_spanish_ci latin1
drop procedure if exists sel2;
drop function if exists sub1;
drop function if exists sub2;
create function sub1(i int) returns int create function sub1(i int) returns int
return i+1; return i+1;
create procedure sel2() create procedure sel2()
...@@ -823,6 +826,8 @@ GRANT SELECT ON *.* TO 'user4'@'localhost' ...@@ -823,6 +826,8 @@ GRANT SELECT ON *.* TO 'user4'@'localhost'
drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost; drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost;
use test; use test;
drop database mysqltest; drop database mysqltest;
drop procedure if exists p1;
drop procedure if exists p2;
create procedure p1 () modifies sql data set @a = 5; create procedure p1 () modifies sql data set @a = 5;
create procedure p2 () set @a = 5; create procedure p2 () set @a = 5;
select sql_data_access from information_schema.routines select sql_data_access from information_schema.routines
......
...@@ -543,6 +543,27 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1 ...@@ -543,6 +543,27 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#11211: Ambiguous column reference in GROUP BY.
#
create table t1 (c1 char(3), c2 char(3));
create table t2 (c3 char(3), c4 char(3));
insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2');
insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2');
# query with ambiguous column reference 'c2'
--disable_ps_protocol
select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
group by c2;
show warnings;
--enable_ps_protocol
# this query has no ambiguity
select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
group by t1.c1;
show warnings;
drop table t1, t2;
# #
# Test for bug #11414: crash on Windows for a simple GROUP BY query # Test for bug #11414: crash on Windows for a simple GROUP BY query
......
...@@ -101,6 +101,12 @@ where COLLATION_NAME like 'latin1%'; ...@@ -101,6 +101,12 @@ where COLLATION_NAME like 'latin1%';
# Test for information_schema.ROUTINES & # Test for information_schema.ROUTINES &
# #
--disable_warnings
drop procedure if exists sel2;
drop function if exists sub1;
drop function if exists sub2;
--enable_warnings
create function sub1(i int) returns int create function sub1(i int) returns int
return i+1; return i+1;
delimiter |; delimiter |;
...@@ -546,6 +552,11 @@ drop database mysqltest; ...@@ -546,6 +552,11 @@ drop database mysqltest;
# #
# Bug #11055 information_schema: routines.sql_data_access has wrong value # Bug #11055 information_schema: routines.sql_data_access has wrong value
# #
--disable_warnings
drop procedure if exists p1;
drop procedure if exists p2;
--enable_warnings
create procedure p1 () modifies sql data set @a = 5; create procedure p1 () modifies sql data set @a = 5;
create procedure p2 () set @a = 5; create procedure p2 () set @a = 5;
select sql_data_access from information_schema.routines select sql_data_access from information_schema.routines
......
...@@ -277,9 +277,8 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink) ...@@ -277,9 +277,8 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink)
record being compared against. record being compared against.
RETURN RETURN
< 0 key of record < key
= 0 key of record == key = 0 key of record == key
> 0 key of record > key != 0 key of record != key
*/ */
static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length) static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length)
......
...@@ -2486,7 +2486,7 @@ int Field_new_decimal::store(longlong nr) ...@@ -2486,7 +2486,7 @@ int Field_new_decimal::store(longlong nr)
int err; int err;
if ((err= int2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, if ((err= int2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
nr, false, &decimal_value))) nr, FALSE, &decimal_value)))
{ {
if (check_overflow(err)) if (check_overflow(err))
set_value_on_overflow(&decimal_value, decimal_value.sign()); set_value_on_overflow(&decimal_value, decimal_value.sign());
...@@ -6829,7 +6829,12 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) ...@@ -6829,7 +6829,12 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
&not_used))) &not_used)))
{ {
uint conv_errors; uint conv_errors;
tmpstr.copy(from, length, cs, field_charset, &conv_errors); if (tmpstr.copy(from, length, cs, field_charset, &conv_errors))
{
/* Fatal OOM error */
bzero(ptr,Field_blob::pack_length());
return -1;
}
from= tmpstr.ptr(); from= tmpstr.ptr();
length= tmpstr.length(); length= tmpstr.length();
if (conv_errors) if (conv_errors)
......
...@@ -1399,27 +1399,25 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) ...@@ -1399,27 +1399,25 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
int ha_federated::delete_row(const byte *buf) int ha_federated::delete_row(const byte *buf)
{ {
uint x= 0;
char delete_buffer[IO_SIZE]; char delete_buffer[IO_SIZE];
char data_buffer[IO_SIZE]; char data_buffer[IO_SIZE];
String delete_string(delete_buffer, sizeof(delete_buffer), &my_charset_bin); String delete_string(delete_buffer, sizeof(delete_buffer), &my_charset_bin);
delete_string.length(0);
String data_string(data_buffer, sizeof(data_buffer), &my_charset_bin); String data_string(data_buffer, sizeof(data_buffer), &my_charset_bin);
data_string.length(0);
DBUG_ENTER("ha_federated::delete_row"); DBUG_ENTER("ha_federated::delete_row");
delete_string.length(0);
delete_string.append("DELETE FROM `"); delete_string.append("DELETE FROM `");
delete_string.append(share->table_base_name); delete_string.append(share->table_base_name);
delete_string.append("`"); delete_string.append("`");
delete_string.append(" WHERE "); delete_string.append(" WHERE ");
for (Field **field= table->field; *field; field++, x++) for (Field **field= table->field; *field; field++)
{ {
delete_string.append((*field)->field_name); Field *cur_field= *field;
data_string.length(0);
delete_string.append(cur_field->field_name);
if ((*field)->is_null()) if (cur_field->is_null_in_record((const uchar*) buf))
{ {
delete_string.append(" IS "); delete_string.append(" IS ");
data_string.append("NULL"); data_string.append("NULL");
...@@ -1427,17 +1425,15 @@ int ha_federated::delete_row(const byte *buf) ...@@ -1427,17 +1425,15 @@ int ha_federated::delete_row(const byte *buf)
else else
{ {
delete_string.append("="); delete_string.append("=");
(*field)->val_str(&data_string); cur_field->val_str(&data_string, (char*) buf+ cur_field->offset());
(*field)->quote_data(&data_string); cur_field->quote_data(&data_string);
} }
delete_string.append(data_string); delete_string.append(data_string);
data_string.length(0); delete_string.append(" AND ");
if (x + 1 < table->s->fields)
delete_string.append(" AND ");
} }
delete_string.length(delete_string.length()-5); // Remove AND
delete_string.append(" LIMIT 1"); delete_string.append(" LIMIT 1");
DBUG_PRINT("info", DBUG_PRINT("info",
("Delete sql: %s", delete_string.c_ptr_quick())); ("Delete sql: %s", delete_string.c_ptr_quick()));
......
This diff is collapsed.
...@@ -4381,18 +4381,16 @@ my_decimal *Item_ref::val_decimal(my_decimal *decimal_value) ...@@ -4381,18 +4381,16 @@ my_decimal *Item_ref::val_decimal(my_decimal *decimal_value)
int Item_ref::save_in_field(Field *to, bool no_conversions) int Item_ref::save_in_field(Field *to, bool no_conversions)
{ {
int res; int res;
if(result_field){ if (result_field)
{
if (result_field->is_null()) if (result_field->is_null())
{ {
null_value= 1; null_value= 1;
return set_field_to_null_with_conversions(to, no_conversions); return set_field_to_null_with_conversions(to, no_conversions);
} }
else to->set_notnull();
{ field_conv(to, result_field);
to->set_notnull(); null_value= 0;
field_conv(to, result_field);
null_value= 0;
}
return 0; return 0;
} }
res= (*ref)->save_in_field(to, no_conversions); res= (*ref)->save_in_field(to, no_conversions);
...@@ -5221,8 +5219,7 @@ enum_field_types Item_type_holder::get_real_type(Item *item) ...@@ -5221,8 +5219,7 @@ enum_field_types Item_type_holder::get_real_type(Item *item)
acceptable information for client in send_field, so we make field acceptable information for client in send_field, so we make field
type from expression type. type from expression type.
*/ */
switch (item->result_type()) switch (item->result_type()) {
{
case STRING_RESULT: case STRING_RESULT:
return MYSQL_TYPE_VAR_STRING; return MYSQL_TYPE_VAR_STRING;
case INT_RESULT: case INT_RESULT:
......
...@@ -275,7 +275,7 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type) ...@@ -275,7 +275,7 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type)
owner= item; owner= item;
func= comparator_matrix[type] func= comparator_matrix[type]
[test(owner->functype() == Item_func::EQUAL_FUNC)]; [test(owner->functype() == Item_func::EQUAL_FUNC)];
switch(type) { switch (type) {
case ROW_RESULT: case ROW_RESULT:
{ {
uint n= (*a)->cols(); uint n= (*a)->cols();
...@@ -1578,6 +1578,21 @@ my_decimal *Item_func_case::val_decimal(my_decimal *decimal_value) ...@@ -1578,6 +1578,21 @@ my_decimal *Item_func_case::val_decimal(my_decimal *decimal_value)
} }
bool Item_func_case::fix_fields(THD *thd, struct st_table_list *tables,
Item **ref)
{
/*
buff should match stack usage from
Item_func_case::val_int() -> Item_func_case::find_item()
*/
char buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(longlong)*2];
if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
return TRUE; // Fatal error flag is set!
return Item_func::fix_fields(thd, tables, ref);
}
void Item_func_case::fix_length_and_dec() void Item_func_case::fix_length_and_dec()
{ {
Item **agg; Item **agg;
......
...@@ -566,6 +566,7 @@ public: ...@@ -566,6 +566,7 @@ public:
longlong val_int(); longlong val_int();
String *val_str(String *); String *val_str(String *);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool fix_fields(THD *thd,struct st_table_list *tlist, Item **ref);
void fix_length_and_dec(); void fix_length_and_dec();
uint decimal_precision() const; uint decimal_precision() const;
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
......
...@@ -1880,8 +1880,7 @@ void Item_func_round::fix_length_and_dec() ...@@ -1880,8 +1880,7 @@ void Item_func_round::fix_length_and_dec()
return; return;
} }
switch (args[0]->result_type()) switch (args[0]->result_type()) {
{
case REAL_RESULT: case REAL_RESULT:
case STRING_RESULT: case STRING_RESULT:
hybrid_type= REAL_RESULT; hybrid_type= REAL_RESULT;
...@@ -1889,16 +1888,17 @@ void Item_func_round::fix_length_and_dec() ...@@ -1889,16 +1888,17 @@ void Item_func_round::fix_length_and_dec()
max_length= float_length(decimals); max_length= float_length(decimals);
break; break;
case INT_RESULT: case INT_RESULT:
if ((decimals_to_set==0) && if (!decimals_to_set &&
(truncate || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS))) (truncate || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS)))
{ {
int length_can_increase= test(!truncate && (args[1]->val_int() < 0));
max_length= args[0]->max_length + length_can_increase;
/* Here we can keep INT_RESULT */ /* Here we can keep INT_RESULT */
hybrid_type= INT_RESULT; hybrid_type= INT_RESULT;
int length_can_increase= !truncate && (args[1]->val_int() < 0);
max_length= args[0]->max_length + length_can_increase;
decimals= 0; decimals= 0;
break; break;
} }
/* fall through */
case DECIMAL_RESULT: case DECIMAL_RESULT:
{ {
hybrid_type= DECIMAL_RESULT; hybrid_type= DECIMAL_RESULT;
...@@ -4446,7 +4446,8 @@ err: ...@@ -4446,7 +4446,8 @@ err:
bool Item_func_match::eq(const Item *item, bool binary_cmp) const bool Item_func_match::eq(const Item *item, bool binary_cmp) const
{ {
if (item->type() != FUNC_ITEM || ((Item_func*)item)->functype() != FT_FUNC || if (item->type() != FUNC_ITEM ||
((Item_func*)item)->functype() != FT_FUNC ||
flags != ((Item_func_match*)item)->flags) flags != ((Item_func_match*)item)->flags)
return 0; return 0;
...@@ -4807,7 +4808,7 @@ Item_func_sp::execute(Item **itp) ...@@ -4807,7 +4808,7 @@ Item_func_sp::execute(Item **itp)
ulong old_client_capabilites; ulong old_client_capabilites;
int res= -1; int res= -1;
bool save_in_sub_stmt= thd->transaction.in_sub_stmt; bool save_in_sub_stmt= thd->transaction.in_sub_stmt;
my_bool nsok; my_bool save_no_send_ok;
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
st_sp_security_context save_ctx; st_sp_security_context save_ctx;
#endif #endif
...@@ -4822,7 +4823,7 @@ Item_func_sp::execute(Item **itp) ...@@ -4822,7 +4823,7 @@ Item_func_sp::execute(Item **itp)
thd->client_capabilities &= ~CLIENT_MULTI_RESULTS; thd->client_capabilities &= ~CLIENT_MULTI_RESULTS;
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
nsok= thd->net.no_send_ok; save_no_send_ok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE; thd->net.no_send_ok= TRUE;
#endif #endif
...@@ -4834,7 +4835,7 @@ Item_func_sp::execute(Item **itp) ...@@ -4834,7 +4835,7 @@ Item_func_sp::execute(Item **itp)
if (save_ctx.changed && if (save_ctx.changed &&
check_routine_access(thd, EXECUTE_ACL, check_routine_access(thd, EXECUTE_ACL,
m_sp->m_db.str, m_sp->m_name.str, 0, 0)) m_sp->m_db.str, m_sp->m_name.str, 0, 0))
goto error_check; goto error_check_ctx;
#endif #endif
/* /*
Like for SPs, we don't binlog the substatements. If the statement which Like for SPs, we don't binlog the substatements. If the statement which
...@@ -4857,8 +4858,8 @@ Item_func_sp::execute(Item **itp) ...@@ -4857,8 +4858,8 @@ Item_func_sp::execute(Item **itp)
ER_FAILED_ROUTINE_BREAK_BINLOG, ER_FAILED_ROUTINE_BREAK_BINLOG,
ER(ER_FAILED_ROUTINE_BREAK_BINLOG)); ER(ER_FAILED_ROUTINE_BREAK_BINLOG));
error_check_ctx:
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
error_check_ctx:
sp_restore_security_context(thd, m_sp, &save_ctx); sp_restore_security_context(thd, m_sp, &save_ctx);
#endif #endif
...@@ -4866,7 +4867,7 @@ error_check_ctx: ...@@ -4866,7 +4867,7 @@ error_check_ctx:
error_check: error_check:
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok; thd->net.no_send_ok= save_no_send_ok;
#endif #endif
thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS; thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS;
......
...@@ -2992,9 +2992,7 @@ int win_main(int argc, char **argv) ...@@ -2992,9 +2992,7 @@ int win_main(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
#endif #endif
{ {
DEBUGGER_OFF; DEBUGGER_OFF;
MY_INIT(argv[0]); // init my_sys library & pthreads MY_INIT(argv[0]); // init my_sys library & pthreads
#ifdef _CUSTOMSTARTUPCONFIG_ #ifdef _CUSTOMSTARTUPCONFIG_
...@@ -3006,14 +3004,15 @@ int main(int argc, char **argv) ...@@ -3006,14 +3004,15 @@ int main(int argc, char **argv)
#endif #endif
#ifdef __WIN__ #ifdef __WIN__
/* Before performing any socket operation (like retrieving hostname */ /*
/* in init_common_variables we have to call WSAStartup */ Before performing any socket operation (like retrieving hostname
if (!opt_disable_networking) in init_common_variables we have to call WSAStartup
*/
{ {
WSADATA WsaData; WSADATA WsaData;
if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData)) if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData))
{ {
/* errors are not read yet, so we use test here */ /* errors are not read yet, so we use english text here */
my_message(ER_WSAS_FAILED, "WSAStartup Failed", MYF(0)); my_message(ER_WSAS_FAILED, "WSAStartup Failed", MYF(0));
unireg_abort(1); unireg_abort(1);
} }
......
...@@ -3528,15 +3528,12 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) ...@@ -3528,15 +3528,12 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
{ {
/* Optimize NOT BETWEEN and NOT IN */ /* Optimize NOT BETWEEN and NOT IN */
Item *arg= cond_func->arguments()[0]; Item *arg= cond_func->arguments()[0];
if (arg->type() == Item::FUNC_ITEM) if (arg->type() != Item::FUNC_ITEM)
{ DBUG_RETURN(0);
cond_func= (Item_func*) arg; cond_func= (Item_func*) arg;
if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE)
DBUG_RETURN(0);
inv= TRUE;
}
else
DBUG_RETURN(0); DBUG_RETURN(0);
inv= TRUE;
} }
else if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) else if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE)
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -8178,7 +8175,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next() ...@@ -8178,7 +8175,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next()
(have_max && have_min && (max_res == 0))); (have_max && have_min && (max_res == 0)));
} }
/* /*
If this is a just a GROUP BY or DISTINCT without MIN or MAX and there If this is just a GROUP BY or DISTINCT without MIN or MAX and there
are equality predicates for the key parts after the group, find the are equality predicates for the key parts after the group, find the
first sub-group with the extended prefix. first sub-group with the extended prefix.
*/ */
...@@ -8581,23 +8578,21 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range() ...@@ -8581,23 +8578,21 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
if ((result == HA_ERR_KEY_NOT_FOUND) && (cur_range->flag & EQ_RANGE)) if ((result == HA_ERR_KEY_NOT_FOUND) && (cur_range->flag & EQ_RANGE))
continue; /* Check the next range. */ continue; /* Check the next range. */
else if (result) if (result)
{
/* /*
In no key was found with this upper bound, there certainly are no keys In no key was found with this upper bound, there certainly are no keys
in the ranges to the left. in the ranges to the left.
*/ */
return result; return result;
}
/* A key was found. */ /* A key was found. */
if (cur_range->flag & EQ_RANGE) if (cur_range->flag & EQ_RANGE)
return result; /* No need to perform the checks below for equal keys. */ return 0; /* No need to perform the checks below for equal keys. */
/* Check if record belongs to the current group. */ /* Check if record belongs to the current group. */
if (key_cmp(index_info->key_part, group_prefix, real_prefix_len)) if (key_cmp(index_info->key_part, group_prefix, real_prefix_len))
{ continue; // Row not found
result = HA_ERR_KEY_NOT_FOUND;
continue;
}
/* If there is a lower limit, check if the found key is in the range. */ /* If there is a lower limit, check if the found key is in the range. */
if ( !(cur_range->flag & NO_MIN_RANGE) ) if ( !(cur_range->flag & NO_MIN_RANGE) )
......
...@@ -653,6 +653,14 @@ typedef struct system_status_var ...@@ -653,6 +653,14 @@ typedef struct system_status_var
void free_tmp_table(THD *thd, TABLE *entry); void free_tmp_table(THD *thd, TABLE *entry);
/* The following macro is to make init of Query_arena simpler */
#ifndef DBUG_OFF
#define INIT_ARENA_DBUG_INFO is_backup_arena= 0
#else
#define INIT_ARENA_DBUG_INFO
#endif
class Query_arena class Query_arena
{ {
public: public:
...@@ -664,9 +672,6 @@ public: ...@@ -664,9 +672,6 @@ public:
MEM_ROOT *mem_root; // Pointer to current memroot MEM_ROOT *mem_root; // Pointer to current memroot
#ifndef DBUG_OFF #ifndef DBUG_OFF
bool is_backup_arena; /* True if this arena is used for backup. */ bool is_backup_arena; /* True if this arena is used for backup. */
#define INIT_ARENA_DBUG_INFO is_backup_arena= 0
#else
#define INIT_ARENA_DBUG_INFO
#endif #endif
enum enum_state enum enum_state
{ {
...@@ -691,7 +696,6 @@ public: ...@@ -691,7 +696,6 @@ public:
*/ */
Query_arena() { INIT_ARENA_DBUG_INFO; } Query_arena() { INIT_ARENA_DBUG_INFO; }
#undef INIT_ARENA_DBUG_INFO
virtual Type type() const; virtual Type type() const;
virtual ~Query_arena() {}; virtual ~Query_arena() {};
......
...@@ -2355,10 +2355,6 @@ mysql_execute_command(THD *thd) ...@@ -2355,10 +2355,6 @@ mysql_execute_command(THD *thd)
} }
#endif /* !HAVE_REPLICATION */ #endif /* !HAVE_REPLICATION */
/* /*
When option readonly is set deny operations which change tables. When option readonly is set deny operations which change tables.
Except for the replication thread and the 'super' users. Except for the replication thread and the 'super' users.
......
...@@ -7987,9 +7987,11 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, ...@@ -7987,9 +7987,11 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
convert_blob_length); convert_blob_length);
} }
case Item::REF_ITEM: case Item::REF_ITEM:
if ( item->real_item()->type() == Item::FIELD_ITEM) {
Item *tmp_item;
if ((tmp_item= item->real_item())->type() == Item::FIELD_ITEM)
{ {
Item_field *field= (Item_field*) *((Item_ref*)item)->ref; Item_field *field= (Item_field*) tmp_item;
Field *new_field= create_tmp_field_from_field(thd, Field *new_field= create_tmp_field_from_field(thd,
(*from_field= field->field), (*from_field= field->field),
item->name, table, item->name, table,
...@@ -7999,6 +8001,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, ...@@ -7999,6 +8001,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
item->set_result_field(new_field); item->set_result_field(new_field);
return new_field; return new_field;
} }
}
case Item::FUNC_ITEM: case Item::FUNC_ITEM:
case Item::COND_ITEM: case Item::COND_ITEM:
case Item::FIELD_AVG_ITEM: case Item::FIELD_AVG_ITEM:
...@@ -11807,14 +11810,13 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref) ...@@ -11807,14 +11810,13 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
SYNOPSIS SYNOPSIS
find_order_in_list() find_order_in_list()
thd [in] Pointer to current thread structure thd Pointer to current thread structure
ref_pointer_array [in/out] All select, group and order by fields ref_pointer_array All select, group and order by fields
tables [in] List of tables to search in (usually FROM clause) tables List of tables to search in (usually FROM clause)
order [in] Column reference to be resolved order Column reference to be resolved
fields [in] List of fields to search in (usually SELECT list) fields List of fields to search in (usually SELECT list)
all_fields [in/out] All select, group and order by fields all_fields All select, group and order by fields
is_group_field [in] True if order is a GROUP field, false if is_group_field True if order is a GROUP field, false if ORDER by field
ORDER by field
DESCRIPTION DESCRIPTION
Given a column reference (represented by 'order') from a GROUP BY or ORDER Given a column reference (represented by 'order') from a GROUP BY or ORDER
...@@ -11831,6 +11833,8 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref) ...@@ -11831,6 +11833,8 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
RETURN RETURN
FALSE if OK FALSE if OK
TRUE if error occurred TRUE if error occurred
ref_pointer_array and all_fields are updated
*/ */
static bool static bool
...@@ -11882,6 +11886,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, ...@@ -11882,6 +11886,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
/* Lookup the current GROUP field in the FROM clause. */ /* Lookup the current GROUP field in the FROM clause. */
order_item_type= order_item->type(); order_item_type= order_item->type();
from_field= (Field*) not_found_field;
if (is_group_field && if (is_group_field &&
order_item_type == Item::FIELD_ITEM || order_item_type == Item::FIELD_ITEM ||
order_item_type == Item::REF_ITEM) order_item_type == Item::REF_ITEM)
...@@ -11889,14 +11894,11 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, ...@@ -11889,14 +11894,11 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
from_field= find_field_in_tables(thd, (Item_ident*) order_item, tables, from_field= find_field_in_tables(thd, (Item_ident*) order_item, tables,
&view_ref, IGNORE_ERRORS, TRUE, &view_ref, IGNORE_ERRORS, TRUE,
FALSE); FALSE);
if(!from_field) if (!from_field)
from_field= (Field*) not_found_field; from_field= (Field*) not_found_field;
} }
else
from_field= (Field*) not_found_field;
if (from_field == not_found_field || if (from_field == not_found_field ||
from_field &&
(from_field != view_ref_found ? (from_field != view_ref_found ?
/* it is field of base table => check that fields are same */ /* it is field of base table => check that fields are same */
((*select_item)->type() == Item::FIELD_ITEM && ((*select_item)->type() == Item::FIELD_ITEM &&
...@@ -11909,37 +11911,40 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, ...@@ -11909,37 +11911,40 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
view_ref->type() == Item::REF_ITEM && view_ref->type() == Item::REF_ITEM &&
((Item_ref *) (*select_item))->ref == ((Item_ref *) (*select_item))->ref ==
((Item_ref *) view_ref)->ref))) ((Item_ref *) view_ref)->ref)))
{
/* /*
If there is no such field in the FROM clause, or it is the same field as If there is no such field in the FROM clause, or it is the same field
the one found in the SELECT clause, then use the Item created for the as the one found in the SELECT clause, then use the Item created for
SELECT field. As a result if there was a derived field that 'shadowed' the SELECT field. As a result if there was a derived field that
a table field with the same name, the table field will be chosen over 'shadowed' a table field with the same name, the table field will be
the derived field. chosen over the derived field.
*/ */
{
order->item= ref_pointer_array + counter; order->item= ref_pointer_array + counter;
order->in_field_list=1; order->in_field_list=1;
return FALSE; return FALSE;
} }
else else
{
/* /*
There is a field with the same name in the FROM clause. This is the field There is a field with the same name in the FROM clause. This
that will be chosen. In this case we issue a warning so the user knows is the field that will be chosen. In this case we issue a
that the field from the FROM clause overshadows the column reference from warning so the user knows that the field from the FROM clause
the SELECT list. overshadows the column reference from the SELECT list.
*/ */
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_NON_UNIQ_ERROR, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_NON_UNIQ_ERROR,
ER(ER_NON_UNIQ_ERROR), from_field->field_name, ER(ER_NON_UNIQ_ERROR), from_field->field_name,
current_thd->where); current_thd->where);
}
} }
order->in_field_list=0; order->in_field_list=0;
/* /*
The call to order_item->fix_fields() means that here we resolve 'order_item' The call to order_item->fix_fields() means that here we resolve
to a column from a table in the list 'tables', or to a column in some outer 'order_item' to a column from a table in the list 'tables', or to
query. Exactly because of the second case we come to this point even if a column in some outer query. Exactly because of the second case
(select_item == not_found_item), inspite of that fix_fields() calls we come to this point even if (select_item == not_found_item),
find_item_in_list() one more time. inspite of that fix_fields() calls find_item_in_list() one more
time.
We check order_item->fixed because Item_func_group_concat can put We check order_item->fixed because Item_func_group_concat can put
arguments for which fix_fields already was called. arguments for which fix_fields already was called.
......
...@@ -656,14 +656,14 @@ bool st_select_lex::cleanup() ...@@ -656,14 +656,14 @@ bool st_select_lex::cleanup()
if (join) if (join)
{ {
DBUG_ASSERT((st_select_lex*)join->select_lex == this); DBUG_ASSERT((st_select_lex*)join->select_lex == this);
error|= join->destroy(); error= join->destroy();
delete join; delete join;
join= 0; join= 0;
} }
for (SELECT_LEX_UNIT *lex_unit= first_inner_unit(); lex_unit ; for (SELECT_LEX_UNIT *lex_unit= first_inner_unit(); lex_unit ;
lex_unit= lex_unit->next_unit()) lex_unit= lex_unit->next_unit())
{ {
error|= lex_unit->cleanup(); error= (bool) ((uint) error | (uint) lex_unit->cleanup());
} }
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
...@@ -58,13 +58,13 @@ static void make_unique_view_field_name(Item *target, ...@@ -58,13 +58,13 @@ static void make_unique_view_field_name(Item *target,
char *name= (target->orig_name ? char *name= (target->orig_name ?
target->orig_name : target->orig_name :
target->name); target->name);
uint name_len; uint name_len, attempt;
uint attempt= 0;
char buff[NAME_LEN+1]; char buff[NAME_LEN+1];
for (;; attempt++) List_iterator_fast<Item> itc(item_list);
for (attempt= 0;; attempt++)
{ {
Item *check; Item *check;
List_iterator_fast<Item> itc(item_list);
bool ok= TRUE; bool ok= TRUE;
if (attempt) if (attempt)
...@@ -84,6 +84,7 @@ static void make_unique_view_field_name(Item *target, ...@@ -84,6 +84,7 @@ static void make_unique_view_field_name(Item *target,
} while (check != last_element); } while (check != last_element);
if (ok) if (ok)
break; break;
itc.rewind();
} }
target->orig_name= target->name; target->orig_name= target->name;
...@@ -305,13 +306,14 @@ bool mysql_create_view(THD *thd, ...@@ -305,13 +306,14 @@ bool mysql_create_view(THD *thd,
{ {
Item *item; Item *item;
List_iterator_fast<Item> it(select_lex->item_list); List_iterator_fast<Item> it(select_lex->item_list);
List_iterator_fast<Item> itc(select_lex->item_list);
while ((item= it++)) while ((item= it++))
{ {
Item *check; Item *check;
List_iterator_fast<Item> itc(select_lex->item_list);
/* treat underlying fields like set by user names */ /* treat underlying fields like set by user names */
if (item->real_item()->type() == Item::FIELD_ITEM) if (item->real_item()->type() == Item::FIELD_ITEM)
item->is_autogenerated_name= FALSE; item->is_autogenerated_name= FALSE;
itc.rewind();
while ((check= itc++) && check != item) while ((check= itc++) && check != item)
{ {
if (my_strcasecmp(system_charset_info, item->name, check->name) == 0) if (my_strcasecmp(system_charset_info, item->name, check->name) == 0)
...@@ -822,6 +824,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) ...@@ -822,6 +824,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
old_lex->can_use_merged()) && old_lex->can_use_merged()) &&
!old_lex->can_not_use_merged()) !old_lex->can_not_use_merged())
{ {
List_iterator_fast<TABLE_LIST> ti(view_select->top_join_list);
/* lex should contain at least one table */ /* lex should contain at least one table */
DBUG_ASSERT(view_tables != 0); DBUG_ASSERT(view_tables != 0);
...@@ -865,13 +868,11 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) ...@@ -865,13 +868,11 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
nested_join->join_list= view_select->top_join_list; nested_join->join_list= view_select->top_join_list;
/* re-nest tables of VIEW */ /* re-nest tables of VIEW */
ti.rewind();
while ((tbl= ti++))
{ {
List_iterator_fast<TABLE_LIST> ti(nested_join->join_list); tbl->join_list= &nested_join->join_list;
while ((tbl= ti++)) tbl->embedding= table;
{
tbl->join_list= &nested_join->join_list;
tbl->embedding= table;
}
} }
} }
......
...@@ -2790,7 +2790,7 @@ static void test_mb(CHARSET_INFO *cs, uchar *s) ...@@ -2790,7 +2790,7 @@ static void test_mb(CHARSET_INFO *cs, uchar *s)
{ {
while(*s) while(*s)
{ {
if(my_ismbhead_utf8(cs,*s)) if (my_ismbhead_utf8(cs,*s))
{ {
int len=my_mbcharlen_utf8(cs,*s); int len=my_mbcharlen_utf8(cs,*s);
while(len--) while(len--)
......
...@@ -218,14 +218,6 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, uint len) ...@@ -218,14 +218,6 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, uint len)
struct my_cs_file_section_st *s; struct my_cs_file_section_st *s;
int state= (int)((s=cs_file_sec(st->attr, (int) strlen(st->attr))) ? s->state : 0); int state= (int)((s=cs_file_sec(st->attr, (int) strlen(st->attr))) ? s->state : 0);
#ifndef DBUG_OFF
if(0){
char str[1024];
mstr(str,attr,len,sizeof(str)-1);
printf("VALUE %d %s='%s'\n",state,st->attr,str);
}
#endif
switch (state) { switch (state) {
case _CS_ID: case _CS_ID:
i->cs.number= strtol(attr,(char**)NULL,10); i->cs.number= strtol(attr,(char**)NULL,10);
......
...@@ -1492,17 +1492,18 @@ decimal_round(decimal_t *from, decimal_t *to, int scale, ...@@ -1492,17 +1492,18 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
{ {
int do_inc= FALSE; int do_inc= FALSE;
DBUG_ASSERT(frac0+intg0 >= 0); DBUG_ASSERT(frac0+intg0 >= 0);
switch (round_digit) switch (round_digit) {
{
case 0: case 0:
{ {
dec1 *p0= buf0 + (frac1-frac0); dec1 *p0= buf0 + (frac1-frac0);
for (; p0 > buf0; p0--) for (; p0 > buf0; p0--)
{
if (*p0) if (*p0)
{ {
do_inc= TRUE; do_inc= TRUE;
break; break;
}; }
}
break; break;
} }
case 5: case 5:
...@@ -1511,9 +1512,10 @@ decimal_round(decimal_t *from, decimal_t *to, int scale, ...@@ -1511,9 +1512,10 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
do_inc= (x>5) || ((x == 5) && do_inc= (x>5) || ((x == 5) &&
(mode == HALF_UP || (frac0+intg0 > 0 && *buf0 & 1))); (mode == HALF_UP || (frac0+intg0 > 0 && *buf0 & 1)));
break; break;
}; }
default:; default:
}; break;
}
if (do_inc) if (do_inc)
{ {
if (frac0+intg0>0) if (frac0+intg0>0)
...@@ -1567,9 +1569,9 @@ decimal_round(decimal_t *from, decimal_t *to, int scale, ...@@ -1567,9 +1569,9 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
*buf1=1; *buf1=1;
to->intg++; to->intg++;
} }
/* Here we check 999.9 -> 1000 case when we need to increase intg */
else else
{ {
/* Here we check 999.9 -> 1000 case when we need to increase intg */
int first_dig= to->intg % DIG_PER_DEC1; int first_dig= to->intg % DIG_PER_DEC1;
/* first_dig==0 should be handled above in the 'if' */ /* first_dig==0 should be handled above in the 'if' */
if (first_dig && (*buf1 >= powers10[first_dig])) if (first_dig && (*buf1 >= powers10[first_dig]))
......
...@@ -96,13 +96,13 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) ...@@ -96,13 +96,13 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a)
a->end=p->cur; a->end=p->cur;
lex=a->beg[0]; lex=a->beg[0];
} }
else if ( (p->cur[0]=='"') || (p->cur[0]=='\'') ) else if ( (p->cur[0] == '"') || (p->cur[0] == '\'') )
{ {
p->cur++; p->cur++;
for( ; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++) for( ; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++)
{} {}
a->end=p->cur; a->end=p->cur;
if (a->beg[0]==p->cur[0])p->cur++; if (a->beg[0] == p->cur[0])p->cur++;
a->beg++; a->beg++;
my_xml_norm_text(a); my_xml_norm_text(a);
lex=MY_XML_STRING; lex=MY_XML_STRING;
...@@ -169,8 +169,8 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen) ...@@ -169,8 +169,8 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen)
int rc; int rc;
/* Find previous '.' or beginning */ /* Find previous '.' or beginning */
for( e=p->attrend; (e>p->attr) && (e[0]!='.') ; e--); for( e=p->attrend; (e>p->attr) && (e[0] != '.') ; e--);
glen = (uint) ((e[0]=='.') ? (p->attrend-e-1) : p->attrend-e); glen = (uint) ((e[0] == '.') ? (p->attrend-e-1) : p->attrend-e);
if (str && (slen != glen)) if (str && (slen != glen))
{ {
...@@ -199,7 +199,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) ...@@ -199,7 +199,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
while ( p->cur < p->end ) while ( p->cur < p->end )
{ {
MY_XML_ATTR a; MY_XML_ATTR a;
if(p->cur[0]=='<') if (p->cur[0] == '<')
{ {
int lex; int lex;
int question=0; int question=0;
...@@ -207,40 +207,40 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) ...@@ -207,40 +207,40 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
lex=my_xml_scan(p,&a); lex=my_xml_scan(p,&a);
if (MY_XML_COMMENT==lex) if (MY_XML_COMMENT == lex)
{ {
continue; continue;
} }
lex=my_xml_scan(p,&a); lex=my_xml_scan(p,&a);
if (MY_XML_SLASH==lex) if (MY_XML_SLASH == lex)
{ {
if(MY_XML_IDENT!=(lex=my_xml_scan(p,&a))) if (MY_XML_IDENT != (lex=my_xml_scan(p,&a)))
{ {
sprintf(p->errstr,"1: %s unexpected (ident wanted)",lex2str(lex)); sprintf(p->errstr,"1: %s unexpected (ident wanted)",lex2str(lex));
return MY_XML_ERROR; return MY_XML_ERROR;
} }
if(MY_XML_OK!=my_xml_leave(p,a.beg,(uint) (a.end-a.beg))) if (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg)))
return MY_XML_ERROR; return MY_XML_ERROR;
lex=my_xml_scan(p,&a); lex=my_xml_scan(p,&a);
goto gt; goto gt;
} }
if (MY_XML_EXCLAM==lex) if (MY_XML_EXCLAM == lex)
{ {
lex=my_xml_scan(p,&a); lex=my_xml_scan(p,&a);
exclam=1; exclam=1;
} }
else if (MY_XML_QUESTION==lex) else if (MY_XML_QUESTION == lex)
{ {
lex=my_xml_scan(p,&a); lex=my_xml_scan(p,&a);
question=1; question=1;
} }
if (MY_XML_IDENT==lex) if (MY_XML_IDENT == lex)
{ {
if(MY_XML_OK!=my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) if (MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg)))
return MY_XML_ERROR; return MY_XML_ERROR;
} }
else else
...@@ -250,17 +250,18 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) ...@@ -250,17 +250,18 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
return MY_XML_ERROR; return MY_XML_ERROR;
} }
while ((MY_XML_IDENT==(lex=my_xml_scan(p,&a))) || (MY_XML_STRING==lex)) while ((MY_XML_IDENT == (lex=my_xml_scan(p,&a))) ||
(MY_XML_STRING == lex))
{ {
MY_XML_ATTR b; MY_XML_ATTR b;
if(MY_XML_EQ==(lex=my_xml_scan(p,&b))) if (MY_XML_EQ == (lex=my_xml_scan(p,&b)))
{ {
lex=my_xml_scan(p,&b); lex=my_xml_scan(p,&b);
if ( (lex==MY_XML_IDENT) || (lex==MY_XML_STRING) ) if ( (lex == MY_XML_IDENT) || (lex == MY_XML_STRING) )
{ {
if((MY_XML_OK!=my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) || if ((MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) ||
(MY_XML_OK!=my_xml_value(p,b.beg,(uint) (b.end-b.beg))) || (MY_XML_OK != my_xml_value(p,b.beg,(uint) (b.end-b.beg))) ||
(MY_XML_OK!=my_xml_leave(p,a.beg,(uint) (a.end-a.beg)))) (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg))))
return MY_XML_ERROR; return MY_XML_ERROR;
} }
else else
...@@ -270,19 +271,19 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) ...@@ -270,19 +271,19 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
return MY_XML_ERROR; return MY_XML_ERROR;
} }
} }
else if ( (MY_XML_STRING==lex) || (MY_XML_IDENT==lex) ) else if ((MY_XML_STRING == lex) || (MY_XML_IDENT == lex))
{ {
if((MY_XML_OK!=my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) || if ((MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) ||
(MY_XML_OK!=my_xml_leave(p,a.beg,(uint) (a.end-a.beg)))) (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg))))
return MY_XML_ERROR; return MY_XML_ERROR;
} }
else else
break; break;
} }
if (lex==MY_XML_SLASH) if (lex == MY_XML_SLASH)
{ {
if(MY_XML_OK!=my_xml_leave(p,NULL,0)) if (MY_XML_OK != my_xml_leave(p,NULL,0))
return MY_XML_ERROR; return MY_XML_ERROR;
lex=my_xml_scan(p,&a); lex=my_xml_scan(p,&a);
} }
...@@ -290,23 +291,23 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) ...@@ -290,23 +291,23 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
gt: gt:
if (question) if (question)
{ {
if (lex!=MY_XML_QUESTION) if (lex != MY_XML_QUESTION)
{ {
sprintf(p->errstr,"6: %s unexpected ('?' wanted)",lex2str(lex)); sprintf(p->errstr,"6: %s unexpected ('?' wanted)",lex2str(lex));
return MY_XML_ERROR; return MY_XML_ERROR;
} }
if(MY_XML_OK!=my_xml_leave(p,NULL,0)) if (MY_XML_OK != my_xml_leave(p,NULL,0))
return MY_XML_ERROR; return MY_XML_ERROR;
lex=my_xml_scan(p,&a); lex=my_xml_scan(p,&a);
} }
if (exclam) if (exclam)
{ {
if(MY_XML_OK!=my_xml_leave(p,NULL,0)) if (MY_XML_OK != my_xml_leave(p,NULL,0))
return MY_XML_ERROR; return MY_XML_ERROR;
} }
if (lex!=MY_XML_GT) if (lex != MY_XML_GT)
{ {
sprintf(p->errstr,"5: %s unexpected ('>' wanted)",lex2str(lex)); sprintf(p->errstr,"5: %s unexpected ('>' wanted)",lex2str(lex));
return MY_XML_ERROR; return MY_XML_ERROR;
...@@ -315,11 +316,11 @@ gt: ...@@ -315,11 +316,11 @@ gt:
else else
{ {
a.beg=p->cur; a.beg=p->cur;
for ( ; (p->cur < p->end) && (p->cur[0]!='<') ; p->cur++); for ( ; (p->cur < p->end) && (p->cur[0] != '<') ; p->cur++);
a.end=p->cur; a.end=p->cur;
my_xml_norm_text(&a); my_xml_norm_text(&a);
if (a.beg!=a.end) if (a.beg != a.end)
{ {
my_xml_value(p,a.beg,(uint) (a.end-a.beg)); my_xml_value(p,a.beg,(uint) (a.end-a.beg));
} }
...@@ -381,7 +382,7 @@ uint my_xml_error_pos(MY_XML_PARSER *p) ...@@ -381,7 +382,7 @@ uint my_xml_error_pos(MY_XML_PARSER *p)
const char *s; const char *s;
for ( s=p->beg ; s<p->cur; s++) for ( s=p->beg ; s<p->cur; s++)
{ {
if (s[0]=='\n') if (s[0] == '\n')
beg=s; beg=s;
} }
return (uint) (p->cur-beg); return (uint) (p->cur-beg);
...@@ -391,9 +392,9 @@ uint my_xml_error_lineno(MY_XML_PARSER *p) ...@@ -391,9 +392,9 @@ uint my_xml_error_lineno(MY_XML_PARSER *p)
{ {
uint res=0; uint res=0;
const char *s; const char *s;
for ( s=p->beg ; s<p->cur; s++) for (s=p->beg ; s<p->cur; s++)
{ {
if (s[0]=='\n') if (s[0] == '\n')
res++; res++;
} }
return res; return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment