Skip to content

Commit f8c2162

Browse files
committed
remove stacker
1 parent b447244 commit f8c2162

5 files changed

Lines changed: 16 additions & 160 deletions

File tree

Cargo.lock

Lines changed: 12 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ itertools = "0.10.3"
2323
prost = { version = "0.13.5", features = ["no-recursion-limit"] }
2424
serde = { version = "1.0.139", features = ["derive"] }
2525
serde_json = "1.0.82"
26-
stacker = "0.1"
2726
thiserror = "1.0.31"
2827

2928
[build-dependencies]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ pub use node_mut::*;
6363
pub use node_ref::*;
6464
pub use parse_result::*;
6565
pub use query::*;
66-
pub use raw_deparse::{deparse_raw, deparse_raw_with_stack};
66+
pub use raw_deparse::deparse_raw;
6767
pub use raw_fingerprint::fingerprint_raw;
68-
pub use raw_parse::{parse_raw, parse_raw_with_stack};
68+
pub use raw_parse::parse_raw;
6969
pub use raw_scan::scan_raw;
7070
pub use summary::*;
7171
pub use summary_result::*;

src/raw_deparse.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,6 @@ pub fn deparse_raw(protobuf: &protobuf::ParseResult) -> Result<String> {
5252
}
5353
}
5454

55-
/// Deparses a protobuf ParseResult with a custom stack size.
56-
///
57-
/// This function is useful for deparsing deeply nested queries that might overflow the stack.
58-
/// It uses the `stacker` crate to grow the stack if needed.
59-
///
60-
/// # Arguments
61-
///
62-
/// * `protobuf` - The protobuf ParseResult to deparse
63-
/// * `stack_size` - The stack size in bytes to ensure is available for deparsing
64-
///
65-
/// # Example
66-
///
67-
/// ```rust
68-
/// let result = pg_query::parse("SELECT * FROM users").unwrap();
69-
/// let sql = pg_query::deparse_raw_with_stack(&result.protobuf, 8 * 1024 * 1024).unwrap();
70-
/// assert_eq!(sql, "SELECT * FROM users");
71-
/// ```
72-
pub fn deparse_raw_with_stack(protobuf: &protobuf::ParseResult, stack_size: usize) -> Result<String> {
73-
stacker::maybe_grow(32 * 1024, stack_size, || deparse_raw(protobuf))
74-
}
75-
7655
/// Allocates a C node of the given type.
7756
unsafe fn alloc_node<T>(tag: bindings_raw::NodeTag) -> *mut T {
7857
bindings_raw::pg_query_alloc_node(std::mem::size_of::<T>(), tag as i32) as *mut T
@@ -148,19 +127,13 @@ fn write_node_boxed(node: &Option<Box<protobuf::Node>>) -> *mut bindings_raw::No
148127
/// Writes a protobuf Node to a C Node.
149128
fn write_node(node: &protobuf::Node) -> *mut bindings_raw::Node {
150129
match &node.node {
151-
Some(n) => write_node_inner(n),
130+
Some(n) => unsafe { write_node_inner(n) },
152131
None => std::ptr::null_mut(),
153132
}
154133
}
155134

156135
/// Writes a protobuf node::Node enum to a C Node.
157-
fn write_node_inner(node: &protobuf::node::Node) -> *mut bindings_raw::Node {
158-
// Use stacker to grow the stack for deeply nested queries
159-
stacker::maybe_grow(32 * 1024, 1024 * 1024, || unsafe { write_node_inner_impl(node) })
160-
}
161-
162-
/// Inner implementation of write_node_inner.
163-
unsafe fn write_node_inner_impl(node: &protobuf::node::Node) -> *mut bindings_raw::Node {
136+
unsafe fn write_node_inner(node: &protobuf::node::Node) -> *mut bindings_raw::Node {
164137
match node {
165138
protobuf::node::Node::SelectStmt(stmt) => write_select_stmt(stmt) as *mut bindings_raw::Node,
166139
protobuf::node::Node::InsertStmt(stmt) => write_insert_stmt(stmt) as *mut bindings_raw::Node,

src/raw_parse.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ pub fn parse_raw(statement: &str) -> Result<ParseResult> {
4545
parse_result
4646
}
4747

48-
/// Parses a SQL statement with a custom stack size.
49-
///
50-
/// This function is useful for parsing deeply nested queries that might overflow the stack.
51-
/// It uses the `stacker` crate to grow the stack if needed.
52-
///
53-
/// # Arguments
54-
///
55-
/// * `statement` - The SQL statement to parse
56-
/// * `stack_size` - The stack size in bytes to ensure is available for parsing
57-
///
58-
/// # Example
59-
///
60-
/// ```rust
61-
/// let result = pg_query::parse_raw_with_stack("SELECT * FROM users", 8 * 1024 * 1024).unwrap();
62-
/// assert_eq!(result.tables(), vec!["users"]);
63-
/// ```
64-
pub fn parse_raw_with_stack(statement: &str, stack_size: usize) -> Result<ParseResult> {
65-
stacker::maybe_grow(32 * 1024, stack_size, || parse_raw(statement))
66-
}
67-
6848
/// Converts a PostgreSQL List of RawStmt nodes to protobuf RawStmt vector.
6949
unsafe fn convert_list_to_raw_stmts(list: *mut bindings_raw::List) -> Vec<protobuf::RawStmt> {
7050
if list.is_null() {

0 commit comments

Comments
 (0)