~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/parser.cc

  • Committer: Lee Bieber
  • Date: 2011-01-28 02:32:26 UTC
  • mfrom: (2114.4.10 alter-table)
  • mto: This revision was merged to the branch mainline in revision 2124.
  • Revision ID: kalebral@gmail.com-20110128023226-11i88kemmdygtz0d
Merge Brian - more parser rework

Show diffs side-by-side

added added

removed removed

Lines of Context:
263
263
  }
264
264
}
265
265
 
266
 
bool buildOrderBy(Session *session)
 
266
bool buildOrderBy(LEX *lex)
267
267
{
268
 
  Select_Lex *sel= session->getLex()->current_select;
 
268
  Select_Lex *sel= lex->current_select;
269
269
  Select_Lex_Unit *unit= sel-> master_unit();
270
270
 
271
271
  if (sel->linkage != GLOBAL_OPTIONS_TYPE &&
277
277
    return false;
278
278
  }
279
279
 
280
 
  if (session->getLex()->sql_command != SQLCOM_ALTER_TABLE && !unit->fake_select_lex)
 
280
  if (lex->sql_command != SQLCOM_ALTER_TABLE && !unit->fake_select_lex)
281
281
  {
282
282
    /*
283
283
      A query of the of the form (SELECT ...) ORDER BY order_list is
291
291
    if (!unit->is_union() &&
292
292
        (first_sl->order_list.elements ||
293
293
         first_sl->select_limit) &&           
294
 
        unit->add_fake_select_lex(session->getLex()->session))
 
294
        unit->add_fake_select_lex(lex->session))
295
295
    {
296
296
      return false;
297
297
    }
300
300
  return true;
301
301
}
302
302
 
303
 
void buildEngineOption(Session *session, const char *key, const LEX_STRING &value)
304
 
{
305
 
  message::Engine::Option *opt= session->getLex()->table()->mutable_engine()->add_options();
306
 
  opt->set_name(key);
307
 
  opt->set_state(value.str, value.length);
308
 
}
309
 
 
310
 
void buildEngineOption(Session *session, const char *key, uint64_t value)
311
 
{
312
 
  drizzled::message::Engine::Option *opt= session->getLex()->table()->mutable_engine()->add_options();
313
 
  opt->set_name(key);
314
 
  opt->set_state(boost::lexical_cast<std::string>(value));
315
 
}
316
 
 
317
 
void buildSchemaOption(Session *session, const char *key, const LEX_STRING &value)
318
 
{
319
 
  statement::CreateSchema *statement= (statement::CreateSchema *)session->getLex()->statement;
320
 
  message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
321
 
  opt->set_name(key);
322
 
  opt->set_state(value.str, value.length);
323
 
}
324
 
 
325
 
void buildSchemaOption(Session *session, const char *key, uint64_t value)
326
 
{
327
 
  statement::CreateSchema *statement= (statement::CreateSchema *)session->getLex()->statement;
328
 
  message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
329
 
  opt->set_name(key);
330
 
  opt->set_state(boost::lexical_cast<std::string>(value));
331
 
}
332
 
 
333
 
bool checkFieldIdent(Session *session, const LEX_STRING &schema_name, const LEX_STRING &table_name)
334
 
{
335
 
  TableList *table= reinterpret_cast<TableList*>(session->getLex()->current_select->table_list.first);
 
303
void buildEngineOption(LEX *lex, const char *key, const LEX_STRING &value)
 
304
{
 
305
  message::Engine::Option *opt= lex->table()->mutable_engine()->add_options();
 
306
  opt->set_name(key);
 
307
  opt->set_state(value.str, value.length);
 
308
}
 
309
 
 
310
void buildEngineOption(LEX *lex, const char *key, uint64_t value)
 
311
{
 
312
  drizzled::message::Engine::Option *opt= lex->table()->mutable_engine()->add_options();
 
313
  opt->set_name(key);
 
314
  opt->set_state(boost::lexical_cast<std::string>(value));
 
315
}
 
316
 
 
317
void buildSchemaOption(LEX *lex, const char *key, const LEX_STRING &value)
 
318
{
 
319
  statement::CreateSchema *statement= (statement::CreateSchema *)lex->statement;
 
320
  message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
 
321
  opt->set_name(key);
 
322
  opt->set_state(value.str, value.length);
 
323
}
 
324
 
 
325
void buildSchemaOption(LEX *lex, const char *key, uint64_t value)
 
326
{
 
327
  statement::CreateSchema *statement= (statement::CreateSchema *)lex->statement;
 
328
  message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
 
329
  opt->set_name(key);
 
330
  opt->set_state(boost::lexical_cast<std::string>(value));
 
331
}
 
332
 
 
333
bool checkFieldIdent(LEX *lex, const LEX_STRING &schema_name, const LEX_STRING &table_name)
 
334
{
 
335
  TableList *table= reinterpret_cast<TableList*>(lex->current_select->table_list.first);
336
336
 
337
337
  if (schema_name.length)
338
338
  {
353
353
  return true;
354
354
}
355
355
 
356
 
Item *buildIdent(Session *session,
 
356
Item *buildIdent(LEX *lex,
357
357
                 const LEX_STRING &schema_name,
358
358
                 const LEX_STRING &table_name,
359
359
                 const LEX_STRING &field_name)
360
360
{
361
 
  Select_Lex *sel= session->getLex()->current_select;
 
361
  Select_Lex *sel= lex->current_select;
362
362
 
363
 
  if (sel->no_table_names_allowed)
 
363
  if (table_name.length and sel->no_table_names_allowed)
364
364
  {
365
365
    my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
366
 
             MYF(0), table_name.str, session->where);
 
366
             MYF(0), table_name.str, lex->session->where());
367
367
  }
368
368
 
369
369
  Item *item= (sel->parsing_place != IN_HAVING or
370
370
               sel->get_in_sum_expr() > 0) ?
371
 
    (Item*) new Item_field(session->getLex()->current_context(), schema_name.str, table_name.str, field_name.str) :
372
 
    (Item*) new Item_ref(session->getLex()->current_context(), schema_name.str, table_name.str, field_name.str);
373
 
 
374
 
  return item;
 
371
    (Item*) new Item_field(lex->current_context(), schema_name.str, table_name.str, field_name.str) :
 
372
    (Item*) new Item_ref(lex->current_context(), schema_name.str, table_name.str, field_name.str);
 
373
 
 
374
  return item;
 
375
}
 
376
 
 
377
Item *buildTableWild(LEX *lex, const LEX_STRING &schema_name, const LEX_STRING &table_name)
 
378
{
 
379
  Select_Lex *sel= lex->current_select;
 
380
  Item *item= new Item_field(lex->current_context(), schema_name.str, table_name.str, "*");
 
381
  sel->with_wild++;
 
382
 
 
383
  return item;
 
384
}
 
385
 
 
386
void buildCreateFieldIdent(LEX *lex)
 
387
{
 
388
  statement::CreateTable *statement= (statement::CreateTable *)lex->statement;
 
389
  lex->length= lex->dec=0;
 
390
  lex->type=0;
 
391
  statement->default_value= statement->on_update_value= 0;
 
392
  statement->comment= null_lex_str;
 
393
  lex->charset= NULL;
 
394
  statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
 
395
 
 
396
  message::AlterTable &alter_proto= ((statement::CreateTable *)lex->statement)->alter_info.alter_proto;
 
397
  lex->setField(alter_proto.add_added_field());
375
398
}
376
399
 
377
400
} // namespace parser