42
32
#include <drizzled/field/double.h>
43
33
#include <drizzled/unireg.h>
44
34
#include <drizzled/message/table.pb.h>
45
#include "drizzled/sql_table.h"
46
#include "drizzled/charset.h"
47
#include "drizzled/internal/m_string.h"
48
#include "plugin/myisam/myisam.h"
50
36
#include <drizzled/item/string.h>
51
37
#include <drizzled/item/int.h>
52
38
#include <drizzled/item/decimal.h>
53
39
#include <drizzled/item/float.h>
54
40
#include <drizzled/item/null.h>
55
#include <drizzled/temporal.h>
57
#include "drizzled/table_proto.h"
42
#include <drizzled/table_proto.h>
59
49
using namespace std;
64
extern pid_t current_pid;
65
extern plugin::StorageEngine *heap_engine;
66
extern plugin::StorageEngine *myisam_engine;
68
/* Functions defined in this cursor */
50
using namespace drizzled;
52
/* Functions defined in this file */
70
54
void open_table_error(TableShare *share, int error, int db_errno,
71
55
myf errortype, int errarg);
97
127
TableShare *alloc_table_share(TableList *table_list, char *key,
98
128
uint32_t key_length)
100
memory::Root mem_root;
101
131
TableShare *share;
102
132
char *key_buff, *path_buff;
105
build_table_filename(path, table_list->db, table_list->table_name, false);
107
memory::init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
133
char path[FN_REFLEN];
134
uint32_t path_length;
136
path_length= build_table_filename(path, sizeof(path) - 1,
138
table_list->table_name, false);
139
init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
108
140
if (multi_alloc_root(&mem_root,
109
141
&share, sizeof(*share),
110
142
&key_buff, key_length,
111
&path_buff, path.length() + 1,
143
&path_buff, path_length + 1,
114
146
memset(share, 0, sizeof(*share));
116
148
share->set_table_cache_key(key_buff, key, key_length);
118
share->path.str= path_buff,
119
share->path.length= path.length();
120
strcpy(share->path.str, path.c_str());
150
share->path.str= path_buff;
151
share->path.length= path_length;
152
strcpy(share->path.str, path);
121
153
share->normalized_path.str= share->path.str;
122
share->normalized_path.length= path.length();
154
share->normalized_path.length= path_length;
124
156
share->version= refresh_version;
355
387
message::Table::Index::IndexOptions indx_options= indx.options();
356
388
if (indx_options.pack_key())
357
keyinfo->flags|= HA_PACK_KEY;
389
keyinfo->flags|= HA_PACK_KEY;
359
391
if (indx_options.var_length_key())
360
keyinfo->flags|= HA_VAR_LENGTH_PART;
392
keyinfo->flags|= HA_VAR_LENGTH_PART;
362
394
if (indx_options.null_part_key())
363
keyinfo->flags|= HA_NULL_PART_KEY;
395
keyinfo->flags|= HA_NULL_PART_KEY;
365
397
if (indx_options.binary_pack_key())
366
keyinfo->flags|= HA_BINARY_PACK_KEY;
398
keyinfo->flags|= HA_BINARY_PACK_KEY;
368
400
if (indx_options.has_partial_segments())
369
keyinfo->flags|= HA_KEY_HAS_PART_KEY_SEG;
401
keyinfo->flags|= HA_KEY_HAS_PART_KEY_SEG;
371
403
if (indx_options.auto_generated_key())
372
keyinfo->flags|= HA_GENERATED_KEY;
404
keyinfo->flags|= HA_GENERATED_KEY;
374
406
if (indx_options.has_key_block_size())
376
keyinfo->flags|= HA_USES_BLOCK_SIZE;
377
keyinfo->block_size= indx_options.key_block_size();
408
keyinfo->flags|= HA_USES_BLOCK_SIZE;
409
keyinfo->block_size= indx_options.key_block_size();
381
keyinfo->block_size= 0;
413
keyinfo->block_size= 0;
387
420
case message::Table::Index::UNKNOWN_INDEX:
388
421
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
498
549
case DRIZZLE_TYPE_BLOB:
499
550
case DRIZZLE_TYPE_VARCHAR:
501
message::Table::Field::StringFieldOptions field_options= pfield.string_options();
503
const CHARSET_INFO *cs= get_charset(field_options.has_collation_id() ?
504
field_options.collation_id() : 0);
507
cs= default_charset_info;
509
field_pack_length[fieldnr]= calc_pack_length(drizzle_field_type,
510
field_options.length() * cs->mbmaxlen);
552
message::Table::Field::StringFieldOptions field_options=
553
pfield.string_options();
555
const CHARSET_INFO *cs= get_charset(field_options.has_collation_id()?
556
field_options.collation_id() : 0);
559
cs= default_charset_info;
561
field_pack_length[fieldnr]=
562
calc_pack_length(drizzle_field_type,
563
field_options.length() * cs->mbmaxlen);
513
567
case DRIZZLE_TYPE_ENUM:
515
message::Table::Field::EnumerationValues field_options= pfield.enumeration_values();
517
field_pack_length[fieldnr]=
518
get_enum_pack_length(field_options.field_value_size());
521
interval_parts+= field_options.field_value_size();
569
message::Table::Field::SetFieldOptions field_options=
570
pfield.set_options();
572
field_pack_length[fieldnr]=
573
get_enum_pack_length(field_options.field_value_size());
576
interval_parts+= field_options.field_value_size();
524
case DRIZZLE_TYPE_DECIMAL:
579
case DRIZZLE_TYPE_NEWDECIMAL:
526
message::Table::Field::NumericFieldOptions fo= pfield.numeric_options();
528
field_pack_length[fieldnr]= my_decimal_get_binary_size(fo.precision(), fo.scale());
581
message::Table::Field::NumericFieldOptions fo= pfield.numeric_options();
582
field_pack_length[fieldnr]=
583
my_decimal_get_binary_size(fo.precision(), fo.scale());
698
748
Field::utype unireg_type= Field::NONE;
700
if (pfield.has_numeric_options() &&
701
pfield.numeric_options().is_autoincrement())
750
if (pfield.has_numeric_options()
751
&& pfield.numeric_options().is_autoincrement())
703
753
unireg_type= Field::NEXT_NUMBER;
706
if (pfield.has_options() &&
707
pfield.options().has_default_value() &&
708
pfield.options().default_value().compare("NOW()") == 0)
756
if (pfield.has_options()
757
&& pfield.options().has_default_value()
758
&& pfield.options().default_value().compare("NOW()") == 0)
710
if (pfield.options().has_update_value() &&
711
pfield.options().update_value().compare("NOW()") == 0)
760
if (pfield.options().has_update_value()
761
&& pfield.options().update_value().compare("NOW()") == 0)
713
unireg_type= Field::TIMESTAMP_DNUN_FIELD;
763
unireg_type= Field::TIMESTAMP_DNUN_FIELD;
715
else if (! pfield.options().has_update_value())
765
else if (!pfield.options().has_update_value())
717
unireg_type= Field::TIMESTAMP_DN_FIELD;
767
unireg_type= Field::TIMESTAMP_DN_FIELD;
720
assert(1); // Invalid update value.
770
assert(1); // Invalid update value.
722
else if (pfield.has_options() &&
723
pfield.options().has_update_value() &&
724
pfield.options().update_value().compare("NOW()") == 0)
772
else if (pfield.has_options()
773
&& pfield.options().has_update_value()
774
&& pfield.options().update_value().compare("NOW()") == 0)
726
776
unireg_type= Field::TIMESTAMP_UN_FIELD;
748
798
const CHARSET_INFO *charset= &my_charset_bin;
750
if (field_type == DRIZZLE_TYPE_BLOB ||
751
field_type == DRIZZLE_TYPE_VARCHAR)
753
message::Table::Field::StringFieldOptions field_options= pfield.string_options();
755
charset= get_charset(field_options.has_collation_id() ?
756
field_options.collation_id() : 0);
759
charset= default_charset_info;
762
if (field_type == DRIZZLE_TYPE_ENUM)
764
message::Table::Field::EnumerationValues field_options= pfield.enumeration_values();
766
charset= get_charset(field_options.has_collation_id()?
767
field_options.collation_id() : 0);
770
charset= default_charset_info;
774
if (field_type == DRIZZLE_TYPE_DECIMAL
775
|| field_type == DRIZZLE_TYPE_DOUBLE)
777
message::Table::Field::NumericFieldOptions fo= pfield.numeric_options();
779
if (! pfield.has_numeric_options() || ! fo.has_scale())
782
We don't write the default to table proto so
783
if no decimals specified for DOUBLE, we use the default.
785
decimals= NOT_FIXED_DEC;
789
if (fo.scale() > DECIMAL_MAX_SCALE)
794
decimals= static_cast<uint8_t>(fo.scale());
800
if (field_type==DRIZZLE_TYPE_BLOB
801
|| field_type==DRIZZLE_TYPE_VARCHAR)
803
message::Table::Field::StringFieldOptions field_options=
804
pfield.string_options();
806
charset= get_charset(field_options.has_collation_id()?
807
field_options.collation_id() : 0);
810
charset= default_charset_info;
814
if (field_type==DRIZZLE_TYPE_ENUM)
816
message::Table::Field::SetFieldOptions field_options=
817
pfield.set_options();
819
charset= get_charset(field_options.has_collation_id()?
820
field_options.collation_id() : 0);
823
charset= default_charset_info;
798
827
Item *default_value= NULL;
800
if (pfield.options().has_default_value() ||
801
pfield.options().has_default_null() ||
802
pfield.options().has_default_bin_value())
829
if (pfield.options().has_default_value()
830
|| pfield.options().has_default_null()
831
|| pfield.options().has_default_bin_value())
804
833
default_value= default_value_item(field_type,
806
pfield.options().default_null(),
807
&pfield.options().default_value(),
808
&pfield.options().default_bin_value());
835
pfield.options().default_null(),
836
&pfield.options().default_value(),
837
&pfield.options().default_bin_value());
840
uint32_t pack_flag= pfield.pack_flag(); /* TODO: MUST DIE */
812
842
Table temp_table; /* Use this so that BLOB DEFAULT '' works */
813
843
memset(&temp_table, 0, sizeof(temp_table));
814
844
temp_table.s= share;
815
temp_table.in_use= &session;
816
temp_table.s->db_low_byte_first= true; //Cursor->low_byte_first();
845
temp_table.in_use= session;
846
temp_table.s->db_low_byte_first= 1; //handler->low_byte_first();
817
847
temp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
819
uint32_t field_length= 0; //Assignment is for compiler complaint.
823
case DRIZZLE_TYPE_BLOB:
824
case DRIZZLE_TYPE_VARCHAR:
826
message::Table::Field::StringFieldOptions field_options= pfield.string_options();
828
charset= get_charset(field_options.has_collation_id() ?
829
field_options.collation_id() : 0);
832
charset= default_charset_info;
834
field_length= field_options.length() * charset->mbmaxlen;
837
case DRIZZLE_TYPE_DOUBLE:
839
message::Table::Field::NumericFieldOptions fo= pfield.numeric_options();
840
if (!fo.has_precision() && !fo.has_scale())
842
field_length= DBL_DIG+7;
846
field_length= fo.precision();
848
if (field_length < decimals &&
849
decimals != NOT_FIXED_DEC)
851
my_error(ER_M_BIGGER_THAN_D, MYF(0), pfield.name().c_str());
857
case DRIZZLE_TYPE_DECIMAL:
859
message::Table::Field::NumericFieldOptions fo= pfield.numeric_options();
861
field_length= my_decimal_precision_to_length(fo.precision(), fo.scale(),
865
case DRIZZLE_TYPE_TIMESTAMP:
866
case DRIZZLE_TYPE_DATETIME:
867
field_length= DateTime::MAX_STRING_LENGTH;
869
case DRIZZLE_TYPE_DATE:
870
field_length= Date::MAX_STRING_LENGTH;
872
case DRIZZLE_TYPE_ENUM:
876
message::Table::Field::EnumerationValues fo= pfield.enumeration_values();
878
for (int valnr= 0; valnr < fo.field_value_size(); valnr++)
880
if (fo.field_value(valnr).length() > field_length)
882
field_length= charset->cset->numchars(charset,
883
fo.field_value(valnr).c_str(),
884
fo.field_value(valnr).c_str()
885
+ fo.field_value(valnr).length())
891
case DRIZZLE_TYPE_LONG:
893
uint32_t sign_len= pfield.constraints().is_unsigned() ? 0 : 1;
894
field_length= MAX_INT_WIDTH+sign_len;
897
case DRIZZLE_TYPE_LONGLONG:
898
field_length= MAX_BIGINT_WIDTH;
900
case DRIZZLE_TYPE_NULL:
901
abort(); // Programming error
904
Field* f= make_field(share,
906
record + field_offsets[fieldnr] + data_offset,
908
pfield.constraints().is_nullable(),
914
(Field::utype) MTYP_TYPENR(unireg_type),
915
((field_type == DRIZZLE_TYPE_ENUM) ?
916
share->intervals + (interval_nr++)
918
share->fieldnames.type_names[fieldnr]);
849
Field* f= make_field(share, &share->mem_root,
850
record+field_offsets[fieldnr]+data_offset,
851
pfield.options().length(),
857
(Field::utype) MTYP_TYPENR(unireg_type),
858
((field_type==DRIZZLE_TYPE_ENUM)?
859
share->intervals+(interval_nr++)
861
share->fieldnames.type_names[fieldnr]);
920
863
share->field[fieldnr]= f;
922
865
f->init(&temp_table); /* blob default values need table obj */
924
if (! (f->flags & NOT_NULL_FLAG))
867
if (!(f->flags & NOT_NULL_FLAG))
926
869
*f->null_ptr|= f->null_bit;
927
if (! (null_bit_pos= (null_bit_pos + 1) & 7)) /* @TODO Ugh. */
870
if (!(null_bit_pos= (null_bit_pos + 1) & 7))
932
875
if (default_value)
934
enum_check_fields old_count_cuted_fields= session.count_cuted_fields;
935
session.count_cuted_fields= CHECK_FIELD_WARN;
877
enum_check_fields old_count_cuted_fields= session->count_cuted_fields;
878
session->count_cuted_fields= CHECK_FIELD_WARN;
936
879
int res= default_value->save_in_field(f, 1);
937
session.count_cuted_fields= old_count_cuted_fields;
938
if (res != 0 && res != 3) /* @TODO Huh? */
880
session->count_cuted_fields= old_count_cuted_fields;
881
if (res != 0 && res != 3)
940
883
my_error(ER_INVALID_DEFAULT, MYF(0), f->field_name);
945
888
else if (f->real_type() == DRIZZLE_TYPE_ENUM &&
946
(f->flags & NOT_NULL_FLAG))
889
(f->flags & NOT_NULL_FLAG))
948
891
f->set_notnull();
949
892
f->store((int64_t) 1, true);
1003
942
if (null_count & 7)
1004
943
*(record + null_count / 8)|= ~(((unsigned char) 1 << (null_count & 7)) - 1);
1006
share->null_bytes= (null_pos - (unsigned char*) record + (null_bit_pos + 7) / 8);
945
share->null_bytes= (null_pos - (unsigned char*) record +
946
(null_bit_pos + 7) / 8);
1008
948
share->last_null_bit_pos= null_bit_pos;
1010
950
free(field_offsets);
1011
field_offsets= NULL;
1012
951
free(field_pack_length);
1013
field_pack_length= NULL;
953
if (!(handler_file= get_new_handler(share, session->mem_root,
1015
957
/* Fix key stuff */
1016
958
if (share->key_parts)
1018
uint32_t primary_key= (uint32_t) (find_type((char*) "PRIMARY",
1019
&share->keynames, 3) - 1); /* @TODO Huh? */
960
uint32_t primary_key=(uint32_t) (find_type((char*) "PRIMARY",
961
&share->keynames, 3) - 1);
963
int64_t ha_option= handler_file->ha_table_flags();
1021
965
keyinfo= share->key_info;
1022
966
key_part= keyinfo->key_part;
1024
for (uint32_t key= 0; key < share->keys; key++,keyinfo++)
968
for (uint32_t key= 0 ; key < share->keys ; key++,keyinfo++)
1026
970
uint32_t usable_parts= 0;
1028
972
if (primary_key >= MAX_KEY && (keyinfo->flags & HA_NOSAME))
1031
If the UNIQUE key doesn't have NULL columns and is not a part key
1032
declare this as a primary key.
1035
for (uint32_t i= 0; i < keyinfo->key_parts; i++)
1037
uint32_t fieldnr= key_part[i].fieldnr;
1039
share->field[fieldnr-1]->null_ptr ||
1040
share->field[fieldnr-1]->key_length() != key_part[i].length)
1042
primary_key= MAX_KEY; // Can't be used
975
If the UNIQUE key doesn't have NULL columns and is not a part key
976
declare this as a primary key.
979
for (uint32_t i= 0 ; i < keyinfo->key_parts ;i++)
981
uint32_t fieldnr= key_part[i].fieldnr;
983
share->field[fieldnr-1]->null_ptr ||
984
share->field[fieldnr-1]->key_length() !=
987
primary_key=MAX_KEY; // Can't be used
1048
993
for (uint32_t i= 0 ; i < keyinfo->key_parts ; key_part++,i++)
1051
if (! key_part->fieldnr)
996
if (!key_part->fieldnr)
1053
abort(); // goto err;
998
// error= 4; // Wrong file
999
abort(); // goto err;
1055
1001
field= key_part->field= share->field[key_part->fieldnr-1];
1056
1002
key_part->type= field->key_type();
1122
1067
set_if_bigger(share->max_key_length,keyinfo->key_length+
1123
1068
keyinfo->key_parts);
1124
1069
share->total_key_length+= keyinfo->key_length;
1126
if (keyinfo->flags & HA_NOSAME)
1071
MERGE tables do not have unique indexes. But every key could be
1072
an unique index on the underlying MyISAM table. (Bug #10400)
1074
if ((keyinfo->flags & HA_NOSAME) ||
1075
(ha_option & HA_ANY_INDEX_MAY_BE_UNIQUE))
1128
1076
set_if_bigger(share->max_unique_length,keyinfo->key_length);
1131
1078
if (primary_key < MAX_KEY &&
1132
(share->keys_in_use.test(primary_key)))
1079
(share->keys_in_use.test(primary_key)))
1134
1081
share->primary_key= primary_key;
1136
If we are using an integer as the primary key then allow the user to
1137
refer to it as '_rowid'
1083
If we are using an integer as the primary key then allow the user to
1084
refer to it as '_rowid'
1139
1086
if (share->key_info[primary_key].key_parts == 1)
1141
Field *field= share->key_info[primary_key].key_part[0].field;
1142
if (field && field->result_type() == INT_RESULT)
1088
Field *field= share->key_info[primary_key].key_part[0].field;
1089
if (field && field->result_type() == INT_RESULT)
1144
1091
/* note that fieldnr here (and rowid_field_offset) starts from 1 */
1145
share->rowid_field_offset= (share->key_info[primary_key].key_part[0].
1092
share->rowid_field_offset= (share->key_info[primary_key].key_part[0].
1151
1099
share->primary_key = MAX_KEY; // we do not have a primary key
1560
void Table::resetTable(Session *session,
1562
uint32_t db_stat_arg)
1575
db_stat= db_stat_arg;
1578
record[0]= (unsigned char *) NULL;
1579
record[1]= (unsigned char *) NULL;
1581
insert_values= NULL;
1583
next_number_field= NULL;
1584
found_next_number_field= NULL;
1585
timestamp_field= NULL;
1587
pos_in_table_list= NULL;
1597
derived_select_number= 0;
1598
current_lock= F_UNLCK;
1612
open_placeholder= false;
1613
locked_by_name= false;
1616
auto_increment_field_not_null= false;
1617
alias_name_used= false;
1620
quick_condition_rows= 0;
1622
timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
1627
covering_keys.reset();
1632
keys_in_use_for_query.reset();
1633
keys_in_use_for_group_by.reset();
1634
keys_in_use_for_order_by.reset();
1636
memset(quick_rows, 0, sizeof(ha_rows) * MAX_KEY);
1637
memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY);
1639
memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY);
1640
memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY);
1642
memory::init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
1643
memset(&sort, 0, sizeof(filesort_info_st));
1648
1523
/* Deallocate temporary blob storage */
1650
1525
void free_blobs(register Table *table)
2636
2564
/* If result table is small; use a heap */
2637
2565
/* future: storage engine selection can be made dynamic? */
2638
2566
if (blob_count || using_unique_constraint ||
2639
(select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) == OPTION_BIG_TABLES)
2567
(select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) ==
2568
OPTION_BIG_TABLES || (select_options & TMP_TABLE_FORCE_MYISAM))
2641
2570
share->storage_engine= myisam_engine;
2642
table->cursor= share->db_type()->getCursor(*share, &table->mem_root);
2571
table->file= get_new_handler(share, &table->mem_root,
2644
(param->group_parts > table->cursor->getEngine()->max_key_parts() ||
2645
param->group_length > table->cursor->getEngine()->max_key_length()))
2646
using_unique_constraint= true;
2574
(param->group_parts > table->file->max_key_parts() ||
2575
param->group_length > table->file->max_key_length()))
2576
using_unique_constraint=1;
2650
2580
share->storage_engine= heap_engine;
2651
table->cursor= share->db_type()->getCursor(*share, &table->mem_root);
2581
table->file= get_new_handler(share, &table->mem_root,
2653
if (! table->cursor)
2657
if (! using_unique_constraint)
2588
if (!using_unique_constraint)
2658
2589
reclength+= group_null_items; // null flag is stored separately
2660
2591
share->blob_fields= blob_count;
3350
3275
if (new_table.open_tmp_table())
3352
if (table->cursor->indexes_are_disabled())
3353
new_table.cursor->ha_disable_indexes(HA_KEY_SWITCH_ALL);
3354
table->cursor->ha_index_or_rnd_end();
3355
table->cursor->ha_rnd_init(1);
3277
if (table->file->indexes_are_disabled())
3278
new_table.file->ha_disable_indexes(HA_KEY_SWITCH_ALL);
3279
table->file->ha_index_or_rnd_end();
3280
table->file->ha_rnd_init(1);
3356
3281
if (table->no_rows)
3358
new_table.cursor->extra(HA_EXTRA_NO_ROWS);
3283
new_table.file->extra(HA_EXTRA_NO_ROWS);
3359
3284
new_table.no_rows=1;
3362
3287
/* HA_EXTRA_WRITE_CACHE can stay until close, no need to disable it */
3363
new_table.cursor->extra(HA_EXTRA_WRITE_CACHE);
3288
new_table.file->extra(HA_EXTRA_WRITE_CACHE);
3366
3291
copy all old rows from heap table to MyISAM table
3367
3292
This is the only code that uses record[1] to read/write but this
3368
3293
is safe as this is a temporary MyISAM table without timestamp/autoincrement.
3370
while (!table->cursor->rnd_next(new_table.record[1]))
3295
while (!table->file->rnd_next(new_table.record[1]))
3372
write_err= new_table.cursor->ha_write_row(new_table.record[1]);
3297
write_err= new_table.file->ha_write_row(new_table.record[1]);
3376
3301
/* copy row that filled HEAP table */
3377
if ((write_err=new_table.cursor->ha_write_row(table->record[0])))
3302
if ((write_err=new_table.file->ha_write_row(table->record[0])))
3379
if (new_table.cursor->is_fatal_error(write_err, HA_CHECK_DUP) ||
3304
if (new_table.file->is_fatal_error(write_err, HA_CHECK_DUP) ||
3380
3305
!ignore_last_dupp_key_error)
3384
3309
/* remove heap table and change to use myisam table */
3385
(void) table->cursor->ha_rnd_end();
3386
(void) table->cursor->close(); // This deletes the table !
3387
delete table->cursor;
3388
table->cursor= NULL;
3310
(void) table->file->ha_rnd_end();
3311
(void) table->file->close(); // This deletes the table !
3389
3314
new_table.s= table->s; // Keep old share
3390
3315
*table= new_table;
3391
3316
*table->s= share;
3393
table->cursor->change_table_ptr(table, table->s);
3318
table->file->change_table_ptr(table, table->s);
3394
3319
table->use_all_columns();
3395
3320
if (save_proc_info)
3546
3466
memset(null_flags, 255, s->null_bytes);
3560
insert_values(NULL),
3562
next_number_field(NULL),
3563
found_next_number_field(NULL),
3564
timestamp_field(NULL),
3565
pos_in_table_list(NULL),
3574
derived_select_number(0),
3575
current_lock(F_UNLCK),
3585
open_placeholder(false),
3586
locked_by_name(false),
3588
auto_increment_field_not_null(false),
3589
alias_name_used(false),
3591
quick_condition_rows(0),
3592
timestamp_field_type(TIMESTAMP_NO_AUTO_SET),
3595
record[0]= (unsigned char *) 0;
3596
record[1]= (unsigned char *) 0;
3598
covering_keys.reset();
3603
keys_in_use_for_query.reset();
3604
keys_in_use_for_group_by.reset();
3605
keys_in_use_for_order_by.reset();
3607
memset(quick_rows, 0, sizeof(ha_rows) * MAX_KEY);
3608
memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY);
3610
memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY);
3611
memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY);
3613
memory::init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
3614
memset(&sort, 0, sizeof(filesort_info_st));
3617
3469
/*****************************************************************************
3618
3470
The different ways to read a record
3619
3471
Returns -1 if row was not found, 0 if row was found and 1 on errors
3620
3472
*****************************************************************************/
3622
/** Help function when we get some an error from the table Cursor. */
3474
/** Help function when we get some an error from the table handler. */
3624
3476
int Table::report_error(int error)