Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit504f963

Browse files
committed
Use mode "r" for popen() in psql's evaluate_backtick().
In almost all other places, we use plain "r" or "w" mode in popen()calls (the exceptions being for COPY data). This one has beenoverlooked (possibly because it's buried in a ".l" flex file?),but it's using PG_BINARY_R.Kensuke Okamura complained in bug #16688 that we fail to strip \rwhen stripping the trailing newline from a backtick result string.That's true enough, but we'd also fail to convert embedded \r\ncleanly, which also seems undesirable. Fixing the popen() modeseems like the best way to deal with this.It's been like this for a long time, so back-patch to all supportedbranches.Discussion:https://postgr.es/m/16688-c649c7b69cd7e6f8@postgresql.org
1 parent41c742a commit504f963

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/bin/psql/psqlscanslash.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ evaluate_backtick(PsqlScanState state)
754754

755755
initPQExpBuffer(&cmd_output);
756756

757-
fd =popen(cmd,PG_BINARY_R);
757+
fd =popen(cmd,"r");
758758
if (!fd)
759759
{
760760
state->callbacks->write_error("%s: %s\n", cmd,strerror(errno));
@@ -795,7 +795,7 @@ evaluate_backtick(PsqlScanState state)
795795
/* If no error, transfer result to output_buf */
796796
if (!error)
797797
{
798-
/* strip any trailing newline */
798+
/* strip any trailing newline(but only one)*/
799799
if (cmd_output.len >0 &&
800800
cmd_output.data[cmd_output.len -1] =='\n')
801801
cmd_output.len--;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp