kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | e35412f5ec6027a0aeb79c8d07105fb100906f804b0ada7bd9626e1f2b9c2425 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-07-05 12:45 -05:00 |
| Committer | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-07-05 10:45 -07:00 |
| Parents | c7e0192701f3 |
3 files changed
modified changelog/README.md +1 −0
| @@ -15,6 +15,7 @@ | ||
| 15 | 15 | - [improvement] JAVA-1198: Document that BoundStatement is not thread-safe. |
| 16 | 16 | - [improvement] JAVA-1200: Upgrade LZ4 to 1.3.0. |
| 17 | 17 | - [bug] JAVA-1232: Fix NPE in IdempotenceAwareRetryPolicy.isIdempotent. |
| 18 | +- [improvement] JAVA-1227: Document "SELECT *" issue with prepared statement. | |
| 18 | 19 | |
| 19 | 20 | |
| 20 | 21 | ### 3.0.2 |
modified faq/README.md +11 −0
| @@ -88,6 +88,17 @@ | ||
| 88 | 88 | ``` |
| 89 | 89 | |
| 90 | 90 | |
| 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 | + | |
| 91 | 102 | ### Can I get the raw bytes of a text column? |
| 92 | 103 | |
| 93 | 104 | 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 @@ | ||
| 241 | 241 | specific situations; read each method's Javadoc for detailed |
| 242 | 242 | explanations. |
| 243 | 243 | |
| 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 | + | |
| 244 | 260 | [PreparedStatement]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/PreparedStatement.html |
| 245 | 261 | [BoundStatement]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/BoundStatement.html |
| 246 | 262 | [setPrepareOnAllHosts]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/QueryOptions.html#setPrepareOnAllHosts-boolean- |
| 247 | 263 | [setReprepareOnUp]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/QueryOptions.html#setReprepareOnUp-boolean- |
| 248 | 264 | [execute]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/Session.html#execute-com.datastax.driver.core.Statement- |
| 249 | 265 | [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 |