Re: Variable substitution in psql backtick expansion

Поиск
Список
Период
Сортировка
От Corey Huinker
Тема Re: Variable substitution in psql backtick expansion
Дата
Msg-id CADkLM=c+hm2rc0tkKgC-ZgrLttHT2KkfppE+BC-=i-xj+7V-TQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Variable substitution in psql backtick expansion  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: Variable substitution in psql backtick expansion
Список pgsql-hackers
On Sun, Apr 2, 2017 at 12:29 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:

Hello Corey,

I'm anxious to help with these patches, but they seem a bit of a moving
target. Happy to jump in and review as soon as we've settled on what should
be done.

The "v3" I sent basically adds both client & server version numbers in client-side variables, basically same code as suggested by Pavel for the server version, and some documentation.

patch applies via patch -p1

Works as advertised.
# \echo SERVER_VERSION_NAME
SERVER_VERSION_NAME
# \echo :SERVER_VERSION_NAME
10.0
# \echo :SERVER_VERSION_NUM
100000
# \echo :VERSION_NUM
100000

The new documentation is clear, and accurately reflects current name style.

Looking at #define STRINGIFY(), I got curious where else STRINGIFY was used:

$ git grep STRINGIFY
src/bin/psql/startup.c:#define STRINGIFY2(symbol) #symbol
src/bin/psql/startup.c:#define STRINGIFY(symbol) STRINGIFY2(symbol)
src/bin/psql/startup.c: SetVariable(pset.vars, "VERSION_NUM", STRINGIFY(PG_VERSION_NUM));
src/tools/msvc/Solution.pm:s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY(z)\n#define PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, compiled by Visual C++ build " __STRINGIFY2(_MSC_VER) ", $bits-bit"};

Without digging too deep, it seems like the redefinition wouldn't be harmful, but it might make sense to not use the name STRINGIFY() if only to avoid confusion with Solution.pm.



The questions are:

 - which version should be provided (10.0 100000 ...)

A fixed length string without decimals seems best for the multitude of tools that will want to manipulate that data.

 
 - how should they be named?

   In v3 there is VERSION{,_NAME,_NUM} for client and
   SERVER_VERSION_{NUM,NAME} or SVERSION_NUM suggested
   by Pavel for server.

SERVER_VERSION_* is good.
VERSION_* is ok. Would CLIENT_VERSION_* or PSQL_VERSION_* be better?
 
 - how desirable/useful is it to have this in 10?

Extensions and extension-ish packages will love the _NUM vars. The sooner the better.

There's a lesser need for the _NAME vars.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: Undefined psql variables
Следующее
От: "Daniel Verite"
Дата:
Сообщение: Re: Suggested fix for \p and \r in psql