1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

WL 1682: Use bitvector instead of query_id to tell handler which fields

to read and write
Changed Server code, added new interface to handler and changed the
NDB handler, InnoDB handler and Federated handler that previously used
query_id
Bug#10202 fix (one-liner fix for memory leak)


mysys/my_bitmap.c:
  Debug code
sql/field.cc:
  Initialise fieldnr to 0 if not set anywhere else
sql/field.h:
  Introduce a fieldnr (first field = 1 and last = table->s->fields
  in field object to be able to quickly set appropriate bit in
  read/write set
sql/ha_federated.cc:
  Changed federated handler to use write set instead of query_id
sql/ha_innodb.cc:
  Changed InnoDB handler to use write set instead of query_id
sql/ha_ndbcluster.cc:
  Changed NDB handler to use write set instead of query_id
sql/ha_ndbcluster.h:
  Changed NDB handler to use write set instead of query_id
sql/handler.cc:
  Allocate read_set and write_set either in get_new_handler or in
  special routine
  Routines used at destruction of handler object
  plus routine to set all primary key fields in read_set
sql/handler.h:
  bool to keep track if read/write set allocated or not in handler
  Deallocate read/write set at delete of handler object
  New bitmap's for read/write set
sql/item.cc:
  Set bits in read or write set (set_query_id = 2 => write_set
  set_query_id = 1 => read_set
sql/lock.cc:
  Clear bit set when starting a new statement in external lock
sql/mysql_priv.h:
  changed set_query_id from bool to ulong
sql/opt_range.cc:
  Set primary key read set in all places where HA_EXTRA_RETRIEVE_PRIMARY_KEY
  is used
sql/sql_acl.cc:
  set all bits in read set all places where HA_EXTRA_RETRIEVE_ALL_COLS
  are used
sql/sql_base.cc:
  Clear all bits before start new statement when table locked already
  Set bit in read/write set dependent on set_query_id and fieldnr
  bool -> ulong for set_query_id
  set all bits in read set for SELECT * queries where table is not view
sql/sql_class.h:
  Added comments + changed type of set_query_id
sql/sql_insert.cc:
  Use 2 when setup_fields called for fields to updated in UPDATE
  and INSERT statements
  set primary key fields when EXTRA param used
sql/sql_load.cc:
  Set all bits in write set if no fields specified in LOAD DATA FROM
  INFILE
  Otherwise use 2 to set specific fields to be updated by LOAD DATA...
sql/sql_select.cc:
  Set primary key read set when EXTRA param specified
  Set fieldnr for temporary tables
  Set number of fields before calling get_new_handler
  and only set all bits if there at least one field in table
sql/sql_table.cc:
  Set all bits in read set for old table and all bits in write set for
  new table for ALTER TABLE copy method
  Set all bits in read set when EXTRA param used
sql/sql_udf.cc:
  Set all bits in read set when EXTRA param used
sql/sql_update.cc:
  Set fields to UPDATE to use 2 for set_query_id
  Set all bits in read set when EXTRA param used
sql/table.cc:
  Set fieldnr in openfrm
  Reallocate read/write set in openfrm since table->s->fields==0
  at call to get_new_handler
sql/unireg.cc:
  Fix Bug #10202
This commit is contained in:
unknown
2005-04-28 14:45:27 +02:00
parent a2ed27af52
commit 5d3af2b0a7
24 changed files with 299 additions and 199 deletions

View File

@@ -105,6 +105,11 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
#endif
clear_timestamp_auto_bits(table->timestamp_field_type,
TIMESTAMP_AUTO_SET_ON_INSERT);
/*
No fields are provided so all fields must be provided in the values.
Thus we set all bits in the write set.
*/
table->file->ha_set_all_bits_in_write_set();
}
else
{ // Part field list
@@ -120,7 +125,11 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
thd->lex->select_lex.no_wrap_view_item= 1;
save_next= table_list->next_local; // fields only from first table
table_list->next_local= 0;
res= setup_fields(thd, 0, table_list, fields, 1, 0, 0);
/*
Indicate fields in list is to be updated by setting set_query_id
parameter to 2. This sets the bit in the write_set for each field.
*/
res= setup_fields(thd, 0, table_list, fields, 2, 0, 0);
table_list->next_local= save_next;
thd->lex->select_lex.no_wrap_view_item= 0;
if (res)
@@ -209,9 +218,10 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
/*
Check the fields we are going to modify. This will set the query_id
of all used fields to the threads query_id.
of all used fields to the threads query_id. It will also set all
fields into the write set of this table.
*/
if (setup_fields(thd, 0, insert_table_list, update_fields, 1, 0, 0))
if (setup_fields(thd, 0, insert_table_list, update_fields, 2, 0, 0))
return -1;
if (table->timestamp_field)
@@ -788,7 +798,10 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
DBUG_RETURN(TRUE);
}
if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
{
table->file->ha_set_primary_key_in_read_set();
table->file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY);
}
thd->lex->select_lex.first_execution= 0;
DBUG_RETURN(FALSE);
}