sstableloader: fix generating CQL statements
sstableloader: fix generating CQL statements

Before this change, sstableloader would incorrectly generate CQL prepared
statements with "range" WHERE clauses. For example in case of:

(... WHERE) ck >= 5 AND ck <= 10 (...)

SSTableToCQL would generate prepared statement:

(...) ck >= :v2 AND ck <= :v2 (...)

incorrectly binding lower and upper bound to the same bound variable. Therefore
an invalid prepared statement would be executed:

(...) ck >= 10 AND ck <= 10 (...)

Before this change, the code assumed every column to be paired with only a
single variable, however in case of "range" WHERE clauses a single column can
be mapped to two bound variables.

This change modifies varName method to differentiate between different
instances of variables regarding the same column and modifies query generation
code to provide that information.

Before this change, sstableloader would incorrectly load SSTable flushed after
the following commands:

cqlsh> CREATE TABLE cycling.t(pk int, ck int, v int, PRIMARY KEY (pk, ck));
cqlsh> INSERT INTO cycling.t(pk, ck, v) VALUES (1, 1, 1);
cqlsh> INSERT INTO cycling.t(pk, ck, v) VALUES (1, 2, 1);
cqlsh> INSERT INTO cycling.t(pk, ck, v) VALUES (1, 3, 1);
cqlsh> INSERT INTO cycling.t(pk, ck, v) VALUES (1, 4, 1);
cqlsh> INSERT INTO cycling.t(pk, ck, v) VALUES (1, 5, 1);
cqlsh> DELETE FROM cycling.t WHERE pk=1 AND ck >= 2 AND ck <= 4;
cqlsh> SELECT * FROM cycling.t;
 pk | ck | v
----+----+---
  1 |  1 | 1
  1 |  5 | 1

After importing with sstableloader (having recreated the table), the table
would have too many rows:

cqlsh> SELECT * FROM cycling.t;
 pk | ck | v
----+----+---
  1 |  1 | 1
  1 |  2 | 1
  1 |  3 | 1
  1 |  5 | 1
(it would execute delete statement with ck >= 4 AND ck <= 4 instead of ck >= 2 AND ck <= 4)

Fixes #204

Dtest checking this scenario: scylladb/scylla-dtest#1691

Reviewed-by: Calle Wilund <8f9f97eb45ed102f8faf72e01bebf7b2c1679978@scylladb.com>
Reviewed-by: Piotr Jastrzebski <2c0eb4a25a7cde333ff2d0860cb06051925fd74f@scylladb.com>

scylladb/scylla-tools-java,scylladb/scylla-tools-java,scylladb/scylla-tools-java,scylladb/scylla-tools-java