File tree Expand file tree Collapse file tree 5 files changed +32
-1
lines changed
main/java/com/google/cloud/spanner/connection
test/java/com/google/cloud/spanner/connection Expand file tree Collapse file tree 5 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 10571057 <differenceType >8001</differenceType >
10581058 <className >com/google/cloud/spanner/LatencyTest</className >
10591059 </difference >
1060+ <difference >
1061+ <differenceType >7012</differenceType >
1062+ <className >com/google/cloud/spanner/connection/Connection</className >
1063+ <method >java.lang.Object getConnectionPropertyValue(com.google.cloud.spanner.connection.ConnectionProperty)</method >
1064+ </difference >
10601065</differences >
Original file line number Diff line number Diff line change @@ -189,6 +189,10 @@ public interface Connection extends AutoCloseable {
189189 */
190190 void reset ();
191191
192+ /** Returns the current value of the given connection property. */
193+ <T > T getConnectionPropertyValue (
194+ com .google .cloud .spanner .connection .ConnectionProperty <T > property );
195+
192196 /**
193197 * Sets autocommit on/off for this {@link Connection}. Connections in autocommit mode will apply
194198 * any changes to the database directly without waiting for an explicit commit. DDL- and DML
Original file line number Diff line number Diff line change @@ -574,7 +574,8 @@ public boolean isClosed() {
574574 return closed ;
575575 }
576576
577- private <T > T getConnectionPropertyValue (
577+ @ Override
578+ public <T > T getConnectionPropertyValue (
578579 com .google .cloud .spanner .connection .ConnectionProperty <T > property ) {
579580 return this .connectionState .getValue (property ).getValue ();
580581 }
Original file line number Diff line number Diff line change @@ -766,6 +766,18 @@ public class ConnectionProperties {
766766 DEFAULT_BATCH_DML_UPDATE_COUNT ,
767767 LongConverter .INSTANCE ,
768768 Context .USER );
769+ public static final ConnectionProperty <Integer > UNKNOWN_LENGTH =
770+ create (
771+ "unknownLength" ,
772+ "Spanner does not return the length of the selected columns in query results. When"
773+ + " returning meta-data about these columns through functions like"
774+ + " ResultSetMetaData.getColumnDisplaySize and ResultSetMetaData.getPrecision, we"
775+ + " must provide a value. Various client tools and applications have different ideas"
776+ + " about what they would like to see. This property specifies the length to return"
777+ + " for types of unknown length." ,
778+ /* defaultValue= */ 50 ,
779+ NonNegativeIntegerConverter .INSTANCE ,
780+ Context .USER );
769781
770782 static final ImmutableMap <String , ConnectionProperty <?>> CONNECTION_PROPERTIES =
771783 CONNECTION_PROPERTIES_BUILDER .build ();
Original file line number Diff line number Diff line change @@ -291,4 +291,13 @@ public void testSetLocalInvalidValue() {
291291 assertTrue (connection .isRetryAbortsInternally ());
292292 }
293293 }
294+
295+ @ Test
296+ public void testGetConnectionProperty () {
297+ try (Connection connection = createConnection ()) {
298+ ConnectionProperty <Integer > unknownLength = ConnectionProperties .UNKNOWN_LENGTH ;
299+ assertEquals (
300+ unknownLength .getDefaultValue (), connection .getConnectionPropertyValue (unknownLength ));
301+ }
302+ }
294303}
You can’t perform that action at this time.
0 commit comments