diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index a09c49d..6e069c9 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -982,6 +982,28 @@ static const SchemaQuery Query_for_list_of_statistics = {
 "       and pg_catalog.pg_table_is_visible(c2.oid)"\
 "       and c2.relispartition = 'true'"
 
+#define Query_for_list_of_selectable_functions_or_attributes \
+" SELECT DISTINCT expansion FROM ( "\
+"   SELECT pg_catalog.quote_ident(proname)||'(' AS expansion, proname AS name "\
+"     FROM pg_catalog.pg_proc "\
+"    WHERE pg_catalog.pg_function_is_visible(oid) "\
+"      AND NOT proisagg AND NOT proiswindow AND proname NOT LIKE 'RI_FKey_%%' "\
+"      AND oid NOT IN (SELECT unnest(array[typinput,typoutput,typreceive,typsend,typmodin,typmodout,typanalyze]) FROM pg_type) "\
+"      AND oid NOT IN (SELECT unnest(array[aggtransfn,aggfinalfn,aggcombinefn,aggserialfn,aggdeserialfn,aggmtransfn,aggminvtransfn,aggmfinalfn]) FROM pg_aggregate) "\
+"      AND oid NOT IN (SELECT unnest(array[oprcode,oprrest,oprjoin]) FROM pg_operator) "\
+"      AND oid NOT IN (SELECT unnest(array[lanplcallfoid,laninline,lanvalidator]) FROM pg_language) "\
+"      AND oid NOT IN (SELECT castfunc FROM pg_cast) "\
+"      AND oid NOT IN (SELECT protransform FROM pg_proc) "\
+"      AND oid NOT IN (SELECT amhandler FROM pg_am) "\
+"      AND oid NOT IN (SELECT amproc FROM pg_amproc) "\
+"    UNION ALL "\
+"   SELECT pg_catalog.quote_ident(attname), attname "\
+"     FROM pg_catalog.pg_attribute "\
+"    WHERE attnum > 0 "\
+"      AND NOT attisdropped "\
+"   ) ss "\
+"  WHERE substring(pg_catalog.quote_ident(name),1,%d)='%s'"
+
 /*
  * This is a list of all "things" in Pgsql, which can show up after CREATE or
  * DROP; and there is also a query to get a list of them.
@@ -3172,7 +3194,10 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_CONST("IS");
 
 /* SELECT */
-	/* naah . . . */
+	else if (Matches1("SELECT"))
+	{
+		COMPLETE_WITH_QUERY(Query_for_list_of_selectable_functions_or_attributes);
+	}
 
 /* SET, RESET, SHOW */
 	/* Complete with a variable name */
