~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/db.cc

  • Committer: Monty Taylor
  • Date: 2009-02-08 11:28:58 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mordred@inaugust.com-20090208112858-aouo9w2okht5r6x0
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
310
310
 
311
311
  /*
312
312
    Do not create database if another thread is holding read lock.
313
 
    Wait for global read lock before acquiring LOCK_drizzle_create_db.
 
313
    Wait for global read lock before acquiring LOCK_drizzleclient_create_db.
314
314
    After wait_if_global_read_lock() we have protection against another
315
 
    global read lock. If we would acquire LOCK_drizzle_create_db first,
 
315
    global read lock. If we would acquire LOCK_drizzleclient_create_db first,
316
316
    another thread could step in and get the global read lock before we
317
317
    reach wait_if_global_read_lock(). If this thread tries the same as we
318
 
    (admin a db), it would then go and wait on LOCK_drizzle_create_db...
 
318
    (admin a db), it would then go and wait on LOCK_drizzleclient_create_db...
319
319
    Furthermore wait_if_global_read_lock() checks if the current thread
320
320
    has the global read lock and refuses the operation with
321
321
    ER_CANT_UPDATE_WITH_READLOCK if applicable.
326
326
    goto exit2;
327
327
  }
328
328
 
329
 
  pthread_mutex_lock(&LOCK_drizzle_create_db);
 
329
  pthread_mutex_lock(&LOCK_drizzleclient_create_db);
330
330
 
331
331
  /* Check directory */
332
332
  path_len= build_table_filename(path, sizeof(path), db, "", "", 0);
386
386
  }
387
387
 
388
388
exit:
389
 
  pthread_mutex_unlock(&LOCK_drizzle_create_db);
 
389
  pthread_mutex_unlock(&LOCK_drizzleclient_create_db);
390
390
  start_waiting_global_read_lock(session);
391
391
exit2:
392
392
  return(error);
404
404
 
405
405
  /*
406
406
    Do not alter database if another thread is holding read lock.
407
 
    Wait for global read lock before acquiring LOCK_drizzle_create_db.
 
407
    Wait for global read lock before acquiring LOCK_drizzleclient_create_db.
408
408
    After wait_if_global_read_lock() we have protection against another
409
 
    global read lock. If we would acquire LOCK_drizzle_create_db first,
 
409
    global read lock. If we would acquire LOCK_drizzleclient_create_db first,
410
410
    another thread could step in and get the global read lock before we
411
411
    reach wait_if_global_read_lock(). If this thread tries the same as we
412
 
    (admin a db), it would then go and wait on LOCK_drizzle_create_db...
 
412
    (admin a db), it would then go and wait on LOCK_drizzleclient_create_db...
413
413
    Furthermore wait_if_global_read_lock() checks if the current thread
414
414
    has the global read lock and refuses the operation with
415
415
    ER_CANT_UPDATE_WITH_READLOCK if applicable.
417
417
  if ((error=wait_if_global_read_lock(session,0,1)))
418
418
    goto exit;
419
419
 
420
 
  pthread_mutex_lock(&LOCK_drizzle_create_db);
 
420
  pthread_mutex_lock(&LOCK_drizzleclient_create_db);
421
421
 
422
422
  /* Change options if current database is being altered. */
423
423
  path_len= build_table_filename(path, sizeof(path), db, "", "", 0);
427
427
  if (error && error != EEXIST)
428
428
  {
429
429
    /* TODO: find some witty way of getting back an error message */
430
 
    pthread_mutex_unlock(&LOCK_drizzle_create_db);
 
430
    pthread_mutex_unlock(&LOCK_drizzleclient_create_db);
431
431
    goto exit;
432
432
  }
433
433
 
442
442
  (void)replicator_statement(session, session->query, session->query_length);
443
443
  session->my_ok(result);
444
444
 
445
 
  pthread_mutex_unlock(&LOCK_drizzle_create_db);
 
445
  pthread_mutex_unlock(&LOCK_drizzleclient_create_db);
446
446
  start_waiting_global_read_lock(session);
447
447
exit:
448
448
  return(error);
483
483
 
484
484
  /*
485
485
    Do not drop database if another thread is holding read lock.
486
 
    Wait for global read lock before acquiring LOCK_drizzle_create_db.
 
486
    Wait for global read lock before acquiring LOCK_drizzleclient_create_db.
487
487
    After wait_if_global_read_lock() we have protection against another
488
 
    global read lock. If we would acquire LOCK_drizzle_create_db first,
 
488
    global read lock. If we would acquire LOCK_drizzleclient_create_db first,
489
489
    another thread could step in and get the global read lock before we
490
490
    reach wait_if_global_read_lock(). If this thread tries the same as we
491
 
    (admin a db), it would then go and wait on LOCK_drizzle_create_db...
 
491
    (admin a db), it would then go and wait on LOCK_drizzleclient_create_db...
492
492
    Furthermore wait_if_global_read_lock() checks if the current thread
493
493
    has the global read lock and refuses the operation with
494
494
    ER_CANT_UPDATE_WITH_READLOCK if applicable.
499
499
    goto exit2;
500
500
  }
501
501
 
502
 
  pthread_mutex_lock(&LOCK_drizzle_create_db);
 
502
  pthread_mutex_lock(&LOCK_drizzleclient_create_db);
503
503
 
504
504
  length= build_table_filename(path, sizeof(path), db, "", "", 0);
505
505
  strcpy(path+length, MY_DB_OPT_FILE);         // Append db option file name
575
575
      tbl_name_len= strlen(tbl->table_name) + 3;
576
576
      if (query_pos + tbl_name_len + 1 >= query_end)
577
577
      {
578
 
        /* These DDL methods and logging protected with LOCK_drizzle_create_db */
 
578
        /* These DDL methods and logging protected with LOCK_drizzleclient_create_db */
579
579
        write_to_binlog(session, query, query_pos -1 - query, db, db_len);
580
580
        query_pos= query_data_start;
581
581
      }
588
588
 
589
589
    if (query_pos != query_data_start)
590
590
    {
591
 
      /* These DDL methods and logging protected with LOCK_drizzle_create_db */
 
591
      /* These DDL methods and logging protected with LOCK_drizzleclient_create_db */
592
592
      write_to_binlog(session, query, query_pos -1 - query, db, db_len);
593
593
    }
594
594
  }
602
602
  */
603
603
  if (session->db && !strcmp(session->db, db))
604
604
    mysql_change_db_impl(session, NULL, session->variables.collation_server);
605
 
  pthread_mutex_unlock(&LOCK_drizzle_create_db);
 
605
  pthread_mutex_unlock(&LOCK_drizzleclient_create_db);
606
606
  start_waiting_global_read_lock(session);
607
607
exit2:
608
608
  return(error);