Current LibSQL code for analyzing ALTER TABLE t ALTER COLUMN x TO x ... just takes raw string after second column name and use it as a column definition with only ; (semicolon) stripped from the end.
This can lead to bad column definition as extra white spaces (like in https://github.com/tursodatabase/libsql/issues/1517) or comments can be prepended to the ALTER TABLE command (for example, ALTER TABLE t4 ALTER COLUMN x TO x INTEGER DEFAULT(-1); -- some explanation should be valid, but with current approach it will be translated to the incorrect SQL: CREATE TABLE t ( x INTEGER DEFAULT(-1); -- some explanation ); note semicolon in the middle of CREATE TABLE expression)
This PR fixes new column sql definition by propagating parsed part of the expression directly from parser
Changes
Propagate length of the new column definition from the parser
Add basic TCL tests for ALTER COLUMN feature in libsql_alter.test
Slightly adjust C code formatting around code added by libsql for ALTER COLUMN feature
Context
Current
LibSQL
code for analyzingALTER TABLE t ALTER COLUMN x TO x ...
just takes raw string after second column name and use it as a column definition with only;
(semicolon) stripped from the end.This can lead to bad column definition as extra white spaces (like in https://github.com/tursodatabase/libsql/issues/1517) or comments can be prepended to the
ALTER TABLE
command (for example,ALTER TABLE t4 ALTER COLUMN x TO x INTEGER DEFAULT(-1); -- some explanation
should be valid, but with current approach it will be translated to the incorrect SQL:CREATE TABLE t ( x INTEGER DEFAULT(-1); -- some explanation )
; note semicolon in the middle ofCREATE TABLE
expression)This PR fixes new column sql definition by propagating parsed part of the expression directly from parser
Changes
ALTER COLUMN
feature inlibsql_alter.test
libsql
forALTER COLUMN
feature