Skip to content

Commit bf4ae68

Browse files
committed
Fix tqueue.c's range-remapping code.
It's depressingly clear that nobody ever tested this.
1 parent 80b346c commit bf4ae68

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/backend/executor/tqueue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ tqueueWalkRange(TQueueDestReceiver *tqueue, Datum value)
371371
* called in the first place: GetRemapClass should have returned NULL when
372372
* asked about this range type.
373373
*/
374-
remapclass = GetRemapClass(typeid);
374+
remapclass = GetRemapClass(typcache->rngelemtype->type_id);
375375
Assert(remapclass != TQUEUE_REMAP_NONE);
376376

377377
/* Walk each bound, if present. */
@@ -749,7 +749,7 @@ TupleQueueRemapRange(TupleQueueReader *reader, Datum value)
749749
* called in the first place: GetRemapClass should have returned NULL when
750750
* asked about this range type.
751751
*/
752-
remapclass = GetRemapClass(typeid);
752+
remapclass = GetRemapClass(typcache->rngelemtype->type_id);
753753
Assert(remapclass != TQUEUE_REMAP_NONE);
754754

755755
/* Remap each bound, if present. */

src/test/regress/expected/rangetypes.out

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,23 @@ select array[1,3] <@ arrayrange(array[1,2], array[2,1]);
13361336
t
13371337
(1 row)
13381338

1339+
--
1340+
-- Ranges of composites
1341+
--
1342+
create type two_ints as (a int, b int);
1343+
create type two_ints_range as range (subtype = two_ints);
1344+
-- with force_parallel_mode on, this exercises tqueue.c's range remapping
1345+
select *, row_to_json(upper(t)) as u from
1346+
(values (two_ints_range(row(1,2), row(3,4))),
1347+
(two_ints_range(row(5,6), row(7,8)))) v(t);
1348+
t | u
1349+
-------------------+---------------
1350+
["(1,2)","(3,4)") | {"a":3,"b":4}
1351+
["(5,6)","(7,8)") | {"a":7,"b":8}
1352+
(2 rows)
1353+
1354+
drop type two_ints cascade;
1355+
NOTICE: drop cascades to type two_ints_range
13391356
--
13401357
-- OUT/INOUT/TABLE functions
13411358
--

src/test/regress/sql/rangetypes.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,20 @@ select arrayrange(ARRAY[2,1], ARRAY[1,2]); -- fail
447447
select array[1,1] <@ arrayrange(array[1,2], array[2,1]);
448448
select array[1,3] <@ arrayrange(array[1,2], array[2,1]);
449449

450+
--
451+
-- Ranges of composites
452+
--
453+
454+
create type two_ints as (a int, b int);
455+
create type two_ints_range as range (subtype = two_ints);
456+
457+
-- with force_parallel_mode on, this exercises tqueue.c's range remapping
458+
select *, row_to_json(upper(t)) as u from
459+
(values (two_ints_range(row(1,2), row(3,4))),
460+
(two_ints_range(row(5,6), row(7,8)))) v(t);
461+
462+
drop type two_ints cascade;
463+
450464
--
451465
-- OUT/INOUT/TABLE functions
452466
--

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy