info.c
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:3k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.    
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16. /* Ger tillbaka en struct med information om isam-filen */
  17. #include "isamdef.h"
  18. #ifdef __WIN__
  19. #include <sys/stat.h>
  20. #endif
  21. ulong nisam_position(N_INFO *info)
  22. {
  23.   return info->lastpos;
  24. }
  25. /* If flag == 1 one only gets pos of last record */
  26. /* if flag == 2 one get current info (no sync from database */
  27. int nisam_info(N_INFO *info, register N_ISAMINFO *x, int flag)
  28. {
  29.   struct stat state;
  30.   ISAM_SHARE *share=info->s;
  31.   DBUG_ENTER("nisam_info");
  32.   x->recpos  = info->lastpos;
  33.   if (flag & (HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE |
  34.       HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK))
  35.   {
  36. #ifndef NO_LOCKING
  37.     if (!(flag & HA_STATUS_NO_LOCK))
  38.     {
  39.       pthread_mutex_lock(&share->intern_lock);
  40.       VOID(_nisam_readinfo(info,F_RDLCK,0));
  41.       VOID(_nisam_writeinfo(info,0));
  42.       pthread_mutex_unlock(&share->intern_lock);
  43.     }
  44. #endif
  45.     x->records  = share->state.records;
  46.     x->deleted  = share->state.del;
  47.     x->delete_length= share->state.empty;
  48.     x->keys  = share->state.keys;
  49.     x->reclength = share->base.reclength;
  50.     x->mean_reclength= share->state.records ?
  51.       (share->state.data_file_length-share->state.empty)/share->state.records :
  52.       share->min_pack_length;
  53.     x->data_file_length=share->state.data_file_length;
  54.     x->max_data_file_length=share->base.max_data_file_length;
  55.     x->index_file_length=share->state.key_file_length;
  56.     x->max_index_file_length=share->base.max_key_file_length;
  57.     x->filenr  = info->dfile;
  58.     x->errkey  = info->errkey;
  59.     x->dupp_key_pos= info->dupp_key_pos;
  60.     x->options  = share->base.options;
  61.     x->create_time=share->base.create_time;
  62.     x->isamchk_time=share->base.isamchk_time;
  63.     x->rec_per_key=share->base.rec_per_key;
  64.     if ((flag & HA_STATUS_TIME) && !fstat(info->dfile,&state))
  65.       x->update_time=state.st_mtime;
  66.     else
  67.       x->update_time=0;
  68.     x->sortkey= -1; /* No clustering */
  69.   }
  70.   DBUG_RETURN(0);
  71. } /* nisam_info */