pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
psql emit WARNING if built with option --with-extra-version and the option only contains numbers
3+ messages / 3 participants
[nested] [flat]

* psql emit WARNING if built with option --with-extra-version and the option only contains numbers
@ 2022-04-27 14:52  Jet Zhang <jet.cx.zhang@hotmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Jet Zhang @ 2022-04-27 14:52 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: psql emit WARNING if built with option --with-extra-version and the option only contains numbers
@ 2022-04-27 15:00  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jet Zhang <jet.cx.zhang@hotmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2022-04-27 15:00 UTC (permalink / raw)
  To: Jet Zhang <jet.cx.zhang@hotmail.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: psql emit WARNING if built with option --with-extra-version and the option only contains numbers
@ 2022-04-27 15:03  David G. Johnston <david.g.johnston@gmail.com>
  parent: Jet Zhang <jet.cx.zhang@hotmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: David G. Johnston @ 2022-04-27 15:03 UTC (permalink / raw)
  To: Jet Zhang <jet.cx.zhang@hotmail.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

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.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-04-27 15:03 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 14:52 psql emit WARNING if built with option --with-extra-version and the option only contains numbers Jet Zhang <jet.cx.zhang@hotmail.com>
2022-04-27 15:00 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-04-27 15:03 ` David G. Johnston <david.g.johnston@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox