Skip to content

INDEX name (...) inside CREATE TABLE does not create an index #2607

Closed

Description

@mathiasrw

INDEX name (...) inside CREATE TABLE is parsed, but no index is created. CREATE INDEX on the same column creates one.

Reproduced on develop (v4.20.0):

alasql('CREATE TABLE t1 (a INT, b INT, INDEX k1 (a))');
alasql('SHOW INDEX FROM t1');                 // []          expected: one index
alasql.databases.alasql.indices;              // {}          expected: {k1: 't1'}

alasql('CREATE TABLE t2 (a INT, b INT)');
alasql('CREATE INDEX k2 ON t2 (a)');
alasql('SHOW INDEX FROM t2');                 // [{hh: ..., len: 0}]
alasql.databases.alasql.indices;              // {k2: 't2'}

Cause

yy.CreateTable.prototype.execute (src/60createtable.js) handles the constraint types PRIMARY KEY, CHECK, UNIQUE and FOREIGN KEY. A constraint of type INDEX is skipped.

Direction

Register the index the way CREATE INDEX does: table.inddefs[name], table.indices[hh] and db.indices[name]. INSERT then keeps it up to date. With #2606, the columns can have a prefix length (INDEX k (a(10))).

Tests: SHOW INDEX, db.indices, and rows inserted after CREATE TABLE are found through the index.

Activity

  1. added a commit that references this issue on Oct 20, 2026
    a170987
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions