Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions google-cloud-spanner/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1057,4 +1057,9 @@
<differenceType>8001</differenceType>
<className>com/google/cloud/spanner/LatencyTest</className>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/spanner/connection/Connection</className>
<method>java.lang.Object getConnectionPropertyValue(com.google.cloud.spanner.connection.ConnectionProperty)</method>
</difference>
</differences>
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public interface Connection extends AutoCloseable {
*/
void reset();

/** Returns the current value of the given connection property. */
<T> T getConnectionPropertyValue(
com.google.cloud.spanner.connection.ConnectionProperty<T> property);

/**
* Sets autocommit on/off for this {@link Connection}. Connections in autocommit mode will apply
* any changes to the database directly without waiting for an explicit commit. DDL- and DML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ public boolean isClosed() {
return closed;
}

private <T> T getConnectionPropertyValue(
@Override
public <T> T getConnectionPropertyValue(
com.google.cloud.spanner.connection.ConnectionProperty<T> property) {
return this.connectionState.getValue(property).getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,18 @@ public class ConnectionProperties {
DEFAULT_BATCH_DML_UPDATE_COUNT,
LongConverter.INSTANCE,
Context.USER);
public static final ConnectionProperty<Integer> UNKNOWN_LENGTH =
create(
"unknownLength",
"Spanner does not return the length of the selected columns in query results. When"
+ " returning meta-data about these columns through functions like"
+ " ResultSetMetaData.getColumnDisplaySize and ResultSetMetaData.getPrecision, we"
+ " must provide a value. Various client tools and applications have different ideas"
+ " about what they would like to see. This property specifies the length to return"
+ " for types of unknown length.",
/* defaultValue= */ 50,
NonNegativeIntegerConverter.INSTANCE,
Context.USER);

static final ImmutableMap<String, ConnectionProperty<?>> CONNECTION_PROPERTIES =
CONNECTION_PROPERTIES_BUILDER.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,13 @@ public void testSetLocalInvalidValue() {
assertTrue(connection.isRetryAbortsInternally());
}
}

@Test
public void testGetConnectionProperty() {
try (Connection connection = createConnection()) {
ConnectionProperty<Integer> unknownLength = ConnectionProperties.UNKNOWN_LENGTH;
assertEquals(
unknownLength.getDefaultValue(), connection.getConnectionPropertyValue(unknownLength));
}
}
}
Loading