@@ -3336,48 +3336,61 @@ match_previous_words(int pattern_id,
33363336 /* Complete COPY <sth> */
33373337 else if (Matches ("COPY|\\copy" , MatchAny ))
33383338 COMPLETE_WITH ("FROM" , "TO" );
3339- /* Complete COPY|\copy <sth> FROM|TO with filename or STDIN/STDOUT */
3339+ /* Complete COPY|\copy <sth> FROM|TO with filename or STDIN/STDOUT/PROGRAM */
33403340 else if (Matches ("COPY|\\copy" , MatchAny , "FROM|TO" ))
33413341 {
33423342 /* COPY requires quoted filename */
33433343 bool force_quote = HeadMatches ("COPY" );
33443344
33453345 if (TailMatches ("FROM" ))
3346- COMPLETE_WITH_FILES_PLUS ("" , force_quote , "STDIN" );
3346+ COMPLETE_WITH_FILES_PLUS ("" , force_quote , "STDIN" , "PROGRAM" );
33473347 else
3348- COMPLETE_WITH_FILES_PLUS ("" , force_quote , "STDOUT" );
3348+ COMPLETE_WITH_FILES_PLUS ("" , force_quote , "STDOUT" , "PROGRAM" );
33493349 }
33503350
3351- /* Complete COPY <sth> TO <sth> */
3352- else if (Matches ("COPY|\\copy" , MatchAny , "TO" , MatchAny ))
3351+ /* Complete COPY|\copy <sth> FROM|TO PROGRAM */
3352+ else if (Matches ("COPY|\\copy" , MatchAny , "FROM|TO" , "PROGRAM" ))
3353+ COMPLETE_WITH_FILES ("" , HeadMatches ("COPY" )); /* COPY requires quoted
3354+ * filename */
3355+
3356+ /* Complete COPY <sth> TO [PROGRAM] <sth> */
3357+ else if (Matches ("COPY|\\copy" , MatchAny , "TO" , MatchAnyExcept ("PROGRAM" )) ||
3358+ Matches ("COPY|\\copy" , MatchAny , "TO" , "PROGRAM" , MatchAny ))
33533359 COMPLETE_WITH ("WITH (" );
33543360
3355- /* Complete COPY <sth> FROM <sth> */
3356- else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAny ))
3361+ /* Complete COPY <sth> FROM [PROGRAM] <sth> */
3362+ else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAnyExcept ("PROGRAM" )) ||
3363+ Matches ("COPY|\\copy" , MatchAny , "FROM" , "PROGRAM" , MatchAny ))
33573364 COMPLETE_WITH ("WITH (" , "WHERE" );
33583365
3359- /* Complete COPY <sth> FROM filename WITH ( */
3360- else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAny , "WITH" , "(" ))
3366+ /* Complete COPY <sth> FROM [PROGRAM] filename WITH ( */
3367+ else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAnyExcept ("PROGRAM" ), "WITH" , "(" ) ||
3368+ Matches ("COPY|\\copy" , MatchAny , "FROM" , "PROGRAM" , MatchAny , "WITH" , "(" ))
33613369 COMPLETE_WITH (Copy_from_options );
33623370
3363- /* Complete COPY <sth> TO filename WITH ( */
3364- else if (Matches ("COPY|\\copy" , MatchAny , "TO" , MatchAny , "WITH" , "(" ))
3371+ /* Complete COPY <sth> TO [PROGRAM] filename WITH ( */
3372+ else if (Matches ("COPY|\\copy" , MatchAny , "TO" , MatchAnyExcept ("PROGRAM" ), "WITH" , "(" ) ||
3373+ Matches ("COPY|\\copy" , MatchAny , "TO" , "PROGRAM" , MatchAny , "WITH" , "(" ))
33653374 COMPLETE_WITH (Copy_to_options );
33663375
3367- /* Complete COPY <sth> FROM|TO filename WITH (FORMAT */
3368- else if (Matches ("COPY|\\copy" , MatchAny , "FROM|TO" , MatchAny , "WITH" , "(" , "FORMAT" ))
3376+ /* Complete COPY <sth> FROM|TO [PROGRAM] <sth> WITH (FORMAT */
3377+ else if (Matches ("COPY|\\copy" , MatchAny , "FROM|TO" , MatchAnyExcept ("PROGRAM" ), "WITH" , "(" , "FORMAT" ) ||
3378+ Matches ("COPY|\\copy" , MatchAny , "FROM|TO" , "PROGRAM" , MatchAny , "WITH" , "(" , "FORMAT" ))
33693379 COMPLETE_WITH ("binary" , "csv" , "text" );
33703380
3371- /* Complete COPY <sth> FROM filename WITH (ON_ERROR */
3372- else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAny , "WITH" , "(" , "ON_ERROR" ))
3381+ /* Complete COPY <sth> FROM [PROGRAM] filename WITH (ON_ERROR */
3382+ else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAnyExcept ("PROGRAM" ), "WITH" , "(" , "ON_ERROR" ) ||
3383+ Matches ("COPY|\\copy" , MatchAny , "FROM" , "PROGRAM" , MatchAny , "WITH" , "(" , "ON_ERROR" ))
33733384 COMPLETE_WITH ("stop" , "ignore" );
33743385
3375- /* Complete COPY <sth> FROM filename WITH (LOG_VERBOSITY */
3376- else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAny , "WITH" , "(" , "LOG_VERBOSITY" ))
3386+ /* Complete COPY <sth> FROM [PROGRAM] filename WITH (LOG_VERBOSITY */
3387+ else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAnyExcept ("PROGRAM" ), "WITH" , "(" , "LOG_VERBOSITY" ) ||
3388+ Matches ("COPY|\\copy" , MatchAny , "FROM" , "PROGRAM" , MatchAny , "WITH" , "(" , "LOG_VERBOSITY" ))
33773389 COMPLETE_WITH ("silent" , "default" , "verbose" );
33783390
3379- /* Complete COPY <sth> FROM <sth> WITH (<options>) */
3380- else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAny , "WITH" , MatchAny ))
3391+ /* Complete COPY <sth> FROM [PROGRAM] <sth> WITH (<options>) */
3392+ else if (Matches ("COPY|\\copy" , MatchAny , "FROM" , MatchAnyExcept ("PROGRAM" ), "WITH" , MatchAny ) ||
3393+ Matches ("COPY|\\copy" , MatchAny , "FROM" , "PROGRAM" , MatchAny , "WITH" , MatchAny ))
33813394 COMPLETE_WITH ("WHERE" );
33823395
33833396 /* CREATE ACCESS METHOD */
0 commit comments