Fix token-aware routing for prepared INSERT and UPDATE queries

Description

The method getRoutingKeyspace is currently implemented as follows in DefaultBoundStatement:

1 2 3 4 5 6 7 8 9 10 11 @Override public CqlIdentifier getRoutingKeyspace() { // If it was set explicitly, use that value, else try to infer it from the prepared statement's // metadata if (routingKeyspace != null) { return routingKeyspace; } else { ColumnDefinitions definitions = preparedStatement.getResultSetDefinitions(); return (definitions.size() == 0) ? null : definitions.get(0).getKeyspace(); } }

This logic works only for SELECT statements; for INSERT and UPDATE statements, it is broken because preparedStatement.getResultSetDefinitions() returns an empty instance; we should inspect getVariableDefinitions() instead.

Environment

None

Pull Requests

None

Status

Assignee

Unassigned

Reporter

Alexandre Dutra

Labels

None

PM Priority

None

Reproduced in

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

Doc Impact

None

Reviewer

None

Size

None

Fix versions

Affects versions

4.2.0

Priority

Major