~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Brian Aker
  • Date: 2008-08-14 22:05:07 UTC
  • Revision ID: brian@tangent.org-20080814220507-vu3rm1f067qc03r7
Remove server based system tables (we no longer have them).

Show diffs side-by-side

added added

removed removed

Lines of Context:
6591
6591
{
6592
6592
  return a->length == b->length && !strncmp(a->str, b->str, a->length);
6593
6593
}
6594
 
 
6595
 
 
6596
 
/*
6597
 
  Open and lock system tables for read.
6598
 
 
6599
 
  SYNOPSIS
6600
 
    open_system_tables_for_read()
6601
 
      thd         Thread context.
6602
 
      table_list  List of tables to open.
6603
 
      backup      Pointer to Open_tables_state instance where
6604
 
                  information about currently open tables will be
6605
 
                  saved, and from which will be restored when we will
6606
 
                  end work with system tables.
6607
 
 
6608
 
  NOTES
6609
 
    Thanks to restrictions which we put on opening and locking of
6610
 
    system tables for writing, we can open and lock them for reading
6611
 
    even when we already have some other tables open and locked.  One
6612
 
    must call close_system_tables() to close systems tables opened
6613
 
    with this call.
6614
 
 
6615
 
  RETURN
6616
 
    false   Success
6617
 
    true    Error
6618
 
*/
6619
 
 
6620
 
bool
6621
 
open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
6622
 
                            Open_tables_state *backup)
6623
 
{
6624
 
  thd->reset_n_backup_open_tables_state(backup);
6625
 
 
6626
 
  uint count= 0;
6627
 
  bool not_used;
6628
 
  for (TABLE_LIST *tables= table_list; tables; tables= tables->next_global)
6629
 
  {
6630
 
    TABLE *table= open_table(thd, tables, thd->mem_root, &not_used,
6631
 
                             DRIZZLE_LOCK_IGNORE_FLUSH);
6632
 
    if (!table)
6633
 
      goto error;
6634
 
 
6635
 
    assert(table->s->table_category == TABLE_CATEGORY_SYSTEM);
6636
 
 
6637
 
    table->use_all_columns();
6638
 
    table->reginfo.lock_type= tables->lock_type;
6639
 
    tables->table= table;
6640
 
    count++;
6641
 
  }
6642
 
 
6643
 
  {
6644
 
    TABLE **list= (TABLE**) thd->alloc(sizeof(TABLE*) * count);
6645
 
    TABLE **ptr= list;
6646
 
    for (TABLE_LIST *tables= table_list; tables; tables= tables->next_global)
6647
 
      *(ptr++)= tables->table;
6648
 
 
6649
 
    thd->lock= mysql_lock_tables(thd, list, count,
6650
 
                                 DRIZZLE_LOCK_IGNORE_FLUSH, &not_used);
6651
 
  }
6652
 
  if (thd->lock)
6653
 
    return(false);
6654
 
 
6655
 
error:
6656
 
  close_system_tables(thd, backup);
6657
 
 
6658
 
  return(true);
6659
 
}
6660
 
 
6661
 
 
6662
 
/*
6663
 
  Close system tables, opened with open_system_tables_for_read().
6664
 
 
6665
 
  SYNOPSIS
6666
 
    close_system_tables()
6667
 
      thd     Thread context
6668
 
      backup  Pointer to Open_tables_state instance which holds
6669
 
              information about tables which were open before we
6670
 
              decided to access system tables.
6671
 
*/
6672
 
 
6673
 
void
6674
 
close_system_tables(THD *thd, Open_tables_state *backup)
6675
 
{
6676
 
  close_thread_tables(thd);
6677
 
  thd->restore_backup_open_tables_state(backup);
6678
 
}
6679
 
 
6680
 
 
6681
 
/*
6682
 
  Open and lock one system table for update.
6683
 
 
6684
 
  SYNOPSIS
6685
 
    open_system_table_for_update()
6686
 
      thd        Thread context.
6687
 
      one_table  Table to open.
6688
 
 
6689
 
  NOTES
6690
 
    Table opened with this call should closed using close_thread_tables().
6691
 
 
6692
 
  RETURN
6693
 
    0   Error
6694
 
    #   Pointer to TABLE object of system table
6695
 
*/
6696
 
 
6697
 
TABLE *
6698
 
open_system_table_for_update(THD *thd, TABLE_LIST *one_table)
6699
 
{
6700
 
  TABLE *table= open_ltable(thd, one_table, one_table->lock_type, 0);
6701
 
  if (table)
6702
 
  {
6703
 
    assert(table->s->table_category == TABLE_CATEGORY_SYSTEM);
6704
 
    table->use_all_columns();
6705
 
  }
6706
 
 
6707
 
  return(table);
6708
 
}
6709
 
 
6710
6594
/**
6711
6595
  @} (end of group Data_Dictionary)
6712
6596
*/