~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_class.cc

  • Committer: Lee
  • Date: 2008-10-03 23:31:06 UTC
  • mfrom: (413.2.3 drizzle)
  • mto: This revision was merged to the branch mainline in revision 459.
  • Revision ID: lbieber@lbieber-desktop-20081003233106-tgvzu0fh25gb3xeg
breaking out enum field classes

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <mysys/thr_alarm.h>
29
29
#include <mysys/mysys_err.h>
30
30
#include <drizzled/drizzled_error_messages.h>
31
 
#include <drizzled/innodb_plugin_extras.h>
32
31
 
33
32
/*
34
33
  The following is used to initialise Table_ident with a internal
60
59
** User variables
61
60
****************************************************************************/
62
61
 
63
 
extern "C" unsigned char *get_var_key(user_var_entry *entry, size_t *length,
 
62
extern "C" uchar *get_var_key(user_var_entry *entry, size_t *length,
64
63
                              bool not_used __attribute__((unused)))
65
64
{
66
65
  *length= entry->name.length;
67
 
  return (unsigned char*) entry->name.str;
 
66
  return (uchar*) entry->name.str;
68
67
}
69
68
 
70
69
extern "C" void free_user_var(user_var_entry *entry)
71
70
{
72
71
  char *pos= (char*) entry+ALIGN_SIZE(sizeof(*entry));
73
72
  if (entry->value && entry->value != pos)
74
 
    free(entry->value);
75
 
  free((char*) entry);
 
73
    my_free(entry->value, MYF(0));
 
74
  my_free((char*) entry,MYF(0));
76
75
}
77
76
 
78
77
bool Key_part_spec::operator==(const Key_part_spec& other) const
184
183
}
185
184
 
186
185
 
187
 
/*
188
 
  Check if the foreign key options are compatible with columns
189
 
  on which the FK is created.
190
 
 
191
 
  RETURN
192
 
    0   Key valid
193
 
    1   Key invalid
194
 
*/
195
 
bool Foreign_key::validate(List<Create_field> &table_fields)
196
 
{
197
 
  Create_field  *sql_field;
198
 
  Key_part_spec *column;
199
 
  List_iterator<Key_part_spec> cols(columns);
200
 
  List_iterator<Create_field> it(table_fields);
201
 
  while ((column= cols++))
202
 
  {
203
 
    it.rewind();
204
 
    while ((sql_field= it++) &&
205
 
           my_strcasecmp(system_charset_info,
206
 
                         column->field_name.str,
207
 
                         sql_field->field_name)) {}
208
 
    if (!sql_field)
209
 
    {
210
 
      my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
211
 
      return true;
212
 
    }
213
 
    if (type == Key::FOREIGN_KEY && sql_field->vcol_info)
214
 
    {
215
 
      if (delete_opt == FK_OPTION_SET_NULL)
216
 
      {
217
 
        my_error(ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN, MYF(0), 
218
 
                 "ON DELETE SET NULL");
219
 
        return true;
220
 
      }
221
 
      if (update_opt == FK_OPTION_SET_NULL)
222
 
      {
223
 
        my_error(ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN, MYF(0), 
224
 
                 "ON UPDATE SET NULL");
225
 
        return true;
226
 
      }
227
 
      if (update_opt == FK_OPTION_CASCADE)
228
 
      {
229
 
        my_error(ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN, MYF(0), 
230
 
                 "ON UPDATE CASCADE");
231
 
        return true;
232
 
      }
233
 
    }
234
 
  }
235
 
  return false;
236
 
}
237
 
 
238
 
 
239
186
/****************************************************************************
240
187
** Thread specific functions
241
188
****************************************************************************/
254
201
{
255
202
  char filename[FN_REFLEN];
256
203
  File fd = create_temp_file(filename, mysql_tmpdir, prefix,
257
 
                             O_CREAT | O_EXCL | O_RDWR,
 
204
                             O_CREAT | O_EXCL | O_RDWR | O_TEMPORARY,
258
205
                             MYF(MY_WME));
259
206
  if (fd >= 0) {
 
207
    /*
 
208
      This can be removed once the following bug is fixed:
 
209
      Bug #28903  create_temp_file() doesn't honor O_TEMPORARY option
 
210
                  (file not removed) (Unix)
 
211
    */
260
212
    unlink(filename);
261
213
  }
262
214
 
278
230
}
279
231
 
280
232
 
281
 
/**
282
 
   Set the process info field of the THD structure.
283
 
 
284
 
   This function is used by plug-ins. Internally, the
285
 
   THD::set_proc_info() function should be used.
286
 
 
287
 
   @see THD::set_proc_info
288
 
 */
289
 
extern "C" void
290
 
set_thd_proc_info(THD *thd, const char *info)
 
233
extern "C"
 
234
const char *set_thd_proc_info(THD *thd, const char *info,
 
235
                              const char *calling_function __attribute__((unused)),
 
236
                              const char *calling_file __attribute__((unused)),
 
237
                              const unsigned int calling_line __attribute__((unused)))
291
238
{
 
239
  const char *old_info= thd->get_proc_info();
292
240
  thd->set_proc_info(info);
293
 
}
294
 
 
295
 
extern "C"
296
 
const char *get_thd_proc_info(THD *thd)
297
 
{
298
 
  return thd->get_proc_info();
 
241
  return old_info;
299
242
}
300
243
 
301
244
extern "C"
416
359
 
417
360
void
418
361
Diagnostics_area::set_error_status(THD *thd __attribute__((unused)),
419
 
                                   uint32_t sql_errno_arg,
 
362
                                   uint sql_errno_arg,
420
363
                                   const char *message_arg)
421
364
{
422
365
  /*
460
403
              /* statement id */ 0),
461
404
   Open_tables_state(refresh_version), rli_fake(0),
462
405
   lock_id(&main_lock_id),
463
 
   user_time(0),
 
406
   user_time(0), in_sub_stmt(0),
464
407
   binlog_table_maps(0), binlog_flags(0UL),
465
408
   arg_of_last_insert_id_function(false),
466
409
   first_successful_insert_id_in_prev_stmt(0),
474
417
   rand_used(0),
475
418
   time_zone_used(0),
476
419
   in_lock_tables(0),
 
420
   bootstrap(0),
477
421
   derived_tables_processing(false),
478
422
   m_lip(NULL)
479
423
{
519
463
  memset(ha_data, 0, sizeof(ha_data));
520
464
  mysys_var=0;
521
465
  binlog_evt_union.do_union= false;
 
466
  enable_slow_log= 0;
522
467
  dbug_sentry=THD_SENTRY_MAGIC;
523
468
  net.vio=0;
524
469
  client_capabilities= 0;                       // minimalistic client
578
523
}
579
524
 
580
525
 
581
 
bool THD::handle_error(uint32_t sql_errno, const char *message,
 
526
bool THD::handle_error(uint sql_errno, const char *message,
582
527
                       DRIZZLE_ERROR::enum_warning_level level)
583
528
{
584
529
  if (m_internal_handler)
732
677
  delete_dynamic(&user_var_events);
733
678
  hash_free(&user_vars);
734
679
  close_temporary_tables(this);
735
 
  free((char*) variables.time_format);
736
 
  free((char*) variables.date_format);
737
 
  free((char*) variables.datetime_format);
 
680
  my_free((char*) variables.time_format, MYF(MY_ALLOW_ZERO_PTR));
 
681
  my_free((char*) variables.date_format, MYF(MY_ALLOW_ZERO_PTR));
 
682
  my_free((char*) variables.datetime_format, MYF(MY_ALLOW_ZERO_PTR));
738
683
  
739
684
  if (global_read_lock)
740
685
    unlock_global_read_lock(this);
764
709
  plugin_thdvar_cleanup(this);
765
710
 
766
711
  main_security_ctx.destroy();
767
 
  if (db)
768
 
  {
769
 
    free(db);
770
 
    db= NULL;
771
 
  }
 
712
  safeFree(db);
772
713
  free_root(&warn_root,MYF(0));
773
714
  free_root(&transaction.mem_root,MYF(0));
774
715
  mysys_var=0;                                  // Safety (shouldn't be needed)
801
742
 
802
743
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
803
744
{
804
 
  ulong *end= (ulong*) ((unsigned char*) to_var +
 
745
  ulong *end= (ulong*) ((uchar*) to_var +
805
746
                        offsetof(STATUS_VAR, last_system_status_var) +
806
747
                        sizeof(ulong));
807
748
  ulong *to= (ulong*) to_var, *from= (ulong*) from_var;
826
767
void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
827
768
                        STATUS_VAR *dec_var)
828
769
{
829
 
  ulong *end= (ulong*) ((unsigned char*) to_var + offsetof(STATUS_VAR,
 
770
  ulong *end= (ulong*) ((uchar*) to_var + offsetof(STATUS_VAR,
830
771
                                                  last_system_status_var) +
831
772
                        sizeof(ulong));
832
773
  ulong *to= (ulong*) to_var, *from= (ulong*) from_var, *dec= (ulong*) dec_var;
937
878
  /*
938
879
    Reset rand_used so that detection of calls to rand() will save random 
939
880
    seeds if needed by the slave.
 
881
 
 
882
    Do not reset rand_used if inside a stored function or trigger because 
 
883
    only the call to these operations is logged. Thus only the calling 
 
884
    statement needs to detect rand() calls made by its substatements. These
 
885
    substatements must not set rand_used to 0 because it would remove the
 
886
    detection of rand() by the calling statement. 
940
887
  */
 
888
  if (!in_sub_stmt) /* stored functions and triggers are a special case */
941
889
  {
942
890
    /* Forget those values, for next binlogger: */
943
891
    stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0;
971
919
  @return  NULL on failure, or pointer to the LEX_STRING object
972
920
*/
973
921
LEX_STRING *THD::make_lex_string(LEX_STRING *lex_str,
974
 
                                 const char* str, uint32_t length,
 
922
                                 const char* str, uint length,
975
923
                                 bool allocate_lex_string)
976
924
{
977
925
  if (allocate_lex_string)
1005
953
*/
1006
954
 
1007
955
bool THD::convert_string(LEX_STRING *to, const CHARSET_INFO * const to_cs,
1008
 
                         const char *from, uint32_t from_length,
 
956
                         const char *from, uint from_length,
1009
957
                         const CHARSET_INFO * const from_cs)
1010
958
{
1011
959
  size_t new_length= to_cs->mbmaxlen * from_length;
1012
 
  uint32_t dummy_errors;
 
960
  uint dummy_errors;
1013
961
  if (!(to->str= (char*) alloc(new_length+1)))
1014
962
  {
1015
963
    to->length= 0;                              // Safety fix
1040
988
bool THD::convert_string(String *s, const CHARSET_INFO * const from_cs,
1041
989
                         const CHARSET_INFO * const to_cs)
1042
990
{
1043
 
  uint32_t dummy_errors;
 
991
  uint dummy_errors;
1044
992
  if (convert_buffer.copy(s->ptr(), s->length(), from_cs, to_cs, &dummy_errors))
1045
993
    return true;
1046
994
  /* If convert_buffer >> s copying is more efficient long term */
1261
1209
  thd=current_thd;
1262
1210
}
1263
1211
 
1264
 
void select_result::send_error(uint32_t errcode,const char *err)
 
1212
void select_result::send_error(uint errcode,const char *err)
1265
1213
{
1266
1214
  my_message(errcode, err, MYF(0));
1267
1215
}
1295
1243
  cs= NULL;
1296
1244
}
1297
1245
 
1298
 
bool select_send::send_fields(List<Item> &list, uint32_t flags)
 
1246
bool select_send::send_fields(List<Item> &list, uint flags)
1299
1247
{
1300
1248
  bool res;
1301
1249
  if (!(res= thd->protocol->send_fields(&list, flags)))
1389
1337
  Handling writing to file
1390
1338
************************************************************************/
1391
1339
 
1392
 
void select_to_file::send_error(uint32_t errcode,const char *err)
 
1340
void select_to_file::send_error(uint errcode,const char *err)
1393
1341
{
1394
1342
  my_message(errcode, err, MYF(0));
1395
1343
  if (file > 0)
1475
1423
                        IO_CACHE *cache)
1476
1424
{
1477
1425
  File file;
1478
 
  uint32_t option= MY_UNPACK_FILENAME | MY_RELATIVE_PATH;
 
1426
  uint option= MY_UNPACK_FILENAME | MY_RELATIVE_PATH;
1479
1427
 
1480
1428
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
1481
1429
  option|= MY_REPLACE_DIR;                      // Force use of db directory
1484
1432
  if (!dirname_length(exchange->file_name))
1485
1433
  {
1486
1434
    strxnmov(path, FN_REFLEN-1, mysql_real_data_home, thd->db ? thd->db : "",
1487
 
             NULL);
 
1435
             NullS);
1488
1436
    (void) fn_format(path, exchange->file_name, path, "", option);
1489
1437
  }
1490
1438
  else
1551
1499
  }
1552
1500
  field_term_length=exchange->field_term->length();
1553
1501
  field_term_char= field_term_length ?
1554
 
                   (int) (unsigned char) (*exchange->field_term)[0] : INT_MAX;
 
1502
                   (int) (uchar) (*exchange->field_term)[0] : INT_MAX;
1555
1503
  if (!exchange->line_term->length())
1556
1504
    exchange->line_term=exchange->field_term;   // Use this if it exists
1557
1505
  field_sep_char= (exchange->enclosed->length() ?
1558
 
                  (int) (unsigned char) (*exchange->enclosed)[0] : field_term_char);
 
1506
                  (int) (uchar) (*exchange->enclosed)[0] : field_term_char);
1559
1507
  escape_char=  (exchange->escaped->length() ?
1560
 
                (int) (unsigned char) (*exchange->escaped)[0] : -1);
 
1508
                (int) (uchar) (*exchange->escaped)[0] : -1);
1561
1509
  is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char));
1562
1510
  is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char));
1563
1511
  line_sep_char= (exchange->line_term->length() ?
1564
 
                 (int) (unsigned char) (*exchange->line_term)[0] : INT_MAX);
 
1512
                 (int) (uchar) (*exchange->line_term)[0] : INT_MAX);
1565
1513
  if (!field_term_length)
1566
1514
    exchange->opt_enclosed=0;
1567
1515
  if (!exchange->enclosed->length())
1584
1532
}
1585
1533
 
1586
1534
 
1587
 
#define NEED_ESCAPING(x) ((int) (unsigned char) (x) == escape_char    || \
1588
 
                          (enclosed ? (int) (unsigned char) (x) == field_sep_char      \
1589
 
                                    : (int) (unsigned char) (x) == field_term_char) || \
1590
 
                          (int) (unsigned char) (x) == line_sep_char  || \
 
1535
#define NEED_ESCAPING(x) ((int) (uchar) (x) == escape_char    || \
 
1536
                          (enclosed ? (int) (uchar) (x) == field_sep_char      \
 
1537
                                    : (int) (uchar) (x) == field_term_char) || \
 
1538
                          (int) (uchar) (x) == line_sep_char  || \
1591
1539
                          !(x))
1592
1540
 
1593
1541
bool select_export::send_data(List<Item> &items)
1604
1552
  }
1605
1553
  row_count++;
1606
1554
  Item *item;
1607
 
  uint32_t used_length=0,items_left=items.elements;
 
1555
  uint used_length=0,items_left=items.elements;
1608
1556
  List_iterator_fast<Item> li(items);
1609
1557
 
1610
 
  if (my_b_write(&cache,(unsigned char*) exchange->line_start->ptr(),
 
1558
  if (my_b_write(&cache,(uchar*) exchange->line_start->ptr(),
1611
1559
                 exchange->line_start->length()))
1612
1560
    goto err;
1613
1561
  while ((item=li++))
1618
1566
    res=item->str_result(&tmp);
1619
1567
    if (res && enclosed)
1620
1568
    {
1621
 
      if (my_b_write(&cache,(unsigned char*) exchange->enclosed->ptr(),
 
1569
      if (my_b_write(&cache,(uchar*) exchange->enclosed->ptr(),
1622
1570
                     exchange->enclosed->length()))
1623
1571
        goto err;
1624
1572
    }
1630
1578
        {
1631
1579
          null_buff[0]=escape_char;
1632
1580
          null_buff[1]='N';
1633
 
          if (my_b_write(&cache,(unsigned char*) null_buff,2))
 
1581
          if (my_b_write(&cache,(uchar*) null_buff,2))
1634
1582
            goto err;
1635
1583
        }
1636
 
        else if (my_b_write(&cache,(unsigned char*) "NULL",4))
 
1584
        else if (my_b_write(&cache,(uchar*) "NULL",4))
1637
1585
          goto err;
1638
1586
      }
1639
1587
      else
1709
1657
 
1710
1658
          if ((NEED_ESCAPING(*pos) ||
1711
1659
               (check_second_byte &&
1712
 
                my_mbcharlen(character_set_client, (unsigned char) *pos) == 2 &&
 
1660
                my_mbcharlen(character_set_client, (uchar) *pos) == 2 &&
1713
1661
                pos + 1 < end &&
1714
1662
                NEED_ESCAPING(pos[1]))) &&
1715
1663
              /*
1717
1665
               valid for ENCLOSED BY characters:
1718
1666
              */
1719
1667
              (enclosed || !is_ambiguous_field_term ||
1720
 
               (int) (unsigned char) *pos != field_term_char))
 
1668
               (int) (uchar) *pos != field_term_char))
1721
1669
          {
1722
1670
            char tmp_buff[2];
1723
 
            tmp_buff[0]= ((int) (unsigned char) *pos == field_sep_char &&
 
1671
            tmp_buff[0]= ((int) (uchar) *pos == field_sep_char &&
1724
1672
                          is_ambiguous_field_sep) ?
1725
1673
                          field_sep_char : escape_char;
1726
1674
            tmp_buff[1]= *pos ? *pos : '0';
1727
 
            if (my_b_write(&cache,(unsigned char*) start,(uint) (pos-start)) ||
1728
 
                my_b_write(&cache,(unsigned char*) tmp_buff,2))
 
1675
            if (my_b_write(&cache,(uchar*) start,(uint) (pos-start)) ||
 
1676
                my_b_write(&cache,(uchar*) tmp_buff,2))
1729
1677
              goto err;
1730
1678
            start=pos+1;
1731
1679
          }
1732
1680
        }
1733
 
        if (my_b_write(&cache,(unsigned char*) start,(uint) (pos-start)))
 
1681
        if (my_b_write(&cache,(uchar*) start,(uint) (pos-start)))
1734
1682
          goto err;
1735
1683
      }
1736
 
      else if (my_b_write(&cache,(unsigned char*) res->ptr(),used_length))
 
1684
      else if (my_b_write(&cache,(uchar*) res->ptr(),used_length))
1737
1685
        goto err;
1738
1686
    }
1739
1687
    if (fixed_row_size)
1746
1694
          space_inited=1;
1747
1695
          memset(space, ' ', sizeof(space));
1748
1696
        }
1749
 
        uint32_t length=item->max_length-used_length;
 
1697
        uint length=item->max_length-used_length;
1750
1698
        for (; length > sizeof(space) ; length-=sizeof(space))
1751
1699
        {
1752
 
          if (my_b_write(&cache,(unsigned char*) space,sizeof(space)))
 
1700
          if (my_b_write(&cache,(uchar*) space,sizeof(space)))
1753
1701
            goto err;
1754
1702
        }
1755
 
        if (my_b_write(&cache,(unsigned char*) space,length))
 
1703
        if (my_b_write(&cache,(uchar*) space,length))
1756
1704
          goto err;
1757
1705
      }
1758
1706
    }
1759
1707
    if (res && enclosed)
1760
1708
    {
1761
 
      if (my_b_write(&cache, (unsigned char*) exchange->enclosed->ptr(),
 
1709
      if (my_b_write(&cache, (uchar*) exchange->enclosed->ptr(),
1762
1710
                     exchange->enclosed->length()))
1763
1711
        goto err;
1764
1712
    }
1765
1713
    if (--items_left)
1766
1714
    {
1767
 
      if (my_b_write(&cache, (unsigned char*) exchange->field_term->ptr(),
 
1715
      if (my_b_write(&cache, (uchar*) exchange->field_term->ptr(),
1768
1716
                     field_term_length))
1769
1717
        goto err;
1770
1718
    }
1771
1719
  }
1772
 
  if (my_b_write(&cache,(unsigned char*) exchange->line_term->ptr(),
 
1720
  if (my_b_write(&cache,(uchar*) exchange->line_term->ptr(),
1773
1721
                 exchange->line_term->length()))
1774
1722
    goto err;
1775
1723
  return(0);
1815
1763
    res=item->str_result(&tmp);
1816
1764
    if (!res)                                   // If NULL
1817
1765
    {
1818
 
      if (my_b_write(&cache,(unsigned char*) "",1))
 
1766
      if (my_b_write(&cache,(uchar*) "",1))
1819
1767
        goto err;
1820
1768
    }
1821
 
    else if (my_b_write(&cache,(unsigned char*) res->ptr(),res->length()))
 
1769
    else if (my_b_write(&cache,(uchar*) res->ptr(),res->length()))
1822
1770
    {
1823
1771
      my_error(ER_ERROR_ON_WRITE, MYF(0), path, my_errno);
1824
1772
      goto err;
1851
1799
  }
1852
1800
  List_iterator_fast<Item> li(items);
1853
1801
  Item *val_item;
1854
 
  for (uint32_t i= 0; (val_item= li++); i++)
 
1802
  for (uint i= 0; (val_item= li++); i++)
1855
1803
    it->store(i, val_item);
1856
1804
  it->assigned(1);
1857
1805
  return(0);
2171
2119
void Security_context::destroy()
2172
2120
{
2173
2121
  // If not pointer to constant
2174
 
  if (user)
2175
 
  {
2176
 
    free(user);
2177
 
    user= NULL;
2178
 
  }
2179
 
  if (ip)
2180
 
  {
2181
 
    free(ip);
2182
 
    ip= NULL;
2183
 
  }
 
2122
  safeFree(user);
 
2123
  safeFree(ip);
2184
2124
}
2185
2125
 
2186
2126
 
2297
2237
pthread_mutex_t LOCK_xid_cache;
2298
2238
HASH xid_cache;
2299
2239
 
2300
 
extern "C" unsigned char *xid_get_hash_key(const unsigned char *, size_t *, bool);
 
2240
extern "C" uchar *xid_get_hash_key(const uchar *, size_t *, bool);
2301
2241
extern "C" void xid_free_hash(void *);
2302
2242
 
2303
 
unsigned char *xid_get_hash_key(const unsigned char *ptr, size_t *length,
 
2243
uchar *xid_get_hash_key(const uchar *ptr, size_t *length,
2304
2244
                        bool not_used __attribute__((unused)))
2305
2245
{
2306
2246
  *length=((XID_STATE*)ptr)->xid.key_length();
2310
2250
void xid_free_hash(void *ptr)
2311
2251
{
2312
2252
  if (!((XID_STATE*)ptr)->in_thd)
2313
 
    free((unsigned char*)ptr);
 
2253
    my_free((uchar*)ptr, MYF(0));
2314
2254
}
2315
2255
 
2316
2256
bool xid_cache_init()
2352
2292
    xs->xa_state=xa_state;
2353
2293
    xs->xid.set(xid);
2354
2294
    xs->in_thd=0;
2355
 
    res=my_hash_insert(&xid_cache, (unsigned char*)xs);
 
2295
    res=my_hash_insert(&xid_cache, (uchar*)xs);
2356
2296
  }
2357
2297
  pthread_mutex_unlock(&LOCK_xid_cache);
2358
2298
  return res;
2364
2304
  pthread_mutex_lock(&LOCK_xid_cache);
2365
2305
  assert(hash_search(&xid_cache, xid_state->xid.key(),
2366
2306
                          xid_state->xid.key_length())==0);
2367
 
  bool res=my_hash_insert(&xid_cache, (unsigned char*)xid_state);
 
2307
  bool res=my_hash_insert(&xid_cache, (uchar*)xid_state);
2368
2308
  pthread_mutex_unlock(&LOCK_xid_cache);
2369
2309
  return res;
2370
2310
}
2373
2313
void xid_cache_delete(XID_STATE *xid_state)
2374
2314
{
2375
2315
  pthread_mutex_lock(&LOCK_xid_cache);
2376
 
  hash_delete(&xid_cache, (unsigned char *)xid_state);
 
2316
  hash_delete(&xid_cache, (uchar *)xid_state);
2377
2317
  pthread_mutex_unlock(&LOCK_xid_cache);
2378
2318
}
2379
2319
 
2383
2323
  inserted/updated/deleted.
2384
2324
*/
2385
2325
 
 
2326
#ifndef DRIZZLE_CLIENT
2386
2327
 
2387
2328
/*
2388
2329
  Template member function for ensuring that there is an rows log
2543
2484
    ~Row_data_memory()
2544
2485
    {
2545
2486
      if (m_memory != 0 && m_release_memory_on_destruction)
2546
 
        free((unsigned char*) m_memory);
 
2487
        my_free((uchar*) m_memory, MYF(MY_WME));
2547
2488
    }
2548
2489
 
2549
2490
    /**
2557
2498
      return m_memory != 0;
2558
2499
    }
2559
2500
 
2560
 
    unsigned char *slot(uint32_t s)
 
2501
    uchar *slot(uint s)
2561
2502
    {
2562
2503
      assert(s < sizeof(m_ptr)/sizeof(*m_ptr));
2563
2504
      assert(m_ptr[s] != 0);
2589
2530
        */
2590
2531
        if (table->write_row_record == 0)
2591
2532
          table->write_row_record=
2592
 
            (unsigned char *) alloc_root(&table->mem_root, 2 * maxlen);
 
2533
            (uchar *) alloc_root(&table->mem_root, 2 * maxlen);
2593
2534
        m_memory= table->write_row_record;
2594
2535
        m_release_memory_on_destruction= false;
2595
2536
      }
2596
2537
      else
2597
2538
      {
2598
 
        m_memory= (unsigned char *) my_malloc(total_length, MYF(MY_WME));
 
2539
        m_memory= (uchar *) my_malloc(total_length, MYF(MY_WME));
2599
2540
        m_release_memory_on_destruction= true;
2600
2541
      }
2601
2542
    }
2602
2543
 
2603
2544
    mutable bool m_alloc_checked;
2604
2545
    bool m_release_memory_on_destruction;
2605
 
    unsigned char *m_memory;
2606
 
    unsigned char *m_ptr[2];
 
2546
    uchar *m_memory;
 
2547
    uchar *m_ptr[2];
2607
2548
  };
2608
2549
}
2609
2550
 
2610
2551
 
2611
2552
int THD::binlog_write_row(Table* table, bool is_trans, 
2612
 
                          unsigned char const *record) 
 
2553
                          uchar const *record) 
2613
2554
2614
2555
  assert(current_stmt_binlog_row_based && mysql_bin_log.is_open());
2615
2556
 
2621
2562
  if (!memory.has_memory())
2622
2563
    return HA_ERR_OUT_OF_MEM;
2623
2564
 
2624
 
  unsigned char *row_data= memory.slot(0);
 
2565
  uchar *row_data= memory.slot(0);
2625
2566
 
2626
2567
  size_t const len= pack_row(table, table->write_set, row_data, record);
2627
2568
 
2636
2577
}
2637
2578
 
2638
2579
int THD::binlog_update_row(Table* table, bool is_trans,
2639
 
                           const unsigned char *before_record,
2640
 
                           const unsigned char *after_record)
 
2580
                           const uchar *before_record,
 
2581
                           const uchar *after_record)
2641
2582
2642
2583
  assert(current_stmt_binlog_row_based && mysql_bin_log.is_open());
2643
2584
 
2648
2589
  if (!row_data.has_memory())
2649
2590
    return HA_ERR_OUT_OF_MEM;
2650
2591
 
2651
 
  unsigned char *before_row= row_data.slot(0);
2652
 
  unsigned char *after_row= row_data.slot(1);
 
2592
  uchar *before_row= row_data.slot(0);
 
2593
  uchar *after_row= row_data.slot(1);
2653
2594
 
2654
2595
  size_t const before_size= pack_row(table, table->read_set, before_row,
2655
2596
                                        before_record);
2670
2611
}
2671
2612
 
2672
2613
int THD::binlog_delete_row(Table* table, bool is_trans, 
2673
 
                           unsigned char const *record)
 
2614
                           uchar const *record)
2674
2615
2675
2616
  assert(current_stmt_binlog_row_based && mysql_bin_log.is_open());
2676
2617
 
2682
2623
  if (unlikely(!memory.has_memory()))
2683
2624
    return HA_ERR_OUT_OF_MEM;
2684
2625
 
2685
 
  unsigned char *row_data= memory.slot(0);
 
2626
  uchar *row_data= memory.slot(0);
2686
2627
 
2687
2628
  size_t const len= pack_row(table, table->read_set, row_data, record);
2688
2629
 
2848
2789
  elements++;
2849
2790
  return(0);
2850
2791
}
 
2792
 
 
2793
#endif /* !defined(DRIZZLE_CLIENT) */