Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pgdog/src/backend/pool/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ impl Cluster {
|| self.router_needed()
|| self.dry_run()
|| self.prepared_statements() == &PreparedStatements::Full
|| self.pub_sub_enabled()
|| self.regex_parser.use_parser(request)
}
}
Expand Down
34 changes: 33 additions & 1 deletion pgdog/src/frontend/regex_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use crate::frontend::ClientRequest;
/// allowed before a statement keyword.
static COMMENT_PREFIX: &str = r"(?i)^\s*(?:(?:--[^\n]*\n|/\*[\s\S]*?\*/)\s*)*";

static CMD_BASE: &[&str] = &["(RE)?SET", "BEGIN", "COMMIT", "ROLLBACK"];
static CMD_BASE: &[&str] = &[
"(RE)?SET", "BEGIN", "COMMIT", "ROLLBACK", "LISTEN", "UNLISTEN", "NOTIFY",
];

static CMD_ADVISORY: &[&str] = &[
r"(?i)\bpg_advisory_lock\b",
Expand Down Expand Up @@ -151,6 +153,36 @@ mod test {
assert!(matches(" ROLLBACK"));
}

#[test]
fn test_listen() {
assert!(matches("LISTEN test_channel"));
assert!(matches("listen test_channel"));
assert!(matches(" LISTEN test_channel"));
assert!(matches("LISTEN \"test-channel\""));
assert!(matches("/* comment */ LISTEN test_channel"));
assert!(matches("-- comment\nLISTEN test_channel"));
}

#[test]
fn test_unlisten() {
assert!(matches("UNLISTEN test_channel"));
assert!(matches("unlisten test_channel"));
assert!(matches(" UNLISTEN test_channel"));
assert!(matches("UNLISTEN *"));
assert!(matches("/* comment */ UNLISTEN test_channel"));
assert!(matches("-- comment\nUNLISTEN *"));
}

#[test]
fn test_notify() {
assert!(matches("NOTIFY test_channel"));
assert!(matches("notify test_channel"));
assert!(matches(" NOTIFY test_channel"));
assert!(matches("NOTIFY test_channel, 'payload'"));
assert!(matches("/* comment */ NOTIFY test_channel"));
assert!(matches("-- comment\nNOTIFY test_channel, 'payload'"));
}

#[test]
fn test_advisory_lock() {
let l = QueryParserLevel::SessionControlAndLocks;
Expand Down
Loading