cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Warski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-10811) Prepared SELECT * queries return incorrect columns after schema change
Date Thu, 03 Dec 2015 12:25:10 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-10811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15037725#comment-15037725
] 

Adam Warski commented on CASSANDRA-10811:
-----------------------------------------

{code}
     val session = Cluster.builder()
        .addContactPoints("127.0.0.1")
        .withPort(9042)
        .build()
        .connect()

      try {
        session.execute("""DROP KEYSPACE IF EXISTS testkeyspace""")
        session.execute("""CREATE KEYSPACE testkeyspace WITH replication={'class' : 'SimpleStrategy',
'replication_factor':1}""")
        session.execute(
          """
            |CREATE TABLE IF NOT EXISTS testkeyspace.bug (
            |  id bigint PRIMARY KEY,
            |  a_field bigint,
            |  c_field bigint
            |);
          """.stripMargin)

        session.execute("INSERT INTO testkeyspace.bug(id, a_field, c_field) VALUES (1, 42,
420)")

        // (1) works if this is commented out
        session
          .execute(session.prepare("SELECT * FROM testkeyspace.bug WHERE id = ?").bind(1L:
java.lang.Long))
          .one().getLong("c_field") must be_==(420)

        // (2) works if the added field is alphabetically after the existing ones (e.g. d_field
would work)
        session.execute("ALTER TABLE testkeyspace.bug ADD b_field bigint")

        // (3) works with a normal query
        session.execute("SELECT * FROM testkeyspace.bug WHERE id = 1")
          .one().getLong("c_field") must be_==(420)

        // doesn't work - returns 0
        session
          .execute(session.prepare("SELECT * FROM testkeyspace.bug WHERE id = ?").bind(1L:
java.lang.Long))
          .one().getLong("c_field") must be_==(420)
      } finally {
        session.close()
      }
{code}

> Prepared SELECT * queries return incorrect columns after schema change
> ----------------------------------------------------------------------
>
>                 Key: CASSANDRA-10811
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10811
>             Project: Cassandra
>          Issue Type: Bug
>         Environment: Cassandra 2.2.3
> Java driver 2.1.9
>            Reporter: Adam Warski
>
> (see also the test case attached)
> When executing the following steps using a single `com.datastax.driver.core.Session`:
> 1. create table with column `a` and `c`
> 2. insert a single row with values for both columns
> 3. select that row using a prepared statement (`SELECT * FROM table WHERE id=?`)
> 4. alter the table adding a new column `b`
> 5. select the row using a prepared statement (preparing the statement again, not re-using
the old one)
> The value of the `c` column is not returned, instead there's a `NULL` (which I suppose
is the value of the newly inserted `b` column).
> The query returns correct results if:
> * step 3 is skipped, that is there is no prepared select before altering the table
> * a normal, non-prepared select is done
> * a select with explicitly enumerated fields is done
> * a new session is created



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message