Efcore: Quote savepoint names as identifiers

Created on 16 Oct 2020  路  8Comments  路  Source: dotnet/efcore

EF Core version: master
Database Provider: Firebird

BatchExecutor creates a savepoint named __EFSavePoint

Firebird cannot create a savepoint with an underscore name - returns a DSQL error.

Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 11
__EFSavePoint

Could you allow replace this hardcoded name?

Thanks.

customer-reported providers-beware type-bug

All 8 comments

@cincuranet can you please confirm this is an actual limitation of Firebird? If so, we may need to add a hook for providers to specify/customize the savepoint name.

Note: this can be worked around by disabling savepoint support for Firebird (i.e. override RelationalTransaction.SupportsSavepoints to return false)

The ___EFSavePoint_ should be quoted (because of the underscores at the beginning). As long as we're talking about SAVEPOINT statement.

The ___EFSavePoint_ should be quoted (because of the underscores at the beginning). As long as we're talking about SAVEPOINT statement.

Connection (to FB/IB) with first (1) dialect does not support quoted names.

To enable quoting, you can inherit from RelationalTransaction and override GetCreateSavepointSql/GetRollbackToSavepointSql/GetReleaseSavepointSql - hopefully that's sufficient.

As I understand, savepoint name uses common rules for database object (like table, column names).

So, I think, RelationalTransaction must use SqlGenerationHelper (and it method DelimitIdentifier) for create correct SQL - SAVEPOINT "SavePointName".

As minimum.

From other side, as I noted earlier, connection (to Firebird) with first dialect does not support quoted names.

Dialect 1 is deprecated in Firebird.

Regardless of Firebird, it's true that savepoint names are standard identifiers and we should go through SqlGenerationHelper (just tested on SQL Server, Sqlite, PG, MySQL).

23036 provides a full fix for this for 6.0, but seems overly risky at this point for 5.0 - especially since:

  • The problem is unlikely to affect many users. This only affects users creating their own savepoints, with identifiers requiring delimiting.
  • If the above is really needed, it's possible to work around this by replacing IRelationalTransactionFactory.
Was this page helpful?
0 / 5 - 0 ratings