Commit 949de544 authored by monty@mysql.com's avatar monty@mysql.com

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/my/mysql-4.1
parents ce5caec1 db7efa27
......@@ -72,7 +72,7 @@ public:
return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_NO_AUTO_INCREMENT |
HA_FILE_BASED);
}
ulong index_flags(uint idx, uint part) const
ulong index_flags(uint idx, uint part, bool all_parts) const
{
return 0;
}
......
......@@ -69,12 +69,16 @@ public:
return 0;
}
/*
This is a list of flags that says how the storage engine
This is a bitmap of flags that says how the storage engine
implements indexes. The current index flags are documented in
handler.h. If you do not implement indexes, just return zero
here.
part is the key part to check. First key part is 0
If all_parts it's set, MySQL want to know the flags for the combined
index up to and including 'part'.
*/
ulong index_flags(uint inx, uint part) const
ulong index_flags(uint inx, uint part, bool all_parts) const
{
return 0;
}
......
......@@ -431,9 +431,9 @@ void Field::store_time(TIME *ltime,timestamp_type type)
}
bool Field::optimize_range(uint idx)
bool Field::optimize_range(uint idx, uint part)
{
return test(table->file->index_flags(idx) & HA_READ_RANGE);
return test(table->file->index_flags(idx, part, 1) & HA_READ_RANGE);
}
/****************************************************************************
......
......@@ -178,7 +178,7 @@ public:
inline bool real_maybe_null(void) { return null_ptr != 0; }
virtual void make_field(Send_field *)=0;
virtual void sort_string(char *buff,uint length)=0;
virtual bool optimize_range(uint idx);
virtual bool optimize_range(uint idx, uint part);
virtual bool store_for_compare() { return 0; }
virtual void free() {}
Field *new_field(MEM_ROOT *root, struct st_table *new_table)
......@@ -1134,7 +1134,7 @@ public:
uint size_of() const { return sizeof(*this); }
enum_field_types real_type() const { return FIELD_TYPE_ENUM; }
virtual bool zero_pack() const { return 0; }
bool optimize_range(uint idx) { return 0; }
bool optimize_range(uint idx, uint part) { return 0; }
bool eq_def(Field *field);
bool has_charset(void) const { return TRUE; }
field_cast_enum field_cast_type() { return FIELD_CAST_ENUM; }
......
......@@ -340,6 +340,23 @@ const char **ha_berkeley::bas_ext() const
{ static const char *ext[]= { ha_berkeley_ext, NullS }; return ext; }
ulong ha_berkeley::index_flags(uint idx, uint part, bool all_parts) const
{
ulong flags= (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_KEYREAD_ONLY
| HA_READ_RANGE);
for (uint idx= all_parts ? 0 : part ; idx <= part ; idx++)
{
if (table->key_info[idx].key_part[part].field->type() == FIELD_TYPE_BLOB)
{
/* We can't use BLOBS to shortcut sorts */
flags&= ~ (HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE);
break;
}
}
return flags;
}
static int
berkeley_cmp_hidden_key(DB* file, const DBT *new_key, const DBT *saved_key)
{
......
......@@ -94,13 +94,7 @@ class ha_berkeley: public handler
changed_rows(0),last_dup_key((uint) -1),version(0),using_ignore(0) {}
~ha_berkeley() {}
const char *table_type() const { return "BerkeleyDB"; }
ulong index_flags(uint idx, uint part) const
{
ulong flags=HA_READ_NEXT | HA_READ_PREV;
if (table->key_info[idx].key_part[part].field->key_type() != HA_KEYTYPE_TEXT)
flags|= HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE;
return flags;
}
ulong index_flags(uint idx, uint part, bool all_parts) const;
const char *index_type(uint key_number) { return "BTREE"; }
const char **bas_ext() const;
ulong table_flags(void) const { return int_table_flags; }
......
......@@ -44,7 +44,7 @@ class ha_heap: public handler
HA_REC_NOT_IN_SEQ | HA_READ_RND_SAME |
HA_CAN_INSERT_DELAYED);
}
ulong index_flags(uint inx, uint part) const
ulong index_flags(uint inx, uint part, bool all_parts) const
{
return ((table->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE :
......
......@@ -94,7 +94,7 @@ class ha_innobase: public handler
const char *index_type(uint key_number) { return "BTREE"; }
const char** bas_ext() const;
ulong table_flags() const { return int_table_flags; }
ulong index_flags(uint idx, uint part) const
ulong index_flags(uint idx, uint part, bool all_parts) const
{
return (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE |
HA_KEYREAD_ONLY);
......
......@@ -36,7 +36,7 @@ class ha_isam: public handler
HA_DUPP_POS | HA_NOT_DELETE_WITH_CACHE | HA_FILE_BASED)
{}
~ha_isam() {}
ulong index_flags(uint idx, uint part) const
ulong index_flags(uint idx, uint part, bool all_parts) const
{ return HA_READ_NEXT; } // but no HA_READ_PREV here!!!
const char *table_type() const { return "ISAM"; }
const char *index_type(uint key_number) { return "BTREE"; }
......
......@@ -34,7 +34,8 @@ class ha_isammrg: public handler
const char **bas_ext() const;
ulong table_flags() const { return (HA_READ_RND_SAME |
HA_REC_NOT_IN_SEQ | HA_FILE_BASED); }
ulong index_flags(uint idx, uint part) const { DBUG_ASSERT(0); return 0; }
ulong index_flags(uint idx, uint part, bool all_parts) const
{ DBUG_ASSERT(0); return 0; }
uint max_supported_keys() const { return 0; }
bool low_byte_first() const { return 0; }
......
......@@ -55,11 +55,11 @@ class ha_myisam: public handler
const char *index_type(uint key_number);
const char **bas_ext() const;
ulong table_flags() const { return int_table_flags; }
ulong index_flags(uint inx, uint part) const
ulong index_flags(uint inx, uint part, bool all_parts) const
{
return ((table->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ?
0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
HA_READ_ORDER | HA_KEYREAD_ONLY);
0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
HA_READ_ORDER | HA_KEYREAD_ONLY);
}
uint max_supported_keys() const { return MI_MAX_KEY; }
uint max_supported_key_length() const { return MI_MAX_KEY_LENGTH; }
......
......@@ -38,11 +38,11 @@ class ha_myisammrg: public handler
HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED |
HA_CAN_INSERT_DELAYED);
}
ulong index_flags(uint inx, uint part) const
ulong index_flags(uint inx, uint part, bool all_parts) const
{
return ((table->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ?
0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
HA_READ_ORDER | HA_KEYREAD_ONLY);
0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
HA_READ_ORDER | HA_KEYREAD_ONLY);
}
uint max_supported_keys() const { return MI_MAX_KEY; }
uint max_supported_key_length() const { return MI_MAX_KEY_LENGTH; }
......
......@@ -524,7 +524,8 @@ inline NDB_INDEX_TYPE ha_ndbcluster::get_index_type(uint idx_no) const
flags depending on the type of the index.
*/
inline ulong ha_ndbcluster::index_flags(uint idx_no, uint part) const
inline ulong ha_ndbcluster::index_flags(uint idx_no, uint part,
bool all_parts) const
{
DBUG_ENTER("index_flags");
DBUG_PRINT("info", ("idx_no: %d", idx_no));
......
......@@ -93,7 +93,7 @@ class ha_ndbcluster: public handler
const char * table_type() const { return("ndbcluster");}
const char ** bas_ext() const;
ulong table_flags(void) const { return m_table_flags; }
ulong index_flags(uint idx, uint part) const;
ulong index_flags(uint idx, uint part, bool all_parts) const;
uint max_supported_record_length() const { return NDB_MAX_TUPLE_SIZE; };
uint max_supported_keys() const { return MAX_KEY; }
uint max_supported_key_parts() const
......
......@@ -449,7 +449,7 @@ public:
virtual const char *table_type() const =0;
virtual const char **bas_ext() const =0;
virtual ulong table_flags(void) const =0;
virtual ulong index_flags(uint idx, uint part=0) const =0;
virtual ulong index_flags(uint idx, uint part, bool all_parts) const =0;
virtual ulong index_ddl_flags(KEY *wanted_index) const
{ return (HA_DDL_SUPPORT); }
virtual int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys)
......
......@@ -2046,10 +2046,8 @@ bool flush_error_log()
bool MYSQL_LOG::cut_spurious_tail()
{
int error= 0;
char llbuf1[22], llbuf2[22];
ulonglong actual_size;
DBUG_ENTER("cut_spurious_tail");
#ifdef HAVE_INNOBASE_DB
if (have_innodb != SHOW_OPTION_YES)
DBUG_RETURN(0);
......@@ -2059,6 +2057,9 @@ bool MYSQL_LOG::cut_spurious_tail()
*/
char *name= ha_innobase::get_mysql_bin_log_name();
ulonglong pos= ha_innobase::get_mysql_bin_log_pos();
ulonglong actual_size;
char llbuf1[22], llbuf2[22];
if (name[0] == 0 || pos == ULONGLONG_MAX)
{
DBUG_PRINT("info", ("InnoDB has not set binlog info"));
......
......@@ -2378,17 +2378,18 @@ void User_var_log_event::print(FILE* file, bool short_form, char* last_db)
> the string constant is still unescaped according to SJIS, not
> according to UCS2.
*/
char *p, *q;
if (!(p= (char *)my_alloca(2*val_len+1+2))) // 2 hex digits per byte
char *hex_str;
CHARSET_INFO *cs;
if (!(hex_str= (char *)my_alloca(2*val_len+1+2))) // 2 hex digits / byte
break; // no error, as we are 'void'
str_to_hex(p, val, val_len);
str_to_hex(hex_str, val, val_len);
/*
For proper behaviour when mysqlbinlog|mysql, we need to explicitely
specify the variable's collation. It will however cause problems when
people want to mysqlbinlog|mysql into another server not supporting the
character set. But there's not much to do about this and it's unlikely.
*/
CHARSET_INFO *cs;
if (!(cs= get_charset(charset_number, MYF(0))))
/*
Generate an unusable command (=> syntax error) is probably the best
......@@ -2396,8 +2397,8 @@ void User_var_log_event::print(FILE* file, bool short_form, char* last_db)
*/
fprintf(file, ":=???;\n");
else
fprintf(file, ":=_%s %s COLLATE %s;\n", cs->csname, p, cs->name);
my_afree(p);
fprintf(file, ":=_%s %s COLLATE %s;\n", cs->csname, hex_str, cs->name);
my_afree(hex_str);
}
break;
case ROW_RESULT:
......
......@@ -727,7 +727,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
found_records=check_quick_select(&param, idx, *key);
if (found_records != HA_POS_ERROR && found_records > 2 &&
head->used_keys.is_set(keynr) &&
(head->file->index_flags(keynr) & HA_KEYREAD_ONLY))
(head->file->index_flags(keynr, param.max_key_part, 1) &
HA_KEYREAD_ONLY))
{
/*
We can resolve this by only reading through this key.
......@@ -1028,7 +1029,8 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
String tmp(buff1,sizeof(buff1),value->collation.collation),*res;
uint length,offset,min_length,max_length;
if (!field->optimize_range(param->real_keynr[key_part->key]))
if (!field->optimize_range(param->real_keynr[key_part->key],
key_part->part))
DBUG_RETURN(0); // Can't optimize this
if (!(res= value->val_str(&tmp)))
DBUG_RETURN(&null_element);
......@@ -1093,7 +1095,8 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
DBUG_RETURN(new SEL_ARG(field,min_str,max_str));
}
if (!field->optimize_range(param->real_keynr[key_part->key]) &&
if (!field->optimize_range(param->real_keynr[key_part->key],
key_part->part) &&
type != Item_func::EQ_FUNC &&
type != Item_func::EQUAL_FUNC)
DBUG_RETURN(0); // Can't optimize this
......
......@@ -645,7 +645,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
part != part_end ;
part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1)
{
if (!(table->file->index_flags(idx, jdx) & HA_READ_ORDER))
if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER))
return 0;
if (field->eq(part->field))
......
......@@ -1744,10 +1744,10 @@ bool sys_var_collation::check(THD *thd, set_var *var)
}
else // INT_RESULT
{
if (!(tmp=get_charset(var->value->val_int(),MYF(0))))
if (!(tmp=get_charset((int) var->value->val_int(),MYF(0))))
{
char buf[20];
int10_to_str(var->value->val_int(), buf, -10);
int10_to_str((int) var->value->val_int(), buf, -10);
my_error(ER_UNKNOWN_COLLATION, MYF(0), buf);
return 1;
}
......@@ -1783,10 +1783,10 @@ bool sys_var_character_set::check(THD *thd, set_var *var)
}
else // INT_RESULT
{
if (!(tmp=get_charset(var->value->val_int(),MYF(0))))
if (!(tmp=get_charset((int) var->value->val_int(),MYF(0))))
{
char buf[20];
int10_to_str(var->value->val_int(), buf, -10);
int10_to_str((int) var->value->val_int(), buf, -10);
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), buf);
return 1;
}
......
......@@ -837,8 +837,10 @@ bool mysql_change_db(THD *thd, const char *name)
int length, db_length;
char *dbname=my_strdup((char*) name,MYF(MY_WME));
char path[FN_REFLEN];
ulong db_access;
HA_CREATE_INFO create;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
ulong db_access;
#endif
DBUG_ENTER("mysql_change_db");
if (!dbname || !(db_length= strlen(dbname)))
......@@ -899,4 +901,3 @@ bool mysql_change_db(THD *thd, const char *name)
thd->variables.collation_database= thd->db_charset;
DBUG_RETURN(0);
}
......@@ -2825,7 +2825,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
Set tmp to (previous record count) * (records / combination)
*/
if ((found_part & 1) &&
(!(table->file->index_flags(key,0) & HA_ONLY_WHOLE_INDEX) ||
(!(table->file->index_flags(key,0,0) & HA_ONLY_WHOLE_INDEX) ||
found_part == PREV_BITS(uint,keyinfo->key_parts)))
{
max_key_part=max_part_bit(found_part);
......@@ -7172,7 +7172,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
if (!select->quick->reverse_sorted())
{
// here used_key_parts >0
if (!(table->file->index_flags(ref_key,used_key_parts-1)
if (!(table->file->index_flags(ref_key,used_key_parts-1, 1)
& HA_READ_PREV))
DBUG_RETURN(0); // Use filesort
// ORDER BY range_key DESC
......@@ -7195,9 +7195,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
Use a traversal function that starts by reading the last row
with key part (A) and then traverse the index backwards.
*/
if (!(table->file->index_flags(ref_key,used_key_parts-1)
& HA_READ_PREV))
DBUG_RETURN(0); // Use filesort
if (!(table->file->index_flags(ref_key,used_key_parts-1, 1)
& HA_READ_PREV))
DBUG_RETURN(0); // Use filesort
tab->read_first_record= join_read_last_key;
tab->read_record.read_record= join_read_prev_same;
/* fall through */
......
......@@ -701,8 +701,9 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
byte *pos;
uint flags=field->flags;
String type(tmp,sizeof(tmp), system_charset_info);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
uint col_access;
#endif
protocol->prepare_for_resend();
protocol->store(field->field_name, system_charset_info);
field->sql_type(type);
......@@ -995,7 +996,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
str=(key_part->field ? key_part->field->field_name :
"?unknown field?");
protocol->store(str, system_charset_info);
if (table->file->index_flags(i,j) & HA_READ_ORDER)
if (table->file->index_flags(i, j, 0) & HA_READ_ORDER)
protocol->store(((key_part->key_part_flag & HA_REVERSE_SORT) ?
"D" : "A"), 1, system_charset_info);
else
......
......@@ -61,7 +61,10 @@ int mysql_update(THD *thd,
bool safe_update= thd->options & OPTION_SAFE_UPDATES;
bool used_key_is_modified, transactional_table, log_delayed;
int error=0;
uint used_index, want_privilege;
uint used_index;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
uint want_privilege;
#endif
ulong query_id=thd->query_id, timestamp_query_id;
ha_rows updated, found;
key_map old_used_keys;
......
......@@ -569,13 +569,13 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
if (field->key_length() == key_part->length &&
!(field->flags & BLOB_FLAG))
{
if (outparam->file->index_flags(key, i) & HA_KEYREAD_ONLY)
if (outparam->file->index_flags(key, i, 1) & HA_KEYREAD_ONLY)
{
outparam->read_only_keys.clear_bit(key);
outparam->keys_for_keyread.set_bit(key);
field->part_of_key.set_bit(key);
}
if (outparam->file->index_flags(key, i) & HA_READ_ORDER)
if (outparam->file->index_flags(key, i, 1) & HA_READ_ORDER)
field->part_of_sortkey.set_bit(key);
}
if (!(key_part->key_part_flag & HA_REVERSE_SORT) &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment