@@ -1329,6 +1329,13 @@ static const char *const table_storage_parameters[] = {
1329
1329
NULL
1330
1330
};
1331
1331
1332
+ /* Optional parameters for CREATE VIEW and ALTER VIEW */
1333
+ static const char * const view_optional_parameters []= {
1334
+ "check_option" ,
1335
+ "security_barrier" ,
1336
+ "security_invoker" ,
1337
+ NULL
1338
+ };
1332
1339
1333
1340
/* Forward declaration of functions */
1334
1341
static char * * psql_completion (const char * text ,int start ,int end );
@@ -2216,8 +2223,7 @@ psql_completion(const char *text, int start, int end)
2216
2223
COMPLETE_WITH ("TO" );
2217
2224
/* ALTER VIEW <name> */
2218
2225
else if (Matches ("ALTER" ,"VIEW" ,MatchAny ))
2219
- COMPLETE_WITH ("ALTER COLUMN" ,"OWNER TO" ,"RENAME" ,
2220
- "SET SCHEMA" );
2226
+ COMPLETE_WITH ("ALTER COLUMN" ,"OWNER TO" ,"RENAME" ,"RESET" ,"SET" );
2221
2227
/* ALTER VIEW xxx RENAME */
2222
2228
else if (Matches ("ALTER" ,"VIEW" ,MatchAny ,"RENAME" ))
2223
2229
COMPLETE_WITH_ATTR_PLUS (prev2_wd ,"COLUMN" ,"TO" );
@@ -2233,6 +2239,21 @@ psql_completion(const char *text, int start, int end)
2233
2239
/* ALTER VIEW xxx RENAME COLUMN yyy */
2234
2240
else if (Matches ("ALTER" ,"VIEW" ,MatchAny ,"RENAME" ,"COLUMN" ,MatchAnyExcept ("TO" )))
2235
2241
COMPLETE_WITH ("TO" );
2242
+ /* ALTER VIEW xxx RESET ( */
2243
+ else if (Matches ("ALTER" ,"VIEW" ,MatchAny ,"RESET" ))
2244
+ COMPLETE_WITH ("(" );
2245
+ /* Complete ALTER VIEW xxx SET with "(" or "SCHEMA" */
2246
+ else if (Matches ("ALTER" ,"VIEW" ,MatchAny ,"SET" ))
2247
+ COMPLETE_WITH ("(" ,"SCHEMA" );
2248
+ /* ALTER VIEW xxx SET|RESET ( yyy [= zzz] ) */
2249
+ else if (Matches ("ALTER" ,"VIEW" ,MatchAny ,"SET|RESET" ,"(" ))
2250
+ COMPLETE_WITH_LIST (view_optional_parameters );
2251
+ else if (Matches ("ALTER" ,"VIEW" ,MatchAny ,"SET" ,"(" ,MatchAny ))
2252
+ COMPLETE_WITH ("=" );
2253
+ else if (Matches ("ALTER" ,"VIEW" ,MatchAny ,"SET" ,"(" ,"check_option" ,"=" ))
2254
+ COMPLETE_WITH ("local" ,"cascaded" );
2255
+ else if (Matches ("ALTER" ,"VIEW" ,MatchAny ,"SET" ,"(" ,"security_barrier|security_invoker" ,"=" ))
2256
+ COMPLETE_WITH ("true" ,"false" );
2236
2257
2237
2258
/* ALTER MATERIALIZED VIEW <name> */
2238
2259
else if (Matches ("ALTER" ,"MATERIALIZED" ,"VIEW" ,MatchAny ))
@@ -3531,14 +3552,35 @@ psql_completion(const char *text, int start, int end)
3531
3552
}
3532
3553
3533
3554
/* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
3534
- /* Complete CREATE [ OR REPLACE ] VIEW <name> with AS */
3555
+ /* Complete CREATE [ OR REPLACE ] VIEW <name> with ASor WITH */
3535
3556
else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny )||
3536
3557
TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ))
3537
- COMPLETE_WITH ("AS" );
3558
+ COMPLETE_WITH ("AS" , "WITH" );
3538
3559
/* Complete "CREATE [ OR REPLACE ] VIEW <sth> AS with "SELECT" */
3539
3560
else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"AS" )||
3540
3561
TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ,"AS" ))
3541
3562
COMPLETE_WITH ("SELECT" );
3563
+ /* CREATE [ OR REPLACE ] VIEW <name> WITH ( yyy [= zzz] ) */
3564
+ else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"WITH" )||
3565
+ TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ,"WITH" ))
3566
+ COMPLETE_WITH ("(" );
3567
+ else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"WITH" ,"(" )||
3568
+ TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ,"WITH" ,"(" ))
3569
+ COMPLETE_WITH_LIST (view_optional_parameters );
3570
+ else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"WITH" ,"(" ,"check_option" )||
3571
+ TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ,"WITH" ,"(" ,"check_option" ))
3572
+ COMPLETE_WITH ("=" );
3573
+ else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"WITH" ,"(" ,"check_option" ,"=" )||
3574
+ TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ,"WITH" ,"(" ,"check_option" ,"=" ))
3575
+ COMPLETE_WITH ("local" ,"cascaded" );
3576
+ /* CREATE [ OR REPLACE ] VIEW <name> WITH ( ... ) AS */
3577
+ else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"WITH" ,"(*)" )||
3578
+ TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ,"WITH" ,"(*)" ))
3579
+ COMPLETE_WITH ("AS" );
3580
+ /* CREATE [ OR REPLACE ] VIEW <name> WITH ( ... ) AS SELECT */
3581
+ else if (TailMatches ("CREATE" ,"VIEW" ,MatchAny ,"WITH" ,"(*)" ,"AS" )||
3582
+ TailMatches ("CREATE" ,"OR" ,"REPLACE" ,"VIEW" ,MatchAny ,"WITH" ,"(*)" ,"AS" ))
3583
+ COMPLETE_WITH ("SELECT" );
3542
3584
3543
3585
/* CREATE MATERIALIZED VIEW */
3544
3586
else if (Matches ("CREATE" ,"MATERIALIZED" ))