~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_parse.cc

  • Committer: Brian Aker
  • Date: 2008-07-10 19:37:55 UTC
  • mfrom: (51.1.67 remove-dbug)
  • Revision ID: brian@tangent.org-20080710193755-f5g761uieqa3wxmt
Merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
bool end_active_trans(THD *thd)
84
84
{
85
85
  int error=0;
86
 
  DBUG_ENTER("end_active_trans");
87
86
  if (unlikely(thd->in_sub_stmt))
88
87
  {
89
88
    my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
90
 
    DBUG_RETURN(1);
 
89
    return(1);
91
90
  }
92
91
  if (thd->transaction.xid_state.xa_state != XA_NOTR)
93
92
  {
94
93
    my_error(ER_XAER_RMFAIL, MYF(0),
95
94
             xa_state_names[thd->transaction.xid_state.xa_state]);
96
 
    DBUG_RETURN(1);
 
95
    return(1);
97
96
  }
98
97
  if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN |
99
98
                      OPTION_TABLE_LOCK))
100
99
  {
101
 
    DBUG_PRINT("info",("options: 0x%llx", thd->options));
102
100
    /* Safety if one did "drop table" on locked tables */
103
101
    if (!thd->locked_tables)
104
102
      thd->options&= ~OPTION_TABLE_LOCK;
108
106
  }
109
107
  thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
110
108
  thd->transaction.all.modified_non_trans_table= false;
111
 
  DBUG_RETURN(error);
 
109
  return(error);
112
110
}
113
111
 
114
112
 
153
151
{
154
152
  for (TABLE_LIST *table= tables; table; table= table->next_global)
155
153
  {
156
 
    DBUG_ASSERT(table->db && table->table_name);
 
154
    assert(table->db && table->table_name);
157
155
    if (table->updating &&
158
156
        !find_temporary_table(thd, table->db, table->table_name))
159
157
      return 1;
237
235
 
238
236
bool is_update_query(enum enum_sql_command command)
239
237
{
240
 
  DBUG_ASSERT(command >= 0 && command <= SQLCOM_END);
 
238
  assert(command >= 0 && command <= SQLCOM_END);
241
239
  return (sql_command_flags[command] & CF_CHANGES_DATA) != 0;
242
240
}
243
241
 
284
282
{
285
283
  bool do_release= 0;
286
284
  int res= 0;
287
 
  DBUG_ENTER("end_trans");
288
285
 
289
286
  if (unlikely(thd->in_sub_stmt))
290
287
  {
291
288
    my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
292
 
    DBUG_RETURN(1);
 
289
    return(1);
293
290
  }
294
291
  if (thd->transaction.xid_state.xa_state != XA_NOTR)
295
292
  {
296
293
    my_error(ER_XAER_RMFAIL, MYF(0),
297
294
             xa_state_names[thd->transaction.xid_state.xa_state]);
298
 
    DBUG_RETURN(1);
 
295
    return(1);
299
296
  }
300
297
  switch (completion) {
301
298
  case COMMIT:
333
330
  default:
334
331
    res= -1;
335
332
    my_error(ER_UNKNOWN_COM_ERROR, MYF(0));
336
 
    DBUG_RETURN(-1);
 
333
    return(-1);
337
334
  }
338
335
 
339
336
  if (res < 0)
341
338
  else if ((res == 0) && do_release)
342
339
    thd->killed= THD::KILL_CONNECTION;
343
340
 
344
 
  DBUG_RETURN(res);
 
341
  return(res);
345
342
}
346
343
 
347
344
 
364
361
  ulong packet_length;
365
362
  NET *net= &thd->net;
366
363
  enum enum_server_command command;
367
 
  DBUG_ENTER("do_command");
368
364
 
369
365
  /*
370
366
    indicator of uninitialized lex => normal flow of errors handling
392
388
  packet_length= my_net_read(net);
393
389
  if (packet_length == packet_error)
394
390
  {
395
 
    DBUG_PRINT("info",("Got error %d reading command from socket %s",
396
 
                       net->error,
397
 
                       vio_description(net->vio)));
398
 
 
399
391
    /* Check if we can continue without closing the connection */
400
392
 
401
393
    /* The error must be set. */
402
 
    DBUG_ASSERT(thd->is_error());
 
394
    assert(thd->is_error());
403
395
    net_end_statement(thd);
404
396
 
405
397
    if (net->error != 3)
436
428
  if (command >= COM_END)
437
429
    command= COM_END;                           // Wrong command
438
430
 
439
 
  DBUG_PRINT("info",("Command on %s = %d (%s)",
440
 
                     vio_description(net->vio), command,
441
 
                     command_name[command].str));
442
 
 
443
431
  /* Restore read timeout value */
444
432
  my_net_set_read_timeout(net, thd->variables.net_read_timeout);
445
433
 
446
 
  DBUG_ASSERT(packet_length);
 
434
  assert(packet_length);
447
435
  return_value= dispatch_command(command, thd, packet+1, (uint) (packet_length-1));
448
436
 
449
437
out:
450
 
  DBUG_RETURN(return_value);
 
438
  return(return_value);
451
439
}
452
440
 
453
441
/**
468
456
static my_bool deny_updates_if_read_only_option(THD *thd,
469
457
                                                TABLE_LIST *all_tables)
470
458
{
471
 
  DBUG_ENTER("deny_updates_if_read_only_option");
472
 
 
473
459
  if (!opt_readonly)
474
 
    DBUG_RETURN(false);
 
460
    return(false);
475
461
 
476
462
  LEX *lex= thd->lex;
477
463
 
478
464
  if (!(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA))
479
 
    DBUG_RETURN(false);
 
465
    return(false);
480
466
 
481
467
  /* Multi update is an exception and is dealt with later. */
482
468
  if (lex->sql_command == SQLCOM_UPDATE_MULTI)
483
 
    DBUG_RETURN(false);
 
469
    return(false);
484
470
 
485
471
  const my_bool create_temp_tables= 
486
472
    (lex->sql_command == SQLCOM_CREATE_TABLE) &&
504
490
      /*
505
491
        An attempt was made to modify one or more non-temporary tables.
506
492
      */
507
 
      DBUG_RETURN(true);
 
493
      return(true);
508
494
  }
509
495
 
510
496
 
511
497
  /* Assuming that only temporary tables are modified. */
512
 
  DBUG_RETURN(false);
 
498
  return(false);
513
499
}
514
500
 
515
501
/**
538
524
{
539
525
  NET *net= &thd->net;
540
526
  bool error= 0;
541
 
  DBUG_ENTER("dispatch_command");
542
 
  DBUG_PRINT("info",("packet: '%*.s'; command: %d", packet_length, packet, command));
543
527
 
544
528
  thd->command=command;
545
529
  /*
719
703
    const char* end_of_stmt= NULL;
720
704
 
721
705
    general_log_write(thd, command, thd->query, thd->query_length);
722
 
    DBUG_PRINT("query",("%-.4096s",thd->query));
723
706
 
724
707
    if (!(specialflag & SPECIAL_NO_PRIOR))
725
708
    {
775
758
      tmp_sched_param.sched_priority= WAIT_PRIOR;
776
759
      (void)pthread_setschedparam(pthread_self(), SCHED_OTHER, &tmp_sched_param);
777
760
    }
778
 
    DBUG_PRINT("info",("query ready"));
779
761
    break;
780
762
  }
781
763
  case COM_FIELD_LIST:                          // This isn't actually needed
883
865
      my_error(ER_NOT_SUPPORTED_YET, MYF(0), "this shutdown level");
884
866
      break;
885
867
    }
886
 
    DBUG_PRINT("quit",("Got shutdown command for level %u", level));
887
868
    general_log_print(thd, command, NullS);
888
869
    my_eof(thd);
889
870
    close_thread_tables(thd);                   // Free before kill
1016
997
  VOID(pthread_mutex_unlock(&LOCK_thread_count));
1017
998
  thd->packet.shrink(thd->variables.net_buffer_length); // Reclaim some memory
1018
999
  free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
1019
 
  DBUG_RETURN(error);
 
1000
  return(error);
1020
1001
}
1021
1002
 
1022
1003
 
1023
1004
void log_slow_statement(THD *thd)
1024
1005
{
1025
 
  DBUG_ENTER("log_slow_statement");
1026
 
 
1027
1006
  /*
1028
1007
    The following should never be true with our current code base,
1029
1008
    but better to keep this here so we don't accidently try to log a
1030
1009
    statement in a trigger or stored function
1031
1010
  */
1032
1011
  if (unlikely(thd->in_sub_stmt))
1033
 
    DBUG_VOID_RETURN;                           // Don't set time for sub stmt
 
1012
    return;                           // Don't set time for sub stmt
1034
1013
 
1035
1014
  /*
1036
1015
    Do not log administrative statements unless the appropriate option is
1054
1033
      slow_log_print(thd, thd->query, thd->query_length, end_utime_of_query);
1055
1034
    }
1056
1035
  }
1057
 
  DBUG_VOID_RETURN;
 
1036
  return;
1058
1037
}
1059
1038
 
1060
1039
 
1088
1067
                         enum enum_schema_tables schema_table_idx)
1089
1068
{
1090
1069
  SELECT_LEX *schema_select_lex= NULL;
1091
 
  DBUG_ENTER("prepare_schema_table");
1092
1070
 
1093
1071
  switch (schema_table_idx) {
1094
1072
  case SCH_SCHEMATA:
1101
1079
      if (lex->select_lex.db == NULL &&
1102
1080
          lex->copy_db_to(&lex->select_lex.db, &dummy))
1103
1081
      {
1104
 
        DBUG_RETURN(1);
 
1082
        return(1);
1105
1083
      }
1106
1084
      schema_select_lex= new SELECT_LEX();
1107
1085
      db.str= schema_select_lex->db= lex->select_lex.db;
1111
1089
      if (check_db_name(&db))
1112
1090
      {
1113
1091
        my_error(ER_WRONG_DB_NAME, MYF(0), db.str);
1114
 
        DBUG_RETURN(1);
 
1092
        return(1);
1115
1093
      }
1116
1094
      break;
1117
1095
    }
1118
1096
  case SCH_COLUMNS:
1119
1097
  case SCH_STATISTICS:
1120
1098
  {
1121
 
    DBUG_ASSERT(table_ident);
 
1099
    assert(table_ident);
1122
1100
    TABLE_LIST **query_tables_last= lex->query_tables_last;
1123
1101
    schema_select_lex= new SELECT_LEX();
1124
1102
    /* 'parent_lex' is used in init_query() so it must be before it. */
1125
1103
    schema_select_lex->parent_lex= lex;
1126
1104
    schema_select_lex->init_query();
1127
1105
    if (!schema_select_lex->add_table_to_list(thd, table_ident, 0, 0, TL_READ))
1128
 
      DBUG_RETURN(1);
 
1106
      return(1);
1129
1107
    lex->query_tables_last= query_tables_last;
1130
1108
    break;
1131
1109
  }
1145
1123
  assert(select_lex);
1146
1124
  if (make_schema_select(thd, select_lex, schema_table_idx))
1147
1125
  {
1148
 
    DBUG_RETURN(1);
 
1126
    return(1);
1149
1127
  }
1150
1128
  TABLE_LIST *table_list= (TABLE_LIST*) select_lex->table_list.first;
1151
1129
  assert(table_list);
1152
1130
  table_list->schema_select_lex= schema_select_lex;
1153
1131
  table_list->schema_table_reformed= 1;
1154
 
  DBUG_RETURN(0);
 
1132
  return(0);
1155
1133
}
1156
1134
 
1157
1135
 
1264
1242
  /* most outer SELECT_LEX_UNIT of query */
1265
1243
  SELECT_LEX_UNIT *unit= &lex->unit;
1266
1244
  /* Saved variable value */
1267
 
  DBUG_ENTER("mysql_execute_command");
1268
1245
 
1269
1246
  /*
1270
1247
    In many cases first table of main SELECT_LEX have special meaning =>
1278
1255
 
1279
1256
    Because of above in place where should be at least one table in most
1280
1257
    outer SELECT_LEX we have following check:
1281
 
    DBUG_ASSERT(first_table == all_tables);
1282
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1258
    assert(first_table == all_tables);
 
1259
    assert(first_table == all_tables && first_table != 0);
1283
1260
  */
1284
1261
  lex->first_lists_tables_same();
1285
1262
  /* should be assigned after making first tables same */
1339
1316
        */
1340
1317
        reset_one_shot_variables(thd);
1341
1318
      }
1342
 
      DBUG_RETURN(0);
 
1319
      return(0);
1343
1320
    }
1344
1321
  }
1345
1322
  else
1351
1328
    if (deny_updates_if_read_only_option(thd, all_tables))
1352
1329
    {
1353
1330
      my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
1354
 
      DBUG_RETURN(-1);
 
1331
      return(-1);
1355
1332
    }
1356
1333
  } /* endif unlikely slave */
1357
1334
  status_var_increment(thd->status_var.com_stat[lex->sql_command]);
1358
1335
 
1359
 
  DBUG_ASSERT(thd->transaction.stmt.modified_non_trans_table == false);
 
1336
  assert(thd->transaction.stmt.modified_non_trans_table == false);
1360
1337
  
1361
1338
  switch (lex->sql_command) {
1362
1339
  case SQLCOM_SHOW_STATUS:
1451
1428
 
1452
1429
  case SQLCOM_ASSIGN_TO_KEYCACHE:
1453
1430
  {
1454
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1431
    assert(first_table == all_tables && first_table != 0);
1455
1432
    res= mysql_assign_to_keycache(thd, first_table, &lex->ident);
1456
1433
    break;
1457
1434
  }
1500
1477
        break;
1501
1478
      }
1502
1479
    }
1503
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1480
    assert(first_table == all_tables && first_table != 0);
1504
1481
    bool link_to_local;
1505
1482
    // Skip first table, which is the table we are creating
1506
1483
    TABLE_LIST *create_table= lex->unlink_first_table(&link_to_local);
1701
1678
    if (thd->is_fatal_error) /* out of memory creating a copy of alter_info */
1702
1679
      goto error;
1703
1680
 
1704
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1681
    assert(first_table == all_tables && first_table != 0);
1705
1682
    if (end_active_trans(thd))
1706
1683
      goto error;
1707
1684
    /*
1758
1735
#endif /* HAVE_REPLICATION */
1759
1736
 
1760
1737
  case SQLCOM_ALTER_TABLE:
1761
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1738
    assert(first_table == all_tables && first_table != 0);
1762
1739
    {
1763
1740
      /*
1764
1741
        Code in mysql_alter_table() may modify its HA_CREATE_INFO argument,
1775
1752
      }
1776
1753
 
1777
1754
      /* Must be set in the parser */
1778
 
      DBUG_ASSERT(select_lex->db);
 
1755
      assert(select_lex->db);
1779
1756
 
1780
1757
      { // Rename of table
1781
1758
          TABLE_LIST tmp_table;
1815
1792
    }
1816
1793
  case SQLCOM_RENAME_TABLE:
1817
1794
  {
1818
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1795
    assert(first_table == all_tables && first_table != 0);
1819
1796
    TABLE_LIST *table;
1820
1797
    for (table= first_table; table; table= table->next_local->next_local)
1821
1798
    {
1840
1817
      break;
1841
1818
    }
1842
1819
  case SQLCOM_SHOW_CREATE:
1843
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1820
    assert(first_table == all_tables && first_table != 0);
1844
1821
    {
1845
1822
      res= mysqld_show_create(thd, first_table);
1846
1823
      break;
1847
1824
    }
1848
1825
  case SQLCOM_CHECKSUM:
1849
1826
  {
1850
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1827
    assert(first_table == all_tables && first_table != 0);
1851
1828
    res = mysql_checksum_table(thd, first_table, &lex->check_opt);
1852
1829
    break;
1853
1830
  }
1854
1831
  case SQLCOM_REPAIR:
1855
1832
  {
1856
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1833
    assert(first_table == all_tables && first_table != 0);
1857
1834
    thd->enable_slow_log= opt_log_slow_admin_statements;
1858
1835
    res= mysql_repair_table(thd, first_table, &lex->check_opt);
1859
1836
    /* ! we write after unlocking the table */
1870
1847
  }
1871
1848
  case SQLCOM_CHECK:
1872
1849
  {
1873
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1850
    assert(first_table == all_tables && first_table != 0);
1874
1851
    thd->enable_slow_log= opt_log_slow_admin_statements;
1875
1852
    res = mysql_check_table(thd, first_table, &lex->check_opt);
1876
1853
    select_lex->table_list.first= (uchar*) first_table;
1879
1856
  }
1880
1857
  case SQLCOM_ANALYZE:
1881
1858
  {
1882
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1859
    assert(first_table == all_tables && first_table != 0);
1883
1860
    thd->enable_slow_log= opt_log_slow_admin_statements;
1884
1861
    res= mysql_analyze_table(thd, first_table, &lex->check_opt);
1885
1862
    /* ! we write after unlocking the table */
1897
1874
 
1898
1875
  case SQLCOM_OPTIMIZE:
1899
1876
  {
1900
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1877
    assert(first_table == all_tables && first_table != 0);
1901
1878
    thd->enable_slow_log= opt_log_slow_admin_statements;
1902
1879
    res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ?
1903
1880
      mysql_recreate_table(thd, first_table) :
1915
1892
    break;
1916
1893
  }
1917
1894
  case SQLCOM_UPDATE:
1918
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1895
    assert(first_table == all_tables && first_table != 0);
1919
1896
    if (update_precheck(thd, all_tables))
1920
1897
      break;
1921
 
    DBUG_ASSERT(select_lex->offset_limit == 0);
 
1898
    assert(select_lex->offset_limit == 0);
1922
1899
    unit->set_limit(select_lex);
1923
1900
    res= (up_result= mysql_update(thd, all_tables,
1924
1901
                                  select_lex->item_list,
1934
1911
    /* Fall through */
1935
1912
  case SQLCOM_UPDATE_MULTI:
1936
1913
  {
1937
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1914
    assert(first_table == all_tables && first_table != 0);
1938
1915
    /* if we switched from normal update, rights are checked */
1939
1916
    if (up_result != 2)
1940
1917
    {
1988
1965
    break;
1989
1966
  }
1990
1967
  case SQLCOM_REPLACE:
1991
 
#ifndef DBUG_OFF
1992
 
    if (mysql_bin_log.is_open())
1993
 
    {
1994
 
      /*
1995
 
        Generate an incident log event before writing the real event
1996
 
        to the binary log.  We put this event is before the statement
1997
 
        since that makes it simpler to check that the statement was
1998
 
        not executed on the slave (since incidents usually stop the
1999
 
        slave).
2000
 
 
2001
 
        Observe that any row events that are generated will be
2002
 
        generated before.
2003
 
 
2004
 
        This is only for testing purposes and will not be present in a
2005
 
        release build.
2006
 
      */
2007
 
 
2008
 
      Incident incident= INCIDENT_NONE;
2009
 
      DBUG_PRINT("debug", ("Just before generate_incident()"));
2010
 
      DBUG_EXECUTE_IF("incident_database_resync_on_replace",
2011
 
                      incident= INCIDENT_LOST_EVENTS;);
2012
 
      if (incident)
2013
 
      {
2014
 
        Incident_log_event ev(thd, incident);
2015
 
        mysql_bin_log.write(&ev);
2016
 
        mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
2017
 
      }
2018
 
      DBUG_PRINT("debug", ("Just after generate_incident()"));
2019
 
    }
2020
 
#endif
2021
1968
  case SQLCOM_INSERT:
2022
1969
  {
2023
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1970
    assert(first_table == all_tables && first_table != 0);
2024
1971
    if ((res= insert_precheck(thd, all_tables)))
2025
1972
      break;
2026
1973
 
2041
1988
  case SQLCOM_INSERT_SELECT:
2042
1989
  {
2043
1990
    select_result *sel_result;
2044
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
1991
    assert(first_table == all_tables && first_table != 0);
2045
1992
    if ((res= insert_precheck(thd, all_tables)))
2046
1993
      break;
2047
1994
 
2106
2053
      res= -1;
2107
2054
      break;
2108
2055
    }
2109
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
2056
    assert(first_table == all_tables && first_table != 0);
2110
2057
    /*
2111
2058
      Don't allow this within a transaction because we want to use
2112
2059
      re-generate table
2123
2070
    break;
2124
2071
  case SQLCOM_DELETE:
2125
2072
  {
2126
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
2127
 
    DBUG_ASSERT(select_lex->offset_limit == 0);
 
2073
    assert(first_table == all_tables && first_table != 0);
 
2074
    assert(select_lex->offset_limit == 0);
2128
2075
    unit->set_limit(select_lex);
2129
2076
 
2130
2077
    if (!thd->locked_tables &&
2142
2089
  }
2143
2090
  case SQLCOM_DELETE_MULTI:
2144
2091
  {
2145
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
2092
    assert(first_table == all_tables && first_table != 0);
2146
2093
    TABLE_LIST *aux_tables=
2147
2094
      (TABLE_LIST *)thd->lex->auxiliary_table_list.first;
2148
2095
    multi_delete *del_result;
2195
2142
  }
2196
2143
  case SQLCOM_DROP_TABLE:
2197
2144
  {
2198
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
2145
    assert(first_table == all_tables && first_table != 0);
2199
2146
    if (!lex->drop_temporary)
2200
2147
    {
2201
2148
      if (end_active_trans(thd))
2242
2189
 
2243
2190
  case SQLCOM_LOAD:
2244
2191
  {
2245
 
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
 
2192
    assert(first_table == all_tables && first_table != 0);
2246
2193
    if (lex->local_file)
2247
2194
    {
2248
2195
      if (!(thd->client_capabilities & CLIENT_LOCAL_FILES) ||
2320
2267
      - only transactional locks are requested (lex->lock_transactional) and
2321
2268
      - no non-transactional locks exist (!thd->locked_tables).
2322
2269
    */
2323
 
    DBUG_PRINT("lock_info", ("lex->lock_transactional: %d  "
2324
 
                             "thd->locked_tables: 0x%lx",
2325
 
                             lex->lock_transactional,
2326
 
                             (long) thd->locked_tables));
2327
2270
    if (lex->lock_transactional && !thd->locked_tables)
2328
2271
    {
2329
2272
      int rc;
2366
2309
      thd->locked_tables=thd->lock;
2367
2310
      thd->lock=0;
2368
2311
      (void) set_handler_table_locks(thd, all_tables, false);
2369
 
      DBUG_PRINT("lock_info", ("thd->locked_tables: 0x%lx",
2370
 
                               (long) thd->locked_tables));
2371
2312
      my_ok(thd);
2372
2313
    }
2373
2314
    else
2530
2471
  }
2531
2472
  case SQLCOM_SHOW_CREATE_DB:
2532
2473
  {
2533
 
    DBUG_EXECUTE_IF("4x_server_emul",
2534
 
                    my_error(ER_UNKNOWN_ERROR, MYF(0)); goto error;);
2535
2474
    if (check_db_name(&lex->name))
2536
2475
    {
2537
2476
      my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
2720
2659
    break;
2721
2660
  }
2722
2661
  default:
2723
 
    DBUG_ASSERT(0);                             /* Impossible */
 
2662
    assert(0);                             /* Impossible */
2724
2663
    my_ok(thd);
2725
2664
    break;
2726
2665
  }
2762
2701
    */
2763
2702
    start_waiting_global_read_lock(thd);
2764
2703
  }
2765
 
  DBUG_RETURN(res || thd->is_error());
 
2704
  return(res || thd->is_error());
2766
2705
}
2767
2706
 
2768
2707
 
2829
2768
#define used_stack(A,B) (long) (B - A)
2830
2769
#endif
2831
2770
 
2832
 
#ifndef DBUG_OFF
2833
 
long max_stack_used;
2834
 
#endif
2835
 
 
2836
2771
/**
2837
2772
  @note
2838
2773
  Note: The 'buf' parameter is necessary, even if it is unused here.
2844
2779
                         uchar *buf __attribute__((unused)))
2845
2780
{
2846
2781
  long stack_used;
2847
 
  DBUG_ASSERT(thd == current_thd);
 
2782
  assert(thd == current_thd);
2848
2783
  if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >=
2849
2784
      (long) (my_thread_stack_size - margin))
2850
2785
  {
2853
2788
    my_message(ER_STACK_OVERRUN_NEED_MORE,errbuff[0],MYF(ME_FATALERROR));
2854
2789
    return 1;
2855
2790
  }
2856
 
#ifndef DBUG_OFF
2857
 
  max_stack_used= max(max_stack_used, stack_used);
2858
 
#endif
2859
2791
  return 0;
2860
2792
}
2861
2793
 
2907
2839
 
2908
2840
void mysql_reset_thd_for_next_command(THD *thd)
2909
2841
{
2910
 
  DBUG_ENTER("mysql_reset_thd_for_next_command");
2911
 
  DBUG_ASSERT(! thd->in_sub_stmt);
 
2842
  assert(! thd->in_sub_stmt);
2912
2843
  thd->free_list= 0;
2913
2844
  thd->select_number= 1;
2914
2845
  /*
2933
2864
    thd->options&= ~OPTION_KEEP_LOG;
2934
2865
    thd->transaction.all.modified_non_trans_table= false;
2935
2866
  }
2936
 
  DBUG_ASSERT(thd->security_ctx== &thd->main_security_ctx);
 
2867
  assert(thd->security_ctx== &thd->main_security_ctx);
2937
2868
  thd->thread_specific_used= false;
2938
2869
 
2939
2870
  if (opt_bin_log)
2953
2884
  */
2954
2885
  thd->reset_current_stmt_binlog_row_based();
2955
2886
 
2956
 
  DBUG_VOID_RETURN;
 
2887
  return;
2957
2888
}
2958
2889
 
2959
2890
 
2965
2896
  lex->wild= 0;
2966
2897
  if (select_lex == &lex->select_lex)
2967
2898
  {
2968
 
    DBUG_ASSERT(lex->result == 0);
 
2899
    assert(lex->result == 0);
2969
2900
    lex->exchange= 0;
2970
2901
  }
2971
2902
}
2976
2907
{
2977
2908
  SELECT_LEX *select_lex;
2978
2909
  THD *thd= lex->thd;
2979
 
  DBUG_ENTER("mysql_new_select");
2980
2910
 
2981
2911
  if (!(select_lex= new (thd->mem_root) SELECT_LEX()))
2982
 
    DBUG_RETURN(1);
 
2912
    return(1);
2983
2913
  select_lex->select_number= ++thd->select_number;
2984
2914
  select_lex->parent_lex= lex; /* Used in init_query. */
2985
2915
  select_lex->init_query();
2988
2918
  if (lex->nest_level > (int) MAX_SELECT_NESTING)
2989
2919
  {
2990
2920
    my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT,MYF(0),MAX_SELECT_NESTING);
2991
 
    DBUG_RETURN(1);
 
2921
    return(1);
2992
2922
  }
2993
2923
  select_lex->nest_level= lex->nest_level;
2994
2924
  if (move_down)
2997
2927
    lex->subqueries= true;
2998
2928
    /* first select_lex of subselect or derived table */
2999
2929
    if (!(unit= new (thd->mem_root) SELECT_LEX_UNIT()))
3000
 
      DBUG_RETURN(1);
 
2930
      return(1);
3001
2931
 
3002
2932
    unit->init_query();
3003
2933
    unit->init_select();
3018
2948
    if (lex->current_select->order_list.first && !lex->current_select->braces)
3019
2949
    {
3020
2950
      my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY");
3021
 
      DBUG_RETURN(1);
 
2951
      return(1);
3022
2952
    }
3023
2953
    select_lex->include_neighbour(lex->current_select);
3024
2954
    SELECT_LEX_UNIT *unit= select_lex->master_unit();                              
3025
2955
    if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->thd))
3026
 
      DBUG_RETURN(1);
 
2956
      return(1);
3027
2957
    select_lex->context.outer_context= 
3028
2958
                unit->first_select()->context.outer_context;
3029
2959
  }
3036
2966
    list
3037
2967
  */
3038
2968
  select_lex->context.resolve_in_select_list= true;
3039
 
  DBUG_RETURN(0);
 
2969
  return(0);
3040
2970
}
3041
2971
 
3042
2972
/**
3056
2986
  LEX_STRING tmp, null_lex_string;
3057
2987
  Item *var;
3058
2988
  char buff[MAX_SYS_VAR_LENGTH*2+4+8], *end;
3059
 
  DBUG_ENTER("create_select_for_variable");
3060
2989
 
3061
2990
  thd= current_thd;
3062
2991
  lex= thd->lex;
3075
3004
    var->set_name(buff, end-buff, system_charset_info);
3076
3005
    add_item_to_list(thd, var);
3077
3006
  }
3078
 
  DBUG_VOID_RETURN;
 
3007
  return;
3079
3008
}
3080
3009
 
3081
3010
 
3110
3039
void mysql_parse(THD *thd, const char *inBuf, uint length,
3111
3040
                 const char ** found_semicolon)
3112
3041
{
3113
 
  DBUG_ENTER("mysql_parse");
3114
 
 
3115
 
  DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on(););
3116
 
 
3117
3042
  /*
3118
3043
    Warning.
3119
3044
    The purpose of query_cache_send_result_to_client() is to lookup the
3166
3091
    }
3167
3092
    else
3168
3093
    {
3169
 
      DBUG_ASSERT(thd->is_error());
3170
 
      DBUG_PRINT("info",("Command aborted. Fatal_error: %d",
3171
 
                         thd->is_fatal_error));
 
3094
      assert(thd->is_error());
3172
3095
    }
3173
3096
    lex->unit.cleanup();
3174
3097
    thd_proc_info(thd, "freeing items");
3175
3098
    thd->end_statement();
3176
3099
    thd->cleanup_after_query();
3177
 
    DBUG_ASSERT(thd->change_list.is_empty());
 
3100
    assert(thd->change_list.is_empty());
3178
3101
  }
3179
3102
 
3180
 
  DBUG_VOID_RETURN;
 
3103
  return;
3181
3104
}
3182
3105
 
3183
3106
 
3196
3119
{
3197
3120
  LEX *lex= thd->lex;
3198
3121
  bool error= 0;
3199
 
  DBUG_ENTER("mysql_test_parse_for_slave");
3200
3122
 
3201
3123
  Lex_input_stream lip(thd, inBuf, length);
3202
3124
  lex_start(thd);
3207
3129
    error= 1;                  /* Ignore question */
3208
3130
  thd->end_statement();
3209
3131
  thd->cleanup_after_query();
3210
 
  DBUG_RETURN(error);
 
3132
  return(error);
3211
3133
}
3212
3134
#endif
3213
3135
 
3231
3153
{
3232
3154
  register Create_field *new_field;
3233
3155
  LEX  *lex= thd->lex;
3234
 
  DBUG_ENTER("add_field_to_list");
3235
3156
 
3236
3157
  if (check_identifier_name(field_name, ER_TOO_LONG_IDENT))
3237
 
    DBUG_RETURN(1);                             /* purecov: inspected */
 
3158
    return(1);                          /* purecov: inspected */
3238
3159
 
3239
3160
  if (type_modifier & PRI_KEY_FLAG)
3240
3161
  {
3271
3192
         type == MYSQL_TYPE_TIMESTAMP))
3272
3193
    {
3273
3194
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
3274
 
      DBUG_RETURN(1);
 
3195
      return(1);
3275
3196
    }
3276
3197
    else if (default_value->type() == Item::NULL_ITEM)
3277
3198
    {
3280
3201
          NOT_NULL_FLAG)
3281
3202
      {
3282
3203
        my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
3283
 
        DBUG_RETURN(1);
 
3204
        return(1);
3284
3205
      }
3285
3206
    }
3286
3207
    else if (type_modifier & AUTO_INCREMENT_FLAG)
3287
3208
    {
3288
3209
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
3289
 
      DBUG_RETURN(1);
 
3210
      return(1);
3290
3211
    }
3291
3212
  }
3292
3213
 
3293
3214
  if (on_update_value && type != MYSQL_TYPE_TIMESTAMP)
3294
3215
  {
3295
3216
    my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name->str);
3296
 
    DBUG_RETURN(1);
 
3217
    return(1);
3297
3218
  }
3298
3219
 
3299
3220
  if (!(new_field= new Create_field()) ||
3300
3221
      new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
3301
3222
                      default_value, on_update_value, comment, change,
3302
3223
                      interval_list, cs, 0, column_format))
3303
 
    DBUG_RETURN(1);
 
3224
    return(1);
3304
3225
 
3305
3226
  lex->alter_info.create_list.push_back(new_field);
3306
3227
  lex->last_field=new_field;
3307
 
  DBUG_RETURN(0);
 
3228
  return(0);
3308
3229
}
3309
3230
 
3310
3231
 
3339
3260
bool add_to_list(THD *thd, SQL_LIST &list,Item *item,bool asc)
3340
3261
{
3341
3262
  ORDER *order;
3342
 
  DBUG_ENTER("add_to_list");
3343
3263
  if (!(order = (ORDER *) thd->alloc(sizeof(ORDER))))
3344
 
    DBUG_RETURN(1);
 
3264
    return(1);
3345
3265
  order->item_ptr= item;
3346
3266
  order->item= &order->item_ptr;
3347
3267
  order->asc = asc;
3349
3269
  order->used=0;
3350
3270
  order->counter_used= 0;
3351
3271
  list.link_in_list((uchar*) order,(uchar**) &order->next);
3352
 
  DBUG_RETURN(0);
 
3272
  return(0);
3353
3273
}
3354
3274
 
3355
3275
 
3384
3304
  TABLE_LIST *previous_table_ref; /* The table preceding the current one. */
3385
3305
  char *alias_str;
3386
3306
  LEX *lex= thd->lex;
3387
 
  DBUG_ENTER("add_table_to_list");
3388
3307
 
3389
3308
  if (!table)
3390
 
    DBUG_RETURN(0);                             // End of memory
 
3309
    return(0);                          // End of memory
3391
3310
  alias_str= alias ? alias->str : table->table.str;
3392
3311
  if (!test(table_options & TL_OPTION_ALIAS) && 
3393
3312
      check_table_name(table->table.str, table->table.length))
3394
3313
  {
3395
3314
    my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str);
3396
 
    DBUG_RETURN(0);
 
3315
    return(0);
3397
3316
  }
3398
3317
 
3399
3318
  if (table->is_derived_table() == false && table->db.str &&
3400
3319
      check_db_name(&table->db))
3401
3320
  {
3402
3321
    my_error(ER_WRONG_DB_NAME, MYF(0), table->db.str);
3403
 
    DBUG_RETURN(0);
 
3322
    return(0);
3404
3323
  }
3405
3324
 
3406
3325
  if (!alias)                                   /* Alias is case sensitive */
3409
3328
    {
3410
3329
      my_message(ER_DERIVED_MUST_HAVE_ALIAS,
3411
3330
                 ER(ER_DERIVED_MUST_HAVE_ALIAS), MYF(0));
3412
 
      DBUG_RETURN(0);
 
3331
      return(0);
3413
3332
    }
3414
3333
    if (!(alias_str= (char*) thd->memdup(alias_str,table->table.length+1)))
3415
 
      DBUG_RETURN(0);
 
3334
      return(0);
3416
3335
  }
3417
3336
  if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
3418
 
    DBUG_RETURN(0);                             /* purecov: inspected */
 
3337
    return(0);                          /* purecov: inspected */
3419
3338
  if (table->db.str)
3420
3339
  {
3421
3340
    ptr->is_fqtn= true;
3423
3342
    ptr->db_length= table->db.length;
3424
3343
  }
3425
3344
  else if (lex->copy_db_to(&ptr->db, &ptr->db_length))
3426
 
    DBUG_RETURN(0);
 
3345
    return(0);
3427
3346
  else
3428
3347
    ptr->is_fqtn= false;
3429
3348
 
3455
3374
    {
3456
3375
      my_error(ER_UNKNOWN_TABLE, MYF(0),
3457
3376
               ptr->table_name, INFORMATION_SCHEMA_NAME.str);
3458
 
      DBUG_RETURN(0);
 
3377
      return(0);
3459
3378
    }
3460
3379
    ptr->schema_table_name= ptr->table_name;
3461
3380
    ptr->schema_table= schema_table;
3476
3395
          !strcmp(ptr->db, tables->db))
3477
3396
      {
3478
3397
        my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str); /* purecov: tested */
3479
 
        DBUG_RETURN(0);                         /* purecov: tested */
 
3398
        return(0);                              /* purecov: tested */
3480
3399
      }
3481
3400
    }
3482
3401
  }
3511
3430
  ptr->next_name_resolution_table= NULL;
3512
3431
  /* Link table in global list (all used tables) */
3513
3432
  lex->add_to_query_tables(ptr);
3514
 
  DBUG_RETURN(ptr);
 
3433
  return(ptr);
3515
3434
}
3516
3435
 
3517
3436
 
3538
3457
{
3539
3458
  TABLE_LIST *ptr;
3540
3459
  NESTED_JOIN *nested_join;
3541
 
  DBUG_ENTER("init_nested_join");
3542
3460
 
3543
3461
  if (!(ptr= (TABLE_LIST*) thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST))+
3544
3462
                                       sizeof(NESTED_JOIN))))
3545
 
    DBUG_RETURN(1);
 
3463
    return(1);
3546
3464
  nested_join= ptr->nested_join=
3547
3465
    ((NESTED_JOIN*) ((uchar*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST))));
3548
3466
 
3553
3471
  embedding= ptr;
3554
3472
  join_list= &nested_join->join_list;
3555
3473
  join_list->empty();
3556
 
  DBUG_RETURN(0);
 
3474
  return(0);
3557
3475
}
3558
3476
 
3559
3477
 
3575
3493
{
3576
3494
  TABLE_LIST *ptr;
3577
3495
  NESTED_JOIN *nested_join;
3578
 
  DBUG_ENTER("end_nested_join");
3579
3496
 
3580
 
  DBUG_ASSERT(embedding);
 
3497
  assert(embedding);
3581
3498
  ptr= embedding;
3582
3499
  join_list= ptr->join_list;
3583
3500
  embedding= ptr->embedding;
3596
3513
    join_list->pop();
3597
3514
    ptr= 0;                                     // return value
3598
3515
  }
3599
 
  DBUG_RETURN(ptr);
 
3516
  return(ptr);
3600
3517
}
3601
3518
 
3602
3519
 
3618
3535
  TABLE_LIST *ptr;
3619
3536
  NESTED_JOIN *nested_join;
3620
3537
  List<TABLE_LIST> *embedded_list;
3621
 
  DBUG_ENTER("nest_last_join");
3622
3538
 
3623
3539
  if (!(ptr= (TABLE_LIST*) thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST))+
3624
3540
                                       sizeof(NESTED_JOIN))))
3625
 
    DBUG_RETURN(0);
 
3541
    return(0);
3626
3542
  nested_join= ptr->nested_join=
3627
3543
    ((NESTED_JOIN*) ((uchar*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST))));
3628
3544
 
3651
3567
  }
3652
3568
  join_list->push_front(ptr);
3653
3569
  nested_join->used_tables= nested_join->not_null_tables= (table_map) 0;
3654
 
  DBUG_RETURN(ptr);
 
3570
  return(ptr);
3655
3571
}
3656
3572
 
3657
3573
 
3671
3587
 
3672
3588
void st_select_lex::add_joined_table(TABLE_LIST *table)
3673
3589
{
3674
 
  DBUG_ENTER("add_joined_table");
3675
3590
  join_list->push_front(table);
3676
3591
  table->join_list= join_list;
3677
3592
  table->embedding= embedding;
3678
 
  DBUG_VOID_RETURN;
 
3593
  return;
3679
3594
}
3680
3595
 
3681
3596
 
3714
3629
{
3715
3630
  TABLE_LIST *tab2= join_list->pop();
3716
3631
  TABLE_LIST *tab1= join_list->pop();
3717
 
  DBUG_ENTER("convert_right_join");
3718
3632
 
3719
3633
  join_list->push_front(tab2);
3720
3634
  join_list->push_front(tab1);
3721
3635
  tab1->outer_join|= JOIN_TYPE_RIGHT;
3722
3636
 
3723
 
  DBUG_RETURN(tab1);
 
3637
  return(tab1);
3724
3638
}
3725
3639
 
3726
3640
/**
3737
3651
void st_select_lex::set_lock_for_tables(thr_lock_type lock_type)
3738
3652
{
3739
3653
  bool for_update= lock_type >= TL_READ_NO_INSERT;
3740
 
  DBUG_ENTER("set_lock_for_tables");
3741
 
  DBUG_PRINT("enter", ("lock_type: %d  for_update: %d", lock_type,
3742
 
                       for_update));
3743
3654
 
3744
3655
  for (TABLE_LIST *tables= (TABLE_LIST*) table_list.first;
3745
3656
       tables;
3748
3659
    tables->lock_type= lock_type;
3749
3660
    tables->updating=  for_update;
3750
3661
  }
3751
 
  DBUG_VOID_RETURN;
 
3662
  return;
3752
3663
}
3753
3664
 
3754
3665
 
3781
3692
bool st_select_lex_unit::add_fake_select_lex(THD *thd_arg)
3782
3693
{
3783
3694
  SELECT_LEX *first_sl= first_select();
3784
 
  DBUG_ENTER("add_fake_select_lex");
3785
 
  DBUG_ASSERT(!fake_select_lex);
 
3695
  assert(!fake_select_lex);
3786
3696
 
3787
3697
  if (!(fake_select_lex= new (thd_arg->mem_root) SELECT_LEX()))
3788
 
      DBUG_RETURN(1);
 
3698
      return(1);
3789
3699
  fake_select_lex->include_standalone(this, 
3790
3700
                                      (SELECT_LEX_NODE**)&fake_select_lex);
3791
3701
  fake_select_lex->select_number= INT_MAX;
3812
3722
    thd_arg->lex->current_select= fake_select_lex;
3813
3723
  }
3814
3724
  thd_arg->lex->pop_context();
3815
 
  DBUG_RETURN(0);
 
3725
  return(0);
3816
3726
}
3817
3727
 
3818
3728
 
3952
3862
  select_errors=0;                              /* Write if more errors */
3953
3863
  bool tmp_write_to_binlog= 1;
3954
3864
 
3955
 
  DBUG_ASSERT(!thd || !thd->in_sub_stmt);
 
3865
  assert(!thd || !thd->in_sub_stmt);
3956
3866
 
3957
3867
  if (options & REFRESH_LOG)
3958
3868
  {
4039
3949
    flush_thread_cache();
4040
3950
  if (options & REFRESH_MASTER)
4041
3951
  {
4042
 
    DBUG_ASSERT(thd);
 
3952
    assert(thd);
4043
3953
    tmp_write_to_binlog= 0;
4044
3954
    if (reset_master(thd))
4045
3955
    {
4075
3985
{
4076
3986
  THD *tmp;
4077
3987
  uint error=ER_NO_SUCH_THREAD;
4078
 
  DBUG_ENTER("kill_one_thread");
4079
 
  DBUG_PRINT("enter", ("id=%lu only_kill=%d", id, only_kill_query));
4080
3988
  VOID(pthread_mutex_lock(&LOCK_thread_count)); // For unlink from list
4081
3989
  I_List_iterator<THD> it(threads);
4082
3990
  while ((tmp=it++))
4096
4004
    error=0;
4097
4005
    pthread_mutex_unlock(&tmp->LOCK_delete);
4098
4006
  }
4099
 
  DBUG_PRINT("exit", ("%d", error));
4100
 
  DBUG_RETURN(error);
 
4007
  return(error);
4101
4008
}
4102
4009
 
4103
4010
 
4259
4166
  const char *msg= 0;
4260
4167
  LEX *lex= thd->lex;
4261
4168
  SELECT_LEX *select_lex= &lex->select_lex;
4262
 
  DBUG_ENTER("multi_update_precheck");
4263
4169
 
4264
4170
  if (select_lex->item_list.elements != lex->value_list.elements)
4265
4171
  {
4266
4172
    my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
4267
 
    DBUG_RETURN(true);
 
4173
    return(true);
4268
4174
  }
4269
4175
 
4270
4176
  if (select_lex->order_list.elements)
4274
4180
  if (msg)
4275
4181
  {
4276
4182
    my_error(ER_WRONG_USAGE, MYF(0), "UPDATE", msg);
4277
 
    DBUG_RETURN(true);
 
4183
    return(true);
4278
4184
  }
4279
 
  DBUG_RETURN(false);
 
4185
  return(false);
4280
4186
}
4281
4187
 
4282
4188
/**
4296
4202
{
4297
4203
  SELECT_LEX *select_lex= &thd->lex->select_lex;
4298
4204
  TABLE_LIST **save_query_tables_own_last= thd->lex->query_tables_own_last;
4299
 
  DBUG_ENTER("multi_delete_precheck");
4300
4205
 
4301
4206
  thd->lex->query_tables_own_last= 0;
4302
4207
  thd->lex->query_tables_own_last= save_query_tables_own_last;
4305
4210
  {
4306
4211
    my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
4307
4212
               ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0));
4308
 
    DBUG_RETURN(true);
 
4213
    return(true);
4309
4214
  }
4310
 
  DBUG_RETURN(false);
 
4215
  return(false);
4311
4216
}
4312
4217
 
4313
4218
 
4333
4238
                                            TABLE_LIST *tables)
4334
4239
{
4335
4240
  TABLE_LIST *match= NULL;
4336
 
  DBUG_ENTER("multi_delete_table_match");
4337
4241
 
4338
4242
  for (TABLE_LIST *elem= tables; elem; elem= elem->next_local)
4339
4243
  {
4356
4260
    if (match)
4357
4261
    {
4358
4262
      my_error(ER_NONUNIQ_TABLE, MYF(0), elem->alias);
4359
 
      DBUG_RETURN(NULL);
 
4263
      return(NULL);
4360
4264
    }
4361
4265
 
4362
4266
    match= elem;
4365
4269
  if (!match)
4366
4270
    my_error(ER_UNKNOWN_TABLE, MYF(0), tbl->table_name, "MULTI DELETE");
4367
4271
 
4368
 
  DBUG_RETURN(match);
 
4272
  return(match);
4369
4273
}
4370
4274
 
4371
4275
 
4385
4289
{
4386
4290
  TABLE_LIST *tables= (TABLE_LIST*)lex->select_lex.table_list.first;
4387
4291
  TABLE_LIST *target_tbl;
4388
 
  DBUG_ENTER("multi_delete_set_locks_and_link_aux_tables");
4389
4292
 
4390
4293
  lex->table_count= 0;
4391
4294
 
4396
4299
    /* All tables in aux_tables must be found in FROM PART */
4397
4300
    TABLE_LIST *walk= multi_delete_table_match(lex, target_tbl, tables);
4398
4301
    if (!walk)
4399
 
      DBUG_RETURN(true);
 
4302
      return(true);
4400
4303
    if (!walk->derived)
4401
4304
    {
4402
4305
      target_tbl->table_name= walk->table_name;
4406
4309
    walk->lock_type= target_tbl->lock_type;
4407
4310
    target_tbl->correspondent_table= walk;      // Remember corresponding table
4408
4311
  }
4409
 
  DBUG_RETURN(false);
 
4312
  return(false);
4410
4313
}
4411
4314
 
4412
4315
 
4424
4327
 
4425
4328
bool update_precheck(THD *thd, TABLE_LIST *tables __attribute__((__unused__)))
4426
4329
{
4427
 
  DBUG_ENTER("update_precheck");
4428
4330
  if (thd->lex->select_lex.item_list.elements != thd->lex->value_list.elements)
4429
4331
  {
4430
4332
    my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
4431
 
    DBUG_RETURN(true);
 
4333
    return(true);
4432
4334
  }
4433
 
  DBUG_RETURN(false);
 
4335
  return(false);
4434
4336
}
4435
4337
 
4436
4338
 
4449
4351
bool insert_precheck(THD *thd, TABLE_LIST *tables __attribute__((__unused__)))
4450
4352
{
4451
4353
  LEX *lex= thd->lex;
4452
 
  DBUG_ENTER("insert_precheck");
4453
4354
 
4454
4355
  /*
4455
4356
    Check that we have modify privileges for the first table and
4458
4359
  if (lex->update_list.elements != lex->value_list.elements)
4459
4360
  {
4460
4361
    my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
4461
 
    DBUG_RETURN(true);
 
4362
    return(true);
4462
4363
  }
4463
 
  DBUG_RETURN(false);
 
4364
  return(false);
4464
4365
}
4465
4366
 
4466
4367
 
4484
4385
  LEX *lex= thd->lex;
4485
4386
  SELECT_LEX *select_lex= &lex->select_lex;
4486
4387
  bool error= true;                                 // Error message is given
4487
 
  DBUG_ENTER("create_table_precheck");
4488
4388
 
4489
4389
  if (create_table && (strcmp(create_table->db, "information_schema") == 0))
4490
4390
  {
4491
4391
    my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), "", "", INFORMATION_SCHEMA_NAME.str);
4492
 
    DBUG_RETURN(true);
 
4392
    return(true);
4493
4393
  }
4494
4394
 
4495
4395
  if (select_lex->item_list.elements)
4520
4420
  }
4521
4421
  error= false;
4522
4422
 
4523
 
  DBUG_RETURN(error);
 
4423
  return(error);
4524
4424
}
4525
4425
 
4526
4426
 
4656
4556
    my_error(err_code, MYF(0), str->str);
4657
4557
    break;
4658
4558
  default:
4659
 
    DBUG_ASSERT(0);
 
4559
    assert(0);
4660
4560
    break;
4661
4561
  }
4662
4562
  return true;
4680
4580
{
4681
4581
  char path[FN_REFLEN], conv_path[FN_REFLEN];
4682
4582
  uint dir_len, home_dir_len= strlen(mysql_unpacked_real_data_home);
4683
 
  DBUG_ENTER("test_if_data_home_dir");
4684
4583
 
4685
4584
  if (!dir)
4686
 
    DBUG_RETURN(0);
 
4585
    return(0);
4687
4586
 
4688
4587
  (void) fn_format(path, dir, "", "",
4689
4588
                   (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
4697
4596
                        (const uchar*) conv_path, home_dir_len,
4698
4597
                        (const uchar*) mysql_unpacked_real_data_home,
4699
4598
                        home_dir_len))
4700
 
        DBUG_RETURN(1);
 
4599
        return(1);
4701
4600
    }
4702
4601
    else if (!memcmp(conv_path, mysql_unpacked_real_data_home, home_dir_len))
4703
 
      DBUG_RETURN(1);
 
4602
      return(1);
4704
4603
  }
4705
 
  DBUG_RETURN(0);
 
4604
  return(0);
4706
4605
}
4707
4606
 
4708
4607
 
4726
4625
               Lex_input_stream *lip,
4727
4626
               Object_creation_ctx *creation_ctx)
4728
4627
{
4729
 
  DBUG_ASSERT(thd->m_lip == NULL);
 
4628
  assert(thd->m_lip == NULL);
4730
4629
 
4731
4630
  /* Backup creation context. */
4732
4631
 
4745
4644
 
4746
4645
  /* Check that if MYSQLparse() failed, thd->is_error() is set. */
4747
4646
 
4748
 
  DBUG_ASSERT(!mysql_parse_status || thd->is_error());
 
4647
  assert(!mysql_parse_status || thd->is_error());
4749
4648
 
4750
4649
  /* Reset Lex_input_stream. */
4751
4650