phpmyadmin / phpmyadmin/sql-parser

phpMyAdmin 5.2.3 export fails with RuntimeException: No statement inside WITH for views containing nested CTEs

Open
#666 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
485
Forks
119
PR merge metrics
No merged PRs in 30d

Description

When exporting a database/schema from phpMyAdmin 5.2.3, the export fails if a view contains a nested CTE (WITH inside another WITH).

The view itself is valid in MariaDB and can be created, queried, and retrieved successfully using SHOW CREATE VIEW. However, during phpMyAdmin export, phpMyAdmin creates the temporary stand-in definition for the view and then terminates with:

RuntimeException: No statement inside WITH
Because the export terminates at this point, the final CREATE VIEW definitions that phpMyAdmin normally writes near the end of the export are missing from the generated SQL file.

Simple reproduction steps: (MariaDB 10.11.16)
DROP VIEW IF EXISTS test_nested_cte_view;

CREATE VIEW test_nested_cte_view AS
WITH outer_cte AS
(
WITH inner_cte AS
(
SELECT 1 AS id, 'test' AS name
)
SELECT id, name
FROM inner_cte
)
SELECT id, name
FROM outer_cte;

Then perform a SQL export of the database/schema through phpMyAdmin.
The export then terminates with:
RuntimeException: No statement inside WITH

Expected result

phpMyAdmin should successfully export a valid MariaDB view containing nested CTEs and include its complete CREATE VIEW definition in the SQL export.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the nested-CTE view and a MariaDB schema SQL export, using the reported RuntimeException as the entry point. Trace the parser handling of the temporary stand-in view definition; done means the export completes and includes the complete CREATE VIEW definition.

Written by the indexing model from the issue text.

Assessment

Tech stack
mariadb, php, sql
Domain
databases, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.