Skip to content

Commit

Permalink
Merge pull request #2030 from ClickHouse/add-noop-flags
Browse files Browse the repository at this point in the history
No-op flags
  • Loading branch information
Paultagoras authored Dec 17, 2024
2 parents 20babb5 + 3b6fc1c commit 19172f6
Show file tree
Hide file tree
Showing 5 changed files with 519 additions and 141 deletions.
98 changes: 79 additions & 19 deletions jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,22 @@ public PreparedStatement prepareStatement(String sql) throws SQLException {
@Override
public CallableStatement prepareCall(String sql) throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
public String nativeSQL(String sql) throws SQLException {
checkOpen();
/// TODO: this is not implemented according to JDBC spec and may not be used.
throw new SQLFeatureNotSupportedException("nativeSQL not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("nativeSQL not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
Expand Down Expand Up @@ -181,7 +189,7 @@ public DatabaseMetaData getMetaData() throws SQLException {
@Override
public void setReadOnly(boolean readOnly) throws SQLException {
checkOpen();
if (readOnly) {
if (!config.isIgnoreUnsupportedRequests() && readOnly) {
throw new SQLFeatureNotSupportedException("read-only=true unsupported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}
Expand All @@ -206,7 +214,7 @@ public String getCatalog() throws SQLException {
@Override
public void setTransactionIsolation(int level) throws SQLException {
checkOpen();
if (TRANSACTION_NONE != level) {
if (!config.isIgnoreUnsupportedRequests() && TRANSACTION_NONE != level) {
throw new SQLFeatureNotSupportedException("setTransactionIsolation not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}
Expand Down Expand Up @@ -243,19 +251,29 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
public Map<String, Class<?>> getTypeMap() throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("getTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("getTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("setTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("setTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}

@Override
Expand All @@ -273,13 +291,21 @@ public int getHoldability() throws SQLException {
@Override
public Savepoint setSavepoint() throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
public Savepoint setSavepoint(String name) throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
Expand All @@ -293,7 +319,9 @@ public void rollback(Savepoint savepoint) throws SQLException {
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}

@Override
Expand All @@ -311,7 +339,11 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
Expand Down Expand Up @@ -350,25 +382,41 @@ public PreparedStatement prepareStatement(String sql, String[] columnNames) thro
@Override
public Clob createClob() throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("Clob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("Clob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
public Blob createBlob() throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("Blob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("Blob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
public NClob createNClob() throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("NClob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("NClob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
public SQLXML createSQLXML() throws SQLException {
checkOpen();
throw new SQLFeatureNotSupportedException("SQLXML not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("SQLXML not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
Expand Down Expand Up @@ -445,7 +493,11 @@ public Array createArrayOf(String typeName, Object[] elements) throws SQLExcepti
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
//TODO: Should this be supported?
throw new SQLFeatureNotSupportedException("createStruct not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("createStruct not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return null;
}

@Override
Expand All @@ -462,19 +514,27 @@ public String getSchema() throws SQLException {

@Override
public void abort(Executor executor) throws SQLException {
throw new SQLFeatureNotSupportedException("abort not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("abort not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}

@Override
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
//TODO: Should this be supported?
throw new SQLFeatureNotSupportedException("setNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("setNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}

@Override
public int getNetworkTimeout() throws SQLException {
//TODO: Should this be supported?
throw new SQLFeatureNotSupportedException("getNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("getNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}

return -1;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ public void setCharacterStream(int parameterIndex, Reader x, int length) throws
@Override
public void setRef(int parameterIndex, Ref x) throws SQLException {
checkClosed();
throw new SQLFeatureNotSupportedException("Ref is not supported.", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
if (!connection.config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("Ref is not supported.", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}

@Override
Expand Down
Loading

0 comments on commit 19172f6

Please sign in to comment.