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

Commit45a2d45

Browse files
committed
Fix bogus tab-completion rule for CREATE PUBLICATION.
You can't use "FOR TABLE" as a single Matches argument, because readlinewill consider that input to be two words not one. It's necessary to makethe pattern contain two arguments.The case accidentally worked anyway because the words_after_createtest fired ... but only for the first such table name.Noted by Edmund Horner, though this isn't exactly his proposed fix.Backpatch to v10 where the faulty code came in.Discussion:https://postgr.es/m/CAMyN-kDe=gBmHgxWwUUaXuwK+p+7g1vChR7foPHRDLE592nJPQ@mail.gmail.com
1 parentec7b276 commit45a2d45

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,21 @@ psql_completion(const char *text, int start, int end)
16001600
word_matches(p2, previous_words[previous_words_count - 2]) && \
16011601
word_matches(p3, previous_words[previous_words_count - 3]))
16021602

1603+
#defineHeadMatches4(p1,p2,p3,p4) \
1604+
(previous_words_count >= 4 && \
1605+
word_matches(p1, previous_words[previous_words_count - 1]) && \
1606+
word_matches(p2, previous_words[previous_words_count - 2]) && \
1607+
word_matches(p3, previous_words[previous_words_count - 3]) && \
1608+
word_matches(p4, previous_words[previous_words_count - 4]))
1609+
1610+
#defineHeadMatches5(p1,p2,p3,p4,p5) \
1611+
(previous_words_count >= 5 && \
1612+
word_matches(p1, previous_words[previous_words_count - 1]) && \
1613+
word_matches(p2, previous_words[previous_words_count - 2]) && \
1614+
word_matches(p3, previous_words[previous_words_count - 3]) && \
1615+
word_matches(p4, previous_words[previous_words_count - 4]) && \
1616+
word_matches(p5, previous_words[previous_words_count - 5]))
1617+
16031618
/* Known command-starting keywords. */
16041619
staticconstchar*constsql_commands[]= {
16051620
"ABORT","ALTER","ANALYZE","BEGIN","CALL","CHECKPOINT","CLOSE","CLUSTER",
@@ -2646,8 +2661,8 @@ psql_completion(const char *text, int start, int end)
26462661
COMPLETE_WITH_LIST3("FOR TABLE","FOR ALL TABLES","WITH (");
26472662
elseif (Matches4("CREATE","PUBLICATION",MatchAny,"FOR"))
26482663
COMPLETE_WITH_LIST2("TABLE","ALL TABLES");
2649-
/* Complete "CREATE PUBLICATION <name> FOR TABLE <table>" */
2650-
elseif (Matches4("CREATE","PUBLICATION",MatchAny,"FORTABLE"))
2664+
/* Complete "CREATE PUBLICATION <name> FOR TABLE <table>, ..." */
2665+
elseif (HeadMatches5("CREATE","PUBLICATION",MatchAny,"FOR","TABLE"))
26512666
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,NULL);
26522667
/* Complete "CREATE PUBLICATION <name> [...] WITH" */
26532668
elseif (HeadMatches2("CREATE","PUBLICATION")&&TailMatches2("WITH","("))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp