Parse MOVE [FORWARD | BACKWARD] n IN cursor_name.
(parts: &[&str])
| 150 | |
| 151 | /// Parse MOVE [FORWARD | BACKWARD] n IN cursor_name. |
| 152 | fn parse_move(parts: &[&str]) -> PgWireResult<(bool, usize, String)> { |
| 153 | // MOVE FORWARD n IN cursor_name |
| 154 | if parts.len() >= 5 && parts[1].eq_ignore_ascii_case("FORWARD") { |
| 155 | let count = parts[2].parse::<usize>().unwrap_or(1); |
| 156 | let cursor_name = parts[4].to_lowercase(); |
| 157 | return Ok((true, count, cursor_name)); |
| 158 | } |
| 159 | |
| 160 | // MOVE BACKWARD n IN cursor_name |
| 161 | if parts.len() >= 5 && parts[1].eq_ignore_ascii_case("BACKWARD") { |
| 162 | let count = parts[2].parse::<usize>().unwrap_or(1); |
| 163 | let cursor_name = parts[4].to_lowercase(); |
| 164 | return Ok((false, count, cursor_name)); |
| 165 | } |
| 166 | |
| 167 | // MOVE n IN cursor_name (forward by default) |
| 168 | if parts.len() >= 4 && parts[2].eq_ignore_ascii_case("IN") { |
| 169 | let count = parts[1].parse::<usize>().unwrap_or(1); |
| 170 | let cursor_name = parts[3].to_lowercase(); |
| 171 | return Ok((true, count, cursor_name)); |
| 172 | } |
| 173 | |
| 174 | Err(PgWireError::UserError(Box::new(ErrorInfo::new( |
| 175 | "ERROR".to_owned(), |
| 176 | "42601".to_owned(), |
| 177 | "syntax: MOVE [FORWARD|BACKWARD] <count> IN <cursor_name>".to_owned(), |
| 178 | )))) |
| 179 | } |
| 180 | |
| 181 | fn cursor_error(msg: &str) -> PgWireError { |
| 182 | PgWireError::UserError(Box::new(ErrorInfo::new( |