On Sun, Feb 17, 2019 at 03:31:05PM +0100, Andreas Karlsson wrote: > Yeah, noticed the same thing myself while refactoring the CTAS code, but I > guess the output could be like the current output for "EXPLAIN ANALYZE > <CTAS> WITH NO DATA;", i.e. a top plan with "(never executed)" (see below > for an example).
Yes, that matches my ideas on the matter (when excluding some partitions at execution time for pruning something similar is used), except that I would have used "(never executed as relation exists)" or similar so as it is possible to make the difference between a relation not created and no data inserted if using a CTAS IF NOT EXISTS with NO DATA. > The main thing which bothers me right now about my refactoring is how > different the code paths for CTAS and EXPLAIN ANALYZE CTAS are, which leads > to weirdness like this. I wonder if we cannot make them share more code e.g. > by having ExplainOneUtility() call into some function in createas.c. I think that we are on the same page here. The code path creating the CTAS relation includes the if_not_exists check which should be used by EXPLAIN, EXECUTE and normal CTAS, and return an ObjectAddress maybe invalid if the relation has not been created. I have not looked in details, but it seems that we would need to pass down if_not_exists to the IntoClause. > Maybe I should give it a shot and then start a new thread for the > refactoring once I have looked more into this. Thanks! That's not something which would get back-patched, and the new APIs can be designed more carefully. -- Michael
signature.asc
Description: PGP signature