tursodatabase / tursodatabase/libsql

Setting `legacy_alter_table` works in shell but not in sqld

Open
#1,547 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17.2k
Forks
531
Avg merge
1h 12m
Merged PRs (30d)
1

Description

The legacy_alter_table pragma is required to reliably implement the suggested procedure for other kinds of schema changes without manually tracking views. Unfortunately, setting this pragma fails in Turso. I thought that this may perhaps be caused by compile-time options disabling legacy pragmas, but it's available in libsql-sqlite3:

$ ./libsql-sqlite3/libsql
-- Loading resources from /home/simon/.sqliterc
libSQL version 0.2.3 (based on SQLite version 3.44.0) 2023-11-01 11:23:50
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
libsql> pragma legacy_alter_table = 1;
libsql> .q

With a sqld build that should use the same sqlite3 build, it doesn't work:

$ ./target/debug/sqld &
$ turso db shell http://127.0.0.1:8080
Connected to http://127.0.0.1:8080

Welcome to Turso SQL shell!

Type ".quit" to exit the shell and ".help" to list all available commands.

→  pragma legacy_alter_table = 1;
Error: failed to execute SQL: pragma legacy_alter_table = 1;
SQL string could not be parsed: unsupported statement: pragma legacy_alter_table = 1

Contributor guide

Open the contributing guide

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

Reproduce the failure by running sqld and issuing pragma legacy_alter_table = 1; through turso db shell, then compare it with the libsql CLI behavior shown in the issue. Trace how sqld parses and executes PRAGMA statements. Done means the pragma is accepted and executes successfully through sqld.

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.