Remove psql support for server versions preceding 9.2.

Per discussion, we'll limit support for old servers to those branches
that can still be built easily on modern platforms, which as of now
is 9.2 and up.

Aside from removing code that is dead per the assumption of
server >= 9.2, I tweaked the startup warning for unsupported versions
to complain about too-old servers as well as too-new ones.  The
warning that "Some psql features might not work" applies precisely
to both cases.

Discussion: https://postgr.es/m/2923349.1634942313@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2021-12-16 14:02:28 -05:00
parent c49d926833
commit cf0cab868a
5 changed files with 259 additions and 813 deletions

View File

@ -1103,21 +1103,7 @@ exec_command_ef_ev(PsqlScanState scan_state, bool active_branch,
NULL, true); NULL, true);
int lineno = -1; int lineno = -1;
if (pset.sversion < (is_func ? 80400 : 70400)) if (!query_buf)
{
char sverbuf[32];
formatPGVersionNumber(pset.sversion, false,
sverbuf, sizeof(sverbuf));
if (is_func)
pg_log_error("The server (version %s) does not support editing function source.",
sverbuf);
else
pg_log_error("The server (version %s) does not support editing view definitions.",
sverbuf);
status = PSQL_CMD_ERROR;
}
else if (!query_buf)
{ {
pg_log_error("no query buffer"); pg_log_error("no query buffer");
status = PSQL_CMD_ERROR; status = PSQL_CMD_ERROR;
@ -2418,21 +2404,7 @@ exec_command_sf_sv(PsqlScanState scan_state, bool active_branch,
buf = createPQExpBuffer(); buf = createPQExpBuffer();
obj_desc = psql_scan_slash_option(scan_state, obj_desc = psql_scan_slash_option(scan_state,
OT_WHOLE_LINE, NULL, true); OT_WHOLE_LINE, NULL, true);
if (pset.sversion < (is_func ? 80400 : 70400)) if (!obj_desc)
{
char sverbuf[32];
formatPGVersionNumber(pset.sversion, false,
sverbuf, sizeof(sverbuf));
if (is_func)
pg_log_error("The server (version %s) does not support showing function source.",
sverbuf);
else
pg_log_error("The server (version %s) does not support showing view definitions.",
sverbuf);
status = PSQL_CMD_ERROR;
}
else if (!obj_desc)
{ {
if (is_func) if (is_func)
pg_log_error("function name is required"); pg_log_error("function name is required");
@ -3611,7 +3583,12 @@ connection_warnings(bool in_startup)
else if (in_startup) else if (in_startup)
printf("%s (%s)\n", pset.progname, PG_VERSION); printf("%s (%s)\n", pset.progname, PG_VERSION);
if (pset.sversion / 100 > client_ver / 100) /*
* Warn if server's major version is newer than ours, or if server
* predates our support cutoff (currently 9.2).
*/
if (pset.sversion / 100 > client_ver / 100 ||
pset.sversion < 90200)
printf(_("WARNING: %s major version %s, server major version %s.\n" printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"), " Some psql features might not work.\n"),
pset.progname, pset.progname,
@ -5271,8 +5248,7 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind * ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view. * to be sure it's a view.
* *
* Starting with 9.2, views may have reloptions (security_barrier) * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
* and from 9.4 onwards they may also have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition * CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved * returned by pg_get_viewdef() and so need to be retrieved
* separately. Materialized views (introduced in 9.3) may have * separately. Materialized views (introduced in 9.3) may have
@ -5291,24 +5267,12 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"ON c.relnamespace = n.oid WHERE c.oid = %u", "ON c.relnamespace = n.oid WHERE c.oid = %u",
oid); oid);
} }
else if (pset.sversion >= 90200)
{
printfPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
"c.reloptions AS reloptions, "
"NULL AS checkoption "
"FROM pg_catalog.pg_class c "
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
}
else else
{ {
printfPQExpBuffer(query, printfPQExpBuffer(query,
"SELECT nspname, relname, relkind, " "SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), " "pg_catalog.pg_get_viewdef(c.oid, true), "
"NULL AS reloptions, " "c.reloptions AS reloptions, "
"NULL AS checkoption " "NULL AS checkoption "
"FROM pg_catalog.pg_class c " "FROM pg_catalog.pg_class c "
"LEFT JOIN pg_catalog.pg_namespace n " "LEFT JOIN pg_catalog.pg_namespace n "

View File

@ -1200,7 +1200,6 @@ SendQuery(const char *query)
bool OK = false; bool OK = false;
int i; int i;
bool on_error_rollback_savepoint = false; bool on_error_rollback_savepoint = false;
static bool on_error_rollback_warning = false;
if (!pset.db) if (!pset.db)
{ {
@ -1264,28 +1263,16 @@ SendQuery(const char *query)
(pset.cur_cmd_interactive || (pset.cur_cmd_interactive ||
pset.on_error_rollback == PSQL_ERROR_ROLLBACK_ON)) pset.on_error_rollback == PSQL_ERROR_ROLLBACK_ON))
{ {
if (on_error_rollback_warning == false && pset.sversion < 80000) results = PQexec(pset.db, "SAVEPOINT pg_psql_temporary_savepoint");
if (PQresultStatus(results) != PGRES_COMMAND_OK)
{ {
char sverbuf[32]; pg_log_info("%s", PQerrorMessage(pset.db));
pg_log_warning("The server (version %s) does not support savepoints for ON_ERROR_ROLLBACK.",
formatPGVersionNumber(pset.sversion, false,
sverbuf, sizeof(sverbuf)));
on_error_rollback_warning = true;
}
else
{
results = PQexec(pset.db, "SAVEPOINT pg_psql_temporary_savepoint");
if (PQresultStatus(results) != PGRES_COMMAND_OK)
{
pg_log_info("%s", PQerrorMessage(pset.db));
ClearOrSaveResult(results);
ResetCancelConn();
goto sendquery_cleanup;
}
ClearOrSaveResult(results); ClearOrSaveResult(results);
on_error_rollback_savepoint = true; ResetCancelConn();
goto sendquery_cleanup;
} }
ClearOrSaveResult(results);
on_error_rollback_savepoint = true;
} }
if (pset.gdesc_flag) if (pset.gdesc_flag)

File diff suppressed because it is too large Load Diff

View File

@ -277,28 +277,15 @@ do_lo_list(void)
char buf[1024]; char buf[1024];
printQueryOpt myopt = pset.popt; printQueryOpt myopt = pset.popt;
if (pset.sversion >= 90000) snprintf(buf, sizeof(buf),
{ "SELECT oid as \"%s\",\n"
snprintf(buf, sizeof(buf), " pg_catalog.pg_get_userbyid(lomowner) as \"%s\",\n"
"SELECT oid as \"%s\",\n" " pg_catalog.obj_description(oid, 'pg_largeobject') as \"%s\"\n"
" pg_catalog.pg_get_userbyid(lomowner) as \"%s\",\n" " FROM pg_catalog.pg_largeobject_metadata "
" pg_catalog.obj_description(oid, 'pg_largeobject') as \"%s\"\n" " ORDER BY oid",
" FROM pg_catalog.pg_largeobject_metadata " gettext_noop("ID"),
" ORDER BY oid", gettext_noop("Owner"),
gettext_noop("ID"), gettext_noop("Description"));
gettext_noop("Owner"),
gettext_noop("Description"));
}
else
{
snprintf(buf, sizeof(buf),
"SELECT loid as \"%s\",\n"
" pg_catalog.obj_description(loid, 'pg_largeobject') as \"%s\"\n"
"FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) x\n"
"ORDER BY 1",
gettext_noop("ID"),
gettext_noop("Description"));
}
res = PSQLexec(buf); res = PSQLexec(buf);
if (!res) if (!res)

View File

@ -993,7 +993,7 @@ Query_for_index_of_table \
/* /*
* These object types were introduced later than our support cutoff of * These object types were introduced later than our support cutoff of
* server version 7.4. We use the VersionedQuery infrastructure so that * server version 9.2. We use the VersionedQuery infrastructure so that
* we don't send certain-to-fail queries to older servers. * we don't send certain-to-fail queries to older servers.
*/ */
@ -2911,7 +2911,7 @@ psql_completion(const char *text, int start, int end)
Matches("CREATE", "OR", "REPLACE", "TRANSFORM")) Matches("CREATE", "OR", "REPLACE", "TRANSFORM"))
COMPLETE_WITH("FOR"); COMPLETE_WITH("FOR");
else if (Matches("CREATE", "TRANSFORM", "FOR") || else if (Matches("CREATE", "TRANSFORM", "FOR") ||
Matches("CREATE","OR", "REPLACE", "TRANSFORM", "FOR")) Matches("CREATE", "OR", "REPLACE", "TRANSFORM", "FOR"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
else if (Matches("CREATE", "TRANSFORM", "FOR", MatchAny) || else if (Matches("CREATE", "TRANSFORM", "FOR", MatchAny) ||
Matches("CREATE", "OR", "REPLACE", "TRANSFORM", "FOR", MatchAny)) Matches("CREATE", "OR", "REPLACE", "TRANSFORM", "FOR", MatchAny))