@@ -12601,6 +12601,17 @@ fn parse_alter_server() {
1260112601 "ALTER SERVER public.s OWNER TO app" ,
1260212602 "Expected: VERSION, OPTIONS, OWNER TO, or RENAME TO after ALTER SERVER, found: ." ,
1260312603 ) ,
12604+ ( "ALTER SERVER" , "Expected: identifier, found: EOF" ) ,
12605+ ( "ALTER SERVER s RENAME TO" , "Expected: identifier, found: EOF" ) ,
12606+ (
12607+ "ALTER SERVER s OWNER TO" ,
12608+ "Expected: CURRENT_USER, CURRENT_ROLE, SESSION_USER or identifier after OWNER TO. sql parser error: Expected: identifier, found: EOF" ,
12609+ ) ,
12610+ ( "ALTER SERVER s VERSION" , "Expected: a value, found: EOF" ) ,
12611+ (
12612+ "ALTER SERVER s OPTIONS (ADD host)" ,
12613+ "Expected: identifier, found: )" ,
12614+ ) ,
1260412615 ] {
1260512616 assert_eq ! (
1260612617 pg_and_generic( )
@@ -12612,3 +12623,34 @@ fn parse_alter_server() {
1261212623 ) ;
1261312624 }
1261412625}
12626+
12627+ #[ test]
12628+ fn display_alter_server_propagates_formatter_errors ( ) {
12629+ use core:: fmt:: { self , Write } ;
12630+
12631+ struct RejectingWriter ( & ' static str ) ;
12632+
12633+ impl Write for RejectingWriter {
12634+ fn write_str ( & mut self , value : & str ) -> fmt:: Result {
12635+ if value == self . 0 {
12636+ Err ( fmt:: Error )
12637+ } else {
12638+ Ok ( ( ) )
12639+ }
12640+ }
12641+ }
12642+
12643+ let Statement :: AlterServer ( alter) =
12644+ pg_and_generic ( ) . verified_stmt ( "ALTER SERVER s VERSION '1' OPTIONS (ADD host 'db')" )
12645+ else {
12646+ unreachable ! ( )
12647+ } ;
12648+ for rejected in [ "VERSION " , " " , "OPTIONS (" ] {
12649+ let mut writer = RejectingWriter ( rejected) ;
12650+ assert_eq ! (
12651+ write!( writer, "{}" , alter. operation) ,
12652+ Err ( fmt:: Error ) ,
12653+ "{rejected:?}"
12654+ ) ;
12655+ }
12656+ }
0 commit comments