8000 psql: Fix \gx when FETCH_COUNT is used · dirbacke/postgres@51d0fa8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 51d0fa8

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
{
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
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ SELECT 1 as one, 2 as two \g
2828
SELECT 3 as three, 4 as four \gx
2929
\g
3030

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

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