~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

Merge from Monty's tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "tmp_table.h"
23
23
#include "sj_tmp_table.h"
24
24
 
 
25
#include <string>
 
26
 
 
27
using namespace std;
 
28
 
25
29
/* INFORMATION_SCHEMA name */
26
30
LEX_STRING INFORMATION_SCHEMA_NAME= {C_STRING_WITH_LEN("information_schema")};
27
31
 
300
304
  bool error_given;
301
305
  File file;
302
306
  unsigned char head[64], *disk_buff;
303
 
  char  path[FN_REFLEN];
 
307
  string        path("");
 
308
 
304
309
  MEM_ROOT **root_ptr, *old_root;
305
310
 
306
311
  error= 1;
307
312
  error_given= 0;
308
313
  disk_buff= NULL;
309
314
 
310
 
  strxmov(path, share->normalized_path.str, reg_ext, NULL);
311
 
  if ((file= open(path, O_RDONLY)) < 0)
 
315
  path.reserve(FN_REFLEN);
 
316
  path.append(share->normalized_path.str);
 
317
  path.append(reg_ext);
 
318
  if ((file= open(path.c_str(), O_RDONLY)) < 0)
312
319
  {
313
320
    /*
314
321
      We don't try to open 5.0 unencoded name, if
329
336
      goto err_not_open;
330
337
 
331
338
    /* Try unencoded 5.0 name */
332
 
    uint32_t length;
333
 
    strxnmov(path, sizeof(path)-1,
334
 
             mysql_data_home, "/", share->db.str, "/",
335
 
             share->table_name.str, reg_ext, NULL);
336
 
    length= unpack_filename(path, path) - reg_ext_length;
 
339
    size_t length;
 
340
    char unpacked_path[FN_REFLEN];
 
341
    path.clear();
 
342
    path.append(mysql_data_home);
 
343
    path.append("/");
 
344
    path.append(share->db.str);
 
345
    path.append("/");
 
346
    path.append(share->table_name.str);
 
347
    path.append(reg_ext);
 
348
    length= unpack_filename(unpacked_path, path.c_str()) - reg_ext_length;
337
349
    /*
338
350
      The following is a safety test and should never fail
339
351
      as the old file name should never be longer than the new one.
345
357
      so no need to check the old file name.
346
358
    */
347
359
    if (length == share->normalized_path.length ||
348
 
        ((file= open(path, O_RDONLY)) < 0))
 
360
        ((file= open(unpacked_path, O_RDONLY)) < 0))
349
361
      goto err_not_open;
350
362
 
351
363
    /* Unencoded 5.0 table name found */
352
 
    path[length]= '\0'; // Remove .frm extension
353
 
    my_stpcpy(share->normalized_path.str, path);
 
364
    unpacked_path[length]= '\0'; // Remove .frm extension
 
365
    my_stpcpy(share->normalized_path.str, unpacked_path);
354
366
    share->normalized_path.length= length;
355
367
  }
356
368