Refactor ECPGconnect and allow IPv6 connection

From: "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: "wangsh(dot)fnst(at)fujitsu(dot)com" <wangsh(dot)fnst(at)fujitsu(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Refactor ECPGconnect and allow IPv6 connection
Date: 2021-02-24 01:42:57
Message-ID: OSBPR01MB3157652E30B2CF1D6F9E1969F59F9@OSBPR01MB3157.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Hackers,

In the previous discussion [1], we noticed that ECPG cannot accept IPv6
connection string, it means the following statement does not work well:

EXEC SQL CONNECT TO 'tcp:postgresql://::1/postgres';

This is caused because colons are gotten entangled in the ECPGconnect(),
and Wang suggests that we should support IPv6 like libpq:

> The host part may be either host name or an IP address.
> To specify an IPv6 host address, enclose it in square brackets:

The square bracket must be searched first for implementing the suggestion,
and it means some refactoring is needed for ECPGconnect().

I attached two patches, 0001 contains some refactoring, and 0002 contains
fixes for accepting IPv6. Currently the following statement can be passed:

EXEC SQL CONNECT TO 'tcp:postgresql://[::1]/postgres';

I think this is WIP, because some problems remain:

* Only an SQL literal or a host variable is acceptable.
I understand we should support other notations, but now hacking.
* parse_options() was not refactored because
it does not affect to parsing the host.
I will try it if should be.
* New parse functions are have similar part,
but I did not standardize them because approved characters
are different.

How do you think?

Best Regards,
Hayato Kuroda
FUJITSU LIMITED

Attachment Content-Type Size
v1-0001-refactor_ecpgconnect.patch application/octet-stream 16.8 KB
v1-0002-allow-IPv6.patch application/octet-stream 7.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Takashi Menjo 2021-02-24 02:03:29 Re: [PoC] Non-volatile WAL buffer
Previous Message alvherre@alvh.no-ip.org 2021-02-24 01:40:32 Re: libpq debug log