Closed pankaj2461 closed 10 years ago
Pankaj,
Did you mean adding a new NOT NULL column which is part of a row key? If yes, then we already don't allow adding non null columns that will be part of PK.
CREATE TABLE test_table (a_string varchar not null, col1 integer, cf1.col2 integer CONSTRAINT pk PRIMARY KEY (a_string))
ALTER TABLE test_table ADD b_string VARCHAR NOT NULL PRIMARY KEY
Fails with the error: Error: ERROR 1006 (42J04): Only nullable columns may be added to a multi-part row key. columnName=B_STRING SQLState: 42J04 ErrorCode: 1006
However, we do currently allow adding a non null column to the table if it is not part of the PK. I am working on addressing that issue.
Thanks Samarth for replying..!!
I meant for adding a NOT NULL column to the table (few records already present) if it is not part of the PK.
We should not allow to add a NOT NULL column when records present in the table.
Fixed in master by @samarthjain. Thanks for the contribution!
ALTER TABLE should not add/modify a column with NOT NULL constraint in table where some records are already present.
Currently the same is allowed in phoenix 2.0.1 release, which is causing inconsistent behavior while querying on the added column with "IS NULL" or "IS NOT NULL" utilities