diesel-cli stack overflow when running migration with copy stdin statement.
Author: df51dCreated Jun 30, 2023Updated Sep 24, 2026
Labelsbugcli
Setup
Versions
- Rust: cargo 1.70.0 (ec8a8a0ca 2023-04-25) rustc 1.70.0 (90c541806 2023-05-31)
- Diesel: diesel 2.1.0
- Database: postgresql 15.3-1.pgdg120+1
- Operating System ArcoLinux kernel 6.3.8-arch1-1
Feature Flags
cargo install diesel_cli --no-
default-features --features "postgres sqlite"Problem Description
While attempting to create a minimal reproducible state for issue #3673, I encountered an error related to a stack overflow when executing diesel migration run with COPY public."name" (id) FROM stdin;. In order to reproduce the issue, I copied the SQL code from my pg_dump and included it in the diesel migration script.
What are you trying to accomplish?
diesel migration run
What is the actual output?
Running migration user
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
[1] 36976 IOT instruction (core dumped) diesel migration runSteps to reproduce
docker pull postgres
docker run -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
echo 'DATABASE_URL="postgresql://postgres:postgres@localhost:5432/db"' > .env
diesel setup
mkdir migrations/user
echo "CREATE TABLE public.\"user\" (
id integer NOT NULL
);
COPY public.\"user\" (id) FROM stdin;" > migrations/user/up.sql
diesel migration runRelated bug with COPY
When I include end of a COPY statement \. like in my pg_dump it gave me instead this error:
Running migration user
Failed to run user with: syntax error at or near "\"End of data can be represented by a single line containing just backslash-period (\.).
An end-of-data marker is not necessary when reading from a file, since the end of file
serves perfectly well; it is needed only when copying data to or from client
applications using pre-3.0 client protocol.Checklist
- I have already looked over the issue tracker and the discussion forum for similar possible closed issues.
- This issue can be reproduced on Rust's stable channel. (Your issue will be closed if this is not the case)
- This issue can be reproduced without requiring a third party crate
Source: diesel-rs/diesel