1
2
3
4
5
6
7
8
9
10
11
12
13
use std::cell::Cell;

// Will be set/ unset in the fetch operation to communicate overwriting the number of rows to scan.
thread_local! {pub static FETCH_ROWS: Cell<Option<usize>> = const { Cell::new(None) }}

pub fn _set_n_rows_for_scan(n_rows: Option<usize>) -> Option<usize> {
    let fetch_rows = FETCH_ROWS.with(|fetch_rows| fetch_rows.get());
    fetch_rows.or(n_rows)
}

pub fn _is_fetch_query() -> bool {
    FETCH_ROWS.with(|fetch_rows| fetch_rows.get().is_some())
}