psql emit WARNING if built with option --with-extra-version and the option only contains numbers

From: Jet Zhang <jet(dot)cx(dot)zhang(at)hotmail(dot)com>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: psql emit WARNING if built with option --with-extra-version and the option only contains numbers
Date: 2022-04-27 14:52:42
Message-ID: OS3PR01MB60889FA73FC6DFA50EFA0D1DD5FA9@OS3PR01MB6088.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi All,

As the doc mentioned, the --with-extra-version can be a distribution package release number. But if I build the program like below configure:

./configure --prefix=/home/zhangchenxi/Workspace/c/.build/psql --enable-debug --enable-depend --enable-cassert --with-extra-version=.54321 CFLAGS=-O0

The configure goes well, and make goes well too. All things seems OK. But when using psql to connect to database, it emit a WARNING:

psql (14.2.54321, server 14.2.54321)
WARNING: psql major version 14, server major version 19.
Some psql features might not work.
Type "help" for help.

I made a some effort, and it seems some code in src/interfaces/libpq/fe-exec.c goes wrong.


1052 cnt = sscanf(value, "%d.%d.%d", &vmaj, &vmin, &vrev);
1053
1054 if (cnt == 3)
1055 {
1056 /* old style, e.g. 9.6.1 */
1057 conn->sversion = (100 * vmaj + vmin) * 100 + vrev;
1058 }

Because the extra version STRING only contains numbers, so the cnt will be 3, and then it will be reconginized as oly style version format.
So, may be we need to do more when cnt == 3:


1052 cnt = sscanf(value, "%d.%d.%d", &vmaj, &vmin, &vrev);
1053
1054 if (cnt == 3)
1055 {
1056 if (vmaj >= 10)
1057 {
1058 /* new style, e.g. 10.1 */
1059 conn->sversion = 100 * 100 * vmaj + vmin;
1060 }
1061 else
1062 {
1063 /* old style, e.g. 9.6.1 */
1064 conn->sversion = (100 * vmaj + vmin) * 100 + vrev;
1065 }
1066 }

Am I right?

But it still not able to solve if the extra version STRING like below:

./configure --prefix=/home/zhangchenxi/Workspace/c/.build/psql --enable-debug --enable-depend --enable-cassert --with-extra-version=54321 CFLAGS=-O0

the extra version STRING 54321 with no dot (.)

psql (14.254321, server 14.254321)
WARNING: psql major version 14, server major version 39.
Some psql features might not work.
Type "help" for help.

Jet C.X. ZHANG
Halo Tech Co.,Ltd. http://www.halodbtech.com

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-04-27 15:00:31 Re: psql emit WARNING if built with option --with-extra-version and the option only contains numbers
Previous Message Dave Cramer 2022-04-27 14:47:04 Re: BUG #17467: Perf degradation after switching to latest jdbc drivers