{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments/41294553","id":41294553,"diff_hunk":"@@ -3287,6 +3287,15 @@ NABoolean TSJRule::topMatch (RelExpr * expr,\n       ((updateExpr->getOperatorType() == REL_UNARY_DELETE) && updateExpr->isMtsStatement()))\n     return FALSE;\n \n+  // It is not semantically correct to convert a MERGE having a \n+  // \"NOT MATCHED\" action to a TSJ, since the former has right \n+  // join semantics. (If we converted here to a TSJ, a non-matching\n+  // row would not be returned by the outer child scan node, so\n+  // the inner child merge node would never see it and hence the\n+  // \"NOT MATCHED\" logic would not be activiated.)\n+  if (updateExpr->isMerge() && updateExpr->insertValues())","path":"core/sql/optimizer/TransRule.cpp","position":10,"original_position":10,"commit_id":"aa0994e15698341727a1ec5414303a7cd5924727","original_commit_id":"aa0994e15698341727a1ec5414303a7cd5924727","user":{"login":"DaveBirdsall","id":5659628,"avatar_url":"https://avatars.githubusercontent.com/u/5659628?v=3","gravatar_id":"","url":"https://api.github.com/users/DaveBirdsall","html_url":"https://github.com/DaveBirdsall","followers_url":"https://api.github.com/users/DaveBirdsall/followers","following_url":"https://api.github.com/users/DaveBirdsall/following{/other_user}","gists_url":"https://api.github.com/users/DaveBirdsall/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveBirdsall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveBirdsall/subscriptions","organizations_url":"https://api.github.com/users/DaveBirdsall/orgs","repos_url":"https://api.github.com/users/DaveBirdsall/repos","events_url":"https://api.github.com/users/DaveBirdsall/events{/privacy}","received_events_url":"https://api.github.com/users/DaveBirdsall/received_events","type":"User","site_admin":false},"body":"Yes, a TSJ for index maintenance still occurs. That is introduced by the Binder, before we get to this code. This code deals with a different issue. When we parse an UPDATE or DELETE statement, the Parser creates a Scan node underneath the Update or Delete node. This rule allows the optimizer to transform that to a TSJ(Scan,Update/Delete). (The alternative plan simply clips off the Scan and an Update/Delete node by itself remains.) For MERGE with a NOT MATCHED clause, the TSJ transformation gives an incorrect plan.","created_at":"2015-10-06T17:24:17Z","updated_at":"2015-10-06T17:24:17Z","html_url":"https://github.com/apache/incubator-trafodion/pull/102#discussion_r41294553","pull_request_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/102","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments/41294553"},"html":{"href":"https://github.com/apache/incubator-trafodion/pull/102#discussion_r41294553"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/102"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/102","id":46808351,"html_url":"https://github.com/apache/incubator-trafodion/pull/102","diff_url":"https://github.com/apache/incubator-trafodion/pull/102.diff","patch_url":"https://github.com/apache/incubator-trafodion/pull/102.patch","issue_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/102","number":102,"state":"open","locked":false,"title":"[TRAFODION-25] First draft of costing code for DELETE.","user":{"login":"DaveBirdsall","id":5659628,"avatar_url":"https://avatars.githubusercontent.com/u/5659628?v=3","gravatar_id":"","url":"https://api.github.com/users/DaveBirdsall","html_url":"https://github.com/DaveBirdsall","followers_url":"https://api.github.com/users/DaveBirdsall/followers","following_url":"https://api.github.com/users/DaveBirdsall/following{/other_user}","gists_url":"https://api.github.com/users/DaveBirdsall/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveBirdsall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveBirdsall/subscriptions","organizations_url":"https://api.github.com/users/DaveBirdsall/orgs","repos_url":"https://api.github.com/users/DaveBirdsall/repos","events_url":"https://api.github.com/users/DaveBirdsall/events{/privacy}","received_events_url":"https://api.github.com/users/DaveBirdsall/received_events","type":"User","site_admin":false},"body":"This is the first draft of costing code for the Delete operator\r\nin Trafodion. Formerly a cost of 1 was returned for the Delete\r\noperator. With this change, we can expect better plans for DELETE\r\nstatements.\r\n\r\nPart of the code for the Update operator is in this check-in as\r\nwell, but the main part of the Update code remains to be written.\r\n\r\nTwo CQDs have been added to control execution of this code.\r\n\r\nCQD HBASE_DELETE_COSTING 'ON' causes the new Delete costing code\r\nto be executed. A value of 'OFF' causes the old stub logic (a\r\ncost of 1) to be executed instead. The default for this CQD is\r\n'ON', so this code can be exercised.\r\n\r\nCQD HBASE_UPDATE_COSTING 'ON' causes partial Update costing code\r\nto be executed. This results in a stub cost object of 1e32 to\r\nbe returned. (Actually, this activates a stub that was already\r\nthere in the code; this turned out to be useful in discovering\r\ncertain bugs, fixed below.) A value of 'OFF' causes earlier \r\nstub logic (a cost of 1) to be executed instead. The default\r\nfor this CQD is 'OFF' for now.\r\n\r\nOnce this code has been sufficiently validated, these CQDs will be\r\nremoved.\r\n\r\nSeveral bugs are also fixed in this check-in. All are latent,\r\nexisting bugs that became more visible when regression-testing the\r\nnew costing code due to plan changes.\r\n\r\n1. MERGE with a NOT MATCHED action was being (incorrectly)\r\ntransformed into a nested join in some plans. This caused the\r\nNOT MATCHED action to not be executed. (optimizer/TransRule.cpp,\r\noptimizer/RelUpdate.h)\r\n\r\n2. MERGE error messages generated by the compiler were sometimes\r\nincorrect. (optimizer/BindRelExpr.cpp, generator/GenPreCode.cpp)\r\n\r\n3. A check constraint error message was not being reported when\r\nit should have on a table with SERIALIZED columns. This was caused\r\nby an HBase filter expression being generated with operators\r\nhaving the wrong sense (e.g., < instead of >).\r\n(generator/GenPreCode.cpp)\r\n\r\n4. CLEANUP would fail if the record in the OBJECTS_UNIQ_IDX index\r\nwas missing. This happened because it was using a vanilla DELETE\r\nand the plan for the DELETE changed with the costing changes to \r\nuse index access. The fix was to use CQDs to avoid accessing the\r\nindex when deleting from the OBJECTS table.\r\n(sqlcomp/CmpSeabaseDDLcleanup.cpp)\r\n\r\n5. INITIALIZE AUTHORIZATION would fail if there was a row in\r\nthe OBJECTS table with an object_owner that does not exist in\r\nthe AUTHS table. (The latter can happen in rare circumstances\r\nwhen toggling authorization off and on repeatedly. That is a\r\nbug in its own right that remains outstanding.) This has been\r\nworked around by writing 'DB__ROOT' to the OBJECT_PRIVILEGES\r\ntable when the object_owner is invalid.\r\n\r\nSome other issues were noticed during unit testing that will\r\nbe addressed in later check-ins:\r\n\r\n1. Scan costs for DELETEs using TSJ plans are grossly over-\r\nestimated. The cause is that the generated join predicates between\r\nthe Scan and Delete operators are being assigned a default\r\nselectivity of 1/3. This is an existing, latent bug.\r\n\r\n2. The HBaseDeleteRule in the optimizer considers a Delete-only\r\nplan (that is, without a TSJ of a Scan to a Delete) when there\r\nare equality predicates on all key columns, and when there are\r\nno predicates on key columns at all. The former is correct, the\r\nlatter is almost never a good plan. Costing should prevent the\r\nlatter from being chosen but still this is unnecessary extra\r\ncomputation. (The rule does not consider Delete-only plans when\r\na proper subset of the key columns have equality predicates.)\r\nThis is an existing, latent bug.\r\n\r\n ","created_at":"2015-10-05T17:21:02Z","updated_at":"2015-10-06T17:24:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"257f52a9981dfa67d87b9ad7bf1983df623f7709","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/102/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/102/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/102/comments","statuses_url":"https://api.github.com/repos/apache/incubator-trafodion/statuses/aa0994e15698341727a1ec5414303a7cd5924727","head":{"label":"DaveBirdsall:DeleteCostingDraft1","ref":"DeleteCostingDraft1","sha":"aa0994e15698341727a1ec5414303a7cd5924727","user":{"login":"DaveBirdsall","id":5659628,"avatar_url":"https://avatars.githubusercontent.com/u/5659628?v=3","gravatar_id":"","url":"https://api.github.com/users/DaveBirdsall","html_url":"https://github.com/DaveBirdsall","followers_url":"https://api.github.com/users/DaveBirdsall/followers","following_url":"https://api.github.com/users/DaveBirdsall/following{/other_user}","gists_url":"https://api.github.com/users/DaveBirdsall/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveBirdsall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveBirdsall/subscriptions","organizations_url":"https://api.github.com/users/DaveBirdsall/orgs","repos_url":"https://api.github.com/users/DaveBirdsall/repos","events_url":"https://api.github.com/users/DaveBirdsall/events{/privacy}","received_events_url":"https://api.github.com/users/DaveBirdsall/received_events","type":"User","site_admin":false},"repo":{"id":38782828,"name":"incubator-trafodion","full_name":"DaveBirdsall/incubator-trafodion","owner":{"login":"DaveBirdsall","id":5659628,"avatar_url":"https://avatars.githubusercontent.com/u/5659628?v=3","gravatar_id":"","url":"https://api.github.com/users/DaveBirdsall","html_url":"https://github.com/DaveBirdsall","followers_url":"https://api.github.com/users/DaveBirdsall/followers","following_url":"https://api.github.com/users/DaveBirdsall/following{/other_user}","gists_url":"https://api.github.com/users/DaveBirdsall/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveBirdsall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveBirdsall/subscriptions","organizations_url":"https://api.github.com/users/DaveBirdsall/orgs","repos_url":"https://api.github.com/users/DaveBirdsall/repos","events_url":"https://api.github.com/users/DaveBirdsall/events{/privacy}","received_events_url":"https://api.github.com/users/DaveBirdsall/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DaveBirdsall/incubator-trafodion","description":"Mirror of Apache Trafodion (Incubating)","fork":true,"url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion","forks_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/forks","keys_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/teams","hooks_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/hooks","issue_events_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/issues/events{/number}","events_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/events","assignees_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/assignees{/user}","branches_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/branches{/branch}","tags_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/tags","blobs_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/git/refs{/sha}","trees_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/statuses/{sha}","languages_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/languages","stargazers_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/stargazers","contributors_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/contributors","subscribers_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/subscribers","subscription_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/subscription","commits_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/commits{/sha}","git_commits_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/git/commits{/sha}","comments_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/comments{/number}","issue_comment_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/issues/comments{/number}","contents_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/contents/{+path}","compare_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/merges","archive_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/downloads","issues_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/issues{/number}","pulls_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/pulls{/number}","milestones_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/milestones{/number}","notifications_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/labels{/name}","releases_url":"https://api.github.com/repos/DaveBirdsall/incubator-trafodion/releases{/id}","created_at":"2015-07-08T22:12:46Z","updated_at":"2015-07-08T22:13:26Z","pushed_at":"2015-10-05T17:16:17Z","git_url":"git://github.com/DaveBirdsall/incubator-trafodion.git","ssh_url":"git@github.com:DaveBirdsall/incubator-trafodion.git","clone_url":"https://github.com/DaveBirdsall/incubator-trafodion.git","svn_url":"https://github.com/DaveBirdsall/incubator-trafodion","homepage":null,"size":56919,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"bb759855b4ff2488a3f0d3f10585589eacdba1cb","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":36349344,"name":"incubator-trafodion","full_name":"apache/incubator-trafodion","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-trafodion","description":"Mirror of Apache Trafodion (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-trafodion","forks_url":"https://api.github.com/repos/apache/incubator-trafodion/forks","keys_url":"https://api.github.com/repos/apache/incubator-trafodion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-trafodion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-trafodion/teams","hooks_url":"https://api.github.com/repos/apache/incubator-trafodion/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-trafodion/events","assignees_url":"https://api.github.com/repos/apache/incubator-trafodion/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-trafodion/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-trafodion/tags","blobs_url":"https://api.github.com/repos/apache/incubator-trafodion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-trafodion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-trafodion/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-trafodion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-trafodion/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-trafodion/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-trafodion/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-trafodion/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-trafodion/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-trafodion/subscription","commits_url":"https://api.github.com/repos/apache/incubator-trafodion/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-trafodion/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-trafodion/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-trafodion/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-trafodion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-trafodion/merges","archive_url":"https://api.github.com/repos/apache/incubator-trafodion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-trafodion/downloads","issues_url":"https://api.github.com/repos/apache/incubator-trafodion/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-trafodion/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-trafodion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-trafodion/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-trafodion/releases{/id}","created_at":"2015-05-27T07:00:05Z","updated_at":"2015-10-05T00:52:23Z","pushed_at":"2015-10-06T16:37:30Z","git_url":"git://github.com/apache/incubator-trafodion.git","ssh_url":"git@github.com:apache/incubator-trafodion.git","clone_url":"https://github.com/apache/incubator-trafodion.git","svn_url":"https://github.com/apache/incubator-trafodion","homepage":null,"size":61395,"stargazers_count":17,"watchers_count":17,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":41,"mirror_url":"git://git.apache.org/incubator-trafodion.git","open_issues_count":5,"forks":41,"open_issues":5,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/102"},"html":{"href":"https://github.com/apache/incubator-trafodion/pull/102"},"issue":{"href":"https://api.github.com/repos/apache/incubator-trafodion/issues/102"},"comments":{"href":"https://api.github.com/repos/apache/incubator-trafodion/issues/102/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/102/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/102/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-trafodion/statuses/aa0994e15698341727a1ec5414303a7cd5924727"}}}}