pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
CR is not removed with psql -f command on Windows.
3+ messages / 2 participants
[nested] [flat]

* CR is not removed with psql -f command on Windows.
@ 2021-05-27 09:09 okano.naoki@fujitsu.com <okano.naoki@fujitsu.com>
  2021-05-27 13:56 ` Re: CR is not removed with psql -f command on Windows. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: okano.naoki@fujitsu.com @ 2021-05-27 09:09 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi,

I am using Windows OS.
When creating a function with the psql -f filename command, the prosrc in pg_proc catalog contains \r(CR).
But I expect \r to be deleted. Is this a bug?
# If I use the psql < test.sql command, the prosrc in pg_proc catalog does not contain \r(CR). 

[Environment]
* Windows 10
* PostgreSQL 13.3, compiled by Visual C + build 1914, 64 bit

[Reproduction]
(1) Create test.sql describing the following (The newline is CRLF)

CREATE OR REPLACE FUNCTION test_func(i integer) RETURNS integer AS $$
  BEGIN
    RETURN i + 1;
  END;
$$ LANGUAGE plpgsql;

(2) psql -f test.sql

(3) psql -c "SELECT proname, prosrc FROM pg_proc WHERE proname = 'test_func';" 
The result of (3) above contains \r in the prosrc in pg_proc.

  proname  |       prosrc
-----------+---------------------
 test_func | \r                 +
           |   BEGIN\r          +
           |     RETURN i + 1;\r+
           |   END;\r           +

I found a similar bug report below.
Is it related to this problem?
* https://www.postgresql.org/message-id/flat/20201028204654.GD3239%40momjian.us#1b2a2672d66aa6f10225a2...

Regards,
Naoki, Okano





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

* Re: CR is not removed with psql -f command on Windows.
  2021-05-27 09:09 CR is not removed with psql -f command on Windows. okano.naoki@fujitsu.com <okano.naoki@fujitsu.com>
@ 2021-05-27 13:56 ` Tom Lane <tgl@sss.pgh.pa.us>
  2021-05-28 10:51   ` RE: CR is not removed with psql -f command on Windows. okano.naoki@fujitsu.com <okano.naoki@fujitsu.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2021-05-27 13:56 UTC (permalink / raw)
  To: okano.naoki@fujitsu.com <okano.naoki@fujitsu.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

"okano.naoki@fujitsu.com" <okano.naoki@fujitsu.com> writes:
> When creating a function with the psql -f filename command, the prosrc in pg_proc catalog contains \r(CR).

Does that cause you any actual problems?

> But I expect \r to be deleted. Is this a bug?

I'm kind of inclined to ignore it, mainly because of the law of unintended
consequences: adding code to strip \r is likely to break some scenario
that's working fine for somebody else.

I see that psql opens -f files with PG_BINARY_R, but that seems to be
a very ancient decision so I'm hesitant to change it.

			regards, tom lane





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

* RE: CR is not removed with psql -f command on Windows.
  2021-05-27 09:09 CR is not removed with psql -f command on Windows. okano.naoki@fujitsu.com <okano.naoki@fujitsu.com>
  2021-05-27 13:56 ` Re: CR is not removed with psql -f command on Windows. Tom Lane <tgl@sss.pgh.pa.us>
@ 2021-05-28 10:51   ` okano.naoki@fujitsu.com <okano.naoki@fujitsu.com>
  0 siblings, 0 replies; 3+ messages in thread

From: okano.naoki@fujitsu.com @ 2021-05-28 10:51 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Thank you for your reply.

From:   Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> > When creating a function with the psql -f filename command, the prosrc in pg_proc catalog contains \r(CR).
>
> Does that cause you any actual problems?

There is actual no problem.
However, I was puzzled by the difference between psql -f and psql < .

> > But I expect \r to be deleted. Is this a bug?
> 
> I'm kind of inclined to ignore it, mainly because of the law of unintended
> consequences: adding code to strip \r is likely to break some scenario
> that's working fine for somebody else.
> 
> I see that psql opens -f files with PG_BINARY_R, but that seems to be
> a very ancient decision so I'm hesitant to change it

As you said, changing to remove \r will affect somebody, 
so I understand changing the behavior is difficult.

I think it is not necessary to change the mode from PG_BINARY_R,
because it is enough to remove \r in gets_fromFile() function in src/bin/psql/input.c.

Regards,
Naoki, Okano





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


end of thread, other threads:[~2021-05-28 10:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 09:09 CR is not removed with psql -f command on Windows. okano.naoki@fujitsu.com <okano.naoki@fujitsu.com>
2021-05-27 13:56 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-05-28 10:51   ` okano.naoki@fujitsu.com <okano.naoki@fujitsu.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