Commit 906b210a authored by unknown's avatar unknown
Browse files

Code cleanups during code reviews

Ensure we get error if INSERT IGNORE ... SELECT fails
Fixed wrong key_part->key_length usage in index_merge


client/mysql.cc:
  Code cleanups & simply optimizations
mysql-test/r/information_schema.result:
  Safety
mysql-test/t/information_schema.test:
  Safety
sql/ha_ndbcluster.cc:
  Code cleanups
sql/item.cc:
  Code cleanups
sql/item_subselect.cc:
  Code cleanups
sql/item_sum.cc:
  Code cleanups
sql/opt_range.cc:
  Made get_index_only_read_time() static (instad of inline) to increase portability (function was not declared before use)
  Simple optimization
  Fixed wrong key_part->key_length usage in index_merge
  Removed not used variable n_used_covered
  Indentation fixes & comment cleanups
sql/parse_file.cc:
  Code cleanups
sql/sql_base.cc:
  Code cleanups
sql/sql_bitmap.h:
  Added missing return
sql/sql_insert.cc:
  Ensure we get error if INSERT IGNORE ... SELECT fails
sql/sql_select.cc:
  Code cleanups
sql/sql_show.cc:
  Safety fix if a LOT of errors are ignored
sql/sql_update.cc:
  Code cleanups
sql/table.cc:
  Code cleanups
sql/table.h:
  Code cleanups
sql/uniques.cc:
  Code cleanups
strings/decimal.c:
  Simple optimization
  Code cleanups
parent 87805b68
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -1657,9 +1657,10 @@ int mysql_real_query_for_lazy(const char *buf, int length)
{
  for (uint retry=0;; retry++)
  {
    int error;
    if (!mysql_real_query(&mysql,buf,length))
      return 0;
    int error= put_error(&mysql);
    error= put_error(&mysql);
    if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR || retry > 1 ||
        !opt_reconnect)
      return error;
@@ -2237,22 +2238,23 @@ print_table_data_vertically(MYSQL_RES *result)
  }
}


/* print_warnings should be called right after executing a statement */
static void
print_warnings()

static void print_warnings()
{
  char query[30];
  const char   *query;
  MYSQL_RES    *result;
  MYSQL_ROW    cur;
  my_ulonglong num_rows;

  /* Get the warnings */
  strmov(query,"show warnings");
  query= "show warnings";
  mysql_real_query_for_lazy(query, strlen(query));
  mysql_store_result_for_lazy(&result);

  /* Bail out when no warnings */
  my_ulonglong num_rows = mysql_num_rows(result);
  if (num_rows == 0) 
  if (!(num_rows= mysql_num_rows(result)))
  {
    mysql_free_result(result);
    return;
@@ -2266,13 +2268,12 @@ print_warnings()
  mysql_free_result(result);
}

static const char
*array_value(const char **array, char key)

static const char *array_value(const char **array, char key)
{
  int x;
  for (x= 0; array[x]; x+= 2)
    if (*array[x] == key)
      return array[x + 1];
  for (; *array; array+= 2)
    if (**array == key)
      return array[1];
  return 0;
}

+1 −0
Original line number Diff line number Diff line
DROP TABLE IF EXISTS t0,t1,t2;
show variables where variable_name like "skip_show_database";
Variable_name	Value
skip_show_database	OFF
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,11 @@
# Test for information_schema.schemata &
# show databases

--disable_warnings
DROP TABLE IF EXISTS t0,t1,t2;
--enable_warnings


show variables where variable_name like "skip_show_database";
grant select, update, execute on test.* to mysqltest_2@localhost;
grant select, update on test.* to mysqltest_1@localhost;
+4 −6
Original line number Diff line number Diff line
@@ -2246,8 +2246,7 @@ bool Item_param::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
      SELECT_LEX_UNIT::item set only for subqueries, so test of it presence
      can be barrier to stop before derived table SELECT or very outer SELECT
    */
    for(;
        cursel->master_unit()->item;
    for (; cursel->master_unit()->item;
         cursel= cursel->outer_select())
    {
      Item_subselect *subselect_item= cursel->master_unit()->item;
@@ -2528,8 +2527,7 @@ void mark_select_range_as_dependent(THD *thd,
    resolving)
  */
  SELECT_LEX *previous_select= current_sel;
  for(;
      previous_select->outer_select() != last_select;
  for (; previous_select->outer_select() != last_select;
       previous_select= previous_select->outer_select())
  {
    Item_subselect *prev_subselect_item=
+6 −2
Original line number Diff line number Diff line
@@ -240,8 +240,12 @@ Item_sum_hybrid::Item_sum_hybrid(THD *thd, Item_sum_hybrid *item)
  case REAL_RESULT:
    sum= item->sum;
    break;
  case STRING_RESULT: // This can happen with ROLLUP. Note that the value is already
    break;            // copied at function call.
  case STRING_RESULT:
    /*
      This can happen with ROLLUP. Note that the value is already
      copied at function call.
    */
    break;
  case ROW_RESULT:
  default:
    DBUG_ASSERT(0);
Loading