{"push_id":1108665085,"size":1,"distinct_size":1,"ref":"refs/heads/knz/fix-start","head":"c3820ee6eb4f0f72b377cd427d0a3922f2853e91","before":"2064cdc0b56799f0fe833d9ffc7e33a933256470","commits":[{"sha":"c3820ee6eb4f0f72b377cd427d0a3922f2853e91","author":{"email":"ffa74aa72f5ed5e720c03212554d1e38d8a2905e@cockroachlabs.com","name":"Raphael 'kena' Poss"},"message":"Segregate query plan preparation in a new expandPlan interface.\n\nThe makePlan() interface was not well designed, it had too much\nresponsibility. There are really 6 semantic phases on SQL statements:\n\n1.  structural syntax checking.\n2.  gathering the table descriptors and resolving qualified names.\n3.  type inference and type checking.\n4.  normalization and substituting placeholders with actual values.\n5.  building the query plan, including index selection.\n6.  running the query plan.\n\nThe pgwire Prepare phase needs to do steps 1-3 only.\nThe EXPLAIN statement needs to do steps 1-5 only.\n\nPrior to this patch, the makePlan() interface does steps 1-5 in one\ngo. This is arguably too much, although the overhead is not visible to\nusers.\n\nPrior to this patch, the Start() interface re-did steps 2 to 5 again,\nand also performed step 6 for some statements, in particular DELETE\nwhich has a \"fast path\" for when there is no WHERE clause or index\nupdates.\n\nNow EXPLAIN needs a full query plan to work properly, ie it needs to\nobserve completion of step 5. This means EXPLAIN could not merely use\nmakePlan() and had to call Start() to get the fully build query\nplan. But then because Start() also performs side effects (eg. for\nDELETE), this would cause EXPLAIN to do too much work, in particular\ndelete data for DELETE. This is a bug.\n\nThis patch addresses this issue by clearly separating:\n\n- the role of newPlan(), which is to achieve steps 1-3, in some cases step 4.\n\n- a new role played by a new interface planNode.expandPlan(), which is\n  to achieve step 5, possibly re-running step 4, without ever\n  starting step 6.\n\n- the role of Start(), which may start step 6.\n\nUsing this, makePlan() invokes newPlan() then expandPlan(); EXPLAIN\nuses makePlan() and prepare() uses only newPlan().","distinct":true,"url":"https://api.github.com/repos/cockroachdb/cockroach/commits/c3820ee6eb4f0f72b377cd427d0a3922f2853e91"}]}