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

Commit0cdc3e4

Browse files
committed
psql: Fix \gx when FETCH_COUNT is used
Set expanded output when requested through \gx in ExecQueryUsingCursor()(used when FETCH_COUNT is set).Discussion:https://www.postgresql.org/message-id/CB7A53AA-5645-4BDD-AB07-4D22CD9D8FF1%40gmx.netAuthor: Tobias Bussmann
1 parent6ce6a61 commit0cdc3e4

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

‎src/bin/psql/common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,10 @@ ExecQueryUsingCursor(const char *query, double *elapsed_msec)
15651565
"FETCH FORWARD %d FROM _psql_cursor",
15661566
fetch_count);
15671567

1568+
/* one-shot expanded output requested via \gx */
1569+
if (pset.g_expanded)
1570+
my_popt.topt.expanded=1;
1571+
15681572
/* prepare to write output to \g argument, if any */
15691573
if (pset.gfname)
15701574
{

‎src/test/regress/expected/psql.out

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,31 @@ four | 4
5151
3 | 4
5252
(1 row)
5353

54+
-- \gx should work in FETCH_COUNT mode too
55+
\set FETCH_COUNT 1
56+
SELECT 1 as one, 2 as two \g
57+
one | two
58+
-----+-----
59+
1 | 2
60+
(1 row)
61+
62+
\gx
63+
-[ RECORD 1 ]
64+
one | 1
65+
two | 2
66+
67+
SELECT 3 as three, 4 as four \gx
68+
-[ RECORD 1 ]
69+
three | 3
70+
four | 4
71+
72+
\g
73+
three | four
74+
-------+------
75+
3 | 4
76+
(1 row)
77+
78+
\unset FETCH_COUNT
5479
-- \gset
5580
select 10 as test01, 20 as test02, 'Hello' as test03 \gset pref01_
5681
\echo :pref01_test01 :pref01_test02 :pref01_test03

‎src/test/regress/sql/psql.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ SELECT 1 as one, 2 as two \g
2828
SELECT3as three,4as four \gx
2929
\g
3030

31+
-- \gx should work in FETCH_COUNT mode too
32+
\set FETCH_COUNT1
33+
34+
SELECT1as one,2as two \g
35+
\gx
36+
SELECT3as three,4as four \gx
37+
\g
38+
39+
\unset FETCH_COUNT
40+
3141
-- \gset
3242

3343
select10as test01,20as test02,'Hello'as test03 \gset pref01_

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp