RAD Studio 10.4中对FireDAC事务隔离配置的更改

//以下为机器翻译,来自国外网站


FireDAC事务配置的默认设置之一已在10.4中更改,这可能需要对代码进行一些更改。

在RAD Studio 10.4之前,FireDAc连接的默认事务隔离选项被读取为commit那就是TFDConnection.TxOptions.Isolation是xiReadCommitted。这是为组件设置的值,并且是默认值,它没有发送到数据库。FireDAC只是假设其配置中的默认值是数据库的默认值,并且在会话开始时并未明确将此隔离配置发送到数据库。例如,在MySQL中,如果未修改默认值,则所需的命令是SET SESSION TRANSACTION ISOLATION LEVEL未执行。在这种情况下,无论在FireDAC默认配置中设置了什么,MySQL事务隔离都将保留为数据库默认值xiRepeatableRead。

为了解决此问题,我们决定最好将默认隔离级别保持为xiUnspecified,这意味着,如果您不需要特定的隔离级别,则使用特定数据库的默认配置-这是一个已经预先设置的int数据库,您无需询问配置。默认隔离级别已针对特定数据库进行了优化,因为默认设置不同,并且某些隔离级别甚至都不能很好地被所有数据库引擎支持。

如果开发人员希望使用与数据库使用的默认级别不同的隔离级别,则必须在组件配置或代码中显式设置隔离级别。如果开发人员想要使用数据库默认值,则不需要代码。

这是FireDAC术语中主要数据库的默认隔离级别-再次,该属性值只是xiUnspecified:

DB2-xiReadCommitted
InterBase和Firebird-xiSnapshot
MySQL和MariaDB-xiRepeatableRead
Oracle-xiReadCommitted
Microsoft SQL Server-xiReadCommitted
SQLite-xiSerializible
PostgreSQL-xiReadCommitted

我希望这有助于弄清更改并解释如何解决,将FireDAC连接的事务隔离级别更改为您特别需要的(如果与数据库默认设置不同的话)。RAD Studio 10.4的发行说明中未列出此更改,但确实引起了一些担忧(以及错误报告)。




原文:

One of the default setting for FireDAC transactions configuration has been changed in 10.4, and that might require some changes in your code.

Before RAD Studio 10.4, the default of transaction isolation option for FireDAc connections was read committed. That is TFDConnection.TxOptions.Isolation was xiReadCommitted. This was the value set for the component, and being the default it wasn't send to the database. FireDAC just assumed the default value in its configuration was the default of the database and it did not explicitly send this isolation configuration to the database at the start of a session. For example, in MySQL the required command is SET SESSION TRANSACTION ISOLATION LEVEL was not executed if the default wasn't modified. In this case, the MySQL transaction isolation was remaining to the database default value, which is xiRepeatableRead, no matter what was set in the FireDAC default configuration.

To fix this issue we decided that is was better to keep the default isolation level to xiUnspecified, meaning that if you won't require a specific isolation level, the default configuration for the specific database is used -- this is the one already preset int he database and you don't need to ask configuring. The default isolation level is optimized for specific database, as the defaults are different and some of the isolation levels are not even supported by all database engines equally well.

If a developer wants to use an isolation level different from the default used by the database, it must be set explicitly in the component configuration or in code. If the developer wants to the use the database default, no code is required.

Here are default isolation levels of the main databases in FireDAC terms -- again the property value is just xiUnspecified:

DB2 - xiReadCommitted
InterBase and Firebird - xiSnapshot
MySQL and MariaDB - xiRepeatableRead
Oracle - xiReadCommitted
Microsoft SQL Server - xiReadCommitted
SQLite - xiSerializible
PostgreSQL - xiReadCommitted

I hope this helps clarify the change and explain how to work around it, changing the transaction isolation level of your FireDAC connection to the one you specifically need, if different from the database default. This change wasn't listed in the release notes for RAD Studio 10.4 and it did cause some concerns (and bug reports).



联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678