@@ -5313,10 +5313,11 @@ match_previous_words(int pattern_id,
53135313 COMPLETE_WITH_SCHEMA_QUERY (Query_for_list_of_vacuumables );
53145314
53155315/*
5316- * WAIT FOR LSN '<lsn>' [ WITH ( option [, ...] ) ]
5316+ * WAIT FOR LSN '<lsn>' [ MODE { REPLAY | FLUSH | WRITE } ] [ WITH ( option [, ...] ) ]
53175317 * where option can be:
53185318 * TIMEOUT '<timeout>'
53195319 * NO_THROW
5320+ * MODE defaults to REPLAY if not specified.
53205321 */
53215322 else if (Matches ("WAIT" ))
53225323 COMPLETE_WITH ("FOR" );
@@ -5325,25 +5326,41 @@ match_previous_words(int pattern_id,
53255326 else if (Matches ("WAIT" , "FOR" , "LSN" ))
53265327 /* No completion for LSN value - user must provide manually */
53275328 ;
5329+
5330+ /*
5331+ * After LSN value, offer MODE (optional) or WITH, since MODE defaults to
5332+ * REPLAY
5333+ */
53285334 else if (Matches ("WAIT" , "FOR" , "LSN" , MatchAny ))
5335+ COMPLETE_WITH ("MODE" , "WITH" );
5336+ else if (Matches ("WAIT" , "FOR" , "LSN" , MatchAny , "MODE" ))
5337+ COMPLETE_WITH ("REPLAY" , "FLUSH" , "WRITE" );
5338+ else if (Matches ("WAIT" , "FOR" , "LSN" , MatchAny , "MODE" , MatchAny ))
53295339 COMPLETE_WITH ("WITH" );
5340+ /* WITH directly after LSN (using default REPLAY mode) */
53305341 else if (Matches ("WAIT" , "FOR" , "LSN" , MatchAny , "WITH" ))
53315342 COMPLETE_WITH ("(" );
5343+ else if (Matches ("WAIT" , "FOR" , "LSN" , MatchAny , "MODE" , MatchAny , "WITH" ))
5344+ COMPLETE_WITH ("(" );
5345+
5346+ /*
5347+ * Handle parenthesized option list (both with and without explicit MODE).
5348+ * This fires when we're in an unfinished parenthesized option list.
5349+ * get_previous_words treats a completed parenthesized option list as one
5350+ * word, so the above test is correct. timeout takes a string value,
5351+ * no_throw takes no value. We don't offer completions for these values.
5352+ */
53325353 else if (HeadMatches ("WAIT" , "FOR" , "LSN" , MatchAny , "WITH" , "(*" ) &&
53335354 !HeadMatches ("WAIT" , "FOR" , "LSN" , MatchAny , "WITH" , "(*)" ))
53345355 {
5335- /*
5336- * This fires if we're in an unfinished parenthesized option list.
5337- * get_previous_words treats a completed parenthesized option list as
5338- * one word, so the above test is correct.
5339- */
53405356 if (ends_with (prev_wd , '(' ) || ends_with (prev_wd , ',' ))
53415357 COMPLETE_WITH ("timeout" , "no_throw" );
5342-
5343- /*
5344- * timeout takes a string value, no_throw takes no value. We don't
5345- * offer completions for these values.
5346- */
5358+ }
5359+ else if (HeadMatches ("WAIT" , "FOR" , "LSN" , MatchAny , "MODE" , MatchAny , "WITH" , "(*" ) &&
5360+ !HeadMatches ("WAIT" , "FOR" , "LSN" , MatchAny , "MODE" , MatchAny , "WITH" , "(*)" ))
5361+ {
5362+ if (ends_with (prev_wd , '(' ) || ends_with (prev_wd , ',' ))
5363+ COMPLETE_WITH ("timeout" , "no_throw" );
53475364 }
53485365
53495366/* WITH [RECURSIVE] */
0 commit comments