-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5893 from derrabus/bugfix/deallocate-statements
Deallocate prepared statements in destructor
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Driver\PgSQL; | ||
|
||
use Doctrine\DBAL\Driver\PgSQL\Statement; | ||
use Doctrine\DBAL\Exception\DriverException; | ||
use Doctrine\DBAL\Statement as WrapperStatement; | ||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Tests\TestUtil; | ||
use ReflectionProperty; | ||
|
||
use function sprintf; | ||
|
||
class StatementTest extends FunctionalTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
if (TestUtil::isDriverOneOf('pgsql')) { | ||
return; | ||
} | ||
|
||
self::markTestSkipped('This test requires the pgsql driver.'); | ||
} | ||
|
||
public function testStatementsAreDeallocatedProperly(): void | ||
{ | ||
$statement = $this->connection->prepare('SELECT 1'); | ||
|
||
$property = new ReflectionProperty(WrapperStatement::class, 'stmt'); | ||
$property->setAccessible(true); | ||
|
||
$driverStatement = $property->getValue($statement); | ||
|
||
$property = new ReflectionProperty(Statement::class, 'name'); | ||
$property->setAccessible(true); | ||
|
||
$name = $property->getValue($driverStatement); | ||
|
||
unset($statement, $driverStatement); | ||
|
||
$this->expectException(DriverException::class); | ||
$this->expectExceptionMessageMatches('/prepared statement .* does not exist/'); | ||
|
||
$this->connection->executeQuery(sprintf('EXECUTE "%s"', $name)); | ||
} | ||
} |