~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Mark Atwood
  • Date: 2011-08-17 19:14:47 UTC
  • mfrom: (2385.3.17 rf)
  • Revision ID: me@mark.atwood.name-20110817191447-h86yzddvycd0xmof
mergeĀ lp:~olafvdspek/drizzle/refactor6

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
#include <drizzled/plugin/transactional_storage_engine.h>
55
55
#include <drizzled/probes.h>
56
56
#include <drizzled/pthread_globals.h>
57
 
#include <drizzled/query_id.h>
58
57
#include <drizzled/schema.h>
59
58
#include <drizzled/select_dump.h>
60
59
#include <drizzled/select_exists_subselect.h>
254
253
  originating_commit_id= 0;
255
254
  cleanup_done= abort_on_warning= no_warnings_for_error= false;
256
255
 
257
 
  /* query_cache init */
258
 
  query_cache_key= "";
259
256
  resultset= NULL;
260
257
 
261
258
  /* Variables with default values */
524
521
  setCurrentSession(this);
525
522
  setCurrentMemRoot(&mem);
526
523
 
527
 
  mysys_var= my_thread_var;
 
524
  mysys_var= internal::my_thread_var();
528
525
 
529
526
  /*
530
527
    Let mysqld define the thread id (not mysys)
1064
1061
  /* Check if there is any blobs in data */
1065
1062
  {
1066
1063
    List<Item>::iterator li(list.begin());
1067
 
    Item *item;
1068
 
    while ((item=li++))
 
1064
    while (Item* item= li++)
1069
1065
    {
1070
1066
      if (item->max_length >= MAX_BLOB_WIDTH)
1071
1067
      {
1121
1117
    return false;
1122
1118
  }
1123
1119
  row_count++;
1124
 
  Item *item;
1125
1120
  uint32_t used_length=0,items_left=items.size();
1126
1121
  List<Item>::iterator li(items.begin());
1127
1122
 
1128
 
  if (my_b_write(cache,(unsigned char*) exchange->line_start->ptr(),
1129
 
                 exchange->line_start->length()))
 
1123
  if (cache->write(exchange->line_start->ptr(), exchange->line_start->length()))
1130
1124
    return true;
1131
1125
 
1132
 
  while ((item=li++))
 
1126
  while (Item* item=li++)
1133
1127
  {
1134
1128
    Item_result result_type=item->result_type();
1135
1129
    bool enclosed = (exchange->enclosed->length() &&
1137
1131
    res=item->str_result(&tmp);
1138
1132
    if (res && enclosed)
1139
1133
    {
1140
 
      if (my_b_write(cache,(unsigned char*) exchange->enclosed->ptr(),
1141
 
                     exchange->enclosed->length()))
 
1134
      if (cache->write(exchange->enclosed->ptr(), exchange->enclosed->length()))
1142
1135
        return true;
1143
1136
    }
1144
1137
    if (!res)
1149
1142
        {
1150
1143
          null_buff[0]=escape_char;
1151
1144
          null_buff[1]='N';
1152
 
          if (my_b_write(cache,(unsigned char*) null_buff,2))
 
1145
          if (cache->write(null_buff, 2))
1153
1146
            return true;
1154
1147
        }
1155
 
        else if (my_b_write(cache,(unsigned char*) "NULL",4))
 
1148
        else if (cache->write("NULL", 4))
1156
1149
          return true;
1157
1150
      }
1158
1151
      else
1242
1235
                          is_ambiguous_field_sep) ?
1243
1236
              field_sep_char : escape_char;
1244
1237
            tmp_buff[1]= *pos ? *pos : '0';
1245
 
            if (my_b_write(cache,(unsigned char*) start,(uint32_t) (pos-start)) ||
1246
 
                my_b_write(cache,(unsigned char*) tmp_buff,2))
 
1238
            if (cache->write(start, pos - start) || cache->write(tmp_buff, 2))
1247
1239
              return true;
1248
1240
            start=pos+1;
1249
1241
          }
1250
1242
        }
1251
 
        if (my_b_write(cache,(unsigned char*) start,(uint32_t) (pos-start)))
 
1243
        if (cache->write(start, pos - start))
1252
1244
          return true;
1253
1245
      }
1254
 
      else if (my_b_write(cache,(unsigned char*) res->ptr(),used_length))
 
1246
      else if (cache->write(res->ptr(), used_length))
1255
1247
        return true;
1256
1248
    }
1257
1249
    if (fixed_row_size)
1267
1259
        uint32_t length=item->max_length-used_length;
1268
1260
        for (; length > sizeof(space) ; length-=sizeof(space))
1269
1261
        {
1270
 
          if (my_b_write(cache,(unsigned char*) space,sizeof(space)))
 
1262
          if (cache->write(space, sizeof(space)))
1271
1263
            return true;
1272
1264
        }
1273
 
        if (my_b_write(cache,(unsigned char*) space,length))
 
1265
        if (cache->write(space, length))
1274
1266
          return true;
1275
1267
      }
1276
1268
    }
1277
1269
    if (res && enclosed)
1278
1270
    {
1279
 
      if (my_b_write(cache, (unsigned char*) exchange->enclosed->ptr(),
1280
 
                     exchange->enclosed->length()))
 
1271
      if (cache->write(exchange->enclosed->ptr(), exchange->enclosed->length()))
1281
1272
        return true;
1282
1273
    }
1283
1274
    if (--items_left)
1284
1275
    {
1285
 
      if (my_b_write(cache, (unsigned char*) exchange->field_term->ptr(),
1286
 
                     field_term_length))
 
1276
      if (cache->write(exchange->field_term->ptr(), field_term_length))
1287
1277
        return true;
1288
1278
    }
1289
1279
  }
1290
 
  if (my_b_write(cache,(unsigned char*) exchange->line_term->ptr(),
1291
 
                 exchange->line_term->length()))
 
1280
  if (cache->write(exchange->line_term->ptr(), exchange->line_term->length()))
1292
1281
  {
1293
1282
    return true;
1294
1283
  }
1332
1321
    res=item->str_result(&tmp);
1333
1322
    if (!res)                                   // If NULL
1334
1323
    {
1335
 
      if (my_b_write(cache,(unsigned char*) "",1))
 
1324
      if (cache->write("", 1))
1336
1325
        return 1;
1337
1326
    }
1338
 
    else if (my_b_write(cache,(unsigned char*) res->ptr(),res->length()))
 
1327
    else if (cache->write(res->ptr(), res->length()))
1339
1328
    {
1340
1329
      my_error(ER_ERROR_ON_WRITE, MYF(0), path.file_string().c_str(), errno);
1341
1330
      return 1;
1503
1492
{
1504
1493
  /* Cleanup SQL processing state to reuse this statement in next query. */
1505
1494
  lex().end();
1506
 
  query_cache_key= ""; // reset the cache key
1507
1495
  resetResultsetMessage();
1508
1496
}
1509
1497
 
1532
1520
  precomputed_group_by= 0;
1533
1521
}
1534
1522
 
1535
 
void Tmp_Table_Param::cleanup(void)
 
1523
void Tmp_Table_Param::cleanup()
1536
1524
{
1537
1525
  /* Fix for Intel compiler */
1538
1526
  if (copy_field)