Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5c4dd2c

Browse files
committed
Simplify tab completion rules for views and foreign tables.
Since an increasing number of views and foreign tables are now ableto be updated, complete with any table, view, or foreign table inthe relevant contexts. This avoids the need to use a complexquery that may be both confusing to end-users and nonperformantto construct the list of possible completions.Dean Rasheed, persuant to a complaint from Bernd Helme and asuggestion from Peter Eisentraut
1 parent83eb540 commit5c4dd2c

File tree

1 file changed

+4
-39
lines changed

1 file changed

+4
-39
lines changed

‎src/bin/psql/tab-complete.c

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -369,47 +369,12 @@ static const SchemaQuery Query_for_list_of_constraints_with_schema = {
369369
NULL
370370
};
371371

372-
/* The bit masks for the following three functions come from
373-
* src/include/catalog/pg_trigger.h.
374-
*/
375-
staticconstSchemaQueryQuery_for_list_of_insertables= {
376-
/* catname */
377-
"pg_catalog.pg_class c",
378-
/* selcondition */
379-
"(c.relkind = 'r' OR (c.relkind = 'v' AND c.relhastriggers AND EXISTS "
380-
"(SELECT 1 FROM pg_catalog.pg_trigger t WHERE t.tgrelid = c.oid AND t.tgtype & (1 << 2) <> 0)))",
381-
/* viscondition */
382-
"pg_catalog.pg_table_is_visible(c.oid)",
383-
/* namespace */
384-
"c.relnamespace",
385-
/* result */
386-
"pg_catalog.quote_ident(c.relname)",
387-
/* qualresult */
388-
NULL
389-
};
390-
391-
staticconstSchemaQueryQuery_for_list_of_deletables= {
392-
/* catname */
393-
"pg_catalog.pg_class c",
394-
/* selcondition */
395-
"(c.relkind = 'r' OR (c.relkind = 'v' AND c.relhastriggers AND EXISTS "
396-
"(SELECT 1 FROM pg_catalog.pg_trigger t WHERE t.tgrelid = c.oid AND t.tgtype & (1 << 3) <> 0)))",
397-
/* viscondition */
398-
"pg_catalog.pg_table_is_visible(c.oid)",
399-
/* namespace */
400-
"c.relnamespace",
401-
/* result */
402-
"pg_catalog.quote_ident(c.relname)",
403-
/* qualresult */
404-
NULL
405-
};
406-
372+
/* Relations supporting INSERT, UPDATE or DELETE */
407373
staticconstSchemaQueryQuery_for_list_of_updatables= {
408374
/* catname */
409375
"pg_catalog.pg_class c",
410376
/* selcondition */
411-
"(c.relkind = 'r' OR (c.relkind = 'v' AND c.relhastriggers AND EXISTS "
412-
"(SELECT 1 FROM pg_catalog.pg_trigger t WHERE t.tgrelid = c.oid AND t.tgtype & (1 << 4) <> 0)))",
377+
"c.relkind IN ('r', 'f', 'v')",
413378
/* viscondition */
414379
"pg_catalog.pg_table_is_visible(c.oid)",
415380
/* namespace */
@@ -2362,7 +2327,7 @@ psql_completion(char *text, int start, int end)
23622327
/* Complete DELETE FROM with a list of tables */
23632328
elseif (pg_strcasecmp(prev2_wd,"DELETE")==0&&
23642329
pg_strcasecmp(prev_wd,"FROM")==0)
2365-
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_deletables,NULL);
2330+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_updatables,NULL);
23662331
/* Complete DELETE FROM <table> */
23672332
elseif (pg_strcasecmp(prev3_wd,"DELETE")==0&&
23682333
pg_strcasecmp(prev2_wd,"FROM")==0)
@@ -2732,7 +2697,7 @@ psql_completion(char *text, int start, int end)
27322697
/* Complete INSERT INTO with table names */
27332698
elseif (pg_strcasecmp(prev2_wd,"INSERT")==0&&
27342699
pg_strcasecmp(prev_wd,"INTO")==0)
2735-
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_insertables,NULL);
2700+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_updatables,NULL);
27362701
/* Complete "INSERT INTO <table> (" with attribute names */
27372702
elseif (pg_strcasecmp(prev4_wd,"INSERT")==0&&
27382703
pg_strcasecmp(prev3_wd,"INTO")==0&&

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp