1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

merge with 4.1 tree

This commit is contained in:
monty@mashka.mysql.fi
2003-09-11 20:31:40 +03:00
210 changed files with 4473 additions and 3651 deletions

View File

@ -920,7 +920,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
thd->proc_info="creating table";
if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
create_info->data_file_name= create_info->index_file_name= 0;
create_info->table_options=db_options;
if (rea_create_table(thd, path, create_info, fields, key_count,
key_info_buffer))
{
@ -2585,7 +2588,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
DBUG_RETURN(error > 0 ? -1 : 0);
}
int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
{
TABLE_LIST *table;
List<Item> field_list;
@ -2600,24 +2604,23 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(-1);
for (table = tables; table; table = table->next)
for (table= tables; table; table= table->next)
{
char table_name[NAME_LEN*2+2];
char* db = (table->db) ? table->db : thd->db;
bool fatal_error=0;
bool fatal_error= 0;
TABLE *t;
strxmov(table_name,db ? db : "",".",table->real_name,NullS);
t=table->table = open_ltable(thd, table, TL_READ_NO_INSERT);
#ifdef EMBEDDED_LIBRARY
thd->net.last_errno= 0; // these errors shouldn't get client
#endif
strxmov(table_name, table->db ,".", table->real_name, NullS);
t= table->table= open_ltable(thd, table, TL_READ_NO_INSERT);
thd->clear_error(); // these errors shouldn't get client
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
if (!t)
{
/* Table didn't exist */
protocol->store_null();
thd->net.last_error[0]=0;
}
@ -2629,45 +2632,42 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
!(check_opt->flags & T_EXTEND))
protocol->store((ulonglong)t->file->checksum());
else if (!(t->file->table_flags() & HA_HAS_CHECKSUM) &&
check_opt->flags & T_QUICK)
(check_opt->flags & T_QUICK))
protocol->store_null();
else
{
/* calculating table's checksum */
ha_checksum crc=0;
ha_checksum crc= 0;
if (t->file->rnd_init(1))
protocol->store_null();
else
{
while (!t->file->rnd_next(t->record[0]))
{
ha_checksum row_crc=0;
ha_checksum row_crc= 0;
if (t->record[0] != t->field[0]->ptr)
row_crc=my_checksum(row_crc, t->record[0],
t->field[0]->ptr - t->record[0]);
row_crc= my_checksum(row_crc, t->record[0],
t->field[0]->ptr - t->record[0]);
for (uint i=0; i < t->fields; i++ )
for (uint i= 0; i < t->fields; i++ )
{
Field *f=t->field[i];
Field *f= t->field[i];
if (f->type() == FIELD_TYPE_BLOB)
{
String tmp;
f->val_str(&tmp,&tmp);
row_crc=my_checksum(row_crc, tmp.ptr(), tmp.length());
row_crc= my_checksum(row_crc, tmp.ptr(), tmp.length());
}
else
row_crc=my_checksum(row_crc, f->ptr, f->pack_length());
row_crc= my_checksum(row_crc, f->ptr, f->pack_length());
}
crc+=row_crc;
crc+= row_crc;
}
protocol->store((ulonglong)crc);
}
}
#ifdef EMBEDDED_LIBRARY
thd->net.last_errno= 0; // these errors shouldn't get client
#endif
thd->clear_error();
close_thread_tables(thd);
table->table=0; // For query cache
}
@ -2677,6 +2677,7 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
send_eof(thd);
DBUG_RETURN(0);
err:
close_thread_tables(thd); // Shouldn't be needed
if (table)