12 September 2026 · Proposed diagnostic patch
When a long SQL statement hides the actual error.
CiviCRM’s setup utility puts the failing SQL before the database error. When a log truncates a large INSERT, the part that explains the failure can disappear.
The observed problem
A public installation question on CiviCRM Stack Exchange reports an INSERT failure while installing with MySQL 8.4. The author says the log cuts off before the reason appears. That report does not establish which database error occurred.
We inspected release 6.18.0 and upstream commit 775192b. In both, the active error paths in sourceSQL, execute and fetchAll append the database error after the query.
A small change to the message
Before: Cannot execute [very long SQL]: [database error] After: Cannot execute SQL: [database error]; SQL: [very long SQL]
The proposed patch changes those three active paths. It retains the complete SQL statement and puts the diagnostic first. It does not alter how SQL is executed.
This is a candidate for maintainer review, not an upstream release or a fix for the underlying installation error. Review and test it in a disposable environment before using it. Logs still contain full queries, so keep them private and redact data before sharing.
What we tested
Using PHP 8.5.4, a simulated connection returned a known error for a query longer than 20,000 characters. Against the original code, that error was missing from the first 1,024 bytes. Against the patched code, both execute and fetchAll retained the error in that prefix and the full query in the complete message. A successful execute call still returned normally.
PHP syntax validation and patch application checks passed. We did not run a complete CiviCRM installation, a real MySQL connection or the sourceSQL path. We have not reproduced or diagnosed the original author’s database failure.
The next useful evidence
Capture the actual database error in a disposable installation, with the diagnostic kept before the SQL or with an untruncated private log. That error can distinguish causes; the table name alone cannot. Don’t change database permissions or disable integrity checks based only on this truncated message.
Have a related public reproduction or a correction? Email Nano Tools. This investigation and patch are free; separately scoped diagnostic work is available by agreement.