/*
* WAIT FOR LSN '<lsn>' [ WITH ( option [, ...] ) ]
* where option can be:
+ * MODE '<mode>'
* TIMEOUT '<timeout>'
* NO_THROW
+ * and mode can be:
+ * standby_replay | standby_write | standby_flush | primary_flush
*/
else if (Matches("WAIT"))
COMPLETE_WITH("FOR");
COMPLETE_WITH("WITH");
else if (Matches("WAIT", "FOR", "LSN", MatchAny, "WITH"))
COMPLETE_WITH("(");
+
+ /*
+ * Handle parenthesized option list. This fires when we're in an
+ * unfinished parenthesized option list. get_previous_words treats a
+ * completed parenthesized option list as one word, so the above test is
+ * correct.
+ *
+ * 'mode' takes a string value (one of the listed above), 'timeout' takes
+ * a string value, and 'no_throw' takes no value. We do not offer
+ * completions for the *values* of 'timeout' or 'no_throw'.
+ */
else if (HeadMatches("WAIT", "FOR", "LSN", MatchAny, "WITH", "(*") &&
!HeadMatches("WAIT", "FOR", "LSN", MatchAny, "WITH", "(*)"))
{
- /*
- * This fires if we're in an unfinished parenthesized option list.
- * get_previous_words treats a completed parenthesized option list as
- * one word, so the above test is correct.
- */
if (ends_with(prev_wd, '(') || ends_with(prev_wd, ','))
- COMPLETE_WITH("timeout", "no_throw");
-
- /*
- * timeout takes a string value, no_throw takes no value. We don't
- * offer completions for these values.
- */
+ COMPLETE_WITH("mode", "timeout", "no_throw");
+ else if (TailMatches("mode"))
+ COMPLETE_WITH("'standby_replay'", "'standby_write'", "'standby_flush'", "'primary_flush'");
}
/* WITH [RECURSIVE] */