pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: buildfarm@sraoss.co.jp, Pavel Stehule <pavel.stehule@gmail.com>
Cc: Christoph Berg <myon@debian.org>
Cc: Michael Banck <mbanck@gmx.net>
Cc: Tommy Pavlicek <tommypav122@gmail.com>
Cc: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: pgsql-hackers@lists.postgresql.org
Cc: jian.universality@gmail.com
Subject: Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)
Date: Mon, 28 Oct 2024 22:00:00 +0300
Message-ID: <f2e9506f-c0f3-4483-9f7b-711f9165f5b0@gmail.com> (raw)
In-Reply-To: <3975515.1730131606@sss.pgh.pa.us>
References: <CAEhP-W_1bMTLan2LtzS+xr=b-Wep56gw+OoirABQ8b2aOw+5yg@mail.gmail.com>
	<560086.1698160614@sss.pgh.pa.us>
	<ZTfjXzOKFI9AawJF@msg.df7cb.de>
	<570833.1698162135@sss.pgh.pa.us>
	<66f33840.050a0220.1f9e60.7fb9@mx.google.com>
	<ZvV1ClhnbJLCz7Sm@msg.df7cb.de>
	<325394.1727365907@sss.pgh.pa.us>
	<ZvaiS57G10dITjQm@msg.df7cb.de>
	<571930.1727454668@sss.pgh.pa.us>
	<Zvbr5zv78AfhB83S@msg.df7cb.de>
	<621972.1727459684@sss.pgh.pa.us>
	<1092841.1727552736@sss.pgh.pa.us>
	<2245576.1728418678@sss.pgh.pa.us>
	<CAFj8pRBGquZK3aTYvN559FFqa=bMXEuxZZBLc6kMd671u62hTQ@mail.gmail.com>
	<2864637.1728662904@sss.pgh.pa.us>
	<CAFj8pRCF2-ObuMHV5sxQbq9sZ+hCv5mV5SUToD8=9Qw8tZ7DgQ@mail.gmail.com>
	<CAFj8pRCw09RUROc31nJCZBPXrO5fxaDO-Lg885eXMUPwjBZNSw@mail.gmail.com>
	<1967263.1729611423@sss.pgh.pa.us>
	<CAFj8pRCtFo2jyJAjXpzB8Rg=mtPXfS44bp2gM4Ea-iRD-wA9Xw@mail.gmail.com>
	<2480333.1729784872@sss.pgh.pa.us>
	<3792414.1730050914@sss.pgh.pa.us>
	<79284195-4993-7b00-f6df-8db28ca60fa3@gmail.co! m>
	<3975515.1730131606@sss.pgh.pa.us>

28.10.2024 19:06, Tom Lane wrote:
>> I've also dumped buf in read_whole_file() and found that in both
>> PG_BINARY_R and "r" modes the 0d 0a ending is preserved. But it changed
>> to 0a with the "rt" mode (see [1]), and it makes the test (and the whole
>> `meson test`) pass for me.
> Interesting.  I believe we decided years ago that we didn't need to
> use "rt" mode because that was the default on Windows, but was that
> a misreading of the documentation?  The link you provided doesn't
> give any hint that there are more than two behaviors.
>
> However ... the link you provided also mentions that text mode
> includes treating control-Z as EOF; which I'd forgotten, but it
> does make it less safe than I thought to use text mode for
> reading script files.

I think that this other behavior can be explained by pgwin32_fopen()/
pgwin32_open() coding (O_TEXT assumed implicitly only #ifdef FRONTEND).

Anyway, as you noticed, \x1A injected into test_ext....sql really leads to
the file contents truncation on read (with "rt"), so I agree that using the
text/translation mode here is not an improvement.

> What I'm now thinking is that we should revert 924e03917 after
> all (that is, go back to using PG_BINARY_R) and instead make
> read_whole_file manually squash \r\n to \n if we're on Windows.
> Ugly, but I have yet to find anything about that platform that
> isn't.

Yes, I think this should help.

Best regards,
Alexander





view thread (27+ messages)

Message-ID: <f2e9506f-c0f3-4483-9f7b-711f9165f5b0@gmail.com>
Permalink:  ../f2e9506f-c0f3-4483-9f7b-711f9165f5b0@gmail.com/
Also on:    postgresql.org/message-id/f2e9506f-c0f3-4483-9f7b-711f9165f5b0@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: exclusion@gmail.com, tgl@sss.pgh.pa.us, andrew@dunslane.net, pavel.stehule@gmail.com, myon@debian.org, mbanck@gmx.net, tommypav122@gmail.com, ilmari@ilmari.org, pgsql-hackers@lists.postgresql.org, jian.universality@gmail.com
  Subject: Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)
  In-Reply-To: <f2e9506f-c0f3-4483-9f7b-711f9165f5b0@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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