[MDEV-25464] Joining CTEs inside a function fails with error code 1146 despite the tables existing Created: 2021-04-20  Updated: 2021-04-20  Resolved: 2021-04-20

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - CTE, Stored routines
Affects Version/s: 10.3.23
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Jon Kilgallon Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: CTE, Functions, query
Environment:

Ubuntu 18.04.4 LTS (Bionic Beaver) running in Docker


Attachments: File MariaDB CTE Bug Repro.sql    
Issue Links:
Duplicate
duplicates MDEV-23886 Reusing CTE inside a function fails w... Closed
Relates
relates to MDEV-16629 "Table Does Not Exist" Error from Rec... Closed

 Description   

When I wrap a statement containing two or more Common Table Expressions in a function, and one of those CTEs is JOINed to another CTE, executing the function will result in error code 1146, reporting that the first table that the CTE interacts with doesn't exist - even though it does.

Extracting the failing query and running it standalone works fine, the query will return the expected results.

I have attached sample SQL that replicates this behaviour.



 Comments   
Comment by Alice Sherepa [ 2021-04-20 ]

Thanks for the report!
This is a duplicate of MDEV-23886. If you'd like to follow the progress, please, watch MDEV-23886

Generated at Thu Feb 08 09:37:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.