Transactions support

Đang mở
#79 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
postgresql, rust
Lĩnh vực
database

Hướng nghiên cứu

Read the SimpleQueryHandler and ExtendedQueryHandler implementations and the example using tokio_postgres::connect in the issue. Trace how a BEGIN and the subsequent query are dispatched and how connection state is shared. Done means a transaction can execute the shown query and commit successfully; the issue gives no file names or tests to start from.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

I noticed transactions are not supported, at least when testing with tokio-postgres.

My pgwire handler receives a BEGIN statement and it's handled by the SimpleQueryHandler implementation. Then the single statement I have in the transaction is handled by the ExtendedQueryHandler. When I finally get to tx.commit().await, there's no transaction to commit because all of these things are disconnected.

Is there a way to handle transactions? I figure it might be possible by keeping a record when we get a BEGIN and somehow associate it with the incoming connection and sharing that information between the simple and extended query handler. It seemed like a lot of work though.

Example test code:

        let (mut pg, connection) = tokio_postgres::connect(
            format!("host={} port={}", pg_addr.ip(), pg_addr.port()).as_str(),
            NoTls,
        )
        .await?;

        tokio::spawn(async move {
            if let Err(e) = connection.await {
                eprintln!("connection error: {e}");
            }
        });

        let rows = {
            let tx = pg.transaction().await?;
            let rows = tx.query("SELECT * FROM sqlite_master;", &[]).await?;
            tx.commit().await?;
            rows
        };
Ngôn ngữ chính
Rust
Star
805
Fork
88
Merge trung bình
1 ngày 7 giờ
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sunng87/pgwire

Tất cả issue của sunng87/pgwire

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.