pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedpsql tab-complete
10+ messages / 4 participants
[nested] [flat]
Commits from this thread:
2022-12-22 3f28bd7337 Add work-around for VA_ARGS_NARGS() on MSVC.
* psql tab-complete
@ 2019-10-24 16:11 Victor Spirin <v.spirin@postgrespro.ru>
0 siblings, 2 replies; 10+ messages in thread
From: Victor Spirin @ 2019-10-24 16:11 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
I found some problem with tab-complete in the 12 version. I checked
this in the Windows.
Victor Spirin
Postgres Professional:http://www.postgrespro.com
The Russian Postgres Company
Attachments:
tab-complete.patch (text/plain, 481B) download
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index e00dbab5aa..5d7f24e57a 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3577,7 +3577,7 @@ psql_completion(const char *text, int start, int end)
/* WHERE */
/* Simple case of the word before the where being the table name */
- else if (TailMatches(MatchAny, "WHERE"))
+ else if (TailMatches("WHERE", MatchAny))
COMPLETE_WITH_ATTR(prev2_wd, "");
/* ... FROM ... */
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2019-10-24 21:31 Victor Spirin <v.spirin@postgrespro.ru>
parent: Victor Spirin <v.spirin@postgrespro.ru>
1 sibling, 0 replies; 10+ messages in thread
From: Victor Spirin @ 2019-10-24 21:31 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
Sorry for wrong place and contents of my message.
It seems that the VA_ARGS_NARGS (__ VA_ARGS__) macros always return 1 on
Windows.
Victor Spirin
Postgres Professional:http://www.postgrespro.com
The Russian Postgres Company
24.10.2019 19:11, Victor Spirin пишет:
> I found some problem with tab-complete in the 12 version. I checked
> this in the Windows.
>
>
> Victor Spirin
> Postgres Professional:http://www.postgrespro.com
> The Russian Postgres Company
>
>
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2019-10-24 21:48 Tom Lane <tgl@sss.pgh.pa.us>
parent: Victor Spirin <v.spirin@postgrespro.ru>
1 sibling, 1 reply; 10+ messages in thread
From: Tom Lane @ 2019-10-24 21:48 UTC (permalink / raw)
To: Victor Spirin <v.spirin@postgrespro.ru>; +Cc: pgsql-hackers@lists.postgresql.org
Victor Spirin <v.spirin@postgrespro.ru> writes:
> I found some problem with tab-complete in the 12 version. I checked
> this in the Windows.
This change seems to break the case intended by the comment,
ie given the context
SELECT * FROM tablename WHERE <tab>
we want to offer the columns of "tablename" as completions.
I'd be the first to agree that that's completely lame, as there
are any number of related cases it fails to cover ... but this
patch isn't making it better.
regards, tom lane
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2019-10-24 21:53 Victor Spirin <v.spirin@postgrespro.ru>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 10+ messages in thread
From: Victor Spirin @ 2019-10-24 21:53 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
Yes, I found, that VA_ARGS_NARGS(__ VA_ARGS__) macros always return 1 on
Windows.
Victor Spirin
Postgres Professional:http://www.postgrespro.com
The Russian Postgres Company
25.10.2019 0:48, Tom Lane пишет:
> Victor Spirin <v.spirin@postgrespro.ru> writes:
>> I found some problem with tab-complete in the 12 version. I checked
>> this in the Windows.
> This change seems to break the case intended by the comment,
> ie given the context
>
> SELECT * FROM tablename WHERE <tab>
>
> we want to offer the columns of "tablename" as completions.
>
> I'd be the first to agree that that's completely lame, as there
> are any number of related cases it fails to cover ... but this
> patch isn't making it better.
>
> regards, tom lane
>
>
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2019-10-25 08:57 Victor Spirin <v.spirin@postgrespro.ru>
parent: Victor Spirin <v.spirin@postgrespro.ru>
0 siblings, 1 reply; 10+ messages in thread
From: Victor Spirin @ 2019-10-25 08:57 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
This patch resolved one problem in the tab-complete.c on MSVC. The
VA_ARGS_NARGS macros now work correctly on Windows.
Victor Spirin
Postgres Professional:http://www.postgrespro.com
The Russian Postgres Company
25.10.2019 0:53, Victor Spirin пишет:
> Yes, I found, that VA_ARGS_NARGS(__ VA_ARGS__) macros always return 1
> on Windows.
>
> Victor Spirin
> Postgres Professional:http://www.postgrespro.com
> The Russian Postgres Company
>
> 25.10.2019 0:48, Tom Lane пишет:
>> Victor Spirin <v.spirin@postgrespro.ru> writes:
>>> I found some problem with tab-complete in the 12 version. I checked
>>> this in the Windows.
>> This change seems to break the case intended by the comment,
>> ie given the context
>>
>> SELECT * FROM tablename WHERE <tab>
>>
>> we want to offer the columns of "tablename" as completions.
>>
>> I'd be the first to agree that that's completely lame, as there
>> are any number of related cases it fails to cover ... but this
>> patch isn't making it better.
>>
>> regards, tom lane
>>
>>
>
>
Attachments:
nargs.patch (text/plain, 1.0K) download
diff --git a/src/include/c.h b/src/include/c.h
index edc7822b0f..ed7099164b 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -238,6 +238,19 @@
* the call so that that is the appropriate one of the list of constants.
* This idea is due to Laurent Deniau.
*/
+#ifdef _MSC_VER
+#define EXPAND(args) args
+#define VA_ARGS_NARGS(...) \
+ VA_ARGS_NARGS_ EXPAND((__VA_ARGS__, \
+ 63,62,61,60, \
+ 59,58,57,56,55,54,53,52,51,50, \
+ 49,48,47,46,45,44,43,42,41,40, \
+ 39,38,37,36,35,34,33,32,31,30, \
+ 29,28,27,26,25,24,23,22,21,20, \
+ 19,18,17,16,15,14,13,12,11,10, \
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
+#else
+
#define VA_ARGS_NARGS(...) \
VA_ARGS_NARGS_(__VA_ARGS__, \
63,62,61,60, \
@@ -247,6 +260,8 @@
29,28,27,26,25,24,23,22,21,20, \
19,18,17,16,15,14,13,12,11,10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+#endif
+
#define VA_ARGS_NARGS_( \
_01,_02,_03,_04,_05,_06,_07,_08,_09,_10, \
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2019-10-26 03:59 Michael Paquier <michael@paquier.xyz>
parent: Victor Spirin <v.spirin@postgrespro.ru>
0 siblings, 1 reply; 10+ messages in thread
From: Michael Paquier @ 2019-10-26 03:59 UTC (permalink / raw)
To: Victor Spirin <v.spirin@postgrespro.ru>; +Cc: pgsql-hackers@lists.postgresql.org
On Fri, Oct 25, 2019 at 11:57:18AM +0300, Victor Spirin wrote:
> This patch resolved one problem in the tab-complete.c on MSVC. The
> VA_ARGS_NARGS macros now work correctly on Windows.
Can you explain why and in what the use of EXPAND() helps with MSVC
builds? Any references which help to understand why this is better?
If this change is needed, this also surely needs a comment to explain
the difference.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2022-12-21 22:41 Thomas Munro <thomas.munro@gmail.com>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Munro @ 2022-12-21 22:41 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Victor Spirin <v.spirin@postgrespro.ru>; pgsql-hackers@lists.postgresql.org
On Sat, Oct 26, 2019 at 4:59 PM Michael Paquier <michael@paquier.xyz> wrote:
> On Fri, Oct 25, 2019 at 11:57:18AM +0300, Victor Spirin wrote:
> > This patch resolved one problem in the tab-complete.c on MSVC. The
> > VA_ARGS_NARGS macros now work correctly on Windows.
>
> Can you explain why and in what the use of EXPAND() helps with MSVC
> builds? Any references which help to understand why this is better?
> If this change is needed, this also surely needs a comment to explain
> the difference.
Since I really want to be able to use VA_ARGS_NARGS() elsewhere, I
looked into this. There are various derivatives of that macro, some
using GCC/Clang-only syntax and that work on GCC and MSVC, splattered
all over the internet, but the original, coming as it does from a C
standards newsgroup[1], does not. There are also lots of complaints
that the original standard version doesn't work on MSVC, with
analysis:
https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly
https://stackoverflow.com/questions/32399191/va-args-expansion-using-msvc
https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170
The short version is that __VA_ARGS__ is not tokenized the way the
standard requires (it's considered to be a single token unless you
shove it back through the preprocessor again, which is what EXPAND()
does), but you can fix that with /Zc:preprocessor. That switch only
works in Visual Studio 2019 and up, and maybe also 2017 if you spell
it /experimental:preprocessor. We still claim to support older
compilers. Assuming those switches actually work as claimed, I see
two choices: commit this hack with a comment reminding us to clean it
up later, or drop 2015.
[1] https://groups.google.com/g/comp.std.c/c/d-6Mj5Lko_s
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2022-12-21 22:56 Tom Lane <tgl@sss.pgh.pa.us>
parent: Thomas Munro <thomas.munro@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Tom Lane @ 2022-12-21 22:56 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Victor Spirin <v.spirin@postgrespro.ru>; pgsql-hackers@lists.postgresql.org
Thomas Munro <thomas.munro@gmail.com> writes:
> Since I really want to be able to use VA_ARGS_NARGS() elsewhere,
+1, that'd be handy.
> ... Assuming those switches actually work as claimed, I see
> two choices: commit this hack with a comment reminding us to clean it
> up later, or drop 2015.
As long as we can hide the messiness inside a macro definition,
I'd vote for the former.
regards, tom lane
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2022-12-22 02:25 Michael Paquier <michael@paquier.xyz>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 10+ messages in thread
From: Michael Paquier @ 2022-12-22 02:25 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Thomas Munro <thomas.munro@gmail.com>; Victor Spirin <v.spirin@postgrespro.ru>; pgsql-hackers@lists.postgresql.org
On Wed, Dec 21, 2022 at 05:56:05PM -0500, Tom Lane wrote:
> Thomas Munro <thomas.munro@gmail.com> writes:
>> Since I really want to be able to use VA_ARGS_NARGS() elsewhere,
>
> +1, that'd be handy.
>
>> ... Assuming those switches actually work as claimed, I see
>> two choices: commit this hack with a comment reminding us to clean it
>> up later, or drop 2015.
>
> As long as we can hide the messiness inside a macro definition,
> I'd vote for the former.
Agreed, even if it is worth noting that all the buildfarm members
with MSVC use 2017 or newer.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: psql tab-complete
@ 2022-12-22 05:36 Thomas Munro <thomas.munro@gmail.com>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Munro @ 2022-12-22 05:36 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Victor Spirin <v.spirin@postgrespro.ru>; pgsql-hackers@lists.postgresql.org
On Thu, Dec 22, 2022 at 3:25 PM Michael Paquier <michael@paquier.xyz> wrote:
> On Wed, Dec 21, 2022 at 05:56:05PM -0500, Tom Lane wrote:
> > Thomas Munro <thomas.munro@gmail.com> writes:
> >> Since I really want to be able to use VA_ARGS_NARGS() elsewhere,
> >
> > +1, that'd be handy.
> >
> >> ... Assuming those switches actually work as claimed, I see
> >> two choices: commit this hack with a comment reminding us to clean it
> >> up later, or drop 2015.
> >
> > As long as we can hide the messiness inside a macro definition,
> > I'd vote for the former.
>
> Agreed, even if it is worth noting that all the buildfarm members
> with MSVC use 2017 or newer.
Thanks. Pushed.
PS is it a mistake that we still mention SDK 8.1 in the docs?
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2022-12-22 05:36 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 16:11 psql tab-complete Victor Spirin <v.spirin@postgrespro.ru>
2019-10-24 21:31 ` Victor Spirin <v.spirin@postgrespro.ru>
2019-10-24 21:48 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-10-24 21:53 ` Victor Spirin <v.spirin@postgrespro.ru>
2019-10-25 08:57 ` Victor Spirin <v.spirin@postgrespro.ru>
2019-10-26 03:59 ` Michael Paquier <michael@paquier.xyz>
2022-12-21 22:41 ` Thomas Munro <thomas.munro@gmail.com>
2022-12-21 22:56 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-12-22 02:25 ` Michael Paquier <michael@paquier.xyz>
2022-12-22 05:36 ` Thomas Munro <thomas.munro@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox