Bug #80540 Support CREATE TABLE ... AS CALL(xyz); extended syntax
Submitted: 27 Feb 2016 3:28 Modified: 27 Feb 2016 14:36
Reporter: Justin Swanhart Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.6, 5.7 OS:Any
Assigned to: CPU Architecture:Any

[27 Feb 2016 3:28] Justin Swanhart
Description:
Stored procedures can return a resultset like a SELECT statement.  You can materialize the result of a select statement with
SELECT ...
AS
table_name;

I'd like to be able to do the same:
CALL xyz(...)
AS
table_name

or for stored procs that return more than one resultset:
CALL xyz(...)
AS
[table_name, ...]

This will allow my tool called async [a native message queue for background, parallel, async queries (http://github.com/swanhart-tools)] to materialize the results of CALL statements as well as SELECT statements, which would be a nice addition.

How to repeat:
N/A

Suggested fix:
N/A
[27 Feb 2016 3:31] Justin Swanhart
for queries that return no resultset, issue a warning and don't create the table.

for queries that return more results than listed, return a warning for each resultset that doensn't have a table name.  

CALL three_resultsets()
AS
table1;
Query OK.  2 warnings

SHOW WARNINGS;
More resulsets were returned than table names provided.  Resultset not materialised.
More resulsets were returned than table names provided.  Resultset not materialised.
[27 Feb 2016 9:00] Justin Swanhart
of course i meant
create table xyz as call ...
[27 Feb 2016 14:36] Justin Swanhart
Changed synopsis slightly.