~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Brian Aker
  • Date: 2009-02-03 21:38:52 UTC
  • Revision ID: brian@tangent.org-20090203213852-rbwmyx2w70zhnea9
Simplify update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1401
1401
  }
1402
1402
  case SQLCOM_UPDATE:
1403
1403
    assert(first_table == all_tables && first_table != 0);
1404
 
    if (update_precheck(session, all_tables))
 
1404
    if ((res= update_precheck(session, all_tables)))
1405
1405
      break;
1406
1406
    assert(select_lex->offset_limit == 0);
1407
1407
    unit->set_limit(select_lex);
1417
1417
  case SQLCOM_UPDATE_MULTI:
1418
1418
  {
1419
1419
    assert(first_table == all_tables && first_table != 0);
1420
 
    if ((res= multi_update_precheck(session, all_tables)))
 
1420
    if ((res= update_precheck(session, all_tables)))
1421
1421
      break;
1422
1422
 
1423
1423
    if ((res= mysql_multi_update_prepare(session)))
3311
3311
 
3312
3312
 
3313
3313
/**
3314
 
  Multi update query pre-check.
 
3314
  Update query pre-check.
3315
3315
 
3316
3316
  @param session                Thread handler
3317
3317
  @param tables Global/local table list (have to be the same)
3322
3322
    true  Error
3323
3323
*/
3324
3324
 
3325
 
bool multi_update_precheck(Session *session, TableList *)
 
3325
bool update_precheck(Session *session, TableList *)
3326
3326
{
3327
3327
  const char *msg= 0;
3328
3328
  LEX *lex= session->lex;
3329
3329
  SELECT_LEX *select_lex= &lex->select_lex;
3330
3330
 
3331
 
  if (select_lex->item_list.elements != lex->value_list.elements)
 
3331
  if (session->lex->select_lex.item_list.elements != session->lex->value_list.elements)
3332
3332
  {
3333
3333
    my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
3334
3334
    return(true);
3335
3335
  }
3336
3336
 
3337
 
  if (select_lex->order_list.elements)
3338
 
    msg= "ORDER BY";
3339
 
  else if (select_lex->select_limit)
3340
 
    msg= "LIMIT";
3341
 
  if (msg)
 
3337
  if (session->lex->select_lex.table_list.elements > 1)
3342
3338
  {
3343
 
    my_error(ER_WRONG_USAGE, MYF(0), "UPDATE", msg);
3344
 
    return(true);
 
3339
    if (select_lex->order_list.elements)
 
3340
      msg= "ORDER BY";
 
3341
    else if (select_lex->select_limit)
 
3342
      msg= "LIMIT";
 
3343
    if (msg)
 
3344
    {
 
3345
      my_error(ER_WRONG_USAGE, MYF(0), "UPDATE", msg);
 
3346
      return(true);
 
3347
    }
3345
3348
  }
3346
3349
  return(false);
3347
3350
}
3473
3476
 
3474
3477
 
3475
3478
/**
3476
 
  simple UPDATE query pre-check.
3477
 
 
3478
 
  @param session                Thread handler
3479
 
  @param tables Global table list
3480
 
 
3481
 
  @retval
3482
 
    false OK
3483
 
  @retval
3484
 
    true  Error
3485
 
*/
3486
 
 
3487
 
bool update_precheck(Session *session, TableList *)
3488
 
{
3489
 
  if (session->lex->select_lex.item_list.elements != session->lex->value_list.elements)
3490
 
  {
3491
 
    my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
3492
 
    return(true);
3493
 
  }
3494
 
  return(false);
3495
 
}
3496
 
 
3497
 
 
3498
 
/**
3499
3479
  simple INSERT query pre-check.
3500
3480
 
3501
3481
  @param session                Thread handler