Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4b0d53d

Browse files
author
Alexander Korotkov
committed
Fix operations with ranges.
1 parent 25a2eec commit 4b0d53d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

rangeset.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
bool
55
irange_intersects(IndexRange a, IndexRange b)
66
{
7-
return (irange_lower(a) <= irange_upper(b)) ||
7+
return (irange_lower(a) <= irange_upper(b)) &&
88
(irange_lower(b) <= irange_upper(a));
99
}
1010

1111
/* Check if two ranges are conjuncted */
1212
bool
1313
irange_conjuncted(IndexRange a, IndexRange b)
1414
{
15-
return (irange_lower(a) - 1 <= irange_upper(b)) ||
15+
return (irange_lower(a) - 1 <= irange_upper(b)) &&
1616
(irange_lower(b) - 1 <= irange_upper(a));
1717
}
1818

@@ -35,6 +35,27 @@ irange_intersect(IndexRange a, IndexRange b)
3535
irange_is_lossy(a) || irange_is_lossy(b));
3636
}
3737

38+
#ifdef NOT_USED
39+
/* Print range list in debug purposes */
40+
static char *
41+
print_irange(List *l)
42+
{
43+
ListCell *c;
44+
StringInfoData str;
45+
46+
initStringInfo(&str);
47+
48+
foreach (c, l)
49+
{
50+
IndexRange ir = lfirst_irange(c);
51+
52+
appendStringInfo(&str, "[%d,%d]%c ", irange_lower(ir), irange_upper(ir),
53+
irange_is_lossy(ir) ? 'l' : 'e');
54+
}
55+
return str.data;
56+
}
57+
#endif
58+
3859
/*
3960
* Make union of two index rage lists.
4061
*/
@@ -192,6 +213,7 @@ irange_list_intersect(List *a, List *b)
192213
if (irange_upper(ra) >= irange_upper(rb))
193214
cb = lnext(cb);
194215
}
216+
195217
return result;
196218
}
197219

0 commit comments

Comments
 (0)