vibesql_ast/ddl/
cursor.rs

1//! Cursor DDL operations
2//!
3//! This module contains AST nodes for cursor-related DDL operations (SQL:1999 Feature E121):
4//! - DECLARE CURSOR
5//! - OPEN CURSOR
6//! - FETCH
7//! - CLOSE CURSOR
8
9/// DECLARE CURSOR statement (SQL:1999 Feature E121)
10#[derive(Debug, Clone, PartialEq)]
11pub struct DeclareCursorStmt {
12    pub cursor_name: String,
13    pub insensitive: bool,
14    pub scroll: bool,
15    pub hold: Option<bool>, /* Some(true) = WITH HOLD, Some(false) = WITHOUT HOLD, None = not
16                             * specified */
17    pub query: Box<crate::SelectStmt>,
18    pub updatability: CursorUpdatability,
19}
20
21/// Cursor updatability specification
22#[derive(Debug, Clone, PartialEq)]
23pub enum CursorUpdatability {
24    ReadOnly,
25    Update { columns: Option<Vec<String>> }, /* Some(cols) = UPDATE OF cols, None = UPDATE (all
26                                              * columns) */
27    Unspecified,
28}
29
30/// OPEN CURSOR statement (SQL:1999 Feature E121)
31#[derive(Debug, Clone, PartialEq)]
32pub struct OpenCursorStmt {
33    pub cursor_name: String,
34}
35
36/// FETCH statement (SQL:1999 Feature E121)
37#[derive(Debug, Clone, PartialEq)]
38pub struct FetchStmt {
39    pub cursor_name: String,
40    pub orientation: FetchOrientation,
41    pub into_variables: Option<Vec<String>>, // INTO variable_list
42}
43
44/// Fetch orientation specification
45#[derive(Debug, Clone, PartialEq)]
46pub enum FetchOrientation {
47    Next,
48    Prior,
49    First,
50    Last,
51    Absolute(i64), // ABSOLUTE n
52    Relative(i64), // RELATIVE n
53}
54
55/// CLOSE CURSOR statement (SQL:1999 Feature E121)
56#[derive(Debug, Clone, PartialEq)]
57pub struct CloseCursorStmt {
58    pub cursor_name: String,
59}