{"action":"created","comment":{"url":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/comments/36266941","id":36266941,"diff_hunk":"@@ -0,0 +1,135 @@\n+#include \"postgres_fe.h\"\n+#include \"adhoc_compat.h\"\n+#include \"rowmap.h\"\n+#include \"rowstream.h\"\n+#include \"screen.h\"\n+#include \"model.h\"\n+\n+#include <curses.h>\n+#include <utils/rbtree.h>\n+#include <unistd.h>\n+#include <fcntl.h>\n+#include <poll.h>\n+#include <signal.h>\n+\n+/*\n+ * pipeline adhoc query client\n+ */\n+\n+typedef struct App\n+{\n+\tModel* model;\n+\tScreen* screen;\n+} App;\n+\n+volatile int keep_running = 1;\n+void sighandle(int);\n+\n+void sighandle(int x)\n+{\n+\tkeep_running = 0;\n+}\n+\n+void row_callback(void* ctx, int type, Row* row);\n+\n+int\n+main(int argc, char *argv[])\n+{\n+\tApp app = {0,0};\n+\tModel *model = ModelInit();\n+\n+\tScreen *screen = 0;\n+\tRowStream *stream = 0;\n+\n+\tsignal(SIGINT, sighandle);\n+\tscreen = ScreenInit(model);\n+\n+\tapp.model = model;\n+\tapp.screen = screen;\n+\n+\tstream = RowStreamInit(row_callback, &app);\n+\n+\twhile (keep_running)\n+\t{\n+\t\tstruct pollfd pfd[2];\n+\t\tint rc = 0;\n+\n+\t\tmemset(&pfd, 0, sizeof(pfd));\n+\n+\t\tpfd[0].fd = RowStreamFd(stream);\n+\t\tpfd[0].events = POLLIN;\n+\t\tpfd[0].revents = 0;\n+\n+\t\tif (screen)\n+\t\t{\n+\t\t\tpfd[1].fd = ScreenFd(screen);\n+\t\t\tpfd[1].events = POLLIN;\n+\t\t\tpfd[1].revents = 0;\n+\t\t}\n+\n+\t\trc = poll(pfd, screen ? 2 : 1, -1);\n+\n+\t\tif (rc < 0)\n+\t\t{\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (pfd[0].revents & POLLIN)\n+\t\t{\n+\t\t\t// TODO - take a snapshot instead\n+\t\t\tif (screen && ScreenIsPaused(screen))\n+\t\t\t{\n+\t\t\t\tusleep(1000);\n+\t\t\t}\n+\t\t\telse\n+\t\t\t{\n+\t\t\t\tbool fin = RowStreamHandleInput(stream);\n+\n+\t\t\t\tif (fin)\n+\t\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (screen)\n+\t\t{\n+\t\t\tif (pfd[1].revents & POLLIN)\n+\t\t\t{\n+\t\t\t\tScreenHandleInput(screen);\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\tif (screen)\n+\t{\n+\t\tScreenDestroy(screen);\n+\t}\n+\n+\tRowStreamDestroy(stream);\n+\tModelDestroy(model);\n+\n+\treturn 0;\n+}\n+\n+void row_callback(void* ctx, int type, Row* row)","path":"src/bin/psql/adhoc.c","position":113,"original_position":113,"commit_id":"52421c00982864d6f76a6e055af1be0c313afca3","original_commit_id":"52421c00982864d6f76a6e055af1be0c313afca3","user":{"login":"derekjn","id":384666,"avatar_url":"https://avatars.githubusercontent.com/u/384666?v=3","gravatar_id":"","url":"https://api.github.com/users/derekjn","html_url":"https://github.com/derekjn","followers_url":"https://api.github.com/users/derekjn/followers","following_url":"https://api.github.com/users/derekjn/following{/other_user}","gists_url":"https://api.github.com/users/derekjn/gists{/gist_id}","starred_url":"https://api.github.com/users/derekjn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekjn/subscriptions","organizations_url":"https://api.github.com/users/derekjn/orgs","repos_url":"https://api.github.com/users/derekjn/repos","events_url":"https://api.github.com/users/derekjn/events{/privacy}","received_events_url":"https://api.github.com/users/derekjn/received_events","type":"User","site_admin":false},"body":"As per the style guide, function return types go on their own line:\r\n\r\n```\r\nvoid\r\nrow_callback(void* ctx, int type, Row* row)\r\n```","created_at":"2015-08-05T03:25:19Z","updated_at":"2015-08-05T03:25:19Z","html_url":"https://github.com/pipelinedb/pipelinedb/pull/1082#discussion_r36266941","pull_request_url":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/1082","_links":{"self":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/comments/36266941"},"html":{"href":"https://github.com/pipelinedb/pipelinedb/pull/1082#discussion_r36266941"},"pull_request":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/1082"}}},"pull_request":{"url":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/1082","id":41623969,"html_url":"https://github.com/pipelinedb/pipelinedb/pull/1082","diff_url":"https://github.com/pipelinedb/pipelinedb/pull/1082.diff","patch_url":"https://github.com/pipelinedb/pipelinedb/pull/1082.patch","issue_url":"https://api.github.com/repos/pipelinedb/pipelinedb/issues/1082","number":1082,"state":"open","locked":false,"title":"1078 adhoc client","user":{"login":"loadzero","id":10953013,"avatar_url":"https://avatars.githubusercontent.com/u/10953013?v=3","gravatar_id":"","url":"https://api.github.com/users/loadzero","html_url":"https://github.com/loadzero","followers_url":"https://api.github.com/users/loadzero/followers","following_url":"https://api.github.com/users/loadzero/following{/other_user}","gists_url":"https://api.github.com/users/loadzero/gists{/gist_id}","starred_url":"https://api.github.com/users/loadzero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loadzero/subscriptions","organizations_url":"https://api.github.com/users/loadzero/orgs","repos_url":"https://api.github.com/users/loadzero/repos","events_url":"https://api.github.com/users/loadzero/events{/privacy}","received_events_url":"https://api.github.com/users/loadzero/received_events","type":"User","site_admin":false},"body":"Finished work on the ncurses adhoc query client for the time being.\r\n\r\nThe binary is called ```padhoc```\r\n\r\nRun it like this\r\n\r\n```\r\n./bin/generate-adhoc | padhoc\r\n```\r\n\r\nThe keys are\r\n\r\n```\r\nUP         ScreenScrollUp\r\nDOWN       ScreenScrollDown\r\nLEFT       ScreenScrollLeft\r\nRIGHT      ScreenScrollRight\r\nNPAGE      ScreenPageDown\r\nHOME       ScreenHome\r\nEND        ScreenEnd\r\nPPAGE      ScreenPageUp\r\nTAB        ScreenNextCol\r\nSHIFT+TAB  ScreenPrevCol\r\np          ScreenTogglePause\r\n```\r\nctrl-c will quit.\r\n\r\nTODO: \r\n\r\n* hook up to the backend\r\n* optimise the rowmap\r\n* add tests\r\n* unicode support ","created_at":"2015-08-04T22:13:06Z","updated_at":"2015-08-05T03:25:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4b2b05c36a088e94f31b0a83250bcc48a9bc27e0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/1082/commits","review_comments_url":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/1082/comments","review_comment_url":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pipelinedb/pipelinedb/issues/1082/comments","statuses_url":"https://api.github.com/repos/pipelinedb/pipelinedb/statuses/52421c00982864d6f76a6e055af1be0c313afca3","head":{"label":"pipelinedb:1078-adhoc-client","ref":"1078-adhoc-client","sha":"52421c00982864d6f76a6e055af1be0c313afca3","user":{"login":"pipelinedb","id":5367380,"avatar_url":"https://avatars.githubusercontent.com/u/5367380?v=3","gravatar_id":"","url":"https://api.github.com/users/pipelinedb","html_url":"https://github.com/pipelinedb","followers_url":"https://api.github.com/users/pipelinedb/followers","following_url":"https://api.github.com/users/pipelinedb/following{/other_user}","gists_url":"https://api.github.com/users/pipelinedb/gists{/gist_id}","starred_url":"https://api.github.com/users/pipelinedb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipelinedb/subscriptions","organizations_url":"https://api.github.com/users/pipelinedb/orgs","repos_url":"https://api.github.com/users/pipelinedb/repos","events_url":"https://api.github.com/users/pipelinedb/events{/privacy}","received_events_url":"https://api.github.com/users/pipelinedb/received_events","type":"Organization","site_admin":false},"repo":{"id":14702444,"name":"pipelinedb","full_name":"pipelinedb/pipelinedb","owner":{"login":"pipelinedb","id":5367380,"avatar_url":"https://avatars.githubusercontent.com/u/5367380?v=3","gravatar_id":"","url":"https://api.github.com/users/pipelinedb","html_url":"https://github.com/pipelinedb","followers_url":"https://api.github.com/users/pipelinedb/followers","following_url":"https://api.github.com/users/pipelinedb/following{/other_user}","gists_url":"https://api.github.com/users/pipelinedb/gists{/gist_id}","starred_url":"https://api.github.com/users/pipelinedb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipelinedb/subscriptions","organizations_url":"https://api.github.com/users/pipelinedb/orgs","repos_url":"https://api.github.com/users/pipelinedb/repos","events_url":"https://api.github.com/users/pipelinedb/events{/privacy}","received_events_url":"https://api.github.com/users/pipelinedb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pipelinedb/pipelinedb","description":"The Streaming SQL Database","fork":false,"url":"https://api.github.com/repos/pipelinedb/pipelinedb","forks_url":"https://api.github.com/repos/pipelinedb/pipelinedb/forks","keys_url":"https://api.github.com/repos/pipelinedb/pipelinedb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pipelinedb/pipelinedb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pipelinedb/pipelinedb/teams","hooks_url":"https://api.github.com/repos/pipelinedb/pipelinedb/hooks","issue_events_url":"https://api.github.com/repos/pipelinedb/pipelinedb/issues/events{/number}","events_url":"https://api.github.com/repos/pipelinedb/pipelinedb/events","assignees_url":"https://api.github.com/repos/pipelinedb/pipelinedb/assignees{/user}","branches_url":"https://api.github.com/repos/pipelinedb/pipelinedb/branches{/branch}","tags_url":"https://api.github.com/repos/pipelinedb/pipelinedb/tags","blobs_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pipelinedb/pipelinedb/statuses/{sha}","languages_url":"https://api.github.com/repos/pipelinedb/pipelinedb/languages","stargazers_url":"https://api.github.com/repos/pipelinedb/pipelinedb/stargazers","contributors_url":"https://api.github.com/repos/pipelinedb/pipelinedb/contributors","subscribers_url":"https://api.github.com/repos/pipelinedb/pipelinedb/subscribers","subscription_url":"https://api.github.com/repos/pipelinedb/pipelinedb/subscription","commits_url":"https://api.github.com/repos/pipelinedb/pipelinedb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pipelinedb/pipelinedb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pipelinedb/pipelinedb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pipelinedb/pipelinedb/contents/{+path}","compare_url":"https://api.github.com/repos/pipelinedb/pipelinedb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pipelinedb/pipelinedb/merges","archive_url":"https://api.github.com/repos/pipelinedb/pipelinedb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pipelinedb/pipelinedb/downloads","issues_url":"https://api.github.com/repos/pipelinedb/pipelinedb/issues{/number}","pulls_url":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls{/number}","milestones_url":"https://api.github.com/repos/pipelinedb/pipelinedb/milestones{/number}","notifications_url":"https://api.github.com/repos/pipelinedb/pipelinedb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pipelinedb/pipelinedb/labels{/name}","releases_url":"https://api.github.com/repos/pipelinedb/pipelinedb/releases{/id}","created_at":"2013-11-26T00:11:48Z","updated_at":"2015-08-04T19:55:41Z","pushed_at":"2015-08-05T01:52:49Z","git_url":"git://github.com/pipelinedb/pipelinedb.git","ssh_url":"git@github.com:pipelinedb/pipelinedb.git","clone_url":"https://github.com/pipelinedb/pipelinedb.git","svn_url":"https://github.com/pipelinedb/pipelinedb","homepage":"http://pipelinedb.com","size":62113,"stargazers_count":571,"watchers_count":571,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":59,"forks":21,"open_issues":59,"watchers":571,"default_branch":"master"}},"base":{"label":"pipelinedb:master","ref":"master","sha":"16a81f9c8b251e68a5dda4b25bf4148b336f52d9","user":{"login":"pipelinedb","id":5367380,"avatar_url":"https://avatars.githubusercontent.com/u/5367380?v=3","gravatar_id":"","url":"https://api.github.com/users/pipelinedb","html_url":"https://github.com/pipelinedb","followers_url":"https://api.github.com/users/pipelinedb/followers","following_url":"https://api.github.com/users/pipelinedb/following{/other_user}","gists_url":"https://api.github.com/users/pipelinedb/gists{/gist_id}","starred_url":"https://api.github.com/users/pipelinedb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipelinedb/subscriptions","organizations_url":"https://api.github.com/users/pipelinedb/orgs","repos_url":"https://api.github.com/users/pipelinedb/repos","events_url":"https://api.github.com/users/pipelinedb/events{/privacy}","received_events_url":"https://api.github.com/users/pipelinedb/received_events","type":"Organization","site_admin":false},"repo":{"id":14702444,"name":"pipelinedb","full_name":"pipelinedb/pipelinedb","owner":{"login":"pipelinedb","id":5367380,"avatar_url":"https://avatars.githubusercontent.com/u/5367380?v=3","gravatar_id":"","url":"https://api.github.com/users/pipelinedb","html_url":"https://github.com/pipelinedb","followers_url":"https://api.github.com/users/pipelinedb/followers","following_url":"https://api.github.com/users/pipelinedb/following{/other_user}","gists_url":"https://api.github.com/users/pipelinedb/gists{/gist_id}","starred_url":"https://api.github.com/users/pipelinedb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipelinedb/subscriptions","organizations_url":"https://api.github.com/users/pipelinedb/orgs","repos_url":"https://api.github.com/users/pipelinedb/repos","events_url":"https://api.github.com/users/pipelinedb/events{/privacy}","received_events_url":"https://api.github.com/users/pipelinedb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pipelinedb/pipelinedb","description":"The Streaming SQL Database","fork":false,"url":"https://api.github.com/repos/pipelinedb/pipelinedb","forks_url":"https://api.github.com/repos/pipelinedb/pipelinedb/forks","keys_url":"https://api.github.com/repos/pipelinedb/pipelinedb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pipelinedb/pipelinedb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pipelinedb/pipelinedb/teams","hooks_url":"https://api.github.com/repos/pipelinedb/pipelinedb/hooks","issue_events_url":"https://api.github.com/repos/pipelinedb/pipelinedb/issues/events{/number}","events_url":"https://api.github.com/repos/pipelinedb/pipelinedb/events","assignees_url":"https://api.github.com/repos/pipelinedb/pipelinedb/assignees{/user}","branches_url":"https://api.github.com/repos/pipelinedb/pipelinedb/branches{/branch}","tags_url":"https://api.github.com/repos/pipelinedb/pipelinedb/tags","blobs_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pipelinedb/pipelinedb/statuses/{sha}","languages_url":"https://api.github.com/repos/pipelinedb/pipelinedb/languages","stargazers_url":"https://api.github.com/repos/pipelinedb/pipelinedb/stargazers","contributors_url":"https://api.github.com/repos/pipelinedb/pipelinedb/contributors","subscribers_url":"https://api.github.com/repos/pipelinedb/pipelinedb/subscribers","subscription_url":"https://api.github.com/repos/pipelinedb/pipelinedb/subscription","commits_url":"https://api.github.com/repos/pipelinedb/pipelinedb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pipelinedb/pipelinedb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pipelinedb/pipelinedb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pipelinedb/pipelinedb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pipelinedb/pipelinedb/contents/{+path}","compare_url":"https://api.github.com/repos/pipelinedb/pipelinedb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pipelinedb/pipelinedb/merges","archive_url":"https://api.github.com/repos/pipelinedb/pipelinedb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pipelinedb/pipelinedb/downloads","issues_url":"https://api.github.com/repos/pipelinedb/pipelinedb/issues{/number}","pulls_url":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls{/number}","milestones_url":"https://api.github.com/repos/pipelinedb/pipelinedb/milestones{/number}","notifications_url":"https://api.github.com/repos/pipelinedb/pipelinedb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pipelinedb/pipelinedb/labels{/name}","releases_url":"https://api.github.com/repos/pipelinedb/pipelinedb/releases{/id}","created_at":"2013-11-26T00:11:48Z","updated_at":"2015-08-04T19:55:41Z","pushed_at":"2015-08-05T01:52:49Z","git_url":"git://github.com/pipelinedb/pipelinedb.git","ssh_url":"git@github.com:pipelinedb/pipelinedb.git","clone_url":"https://github.com/pipelinedb/pipelinedb.git","svn_url":"https://github.com/pipelinedb/pipelinedb","homepage":"http://pipelinedb.com","size":62113,"stargazers_count":571,"watchers_count":571,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":59,"forks":21,"open_issues":59,"watchers":571,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/1082"},"html":{"href":"https://github.com/pipelinedb/pipelinedb/pull/1082"},"issue":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/issues/1082"},"comments":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/issues/1082/comments"},"review_comments":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/1082/comments"},"review_comment":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/pulls/1082/commits"},"statuses":{"href":"https://api.github.com/repos/pipelinedb/pipelinedb/statuses/52421c00982864d6f76a6e055af1be0c313afca3"}}}}