{"action":"created","comment":{"url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments/72384000","id":72384000,"diff_hunk":"@@ -3237,34 +3237,73 @@ heap_truncate(List *relids)\n \t\t/*\n \t\t * CONCERN: Not clear this EVER makes sense for Append-Only.\n \t\t */\n-\t\tif (RelationIsAoRows(rel) || RelationIsAoCols(rel))\n+\t\tif (RelationIsHeap(rel))\n \t\t{\n+\t\t\trelations = lappend(relations, rel);\n+\t\t}\n+\t\tif (RelationIsAoRows(rel))\n+\t\t{\n+\t\t\tFileSegInfo\t  **fsi;\n+\t\t\tint\t\t\t\ttotalSegs;\n+\t\t\tint\t\t\t\ti;\n+\t\t\tList\t\t   *seg_list = NIL;\n+\n+\t\t\tCommandCounterIncrement();\n \t\t\taoEntry = GetAppendOnlyEntry(rid, SnapshotNow);\n+\t\t\tfsi = GetAllFileSegInfo(rel, aoEntry, SnapshotNow, &totalSegs);\n+\t\t\tfor (i = 0; i < totalSegs; i++)\n+\t\t\t{\n+\t\t\t\tint\t\tsegno = fsi[i]->segno;\n \n-\t\t\t/* If there is an aoseg table, add it to the list too */\n-\t\t\taosegrelid = aoEntry->segrelid;\n-\t\t\tif (OidIsValid(aosegrelid))\n+\t\t\t\tseg_list = lappend_int(seg_list, segno);\n+\t\t\t\tLockRelationAppendOnlySegmentFile(&rel->rd_node, segno,\n+\t\t\t\t\t\tAccessExclusiveLock, false);\n+\t\t\t\tSetFileSegInfoState(rel, aoEntry, segno,\n+\t\t\t\t\t\tAOSEG_STATE_AWAITING_DROP);\n+\t\t\t}\n+\t\t\tif (fsi)","path":"src/backend/catalog/heap.c","position":57,"original_position":57,"commit_id":"923c098656389368b045f6e5a4ac3b91e48a8995","original_commit_id":"923c098656389368b045f6e5a4ac3b91e48a8995","user":{"login":"asimrp","id":4307811,"avatar_url":"https://avatars.githubusercontent.com/u/4307811?v=3","gravatar_id":"","url":"https://api.github.com/users/asimrp","html_url":"https://github.com/asimrp","followers_url":"https://api.github.com/users/asimrp/followers","following_url":"https://api.github.com/users/asimrp/following{/other_user}","gists_url":"https://api.github.com/users/asimrp/gists{/gist_id}","starred_url":"https://api.github.com/users/asimrp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asimrp/subscriptions","organizations_url":"https://api.github.com/users/asimrp/orgs","repos_url":"https://api.github.com/users/asimrp/repos","events_url":"https://api.github.com/users/asimrp/events{/privacy}","received_events_url":"https://api.github.com/users/asimrp/received_events","type":"User","site_admin":false},"body":"`fsi` should be initialized to NULL.  Same applies to AOCS case below.","created_at":"2016-07-27T05:52:45Z","updated_at":"2016-07-27T05:52:45Z","html_url":"https://github.com/greenplum-db/gpdb/pull/960#discussion_r72384000","pull_request_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/960","_links":{"self":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments/72384000"},"html":{"href":"https://github.com/greenplum-db/gpdb/pull/960#discussion_r72384000"},"pull_request":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/960"}}},"pull_request":{"url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/960","id":77779049,"html_url":"https://github.com/greenplum-db/gpdb/pull/960","diff_url":"https://github.com/greenplum-db/gpdb/pull/960.diff","patch_url":"https://github.com/greenplum-db/gpdb/pull/960.patch","issue_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/960","number":960,"state":"open","locked":false,"title":"Bug fix which append only temp table cannot be inserted multiple times.","user":{"login":"Tao-Ma","id":6395057,"avatar_url":"https://avatars.githubusercontent.com/u/6395057?v=3","gravatar_id":"","url":"https://api.github.com/users/Tao-Ma","html_url":"https://github.com/Tao-Ma","followers_url":"https://api.github.com/users/Tao-Ma/followers","following_url":"https://api.github.com/users/Tao-Ma/following{/other_user}","gists_url":"https://api.github.com/users/Tao-Ma/gists{/gist_id}","starred_url":"https://api.github.com/users/Tao-Ma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tao-Ma/subscriptions","organizations_url":"https://api.github.com/users/Tao-Ma/orgs","repos_url":"https://api.github.com/users/Tao-Ma/repos","events_url":"https://api.github.com/users/Tao-Ma/events{/privacy}","received_events_url":"https://api.github.com/users/Tao-Ma/received_events","type":"User","site_admin":false},"body":"\r\nI opened the Issue #913 and @asimrp reproduce it.\r\n\r\nI digged into the code and found that append-only temp table do not implement the delete rows behaviour.\r\n\r\nFor the heap table, a truncation is enough. But the append only table save the data file information in the aoseg heap table. Truncate aoseg heap table will ruin the dependency between it and the gp_relation_node.\r\n\r\nThe correct way to delete rows from a append only table is that drop the data file or truncate them. The compaction codes is a good candidate to be the foundation of append-only temp table.\r\n\r\nI add some basic tests for the fix too.","created_at":"2016-07-18T09:22:06Z","updated_at":"2016-07-27T05:52:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2eb0f5b17d2cd2a7ec78553eb6326be0b41c1555","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/960/commits","review_comments_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/960/comments","review_comment_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/960/comments","statuses_url":"https://api.github.com/repos/greenplum-db/gpdb/statuses/923c098656389368b045f6e5a4ac3b91e48a8995","head":{"label":"Tao-Ma:temp-table","ref":"temp-table","sha":"923c098656389368b045f6e5a4ac3b91e48a8995","user":{"login":"Tao-Ma","id":6395057,"avatar_url":"https://avatars.githubusercontent.com/u/6395057?v=3","gravatar_id":"","url":"https://api.github.com/users/Tao-Ma","html_url":"https://github.com/Tao-Ma","followers_url":"https://api.github.com/users/Tao-Ma/followers","following_url":"https://api.github.com/users/Tao-Ma/following{/other_user}","gists_url":"https://api.github.com/users/Tao-Ma/gists{/gist_id}","starred_url":"https://api.github.com/users/Tao-Ma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tao-Ma/subscriptions","organizations_url":"https://api.github.com/users/Tao-Ma/orgs","repos_url":"https://api.github.com/users/Tao-Ma/repos","events_url":"https://api.github.com/users/Tao-Ma/events{/privacy}","received_events_url":"https://api.github.com/users/Tao-Ma/received_events","type":"User","site_admin":false},"repo":{"id":45092706,"name":"gpdb","full_name":"Tao-Ma/gpdb","owner":{"login":"Tao-Ma","id":6395057,"avatar_url":"https://avatars.githubusercontent.com/u/6395057?v=3","gravatar_id":"","url":"https://api.github.com/users/Tao-Ma","html_url":"https://github.com/Tao-Ma","followers_url":"https://api.github.com/users/Tao-Ma/followers","following_url":"https://api.github.com/users/Tao-Ma/following{/other_user}","gists_url":"https://api.github.com/users/Tao-Ma/gists{/gist_id}","starred_url":"https://api.github.com/users/Tao-Ma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tao-Ma/subscriptions","organizations_url":"https://api.github.com/users/Tao-Ma/orgs","repos_url":"https://api.github.com/users/Tao-Ma/repos","events_url":"https://api.github.com/users/Tao-Ma/events{/privacy}","received_events_url":"https://api.github.com/users/Tao-Ma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Tao-Ma/gpdb","description":"Pivotal Greenplum Database","fork":true,"url":"https://api.github.com/repos/Tao-Ma/gpdb","forks_url":"https://api.github.com/repos/Tao-Ma/gpdb/forks","keys_url":"https://api.github.com/repos/Tao-Ma/gpdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tao-Ma/gpdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tao-Ma/gpdb/teams","hooks_url":"https://api.github.com/repos/Tao-Ma/gpdb/hooks","issue_events_url":"https://api.github.com/repos/Tao-Ma/gpdb/issues/events{/number}","events_url":"https://api.github.com/repos/Tao-Ma/gpdb/events","assignees_url":"https://api.github.com/repos/Tao-Ma/gpdb/assignees{/user}","branches_url":"https://api.github.com/repos/Tao-Ma/gpdb/branches{/branch}","tags_url":"https://api.github.com/repos/Tao-Ma/gpdb/tags","blobs_url":"https://api.github.com/repos/Tao-Ma/gpdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tao-Ma/gpdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tao-Ma/gpdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tao-Ma/gpdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tao-Ma/gpdb/statuses/{sha}","languages_url":"https://api.github.com/repos/Tao-Ma/gpdb/languages","stargazers_url":"https://api.github.com/repos/Tao-Ma/gpdb/stargazers","contributors_url":"https://api.github.com/repos/Tao-Ma/gpdb/contributors","subscribers_url":"https://api.github.com/repos/Tao-Ma/gpdb/subscribers","subscription_url":"https://api.github.com/repos/Tao-Ma/gpdb/subscription","commits_url":"https://api.github.com/repos/Tao-Ma/gpdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tao-Ma/gpdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tao-Ma/gpdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tao-Ma/gpdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tao-Ma/gpdb/contents/{+path}","compare_url":"https://api.github.com/repos/Tao-Ma/gpdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tao-Ma/gpdb/merges","archive_url":"https://api.github.com/repos/Tao-Ma/gpdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tao-Ma/gpdb/downloads","issues_url":"https://api.github.com/repos/Tao-Ma/gpdb/issues{/number}","pulls_url":"https://api.github.com/repos/Tao-Ma/gpdb/pulls{/number}","milestones_url":"https://api.github.com/repos/Tao-Ma/gpdb/milestones{/number}","notifications_url":"https://api.github.com/repos/Tao-Ma/gpdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tao-Ma/gpdb/labels{/name}","releases_url":"https://api.github.com/repos/Tao-Ma/gpdb/releases{/id}","deployments_url":"https://api.github.com/repos/Tao-Ma/gpdb/deployments","created_at":"2015-10-28T06:12:11Z","updated_at":"2016-01-20T09:39:05Z","pushed_at":"2016-07-24T02:24:40Z","git_url":"git://github.com/Tao-Ma/gpdb.git","ssh_url":"git@github.com:Tao-Ma/gpdb.git","clone_url":"https://github.com/Tao-Ma/gpdb.git","svn_url":"https://github.com/Tao-Ma/gpdb","homepage":"http://greenplum.org","size":156780,"stargazers_count":0,"watchers_count":0,"language":"PLpgSQL","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":"greenplum-db:master","ref":"master","sha":"6f5b61bd991da6184bf66dc1e0b9b6be824df3bb","user":{"login":"greenplum-db","id":14097842,"avatar_url":"https://avatars.githubusercontent.com/u/14097842?v=3","gravatar_id":"","url":"https://api.github.com/users/greenplum-db","html_url":"https://github.com/greenplum-db","followers_url":"https://api.github.com/users/greenplum-db/followers","following_url":"https://api.github.com/users/greenplum-db/following{/other_user}","gists_url":"https://api.github.com/users/greenplum-db/gists{/gist_id}","starred_url":"https://api.github.com/users/greenplum-db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenplum-db/subscriptions","organizations_url":"https://api.github.com/users/greenplum-db/orgs","repos_url":"https://api.github.com/users/greenplum-db/repos","events_url":"https://api.github.com/users/greenplum-db/events{/privacy}","received_events_url":"https://api.github.com/users/greenplum-db/received_events","type":"Organization","site_admin":false},"repo":{"id":44781140,"name":"gpdb","full_name":"greenplum-db/gpdb","owner":{"login":"greenplum-db","id":14097842,"avatar_url":"https://avatars.githubusercontent.com/u/14097842?v=3","gravatar_id":"","url":"https://api.github.com/users/greenplum-db","html_url":"https://github.com/greenplum-db","followers_url":"https://api.github.com/users/greenplum-db/followers","following_url":"https://api.github.com/users/greenplum-db/following{/other_user}","gists_url":"https://api.github.com/users/greenplum-db/gists{/gist_id}","starred_url":"https://api.github.com/users/greenplum-db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenplum-db/subscriptions","organizations_url":"https://api.github.com/users/greenplum-db/orgs","repos_url":"https://api.github.com/users/greenplum-db/repos","events_url":"https://api.github.com/users/greenplum-db/events{/privacy}","received_events_url":"https://api.github.com/users/greenplum-db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/greenplum-db/gpdb","description":"Greenplum Database","fork":false,"url":"https://api.github.com/repos/greenplum-db/gpdb","forks_url":"https://api.github.com/repos/greenplum-db/gpdb/forks","keys_url":"https://api.github.com/repos/greenplum-db/gpdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/greenplum-db/gpdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/greenplum-db/gpdb/teams","hooks_url":"https://api.github.com/repos/greenplum-db/gpdb/hooks","issue_events_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/events{/number}","events_url":"https://api.github.com/repos/greenplum-db/gpdb/events","assignees_url":"https://api.github.com/repos/greenplum-db/gpdb/assignees{/user}","branches_url":"https://api.github.com/repos/greenplum-db/gpdb/branches{/branch}","tags_url":"https://api.github.com/repos/greenplum-db/gpdb/tags","blobs_url":"https://api.github.com/repos/greenplum-db/gpdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/greenplum-db/gpdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/greenplum-db/gpdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/greenplum-db/gpdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/greenplum-db/gpdb/statuses/{sha}","languages_url":"https://api.github.com/repos/greenplum-db/gpdb/languages","stargazers_url":"https://api.github.com/repos/greenplum-db/gpdb/stargazers","contributors_url":"https://api.github.com/repos/greenplum-db/gpdb/contributors","subscribers_url":"https://api.github.com/repos/greenplum-db/gpdb/subscribers","subscription_url":"https://api.github.com/repos/greenplum-db/gpdb/subscription","commits_url":"https://api.github.com/repos/greenplum-db/gpdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/greenplum-db/gpdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/greenplum-db/gpdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/greenplum-db/gpdb/contents/{+path}","compare_url":"https://api.github.com/repos/greenplum-db/gpdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/greenplum-db/gpdb/merges","archive_url":"https://api.github.com/repos/greenplum-db/gpdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/greenplum-db/gpdb/downloads","issues_url":"https://api.github.com/repos/greenplum-db/gpdb/issues{/number}","pulls_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls{/number}","milestones_url":"https://api.github.com/repos/greenplum-db/gpdb/milestones{/number}","notifications_url":"https://api.github.com/repos/greenplum-db/gpdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/greenplum-db/gpdb/labels{/name}","releases_url":"https://api.github.com/repos/greenplum-db/gpdb/releases{/id}","deployments_url":"https://api.github.com/repos/greenplum-db/gpdb/deployments","created_at":"2015-10-23T00:25:17Z","updated_at":"2016-07-26T02:47:34Z","pushed_at":"2016-07-27T01:32:59Z","git_url":"git://github.com/greenplum-db/gpdb.git","ssh_url":"git@github.com:greenplum-db/gpdb.git","clone_url":"https://github.com/greenplum-db/gpdb.git","svn_url":"https://github.com/greenplum-db/gpdb","homepage":"http://greenplum.org","size":171446,"stargazers_count":1539,"watchers_count":1539,"language":"PLpgSQL","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":426,"mirror_url":null,"open_issues_count":115,"forks":426,"open_issues":115,"watchers":1539,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/960"},"html":{"href":"https://github.com/greenplum-db/gpdb/pull/960"},"issue":{"href":"https://api.github.com/repos/greenplum-db/gpdb/issues/960"},"comments":{"href":"https://api.github.com/repos/greenplum-db/gpdb/issues/960/comments"},"review_comments":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/960/comments"},"review_comment":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/960/commits"},"statuses":{"href":"https://api.github.com/repos/greenplum-db/gpdb/statuses/923c098656389368b045f6e5a4ac3b91e48a8995"}}}}
{"actor":{"display_login":"asimrp"}}