Elffuss BraidHub

kikocis/java-driver public

JAVA-1227: Document "SELECT *" issue with prepared statement (#703)

Changesete35412f5ec6027a0aeb79c8d07105fb100906f804b0ada7bd9626e1f2b9c2425
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2016-07-05 12:45 -05:00
CommitterOlivier Michallat <olim7t@users.noreply.github.com> · 2016-07-05 10:45 -07:00
Parentsc7e0192701f3

Browse the files at this changeset

3 files changed

modified changelog/README.md +1 −0
@@ -15,6 +15,7 @@
1515 - [improvement] JAVA-1198: Document that BoundStatement is not thread-safe.
1616 - [improvement] JAVA-1200: Upgrade LZ4 to 1.3.0.
1717 - [bug] JAVA-1232: Fix NPE in IdempotenceAwareRetryPolicy.isIdempotent.
18+- [improvement] JAVA-1227: Document "SELECT *" issue with prepared statement.
1819
1920
2021 ### 3.0.2
modified faq/README.md +11 −0
@@ -88,6 +88,17 @@
8888 ```
8989
9090
91+### Why do my 'SELECT *' `PreparedStatement`-based queries stop working after a schema change?
92+
93+Both the driver and Cassandra maintain a mapping of `PreparedStatement` queries to their
94+metadata. When a change is made to a table, such as a column being added or dropped, there
95+is currently no mechanism for Cassandra to invalidate the existing metadata. Because of this,
96+the driver is not able to properly react to these changes and will improperly read rows after
97+a schema change is made.
98+
99+See [Prepared statements](../manual/statements/prepared) for more information.
100+
101+
91102 ### Can I get the raw bytes of a text column?
92103
93104 If you need to access the raw bytes of a text column, call the
modified manual/statements/prepared/README.md +18 −0
@@ -241,9 +241,27 @@
241241 specific situations; read each method's Javadoc for detailed
242242 explanations.
243243
244+### Avoid preparing 'SELECT *' queries
245+
246+Both the driver and Cassandra maintain a mapping of `PreparedStatement` queries to their
247+metadata. When a change is made to a table, such as a column being added or dropped, there
248+is currently no mechanism for Cassandra to invalidate the existing metadata. Because of this,
249+the driver is not able to properly react to these changes and will improperly read rows after
250+a schema change is made.
251+
252+Therefore it is currently recommended to not create prepared statements
253+for 'SELECT *' queries if you plan on making schema changes involving
254+adding or dropping columns. Alternatively you should list all columns of interest
255+in your statement, i.e.: `SELECT a, b, c FROM tbl`.
256+
257+This will be addressed in a future release of both Cassandra and the driver. Follow
258+[CASSANDRA-10786] and [JAVA-1196] for more information.
259+
244260 [PreparedStatement]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/PreparedStatement.html
245261 [BoundStatement]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/BoundStatement.html
246262 [setPrepareOnAllHosts]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/QueryOptions.html#setPrepareOnAllHosts-boolean-
247263 [setReprepareOnUp]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/QueryOptions.html#setReprepareOnUp-boolean-
248264 [execute]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/Session.html#execute-com.datastax.driver.core.Statement-
249265 [executeAsync]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/Session.html#executeAsync-com.datastax.driver.core.Statement-
266+[CASSANDRA-10786]: https://issues.apache.org/jira/browse/CASSANDRA-10786
267+[JAVA-1196]: https://datastax-oss.atlassian.net/browse/JAVA-1196
No newline at the end of the file