{"record":{"id":"11481ff913d8faf5","repo":"phalcon/cphalcon","slug":"savepoints-are-not-supported-by-this-database-adap","errorCode":null,"errorMessage":"Savepoints are not supported by this database adapter","messagePattern":"Savepoints are not supported by this database adapter","errorType":"exception","errorClass":"Phalcon\\Db\\Exceptions\\SavepointsNotSupported","httpStatus":null,"severity":"error","filePath":"phalcon/Db/Adapter/AbstractAdapter.zep","lineNumber":308,"sourceCode":"            this->dialect->addPrimaryKey(\n                tableName,\n                schemaName,\n                index\n            )\n        );\n    }\n\n    /**\n     * Creates a new savepoint\n     */\n    public function createSavepoint( string name) -> bool\n    {\n        var dialect;\n\n        let dialect = this->dialect;\n\n        if unlikely !dialect->supportsSavePoints() {\n            throw new SavepointsNotSupported();\n        }\n\n        return this->{\"execute\"}(\n            dialect->createSavepoint(name)\n        );\n    }\n\n    /**\n     * Creates a table\n     */\n    public function createTable( string tableName,  string schemaName,  array definition) -> bool\n    {\n        var columns;\n\n        if unlikely !fetch columns, definition[\"columns\"] {\n            throw new TableMustHaveColumn();\n        }\n","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Db/Adapter/AbstractAdapter.zep#L290-L326","documentation":"createSavepoint() first asks the adapter's dialect supportsSavePoints(); if the dialect reports no savepoint support, SavepointsNotSupported is thrown before any SQL is sent. All bundled dialects (Mysql, Postgresql, Sqlite) inherit the base Phalcon\\Db\\Dialect::supportsSavepoints() which returns true, so in practice this fires when a custom dialectClass overrides supportsSavePoints() to false or a hand-written DialectInterface implementation returns false/null.","triggerScenarios":"Direct call $connection->createSavepoint('my_savepoint') while the configured dialect reports no savepoint support; or enabling nested transactions with savepoints ($connection->setNestedTransactionsWithSavepoints(true)) and then calling begin() repeatedly so the second nesting level issues createSavepoint().","commonSituations":"Custom dialect for a database/proxy layer that genuinely lacks SAVEPOINT; test doubles whose supportsSavePoints() returns false by default (PHPUnit mocks return null/false); a hand-implemented DialectInterface that forgot the support methods; adapters for platforms without nested-transaction support.","solutions":["Check $connection->getDialect()->supportsSavePoints() before calling createSavepoint()","If the database does support SAVEPOINT, fix the custom dialect: extend Phalcon\\Db\\Dialect (inherits true) or override supportsSavePoints() to return true","Avoid nested transactions: do not call setNestedTransactionsWithSavepoints(true) and keep transaction level at 1"],"exampleFix":"// before\n$connection->createSavepoint('LEVEL_1');\n\n// after\nif ($connection->getDialect()->supportsSavePoints()) {\n    $connection->createSavepoint('LEVEL_1');\n} else {\n    // fall back to flat transactions: commit/rollback at level 1 only\n}","handlingStrategy":"validation","validationCode":"if (!$connection->getDialect()->supportsSavePoints()) {\n    // run without savepoints: keep the transaction flat instead of creating one\n    return;\n}\n$connection->createSavepoint($name);","typeGuard":null,"tryCatchPattern":"use Phalcon\\Db\\Exceptions\\SavepointsNotSupported;\n\ntry {\n    $connection->createSavepoint($name);\n} catch (SavepointsNotSupported $e) {\n    // degrade gracefully: continue in a flat, non-nested transaction\n    $logger->warning('Savepoints unavailable, nesting disabled: ' . $e->getMessage());\n}","preventionTips":["Query supportsSavePoints() once at startup and store the capability next to the adapter","Make custom dialects extend Phalcon\\Db\\Dialect so support flags are accurate","Design transaction helpers to degrade to flat transactions when the dialect lacks savepoints"],"tags":["php","phalcon","db","savepoint","transaction","dialect"],"backgroundTag":"savepoints-not-supported","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}