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

Prepare a 2.2.7 patch release #4459

Merged
merged 16 commits into from
Jan 31, 2025
Merged

Conversation

weiznich
Copy link
Member

@weiznich weiznich commented Jan 28, 2025

Make NoOrderClause and OrderClause for third-party-backends
…entation

Generate `InstrumentationEvent::BeginTransaction` for custom transaction SQL
This commit updates the supported libsqlite3-sys version to 0.31.0
@weiznich weiznich requested a review from a team January 28, 2025 12:33
DebugBinds/Query: Reduce monomorphization overhead
Bump rustversion to 1.83 and fix new clippy lints
@weiznich weiznich force-pushed the prepare/2.2.7 branch 4 times, most recently from d74979f to 572e339 Compare January 28, 2025 16:13
Copy link
Member

@Ten0 Ten0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thanks! 😊

I would tend to also add #4281 as that's a minor upgrade that has zero chance to break existing stuff.

@weiznich weiznich force-pushed the prepare/2.2.7 branch 2 times, most recently from 4d0df75 to b0ba064 Compare January 31, 2025 09:04
@weiznich
Copy link
Member Author

I did some rather extensive CI debugging here as we had segfaults while running our sqlite tests. It turned out that this is caused by a bug in the libsqlite version shipped by ubuntu 24.04. See this bug report for some details: https://bugs.launchpad.net/ubuntu/+source/sqlite3/+bug/2087772

Otherwise for anyone seeking to reproduce this:

The following rust code currently segfaults in libsqlite3 on ubuntu 24.04 with the libsqlite3-dev (sqlite 3.45.1) package installed.

use libsqlite3_sys as ffi;
use std::ffi::{CString, CStr};

const SQL: &str = "SELECT `users`.`id`, `users`.`name`, `users`.`hair_color`, `posts`.`id`, `posts`.`user_id`, `posts`.`title`, `posts`.`body`, `comments`.`id`, `comments`.`post_id`, `comments`.`text`, `likes`.`comment_id`, `likes`.`user_id`, `followings`.`user_id`, `followings`.`post_id`, `followings`.`email_notifications` FROM (`users` INNER JOIN ((`posts` LEFT OUTER JOIN (`comments` LEFT OUTER JOIN `likes` ON (`likes`.`comment_id` = `comments`.`id`)) ON (`comments`.`post_id` = `posts`.`id`)) LEFT OUTER JOIN `followings` ON (`followings`.`post_id` = `posts`.`id`)) ON (`posts`.`user_id` = `users`.`id`)) ORDER BY `users`.`id`, `posts`.`id`, `comments`.`id`";

fn main() {
    let url = CString::new("/tmp/test.db").unwrap();
    let mut conn_pointer = std::ptr::null_mut();
    let mut stmt = std::ptr::null_mut();
    let flags = ffi::SQLITE_OPEN_READWRITE;

    let sql = CString::new(SQL).unwrap();

    unsafe {
        let conn_status = ffi::sqlite3_open_v2(url.as_ptr(), &mut conn_pointer, flags, std::ptr::null());
        if conn_status != ffi::SQLITE_OK {
            panic!("Something went wrong");
        }

        let prep_result = ffi::sqlite3_prepare_v3(conn_pointer, sql.as_ptr(), SQL.len() as i32, 0, &mut stmt, std::ptr::null_mut());
        if prep_result != ffi::SQLITE_OK {
            let c_str = ffi::sqlite3_errmsg(conn_pointer);
            let c_str = CStr::from_ptr(c_str);
            println!("{}", c_str.to_string_lossy());

            panic!("Could not prepare");
        }

    }

    println!("Everything is fine");
}

It doesn't segfault if you manually build sqlite 3.45.1 and use that 😱

@weiznich weiznich merged commit 84340f7 into diesel-rs:2.2.x Jan 31, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants