~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

Merged in changes from Andrey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#define my_safe_alloca(size, min_length) my_alloca(size)
35
35
#define my_safe_afree(ptr, size, min_length) my_afree(ptr)
36
36
#else
37
 
#define my_safe_alloca(size, min_length) ((size <= min_length) ? my_alloca(size) : my_malloc(size,MYF(0)))
38
 
#define my_safe_afree(ptr, size, min_length) if (size > min_length) my_free(ptr,MYF(0))
 
37
#define my_safe_alloca(size, min_length) ((size <= min_length) ? my_alloca(size) : malloc(size))
 
38
#define my_safe_afree(ptr, size, min_length) if (size > min_length) free(ptr)
39
39
#endif
40
40
 
41
41
 
239
239
  bool transactional_table, joins_freed= false;
240
240
  bool changed;
241
241
  bool was_insert_delayed= (table_list->lock_type ==  TL_WRITE_DELAYED);
242
 
  uint value_count;
 
242
  uint32_t value_count;
243
243
  ulong counter = 1;
244
244
  uint64_t id;
245
245
  COPY_INFO info;
351
351
  thd->cuted_fields = 0L;
352
352
  table->next_number_field=table->found_next_number_field;
353
353
 
354
 
#ifdef HAVE_REPLICATION
355
354
  if (thd->slave_thread &&
356
355
      (info.handle_duplicates == DUP_UPDATE) &&
357
356
      (table->next_number_field != NULL) &&
358
357
      rpl_master_has_bug(&active_mi->rli, 24432))
359
358
    goto abort;
360
 
#endif
361
359
 
362
360
  error=0;
363
361
  thd_proc_info(thd, "update");
745
743
      update_non_unique_table_error(table_list, "INSERT", duplicate);
746
744
      return(true);
747
745
    }
748
 
    select_lex->first_execution= 0;
749
746
  }
750
747
  if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
751
748
    table->prepare_for_position();
755
752
 
756
753
        /* Check if there is more uniq keys after field */
757
754
 
758
 
static int last_uniq_key(Table *table,uint keynr)
 
755
static int last_uniq_key(Table *table,uint32_t keynr)
759
756
{
760
757
  while (++keynr < table->s->keys)
761
758
    if (table->key_info[keynr].flags & HA_NOSAME)
809
806
  {
810
807
    while ((error=table->file->ha_write_row(table->record[0])))
811
808
    {
812
 
      uint key_nr;
 
809
      uint32_t key_nr;
813
810
      /*
814
811
        If we do more than one iteration of this loop, from the second one the
815
812
        row will have an explicit value in the autoinc field, which was set at
875
872
            goto err;
876
873
          }
877
874
        }
878
 
        key_copy((uchar*) key,table->record[0],table->key_info+key_nr,0);
 
875
        key_copy((unsigned char*) key,table->record[0],table->key_info+key_nr,0);
879
876
        if ((error=(table->file->index_read_idx_map(table->record[1],key_nr,
880
 
                                                    (uchar*) key, HA_WHOLE_KEY,
 
877
                                                    (unsigned char*) key, HA_WHOLE_KEY,
881
878
                                                    HA_READ_KEY_EXACT))))
882
879
          goto err;
883
880
      }
1221
1218
      while ((item= li++))
1222
1219
      {
1223
1220
        item->transform(&Item::update_value_transformer,
1224
 
                        (uchar*)lex->current_select);
 
1221
                        (unsigned char*)lex->current_select);
1225
1222
      }
1226
1223
    }
1227
1224
 
1264
1261
  restore_record(table,s->default_values);              // Get empty record
1265
1262
  table->next_number_field=table->found_next_number_field;
1266
1263
 
1267
 
#ifdef HAVE_REPLICATION
1268
1264
  if (thd->slave_thread &&
1269
1265
      (info.handle_duplicates == DUP_UPDATE) &&
1270
1266
      (table->next_number_field != NULL) &&
1271
1267
      rpl_master_has_bug(&active_mi->rli, 24432))
1272
1268
    return(1);
1273
 
#endif
1274
1269
 
1275
1270
  thd->cuted_fields=0;
1276
1271
  if (info.ignore || info.handle_duplicates != DUP_ERROR)
1394
1389
    fill_record(thd, table->field, values, 1);
1395
1390
}
1396
1391
 
1397
 
void select_insert::send_error(uint errcode,const char *err)
 
1392
void select_insert::send_error(uint32_t errcode,const char *err)
1398
1393
{
1399
1394
  
1400
1395
 
1573
1568
  Table tmp_table;              // Used during 'Create_field()'
1574
1569
  TABLE_SHARE share;
1575
1570
  Table *table= 0;
1576
 
  uint select_field_count= items->elements;
 
1571
  uint32_t select_field_count= items->elements;
1577
1572
  /* Add selected items to field list */
1578
1573
  List_iterator_fast<Item> it(*items);
1579
1574
  Item *item;
1670
1665
 
1671
1666
      if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
1672
1667
      {
1673
 
        VOID(pthread_mutex_lock(&LOCK_open));
 
1668
        pthread_mutex_lock(&LOCK_open);
1674
1669
        if (reopen_name_locked_table(thd, create_table, false))
1675
1670
        {
1676
1671
          quick_rm_table(create_info->db_type, create_table->db,
1679
1674
        }
1680
1675
        else
1681
1676
          table= create_table->table;
1682
 
        VOID(pthread_mutex_unlock(&LOCK_open));
 
1677
        pthread_mutex_unlock(&LOCK_open);
1683
1678
      }
1684
1679
      else
1685
1680
      {
1756
1751
      }
1757
1752
 
1758
1753
  private:
1759
 
    virtual int do_postlock(Table **tables, uint count)
 
1754
    virtual int do_postlock(Table **tables, uint32_t count)
1760
1755
    {
1761
1756
      THD *thd= const_cast<THD*>(ptr->get_thd());
1762
1757
      if (int error= decide_logging_format(thd, &all_tables))
1844
1839
}
1845
1840
 
1846
1841
void
1847
 
select_create::binlog_show_create_table(Table **tables, uint count)
 
1842
select_create::binlog_show_create_table(Table **tables, uint32_t count)
1848
1843
{
1849
1844
  /*
1850
1845
    Note 1: In RBR mode, we generate a CREATE TABLE statement for the
1890
1885
}
1891
1886
 
1892
1887
 
1893
 
void select_create::send_error(uint errcode,const char *err)
 
1888
void select_create::send_error(uint32_t errcode,const char *err)
1894
1889
{
1895
1890
  
1896
1891