~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

  • Committer: Brian Aker
  • Date: 2009-06-08 22:21:27 UTC
  • mto: This revision was merged to the branch mainline in revision 1058.
  • Revision ID: brian@gaz-20090608222127-gazmq4pzrq49dvhn
This is a large number of refactors against the Session class for its
ownership of of open_tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
239
239
  upgrade_lock_type(session, &table_list->lock_type, duplic,
240
240
                    values_list.elements > 1);
241
241
 
242
 
  if (open_and_lock_tables(session, table_list))
 
242
  if (session->open_and_lock_tables(table_list))
243
243
    return(true);
244
244
 
245
245
  lock_type= table_list->lock_type;
656
656
    TableList *duplicate;
657
657
    if ((duplicate= unique_table(session, table_list, table_list->next_global, 1)))
658
658
    {
659
 
      update_non_unique_table_error(table_list, "INSERT", duplicate);
660
 
      return(true);
 
659
      my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->alias);
 
660
 
 
661
      return true;
661
662
    }
662
663
  }
663
664
  if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
664
665
    table->prepare_for_position();
665
 
  return(false);
 
666
 
 
667
  return false;
666
668
}
667
669
 
668
670
 
1470
1472
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1471
1473
                          ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
1472
1474
                          create_table->table_name);
1473
 
      return(create_table->table);
 
1475
      return create_table->table;
1474
1476
    }
1475
1477
 
1476
1478
    my_error(ER_TABLE_EXISTS_ERROR, MYF(0), create_table->table_name);
1477
 
    return(0);
 
1479
    return NULL;
1478
1480
  }
1479
1481
 
1480
1482
  tmp_table.alias= 0;
1506
1508
        !(cr_field=new Create_field(field,(item->type() == Item::FIELD_ITEM ?
1507
1509
                                           ((Item_field *)item)->field :
1508
1510
                                           (Field*) 0))))
1509
 
      return(0);
 
1511
      return NULL;
1510
1512
    if (item->maybe_null)
1511
1513
      cr_field->flags &= ~NOT_NULL_FLAG;
1512
1514
    alter_info->create_list.push_back(cr_field);
1540
1542
          cluster. We don't have much options but throw an error.
1541
1543
        */
1542
1544
        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), create_table->table_name);
1543
 
        return(0);
 
1545
        return NULL;
1544
1546
      }
1545
1547
 
1546
1548
      if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
1547
1549
      {
1548
1550
        pthread_mutex_lock(&LOCK_open); /* CREATE TABLE... has found that the table already exists for insert and is adapting to use it */
1549
 
        if (reopen_name_locked_table(session, create_table, false))
 
1551
        if (session->reopen_name_locked_table(create_table, false))
1550
1552
        {
1551
1553
          quick_rm_table(create_info->db_type, create_table->db,
1552
1554
                         create_table->table_name, false);
1566
1568
            it preparable for open. But let us do close_temporary_table() here
1567
1569
            just in case.
1568
1570
          */
1569
 
          drop_temporary_table(session, create_table);
 
1571
          session->drop_temporary_table(create_table);
1570
1572
        }
1571
1573
      }
1572
1574
    }
1573
1575
    if (!table)                                   // open failed
1574
 
      return(0);
 
1576
      return NULL;
1575
1577
  }
1576
1578
 
1577
1579
  table->reginfo.lock_type=TL_WRITE;
1585
1587
    }
1586
1588
 
1587
1589
    if (!create_info->table_existed)
1588
 
      drop_open_table(session, table, create_table->db, create_table->table_name);
1589
 
    return(0);
 
1590
      session->drop_open_table(table, create_table->db, create_table->table_name);
 
1591
    return NULL;
1590
1592
  }
1591
 
  return(table);
 
1593
 
 
1594
  return table;
1592
1595
}
1593
1596
 
1594
1597
 
1767
1770
    table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
1768
1771
    table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
1769
1772
    if (!create_info->table_existed)
1770
 
      drop_open_table(session, table, create_table->db, create_table->table_name);
1771
 
    table=0;                                    // Safety
 
1773
      session->drop_open_table(table, create_table->db, create_table->table_name);
 
1774
    table= NULL;                                    // Safety
1772
1775
  }
1773
 
  return;
1774
1776
}
1775
1777
 
1776
1778