Strip Windows newlines from extension script files manually.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 28 Oct 2024 17:07:29 +0000 (13:07 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 28 Oct 2024 17:07:32 +0000 (13:07 -0400)
commit6cfb3a33746990602c790199adc2debb2c4bbb87
tree994f22433618a35359707389cf39694e70416df2
parent8a98822bcc37c03baf44ec39d8e88d9c24647b9d
Strip Windows newlines from extension script files manually.

Revert commit 924e03917 in favor of adding code to convert \r\n to \n
explicitly, on Windows only.  The idea of letting text mode do the
work fails for a couple of reasons:

* Per Microsoft documentation, text mode also causes control-Z to be
interpreted as end-of-file.  While it may be unlikely that extension
scripts contain control-Z, we've historically allowed it, and breaking
the case doesn't seem wise.

* Apparently, on some Windows configurations, "r" mode is interpreted
as binary not text mode.  We could force it with "rt" but that would
be inconsistent with our code elsewhere, and it would still require
Windows-specific coding.

Thanks to Alexander Lakhin for investigation.

Discussion: https://postgr.es/m/79284195-4993-7b00-f6df-8db28ca60fa3@gmail.com
src/backend/commands/extension.c