Details
- 
    
Bug
 - 
    Status: Closed (View Workflow)
 - 
    
Major
 - 
    Resolution: Fixed
 - 
    10.4.12, 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5(EOL)
 
Description
The bug described in MDEV-15478 is not fully resolved. When the CTE is used again with UNION in the main statement, it gives error #1054 - Unknown column 'col1' in 'field list'
					WITH cte (col1) AS  | 
		
					(
			 | 
		
					SELECT 1  | 
		
					UNION  | 
		
					SELECT 2  | 
		
					)
			 | 
		
					SELECT col1 FROM cte  | 
		
					-- union statement added to example in MDEV-15478
			 | 
		
					UNION
			 | 
		
					SELECT col1 FROM cte  | 
		
This can currently be worked around with:
					WITH cte (col1) AS  | 
		
					(
			 | 
		
					SELECT 1 AS col1 -- alias required  | 
		
					UNION  | 
		
					SELECT 2  | 
		
					)
			 | 
		
					SELECT col1 FROM cte  | 
		
					UNION
			 | 
		
					SELECT col1 FROM cte  | 
		
Attachments
Issue Links
- relates to
 - 
                    
MDEV-15478 Explicit column name error in CTE of UNION
-         
 - Closed
 
 -