Fixes copy from#8
Merged
Merged
Conversation
Add support for COPY table FROM file with PostgreSQL default text format (tab-delimited). This is the prerequisite for running PG regression tests that load data via COPY. - Add AST types: Stmt::Copy, CopyDirection, CopyTarget, CopyFormat - Add PG translator: translate_copy() and try_extract_copy_from() - Add text format parser in core/copy.rs with backslash escape handling - Add COPY FROM handler in pg_dispatch.rs using prepare/bind/step - Supports column subsets, HEADER option, custom delimiter, custom NULL - Wraps inserts in a transaction for atomicity - Wire protocol returns COPY N matching PostgreSQL behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The PG translator was baking type parameters into the type name string (e.g. varchar(4)) instead of setting the AST Type.size field. This caused Turso custom type validation to reject parametric types like varchar(4) and numeric(10,2) as unknown datatype on STRICT tables. Fix both translate_create_table_column (CREATE TABLE) and translate_column_def (ALTER TABLE) to populate Type.size from the new PgTypeMapping.type_params field. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
translate_binary_expr assumed all AExprKind::AexprOp expressions were binary, failing with Missing left expression on unary operators like +42. PostgreSQL parses these as A_Expr with only rexpr set. Detect the unary case (no lexpr) and map to the appropriate ast::UnaryOperator variant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SELECT i.* FROM table i was failing with 'no such column: i' because
the ColumnRef [String('i'), AStar] was not recognized as a table-star
pattern. The translator only checked if the first field was AStar
(for bare *) but not the last field (for table.*).
Now correctly emits ResultColumn::TableStar for qualified star refs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add handling for standalone VALUES statements (VALUES (1,'a'), (2,'b')) by detecting SelectStmt with values_lists and no target_list, producing OneSelect::Values AST nodes. Also add RangeSubselect to the comma-join FROM item handler, which was missing (only the first FROM item handled subselects). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In PG, float8(x) is equivalent to CAST(x AS float8). Map these function calls to Expr::Cast in the translator instead of passing them as unknown functions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These functions are used in PG regression tests (int4, int8, boolean). - gcd/lcm: greatest common divisor / least common multiple - repeat: repeat a string N times - to_char: basic numeric formatting with PG format patterns - pg_input_is_valid: validate text input for a given type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gcd(INT_MIN, 0) would panic on .abs(). Use wrapping_abs and return an error string for overflow cases, matching PG behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DELETE FROM t AS dt WHERE dt.a > 75 failed because the alias was not set on the QualifiedName. This also benefits UPDATE aliases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PG internal functions for boolean equality/inequality, used in the boolean regression test suite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds pg_input_error_info(input, type) as a virtual table that returns error details when input text is invalid for a given type. Returns one row with (message, detail, hint, sql_error_code) — all NULL if valid, populated with PG-compatible error messages if invalid. Supports bool, int2/int4/int8, float4/float8, and text types. This fixes the last remaining error in the PG boolean regression test and resolves pg_input_error_info errors in int4 and int8 tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The REPL tokenizer now recognizes PostgreSQL dollar-quoted strings ($$...$$, $body$...$body$, etc.) so that semicolons inside function bodies don't prematurely terminate the statement. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
many fixes trying to run the postgres regression test suite.
Most notable are COPY FROM - which is used almost everywhere, and a virtual table where we can check for errors.