diesel-rs / diesel

A safe, extensible ORM and Query Builder for Rust
https://diesel.rs
Apache License 2.0
12.31k stars 1.02k forks source link

Segmantation fault happend when run "diesel setup" command #3307

Closed ShintaroOba closed 1 year ago

ShintaroOba commented 1 year ago

Setup

Versions

Feature Flags

Problem Description

I installed diesel_cli for cargo install diesel_cli --no-default-features --features postgrescommand.

I run diesel setupcommand, got a message below.

$ diesel setup
Segmentation fault

After the running this command, the migrationsfolder (include up.sql and down.sql)is generated.

Then, I run command below after the diesel migration generatecommand, the schema.rs is generated but it is empty. (TBL is created, but schema.rs is empty)

$ diesel migration run 
Segmentation fault

What makes "segmantation fault" and generate empty "schema.rs" happens?

detail about my environment

GRANT CONNECT ON DATABASE diesel TO diesel; GRANT USAGE ON SCHEMA diesel TO diesel; GRANT ALL ON ALL TABLES IN SCHEMA diesel TO diesel;


- up.sql
````sql
create table diesel.users (
  id bigint not null 
  , user_name character varying(50) not null
  , age smallint not null
  , constraint user_id_primary_key primary key (id)
);

create table diesel.cash_flow(
    id bigint not null 
    , user_id bigint not null
    , item character varying(50) not null
    , cash_flow_type character varying(20) not null
    , amount bigint not null
    , constraint cash_id_primary_key primary key (id)
);

alter table diesel.cash_flow
  add constraint user_foreign_key foreign key (user_id) references diesel.users(id)
  on update cascade;


<!--
Please include as much of your codebase as needed to reproduce the error.  If the relevant files are large, please consider linking to a public repository or a [Gist](https://gist.github.com/). This includes normally the following parts:

* The exact code where your hit the problem
* Relevant parts your schema, so any `table!` macro calls required for the
* Any other type definitions involved in the code, which produces your problem
-->

## Checklist

- [x] I have already looked over the [issue tracker](https://github.com/diesel-rs/diesel/issues)  and the [disussion forum](https://github.com/diesel-rs/diesel/discussions)  for similar possible closed issues.
<!--
If you are unsure if your issue is a duplicate of an existing issue please link the issue in question here
--> 
- [x] This issue can be reproduced on Rust's stable channel. (Your issue will be
  closed if this is not the case)
- [x] This issue can be reproduced without requiring a third party crate

<!--
Thank you for your submission!  You're helping make Diesel more robust 🎉

We'll try to respond as quickly as possible.
-->
weiznich commented 1 year ago

Can you provide details about:

ShintaroOba commented 1 year ago

@weiznich

your libpq version

I use windows, so I installed libpq from Postgres server, not from apt-get. (I installed here) Postgres version is 14.5. I'm not sure the how I can check libpq specific version.

a backtrace for the segfault

I'm afraid that I wanna show you a backtrace, but I coudln't run rust-gdbcommand because of another prloblem. I'm gonna solve this first.

Maybe segfault happens when I use gitbash for terminial. When I use Powershell, it doesn't happen. So, it should be ok for now, but I run diesel migration runcommand in powershell, the schema.rs is empty yet. Is there anything wrong my sql and diesel.toml and things like that?

weiznich commented 1 year ago

There is a known issue with the libpq version provided by enterprise db. See https://github.com/diesel-rs/diesel/discussions/2947 for details. This is likely the same underlying issue. We as diesel team cannot do anything to fix this, please report this upstream. You can verify that by using a different libpq version

So, it should be ok for now, but I run diesel migration run command in powershell, the schema.rs is empty yet. Is there anything wrong my sql and diesel.toml and things like that?

Our issue tracker is not meant for support questions. Please open a separate discussion thread for this including all necessary details. For questions like yours this needs to include a database dump of before you tried your migration, all relevant migration files and a reproductions script. Otherwise there are just too many missing information to reproduce anything.

ShintaroOba commented 1 year ago

Thank you for your comment. I'll check it out.

weiznich commented 1 year ago

Closed as this seems to be an issue with this specific libpq setup.