~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: brian
  • Date: 2009-11-11 19:42:27 UTC
  • mfrom: (1211 staging)
  • mto: (1211.1.4 staging)
  • mto: This revision was merged to the branch mainline in revision 1212.
  • Revision ID: brian@orisndriz04-20091111194227-mky4am3ym0dlosaa
Update for Cursor renaming.

Show diffs side-by-side

added added

removed removed

Lines of Context:
932
932
void Session::add_changed_table(Table *table)
933
933
{
934
934
  assert((options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
935
 
              table->file->has_transactions());
 
935
              table->cursor->has_transactions());
936
936
  add_changed_table(table->s->table_cache_key.str,
937
937
                    (long) table->s->table_cache_key.length);
938
938
}
1038
1038
  if (file > 0)
1039
1039
  {
1040
1040
    (void) end_io_cache(&cache);
1041
 
    (void) my_close(file,MYF(0));
1042
 
    (void) my_delete(path,MYF(0));              // Delete file on error
 
1041
    (void) my_close(file, MYF(0));
 
1042
    (void) my_delete(path, MYF(0));             // Delete file on error
1043
1043
    file= -1;
1044
1044
  }
1045
1045
}
1048
1048
bool select_to_file::send_eof()
1049
1049
{
1050
1050
  int error= test(end_io_cache(&cache));
1051
 
  if (my_close(file,MYF(MY_WME)))
 
1051
  if (my_close(file, MYF(MY_WME)))
1052
1052
    error= 1;
1053
1053
  if (!error)
1054
1054
  {
1070
1070
  if (file >= 0)
1071
1071
  {
1072
1072
    (void) end_io_cache(&cache);
1073
 
    (void) my_close(file,MYF(0));
 
1073
    (void) my_close(file, MYF(0));
1074
1074
    file= -1;
1075
1075
  }
1076
1076
  path[0]= '\0';
1083
1083
  if (file >= 0)
1084
1084
  {                                     // This only happens in case of error
1085
1085
    (void) end_io_cache(&cache);
1086
 
    (void) my_close(file,MYF(0));
 
1086
    (void) my_close(file, MYF(0));
1087
1087
    file= -1;
1088
1088
  }
1089
1089
}
1249
1249
  List_iterator_fast<Item> li(items);
1250
1250
 
1251
1251
  if (my_b_write(&cache,(unsigned char*) exchange->line_start->ptr(),
1252
 
                 exchange->line_start->length()))
 
1252
                 exchange->line_start->length()))
1253
1253
    goto err;
1254
1254
  while ((item=li++))
1255
1255
  {
1260
1260
    if (res && enclosed)
1261
1261
    {
1262
1262
      if (my_b_write(&cache,(unsigned char*) exchange->enclosed->ptr(),
1263
 
                     exchange->enclosed->length()))
1264
 
        goto err;
 
1263
                     exchange->enclosed->length()))
 
1264
        goto err;
1265
1265
    }
1266
1266
    if (!res)
1267
1267
    {                                           // NULL
1268
1268
      if (!fixed_row_size)
1269
1269
      {
1270
 
        if (escape_char != -1)                  // Use \N syntax
1271
 
        {
1272
 
          null_buff[0]=escape_char;
1273
 
          null_buff[1]='N';
1274
 
          if (my_b_write(&cache,(unsigned char*) null_buff,2))
1275
 
            goto err;
1276
 
        }
1277
 
        else if (my_b_write(&cache,(unsigned char*) "NULL",4))
1278
 
          goto err;
 
1270
        if (escape_char != -1)                  // Use \N syntax
 
1271
        {
 
1272
          null_buff[0]=escape_char;
 
1273
          null_buff[1]='N';
 
1274
          if (my_b_write(&cache,(unsigned char*) null_buff,2))
 
1275
            goto err;
 
1276
        }
 
1277
        else if (my_b_write(&cache,(unsigned char*) "NULL",4))
 
1278
          goto err;
1279
1279
      }
1280
1280
      else
1281
1281
      {
1282
 
        used_length=0;                          // Fill with space
 
1282
        used_length=0;                          // Fill with space
1283
1283
      }
1284
1284
    }
1285
1285
    else
1290
1290
        used_length= res->length();
1291
1291
 
1292
1292
      if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
1293
 
           escape_char != -1)
 
1293
          escape_char != -1)
1294
1294
      {
1295
1295
        char *pos, *start, *end;
1296
1296
        const CHARSET_INFO * const res_charset= res->charset();
1297
1297
        const CHARSET_INFO * const character_set_client= default_charset_info;
1298
1298
 
1299
1299
        bool check_second_byte= (res_charset == &my_charset_bin) &&
1300
 
                                 character_set_client->
1301
 
                                 escape_with_backslash_is_dangerous;
 
1300
          character_set_client->
 
1301
          escape_with_backslash_is_dangerous;
1302
1302
        assert(character_set_client->mbmaxlen == 2 ||
1303
1303
               !character_set_client->escape_with_backslash_is_dangerous);
1304
 
        for (start=pos=(char*) res->ptr(),end=pos+used_length ;
1305
 
             pos != end ;
1306
 
             pos++)
1307
 
        {
1308
 
          if (use_mb(res_charset))
1309
 
          {
1310
 
            int l;
1311
 
            if ((l=my_ismbchar(res_charset, pos, end)))
1312
 
            {
1313
 
              pos += l-1;
1314
 
              continue;
1315
 
            }
1316
 
          }
 
1304
        for (start=pos=(char*) res->ptr(),end=pos+used_length ;
 
1305
             pos != end ;
 
1306
             pos++)
 
1307
        {
 
1308
          if (use_mb(res_charset))
 
1309
          {
 
1310
            int l;
 
1311
            if ((l=my_ismbchar(res_charset, pos, end)))
 
1312
            {
 
1313
              pos += l-1;
 
1314
              continue;
 
1315
            }
 
1316
          }
1317
1317
 
1318
1318
          /*
1319
1319
            Special case when dumping BINARY/VARBINARY/BLOB values
1353
1353
                pos + 1 < end &&
1354
1354
                NEED_ESCAPING(pos[1]))) &&
1355
1355
              /*
1356
 
               Don't escape field_term_char by doubling - doubling is only
1357
 
               valid for ENCLOSED BY characters:
 
1356
                Don't escape field_term_char by doubling - doubling is only
 
1357
                valid for ENCLOSED BY characters:
1358
1358
              */
1359
1359
              (enclosed || !is_ambiguous_field_term ||
1360
1360
               (int) (unsigned char) *pos != field_term_char))
1361
1361
          {
1362
 
            char tmp_buff[2];
 
1362
            char tmp_buff[2];
1363
1363
            tmp_buff[0]= ((int) (unsigned char) *pos == field_sep_char &&
1364
1364
                          is_ambiguous_field_sep) ?
1365
 
                          field_sep_char : escape_char;
1366
 
            tmp_buff[1]= *pos ? *pos : '0';
1367
 
            if (my_b_write(&cache,(unsigned char*) start,(uint32_t) (pos-start)) ||
1368
 
                my_b_write(&cache,(unsigned char*) tmp_buff,2))
1369
 
              goto err;
1370
 
            start=pos+1;
1371
 
          }
1372
 
        }
1373
 
        if (my_b_write(&cache,(unsigned char*) start,(uint32_t) (pos-start)))
1374
 
          goto err;
 
1365
              field_sep_char : escape_char;
 
1366
            tmp_buff[1]= *pos ? *pos : '0';
 
1367
            if (my_b_write(&cache,(unsigned char*) start,(uint32_t) (pos-start)) ||
 
1368
                my_b_write(&cache,(unsigned char*) tmp_buff,2))
 
1369
              goto err;
 
1370
            start=pos+1;
 
1371
          }
 
1372
        }
 
1373
        if (my_b_write(&cache,(unsigned char*) start,(uint32_t) (pos-start)))
 
1374
          goto err;
1375
1375
      }
1376
1376
      else if (my_b_write(&cache,(unsigned char*) res->ptr(),used_length))
1377
 
        goto err;
 
1377
        goto err;
1378
1378
    }
1379
1379
    if (fixed_row_size)
1380
1380
    {                                           // Fill with space
1381
1381
      if (item->max_length > used_length)
1382
1382
      {
1383
 
        /* QQ:  Fix by adding a my_b_fill() function */
1384
 
        if (!space_inited)
1385
 
        {
1386
 
          space_inited=1;
1387
 
          memset(space, ' ', sizeof(space));
1388
 
        }
1389
 
        uint32_t length=item->max_length-used_length;
1390
 
        for (; length > sizeof(space) ; length-=sizeof(space))
1391
 
        {
1392
 
          if (my_b_write(&cache,(unsigned char*) space,sizeof(space)))
1393
 
            goto err;
1394
 
        }
1395
 
        if (my_b_write(&cache,(unsigned char*) space,length))
1396
 
          goto err;
 
1383
        /* QQ:  Fix by adding a my_b_fill() function */
 
1384
        if (!space_inited)
 
1385
        {
 
1386
          space_inited=1;
 
1387
          memset(space, ' ', sizeof(space));
 
1388
        }
 
1389
        uint32_t length=item->max_length-used_length;
 
1390
        for (; length > sizeof(space) ; length-=sizeof(space))
 
1391
        {
 
1392
          if (my_b_write(&cache,(unsigned char*) space,sizeof(space)))
 
1393
            goto err;
 
1394
        }
 
1395
        if (my_b_write(&cache,(unsigned char*) space,length))
 
1396
          goto err;
1397
1397
      }
1398
1398
    }
1399
1399
    if (res && enclosed)
1410
1410
    }
1411
1411
  }
1412
1412
  if (my_b_write(&cache,(unsigned char*) exchange->line_term->ptr(),
1413
 
                 exchange->line_term->length()))
 
1413
                 exchange->line_term->length()))
1414
1414
    goto err;
1415
1415
  return(0);
1416
1416
err:
1877
1877
 
1878
1878
/*
1879
1879
  Close all temporary tables created by 'CREATE TEMPORARY TABLE' for thread
1880
 
  creates one DROP TEMPORARY Table binlog event for each pseudo-thread
1881
1880
*/
1882
1881
 
1883
1882
void Session::close_temporary_tables()
2009
2008
    if (table->query_id == query_id)
2010
2009
    {
2011
2010
      table->query_id= 0;
2012
 
      table->file->ha_reset();
 
2011
      table->cursor->ha_reset();
2013
2012
    }
2014
2013
  }
2015
2014
}
2021
2020
    if (table->query_id == query_id)
2022
2021
    {
2023
2022
      table->query_id= 0;
2024
 
      table->file->ha_reset();
 
2023
      table->cursor->ha_reset();
2025
2024
    }
2026
2025
  }
2027
2026
}