| From: | ZizhuanLiu X-MAN <44973863(at)qq(dot)com> |
|---|---|
| To: | surya poondla <suryapoondla4(at)gmail(dot)com>, solai v <solai(dot)cdac(at)gmail(dot)com> |
| Cc: | Álvaro Rodríguez <alvaro(at)datadoghq(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Improving psql autocompletion for SET LOCAL / SET SESSION |
| Date: | 2026-06-17 15:28:02 |
| Message-ID: | tencent_EECFB4F9D1CA4F887CEB593A513B3796C30A@qq.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi everyone,
I have spent the past two days learning tab-complete.in.c and the relevant SQL syntax
we discussed starting from 10:46:14 on 2026-06-12, and I have finalized my own patch version today.
Unfortunately, I did not keep track of updates to this mailing list and CF-App these days, and I just
found that the patch has already been iterated to v2. I really appreciate all of your hard work moving this forward.
I have finished my independent v2 implementation and verified it works via local testing, so I am sharing
my patch here and welcome any feedback or suggestions on its deficiencies.
I haven’t had time to implement and test the fixes related to SESSION / LOCAL pointed out by Surya,
so those improvements are not covered in my current patch.
I also have two questions I would like to clarify:
1.We retained SEED and TIME ZONE as special SET parameters after removing the rarely used
SCHEMA and NAMES. Could anyone explain why SEED is not included in the official v2 patch?
2.It seems the current v2 patch does not refactor the logic for the SET command. Is this because
SET and RESET still share the same implementation, making decoupling difficult?
Below is the design plan I prepared in advance for this improvement:
After reviewing tab-complete.in.c together with the syntax specifications for the
SET and RESET commands, I’ve come up with a refinement plan as follows:
1.Split the completion logic for SET and RESET.
Both commands currently share the same Query_for_list_of_set_vars. With the new features
we plan to introduce, the syntactic differences between them will become more prominent.
Separating their tab-completion implementations will make the completion rules more precise for each command, so I propose splitting them.
2.Add a dedicated tab-completion branch for SET LOCAL.
3.Refine the SET SESSION completion branch to expand syntax coverage for tab completion.
Key Modification Details:
0.Add macro definition for newly introduced special SET parameters:
```c
/* SET special parameters */
#define Set_special_parameters \
"SCHEMA", "NAMES", "SEED", "TIME ZONE"
```c
1.Tab-completion candidate list for the separated RESET command:
RESET candidates = $Query_for_list_of_set_vars + "ALL"
This strictly conforms to official syntax. We remove the original irrelevant entries:
CONSTRAINTS, TRANSACTION, SESSION, ROLE, TABLESPACE. No newly added parameter
entries from this patch will be included here, resulting in a cleaner, syntax-consistent
completion list free of unrelated options.
2.Tab-completion candidate list for the separated SET command:
SET candidates =
$Query_for_list_of_set_vars
+ original reserved entries: CONSTRAINTS, TRANSACTION, SESSION, ROLE, TABLESPACE
(excluding "ALL", which exclusively belongs to RESET)
+ SESSION, LOCAL
+ Set_special_parameters
This candidate set fully aligns with PostgreSQL official SQL syntax.
3.New tab-completion candidate list for SET LOCAL:
SET LOCAL candidates = $Query_for_list_of_set_vars + Set_special_parameters
The list strictly matches valid grammar for the SET LOCAL clause.
4.Refined tab-completion candidate list for SET SESSION:
SET SESSION candidates = $Query_for_list_of_set_vars
+ Set_special_parameters
+ legacy entries from existing completion logic: AUTHORIZATION, CHARACTERISTICS AS TRANSACTION
This design complies with standard SQL syntax while retaining the original
completion options bound to SET SESSION in the current codebase.
Looking forward to your valuable reviews and suggestions.
regards,
--
ZizhuanLiu (X-MAN)
44973863(at)qq(dot)com
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Improving-psql-autocompletion-for-SET-LOCAL-SET-S.patch (2).txt | application/octet-stream | 2.9 KB |
| tab-complete.in-new.c | application/octet-stream | 263.7 KB |
| test-result.txt | application/octet-stream | 4.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-06-17 15:36:23 | Re: [PATCH] Doc: document standard_conforming_strings dump/restore incompatibility |
| Previous Message | Erik Rijkers | 2026-06-17 15:27:35 | Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c |