@@ -1007,6 +1007,7 @@ static const pgsql_thing_t words_after_create[] = {
10071007{"MATERIALIZED VIEW" ,NULL ,NULL ,& Query_for_list_of_matviews },
10081008{"OPERATOR" ,NULL ,NULL ,NULL },/* Querying for this is probably not such
10091009 * a good idea. */
1010+ {"OR REPLACE" ,NULL ,NULL ,NULL ,THING_NO_DROP |THING_NO_ALTER },
10101011{"OWNED" ,NULL ,NULL ,NULL ,THING_NO_CREATE |THING_NO_ALTER },/* for DROP OWNED BY ... */
10111012{"PARSER" ,Query_for_list_of_ts_parsers ,NULL ,NULL ,THING_NO_SHOW },
10121013{"POLICY" ,NULL ,NULL ,NULL },
@@ -1489,6 +1490,11 @@ psql_completion(const char *text, int start, int end)
14891490else if (TailMatches ("CREATE" ))
14901491matches = completion_matches (text ,create_command_generator );
14911492
1493+ /* complete with somthing you can create or replace */
1494+ else if (TailMatches ("CREATE" ,"OR" ,"REPLACE" ))
1495+ COMPLETE_WITH ("FUNCTION" ,"PROCEDURE" ,"LANGUAGE" ,"RULE" ,"VIEW" ,
1496+ "AGGREGATE" ,"TRANSFORM" );
1497+
14921498/* DROP, but not DROP embedded in other commands */
14931499/* complete with something you can drop */
14941500else if (Matches ("DROP" ))
@@ -2345,6 +2351,10 @@ psql_completion(const char *text, int start, int end)
23452351 !TailMatches ("FOR" ,MatchAny ,MatchAny ,MatchAny ))
23462352COMPLETE_WITH ("(" );
23472353
2354+ /* CREATE OR REPLACE */
2355+ else if (Matches ("CREATE" ,"OR" ))
2356+ COMPLETE_WITH ("REPLACE" );
2357+
23482358/* CREATE POLICY */
23492359/* Complete "CREATE POLICY <name> ON" */
23502360else if (Matches ("CREATE" ,"POLICY" ,MatchAny ))
@@ -2440,14 +2450,17 @@ psql_completion(const char *text, int start, int end)
24402450COMPLETE_WITH ("publish" );
24412451
24422452/* CREATE RULE */
2443- /* Complete "CREATE RULE <sth>" with "AS ON" */
2444- else if (Matches ("CREATE" ,"RULE" ,MatchAny ))
2453+ /* Complete "CREATE [ OR REPLACE ] RULE <sth>" with "AS ON" */
2454+ else if (Matches ("CREATE" ,"RULE" ,MatchAny )||
2455+ Matches ("CREATE" ,"OR" ,"REPLACE" ,"RULE" ,MatchAny ))
24452456COMPLETE_WITH ("AS ON" );
2446- /* Complete "CREATE RULE <sth> AS" with "ON" */
2447- else if (Matches ("CREATE" ,"RULE" ,MatchAny ,"AS" ))
2457+ /* Complete "CREATE [ OR REPLACE ] RULE <sth> AS" with "ON" */
2458+ else if (Matches ("CREATE" ,"RULE" ,MatchAny ,"AS" )||
2459+ Matches ("CREATE" ,"OR" ,"REPLACE" ,"RULE" ,MatchAny ,"AS" ))
24482460COMPLETE_WITH ("ON" );
2449- /* Complete "CREATE RULE <sth> AS ON" with SELECT|UPDATE|INSERT|DELETE */
2450- else if (Matches ("CREATE" ,"RULE" ,MatchAny ,"AS" ,"ON" ))
2461+ /* Complete "CREATE [ OR REPLACE ] RULE <sth> AS ON" with SELECT|UPDATE|INSERT|DELETE */
2462+ else if (Matches ("CREATE" ,"RULE" ,MatchAny ,"AS" ,"ON" )||
2463+ Matches ("CREATE" ,"OR" ,"REPLACE" ,"RULE" ,MatchAny ,"AS" ,"ON" ))
24512464COMPLETE_WITH ("SELECT" ,"UPDATE" ,"INSERT" ,"DELETE" );
24522465/* Complete "AS ON SELECT|UPDATE|INSERT|DELETE" with a "TO" */
24532466else if (TailMatches ("AS" ,"ON" ,"SELECT|UPDATE|INSERT|DELETE" ))
@@ -2726,11 +2739,13 @@ psql_completion(const char *text, int start, int end)
27262739}
27272740
27282741/* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
2729- /* Complete CREATE VIEW <name> with AS */
2730- else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ))
2742+ /* Complete CREATE [ OR REPLACE ] VIEW <name> with AS */
2743+ else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny )||
2744+ TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ))
27312745COMPLETE_WITH ("AS" );
2732- /* Complete "CREATE VIEW <sth> AS with "SELECT" */
2733- else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"AS" ))
2746+ /* Complete "CREATE [ OR REPLACE ] VIEW <sth> AS with "SELECT" */
2747+ else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"AS" )||
2748+ TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ,"AS" ))
27342749COMPLETE_WITH ("SELECT" );
27352750
27362751/* CREATE MATERIALIZED VIEW */