~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/db.cc

  • Committer: Eric Herman
  • Date: 2008-12-06 19:42:46 UTC
  • mto: (656.1.6 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: eric@mysql.com-20081206194246-5cdexuu81i366eek
removed trailing whitespace with simple script:

for file in $(find . -name "*.c") $(find . -name "*.cc") $(find . -name "*.h"); do ruby -pe 'gsub(/\s+$/, $/)' < $file > $file.out; mv $file.out $file; done;

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
  qinfo.db= db;
146
146
  qinfo.db_len= db_len;
147
147
  drizzle_bin_log.write(&qinfo);
148
 
}  
 
148
}
149
149
 
150
150
 
151
151
/*
160
160
}
161
161
 
162
162
 
163
 
/* 
 
163
/*
164
164
  Initialize database option hash and locked database hash.
165
165
 
166
166
  SYNOPSIS
181
181
  if (!dboptions_init)
182
182
  {
183
183
    dboptions_init= 1;
184
 
    error= hash_init(&dboptions, lower_case_table_names ? 
 
184
    error= hash_init(&dboptions, lower_case_table_names ?
185
185
                     &my_charset_bin : system_charset_info,
186
186
                     32, 0, 0, (hash_get_key) dboptions_get_key,
187
187
                     free_dbopt,0) ||
188
 
           hash_init(&lock_db_cache, lower_case_table_names ? 
 
188
           hash_init(&lock_db_cache, lower_case_table_names ?
189
189
                     &my_charset_bin : system_charset_info,
190
190
                     32, 0, 0, (hash_get_key) lock_db_get_key,
191
191
                     lock_db_free_element,0);
196
196
 
197
197
 
198
198
 
199
 
/* 
 
199
/*
200
200
  Free database option hash and locked databases hash.
201
201
*/
202
202
 
220
220
{
221
221
  pthread_rwlock_wrlock(&LOCK_dboptions);
222
222
  hash_free(&dboptions);
223
 
  hash_init(&dboptions, lower_case_table_names ? 
 
223
  hash_init(&dboptions, lower_case_table_names ?
224
224
            &my_charset_bin : system_charset_info,
225
225
            32, 0, 0, (hash_get_key) dboptions_get_key,
226
226
            free_dbopt,0);
230
230
 
231
231
/*
232
232
  Find database options in the hash.
233
 
  
 
233
 
234
234
  DESCRIPTION
235
235
    Search a database options in the hash, usings its path.
236
236
    Fills "create" on success.
237
 
  
 
237
 
238
238
  RETURN VALUES
239
239
    0 on success.
240
240
    1 on error.
245
245
  my_dbopt_t *opt;
246
246
  uint32_t length;
247
247
  bool error= true;
248
 
  
 
248
 
249
249
  length= (uint) strlen(dbname);
250
 
  
 
250
 
251
251
  pthread_rwlock_rdlock(&LOCK_dboptions);
252
252
  if ((opt= (my_dbopt_t*) hash_search(&dboptions, (unsigned char*) dbname, length)))
253
253
  {
261
261
 
262
262
/*
263
263
  Writes database options into the hash.
264
 
  
 
264
 
265
265
  DESCRIPTION
266
266
    Inserts database options into the hash, or updates
267
267
    options if they are already in the hash.
268
 
  
 
268
 
269
269
  RETURN VALUES
270
270
    0 on success.
271
271
    1 on error.
278
278
  bool error= false;
279
279
 
280
280
  length= (uint) strlen(dbname);
281
 
  
 
281
 
282
282
  pthread_rwlock_wrlock(&LOCK_dboptions);
283
283
  if (!(opt= (my_dbopt_t*) hash_search(&dboptions, (unsigned char*) dbname, length)))
284
 
  { 
 
284
  {
285
285
    /* Options are not in the hash, insert them */
286
286
    char *tmp_name;
287
287
    if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
291
291
      error= true;
292
292
      goto end;
293
293
    }
294
 
    
 
294
 
295
295
    opt->name= tmp_name;
296
296
    my_stpcpy(opt->name, dbname);
297
297
    opt->name_length= length;
298
 
    
 
298
 
299
299
    if ((error= my_hash_insert(&dboptions, (unsigned char*) opt)))
300
300
    {
301
301
      free(opt);
307
307
  opt->charset= create->default_table_charset;
308
308
 
309
309
end:
310
 
  pthread_rwlock_unlock(&LOCK_dboptions);  
 
310
  pthread_rwlock_unlock(&LOCK_dboptions);
311
311
  return(error);
312
312
}
313
313
 
356
356
  db.set_collation(create->default_table_charset->name);
357
357
 
358
358
  fstream output(path, ios::out | ios::trunc | ios::binary);
359
 
  if (!db.SerializeToOstream(&output)) 
 
359
  if (!db.SerializeToOstream(&output))
360
360
    error= false;
361
361
 
362
362
  return error;
619
619
      happened.  (This is a very unlikely senario)
620
620
    */
621
621
  }
622
 
  
 
622
 
623
623
  if (!silent)
624
624
  {
625
625
    char *query;
639
639
 
640
640
    if (drizzle_bin_log.is_open())
641
641
    {
642
 
      Query_log_event qinfo(session, query, query_length, 0, 
 
642
      Query_log_event qinfo(session, query, query_length, 0,
643
643
                            /* suppress_use */ true);
644
644
 
645
645
      /*
648
648
        default. If we do not change the "current database" to the
649
649
        database being created, the CREATE statement will not be
650
650
        replicated when using --binlog-do-db to select databases to be
651
 
        replicated. 
 
651
        replicated.
652
652
 
653
653
        An example (--binlog-do-db=sisyfos):
654
 
       
 
654
 
655
655
          CREATE DATABASE bob;        # Not replicated
656
656
          USE bob;                    # 'bob' is the current database
657
657
          CREATE DATABASE sisyfos;    # Not replicated since 'bob' is
701
701
 
702
702
  pthread_mutex_lock(&LOCK_drizzle_create_db);
703
703
 
704
 
  /* 
 
704
  /*
705
705
     Recreate db options file: /dbpath/.db.opt
706
706
     We pass MY_DB_OPT_FILE as "extension" to avoid
707
707
     "table name to file name" encoding.
823
823
    remove_db_from_cache(db);
824
824
    pthread_mutex_unlock(&LOCK_open);
825
825
 
826
 
    
 
826
 
827
827
    error= -1;
828
828
    if ((deleted= mysql_rm_known_files(session, dirp, db, path, 0,
829
829
                                       &dropped_tables)) >= 0)
850
850
    }
851
851
    if (drizzle_bin_log.is_open())
852
852
    {
853
 
      Query_log_event qinfo(session, query, query_length, 0, 
 
853
      Query_log_event qinfo(session, query, query_length, 0,
854
854
                            /* suppress_use */ true);
855
855
      /*
856
856
        Write should use the database being created as the "current
976
976
      /* Drop the table nicely */
977
977
      *extension= 0;                    // Remove extension
978
978
      TableList *table_list=(TableList*)
979
 
                              session->calloc(sizeof(*table_list) + 
 
979
                              session->calloc(sizeof(*table_list) +
980
980
                                          strlen(db) + 1 +
981
 
                                          MYSQL50_TABLE_NAME_PREFIX_LENGTH + 
 
981
                                          MYSQL50_TABLE_NAME_PREFIX_LENGTH +
982
982
                                          strlen(file->name) + 1);
983
983
 
984
984
      if (!table_list)
1008
1008
      (tot_list && mysql_rm_table_part2(session, tot_list, 1, 0, 1)))
1009
1009
    goto err;
1010
1010
 
1011
 
  my_dirend(dirp);  
1012
 
  
 
1011
  my_dirend(dirp);
 
1012
 
1013
1013
  if (dropped_tables)
1014
1014
    *dropped_tables= tot_list;
1015
 
  
 
1015
 
1016
1016
  /*
1017
1017
    If the directory is a symbolic link, remove the link first, then
1018
1018
    remove the directory the symbolic link pointed at