Re: Variable substitution in psql backtick expansion

Gerdan Rezende dos Santos <gerdan@gmail.com>

From: Gerdan Santos <gerdan@gmail.com>
To: pgsql-hackers@postgresql.org
Cc: Fabien Coelho <postgresql.org@coelho.net>
Date: 2017-09-16T14:23:10Z
Lists: pgsql-hackers
The following review has been posted through the commitfest application:
make installcheck-world:  not tested
Implements feature:       not tested
Spec compliant:           not tested
Documentation:            tested, passed

When i try apply this patch he failed with a following messenger:

File to patch: /src/postgresql/src/bin/psql/command.c
patching file /src/postgresql/src/bin/psql/command.c
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 succeeded at 3209 (offset -128 lines).
Hunk #2 FAILED at 3348.
Hunk #3 succeeded at 3252 (offset -128 lines).
1 out of 3 hunks FAILED -- saving rejects to file /src/postgresql/src/bin/psql/command.c.rej
(Stripping trailing CRs from patch; use --binary to disable.)
can't find file to patch at input line 91
Perhaps you should have used the -p or --strip option?
The text leading up to this was:



postgres@pgdev:/src/postgresql/src/bin/psql$ cat /src/postgresql/src/bin/psql/command.c.rej
--- command.c
+++ command.c
@@ -3348,20 +3345,6 @@ SyncVariables(void)
 	SetVariable(pset.vars, "PORT", PQport(pset.db));
 	SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
 
-	/* this bit should match connection_warnings(): */
-	/* Try to get full text form of version, might include "devel" etc */
-	server_version = PQparameterStatus(pset.db, "server_version");
-	/* Otherwise fall back on pset.sversion for servers prior 7.4 */
-	if (!server_version)
-	{
-		formatPGVersionNumber(pset.sversion, true, vbuf, sizeof(vbuf));
-		server_version = vbuf;
-	}
-	SetVariable(pset.vars, "SERVER_VERSION_NAME", server_version);
-
-	snprintf(vbuf, sizeof(vbuf), "%d", pset.sversion);
-	SetVariable(pset.vars, "SERVER_VERSION_NUM", vbuf);
-
 	/* send stuff to it, too */
 	PQsetErrorVerbosity(pset.db, pset.verbosity);
 	PQsetErrorContextVisibility(pset.db, pset.show_context);

Commits

  1. Add psql variables showing server version and psql version.

  2. Reformat psql's --help=variables output.

  3. Remove reinvention of stringify macro.

  4. Allow psql variable substitution to occur in backtick command strings.