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
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@


public interface ClickHouseConnection extends Connection {

@Deprecated
ClickHouseStatement createClickHouseStatement() throws SQLException;

TimeZone getServerTimeZone();

TimeZone getTimeZone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ public ClickHouseStatement createStatement(int resultSetType) throws SQLExceptio
resultSetType));
}

@Deprecated
@Override
public ClickHouseStatement createClickHouseStatement() throws SQLException {
return createStatement();
}

@Override
public TimeZone getTimeZone() {
return timezone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ public class ClickHousePreparedStatementImpl extends ClickHouseStatementImpl imp
static final String PARAM_MARKER = "?";
static final String NULL_MARKER = "\\N";

private static final Pattern VALUES = Pattern.compile("(?i)VALUES[\\s]*\\(");

private final TimeZone dateTimeZone;
private final TimeZone dateTimeTimeZone;
private final String sql;
private final ClickHouseSqlStatement parsedStmt;
private final List<String> sqlParts;
private final ClickHousePreparedStatementParameter[] binds;
private final List<List<String>> parameterList;
Expand All @@ -67,9 +65,14 @@ public ClickHousePreparedStatementImpl(CloseableHttpClient client,
TimeZone serverTimeZone, int resultSetType) throws SQLException
{
super(client, connection, properties, resultSetType);
parseSingleStatement(sql);
parseSqlStatements(sql);

if (parsedStmts.length != 1) {
throw new IllegalArgumentException("Only single statement is supported");
}

parsedStmt = parsedStmts[0];

this.sql = sql;
PreparedStatementParser parser = PreparedStatementParser.parse(sql,
parsedStmt.getEndPosition(ClickHouseSqlStatement.KEYWORD_VALUES));
this.parameterList = parser.getParameters();
Expand Down Expand Up @@ -353,13 +356,9 @@ public int[] executeBatch() throws SQLException {
@Override
public int[] executeBatch(Map<ClickHouseQueryParam, String> additionalDBParams) throws SQLException {
int valuePosition = -1;
String sql = parsedStmt.getSQL();
if (parsedStmt.getStatementType() == StatementType.INSERT && parsedStmt.hasValues()) {
valuePosition = parsedStmt.getStartPosition(ClickHouseSqlStatement.KEYWORD_VALUES);
} else {
Matcher matcher = VALUES.matcher(sql);
if (matcher.find()) {
valuePosition = matcher.start();
}
}

if (valuePosition < 0) {
Expand Down Expand Up @@ -443,7 +442,7 @@ public ResultSetMetaData getMetaData() throws SQLException {
return currentResult.getMetaData();
}

if (!parsedStmt.isQuery() || (!parsedStmt.isRecognized() && !isSelect(sql))) {
if (!parsedStmt.isQuery()) {
return null;
}
ResultSet myRs = executeQuery(Collections.singletonMap(
Expand Down Expand Up @@ -626,7 +625,7 @@ public String asSql() {
try {
return buildSql();
} catch (SQLException e) {
return sql;
return parsedStmt.getSQL();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ResultSet executeQuery(String sql,

/**
* Returns extended write-API, which simplifies uploading larger files or
* data streams
* data streams.
*
* @return a new {@link Writer} builder object which can be used to
* construct a request to the server
Expand Down
Loading