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

Commit0ed1872

Browse files
hlinnakapull[bot]
authored andcommitted
Add regression tests for psql \g piped into a program
Author: Daniel VéritéReviewed-by: Peter EisentrautDiscussion:https://www.postgresql.org/message-id/33ce8350-8cd1-45ff-a5fe-f9be7bc70649%40manitou-mail.org
1 parentd4bbce6 commit0ed1872

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎src/bin/psql/t/001_basic.pl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,32 @@ sub psql_fails_like
405405
qr/iteration count is specified more than once/,
406406
'\watch, iteration count is specified more than once');
407407

408+
# Test \g output piped into a program.
409+
# The program is perl -pe '' to simply copy the input to the output.
410+
my$g_file ="$tempdir/g_file_1.out";
411+
my$perlbin = $^X;
412+
$perlbin =~s!\\!/!gif$PostgreSQL::Test::Utils::windows_os;
413+
my$pipe_cmd ="$perlbin -pe '' >$g_file";
414+
415+
psql_like($node,"SELECT 'one'\\g |$pipe_cmd",qr//,"one command\\g");
416+
my$c1 = slurp_file($g_file);
417+
like($c1,qr/one/);
418+
419+
psql_like($node,"SELECT 'two'\\; SELECT 'three'\\g |$pipe_cmd",qr//,"two commands\\g");
420+
my$c2 = slurp_file($g_file);
421+
like($c2,qr/two.*three/s);
422+
423+
424+
psql_like($node,"\\set SHOW_ALL_RESULTS 0\nSELECT 'four'\\; SELECT 'five'\\g |$pipe_cmd",qr//,
425+
"two commands\\g with only last result");
426+
my$c3 = slurp_file($g_file);
427+
like($c3,qr/five/);
428+
unlike($c3,qr/four/);
429+
430+
psql_like($node,"copy (values ('foo'),('bar')) to stdout\\g |$pipe_cmd",
431+
qr//,
432+
"copy output passed to\\g pipe");
433+
my$c4 = slurp_file($g_file);
434+
like($c4,qr/foo.*bar/s);
435+
408436
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp