tursodatabase / tursodatabase/libsql

Stack overflow exception then trying to get sqlite schema on an empty turso database on Windows (only)

Open
#1,349 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17.2k
Forks
531
Avg merge
1h 12m
Merged PRs (30d)
1

Description

Stack overflow exception then trying to get sqlite schema on an empty turso database on Windows (only). Works on linux (Fedora v40), unknown for MacOs.

use libsql::{Builder, Connection};


#[tokio::main]
async fn main() {
    let builder = Builder::new_remote("libsql://<subdomain>.turso.io".into(), "<token>".into()).build().await.unwrap();
    let connection = builder.connect().unwrap();
    get_current_db_schema("Test", &connection).await;
}

pub async fn get_current_db_schema(name: &str, connection: &Connection) -> Option<Vec<String>> {  
    let query = format!("SELECT sql FROM sqlite_schema WHERE name = {}", name);

    let result_query = connection
         .query(&query, ())
         .await;

    if let Ok(mut result_row) = result_query {
         let result_rows = result_row
              .next()
              .await;

         if let Ok(_result_row) = result_rows {
              return None;
         }
         else {
              return None;
         }

    }
    else {
         return None;
    }
}

Repository with the same code: https://github.com/milen-denev/libsql_stackoverflow/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal repository linked in the report and reproduce the empty Turso database query on Windows, comparing it with Fedora 40 where it works. Trace the connection.query call against sqlite_schema and determine why the Windows path overflows; done means the query no longer causes a stack overflow on an empty database.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sqlite
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.