Merge lp:~mmcm/akiban-server/pg-server-set-variable into lp:~akiban-technologies/akiban-server/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Nathan Williams
Approved revision: 2737
Merged at revision: 2736
Proposed branch: lp:~mmcm/akiban-server/pg-server-set-variable
Merge into: lp:~akiban-technologies/akiban-server/trunk
Diff against target: 69 lines (+41/-3)
2 files modified
src/main/java/com/akiban/sql/pg/PostgresServerStatement.java (+11/-3)
src/test/resources/com/akiban/sql/pg/yaml/functional/test-server-set-param.yaml (+30/-0)
To merge this branch: bzr merge lp:~mmcm/akiban-server/pg-server-set-variable
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+179828@code.launchpad.net

Description of the change

Make ALTER SERVER SET actually set property for all sessions.

This is what the documentation says it does and it is otherwise identical to just SET.

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

As described.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/com/akiban/sql/pg/PostgresServerStatement.java'
2--- src/main/java/com/akiban/sql/pg/PostgresServerStatement.java 2013-07-06 17:46:02 +0000
3+++ src/main/java/com/akiban/sql/pg/PostgresServerStatement.java 2013-08-12 23:40:24 +0000
4@@ -150,7 +150,7 @@
5 */
6 switch (statement.getAlterSessionType()) {
7 case SET_SERVER_VARIABLE:
8- setVariable (session, statement.getVariable(), statement.getValue());
9+ setVariable (server, statement.getVariable(), statement.getValue());
10 sendComplete (session.getMessenger());
11 break;
12 case INTERRUPT_SESSION:
13@@ -224,10 +224,18 @@
14 throw new ConnectionTerminatedException(completeCurrent);
15 }
16
17- protected void setVariable(PostgresServerSession server, String variable, String value) {
18+ protected void setVariable(PostgresServer server, String variable, String value) {
19 if (!Arrays.asList(PostgresSessionStatement.ALLOWED_CONFIGURATION).contains(variable))
20 throw new UnsupportedConfigurationException (variable);
21- server.setProperty(variable, value);
22+ if (value == null)
23+ server.getProperties().remove(variable);
24+ else
25+ server.getProperties().setProperty(variable, value);
26+ for (PostgresServerConnection conn : server.getConnections()) {
27+ if (!conn.getProperties().containsKey(variable)) {
28+ conn.setProperty(variable, null); // As though SET x TO DEFAULT.
29+ }
30+ }
31 }
32
33 protected void sendComplete (PostgresMessenger messenger) throws IOException {
34
35=== added file 'src/test/resources/com/akiban/sql/pg/yaml/functional/test-server-set-param.yaml'
36--- src/test/resources/com/akiban/sql/pg/yaml/functional/test-server-set-param.yaml 1970-01-01 00:00:00 +0000
37+++ src/test/resources/com/akiban/sql/pg/yaml/functional/test-server-set-param.yaml 2013-08-12 23:40:24 +0000
38@@ -0,0 +1,30 @@
39+# Test SERVER (GLOBAL) SET command
40+---
41+- Properties: sys-mysql
42+- suppressed: true
43+---
44+- Statement: ALTER SERVER SET no_such_var TO 'yes'
45+- error: [42513]
46+---
47+- Statement: SET parserInfixLogical TO 'true'
48+---
49+- Statement: SELECT 1 || 2;
50+- output: [['true']]
51+---
52+- Statement: SET parserInfixLogical TO 'false'
53+---
54+- Statement: SELECT 1 || 2;
55+- output: [['12']]
56+---
57+- Statement: ALTER SERVER SET parserInfixLogical TO 'true'
58+---
59+- Statement: SELECT 1 || 2;
60+- output: [['12']]
61+---
62+- Statement: SET parserInfixLogical TO DEFAULT
63+---
64+- Statement: SELECT 1 || 2;
65+- output: [['true']]
66+---
67+- Statement: ALTER SERVER SET parserInfixLogical TO DEFAULT
68+...
69\ No newline at end of file

Subscribers

People subscribed via source and target branches