~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

  • Committer: Brian Aker
  • Date: 2011-01-17 04:15:23 UTC
  • mto: (2088.1.3 merge)
  • mto: This revision was merged to the branch mainline in revision 2089.
  • Revision ID: brian@gir-3-20110117041523-o9ex94kfz1a6iqyw
Modify TableIdentifier to fit with the rest of the identifiers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <drizzled/probes.h>
26
26
#include <drizzled/sql_base.h>
27
27
#include <drizzled/sql_load.h>
28
 
#include <drizzled/field/timestamp.h>
 
28
#include <drizzled/field/epoch.h>
29
29
#include <drizzled/lock.h>
30
30
#include "drizzled/sql_table.h"
31
31
#include "drizzled/pthread_globals.h"
227
227
  end of dispatch_command().
228
228
*/
229
229
 
230
 
bool mysql_insert(Session *session,TableList *table_list,
 
230
bool insert_query(Session *session,TableList *table_list,
231
231
                  List<Item> &fields,
232
232
                  List<List_item> &values_list,
233
233
                  List<Item> &update_fields,
271
271
  values= its++;
272
272
  value_count= values->elements;
273
273
 
274
 
  if (mysql_prepare_insert(session, table_list, table, fields, values,
 
274
  if (prepare_insert(session, table_list, table, fields, values,
275
275
                           update_fields, update_values, duplic, &unused_conds,
276
276
                           false,
277
277
                           (fields.elements || !value_count ||
520
520
  Check if table can be updated
521
521
 
522
522
  SYNOPSIS
523
 
     mysql_prepare_insert_check_table()
 
523
     prepare_insert_check_table()
524
524
     session            Thread handle
525
525
     table_list         Table list
526
526
     fields             List of fields to be updated
532
532
     true  ERROR
533
533
*/
534
534
 
535
 
static bool mysql_prepare_insert_check_table(Session *session, TableList *table_list,
 
535
static bool prepare_insert_check_table(Session *session, TableList *table_list,
536
536
                                             List<Item> &,
537
537
                                             bool select_insert)
538
538
{
560
560
  Prepare items in INSERT statement
561
561
 
562
562
  SYNOPSIS
563
 
    mysql_prepare_insert()
 
563
    prepare_insert()
564
564
    session                     Thread handler
565
565
    table_list          Global/local table list
566
566
    table               Table to insert into (can be NULL if table should
587
587
    true  error
588
588
*/
589
589
 
590
 
bool mysql_prepare_insert(Session *session, TableList *table_list,
 
590
bool prepare_insert(Session *session, TableList *table_list,
591
591
                          Table *table, List<Item> &fields, List_item *values,
592
592
                          List<Item> &update_fields, List<Item> &update_values,
593
593
                          enum_duplicates duplic,
632
632
      return(true);
633
633
  }
634
634
 
635
 
  if (mysql_prepare_insert_check_table(session, table_list, fields, select_insert))
 
635
  if (prepare_insert_check_table(session, table_list, fields, select_insert))
636
636
    return(true);
637
637
 
638
638
 
868
868
          /*
869
869
            If ON DUP KEY UPDATE updates a row instead of inserting one, it's
870
870
            like a regular UPDATE statement: it should not affect the value of a
871
 
            next SELECT LAST_INSERT_ID() or mysql_insert_id().
 
871
            next SELECT LAST_INSERT_ID() or insert_id().
872
872
            Except if LAST_INSERT_ID(#) was in the INSERT query, which is
873
873
            handled separately by Session::arg_of_last_insert_id_function.
874
874
          */
1026
1026
  make insert specific preparation and checks after opening tables
1027
1027
 
1028
1028
  SYNOPSIS
1029
 
    mysql_insert_select_prepare()
 
1029
    insert_select_prepare()
1030
1030
    session         thread handler
1031
1031
 
1032
1032
  RETURN
1034
1034
    true  Error
1035
1035
*/
1036
1036
 
1037
 
bool mysql_insert_select_prepare(Session *session)
 
1037
bool insert_select_prepare(Session *session)
1038
1038
{
1039
1039
  LEX *lex= session->lex;
1040
1040
  Select_Lex *select_lex= &lex->select_lex;
1044
1044
    clause if table is VIEW
1045
1045
  */
1046
1046
 
1047
 
  if (mysql_prepare_insert(session, lex->query_tables,
 
1047
  if (prepare_insert(session, lex->query_tables,
1048
1048
                           lex->query_tables->table, lex->field_list, 0,
1049
1049
                           lex->update_list, lex->value_list,
1050
1050
                           lex->duplicates,
1485
1485
                                      List<Item> *items,
1486
1486
                                      bool is_if_not_exists,
1487
1487
                                      DrizzleLock **lock,
1488
 
                                      TableIdentifier &identifier)
 
1488
                                      identifier::Table::const_reference identifier)
1489
1489
{
1490
1490
  TableShare share(message::Table::INTERNAL);
1491
1491
  uint32_t select_field_count= items->elements;
1493
1493
  List_iterator_fast<Item> it(*items);
1494
1494
  Item *item;
1495
1495
  Field *tmp_field;
1496
 
  bool not_used;
1497
1496
 
1498
1497
  if (not (identifier.isTmp()) && create_table->table->db_stat)
1499
1498
  {
1576
1575
  */
1577
1576
  Table *table= 0;
1578
1577
  {
1579
 
    if (not mysql_create_table_no_lock(session,
1580
 
                                       identifier,
1581
 
                                       create_info,
1582
 
                                       table_proto,
1583
 
                                       alter_info,
1584
 
                                       false,
1585
 
                                       select_field_count,
1586
 
                                       is_if_not_exists))
 
1578
    if (not create_table_no_lock(session,
 
1579
                                 identifier,
 
1580
                                 create_info,
 
1581
                                 table_proto,
 
1582
                                 alter_info,
 
1583
                                 false,
 
1584
                                 select_field_count,
 
1585
                                 is_if_not_exists))
1587
1586
    {
1588
1587
      if (create_info->table_existed && not identifier.isTmp())
1589
1588
      {
1607
1606
 
1608
1607
          if (concurrent_table->reopen_name_locked_table(create_table, session))
1609
1608
          {
1610
 
            plugin::StorageEngine::dropTable(*session, identifier);
 
1609
            (void)plugin::StorageEngine::dropTable(*session, identifier);
1611
1610
          }
1612
1611
          else
1613
1612
          {
1616
1615
        }
1617
1616
        else
1618
1617
        {
1619
 
          plugin::StorageEngine::dropTable(*session, identifier);
 
1618
          (void)plugin::StorageEngine::dropTable(*session, identifier);
1620
1619
        }
1621
1620
      }
1622
1621
      else
1639
1638
  }
1640
1639
 
1641
1640
  table->reginfo.lock_type=TL_WRITE;
1642
 
  if (! ((*lock)= session->lockTables(&table, 1, DRIZZLE_LOCK_IGNORE_FLUSH, &not_used)))
 
1641
  if (not ((*lock)= session->lockTables(&table, 1, DRIZZLE_LOCK_IGNORE_FLUSH)))
1643
1642
  {
1644
1643
    if (*lock)
1645
1644
    {