Hi Alfranio,
Alfranio Correia wrote:
> #At
> file:///home/acorreia/workspace.sun/repository.mysql.new/bzrwork/bug-53452/mysql-trunk-bugfixing/
> based on revid:alfranio.correia@stripped
>
> 3087 Alfranio Correia 2010-07-23
> BUG#53452 Inconsistent behavior of binlog_direct_non_transactional_updates with
> temp table
[snip]
> + inline bool is_mixed_stmt_unsafe(bool in_multi_stmt_transaction_mode,
> + bool binlog_direct,
> + bool trx_cache_is_not_empty,
> + uint tx_isolation)
> {
> - DBUG_ENTER("THD::stmt_accessed_non_trans_temp_table");
> + if (in_multi_stmt_transaction_mode)
> + {
> + int type_out= 0;
> + for (; type_out < STMT_ACCESS_TABLE_COUNT; type_out++)
> + {
> + if (stmt_accessed_table((enum_stmt_accessed_table) type_out))
> + {
> + int type_in= 4;
> + for (; type_in < STMT_ACCESS_TABLE_COUNT; type_in++)
> + {
> + if (type_in != type_out &&
> + stmt_accessed_table((enum_stmt_accessed_table) type_in))
> + {
> +
> + uint unsafe=
> + (binlog_direct ? BINLOG_DIRECT_ON : BINLOG_DIRECT_OFF) &
> + (trx_cache_is_not_empty ? TRX_CACHE_NOT_EMPTY : TRX_CACHE_EMPTY)
> &
> + (tx_isolation >= ISO_REPEATABLE_READ ? IL_GTE_REPEATABLE :
> IL_LT_REPEATABLE);
> +
> + fprintf(stderr, "ACCESSED %d %s %d %s BINLOG %02X CACHE %02X
> ISOLATION %02X\n",
> + type_in, stmt_accessed_table_string((enum_stmt_accessed_table)
> type_in),
> + type_out, stmt_accessed_table_string((enum_stmt_accessed_table)
> type_out),
> + (binlog_direct ? BINLOG_DIRECT_ON : BINLOG_DIRECT_OFF),
> + (trx_cache_is_not_empty ? TRX_CACHE_NOT_EMPTY : TRX_CACHE_EMPTY),
> + (tx_isolation >= ISO_REPEATABLE_READ ? IL_GTE_REPEATABLE :
> IL_LT_REPEATABLE));
> +
> + fprintf(stderr, "RESULT %02X %02X %02X\n", unsafe,
> GET_UNSAFE(type_in, type_out),
> + CHECK_UNSAFE(type_in, type_out, unsafe));
> +
> + if (CHECK_UNSAFE(type_in, type_out, unsafe))
> + return(TRUE);
> + }
> + }
> + }
> + }
> + }
I don't quite understand why using two nested 'for' loops, which I think
is totally against the idea of using a map. The goodness of using a map
is that it can avoid the expense of condition ('if' or 'case') or loops.
The result can be get directly by accessing the map with an index. While
in the above code, the function CHECK_UNSAFE() will be looped 8x8 times
for every statement. The check should be done simply by one map index
with the statement's table access value.
If you want to including the isolation in the map, then I think you need
two maps, one for isolations that are lower than repeatable read, and
one for the other.