Skip to content

Commit cf0cab8

Browse files
committed
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
1 parent c49d926 commit cf0cab8

File tree

5 files changed

+261
-815
lines changed

5 files changed

+261
-815
lines changed

src/bin/psql/command.c

+10-46
Original file line numberDiff line numberDiff line change
@@ -1103,21 +1103,7 @@ exec_command_ef_ev(PsqlScanState scan_state, bool active_branch,
11031103
NULL, true);
11041104
int lineno = -1;
11051105

1106-
if (pset.sversion < (is_func ? 80400 : 70400))
1107-
{
1108-
char sverbuf[32];
1109-
1110-
formatPGVersionNumber(pset.sversion, false,
1111-
sverbuf, sizeof(sverbuf));
1112-
if (is_func)
1113-
pg_log_error("The server (version %s) does not support editing function source.",
1114-
sverbuf);
1115-
else
1116-
pg_log_error("The server (version %s) does not support editing view definitions.",
1117-
sverbuf);
1118-
status = PSQL_CMD_ERROR;
1119-
}
1120-
else if (!query_buf)
1106+
if (!query_buf)
11211107
{
11221108
pg_log_error("no query buffer");
11231109
status = PSQL_CMD_ERROR;
@@ -2418,21 +2404,7 @@ exec_command_sf_sv(PsqlScanState scan_state, bool active_branch,
24182404
buf = createPQExpBuffer();
24192405
obj_desc = psql_scan_slash_option(scan_state,
24202406
OT_WHOLE_LINE, NULL, true);
2421-
if (pset.sversion < (is_func ? 80400 : 70400))
2422-
{
2423-
char sverbuf[32];
2424-
2425-
formatPGVersionNumber(pset.sversion, false,
2426-
sverbuf, sizeof(sverbuf));
2427-
if (is_func)
2428-
pg_log_error("The server (version %s) does not support showing function source.",
2429-
sverbuf);
2430-
else
2431-
pg_log_error("The server (version %s) does not support showing view definitions.",
2432-
sverbuf);
2433-
status = PSQL_CMD_ERROR;
2434-
}
2435-
else if (!obj_desc)
2407+
if (!obj_desc)
24362408
{
24372409
if (is_func)
24382410
pg_log_error("function name is required");
@@ -3611,7 +3583,12 @@ connection_warnings(bool in_startup)
36113583
else if (in_startup)
36123584
printf("%s (%s)\n", pset.progname, PG_VERSION);
36133585

3614-
if (pset.sversion / 100 > client_ver / 100)
3586+
/*
3587+
* Warn if server's major version is newer than ours, or if server
3588+
* predates our support cutoff (currently 9.2).
3589+
*/
3590+
if (pset.sversion / 100 > client_ver / 100 ||
3591+
pset.sversion < 90200)
36153592
printf(_("WARNING: %s major version %s, server major version %s.\n"
36163593
" Some psql features might not work.\n"),
36173594
pset.progname,
@@ -5271,8 +5248,7 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
52715248
* ensure the right view gets replaced. Also, check relation kind
52725249
* to be sure it's a view.
52735250
*
5274-
* Starting with 9.2, views may have reloptions (security_barrier)
5275-
* and from 9.4 onwards they may also have WITH [LOCAL|CASCADED]
5251+
* Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
52765252
* CHECK OPTION. These are not part of the view definition
52775253
* returned by pg_get_viewdef() and so need to be retrieved
52785254
* separately. Materialized views (introduced in 9.3) may have
@@ -5291,24 +5267,12 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
52915267
"ON c.relnamespace = n.oid WHERE c.oid = %u",
52925268
oid);
52935269
}
5294-
else if (pset.sversion >= 90200)
5295-
{
5296-
printfPQExpBuffer(query,
5297-
"SELECT nspname, relname, relkind, "
5298-
"pg_catalog.pg_get_viewdef(c.oid, true), "
5299-
"c.reloptions AS reloptions, "
5300-
"NULL AS checkoption "
5301-
"FROM pg_catalog.pg_class c "
5302-
"LEFT JOIN pg_catalog.pg_namespace n "
5303-
"ON c.relnamespace = n.oid WHERE c.oid = %u",
5304-
oid);
5305-
}
53065270
else
53075271
{
53085272
printfPQExpBuffer(query,
53095273
"SELECT nspname, relname, relkind, "
53105274
"pg_catalog.pg_get_viewdef(c.oid, true), "
5311-
"NULL AS reloptions, "
5275+
"c.reloptions AS reloptions, "
53125276
"NULL AS checkoption "
53135277
"FROM pg_catalog.pg_class c "
53145278
"LEFT JOIN pg_catalog.pg_namespace n "

src/bin/psql/common.c

+7-20
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,6 @@ SendQuery(const char *query)
12001200
bool OK = false;
12011201
int i;
12021202
bool on_error_rollback_savepoint = false;
1203-
static bool on_error_rollback_warning = false;
12041203

12051204
if (!pset.db)
12061205
{
@@ -1264,28 +1263,16 @@ SendQuery(const char *query)
12641263
(pset.cur_cmd_interactive ||
12651264
pset.on_error_rollback == PSQL_ERROR_ROLLBACK_ON))
12661265
{
1267-
if (on_error_rollback_warning == false && pset.sversion < 80000)
1268-
{
1269-
char sverbuf[32];
1270-
1271-
pg_log_warning("The server (version %s) does not support savepoints for ON_ERROR_ROLLBACK.",
1272-
formatPGVersionNumber(pset.sversion, false,
1273-
sverbuf, sizeof(sverbuf)));
1274-
on_error_rollback_warning = true;
1275-
}
1276-
else
1266+
results = PQexec(pset.db, "SAVEPOINT pg_psql_temporary_savepoint");
1267+
if (PQresultStatus(results) != PGRES_COMMAND_OK)
12771268
{
1278-
results = PQexec(pset.db, "SAVEPOINT pg_psql_temporary_savepoint");
1279-
if (PQresultStatus(results) != PGRES_COMMAND_OK)
1280-
{
1281-
pg_log_info("%s", PQerrorMessage(pset.db));
1282-
ClearOrSaveResult(results);
1283-
ResetCancelConn();
1284-
goto sendquery_cleanup;
1285-
}
1269+
pg_log_info("%s", PQerrorMessage(pset.db));
12861270
ClearOrSaveResult(results);
1287-
on_error_rollback_savepoint = true;
1271+
ResetCancelConn();
1272+
goto sendquery_cleanup;
12881273
}
1274+
ClearOrSaveResult(results);
1275+
on_error_rollback_savepoint = true;
12891276
}
12901277

12911278
if (pset.gdesc_flag)

0 commit comments

Comments
 (0)