parse mistake in ecpg connect string

Поиск
Список
Период
Сортировка
От Wang, Shenhao
Тема parse mistake in ecpg connect string
Дата
Msg-id ae52a416bbbf459c96bab30b3038e06c@G08CNEXMBPEKD06.g08.fujitsu.local
обсуждение исходный текст
Ответы Re: parse mistake in ecpg connect string
RE: parse mistake in ecpg connect string
Список pgsql-hackers
Hi, hacker

I found in function ECPGconnect, the connect string in comment is written as:

/*------
 * new style:
 *    <tcp|unix>:postgresql://server[:port|:/unixsocket/path:]
 *    [/db-name][?options]
 *------
*/

But, the parse logical seems wrong, like:

tmp = strrchr(dbname + offset, ':');
tmp2 = strchr(tmp + 1, ':')

the value tmp2 will always be NULL, the unix-socket path will be ignored.

I have fixed this problem, the patch attached.
However, since this usage is not recorded in manual[1](maybe this is why this problem is not found for a long time), so
howabout delete this source directly instead? 
Thoughts?

This patch only fix the problem when using a character variable to store the connect string like:

EXEC SQL BEGIN DECLARE SECTION;
    char constr[] = "unix:postgresql://localhost:/tmp/a:?port=5435&dbname=postgres";
EXEC SQL END DECLARE SECTION;

If I write a source like:
EXEC SQL CONNECT TO unix:postgresql://localhost:/tmp/a:/postgres?port=5435
EXEC SQL CONNECT TO unix:postgresql://localhost/postgres?host=/tmp/a&port=5435
The program ecpg will report some error when parse .pgc file

I will try to fix this problem later, but it seems a little difficult to add some lex/bison file rules

[1] https://www.postgresql.org/docs/13/ecpg-connect.html#ECPG-CONNECTING

Best regards
Shenhao Wang



Вложения

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

Предыдущее
От: Peter Smith
Дата:
Сообщение: Re: pg_replication_origin_drop API potential race condition
Следующее
От: Amit Langote
Дата:
Сообщение: Re: making update/delete of inheritance trees scale better