Merge lp:~mmcm/akiban-server/direct-timestamp into lp:~akiban-technologies/akiban-server/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Nathan Williams
Approved revision: 2621
Merged at revision: 2621
Proposed branch: lp:~mmcm/akiban-server/direct-timestamp
Merge into: lp:~akiban-technologies/akiban-server/trunk
Diff against target: 63 lines (+15/-1)
2 files modified
src/main/java/com/akiban/server/service/restdml/DirectServiceImpl.java (+2/-0)
src/main/java/com/akiban/server/service/restdml/EndpointMetadata.java (+13/-1)
To merge this branch: bzr merge lp:~mmcm/akiban-server/direct-timestamp
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+158718@code.launchpad.net

Description of the change

Add TIMESTAMP as a parameter type for Direct REST endpoints.

Also fix the auto-commit part of bug #1168547, which is blocking.

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

Do we want encourage DATETIME instead? TIMESTAMP has funnier limitations.

review: Needs Information
Revision history for this message
Mike McMahon (mmcm) wrote :

Are we okay saying that datetime is passed an instance of java.sql.Timestamp? I don't otherwise have issues with the name. But Date & Timestamp are the two basic types in the Java "primitive" world shared between JDBC and scripts.

Someday we can make SQL TIMESTAMP standard with fractional seconds and not some MySQL madness.

Revision history for this message
Nathan Williams (nwilliams) wrote :

I'm not sure what you my by OK, internal support? I was mainly thinking about how we actively limit TIMESTAMP to the 1970-2038 range. Giving someone that for, say, birthdays won't work very well.

++ to getting rid of the madness someday.

Revision history for this message
Mike McMahon (mmcm) wrote :

Well, these values don't go into places that have that limitation. They are parsed from the URI and passed to the script. So, competing arguments I can see are (1) "timestamp" because that's SQL- and Java-standard and (2) "datetime" because in general that's the name of the type in Akiban that behaves rationally.

Revision history for this message
Nathan Williams (nwilliams) wrote :

I see, misunderstood the ramification of this particular path.

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/server/service/restdml/DirectServiceImpl.java'
2--- src/main/java/com/akiban/server/service/restdml/DirectServiceImpl.java 2013-04-11 23:16:55 +0000
3+++ src/main/java/com/akiban/server/service/restdml/DirectServiceImpl.java 2013-04-12 21:18:37 +0000
4@@ -336,6 +336,8 @@
5 final byte[] content, final MediaType[] responseType) throws Exception {
6 try (JDBCConnection conn = jdbcConnection(request, procName.getSchemaName());) {
7
8+ conn.setAutoCommit(false);
9+
10 boolean completed = false;
11 boolean repeat = true;
12
13
14=== modified file 'src/main/java/com/akiban/server/service/restdml/EndpointMetadata.java'
15--- src/main/java/com/akiban/server/service/restdml/EndpointMetadata.java 2013-04-08 14:53:42 +0000
16+++ src/main/java/com/akiban/server/service/restdml/EndpointMetadata.java 2013-04-12 21:18:37 +0000
17@@ -22,6 +22,7 @@
18 import java.io.IOException;
19 import java.nio.charset.Charset;
20 import java.sql.Date;
21+import java.sql.Timestamp;
22 import java.text.ParseException;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25@@ -63,12 +64,13 @@
26 final static String X_TYPE_DOUBLE = "double";
27 final static String X_TYPE_STRING = "string";
28 final static String X_TYPE_DATE = "date";
29+ final static String X_TYPE_TIMESTAMP = "timestamp";
30 final static String X_TYPE_BYTEARRAY = "bytearray";
31 final static String X_TYPE_JSON = "json";
32 final static String X_TYPE_VOID = "void";
33
34 final static List<String> X_TYPES = Arrays.asList(new String[] { X_TYPE_INT, X_TYPE_LONG, X_TYPE_FLOAT,
35- X_TYPE_DOUBLE, X_TYPE_STRING, X_TYPE_DATE, X_TYPE_BYTEARRAY, X_TYPE_JSON, X_TYPE_VOID });
36+ X_TYPE_DOUBLE, X_TYPE_STRING, X_TYPE_DATE, X_TYPE_TIMESTAMP, X_TYPE_BYTEARRAY, X_TYPE_JSON, X_TYPE_VOID });
37
38 private final static Charset UTF8 = Charset.forName("UTF8");
39
40@@ -133,6 +135,8 @@
41 return asString(pm, v);
42 case EndpointMetadata.X_TYPE_DATE:
43 return asDate(pm, v);
44+ case EndpointMetadata.X_TYPE_TIMESTAMP:
45+ return asTimestamp(pm, v);
46 case EndpointMetadata.X_TYPE_BYTEARRAY:
47 assert v instanceof byte[];
48 return v;
49@@ -184,6 +188,14 @@
50 return Date.valueOf(s);
51 }
52
53+ private static Timestamp asTimestamp(ParamMetadata pm, Object v) throws ParseException {
54+ String s = asString(pm, v);
55+ if ("now".equalsIgnoreCase(s)) {
56+ return new Timestamp(System.currentTimeMillis());
57+ }
58+ return Timestamp.valueOf(s);
59+ }
60+
61 static EndpointMetadata createEndpointMetadata(final String schema, final String routineName,
62 final String specification) throws Exception {
63 EndpointMetadata em = new EndpointMetadata();

Subscribers

People subscribed via source and target branches