This issue is automatically created based on existing pull request: #41129: Add AdapterInterface dialect helpers and replace MySQL with Postgres SQL and other SQL like RDBS
Description (*)
Magento core still embeds MySQL-only SQL (GROUP_CONCAT(), FIELD(), IFNULL() literals, backticks, CREATE TABLE … LIKE, CREATE TEMPORARY TABLE … ENGINE=… IGNORE (SELECT), ON DUPLICATE KEY UPDATE text, UNION of mixed types, UPDATE … LIMIT, SHOW VARIABLES LIKE 'version'). That is valid on MySQL and fatal on PostgreSQL.
This PR does not add a Postgres adapter. It adds dialect helpers on AdapterInterface / Pdo\Mysql and switches Magento call sites to those helpers (and to existing ones such as getIfNullSql() / quoteIdentifier() / insertOnDuplicate()).
The Postgres driver lives in a separate module: https://github.com/Genaker/postgento (fork of Kirill Morozov’s Morozov_PgCompat). That repo implements the same AdapterInterface methods on pdo_pgsql. Magento can review/test/merge this core PR on MySQL alone, and optionally install Postgento on a branch of this PR to run Magento on PostgreSQL. After this PR is in Magento, Postgento does not need the Magento SQL call-site patches.
The same change set is open for Mage-OS: mage-os/mageos-magento2#321
New adapter methods (MySQL implementations):
getGroupConcatSql() → GROUP_CONCAT
getFieldSql() → FIELD()
castToText() / castToNumeric() (no-op / CAST(… AS DECIMAL) on MySQL; other engines can map to ::text / ::numeric)
createTableLike() → CREATE TABLE … LIKE
createTemporaryTableFromSelect() → existing MySQL CREATE TEMPORARY TABLE … ENGINE=innodb IGNORE (SELECT)
Also:
Select constructor type-hint relaxed from Pdo\Mysql to Zend_Db_Adapter_Abstract so a non-MySQL AdapterInterface can call select().
- Setup
--db-engine is passed through DbValidator / Installer::assertDbAccessible() so an optional engine can open the correct driver at install time. Default MySQL behavior is unchanged.
Behavior on MySQL is intended to be equivalent.
Related Pull Requests
Fixed Issues (if relevant)
N/A — no Magento issue filed yet.
Manual testing scenarios (*)
On a MySQL Magento Open Source install (this PR must not require Postgres):
bin/magento setup:upgrade — exit 0, no SQLSTATE.
bin/magento indexer:reindex — all indexers complete (catalog price, stock, EAV, catalog rule, fulltext).
- GraphQL: configurable product with variants (e.g. Luma
WJ01) returns variants; GROUP_CONCAT / FIELD() call sites used by collection / search appliers.
- Storefront: homepage, category, PDP, cart, customer login.
- Admin: dashboard, catalog products, categories, EAV attributes, customers, CMS, indexers, sales orders.
- Guest checkout placing a Check / Money Order order (sales sequence + quote).
- Confirm
setup:install --db-engine=mysql still validates and installs as today.
Optional Postgres: check out this PR, Composer-require https://github.com/Genaker/postgento (genaker/module-postgento), setup:install --db-engine=postgresql, then repeat indexer / GraphQL / storefront / admin / checkout.
Questions or comments
Happy to split adapter-interface methods vs call-site SQL into two PRs if that is easier to review. The adapter itself is Postgento — Magento can merge this PR first (MySQL-safe) and take Postgento as a Composer module whenever you want Postgres in the distribution.
Unit tests for the new Pdo\Mysql helpers, TemporaryTableService, and BatchIterator empty-batch minValue are in this PR.
Adobe CLA: signed as required for submissions to https://github.com/magento/magento2.
Contribution checklist (*)
This issue is automatically created based on existing pull request: #41129: Add AdapterInterface dialect helpers and replace MySQL with Postgres SQL and other SQL like RDBS
Description (*)
Magento core still embeds MySQL-only SQL (
GROUP_CONCAT(),FIELD(),IFNULL()literals, backticks,CREATE TABLE … LIKE,CREATE TEMPORARY TABLE … ENGINE=… IGNORE (SELECT),ON DUPLICATE KEY UPDATEtext,UNIONof mixed types,UPDATE … LIMIT,SHOW VARIABLES LIKE 'version'). That is valid on MySQL and fatal on PostgreSQL.This PR does not add a Postgres adapter. It adds dialect helpers on
AdapterInterface/Pdo\Mysqland switches Magento call sites to those helpers (and to existing ones such asgetIfNullSql()/quoteIdentifier()/insertOnDuplicate()).The Postgres driver lives in a separate module: https://github.com/Genaker/postgento (fork of Kirill Morozov’s
Morozov_PgCompat). That repo implements the sameAdapterInterfacemethods onpdo_pgsql. Magento can review/test/merge this core PR on MySQL alone, and optionally install Postgento on a branch of this PR to run Magento on PostgreSQL. After this PR is in Magento, Postgento does not need the Magento SQL call-site patches.The same change set is open for Mage-OS: mage-os/mageos-magento2#321
New adapter methods (MySQL implementations):
getGroupConcatSql()→GROUP_CONCATgetFieldSql()→FIELD()castToText()/castToNumeric()(no-op /CAST(… AS DECIMAL)on MySQL; other engines can map to::text/::numeric)createTableLike()→CREATE TABLE … LIKEcreateTemporaryTableFromSelect()→ existing MySQLCREATE TEMPORARY TABLE … ENGINE=innodb IGNORE (SELECT)Also:
Selectconstructor type-hint relaxed fromPdo\MysqltoZend_Db_Adapter_Abstractso a non-MySQLAdapterInterfacecan callselect().--db-engineis passed throughDbValidator/Installer::assertDbAccessible()so an optional engine can open the correct driver at install time. Default MySQL behavior is unchanged.Behavior on MySQL is intended to be equivalent.
Related Pull Requests
Fixed Issues (if relevant)
N/A — no Magento issue filed yet.
Manual testing scenarios (*)
On a MySQL Magento Open Source install (this PR must not require Postgres):
bin/magento setup:upgrade— exit 0, no SQLSTATE.bin/magento indexer:reindex— all indexers complete (catalog price, stock, EAV, catalog rule, fulltext).WJ01) returns variants;GROUP_CONCAT/FIELD()call sites used by collection / search appliers.setup:install --db-engine=mysqlstill validates and installs as today.Optional Postgres: check out this PR, Composer-require https://github.com/Genaker/postgento (
genaker/module-postgento),setup:install --db-engine=postgresql, then repeat indexer / GraphQL / storefront / admin / checkout.Questions or comments
Happy to split adapter-interface methods vs call-site SQL into two PRs if that is easier to review. The adapter itself is Postgento — Magento can merge this PR first (MySQL-safe) and take Postgento as a Composer module whenever you want Postgres in the distribution.
Unit tests for the new
Pdo\Mysqlhelpers,TemporaryTableService, andBatchIteratorempty-batchminValueare in this PR.Adobe CLA: signed as required for submissions to https://github.com/magento/magento2.
Contribution checklist (*)