~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Olaf van der Spek
  • Date: 2011-08-14 12:20:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2407.
  • Revision ID: olafvdspek@gmail.com-20110814122036-ydjayvqjgwixp3o8
Refactor iocache

Show diffs side-by-side

added added

removed removed

Lines of Context:
1121
1121
    return false;
1122
1122
  }
1123
1123
  row_count++;
1124
 
  Item *item;
1125
1124
  uint32_t used_length=0,items_left=items.size();
1126
1125
  List<Item>::iterator li(items.begin());
1127
1126
 
1128
 
  if (my_b_write(cache,(unsigned char*) exchange->line_start->ptr(),
1129
 
                 exchange->line_start->length()))
 
1127
  if (cache->write(exchange->line_start->ptr(), exchange->line_start->length()))
1130
1128
    return true;
1131
1129
 
1132
 
  while ((item=li++))
 
1130
  while (Item* item=li++)
1133
1131
  {
1134
1132
    Item_result result_type=item->result_type();
1135
1133
    bool enclosed = (exchange->enclosed->length() &&
1137
1135
    res=item->str_result(&tmp);
1138
1136
    if (res && enclosed)
1139
1137
    {
1140
 
      if (my_b_write(cache,(unsigned char*) exchange->enclosed->ptr(),
1141
 
                     exchange->enclosed->length()))
 
1138
      if (cache->write(exchange->enclosed->ptr(), exchange->enclosed->length()))
1142
1139
        return true;
1143
1140
    }
1144
1141
    if (!res)
1149
1146
        {
1150
1147
          null_buff[0]=escape_char;
1151
1148
          null_buff[1]='N';
1152
 
          if (my_b_write(cache,(unsigned char*) null_buff,2))
 
1149
          if (cache->write(null_buff, 2))
1153
1150
            return true;
1154
1151
        }
1155
 
        else if (my_b_write(cache,(unsigned char*) "NULL",4))
 
1152
        else if (cache->write("NULL", 4))
1156
1153
          return true;
1157
1154
      }
1158
1155
      else
1242
1239
                          is_ambiguous_field_sep) ?
1243
1240
              field_sep_char : escape_char;
1244
1241
            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))
 
1242
            if (cache->write(start, pos - start) || cache->write(tmp_buff, 2))
1247
1243
              return true;
1248
1244
            start=pos+1;
1249
1245
          }
1250
1246
        }
1251
 
        if (my_b_write(cache,(unsigned char*) start,(uint32_t) (pos-start)))
 
1247
        if (cache->write(start, pos - start))
1252
1248
          return true;
1253
1249
      }
1254
 
      else if (my_b_write(cache,(unsigned char*) res->ptr(),used_length))
 
1250
      else if (cache->write(res->ptr(), used_length))
1255
1251
        return true;
1256
1252
    }
1257
1253
    if (fixed_row_size)
1267
1263
        uint32_t length=item->max_length-used_length;
1268
1264
        for (; length > sizeof(space) ; length-=sizeof(space))
1269
1265
        {
1270
 
          if (my_b_write(cache,(unsigned char*) space,sizeof(space)))
 
1266
          if (cache->write(space, sizeof(space)))
1271
1267
            return true;
1272
1268
        }
1273
 
        if (my_b_write(cache,(unsigned char*) space,length))
 
1269
        if (cache->write(space, length))
1274
1270
          return true;
1275
1271
      }
1276
1272
    }
1277
1273
    if (res && enclosed)
1278
1274
    {
1279
 
      if (my_b_write(cache, (unsigned char*) exchange->enclosed->ptr(),
1280
 
                     exchange->enclosed->length()))
 
1275
      if (cache->write(exchange->enclosed->ptr(), exchange->enclosed->length()))
1281
1276
        return true;
1282
1277
    }
1283
1278
    if (--items_left)
1284
1279
    {
1285
 
      if (my_b_write(cache, (unsigned char*) exchange->field_term->ptr(),
1286
 
                     field_term_length))
 
1280
      if (cache->write(exchange->field_term->ptr(), field_term_length))
1287
1281
        return true;
1288
1282
    }
1289
1283
  }
1290
 
  if (my_b_write(cache,(unsigned char*) exchange->line_term->ptr(),
1291
 
                 exchange->line_term->length()))
 
1284
  if (cache->write(exchange->line_term->ptr(), exchange->line_term->length()))
1292
1285
  {
1293
1286
    return true;
1294
1287
  }
1332
1325
    res=item->str_result(&tmp);
1333
1326
    if (!res)                                   // If NULL
1334
1327
    {
1335
 
      if (my_b_write(cache,(unsigned char*) "",1))
 
1328
      if (cache->write("", 1))
1336
1329
        return 1;
1337
1330
    }
1338
 
    else if (my_b_write(cache,(unsigned char*) res->ptr(),res->length()))
 
1331
    else if (cache->write(res->ptr(), res->length()))
1339
1332
    {
1340
1333
      my_error(ER_ERROR_ON_WRITE, MYF(0), path.file_string().c_str(), errno);
1341
1334
      return 1;