How do I determine the isolation level in use for a given query? After a query is executed (by a 3rd party application) I'd like to know which isolation level was used (e.g., read uncommitted).
如何确定给定查询使用的隔离级别?在执行查询之后(由第三方应用程序执行),我想知道使用了哪个隔离级别(例如,读取uncommitted)。
To be clear, I'm currently working on an application that uses EF4 running against mysql 5.1. I'm try to test different coding patterns to change isolations levels for specific EF4 queries. I need to be able to test and make sure the isolation levels are being set correctly.
明确地说,我目前正在开发一个应用程序,它使用EF4运行在mysql 5.1上。我尝试测试不同的编码模式,以改变特定EF4查询的隔离级别。我需要能够测试并确保隔离级别被正确设置。
1 个解决方案
#1
34
SHOW VARIABLES LIKE 'tx_isolation';
or if you have MySQL 5.1+
或者MySQL 5.1+
SELECT * FROM information_schema.session_variables
WHERE variable_name = 'tx_isolation';
If you want to know what the server has configured globally, change the above to the following:
如果您想知道服务器在全球配置了什么,请将上面的更改为以下内容:
SHOW GLOBAL VARIABLES LIKE 'tx_isolation';
or if you have MySQL 5.1+
或者MySQL 5.1+
SELECT * FROM information_schema.global_variables
WHERE variable_name = 'tx_isolation';
If you want to make the query reveal what transaction isolation is being used, run this:
如果您想让查询显示正在使用的事务隔离,请运行以下命令:
SELECT variable_value IsolationLevel
FROM information_schema.session_variables
WHERE variable_name = 'tx_isolation';
DISCLAIMER : I DO NOT KNOW EF4
免责声明:我不知道EF4
If you are allowed to embed subqueries in the SQL about to be run by EF4, you may have to embed this query as a subquery (or embed you query as a subquery) and display the variable IsolationLevel along with the results of the actual query.
如果您被允许在EF4将要运行的SQL中嵌入子查询,那么您可能必须将该查询嵌入到子查询中(或者将查询嵌入到子查询中),并显示变量IsolationLevel以及实际查询的结果。
#1
34
SHOW VARIABLES LIKE 'tx_isolation';
or if you have MySQL 5.1+
或者MySQL 5.1+
SELECT * FROM information_schema.session_variables
WHERE variable_name = 'tx_isolation';
If you want to know what the server has configured globally, change the above to the following:
如果您想知道服务器在全球配置了什么,请将上面的更改为以下内容:
SHOW GLOBAL VARIABLES LIKE 'tx_isolation';
or if you have MySQL 5.1+
或者MySQL 5.1+
SELECT * FROM information_schema.global_variables
WHERE variable_name = 'tx_isolation';
If you want to make the query reveal what transaction isolation is being used, run this:
如果您想让查询显示正在使用的事务隔离,请运行以下命令:
SELECT variable_value IsolationLevel
FROM information_schema.session_variables
WHERE variable_name = 'tx_isolation';
DISCLAIMER : I DO NOT KNOW EF4
免责声明:我不知道EF4
If you are allowed to embed subqueries in the SQL about to be run by EF4, you may have to embed this query as a subquery (or embed you query as a subquery) and display the variable IsolationLevel along with the results of the actual query.
如果您被允许在EF4将要运行的SQL中嵌入子查询,那么您可能必须将该查询嵌入到子查询中(或者将查询嵌入到子查询中),并显示变量IsolationLevel以及实际查询的结果。