149
unsigned char *getInsertRecord()
154
unsigned char *getUpdateRecord()
93
159
unsigned char *record[2]; /**< Pointer to "records" */
94
unsigned char *insert_values; /* used by INSERT ... UPDATE */
95
KEY *key_info; /**< data of keys in database */
160
std::vector<unsigned char> insert_values; /* used by INSERT ... UPDATE */
161
KeyInfo *key_info; /**< data of keys in database */
96
162
Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
97
163
Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
98
164
Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
100
166
TableList *pos_in_table_list; /* Element referring to this table */
169
const char *getAlias() const
102
174
const char *alias; /**< alias or table name if no alias */
103
176
unsigned char *null_flags;
105
178
uint32_t lock_position; /**< Position in DRIZZLE_LOCK.table */
106
179
uint32_t lock_data_start; /**< Start pos. in DRIZZLE_LOCK.locks */
107
180
uint32_t lock_count; /**< Number of locks */
108
181
uint32_t used_fields;
109
uint32_t status; /* What's in record[0] */
182
uint32_t status; /* What's in getInsertRecord() */
110
183
/* number of select if it is derived table */
111
184
uint32_t derived_select_number;
112
185
int current_lock; /**< Type of lock on table */
241
316
uint32_t quick_key_parts[MAX_KEY];
242
317
uint32_t quick_n_ranges[MAX_KEY];
244
320
memory::Root mem_root;
324
init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
327
memory::Root *getMemRoot()
329
if (not mem_root.alloc_root_inited())
337
void *alloc_root(size_t arg)
339
if (not mem_root.alloc_root_inited())
344
return mem_root.alloc_root(arg);
347
char *strmake_root(const char *str_arg, size_t len_arg)
349
if (not mem_root.alloc_root_inited())
354
return mem_root.strmake_root(str_arg, len_arg);
245
357
filesort_info_st sort;
360
virtual ~Table() { };
249
362
int report_error(int error);
251
364
* Free information allocated by openfrm
253
366
* @param If true if we also want to free table_share
367
* @note this should all be the destructor
255
int closefrm(bool free_share);
369
int delete_table(bool free_share= false);
257
371
void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg);
259
373
/* SHARE methods */
260
374
inline const TableShare *getShare() const { assert(s); return s; } /* Get rid of this long term */
375
inline bool hasShare() const { return s ? true : false ; } /* Get rid of this long term */
376
inline TableShare *getMutableShare() { assert(s); return s; } /* Get rid of this long term */
261
377
inline void setShare(TableShare *new_share) { s= new_share; } /* Get rid of this long term */
262
inline uint32_t sizeKeys() { return s->keys; }
263
inline uint32_t sizeFields() { return s->fields; }
264
inline uint32_t getRecordLength() { return s->reclength; }
378
inline uint32_t sizeKeys() { return s->sizeKeys(); }
379
inline uint32_t sizeFields() { return s->sizeFields(); }
380
inline uint32_t getRecordLength() const { return s->getRecordLength(); }
265
381
inline uint32_t sizeBlobFields() { return s->blob_fields; }
266
inline uint32_t *getBlobField() { return s->blob_field; }
382
inline uint32_t *getBlobField() { return &s->blob_field[0]; }
384
Field_blob *getBlobFieldAt(uint32_t arg) const
386
if (arg < s->blob_fields)
387
return (Field_blob*) field[s->blob_field[arg]]; /*NOTE: Using 'Table.field' NOT SharedTable.field. */
391
inline uint8_t getBlobPtrSize() { return s->blob_ptr_size; }
267
392
inline uint32_t getNullBytes() { return s->null_bytes; }
268
393
inline uint32_t getNullFields() { return s->null_fields; }
269
inline unsigned char *getDefaultValues() { return s->default_values; }
394
inline unsigned char *getDefaultValues() { return s->getDefaultValues(); }
395
inline const char *getSchemaName() const { return s->getSchemaName(); }
396
inline const char *getTableName() const { return s->getTableName(); }
271
398
inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
272
inline bool isNameLock() { return s->name_lock; }
399
inline bool isNameLock() const { return s->isNameLock(); }
273
400
inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
274
inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
276
402
uint32_t index_flags(uint32_t idx) const
278
return s->storage_engine->index_flags(s->key_info[idx].algorithm);
404
return s->storage_engine->index_flags(s->getKeyInfo(idx).algorithm);
281
inline plugin::StorageEngine *getEngine() const /* table_type for handler */
407
inline plugin::StorageEngine *getEngine() const /* table_type for handler */
283
409
return s->storage_engine;
286
Cursor &getCursor() const /* table_type for handler */
412
Cursor &getCursor() const /* table_type for handler */
292
418
/* For TMP tables, should be pulled out as a class */
293
void updateCreateInfo(message::Table *table_proto);
294
419
void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
295
bool create_myisam_tmp_table(KEY *keyinfo,
420
bool create_myisam_tmp_table(KeyInfo *keyinfo,
296
421
MI_COLUMNDEF *start_recinfo,
297
422
MI_COLUMNDEF **recinfo,
298
423
uint64_t options);
510
634
return output; // for multiple << operators.
638
bool is_placeholder_created;
643
return is_placeholder_created;
515
Table *create_virtual_tmp_table(Session *session, List<CreateField> &field_list);
517
typedef struct st_foreign_key_info
652
* This class defines the information for foreign keys.
519
LEX_STRING *forein_id;
520
LEX_STRING *referenced_db;
521
LEX_STRING *referenced_table;
522
LEX_STRING *update_method;
523
LEX_STRING *delete_method;
524
LEX_STRING *referenced_key_name;
525
List<LEX_STRING> foreign_fields;
526
List<LEX_STRING> referenced_fields;
659
* This is the constructor with all properties set.
661
* @param[in] in_foreign_id The id of the foreign key
662
* @param[in] in_referenced_db The referenced database name of the foreign key
663
* @param[in] in_referenced_table The referenced table name of the foreign key
664
* @param[in] in_update_method The update method of the foreign key.
665
* @param[in] in_delete_method The delete method of the foreign key.
666
* @param[in] in_referenced_key_name The name of referenced key
667
* @param[in] in_foreign_fields The foreign fields
668
* @param[in] in_referenced_fields The referenced fields
670
ForeignKeyInfo(LEX_STRING *in_foreign_id,
671
LEX_STRING *in_referenced_db,
672
LEX_STRING *in_referenced_table,
673
LEX_STRING *in_update_method,
674
LEX_STRING *in_delete_method,
675
LEX_STRING *in_referenced_key_name,
676
List<LEX_STRING> in_foreign_fields,
677
List<LEX_STRING> in_referenced_fields)
679
foreign_id(in_foreign_id),
680
referenced_db(in_referenced_db),
681
referenced_table(in_referenced_table),
682
update_method(in_update_method),
683
delete_method(in_delete_method),
684
referenced_key_name(in_referenced_key_name),
685
foreign_fields(in_foreign_fields),
686
referenced_fields(in_referenced_fields)
691
* This is the default constructor. All properties are set to default values for their types.
694
: foreign_id(NULL), referenced_db(NULL), referenced_table(NULL),
695
update_method(NULL), delete_method(NULL), referenced_key_name(NULL)
700
* Gets the foreign id.
702
* @ retval the foreign id
704
const LEX_STRING *getForeignId() const
711
* Gets the name of the referenced database.
713
* @ retval the name of the referenced database
715
const LEX_STRING *getReferencedDb() const
717
return referenced_db;
722
* Gets the name of the referenced table.
724
* @ retval the name of the referenced table
726
const LEX_STRING *getReferencedTable() const
728
return referenced_table;
733
* Gets the update method.
735
* @ retval the update method
737
const LEX_STRING *getUpdateMethod() const
739
return update_method;
744
* Gets the delete method.
746
* @ retval the delete method
748
const LEX_STRING *getDeleteMethod() const
750
return delete_method;
755
* Gets the name of the referenced key.
757
* @ retval the name of the referenced key
759
const LEX_STRING *getReferencedKeyName() const
761
return referenced_key_name;
766
* Gets the foreign fields.
768
* @ retval the foreign fields
770
const List<LEX_STRING> &getForeignFields() const
772
return foreign_fields;
777
* Gets the referenced fields.
779
* @ retval the referenced fields
781
const List<LEX_STRING> &getReferencedFields() const
783
return referenced_fields;
789
LEX_STRING *foreign_id;
791
* The name of the reference database.
793
LEX_STRING *referenced_db;
795
* The name of the reference table.
797
LEX_STRING *referenced_table;
801
LEX_STRING *update_method;
805
LEX_STRING *delete_method;
807
* The name of the referenced key.
809
LEX_STRING *referenced_key_name;
811
* The foreign fields.
813
List<LEX_STRING> foreign_fields;
815
* The referenced fields.
817
List<LEX_STRING> referenced_fields;
533
#define JOIN_TYPE_LEFT 1
534
#define JOIN_TYPE_RIGHT 2
822
#define JOIN_TYPE_LEFT 1
823
#define JOIN_TYPE_RIGHT 2
537
826
class select_union;
554
TableShare *alloc_table_share(TableList *table_list, char *key,
555
uint32_t key_length);
556
int open_table_def(Session& session, TableIdentifier &identifier, TableShare *share);
557
void open_table_error(TableShare *share, int error, int db_errno, int errarg);
558
int open_table_from_share(Session *session, TableShare *share, const char *alias,
559
uint32_t db_stat, uint32_t ha_open_flags,
561
843
void free_blobs(Table *table);
562
844
int set_zone(int nr,int min_zone,int max_zone);
563
845
uint32_t convert_period_to_month(uint32_t period);