@@ -11595,7 +11595,7 @@ fn test_show_dbs_schemas_tables_views() {
11595
11595
11596
11596
#[ test]
11597
11597
fn parse_listen_channel ( ) {
11598
- let dialects = all_dialects_where ( |d| d. supports_listen ( ) ) ;
11598
+ let dialects = all_dialects_where ( |d| d. supports_listen_notify ( ) ) ;
11599
11599
11600
11600
match dialects. verified_stmt ( "LISTEN test1" ) {
11601
11601
Statement :: LISTEN { channel } => {
@@ -11609,17 +11609,48 @@ fn parse_listen_channel() {
11609
11609
ParserError :: ParserError ( "Expected: identifier, found: *" . to_string( ) )
11610
11610
) ;
11611
11611
11612
- let dialects = all_dialects_where ( |d| !d. supports_listen ( ) ) ;
11612
+ let dialects = all_dialects_where ( |d| !d. supports_listen_notify ( ) ) ;
11613
11613
11614
11614
assert_eq ! (
11615
11615
dialects. parse_sql_statements( "LISTEN test1" ) . unwrap_err( ) ,
11616
11616
ParserError :: ParserError ( "Expected: an SQL statement, found: LISTEN" . to_string( ) )
11617
11617
) ;
11618
11618
}
11619
11619
11620
+ #[ test]
11621
+ fn parse_unlisten_channel ( ) {
11622
+ let dialects = all_dialects_where ( |d| d. supports_listen_notify ( ) ) ;
11623
+
11624
+ match dialects. verified_stmt ( "UNLISTEN test1" ) {
11625
+ Statement :: UNLISTEN { channel } => {
11626
+ assert_eq ! ( Ident :: new( "test1" ) , channel) ;
11627
+ }
11628
+ _ => unreachable ! ( ) ,
11629
+ } ;
11630
+
11631
+ match dialects. verified_stmt ( "UNLISTEN *" ) {
11632
+ Statement :: UNLISTEN { channel } => {
11633
+ assert_eq ! ( Ident :: new( "*" ) , channel) ;
11634
+ }
11635
+ _ => unreachable ! ( ) ,
11636
+ } ;
11637
+
11638
+ assert_eq ! (
11639
+ dialects. parse_sql_statements( "UNLISTEN +" ) . unwrap_err( ) ,
11640
+ ParserError :: ParserError ( "Expected: wildcard or identifier, found: +" . to_string( ) )
11641
+ ) ;
11642
+
11643
+ let dialects = all_dialects_where ( |d| !d. supports_listen_notify ( ) ) ;
11644
+
11645
+ assert_eq ! (
11646
+ dialects. parse_sql_statements( "UNLISTEN test1" ) . unwrap_err( ) ,
11647
+ ParserError :: ParserError ( "Expected: an SQL statement, found: UNLISTEN" . to_string( ) )
11648
+ ) ;
11649
+ }
11650
+
11620
11651
#[ test]
11621
11652
fn parse_notify_channel ( ) {
11622
- let dialects = all_dialects_where ( |d| d. supports_notify ( ) ) ;
11653
+ let dialects = all_dialects_where ( |d| d. supports_listen_notify ( ) ) ;
11623
11654
11624
11655
match dialects. verified_stmt ( "NOTIFY test1" ) {
11625
11656
Statement :: NOTIFY { channel, payload } => {
@@ -11655,7 +11686,7 @@ fn parse_notify_channel() {
11655
11686
"NOTIFY test1" ,
11656
11687
"NOTIFY test1, 'this is a test notification'" ,
11657
11688
] ;
11658
- let dialects = all_dialects_where ( |d| !d. supports_notify ( ) ) ;
11689
+ let dialects = all_dialects_where ( |d| !d. supports_listen_notify ( ) ) ;
11659
11690
11660
11691
for & sql in & sql_statements {
11661
11692
assert_eq ! (
@@ -11864,6 +11895,44 @@ fn parse_load_data() {
11864
11895
) ;
11865
11896
}
11866
11897
11898
+ #[ test]
11899
+ fn test_load_extension ( ) {
11900
+ let dialects = all_dialects_where ( |d| d. supports_load_extension ( ) ) ;
11901
+ let not_supports_load_extension_dialects = all_dialects_where ( |d| !d. supports_load_extension ( ) ) ;
11902
+ let sql = "LOAD my_extension" ;
11903
+
11904
+ match dialects. verified_stmt ( sql) {
11905
+ Statement :: Load { extension_name } => {
11906
+ assert_eq ! ( Ident :: new( "my_extension" ) , extension_name) ;
11907
+ }
11908
+ _ => unreachable ! ( ) ,
11909
+ } ;
11910
+
11911
+ assert_eq ! (
11912
+ not_supports_load_extension_dialects
11913
+ . parse_sql_statements( sql)
11914
+ . unwrap_err( ) ,
11915
+ ParserError :: ParserError (
11916
+ "Expected: `DATA` or an extension name after `LOAD`, found: my_extension" . to_string( )
11917
+ )
11918
+ ) ;
11919
+
11920
+ let sql = "LOAD 'filename'" ;
11921
+
11922
+ match dialects. verified_stmt ( sql) {
11923
+ Statement :: Load { extension_name } => {
11924
+ assert_eq ! (
11925
+ Ident {
11926
+ value: "filename" . to_string( ) ,
11927
+ quote_style: Some ( '\'' )
11928
+ } ,
11929
+ extension_name
11930
+ ) ;
11931
+ }
11932
+ _ => unreachable ! ( ) ,
11933
+ } ;
11934
+ }
11935
+
11867
11936
#[ test]
11868
11937
fn test_select_top ( ) {
11869
11938
let dialects = all_dialects_where ( |d| d. supports_top_before_distinct ( ) ) ;
0 commit comments