struct TABLE_SHARE
- struct TABLE_SHARE
- {
- TABLE_SHARE() {} /* Remove gcc warning */
- /** Category of this table. */
- TABLE_CATEGORY table_category;
- /* hash of field names (contains pointers to elements of field array) */
- HASH name_hash; /* hash of field names */
- MEM_ROOT mem_root;
- TYPELIB keynames; /* Pointers to keynames */
- TYPELIB fieldnames; /* Pointer to fieldnames */
- TYPELIB *intervals; /* pointer to interval info */
- mysql_mutex_t LOCK_ha_data; /* To protect access to ha_data */
- TABLE_SHARE *next, **prev; /* Link to unused shares */
- /*
- Doubly-linked (back-linked) lists of used and unused TABLE objects
- for this share.
- */
- I_P_List <TABLE, TABLE_share> used_tables;
- I_P_List <TABLE, TABLE_share> free_tables;
- /* The following is copied to each TABLE on OPEN */
- Field **field;
- Field **found_next_number_field;
- Field *timestamp_field; /* Used only during open */
- KEY *key_info; /* data of keys in database */
- uint *blob_field; /* Index to blobs in Field arrray*/
- uchar *default_values; /* row with default values */
- LEX_STRING comment; /* Comment about table */
- CHARSET_INFO *table_charset; /* Default charset of string fields */
- MY_BITMAP all_set;
- /*
- Key which is used for looking-up table in table cache and in the list
- of thread's temporary tables. Has the form of:
- "database_name\0table_name\0" + optional part for temporary tables.
- Note that all three 'table_cache_key', 'db' and 'table_name' members
- must be set (and be non-zero) for tables in table cache. They also
- should correspond to each other.
- To ensure this one can use set_table_cache() methods.
- */
- LEX_STRING table_cache_key;
- LEX_STRING db; /* Pointer to db */
- LEX_STRING table_name; /* Table name (for open) */
- LEX_STRING path; /* Path to .frm file (from datadir) */
- LEX_STRING normalized_path; /* unpack_filename(path) */
- LEX_STRING connect_string;
- /*
- Set of keys in use, implemented as a Bitmap.
- Excludes keys disabled by ALTER TABLE ... DISABLE KEYS.
- */
- key_map keys_in_use;
- key_map keys_for_keyread;
- ha_rows min_rows, max_rows; /* create information */
- ulong avg_row_length; /* create information */
- ulong version, mysql_version;
- ulong reclength; /* Recordlength */
- plugin_ref db_plugin; /* storage engine plugin */
- inline handlerton *db_type() const /* table_type for handler */
- {
- // DBUG_ASSERT(db_plugin);
- return db_plugin ? plugin_data(db_plugin, handlerton*) : NULL;
- }
- enum row_type row_type; /* How rows are stored */
- enum tmp_table_type tmp_table;
- uint ref_count; /* How many TABLE objects uses this */
- uint blob_ptr_size; /* 4 or 8 */
- uint key_block_size; /* create key_block_size, if used */
- uint null_bytes, last_null_bit_pos;
- uint fields; /* Number of fields */
- uint rec_buff_length; /* Size of table->record[] buffer */
- uint keys, key_parts;
- uint max_key_length, max_unique_length, total_key_length;
- uint uniques; /* Number of UNIQUE index */
- uint null_fields; /* number of null fields */
- uint blob_fields; /* number of blob fields */
- uint timestamp_field_offset; /* Field number for timestamp field */
- uint varchar_fields; /* number of varchar fields */
- uint db_create_options; /* Create options from database */
- uint db_options_in_use; /* Options in use */
- uint db_record_offset; /* if HA_REC_IN_SEQ */
- uint rowid_field_offset; /* Field_nr +1 to rowid field */
- /* Primary key index number, used in TABLE::key_info[] */
- uint primary_key;
- uint next_number_index; /* autoincrement key number */
- uint next_number_key_offset; /* autoinc keypart offset in a key */
- uint next_number_keypart; /* autoinc keypart number in a key */
- uint error, open_errno, errarg; /* error from open_table_def() */
- uint column_bitmap_size;
- uchar frm_version;
- bool null_field_first;
- bool system; /* Set if system table (one record) */
- bool crypted; /* If .frm file is crypted */
- bool db_low_byte_first; /* Portable row format */
- bool crashed;
- bool is_view;
- ulong table_map_id; /* for row-based replication */
- /*
- Cache for row-based replication table share checks that does not
- need to be repeated. Possible values are: -1 when cache value is
- not calculated yet, 0 when table *shall not* be replicated, 1 when
- table *may* be replicated.
- */
- int cached_row_logging_check;
- /*
- Storage media to use for this table (unless another storage
- media has been specified on an individual column - in versions
- where that is supported)
- */
- enum ha_storage_media default_storage_media;
- /* Name of the tablespace used for this table */
- char *tablespace;
- #ifdef WITH_PARTITION_STORAGE_ENGINE
- /* filled in when reading from frm */
- bool auto_partitioned;
- char *partition_info_str;
- uint partition_info_str_len;
- uint partition_info_buffer_size;
- handlerton *default_part_db_type;
- #endif
- /**
- Cache the checked structure of this table.
- The pointer data is used to describe the structure that
- a instance of the table must have. Each element of the
- array specifies a field that must exist on the table.
- The pointer is cached in order to perform the check only
- once -- when the table is loaded from the disk.
- */
- const TABLE_FIELD_DEF *table_field_def_cache;
- /** place to store storage engine specific data */
- void *ha_data;
- void (*ha_data_destroy)(void *); /* An optional destructor for ha_data */
- #ifdef WITH_PARTITION_STORAGE_ENGINE
- /** place to store partition specific data, LOCK_ha_data hold while init. */
- HA_DATA_PARTITION *ha_part_data;
- /* Destructor for ha_part_data */
- void (*ha_part_data_destroy)(HA_DATA_PARTITION *);
- #endif
- /** Instrumentation for this table share. */
- PSI_table_share *m_psi;
- /**
- List of tickets representing threads waiting for the share to be flushed.
- */
- Wait_for_flush_list m_flush_tickets;
- /*
- Set share's table cache key and update its db and table name appropriately.
- SYNOPSIS
- set_table_cache_key()
- key_buff Buffer with already built table cache key to be
- referenced from share.
- key_length Key length.
- NOTES
- Since 'key_buff' buffer will be referenced from share it should has same
- life-time as share itself.
- This method automatically ensures that TABLE_SHARE::table_name/db have
- appropriate values by using table cache key as their source.
- */
- void set_table_cache_key(char *key_buff, uint key_length)
- {
- table_cache_key.str= key_buff;
- table_cache_key.length= key_length;
- /*
- Let us use the fact that the key is "db/0/table_name/0" + optional
- part for temporary tables.
- */
- db.str= table_cache_key.str;
- db.length= strlen(db.str);
- table_name.str= db.str + db.length + ;
- table_name.length= strlen(table_name.str);
- }
- /*
- Set share's table cache key and update its db and table name appropriately.
- SYNOPSIS
- set_table_cache_key()
- key_buff Buffer to be used as storage for table cache key
- (should be at least key_length bytes).
- key Value for table cache key.
- key_length Key length.
- NOTE
- Since 'key_buff' buffer will be used as storage for table cache key
- it should has same life-time as share itself.
- */
- void set_table_cache_key(char *key_buff, const char *key, uint key_length)
- {
- memcpy(key_buff, key, key_length);
- set_table_cache_key(key_buff, key_length);
- }
- inline bool honor_global_locks()
- {
- return ((table_category == TABLE_CATEGORY_USER)
- || (table_category == TABLE_CATEGORY_SYSTEM));
- }
- inline bool require_write_privileges()
- {
- return (table_category == TABLE_CATEGORY_LOG);
- }
- inline ulong get_table_def_version()
- {
- return table_map_id;
- }
- /** Is this table share being expelled from the table definition cache? */
- inline bool has_old_version() const
- {
- return version != refresh_version;
- }
- /**
- Convert unrelated members of TABLE_SHARE to one enum
- representing its type.
- @todo perhaps we need to have a member instead of a function.
- */
- enum enum_table_ref_type get_table_ref_type() const
- {
- if (is_view)
- return TABLE_REF_VIEW;
- switch (tmp_table) {
- case NO_TMP_TABLE:
- return TABLE_REF_BASE_TABLE;
- case SYSTEM_TMP_TABLE:
- return TABLE_REF_I_S_TABLE;
- default:
- return TABLE_REF_TMP_TABLE;
- }
- }
- /**
- Return a table metadata version.
- * for base tables, we return table_map_id.
- It is assigned from a global counter incremented for each
- new table loaded into the table definition cache (TDC).
- * for temporary tables it's table_map_id again. But for
- temporary tables table_map_id is assigned from
- thd->query_id. The latter is assigned from a thread local
- counter incremented for every new SQL statement. Since
- temporary tables are thread-local, each temporary table
- gets a unique id.
- * for everything else (views, information schema tables),
- the version id is zero.
- This choice of version id is a large compromise
- to have a working prepared statement validation in 5.1. In
- future version ids will be persistent, as described in WL#4180.
- Let's try to explain why and how this limited solution allows
- to validate prepared statements.
- Firstly, sets (in mathematical sense) of version numbers
- never intersect for different table types. Therefore,
- version id of a temporary table is never compared with
- a version id of a view, and vice versa.
- Secondly, for base tables, we know that each DDL flushes the
- respective share from the TDC. This ensures that whenever
- a table is altered or dropped and recreated, it gets a new
- version id.
- Unfortunately, since elements of the TDC are also flushed on
- LRU basis, this choice of version ids leads to false positives.
- E.g. when the TDC size is too small, we may have a SELECT
- * FROM INFORMATION_SCHEMA.TABLES flush all its elements, which
- in turn will lead to a validation error and a subsequent
- reprepare of all prepared statements. This is
- considered acceptable, since as long as prepared statements are
- automatically reprepared, spurious invalidation is only
- a performance hit. Besides, no better simple solution exists.
- For temporary tables, using thd->query_id ensures that if
- a temporary table was altered or recreated, a new version id is
- assigned. This suits validation needs very well and will perhaps
- never change.
- Metadata of information schema tables never changes.
- Thus we can safely assume 0 for a good enough version id.
- Views are a special and tricky case. A view is always inlined
- into the parse tree of a prepared statement at prepare.
- Thus, when we execute a prepared statement, the parse tree
- will not get modified even if the view is replaced with another
- view. Therefore, we can safely choose 0 for version id of
- views and effectively never invalidate a prepared statement
- when a view definition is altered. Note, that this leads to
- wrong binary log in statement-based replication, since we log
- prepared statement execution in form Query_log_events
- containing conventional statements. But since there is no
- metadata locking for views, the very same problem exists for
- conventional statements alone, as reported in Bug#25144. The only
- difference between prepared and conventional execution is,
- effectively, that for prepared statements the race condition
- window is much wider.
- In 6.0 we plan to support view metadata locking (WL#3726) and
- extend table definition cache to cache views (WL#4298).
- When this is done, views will be handled in the same fashion
- as the base tables.
- Finally, by taking into account table type, we always
- track that a change has taken place when a view is replaced
- with a base table, a base table is replaced with a temporary
- table and so on.
- @sa TABLE_LIST::is_table_ref_id_equal()
- */
- ulong get_table_ref_version() const
- {
- : table_map_id;
- }
- bool visit_subgraph(Wait_for_flush *waiting_ticket,
- MDL_wait_for_graph_visitor *gvisitor);
- bool wait_for_old_version(THD *thd, struct timespec *abstime,
- uint deadlock_weight);
- /** Release resources and free memory occupied by the table share. */
- void destroy();
- };
struct TABLE_SHARE的更多相关文章
- 结构体TABLE_share
struct TABLE_share { static inline TABLE **next_ptr(TABLE *l) { return &l->share_next; } stat ...
- struct TABLE
struct TABLE { TABLE() {} /* Remove gcc warning */ TABLE_SHARE *s; handler *file; TABLE *next, *prev ...
- 使用struct处理二进制
有的时候需要用python处理二进制数据,比如,存取文件.socket操作时.这时候,可以使用python的struct模块来完成. struct模块中最重要的三个函数是pack(), unpack( ...
- golang struct扩展函数参数命名警告
今天在使用VSCode编写golang代码时,定义一个struct,扩展几个方法,如下: package storage import ( "fmt" "github.c ...
- go-使用 unsafe 修改 struct 中的 field 的值
以下是方法,不要纠结原理,等东西积累多了,你才有能力纠结原理: 首先,你需要有一个这样的函数,这是在 nsq 的源码里直接抄过来的: func unsafeValueOf(val reflect.Va ...
- C语言中struct位域的定义和使用
位域的定义和使用 有些信息在存储时,并不需要占用一个完整的字节, 而只需占几个或一个二进制位.例如在存放一个开关量时,只有0和1 两种状态, 用一位二进位即可.为了节省存储空间,并使处理简便,C语言又 ...
- C# Struct结构体里数组长度的指定
typedef struct Point{ unsigned short x; unsigned short y; }mPoint;//点坐标 typedef struct Line{ mPoint ...
- C 语言Struct 实现运行类型识别 RTTI
通过RTTI,能够通过基类的指针或引用来检索其所指对象的实际类型.c++通过下面两个操作符提供RTTI. (1)typeid:返回指针或引用所指对象的实际类型. (2)dynamic_cast: ...
- VC++ : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>
最近学习Google Breakpad,将其用在了自己的项目中,编译的版本为VS2010,没有什么问题.但是为了和之前的程序兼容,需要使用VS2008版本的程序,于是又编译了VS2008版本的代码,但 ...
随机推荐
- Android学习笔记:TabHost 和 FragmentTabHost(转)
转自:http://www.cnblogs.com/asion/p/3339313.html 作者:Asion Tang 出处:http://asiontang.cnblogs.com T ...
- LintCode-Hash Function
In data structure Hash, hash function is used to convert a string(or any other type) into an integer ...
- android重写view和viewgroup的区别
重写view: View类一般用于绘图操作,重写它的onDraw方法,但它不可以包含其他组件,没有addView(View view)方法. 重写viewgroup: ViewGroup是一个组件容器 ...
- 巨大bug
//数据结构关于课程设计--------图书馆管理系统的设计 #include <stdio.h> #include <stdlib.h> #include <strin ...
- Jenkins入门-转
reference : http://www.cnblogs.com/itech/archive/2011/11/23/2260009.html 在网上貌似没有找到Jenkins的中文的太多的文档,有 ...
- dede首页调用栏目内容{dedefield.content}的方法
Dedecms的功能确实很强大,但是dedecms的全局变量有字节限制,使得我们在使用dedecms制作企业站的时候,首页无法调用大段大段的企业站. 其实dedecms还有另外一种调用大段内容的方法, ...
- bzoj 3907: 网格 组合数学
3907: 网格 Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 13 Solved: 7[Submit][Status][Discuss] Descr ...
- .net发送邮件代码示例
下面的代理已经调试过,用的是163的SMTP using System;using System.Collections.Generic;using System.Linq;using System. ...
- 关于vs2010 起始页
vs2010 起始页不显示怎么解决 工具 ---> 选项---->环境---->启动---->启动时(选项框),然后点击框尾的下拉三角按钮,点选"显示起始页" ...
- POJ 1459 Power Network(网络最大流,dinic算法模板题)
题意:给出n,np,nc,m,n为节点数,np为发电站数,nc为用电厂数,m为边的个数. 接下来给出m个数据(u,v)z,表示w(u,v)允许传输的最大电力为z:np个数据(u)z,表示发电 ...