mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
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:
parent
c49d926833
commit
cf0cab868a
@ -1103,21 +1103,7 @@ exec_command_ef_ev(PsqlScanState scan_state, bool active_branch,
|
||||
NULL, true);
|
||||
int lineno = -1;
|
||||
|
||||
if (pset.sversion < (is_func ? 80400 : 70400))
|
||||
{
|
||||
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)
|
||||
if (!query_buf)
|
||||
{
|
||||
pg_log_error("no query buffer");
|
||||
status = PSQL_CMD_ERROR;
|
||||
@ -2418,21 +2404,7 @@ exec_command_sf_sv(PsqlScanState scan_state, bool active_branch,
|
||||
buf = createPQExpBuffer();
|
||||
obj_desc = psql_scan_slash_option(scan_state,
|
||||
OT_WHOLE_LINE, NULL, true);
|
||||
if (pset.sversion < (is_func ? 80400 : 70400))
|
||||
{
|
||||
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 (!obj_desc)
|
||||
{
|
||||
if (is_func)
|
||||
pg_log_error("function name is required");
|
||||
@ -3611,7 +3583,12 @@ connection_warnings(bool in_startup)
|
||||
else if (in_startup)
|
||||
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"
|
||||
" Some psql features might not work.\n"),
|
||||
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
|
||||
* to be sure it's a view.
|
||||
*
|
||||
* Starting with 9.2, views may have reloptions (security_barrier)
|
||||
* and from 9.4 onwards they may also have WITH [LOCAL|CASCADED]
|
||||
* Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
|
||||
* CHECK OPTION. These are not part of the view definition
|
||||
* returned by pg_get_viewdef() and so need to be retrieved
|
||||
* 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",
|
||||
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
|
||||
{
|
||||
printfPQExpBuffer(query,
|
||||
"SELECT nspname, relname, relkind, "
|
||||
"pg_catalog.pg_get_viewdef(c.oid, true), "
|
||||
"NULL AS reloptions, "
|
||||
"c.reloptions AS reloptions, "
|
||||
"NULL AS checkoption "
|
||||
"FROM pg_catalog.pg_class c "
|
||||
"LEFT JOIN pg_catalog.pg_namespace n "
|
||||
|
@ -1200,7 +1200,6 @@ SendQuery(const char *query)
|
||||
bool OK = false;
|
||||
int i;
|
||||
bool on_error_rollback_savepoint = false;
|
||||
static bool on_error_rollback_warning = false;
|
||||
|
||||
if (!pset.db)
|
||||
{
|
||||
@ -1264,28 +1263,16 @@ SendQuery(const char *query)
|
||||
(pset.cur_cmd_interactive ||
|
||||
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_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;
|
||||
}
|
||||
pg_log_info("%s", PQerrorMessage(pset.db));
|
||||
ClearOrSaveResult(results);
|
||||
on_error_rollback_savepoint = true;
|
||||
ResetCancelConn();
|
||||
goto sendquery_cleanup;
|
||||
}
|
||||
ClearOrSaveResult(results);
|
||||
on_error_rollback_savepoint = true;
|
||||
}
|
||||
|
||||
if (pset.gdesc_flag)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -277,28 +277,15 @@ do_lo_list(void)
|
||||
char buf[1024];
|
||||
printQueryOpt myopt = pset.popt;
|
||||
|
||||
if (pset.sversion >= 90000)
|
||||
{
|
||||
snprintf(buf, sizeof(buf),
|
||||
"SELECT oid as \"%s\",\n"
|
||||
" pg_catalog.pg_get_userbyid(lomowner) as \"%s\",\n"
|
||||
" pg_catalog.obj_description(oid, 'pg_largeobject') as \"%s\"\n"
|
||||
" FROM pg_catalog.pg_largeobject_metadata "
|
||||
" ORDER BY oid",
|
||||
gettext_noop("ID"),
|
||||
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"));
|
||||
}
|
||||
snprintf(buf, sizeof(buf),
|
||||
"SELECT oid as \"%s\",\n"
|
||||
" pg_catalog.pg_get_userbyid(lomowner) as \"%s\",\n"
|
||||
" pg_catalog.obj_description(oid, 'pg_largeobject') as \"%s\"\n"
|
||||
" FROM pg_catalog.pg_largeobject_metadata "
|
||||
" ORDER BY oid",
|
||||
gettext_noop("ID"),
|
||||
gettext_noop("Owner"),
|
||||
gettext_noop("Description"));
|
||||
|
||||
res = PSQLexec(buf);
|
||||
if (!res)
|
||||
|
@ -993,7 +993,7 @@ Query_for_index_of_table \
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@ -2911,7 +2911,7 @@ psql_completion(const char *text, int start, int end)
|
||||
Matches("CREATE", "OR", "REPLACE", "TRANSFORM"))
|
||||
COMPLETE_WITH("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);
|
||||
else if (Matches("CREATE", "TRANSFORM", "FOR", MatchAny) ||
|
||||
Matches("CREATE", "OR", "REPLACE", "TRANSFORM", "FOR", MatchAny))
|
||||
|
Loading…
Reference in New Issue
Block a user