Re: BUG #18735: Specific multibyte character in psql file path command parameter for Windows - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18735: Specific multibyte character in psql file path command parameter for Windows
Date
Msg-id 2850994.1733516077@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #18735: Specific multibyte character in psql file path command parameter for Windows  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #18735: Specific multibyte character in psql file path command parameter for Windows
List pgsql-bugs
I wrote:
> Anyway, what I'm now thinking is that we can have two variants
> of canonicalize_path:
>     extern void canonicalize_path(char *path);
>     extern void canonicalize_path_enc(char *path, int encoding);
> The first one assumes a server-safe encoding, the second doesn't,
> and at least to start with only psql would bother with the second.

I thought that part would be trivial, but there's a small annoying
problem.  The obvious way to write the encoding-aware version of
the de-backslashing loop is to use pg_encoding_mblen_bounded().
However, that function is in src/common/wchar.c while path.c
is in src/port/ --- and I believe we have a rule that libpgport
can't depend on libpgcommon.  (The dependencies go the other way,
instead.)

Now it's pretty dubious that path.c is in src/port/ at all, because
it does not meet the expectation that that directory is for
functions that replace missing system-library functionality.
(We've trodden pretty hard on that expectation over the years,
but whatever.)  So one reasonable fix could be to move path.c
to src/common, but I'm concerned that that would be unsafe to
back-patch.  Also, we'd really want to move the externs for
path.c out of port.h, which would cause additional code churn
for callers.

Another way, given that we only really need this to work for
SJIS, is to hard-wire the logic into path.c --- it's not like
pg_sjis_mblen is either long or likely to change.  That's
ugly but would be a lot less invasive and safer to back-patch.

I'm leaning a bit to the second way, mainly because of the
extern-relocation annoyance.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18735: Specific multibyte character in psql file path command parameter for Windows
Next
From: Tom Lane
Date:
Subject: Re: Dangling operator family after DROP TYPE