~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/csv/ha_tina.cc

Merged in Jay's tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
    }
163
163
 
164
164
    share->use_count= 0;
165
 
    share->is_log_table= FALSE;
 
165
    share->is_log_table= false;
166
166
    share->table_name_length= length;
167
167
    share->table_name= tmp_name;
168
 
    share->crashed= FALSE;
 
168
    share->crashed= false;
169
169
    share->rows_recorded= 0;
170
 
    share->update_file_opened= FALSE;
171
 
    share->tina_write_opened= FALSE;
 
170
    share->update_file_opened= false;
 
171
    share->tina_write_opened= false;
172
172
    share->data_file_version= 0;
173
173
    strmov(share->table_name, table_name);
174
174
    fn_format(share->data_file_name, table_name, "", CSV_EXT,
193
193
    */
194
194
    if ((share->meta_file= my_open(meta_file_name,
195
195
                                   O_RDWR|O_CREAT, MYF(0))) == -1)
196
 
      share->crashed= TRUE;
 
196
      share->crashed= true;
197
197
 
198
198
    /*
199
199
      If the meta file will not open we assume it is crashed and
200
200
      mark it as such.
201
201
    */
202
202
    if (read_meta_file(share->meta_file, &share->rows_recorded))
203
 
      share->crashed= TRUE;
 
203
      share->crashed= true;
204
204
  }
205
205
  share->use_count++;
206
206
  pthread_mutex_unlock(&tina_mutex);
261
261
 
262
262
  /* check crashed bit and magic number */
263
263
  if ((meta_buffer[0] != (uchar)TINA_CHECK_HEADER) ||
264
 
      ((bool)(*ptr)== TRUE))
 
264
      ((bool)(*ptr)== true))
265
265
    DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
266
266
 
267
267
  my_sync(meta_file, MYF(MY_WME));
340
340
    the file. In the case of the crash it will remain marked crashed,
341
341
    which enforce recovery.
342
342
  */
343
 
  (void)write_meta_file(share->meta_file, share->rows_recorded, TRUE);
 
343
  (void)write_meta_file(share->meta_file, share->rows_recorded, true);
344
344
 
345
345
  if ((share->tina_write_filedes=
346
346
        my_open(share->data_file_name, O_RDWR|O_APPEND, MYF(0))) == -1)
347
347
  {
348
348
    DBUG_PRINT("info", ("Could not open tina file writes"));
349
 
    share->crashed= TRUE;
 
349
    share->crashed= true;
350
350
    DBUG_RETURN(1);
351
351
  }
352
 
  share->tina_write_opened= TRUE;
 
352
  share->tina_write_opened= true;
353
353
 
354
354
  DBUG_RETURN(0);
355
355
}
372
372
  if (!--share->use_count){
373
373
    /* Write the meta file. Mark it as crashed if needed. */
374
374
    (void)write_meta_file(share->meta_file, share->rows_recorded,
375
 
                          share->crashed ? TRUE :FALSE);
 
375
                          share->crashed ? true :false);
376
376
    if (my_close(share->meta_file, MYF(0)))
377
377
      result_code= 1;
378
378
    if (share->tina_write_opened)
379
379
    {
380
380
      if (my_close(share->tina_write_filedes, MYF(0)))
381
381
        result_code= 1;
382
 
      share->tina_write_opened= FALSE;
 
382
      share->tina_write_opened= false;
383
383
    }
384
384
 
385
385
    hash_delete(&tina_open_tables, (uchar*) share);
919
919
                               MY_REPLACE_EXT | MY_UNPACK_FILENAME),
920
920
                     0, O_RDWR | O_TRUNC, MYF(MY_WME))) < 0)
921
921
      return 1;
922
 
    share->update_file_opened= TRUE;
 
922
    share->update_file_opened= true;
923
923
    temp_file_length= 0;
924
924
  }
925
925
  return 0;
1253
1253
        my_close(update_temp_file, MYF(0)))
1254
1254
      DBUG_RETURN(-1);
1255
1255
 
1256
 
    share->update_file_opened= FALSE;
 
1256
    share->update_file_opened= false;
1257
1257
 
1258
1258
    if (share->tina_write_opened)
1259
1259
    {
1263
1263
        Mark that the writer fd is closed, so that init_tina_writer()
1264
1264
        will reopen it later.
1265
1265
      */
1266
 
      share->tina_write_opened= FALSE;
 
1266
      share->tina_write_opened= false;
1267
1267
    }
1268
1268
 
1269
1269
    /*
1294
1294
      closed, so nothing worrying will happen to it in case of a crash.
1295
1295
      Here we record this fact to the meta-file.
1296
1296
    */
1297
 
    (void)write_meta_file(share->meta_file, share->rows_recorded, FALSE);
 
1297
    (void)write_meta_file(share->meta_file, share->rows_recorded, false);
1298
1298
    /* 
1299
1299
      Update local_saved_data_file_length with the real length of the 
1300
1300
      data file.
1305
1305
  DBUG_RETURN(0);
1306
1306
error:
1307
1307
  my_close(update_temp_file, MYF(0));
1308
 
  share->update_file_opened= FALSE;
 
1308
  share->update_file_opened= false;
1309
1309
  DBUG_RETURN(-1);
1310
1310
}
1311
1311
 
1440
1440
  local_saved_data_file_length= (size_t) current_position;
1441
1441
 
1442
1442
end:
1443
 
  share->crashed= FALSE;
 
1443
  share->crashed= false;
1444
1444
  DBUG_RETURN(HA_ADMIN_OK);
1445
1445
}
1446
1446
 
1516
1516
                              O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
1517
1517
    DBUG_RETURN(-1);
1518
1518
 
1519
 
  write_meta_file(create_file, 0, FALSE);
 
1519
  write_meta_file(create_file, 0, false);
1520
1520
  my_close(create_file, MYF(0));
1521
1521
 
1522
1522
  if ((create_file= my_create(fn_format(name_buff, name, "", CSV_EXT,
1572
1572
 
1573
1573
  if ((rc != HA_ERR_END_OF_FILE) || count)
1574
1574
  {
1575
 
    share->crashed= TRUE;
 
1575
    share->crashed= true;
1576
1576
    DBUG_RETURN(HA_ADMIN_CORRUPT);
1577
1577
  }
1578
1578
  else