{"action":"created","comment":{"url":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/comments/40334447","id":40334447,"diff_hunk":"@@ -479,4 +509,71 @@ class PostgresConfigurator\n                     log.info \"Returning empty tablelist\"\n                     callback null, []\n \n+    addMaterialization: (request, callback) =>\n+        if not request.Table? or not request.Provider?\n+            callback new Error(\"Invalid config object (it does not contain any tables): #{request}\")\n+            return\n+\n+        schema = @_MaterializationSchemaName request.Provider, request.Table, request.UserName\n+        sourceTable = @_FullTableName request.Provider, request.Table, request.UserName\n+        table = @_FullMaterializedTableName request.Provider, request.Table, request.UserName\n+        user = request.UserName\n+\n+        query = \"\"\n+        query += Queries.dropMaterializedTable table\n+        query += Queries.createSchema schema\n+        query += Queries.grantSchemaRights schema, user\n+        query += Queries.createMaterializedTable table, sourceTable\n+        query += Queries.grantTableRights table, user\n+        query += Queries.setMaterializedOption sourceTable, true\n+\n+        sendQuery @connectionString, query, true, [], callback\n+\n+    deleteMaterialization: (request, callback) ->\n+        if not request.Table? or not request.Provider?\n+            callback new Error(\"Invalid config object (it does not contain any tables): #{request}\")\n+            return\n+\n+        sourceTable = @_FullTableName request.Provider, request.Table, request.UserName\n+        table = @_FullMaterializedTableName request.Provider, request.Table, request.UserName\n+        query = \"\"\n+        query += Queries.dropMaterializedTable table\n+        query += Queries.setMaterializedOption sourceTable, false\n+\n+        sendQuery @connectionString, query, true, [], callback\n+\n+    sendQuery = (connectionString, queryString, transaction, ignoreErrors = [], callback) ->\n+        transaction = transaction? and transaction\n+        pg.connect connectionString, (err, client, done) ->\n+            if err?\n+                return\n+            if transaction\n+                queryString = \"BEGIN;\" + queryString\n+\n+            queryTimeout = 60 * 1000\n+            timedOut = false\n+            timeout = setTimeout () =>\n+                console.log \"query timeouted\"\n+                Monitoring.requestError 'PostgreSQL Server', VirtDB.Const.REQUEST_ERROR.UPSTREAM_TIMEOUT, 'SQL query timed out', queryString\n+                timedOut = true\n+                log.debug \"Could not process query in time, cancelling\", V_(queryString)","path":"src/postgres-configurator.coffee","position":214,"original_position":214,"commit_id":"4f3b5311631df6977ed6f71fa669c9e0c4529fb3","original_commit_id":"4f3b5311631df6977ed6f71fa669c9e0c4529fb3","user":{"login":"baspeti","id":5700926,"avatar_url":"https://avatars.githubusercontent.com/u/5700926?v=3","gravatar_id":"","url":"https://api.github.com/users/baspeti","html_url":"https://github.com/baspeti","followers_url":"https://api.github.com/users/baspeti/followers","following_url":"https://api.github.com/users/baspeti/following{/other_user}","gists_url":"https://api.github.com/users/baspeti/gists{/gist_id}","starred_url":"https://api.github.com/users/baspeti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baspeti/subscriptions","organizations_url":"https://api.github.com/users/baspeti/orgs","repos_url":"https://api.github.com/users/baspeti/repos","events_url":"https://api.github.com/users/baspeti/events{/privacy}","received_events_url":"https://api.github.com/users/baspeti/received_events","type":"User","site_admin":false},"body":"Why not logging this on error level? Or at least on warning..","created_at":"2015-09-24T15:42:34Z","updated_at":"2015-09-24T15:42:34Z","html_url":"https://github.com/starschema/virtdb-db-config/pull/39#discussion_r40334447","pull_request_url":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/comments/40334447"},"html":{"href":"https://github.com/starschema/virtdb-db-config/pull/39#discussion_r40334447"},"pull_request":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/39","id":45903074,"html_url":"https://github.com/starschema/virtdb-db-config/pull/39","diff_url":"https://github.com/starschema/virtdb-db-config/pull/39.diff","patch_url":"https://github.com/starschema/virtdb-db-config/pull/39.patch","issue_url":"https://api.github.com/repos/starschema/virtdb-db-config/issues/39","number":39,"state":"open","locked":false,"title":"Materialization feature","user":{"login":"pnagy","id":4050025,"avatar_url":"https://avatars.githubusercontent.com/u/4050025?v=3","gravatar_id":"","url":"https://api.github.com/users/pnagy","html_url":"https://github.com/pnagy","followers_url":"https://api.github.com/users/pnagy/followers","following_url":"https://api.github.com/users/pnagy/following{/other_user}","gists_url":"https://api.github.com/users/pnagy/gists{/gist_id}","starred_url":"https://api.github.com/users/pnagy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnagy/subscriptions","organizations_url":"https://api.github.com/users/pnagy/orgs","repos_url":"https://api.github.com/users/pnagy/repos","events_url":"https://api.github.com/users/pnagy/events{/privacy}","received_events_url":"https://api.github.com/users/pnagy/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-24T14:23:43Z","updated_at":"2015-09-24T15:42:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b818cf1146eb7d2bf032a41a661d3394b5cae756","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/39/commits","review_comments_url":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/39/comments","review_comment_url":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/comments{/number}","comments_url":"https://api.github.com/repos/starschema/virtdb-db-config/issues/39/comments","statuses_url":"https://api.github.com/repos/starschema/virtdb-db-config/statuses/4f3b5311631df6977ed6f71fa669c9e0c4529fb3","head":{"label":"starschema:VDB-525","ref":"VDB-525","sha":"4f3b5311631df6977ed6f71fa669c9e0c4529fb3","user":{"login":"starschema","id":102458,"avatar_url":"https://avatars.githubusercontent.com/u/102458?v=3","gravatar_id":"","url":"https://api.github.com/users/starschema","html_url":"https://github.com/starschema","followers_url":"https://api.github.com/users/starschema/followers","following_url":"https://api.github.com/users/starschema/following{/other_user}","gists_url":"https://api.github.com/users/starschema/gists{/gist_id}","starred_url":"https://api.github.com/users/starschema/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starschema/subscriptions","organizations_url":"https://api.github.com/users/starschema/orgs","repos_url":"https://api.github.com/users/starschema/repos","events_url":"https://api.github.com/users/starschema/events{/privacy}","received_events_url":"https://api.github.com/users/starschema/received_events","type":"Organization","site_admin":false},"repo":{"id":28192603,"name":"virtdb-db-config","full_name":"starschema/virtdb-db-config","owner":{"login":"starschema","id":102458,"avatar_url":"https://avatars.githubusercontent.com/u/102458?v=3","gravatar_id":"","url":"https://api.github.com/users/starschema","html_url":"https://github.com/starschema","followers_url":"https://api.github.com/users/starschema/followers","following_url":"https://api.github.com/users/starschema/following{/other_user}","gists_url":"https://api.github.com/users/starschema/gists{/gist_id}","starred_url":"https://api.github.com/users/starschema/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starschema/subscriptions","organizations_url":"https://api.github.com/users/starschema/orgs","repos_url":"https://api.github.com/users/starschema/repos","events_url":"https://api.github.com/users/starschema/events{/privacy}","received_events_url":"https://api.github.com/users/starschema/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/starschema/virtdb-db-config","description":"VirtDB component that communicates with host databases","fork":false,"url":"https://api.github.com/repos/starschema/virtdb-db-config","forks_url":"https://api.github.com/repos/starschema/virtdb-db-config/forks","keys_url":"https://api.github.com/repos/starschema/virtdb-db-config/keys{/key_id}","collaborators_url":"https://api.github.com/repos/starschema/virtdb-db-config/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/starschema/virtdb-db-config/teams","hooks_url":"https://api.github.com/repos/starschema/virtdb-db-config/hooks","issue_events_url":"https://api.github.com/repos/starschema/virtdb-db-config/issues/events{/number}","events_url":"https://api.github.com/repos/starschema/virtdb-db-config/events","assignees_url":"https://api.github.com/repos/starschema/virtdb-db-config/assignees{/user}","branches_url":"https://api.github.com/repos/starschema/virtdb-db-config/branches{/branch}","tags_url":"https://api.github.com/repos/starschema/virtdb-db-config/tags","blobs_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/refs{/sha}","trees_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/trees{/sha}","statuses_url":"https://api.github.com/repos/starschema/virtdb-db-config/statuses/{sha}","languages_url":"https://api.github.com/repos/starschema/virtdb-db-config/languages","stargazers_url":"https://api.github.com/repos/starschema/virtdb-db-config/stargazers","contributors_url":"https://api.github.com/repos/starschema/virtdb-db-config/contributors","subscribers_url":"https://api.github.com/repos/starschema/virtdb-db-config/subscribers","subscription_url":"https://api.github.com/repos/starschema/virtdb-db-config/subscription","commits_url":"https://api.github.com/repos/starschema/virtdb-db-config/commits{/sha}","git_commits_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/commits{/sha}","comments_url":"https://api.github.com/repos/starschema/virtdb-db-config/comments{/number}","issue_comment_url":"https://api.github.com/repos/starschema/virtdb-db-config/issues/comments{/number}","contents_url":"https://api.github.com/repos/starschema/virtdb-db-config/contents/{+path}","compare_url":"https://api.github.com/repos/starschema/virtdb-db-config/compare/{base}...{head}","merges_url":"https://api.github.com/repos/starschema/virtdb-db-config/merges","archive_url":"https://api.github.com/repos/starschema/virtdb-db-config/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/starschema/virtdb-db-config/downloads","issues_url":"https://api.github.com/repos/starschema/virtdb-db-config/issues{/number}","pulls_url":"https://api.github.com/repos/starschema/virtdb-db-config/pulls{/number}","milestones_url":"https://api.github.com/repos/starschema/virtdb-db-config/milestones{/number}","notifications_url":"https://api.github.com/repos/starschema/virtdb-db-config/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/starschema/virtdb-db-config/labels{/name}","releases_url":"https://api.github.com/repos/starschema/virtdb-db-config/releases{/id}","created_at":"2014-12-18T16:56:38Z","updated_at":"2015-05-05T08:30:44Z","pushed_at":"2015-09-24T14:23:43Z","git_url":"git://github.com/starschema/virtdb-db-config.git","ssh_url":"git@github.com:starschema/virtdb-db-config.git","clone_url":"https://github.com/starschema/virtdb-db-config.git","svn_url":"https://github.com/starschema/virtdb-db-config","homepage":null,"size":1087,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"starschema:master","ref":"master","sha":"ba68f76ce243cc753c2f68849b97cefbf0310bb0","user":{"login":"starschema","id":102458,"avatar_url":"https://avatars.githubusercontent.com/u/102458?v=3","gravatar_id":"","url":"https://api.github.com/users/starschema","html_url":"https://github.com/starschema","followers_url":"https://api.github.com/users/starschema/followers","following_url":"https://api.github.com/users/starschema/following{/other_user}","gists_url":"https://api.github.com/users/starschema/gists{/gist_id}","starred_url":"https://api.github.com/users/starschema/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starschema/subscriptions","organizations_url":"https://api.github.com/users/starschema/orgs","repos_url":"https://api.github.com/users/starschema/repos","events_url":"https://api.github.com/users/starschema/events{/privacy}","received_events_url":"https://api.github.com/users/starschema/received_events","type":"Organization","site_admin":false},"repo":{"id":28192603,"name":"virtdb-db-config","full_name":"starschema/virtdb-db-config","owner":{"login":"starschema","id":102458,"avatar_url":"https://avatars.githubusercontent.com/u/102458?v=3","gravatar_id":"","url":"https://api.github.com/users/starschema","html_url":"https://github.com/starschema","followers_url":"https://api.github.com/users/starschema/followers","following_url":"https://api.github.com/users/starschema/following{/other_user}","gists_url":"https://api.github.com/users/starschema/gists{/gist_id}","starred_url":"https://api.github.com/users/starschema/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starschema/subscriptions","organizations_url":"https://api.github.com/users/starschema/orgs","repos_url":"https://api.github.com/users/starschema/repos","events_url":"https://api.github.com/users/starschema/events{/privacy}","received_events_url":"https://api.github.com/users/starschema/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/starschema/virtdb-db-config","description":"VirtDB component that communicates with host databases","fork":false,"url":"https://api.github.com/repos/starschema/virtdb-db-config","forks_url":"https://api.github.com/repos/starschema/virtdb-db-config/forks","keys_url":"https://api.github.com/repos/starschema/virtdb-db-config/keys{/key_id}","collaborators_url":"https://api.github.com/repos/starschema/virtdb-db-config/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/starschema/virtdb-db-config/teams","hooks_url":"https://api.github.com/repos/starschema/virtdb-db-config/hooks","issue_events_url":"https://api.github.com/repos/starschema/virtdb-db-config/issues/events{/number}","events_url":"https://api.github.com/repos/starschema/virtdb-db-config/events","assignees_url":"https://api.github.com/repos/starschema/virtdb-db-config/assignees{/user}","branches_url":"https://api.github.com/repos/starschema/virtdb-db-config/branches{/branch}","tags_url":"https://api.github.com/repos/starschema/virtdb-db-config/tags","blobs_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/refs{/sha}","trees_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/trees{/sha}","statuses_url":"https://api.github.com/repos/starschema/virtdb-db-config/statuses/{sha}","languages_url":"https://api.github.com/repos/starschema/virtdb-db-config/languages","stargazers_url":"https://api.github.com/repos/starschema/virtdb-db-config/stargazers","contributors_url":"https://api.github.com/repos/starschema/virtdb-db-config/contributors","subscribers_url":"https://api.github.com/repos/starschema/virtdb-db-config/subscribers","subscription_url":"https://api.github.com/repos/starschema/virtdb-db-config/subscription","commits_url":"https://api.github.com/repos/starschema/virtdb-db-config/commits{/sha}","git_commits_url":"https://api.github.com/repos/starschema/virtdb-db-config/git/commits{/sha}","comments_url":"https://api.github.com/repos/starschema/virtdb-db-config/comments{/number}","issue_comment_url":"https://api.github.com/repos/starschema/virtdb-db-config/issues/comments{/number}","contents_url":"https://api.github.com/repos/starschema/virtdb-db-config/contents/{+path}","compare_url":"https://api.github.com/repos/starschema/virtdb-db-config/compare/{base}...{head}","merges_url":"https://api.github.com/repos/starschema/virtdb-db-config/merges","archive_url":"https://api.github.com/repos/starschema/virtdb-db-config/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/starschema/virtdb-db-config/downloads","issues_url":"https://api.github.com/repos/starschema/virtdb-db-config/issues{/number}","pulls_url":"https://api.github.com/repos/starschema/virtdb-db-config/pulls{/number}","milestones_url":"https://api.github.com/repos/starschema/virtdb-db-config/milestones{/number}","notifications_url":"https://api.github.com/repos/starschema/virtdb-db-config/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/starschema/virtdb-db-config/labels{/name}","releases_url":"https://api.github.com/repos/starschema/virtdb-db-config/releases{/id}","created_at":"2014-12-18T16:56:38Z","updated_at":"2015-05-05T08:30:44Z","pushed_at":"2015-09-24T14:23:43Z","git_url":"git://github.com/starschema/virtdb-db-config.git","ssh_url":"git@github.com:starschema/virtdb-db-config.git","clone_url":"https://github.com/starschema/virtdb-db-config.git","svn_url":"https://github.com/starschema/virtdb-db-config","homepage":null,"size":1087,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/39"},"html":{"href":"https://github.com/starschema/virtdb-db-config/pull/39"},"issue":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/issues/39"},"comments":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/starschema/virtdb-db-config/statuses/4f3b5311631df6977ed6f71fa669c9e0c4529fb3"}}}}