Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diesel-cli stack overflow when running migration with copy stdin statement. #3674

Open
3 tasks done
df51d opened this issue Jun 30, 2023 · 0 comments
Open
3 tasks done

Comments

@df51d
Copy link

df51d commented Jun 30, 2023

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 run

Steps 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 run

Related 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 "\"

postgres copy docs

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

  • 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
@df51d df51d added the bug label Jun 30, 2023
@weiznich weiznich added the cli label Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants