Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 19, 2025

Description

CREATE INDEX failed with TypeError: undefined is not an object (evaluating 'table.inddefs') when using qualified table names (e.g., database.table). The parser already supported qualified names, but the execute function did not resolve the database correctly.

Changes

Modified src/65createindex.js:

  • Changed database resolution to check this.table.databaseid || databaseid (line 23)
  • Follows existing pattern from CREATE TABLE, DROP TABLE, and ALTER TABLE

Added test/test2184.js:

  • Tests CREATE INDEX with qualified names without USE statement
  • Tests CREATE UNIQUE INDEX with qualified names
  • Tests REINDEX functionality

Example

-- Now works without USE statement
CREATE DATABASE mydb;
CREATE TABLE mydb.users (id INT, name STRING);
CREATE INDEX idx_id ON mydb.users (id);
CREATE UNIQUE INDEX idx_name ON mydb.users (name);

Checklist

  • Tests added
  • No regressions in existing tests
  • Security scan passed

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • upload.wikimedia.org
    • Triggering command: /usr/local/bin/node node_modules/mocha/bin/mocha.js ./test --reporter dot --bail test/test2184.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>CREATE INDEX statement doesn't support qualified table names</issue_title>
<issue_description>The CREATE INDEX statement doesn't support qualified table names.

Error: "TypeError: undefined is not an object (evaluating 'table.inddefs')"

Workaround: Must use temporary USE statements

Root cause: Parser expects unqualified names and fails to resolve table object
</issue_description>

<agent_instructions>Please make a new test file named test2184.js that is a copy of test403.js and then replicate the problem by naming the table explicitly in create index. Like

CREATE INDEX xone ON test403.one (a);

you can run the test via yarn test test/test2184.js

If you need to edit the parser its in src/alasqlparser.jison and after editing (pleaes be very carefull) you need to run yarn jison &&. yarn test to test it. </agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 19, 2025 06:12
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CREATE INDEX statement for qualified table names Fix CREATE INDEX to support qualified table names Nov 19, 2025
Copilot AI requested a review from mathiasrw November 19, 2025 06:22
Copilot finished work on behalf of mathiasrw November 19, 2025 06:22
@mathiasrw mathiasrw marked this pull request as ready for review November 19, 2025 07:06
@mathiasrw mathiasrw merged commit 95fb119 into develop Nov 19, 2025
19 of 20 checks passed
@mathiasrw mathiasrw deleted the copilot/fix-create-index-qualified-names branch November 19, 2025 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CREATE INDEX statement doesn't support qualified table names

2 participants