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

Started by Jet Zhangalmost 4 years ago3 messagesbugs
Jump to latest
#1Jet Zhang
jet.cx.zhang@hotmail.com

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jet Zhang (#1)
Re: psql emit WARNING if built with option --with-extra-version and the option only contains numbers

Jet Zhang <jet.cx.zhang@hotmail.com> writes:

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

Don't do that. As you found out, you'll confuse client programs that
think that three-part version numbers are old-style PG versions.
Use some other format for the extra version, perhaps with a dash or
underscore first.

regards, tom lane

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Jet Zhang (#1)
Re: psql emit WARNING if built with option --with-extra-version and the option only contains numbers

On Wed, Apr 27, 2022 at 7:52 AM Jet Zhang <jet.cx.zhang@hotmail.com> wrote:

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

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.

./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.

My recollection is most people specify --with-extra-version= by having a
leading hyphen.

14.2-54321
Maybe we need to document and enforce this convention (or, at least,
enforce the first character cannot be period or a number).

David J.