psql tab completion broken for storage servers, tags, profiles and resource groups (pre-PG15 query format)
Les mainteneurs répondent en général sous 2 jours
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 72/100
Piste de recherche
Les quatre macros Query_for_list_of_tags, Query_for_list_of_resgroups, Query_for_list_of_storage_servers et Query_for_list_of_profiles se trouvent dans src/bin/psql/tab-complete.c. Compare-les à Query_for_list_of_servers, qui utilise déjà la forme PG16 avec un seul LIKE '%s'. Convertis les quatre selon cette forme, recompile psql et vérifie que TAB après ALTER TAG t_ ou ALTER STORAGE SERVER s_ complète les noms sans ERROR du coordinateur. Les règles liées à COMMENT et DROP STORAGE SERVER sont distinctes et peuvent être traitées ici ou dans #2312.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Apache Cloudberry version
main
What happened
psql tab completion of object names does not work for four Cloudberry-specific object types: storage servers, tags, profiles and resource groups. Pressing TAB after ALTER STORAGE SERVER , ALTER TAG , DROP TAG , ALTER PROFILE , ALTER RESOURCE GROUP , etc. offers nothing, even when matching objects exist. Each attempt also logs a server-side ERROR on the coordinator.
Root cause. These four query macros in src/bin/psql/tab-complete.c still use the pre-PG15 template form:
Query_for_list_of_tags ... WHERE substring(pg_catalog.quote_ident(tagname),1,%d)='%s'
Query_for_list_of_resgroups ... WHERE substring(pg_catalog.quote_ident(rsgname),1,%d)='%s'
Query_for_list_of_storage_servers ... WHERE substring(pg_catalog.quote_ident(srvname),1,%d)='%s'
Query_for_list_of_profiles ... WHERE substring(pg_catalog.quote_ident(profilename),1,%d)='%s'
Upstream commit 02b8048ba5d ("psql: improve tab-complete's handling of variant SQL names", PG15) changed the template contract. _complete_from_query() now does
appendPQExpBuffer(&query_buffer, simple_query, e_object_like, e_ref_object, e_ref_schema);
and expects a single LIKE '%s'. Upstream's own macros were converted when the PG16 code was merged, but these Cloudberry-specific ones were not. As a result, %d receives a char * (undefined behavior) and %s receives the NULL e_ref_object. The generated query looks like this:
ERROR: negative substring length not allowed
STATEMENT: SELECT pg_catalog.quote_ident(srvname) FROM pg_catalog.gp_storage_server
WHERE substring(pg_catalog.quote_ident(srvname),1,-1478678816)='(null)'
When the garbage length happens to be positive, the query runs but matches nothing.
What you think should happen instead
Object names should complete. Convert the four macros to the PG16 form, as Query_for_list_of_servers already does:
#define Query_for_list_of_storage_servers \
" SELECT srvname "\
" FROM pg_catalog.gp_storage_server "\
" WHERE srvname LIKE '%s'"
The other three need the same change. The storage-server conversion has been verified: with psql rebuilt and driven through a pty, ALTER STORAGE SERVER <TAB> lists the servers, and the coordinator ERROR disappears.
How to reproduce
CREATE TAG t_demo;
CREATE PROFILE p_demo;
CREATE STORAGE SERVER s_demo OPTIONS (endpoint 'x');
In interactive psql, press TAB after each of the following. None of them completes:
ALTER TAG t_ALTER PROFILE p_ALTER STORAGE SERVER s_ALTER RESOURCE GROUP admin_
The coordinator log gets one bad query per completion attempt, against gp_storage_server, pg_tag, pg_profile and pg_resgroup, all of the substring(...,1,<garbage>)='(null)' form.
Related completion bugs for storage servers (same area)
The single-word {"SERVER", Query_for_list_of_servers} entry in words_after_create, and the generic COMMENT ON X Y → IS rule, win over the multi-word "STORAGE SERVER". This gives:
DROP STORAGE SERVER <TAB>andCREATE STORAGE USER MAPPING FOR u STORAGE SERVER <TAB>complete foreign servers (for examplegp_exttable_server).COMMENT ON STORAGE SERVER <TAB>completesISinstead of a server name.ALTER STORAGE SERVER s <TAB>offersRENAME TO, but the grammar has no such form.
The following additions were verified to fix the first three cases (the user-mapping case still needs its own rule):
else if (Matches("COMMENT", "ON", "STORAGE", "SERVER"))
COMPLETE_WITH_QUERY(Query_for_list_of_storage_servers);
...
else if (Matches("DROP", "STORAGE", "SERVER") ||
Matches("DROP", "STORAGE", "SERVER", "IF", "EXISTS"))
COMPLETE_WITH_QUERY(Query_for_list_of_storage_servers);
Operating System
Linux (platform independent)
Anything else
Found while reviewing #2312. That PR touches the ALTER STORAGE SERVER <name> completion line but not the issues above. The storage-server part can be fixed there or here.
- Langage dominant
- C
- Étoiles
- 1.4k
- Forks
- 273
- Merge moyen
- 4 j 6 h
- PR mergées (30 j)
- 105
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de apache/cloudberry
-
isolation2 lockmodes fails on cassert builds: extra AccessShareLock on partition rootPeut-être pris @tuhaihe l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/cloudberry#2356 ·
Les mainteneurs répondent en général sous 2 jours
-
[Bug] Expand fails to recognize user-defined tablespacesPeut-être pris @nix-oss l’a pris il y a 92 jours. Ouvertetype: Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
apache/cloudberry#1885 · 2 réactions ·
Les mainteneurs répondent en général sous 2 jours
-
gpexpand first stage fails: 'SyncPackages' object has no attribute 'ret' (extension sync never runs; regression)Peut-être pris @talmacschen-arch l’a pris il y a 153 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
apache/cloudberry#1825 ·
Les mainteneurs répondent en général sous 2 jours
-
type: Bug
Difficulté 4/5 3-5 jours Accessibilité débutants 53/100
apache/cloudberry#2350 · 1 réaction ·
Les mainteneurs répondent en général sous 2 jours
-
Terminated by signal 6: AbortedOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
apache/cloudberry#2348 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de apache/cloudberry
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
windows-artifacts: the win-arm64 job uses a Visual Studio generator missing from windows-11-armOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
-
Add Royalty funding badgeOuverte
Difficulté 1/5 1-3 heures Accessibilité débutants 78/100
crosspoint-reader/crosspoint-reader#4535 ·
Les mainteneurs répondent en général sous 1 jour
-
[core] Clients never advertise RNS_UD_CS_SUPPORT_ERRINFO_PDU, so a conforming server can't send them Set Error InfoPeut-être pris @akallabeth l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
FreeRDP/FreeRDP#14230 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Wrong release linkedOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
Genymobile/scrcpy#7178 ·
Les mainteneurs répondent en général sous 3 jours