57
57
typedef std::vector<std::string> StringVector;
59
TableShare(TableIdentifier::Type type_arg= message::Table::STANDARD);
59
TableShare(TableIdentifier::Type type_arg);
61
TableShare(TableIdentifier &identifier, const TableIdentifier::Key &key); // Used by placeholder
63
TableShare(TableIdentifier &identifier); // Just used during createTable()
61
65
TableShare(TableIdentifier::Type type_arg,
64
const char *new_table_name,
65
const char *new_path);
67
TableShare(TableIdentifier &identifier);
69
TableShare(TableIdentifier::Type type_arg, char *key, uint32_t key_length, char *path_arg= NULL, uint32_t path_length_arg= 0);
66
TableIdentifier &identifier,
67
char *path_arg= NULL, uint32_t path_length_arg= 0); // Shares for cache
274
272
To ensure this one can use set_table_cache() methods.
277
LEX_STRING table_cache_key; /* Pointer to db */
275
TableIdentifier::Key private_key_for_cache; // This will not exist in the final design.
276
std::vector<char> private_normalized_path; // This will not exist in the final design.
278
277
LEX_STRING db; /* Pointer to db */
279
278
LEX_STRING table_name; /* Table name (for open) */
280
279
LEX_STRING path; /* Path to table (from datadir) */
294
const char *getCacheKey() const
293
const char *getCacheKey() const // This should never be called when we aren't looking at a cache.
296
return table_cache_key.str;
295
assert(private_key_for_cache.size());
296
return &private_key_for_cache[0];
299
299
size_t getCacheKeySize() const
301
return table_cache_key.length;
301
return private_key_for_cache.size();
304
304
void setPath(char *str_arg, uint32_t size_arg)
537
532
* only supports a single-column primary key. Is there a better way
538
533
* to ask for the fields which are in a primary key?
540
536
uint32_t primary_key;
539
uint32_t getPrimaryKey() const
544
bool hasPrimaryKey() const
546
return primary_key != MAX_KEY;
541
549
/* Index of auto-updated TIMESTAMP field in field array */
542
550
uint32_t next_number_index; /* autoincrement key number */
543
551
uint32_t next_number_key_offset; /* autoinc keypart offset in a key */
594
Set share's table cache key and update its db and table name appropriately.
602
Set share's identifier information.
597
set_table_cache_key()
598
key_buff Buffer with already built table cache key to be
599
referenced from share.
600
key_length Key length.
603
Since 'key_buff' buffer will be referenced from share it should has same
604
life-time as share itself.
605
This method automatically ensures that TableShare::table_name/db have
606
appropriate values by using table cache key as their source.
609
void set_table_cache_key(char *key_buff, uint32_t key_length, uint32_t db_length= 0, uint32_t table_name_length= 0)
611
table_cache_key.str= key_buff;
612
table_cache_key.length= key_length;
614
Let us use the fact that the key is "db/0/table_name/0" + optional
615
part for temporary tables.
617
db.str= table_cache_key.str;
618
db.length= db_length ? db_length : strlen(db.str);
619
table_name.str= db.str + db.length + 1;
620
table_name.length= table_name_length ? table_name_length :strlen(table_name.str);
610
void setIdentifier(TableIdentifier &identifier_arg);
623
612
inline bool honor_global_locks()
639
628
path Path to table (possible in lower case)
642
This is different from alloc_table_share() because temporary tables
643
don't have to be shared between threads or put into the table def
644
cache, so we can do some things notable simpler and faster
646
If table is not put in session->temporary_tables (happens only when
647
one uses OPEN TEMPORARY) then one can specify 'db' as key and
648
use key_length= 0 as neither table_cache_key or key_length will be used).
657
635
void init(const char *new_table_name,
658
const char *new_path)
660
init("", 0, new_table_name, new_path);
663
void init(const char *key,
664
uint32_t key_length, const char *new_table_name,
665
636
const char *new_path);
668
639
void open_table_error(int pass_error, int db_errno, int pass_errarg);
671
Create a table cache key
675
key Create key here (must be of size MAX_DBKEY_LENGTH)
676
table_list Table definition
679
The table cache_key is created from:
683
if the table is a tmp table, we add the following to make each tmp table
686
4 bytes for master thread id
687
4 bytes pseudo thread id
692
static inline uint32_t createKey(char *key, const char *db_arg, const char *table_name_arg)
697
key_pos= strcpy(key_pos, db_arg) + strlen(db_arg);
698
key_pos= strcpy(key_pos+1, table_name_arg) +
699
strlen(table_name_arg);
700
key_length= (uint32_t)(key_pos-key)+1;
705
static inline uint32_t createKey(char *key, TableIdentifier &identifier)
710
key_pos= strcpy(key_pos, identifier.getSchemaName().c_str()) + identifier.getSchemaName().length();
711
key_pos= strcpy(key_pos + 1, identifier.getTableName().c_str()) + identifier.getTableName().length();
712
key_length= (uint32_t)(key_pos-key)+1;
717
641
static void cacheStart(void);
718
642
static void cacheStop(void);
719
643
static void release(TableShare *share);
720
static void release(const char *key, uint32_t key_length);
721
static TableDefinitionCache &getCache();
644
static void release(TableIdentifier &identifier);
645
static const TableDefinitionCache &getCache();
722
646
static TableShare *getShare(TableIdentifier &identifier);
723
static TableShare *getShare(Session *session,
724
char *key, uint32_t key_length, int *error);
647
static TableShare *getShareCreate(Session *session,
648
TableIdentifier &identifier,
726
651
friend std::ostream& operator<<(std::ostream& output, const TableShare &share)