~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/parser.cc

  • Committer: pcrews
  • Date: 2011-05-24 17:36:24 UTC
  • mfrom: (1099.4.232 drizzle)
  • Revision ID: pcrews@lucid32-20110524173624-mwr1bvq6fa1r01ao
Updated translations + 2011.05.18 tarball tag

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
22
 
 
 
21
#include <config.h>
 
22
#include <drizzled/session.h>
23
23
#include <drizzled/parser.h>
24
 
 
25
 
namespace drizzled
26
 
{
27
 
namespace parser
28
 
{
 
24
#include <drizzled/alter_info.h>
 
25
 
 
26
#include <drizzled/message/alter_table.pb.h>
 
27
#include <drizzled/item/subselect.h>
 
28
#include <drizzled/sql_lex.h>
 
29
 
 
30
namespace drizzled {
 
31
namespace parser {
29
32
 
30
33
/**
31
34
  Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
179
182
 
180
183
Item* reserved_keyword_function(Session *session, const std::string &name, List<Item> *item_list)
181
184
{
182
 
  const plugin::Function *udf= plugin::Function::get(name.c_str(), name.length());
183
 
  Item *item= NULL;
 
185
  const plugin::Function *udf= plugin::Function::get(name);
184
186
 
185
187
  if (udf)
186
188
  {
187
 
    item= Create_udf_func::s_singleton.create(session, udf, item_list);
188
 
  } else {
189
 
    my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
 
189
    return Create_udf_func::s_singleton.create(session, udf, item_list);
190
190
  }
191
191
 
192
 
  return item;
 
192
  my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
 
193
 
 
194
  return NULL;
193
195
}
194
196
 
195
197
/**
248
250
  push an error into the error stack and DRIZZLE_YYABORT
249
251
  to abort from the parser.
250
252
*/
251
 
void errorOn(const char *s)
 
253
void errorOn(drizzled::Session *session, const char *s)
252
254
{
253
 
  Session *session= current_session;
254
 
 
255
255
  /* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
256
256
  if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
257
257
  {
322
322
  opt->set_state(value.str, value.length);
323
323
}
324
324
 
 
325
void buildSchemaDefiner(LEX *lex, const LEX_STRING &value)
 
326
{
 
327
  statement::CreateSchema *statement= (statement::CreateSchema *)lex->statement;
 
328
  identifier::User user(value.str);
 
329
  message::set_definer(statement->schema_message, user);
 
330
}
 
331
 
 
332
void buildSchemaDefiner(LEX *lex, const identifier::User &user)
 
333
{
 
334
  statement::CreateSchema *statement= (statement::CreateSchema *)lex->statement;
 
335
  message::set_definer(statement->schema_message, user);
 
336
}
 
337
 
325
338
void buildSchemaOption(LEX *lex, const char *key, uint64_t value)
326
339
{
327
340
  statement::CreateSchema *statement= (statement::CreateSchema *)lex->statement;
393
406
  lex->charset= NULL;
394
407
  statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
395
408
 
396
 
  message::AlterTable &alter_proto= ((statement::CreateTable *)lex->statement)->alter_info.alter_proto;
397
 
  lex->setField(alter_proto.add_added_field());
 
409
  message::AddedFields &added_fields_proto= ((statement::CreateTable *)lex->statement)->alter_info.added_fields_proto;
 
410
  lex->setField(added_fields_proto.add_added_field());
398
411
}
399
412
 
400
413
void storeAlterColumnPosition(LEX *lex, const char *position)
405
418
  statement->alter_info.flags.set(ALTER_COLUMN_ORDER);
406
419
}
407
420
 
408
 
bool buildCollation(LEX *lex, const CHARSET_INFO *arg)
 
421
bool buildCollation(LEX *lex, const charset_info_st *arg)
409
422
{
410
423
  statement::CreateTable *statement= (statement::CreateTable *)lex->statement;
411
424
 
430
443
  Key *key= new Key(type_par, name_arg, &statement->key_create_info, 0,
431
444
                    lex->col_list);
432
445
  statement->alter_info.key_list.push_back(key);
433
 
  lex->col_list.empty(); /* Alloced by memory::sql_alloc */
 
446
  lex->col_list.clear(); /* Alloced by memory::sql_alloc */
434
447
}
435
448
 
436
449
void buildForeignKey(LEX *lex, const lex_string_t &name_arg, drizzled::Table_ident *table)
448
461
               &default_key_create_info, 1,
449
462
               lex->col_list);
450
463
  statement->alter_info.key_list.push_back(key);
451
 
  lex->col_list.empty(); /* Alloced by memory::sql_alloc */
 
464
  lex->col_list.clear(); /* Alloced by memory::sql_alloc */
452
465
  /* Only used for ALTER TABLE. Ignored otherwise. */
453
466
  statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
454
467
}
647
660
  }
648
661
}
649
662
 
 
663
void buildReplicationOption(LEX *lex, bool arg)
 
664
{
 
665
  statement::CreateSchema *statement= (statement::CreateSchema *)lex->statement;
 
666
  message::set_is_replicated(statement->schema_message, arg);
 
667
}
 
668
 
 
669
void buildAddAlterDropIndex(LEX *lex, const char *name, bool is_foreign_key)
 
670
{
 
671
  statement::AlterTable *statement= (statement::AlterTable *)lex->statement;
 
672
 
 
673
  message::AlterTable::AlterTableOperation *operation;
 
674
  operation= lex->alter_table()->add_operations();
 
675
  operation->set_drop_name(name);
 
676
 
 
677
  statement->alter_info.flags.set(ALTER_DROP_INDEX);
 
678
  if (is_foreign_key)
 
679
  {
 
680
    statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
 
681
    operation->set_operation(message::AlterTable::AlterTableOperation::DROP_FOREIGN_KEY);
 
682
  }
 
683
  else
 
684
  {
 
685
    operation->set_operation(message::AlterTable::AlterTableOperation::DROP_KEY);
 
686
  }
 
687
}
 
688
 
650
689
} // namespace parser
651
690
} // namespace drizzled