phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

support alter modify column grammar

Open jaime0815 opened this issue 6 years ago • 8 comments

JIRA: PHOENIX-4815 @joshelser @twdsilva Please help me reviewing this patch.

jaime0815 avatar Sep 21 '18 12:09 jaime0815

I had updated this patch and added some test. Please review :) @twdsilva

jaime0815 avatar Sep 29 '18 07:09 jaime0815

@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.

twdsilva avatar Oct 11 '18 04:10 twdsilva

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.

jaime0815 avatar Oct 11 '18 15:10 jaime0815

@twdsilva I have updated the new patch. Please review, thank you very much! :)

jaime0815 avatar Oct 12 '18 09:10 jaime0815

I had forbidden to decrease the length of columns. @twdsilva @dbwong @ChinmaySKulkarni

jaime0815 avatar Oct 13 '18 04:10 jaime0815

I'll try to take another look at this sometime tomorrow.

dbwong avatar Oct 16 '18 23:10 dbwong

@twdsilva @jaanaizhang The end? Please provide an latest patch, or the next version will be fixed. Thanks.

Hackeruncle avatar May 06 '19 07:05 Hackeruncle

@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.

jaime0815 avatar May 07 '19 02:05 jaime0815