Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"SQLSTATE[IMSSP]: This function is not implemented by this driver" with MS SQL and doctrine/migrations 3.3.2 #1214

Closed
acelaya opened this issue Nov 15, 2021 · 11 comments

Comments

@acelaya
Copy link

acelaya commented Nov 15, 2021

Bug Report

Q A
BC Break no
Version 3.3.2

Summary

When trying to run the migrations via command line, using v3.3.2 and Microsoft SQL server, this error appears:

In TransactionHelper.php line 63:
                                                                     
  [PDOException (IMSSP)]                                             
  SQLSTATE[IMSSP]: This function is not implemented by this driver.  
                                                                     

Exception trace:
  at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/TransactionHelper.php:63
 method_exists() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/TransactionHelper.php:63
 Doctrine\Migrations\Tools\TransactionHelper::inTransaction() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/TransactionHelper.php:41
 Doctrine\Migrations\Tools\TransactionHelper::rollbackIfInTransaction() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:257
 Doctrine\Migrations\Version\DbalExecutor->migrationEnd() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php:115
 Doctrine\Migrations\Version\DbalExecutor->execute() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:112
 Doctrine\Migrations\DbalMigrator->executePlan() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:76
 Doctrine\Migrations\DbalMigrator->executeMigrations() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php:162
 Doctrine\Migrations\DbalMigrator->migrate() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php:210
 Doctrine\Migrations\Tools\Console\Command\MigrateCommand->execute() at /app/vendor/symfony/console/Command/Command.php:299
 Symfony\Component\Console\Command\Command->run() at /app/vendor/symfony/console/Application.php:978
 Symfony\Component\Console\Application->doRunCommand() at /app/vendor/symfony/console/Application.php:295
 Symfony\Component\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:167
 Symfony\Component\Console\Application->run() at /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/ConsoleRunner.php:96
 Doctrine\Migrations\Tools\Console\ConsoleRunner::run() at /app/vendor/doctrine/migrations/bin/doctrine-migrations.php:45
 Doctrine\Migrations\{closure}() at /app/vendor/doctrine/migrations/bin/doctrine-migrations.php:46
 require() at /app/vendor/doctrine/migrations/bin/doctrine-migrations:8

migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--] [<version>]

Works fine with doctrine/migrations v3.3.1, and also with v3.3.2 when using any other database engine.

Current behavior

The error described above.

How to reproduce

Using Microsoft SQL server, run vendor/bin/doctrine-migrations migrations:migrate.

Expected behavior

Migrations are properly executing, and the migrations command succeeds.

@acelaya acelaya changed the title SQLSTATE[IMSSP]: This function is not implemented by this driver with MS SQL and doctrine/migrations 3.3.2 "SQLSTATE[IMSSP]: This function is not implemented by this driver" with MS SQL and doctrine/migrations 3.3.2 Nov 15, 2021
@acelaya acelaya closed this as completed Nov 15, 2021
@acelaya acelaya reopened this Nov 15, 2021
@greg0ire
Copy link
Member

greg0ire commented Nov 15, 2021

@acelaya this probably has to do with what I did in #1210 … I don't understand why though:

while (method_exists($innermostConnection, 'getWrappedConnection')) {

How could this line possibly result in an exception from SQL Server? It does not execute any SQL, does it?

Also, please provide a full stack trace as describe in https://symfony.com/doc/current/contributing/code/stack_trace.html#stack-traces-in-the-cli

@acelaya
Copy link
Author

acelaya commented Nov 19, 2021

Sorry @greg0ire, I didn't see your request to add the stack trace.

I have updated the ticket description after running the command with -vvv.

@greg0ire
Copy link
Member

How could this line possibly result in an exception from SQL Server? It does not execute any SQL, does it?

I'm starting to think using method_exists on an object that is implemented in a PHP extension can in fact result in any behavior including this one 🤔

What driver are you using, by the way? sqlsrv? pdo_sqlsrv?

@acelaya
Copy link
Author

acelaya commented Nov 19, 2021

pdo_sqlsrv

@greg0ire
Copy link
Member

I found this: microsoft/msphpsql#1306

The issue you are experiencing is with the driver you are using (it is buggy, since it breaks `method_exists).
Upgrading the driver should fix your issue, but won't be possible until early 2022.

In the meantime, I don't think it's fair to have a workaround in doctrine/migrations. I think you should avoid upgrading doctrine/migrations until you can use version 5.10 of the driver.

@acelaya
Copy link
Author

acelaya commented Nov 19, 2021

Thanks!

I will follow-up that issue there. I'm already waiting for that version for other issues, so it's ok.

Agree on no workarounds. This is too specific, and probably not so many people is using MS SQL with PHP.

@S-Tian86
Copy link

Hi @greg0ire

In the meantime, I don't think it's fair to have a workaround in doctrine/migrations. I think you should avoid upgrading doctrine/migrations until you can use version 5.10 of the driver.

Sorry, but for those of us who have no alternative to use SQL Server, migrations are very useful and it is difficult to avoid using them.

This bug has already been fixed in Symfony (here symfony/symfony@d65f9ee) so as not to depend on the driver solution, it could be fixed here too.

The solution would be to implement something similar to what was done in Symfony, just correct a line.

while (! $innermostConnection instanceof PDO && method_exists($innermostConnection, 'getWrappedConnection')) {

Is it possible to do so, to be able to continue using migrations?

@greg0ire
Copy link
Member

It sure would be possible, but before we do that, please explain to me what prevents you from downgrading doctrine/migrations to 3.3.1?

@S-Tian86
Copy link

Ehm... nothing, hehehe, sorry, I just installed Doctrine-Migrations-Bundle and that's the reason why version 3.3.2 of doctrine/migration was installed.
I just manually downgraded to version 3.3.1 and it works without problems.

Thank you very much. And sorry again, I'm a bit of a newbie.

@greg0ire
Copy link
Member

No worries 🙂

@acelaya
Copy link
Author

acelaya commented Dec 2, 2021

I can confirm this is fixed on pdo_sqlsrv 5.10.0beta2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants