{"action":"created","comment":{"url":"https://api.github.com/repos/crate/crate/pulls/comments/83859084","pull_request_review_id":4673572,"id":83859084,"diff_hunk":"@@ -41,36 +42,62 @@\n     private SetStatementAnalyzer() {\n     }\n \n-    public static SetAnalyzedStatement analyze(SetStatement node, ParameterContext parameterContext) {\n-        Settings.Builder builder = Settings.builder();\n+    public static SetAnalyzedStatement analyze(SetStatement node, Analysis context) {\n+        boolean isPersistent = node.settingType().equals(SetStatement.SettingType.PERSISTENT);\n+        Row parameters = context.parameterContext().parameters();\n \n-        if (!SetStatement.Scope.GLOBAL.equals(node.scope())) {\n-            logger.warn(\"SET STATEMENT WITH SESSION OR LOCAL WILL BE IGNORED: {}\", node);\n+        if (SetStatement.Scope.SESSION.equals(node.scope())) {\n             Assignment assignment = node.assignments().get(0);\n-            String settingsName = ExpressionToStringVisitor.convert(assignment.columnName(),\n-                parameterContext.parameters());\n-            Set<String> settingNames = CrateSettings.settingNamesByPrefix(settingsName);\n-            if (settingNames.size() != 0) {\n-                throw new IllegalArgumentException(String.format(Locale.ENGLISH, \"GLOBAL Cluster setting '%s' cannot be used with SET SESSION / LOCAL\", settingsName));\n+            String setting = ExpressionToStringVisitor.convert(assignment.columnName(), parameters);\n+            verifySessionOrLocalSetting(setting);\n+\n+            Settings.Builder builder = Settings.builder().put(setting, assignment.expressions());\n+            // The search_path takes a schema name as a string or comma-separated list of schema names.\n+            // In the second case only the first schema in the list will be used.\n+            if (setting.equals(\"search_path\")) {\n+                Expression value = assignment.expression();\n+                if (value != null) {\n+                    String searchPath = ExpressionToStringVisitor.convert(value, parameters);\n+                    String schemas[] = searchPath.split(\",\");\n+                    assert schemas.length > 0 : \"at least one schema should be provided\";\n+                    context.sessionContext().setDefaultSchema(schemas[0].trim());\n+                } else {","path":"sql/src/main/java/io/crate/analyze/SetStatementAnalyzer.java","position":40,"original_position":40,"commit_id":"5ab6d31d8b6a659790f002959d269a764a461ff7","original_commit_id":"5ab6d31d8b6a659790f002959d269a764a461ff7","user":{"login":"dobe","id":48020,"avatar_url":"https://avatars.githubusercontent.com/u/48020?v=3","gravatar_id":"","url":"https://api.github.com/users/dobe","html_url":"https://github.com/dobe","followers_url":"https://api.github.com/users/dobe/followers","following_url":"https://api.github.com/users/dobe/following{/other_user}","gists_url":"https://api.github.com/users/dobe/gists{/gist_id}","starred_url":"https://api.github.com/users/dobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dobe/subscriptions","organizations_url":"https://api.github.com/users/dobe/orgs","repos_url":"https://api.github.com/users/dobe/repos","events_url":"https://api.github.com/users/dobe/events{/privacy}","received_events_url":"https://api.github.com/users/dobe/received_events","type":"User","site_admin":false},"body":"how  can this happen?","created_at":"2016-10-18T13:56:22Z","updated_at":"2016-10-18T13:56:22Z","html_url":"https://github.com/crate/crate/pull/4285#discussion_r83859084","pull_request_url":"https://api.github.com/repos/crate/crate/pulls/4285","_links":{"self":{"href":"https://api.github.com/repos/crate/crate/pulls/comments/83859084"},"html":{"href":"https://github.com/crate/crate/pull/4285#discussion_r83859084"},"pull_request":{"href":"https://api.github.com/repos/crate/crate/pulls/4285"}}},"pull_request":{"url":"https://api.github.com/repos/crate/crate/pulls/4285","id":89799154,"html_url":"https://github.com/crate/crate/pull/4285","diff_url":"https://github.com/crate/crate/pull/4285.diff","patch_url":"https://github.com/crate/crate/pull/4285.patch","issue_url":"https://api.github.com/repos/crate/crate/issues/4285","number":4285,"state":"open","locked":false,"title":"add the search_path session setting parameter","user":{"login":"kovrus","id":7442373,"avatar_url":"https://avatars.githubusercontent.com/u/7442373?v=3","gravatar_id":"","url":"https://api.github.com/users/kovrus","html_url":"https://github.com/kovrus","followers_url":"https://api.github.com/users/kovrus/followers","following_url":"https://api.github.com/users/kovrus/following{/other_user}","gists_url":"https://api.github.com/users/kovrus/gists{/gist_id}","starred_url":"https://api.github.com/users/kovrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kovrus/subscriptions","organizations_url":"https://api.github.com/users/kovrus/orgs","repos_url":"https://api.github.com/users/kovrus/repos","events_url":"https://api.github.com/users/kovrus/events{/privacy}","received_events_url":"https://api.github.com/users/kovrus/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-18T11:49:50Z","updated_at":"2016-10-18T13:57:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"beb6dd529842f9ab35fb9ef67f8f5debc153b15e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/crate/crate/pulls/4285/commits","review_comments_url":"https://api.github.com/repos/crate/crate/pulls/4285/comments","review_comment_url":"https://api.github.com/repos/crate/crate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crate/crate/issues/4285/comments","statuses_url":"https://api.github.com/repos/crate/crate/statuses/5ab6d31d8b6a659790f002959d269a764a461ff7","head":{"label":"crate:setschema","ref":"setschema","sha":"5ab6d31d8b6a659790f002959d269a764a461ff7","user":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"repo":{"id":9342529,"name":"crate","full_name":"crate/crate","owner":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crate/crate","description":"Crate.IO: The fast, scalable, easy to use SQL database with native full text search","fork":false,"url":"https://api.github.com/repos/crate/crate","forks_url":"https://api.github.com/repos/crate/crate/forks","keys_url":"https://api.github.com/repos/crate/crate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crate/crate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crate/crate/teams","hooks_url":"https://api.github.com/repos/crate/crate/hooks","issue_events_url":"https://api.github.com/repos/crate/crate/issues/events{/number}","events_url":"https://api.github.com/repos/crate/crate/events","assignees_url":"https://api.github.com/repos/crate/crate/assignees{/user}","branches_url":"https://api.github.com/repos/crate/crate/branches{/branch}","tags_url":"https://api.github.com/repos/crate/crate/tags","blobs_url":"https://api.github.com/repos/crate/crate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crate/crate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crate/crate/git/refs{/sha}","trees_url":"https://api.github.com/repos/crate/crate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crate/crate/statuses/{sha}","languages_url":"https://api.github.com/repos/crate/crate/languages","stargazers_url":"https://api.github.com/repos/crate/crate/stargazers","contributors_url":"https://api.github.com/repos/crate/crate/contributors","subscribers_url":"https://api.github.com/repos/crate/crate/subscribers","subscription_url":"https://api.github.com/repos/crate/crate/subscription","commits_url":"https://api.github.com/repos/crate/crate/commits{/sha}","git_commits_url":"https://api.github.com/repos/crate/crate/git/commits{/sha}","comments_url":"https://api.github.com/repos/crate/crate/comments{/number}","issue_comment_url":"https://api.github.com/repos/crate/crate/issues/comments{/number}","contents_url":"https://api.github.com/repos/crate/crate/contents/{+path}","compare_url":"https://api.github.com/repos/crate/crate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crate/crate/merges","archive_url":"https://api.github.com/repos/crate/crate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crate/crate/downloads","issues_url":"https://api.github.com/repos/crate/crate/issues{/number}","pulls_url":"https://api.github.com/repos/crate/crate/pulls{/number}","milestones_url":"https://api.github.com/repos/crate/crate/milestones{/number}","notifications_url":"https://api.github.com/repos/crate/crate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crate/crate/labels{/name}","releases_url":"https://api.github.com/repos/crate/crate/releases{/id}","deployments_url":"https://api.github.com/repos/crate/crate/deployments","created_at":"2013-04-10T09:17:16Z","updated_at":"2016-10-18T09:44:38Z","pushed_at":"2016-10-18T13:53:14Z","git_url":"git://github.com/crate/crate.git","ssh_url":"git@github.com:crate/crate.git","clone_url":"https://github.com/crate/crate.git","svn_url":"https://github.com/crate/crate","homepage":"https://crate.io","size":78584,"stargazers_count":1393,"watchers_count":1393,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":162,"mirror_url":null,"open_issues_count":39,"forks":162,"open_issues":39,"watchers":1393,"default_branch":"master"}},"base":{"label":"crate:master","ref":"master","sha":"23ae63bd3cccd766cacd91f81a081b0c735e295f","user":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"repo":{"id":9342529,"name":"crate","full_name":"crate/crate","owner":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crate/crate","description":"Crate.IO: The fast, scalable, easy to use SQL database with native full text search","fork":false,"url":"https://api.github.com/repos/crate/crate","forks_url":"https://api.github.com/repos/crate/crate/forks","keys_url":"https://api.github.com/repos/crate/crate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crate/crate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crate/crate/teams","hooks_url":"https://api.github.com/repos/crate/crate/hooks","issue_events_url":"https://api.github.com/repos/crate/crate/issues/events{/number}","events_url":"https://api.github.com/repos/crate/crate/events","assignees_url":"https://api.github.com/repos/crate/crate/assignees{/user}","branches_url":"https://api.github.com/repos/crate/crate/branches{/branch}","tags_url":"https://api.github.com/repos/crate/crate/tags","blobs_url":"https://api.github.com/repos/crate/crate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crate/crate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crate/crate/git/refs{/sha}","trees_url":"https://api.github.com/repos/crate/crate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crate/crate/statuses/{sha}","languages_url":"https://api.github.com/repos/crate/crate/languages","stargazers_url":"https://api.github.com/repos/crate/crate/stargazers","contributors_url":"https://api.github.com/repos/crate/crate/contributors","subscribers_url":"https://api.github.com/repos/crate/crate/subscribers","subscription_url":"https://api.github.com/repos/crate/crate/subscription","commits_url":"https://api.github.com/repos/crate/crate/commits{/sha}","git_commits_url":"https://api.github.com/repos/crate/crate/git/commits{/sha}","comments_url":"https://api.github.com/repos/crate/crate/comments{/number}","issue_comment_url":"https://api.github.com/repos/crate/crate/issues/comments{/number}","contents_url":"https://api.github.com/repos/crate/crate/contents/{+path}","compare_url":"https://api.github.com/repos/crate/crate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crate/crate/merges","archive_url":"https://api.github.com/repos/crate/crate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crate/crate/downloads","issues_url":"https://api.github.com/repos/crate/crate/issues{/number}","pulls_url":"https://api.github.com/repos/crate/crate/pulls{/number}","milestones_url":"https://api.github.com/repos/crate/crate/milestones{/number}","notifications_url":"https://api.github.com/repos/crate/crate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crate/crate/labels{/name}","releases_url":"https://api.github.com/repos/crate/crate/releases{/id}","deployments_url":"https://api.github.com/repos/crate/crate/deployments","created_at":"2013-04-10T09:17:16Z","updated_at":"2016-10-18T09:44:38Z","pushed_at":"2016-10-18T13:53:14Z","git_url":"git://github.com/crate/crate.git","ssh_url":"git@github.com:crate/crate.git","clone_url":"https://github.com/crate/crate.git","svn_url":"https://github.com/crate/crate","homepage":"https://crate.io","size":78584,"stargazers_count":1393,"watchers_count":1393,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":162,"mirror_url":null,"open_issues_count":39,"forks":162,"open_issues":39,"watchers":1393,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crate/crate/pulls/4285"},"html":{"href":"https://github.com/crate/crate/pull/4285"},"issue":{"href":"https://api.github.com/repos/crate/crate/issues/4285"},"comments":{"href":"https://api.github.com/repos/crate/crate/issues/4285/comments"},"review_comments":{"href":"https://api.github.com/repos/crate/crate/pulls/4285/comments"},"review_comment":{"href":"https://api.github.com/repos/crate/crate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crate/crate/pulls/4285/commits"},"statuses":{"href":"https://api.github.com/repos/crate/crate/statuses/5ab6d31d8b6a659790f002959d269a764a461ff7"}}}}
{"actor":{"display_login":"dobe"}}