phoenix
phoenix copied to clipboard
support alter modify column grammar
JIRA: PHOENIX-4815 @joshelser @twdsilva Please help me reviewing this patch.
I had updated this patch and added some test. Please review :) @twdsilva
@jaanai0 From the example that @dbwong gave, I don't think we can support decreasing the length of a column. If the column is present in an index this can cause queries to return different results when the index is queried vs the data table.
Thanks for your point out. @dbwong This grammar references ORACLE dialect( https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_3001.htm#i2103956), only one column can be modified at a time.
The modify grammar will not change old data, which just change schema information. we can get correctly query result on the server side as long as the values of filtering conditions are tampered with on the client side.
For Varchar type, now we can not trim query results if the length of fields is decreased, so the example that @dbwong gave will be ok, for blew queries that haven't result, I also add a new test case in the code which similar with this scenario.
SELECT * from table WHERE b=='13'; -- does this return 2 rows? or does it return 0? SELECT * from tableIdx WHERE b=='13'; -- this will return 0 rows
For Char type, we will forbid to decrease the length of fields. The query results will be trimmed on the client side that can not match actual data. For example:
CREATE TABLE tableName (a VARCHAR(5), b VARCHAR(5), CONSTRAINT PK PRIMARY KEY (a)); CREATE INDEX tableIdx ON tableName (b); UPSERT INTO tableName Values('b','13555'); ALTER TABLE tableName modify b VARCHAR(2); UPSERT INTO tableName Values('d','13'); SELECT /+ NO_INDEX/ b from tableName WHERE b='13'; SELECT /+ NO_INDEX/ b from " + tableName + " WHERE b='13555'; SELECT "0:B" from tableIdx WHERE "0:B"='13555'; SELECT "0:B" from tableIdx WHERE "0:B"='13';
Output: 13 13(this is a incorrect result) 13555 13
@twdsilva @dbwong I have updated the patch again.
@twdsilva I have updated the new patch. Please review, thank you very much! :)
I had forbidden to decrease the length of columns. @twdsilva @dbwong @ChinmaySKulkarni
I'll try to take another look at this sometime tomorrow.
@twdsilva @jaanaizhang The end? Please provide an latest patch, or the next version will be fixed. Thanks.
@twdsilva @jaanaizhang The end? Please provide an latest patch, or the next version will be fixed. Thanks.
I will fix this issue in the next major version as soon as possible.