@@ -11399,3 +11399,79 @@ fn test_show_dbs_schemas_tables_views() {
11399
11399
verified_stmt ( "SHOW MATERIALIZED VIEWS FROM db1" ) ;
11400
11400
verified_stmt ( "SHOW MATERIALIZED VIEWS FROM db1 'abc'" ) ;
11401
11401
}
11402
+
11403
+ #[ test]
11404
+ fn parse_listen_channel ( ) {
11405
+ let dialects = all_dialects_where ( |d| d. supports_listen ( ) ) ;
11406
+
11407
+ match dialects. verified_stmt ( "LISTEN test1" ) {
11408
+ Statement :: LISTEN { channel } => {
11409
+ assert_eq ! ( Ident :: new( "test1" ) , channel) ;
11410
+ }
11411
+ _ => unreachable ! ( ) ,
11412
+ } ;
11413
+
11414
+ assert_eq ! (
11415
+ dialects. parse_sql_statements( "LISTEN *" ) . unwrap_err( ) ,
11416
+ ParserError :: ParserError ( "Expected: identifier, found: *" . to_string( ) )
11417
+ ) ;
11418
+
11419
+ let dialects = all_dialects_where ( |d| !d. supports_listen ( ) ) ;
11420
+
11421
+ assert_eq ! (
11422
+ dialects. parse_sql_statements( "LISTEN test1" ) . unwrap_err( ) ,
11423
+ ParserError :: ParserError ( "Expected: an SQL statement, found: LISTEN" . to_string( ) )
11424
+ ) ;
11425
+ }
11426
+
11427
+ #[ test]
11428
+ fn parse_notify_channel ( ) {
11429
+ let dialects = all_dialects_where ( |d| d. supports_notify ( ) ) ;
11430
+
11431
+ match dialects. verified_stmt ( "NOTIFY test1" ) {
11432
+ Statement :: NOTIFY { channel, payload } => {
11433
+ assert_eq ! ( Ident :: new( "test1" ) , channel) ;
11434
+ assert_eq ! ( payload, None ) ;
11435
+ }
11436
+ _ => unreachable ! ( ) ,
11437
+ } ;
11438
+
11439
+ match dialects. verified_stmt ( "NOTIFY test1, 'this is a test notification'" ) {
11440
+ Statement :: NOTIFY {
11441
+ channel,
11442
+ payload : Some ( payload) ,
11443
+ } => {
11444
+ assert_eq ! ( Ident :: new( "test1" ) , channel) ;
11445
+ assert_eq ! ( "this is a test notification" , payload) ;
11446
+ }
11447
+ _ => unreachable ! ( ) ,
11448
+ } ;
11449
+
11450
+ assert_eq ! (
11451
+ dialects. parse_sql_statements( "NOTIFY *" ) . unwrap_err( ) ,
11452
+ ParserError :: ParserError ( "Expected: identifier, found: *" . to_string( ) )
11453
+ ) ;
11454
+ assert_eq ! (
11455
+ dialects
11456
+ . parse_sql_statements( "NOTIFY test1, *" )
11457
+ . unwrap_err( ) ,
11458
+ ParserError :: ParserError ( "Expected: literal string, found: *" . to_string( ) )
11459
+ ) ;
11460
+
11461
+ let sql_statements = [
11462
+ "NOTIFY test1" ,
11463
+ "NOTIFY test1, 'this is a test notification'" ,
11464
+ ] ;
11465
+ let dialects = all_dialects_where ( |d| !d. supports_notify ( ) ) ;
11466
+
11467
+ for & sql in & sql_statements {
11468
+ assert_eq ! (
11469
+ dialects. parse_sql_statements( sql) . unwrap_err( ) ,
11470
+ ParserError :: ParserError ( "Expected: an SQL statement, found: NOTIFY" . to_string( ) )
11471
+ ) ;
11472
+ assert_eq ! (
11473
+ dialects. parse_sql_statements( sql) . unwrap_err( ) ,
11474
+ ParserError :: ParserError ( "Expected: an SQL statement, found: NOTIFY" . to_string( ) )
11475
+ ) ;
11476
+ }
11477
+ }
0 commit comments