~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/csv/ha_tina.cc

  • Committer: lbieber
  • Date: 2010-08-04 22:35:53 UTC
  • mfrom: (1685.3.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 1687.
  • Revision ID: lbieber@orisndriz03-20100804223553-9q2sz4yc1fvkpup4
Merge Brian - custom lock encapsulation, and myisam lock removel code

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
static int read_meta_file(int meta_file, ha_rows *rows);
79
79
static int write_meta_file(int meta_file, ha_rows rows, bool dirty);
80
80
 
81
 
void tina_get_status(void* param, int concurrent_insert);
82
 
void tina_update_status(void* param);
83
 
bool tina_check_status(void* param);
84
 
 
85
81
/* Stuff for shares */
86
82
pthread_mutex_t tina_mutex;
87
83
 
779
775
}
780
776
 
781
777
/*
782
 
  Three functions below are needed to enable concurrent insert functionality
783
 
  for CSV engine. For more details see mysys/thr_lock.c
784
 
*/
785
 
 
786
 
void tina_get_status(void* param, int)
787
 
{
788
 
  ha_tina *tina= (ha_tina*) param;
789
 
  tina->get_status();
790
 
}
791
 
 
792
 
void tina_update_status(void* param)
793
 
{
794
 
  ha_tina *tina= (ha_tina*) param;
795
 
  tina->update_status();
796
 
}
797
 
 
798
 
/* this should exist and return 0 for concurrent insert to work */
799
 
bool tina_check_status(void *)
800
 
{
801
 
  return 0;
802
 
}
803
 
 
804
 
/*
805
 
  Save the state of the table
806
 
 
807
 
  SYNOPSIS
808
 
    get_status()
809
 
 
810
 
  DESCRIPTION
811
 
    This function is used to retrieve the file length. During the lock
812
 
    phase of concurrent insert. For more details see comment to
813
 
    ha_tina::update_status below.
814
 
*/
815
 
 
816
 
void ha_tina::get_status()
817
 
{
818
 
  local_saved_data_file_length= share->saved_data_file_length;
819
 
}
820
 
 
821
 
 
822
 
/*
823
 
  Correct the state of the table. Called by unlock routines
824
 
  before the write lock is released.
825
 
 
826
 
  SYNOPSIS
827
 
    update_status()
828
 
 
829
 
  DESCRIPTION
830
 
    When we employ concurrent insert lock, we save current length of the file
831
 
    during the lock phase. We do not read further saved value, as we don't
832
 
    want to interfere with undergoing concurrent insert. Writers update file
833
 
    length info during unlock with update_status().
834
 
 
835
 
  NOTE
836
 
    For log tables concurrent insert works different. The reason is that
837
 
    log tables are always opened and locked. And as they do not unlock
838
 
    tables, the file length after writes should be updated in a different
839
 
    way.
840
 
*/
841
 
 
842
 
void ha_tina::update_status()
843
 
{
844
 
  /* correct local_saved_data_file_length for writers */
845
 
  share->saved_data_file_length= local_saved_data_file_length;
846
 
}
847
 
 
848
 
 
849
 
/*
850
778
  Open a database file. Keep in mind that tables are caches, so
851
779
  this will not be called for every request. Any sort of positions
852
780
  that need to be reset should be kept in the ::extra() call.
871
799
    so that they could save/update local_saved_data_file_length value
872
800
    during locking. This is needed to enable concurrent inserts.
873
801
  */
874
 
  thr_lock_data_init(&share->lock, &lock, (void*) this);
 
802
  thr_lock_data_init(&share->lock, &lock);
875
803
  ref_length=sizeof(off_t);
876
804
 
877
 
  share->lock.get_status= tina_get_status;
878
 
  share->lock.update_status= tina_update_status;
879
 
  share->lock.check_status= tina_check_status;
880
 
 
881
805
  return(0);
882
806
}
883
807