h2database / h2database/h2database

Can't ADD COLUMN with 2.0.201-212cb2cfe

Open
#3,132 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.6k
Forks
1.3k
Avg merge
1d 2h
Merged PRs (30d)
9

Description

I have migrated successfully to the latest h2-2.0.201-212cb2cfe.jar and am able to open the database.
There is a table defined like that:

CREATE TABLE IFRSBOX.CFE.FEE_TYPE ( 
    ID_FEE_TYPE        CHARACTER VARYING(12) NOT NULL
    , DESCRIPTION        CHARACTER VARYING(255) NULL
);
CREATE UNIQUE INDEX PRIMARY_KEY_24C
    ON IFRSBOX.CFE.FEE_TYPE(ID_FEE_TYPE);

When I try to add a column, I get a very confusing error

ALTER TABLE cfe.fee_type
    ADD COLUMN id_fee_type_ref NUMBER (5) NULL
;
Syntax error in SQL statement "CREATE PRIMARY[*] KEY ""FEE_TYPE_COPY_3_3_PRIMARY_KEY_24C"" ON ""CFE"".""FEE_TYPE_COPY_3_3""(""ID_FEE_TYPE"")"; expected "OR, FORCE, VIEW, ALIAS, SEQUENCE, USER, TRIGGER, ROLE, SCHEMA, CONSTANT, DOMAIN, TYPE, DATATYPE, AGGREGATE, LINKED, MEMORY, CACHED, LOCAL, GLOBAL, TEMP, TEMPORARY, TABLE, SYNONYM, UNIQUE, HASH, SPATIAL, INDEX"; SQL statement:
ALTER TABLE cfe.fee_type
    ADD COLUMN id_fee_type_ref NUMBER (5) NULL [42001-201]

I do not think I did anything wrong because exactly this statement has worked a few times before with previous versions of H2 2.0.201.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided CREATE TABLE, CREATE UNIQUE INDEX, and ALTER TABLE statements against H2 2.0.201, then compare the same reproduction with the earlier H2 versions where it worked. Trace the ALTER TABLE path that generates the FEE_TYPE_COPY_3_3 index statement; done when the valid ADD COLUMN succeeds without the misleading syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.