Hello,

In the following test case, col2 is a computed column depending on col1. I 
try to drop col1, which is obviously a bad idea:

CREATE TABLE test(col1 INT);
INSERT INTO test VALUES (1);
ALTER TABLE test ADD COLUMN col2 INT AS col1*2;
ALTER TABLE test DROP COLUMN COL1;

The error message doesn't seem to correspond to what's actually wrong; H2 
complains that the column is not found:

Column "COL1" not found; SQL statement:
ALTER TABLE test DROP COLUMN COL1 [42122-175] 42S22/42122 (Help)
org.h2.jdbc.JdbcSQLException: Column "COL1" not found; SQL statement:
ALTER TABLE test DROP COLUMN COL1 [42122-175]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:333)
    at org.h2.message.DbException.get(DbException.java:173)
    at org.h2.message.DbException.get(DbException.java:150)
    at 
org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:144)
    at org.h2.expression.Operation.optimize(Operation.java:181)
    at org.h2.table.Column.prepareExpression(Column.java:392)
    at org.h2.command.ddl.CreateTable.update(CreateTable.java:162)
    at 
org.h2.command.ddl.AlterTableAlterColumn.execute(AlterTableAlterColumn.java:440)
    at 
org.h2.command.ddl.AlterTableAlterColumn.cloneTableStructure(AlterTableAlterColumn.java:340)
    at 
org.h2.command.ddl.AlterTableAlterColumn.copyData(AlterTableAlterColumn.java:220)
    at 
org.h2.command.ddl.AlterTableAlterColumn.update(AlterTableAlterColumn.java:164)
    at org.h2.command.CommandContainer.update(CommandContainer.java:79)
    at org.h2.command.Command.executeUpdate(Command.java:253)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:181)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:156)
    at org.h2.server.web.WebApp.getResult(WebApp.java:1324)
    at org.h2.server.web.WebApp.query(WebApp.java:1013)
    at org.h2.server.web.WebApp$1.next(WebApp.java:975)
    at org.h2.server.web.WebApp$1.next(WebApp.java:962)
    at org.h2.server.web.WebThread.process(WebThread.java:167)
    at org.h2.server.web.WebThread.run(WebThread.java:94)
    at java.lang.Thread.run(Thread.java:744)

I would have expected something like "Impossible to delete "COL1" since 
another column depends on it."

Maybe I'm missing something?

Thanks!
Adam Gouge

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to