~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_parse.cc

Removed/replaced DBUG symbols and TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
453
453
    @retval false The statement isn't updating any relevant tables.
454
454
*/
455
455
 
456
 
static bool deny_updates_if_read_only_option(THD *thd,
 
456
static my_bool deny_updates_if_read_only_option(THD *thd,
457
457
                                                TABLE_LIST *all_tables)
458
458
{
459
459
  if (!opt_readonly)
468
468
  if (lex->sql_command == SQLCOM_UPDATE_MULTI)
469
469
    return(false);
470
470
 
471
 
  const bool create_temp_tables= 
 
471
  const my_bool create_temp_tables= 
472
472
    (lex->sql_command == SQLCOM_CREATE_TABLE) &&
473
473
    (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE);
474
474
 
475
 
  const bool drop_temp_tables= 
 
475
  const my_bool drop_temp_tables= 
476
476
    (lex->sql_command == SQLCOM_DROP_TABLE) &&
477
477
    lex->drop_temporary;
478
478
 
479
 
  const bool update_real_tables=
 
479
  const my_bool update_real_tables=
480
480
    some_non_temp_table_to_be_updated(thd, all_tables) &&
481
481
    !(create_temp_tables || drop_temp_tables);
482
482
 
483
483
 
484
 
  const bool create_or_drop_databases=
 
484
  const my_bool create_or_drop_databases=
485
485
    (lex->sql_command == SQLCOM_CREATE_DB) ||
486
486
    (lex->sql_command == SQLCOM_DROP_DB);
487
487
 
541
541
  case COM_STATISTICS:
542
542
  case COM_PING:
543
543
    break;
 
544
  /* Only increase id on these statements but don't count them. */
 
545
  case COM_STMT_PREPARE: 
 
546
  case COM_STMT_CLOSE:
 
547
  case COM_STMT_RESET:
 
548
    next_query_id();
 
549
    break;
544
550
  /* Increase id and count all other statements. */
545
551
  default:
546
552
    statistic_increment(thd->status_var.questions, &LOCK_status);
679
685
    }
680
686
    break;
681
687
  }
 
688
  case COM_STMT_EXECUTE:
 
689
  case COM_STMT_FETCH:
 
690
  case COM_STMT_SEND_LONG_DATA:
 
691
  case COM_STMT_PREPARE:
 
692
  case COM_STMT_CLOSE:
 
693
  case COM_STMT_RESET:
 
694
  {
 
695
    /* We should toss an error here */
 
696
    break;
 
697
  }
682
698
  case COM_QUERY:
683
699
  {
684
700
    if (alloc_query(thd, packet, packet_length))
688
704
 
689
705
    general_log_write(thd, command, thd->query, thd->query_length);
690
706
 
 
707
    if (!(specialflag & SPECIAL_NO_PRIOR))
 
708
    {
 
709
      struct sched_param tmp_sched_param;
 
710
 
 
711
      memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
 
712
      tmp_sched_param.sched_priority= QUERY_PRIOR;
 
713
      (void)pthread_setschedparam(pthread_self(), SCHED_OTHER, &tmp_sched_param);
 
714
    }
 
715
 
691
716
    mysql_parse(thd, thd->query, thd->query_length, &end_of_stmt);
692
717
 
693
718
    while (!thd->killed && (end_of_stmt != NULL) && ! thd->is_error())
724
749
 
725
750
      mysql_parse(thd, beginning_of_next_stmt, length, &end_of_stmt);
726
751
    }
 
752
 
 
753
    if (!(specialflag & SPECIAL_NO_PRIOR))
 
754
    {
 
755
      struct sched_param tmp_sched_param;
 
756
 
 
757
      memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
 
758
      tmp_sched_param.sched_priority= WAIT_PRIOR;
 
759
      (void)pthread_setschedparam(pthread_self(), SCHED_OTHER, &tmp_sched_param);
 
760
    }
727
761
    break;
728
762
  }
729
763
  case COM_FIELD_LIST:                          // This isn't actually needed
843
877
    STATUS_VAR current_global_status_var;
844
878
    ulong uptime;
845
879
    uint length;
846
 
    uint64_t queries_per_second1000;
 
880
    ulonglong queries_per_second1000;
847
881
    char buff[250];
848
882
    uint buff_len= sizeof(buff);
849
883
 
978
1012
  if (thd->enable_slow_log && !thd->user_time)
979
1013
  {
980
1014
    thd_proc_info(thd, "logging slow query");
981
 
    uint64_t end_utime_of_query= thd->current_utime();
 
1015
    ulonglong end_utime_of_query= thd->current_utime();
982
1016
 
983
1017
    if (((end_utime_of_query - thd->utime_after_lock) >
984
1018
         thd->variables.long_query_time ||
1658
1692
                           0, (ORDER*) 0, 0);
1659
1693
    break;
1660
1694
  }
 
1695
#ifdef HAVE_REPLICATION
1661
1696
  case SQLCOM_SLAVE_START:
1662
1697
  {
1663
1698
    pthread_mutex_lock(&LOCK_active_mi);
1691
1726
    pthread_mutex_unlock(&LOCK_active_mi);
1692
1727
    break;
1693
1728
  }
 
1729
#endif /* HAVE_REPLICATION */
1694
1730
 
1695
1731
  case SQLCOM_ALTER_TABLE:
1696
1732
    assert(first_table == all_tables && first_table != 0);
1881
1917
 
1882
1918
    res= mysql_multi_update_prepare(thd);
1883
1919
 
 
1920
#ifdef HAVE_REPLICATION
1884
1921
    /* Check slave filtering rules */
1885
1922
    if (unlikely(thd->slave_thread))
1886
1923
    {
1900
1937
    }
1901
1938
    else
1902
1939
    {
 
1940
#endif /* HAVE_REPLICATION */
1903
1941
      if (res)
1904
1942
        break;
1905
1943
      if (opt_readonly &&
1908
1946
        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
1909
1947
        break;
1910
1948
      }
 
1949
#ifdef HAVE_REPLICATION
1911
1950
    }  /* unlikely */
 
1951
#endif
1912
1952
 
1913
1953
    res= mysql_multi_update(thd, all_tables,
1914
1954
                            &select_lex->item_list,
2119
2159
      thd->options|= OPTION_KEEP_LOG;
2120
2160
    }
2121
2161
    /* DDL and binlog write order protected by LOCK_open */
2122
 
    res= mysql_rm_table(thd, first_table, lex->drop_if_exists, lex->drop_temporary);
 
2162
    res= mysql_rm_table(thd, first_table, lex->drop_if_exists,
 
2163
                        lex->drop_temporary);
2123
2164
  }
2124
2165
  break;
2125
2166
  case SQLCOM_SHOW_PROCESSLIST:
2334
2375
      do_db/ignore_db. And as this query involves no tables, tables_ok()
2335
2376
      above was not called. So we have to check rules again here.
2336
2377
    */
 
2378
#ifdef HAVE_REPLICATION
2337
2379
    if (thd->slave_thread && 
2338
2380
        (!rpl_filter->db_ok(lex->name.str) ||
2339
2381
         !rpl_filter->db_ok_with_wild_table(lex->name.str)))
2341
2383
      my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
2342
2384
      break;
2343
2385
    }
 
2386
#endif
2344
2387
    if (thd->locked_tables || thd->active_transaction())
2345
2388
    {
2346
2389
      my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
2358
2401
      res= 1;
2359
2402
      break;
2360
2403
    }
 
2404
#ifdef HAVE_REPLICATION
2361
2405
    if (thd->slave_thread && 
2362
2406
       (!rpl_filter->db_ok(db->str) ||
2363
2407
        !rpl_filter->db_ok_with_wild_table(db->str)))
2366
2410
      my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
2367
2411
      break;
2368
2412
    }
 
2413
#endif
2369
2414
    if (check_db_name(db))
2370
2415
    {
2371
2416
      my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
2400
2445
      do_db/ignore_db. And as this query involves no tables, tables_ok()
2401
2446
      above was not called. So we have to check rules again here.
2402
2447
    */
 
2448
#ifdef HAVE_REPLICATION
2403
2449
    if (thd->slave_thread &&
2404
2450
        (!rpl_filter->db_ok(db->str) ||
2405
2451
         !rpl_filter->db_ok_with_wild_table(db->str)))
2407
2453
      my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
2408
2454
      break;
2409
2455
    }
 
2456
#endif
2410
2457
    if (thd->locked_tables || thd->active_transaction())
2411
2458
    {
2412
2459
      my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
2662
2709
    SELECT_LEX *param= lex->unit.global_parameters;
2663
2710
    if (!param->explicit_limit)
2664
2711
      param->select_limit=
2665
 
        new Item_int((uint64_t) thd->variables.select_limit);
 
2712
        new Item_int((ulonglong) thd->variables.select_limit);
2666
2713
  }
2667
2714
  if (!(res= open_and_lock_tables(thd, all_tables)))
2668
2715
  {
3051
3098
}
3052
3099
 
3053
3100
 
 
3101
#ifdef HAVE_REPLICATION
3054
3102
/*
3055
3103
  Usable by the replication SQL thread only: just parse a query to know if it
3056
3104
  can be ignored because of replicate-*-table rules.
3077
3125
  thd->cleanup_after_query();
3078
3126
  return(error);
3079
3127
}
 
3128
#endif
3080
3129
 
3081
3130
 
3082
3131