diff --git a/src/backend/utils/adt/multirangetypes.c b/src/backend/utils/adt/multirangetypes.c index 7773215564..51b0ec95ab 100644 --- a/src/backend/utils/adt/multirangetypes.c +++ b/src/backend/utils/adt/multirangetypes.c @@ -713,7 +713,10 @@ multirange_get_range(TypeCacheEntry *rangetyp, if (RANGE_HAS_LBOUND(flags)) ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr); if (RANGE_HAS_UBOUND(flags)) + { + ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr); ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr); + } len = (ptr - begin) + sizeof(RangeType) + sizeof(uint8); range = palloc0(len); diff --git a/src/test/regress/expected/multirangetypes.out b/src/test/regress/expected/multirangetypes.out index f5f089741c..bde3f248a7 100644 --- a/src/test/regress/expected/multirangetypes.out +++ b/src/test/regress/expected/multirangetypes.out @@ -97,6 +97,12 @@ select ' {( " a " " a ", " z " " z " ) }'::textmultirange; {(" a a "," z z ")} (1 row) +select textrange('\\\\', repeat('a', 200))::textmultirange; + textrange +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {["\\\\\\\\",aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)} +(1 row) + select '{(,z)}'::textmultirange; textmultirange ---------------- @@ -289,10 +295,10 @@ select textmultirange(textrange('a', 'c'), textrange('f', 'g')); {[a,c),[f,g)} (1 row) -select textmultirange(textrange('a', 'c'), textrange('b', 'd')); - textmultirange ----------------- - {[a,d)} +select textmultirange(textrange('\\\\', repeat('a', 200)), textrange('c', 'd')); + textmultirange +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {["\\\\\\\\",aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),[c,d)} (1 row) -- @@ -363,6 +369,13 @@ select unnest(textmultirange(textrange('a', 'b'), textrange('d', 'e'))); [d,e) (2 rows) +select unnest(textmultirange(textrange('\\\\', repeat('a', 200)), textrange('c', 'd'))); + unnest +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + ["\\\\\\\\",aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) + [c,d) +(2 rows) + -- -- create some test data and test the operators -- diff --git a/src/test/regress/expected/rangetypes.out b/src/test/regress/expected/rangetypes.out index e6ca99d43d..2eaed6e1f4 100644 --- a/src/test/regress/expected/rangetypes.out +++ b/src/test/regress/expected/rangetypes.out @@ -72,12 +72,6 @@ select ' ( " a " " a ", " z " " z " ) '::textrange; (" a a "," z z ") (1 row) -select '(,z)'::textrange; - textrange ------------ - (,z) -(1 row) - select '(a,)'::textrange; textrange ----------- diff --git a/src/test/regress/sql/multirangetypes.sql b/src/test/regress/sql/multirangetypes.sql index ad50afc0f5..df1edb4d31 100644 --- a/src/test/regress/sql/multirangetypes.sql +++ b/src/test/regress/sql/multirangetypes.sql @@ -25,6 +25,7 @@ select '{}'::textmultirange; select ' {} '::textmultirange; select ' { empty, empty } '::textmultirange; select ' {( " a " " a ", " z " " z " ) }'::textmultirange; +select textrange('\\\\', repeat('a', 200))::textmultirange; select '{(,z)}'::textmultirange; select '{(a,)}'::textmultirange; select '{[,z]}'::textmultirange; @@ -63,7 +64,7 @@ select '{(a,a)}'::textmultirange; select textmultirange(); select textmultirange(textrange('a', 'c')); select textmultirange(textrange('a', 'c'), textrange('f', 'g')); -select textmultirange(textrange('a', 'c'), textrange('b', 'd')); +select textmultirange(textrange('\\\\', repeat('a', 200)), textrange('c', 'd')); -- -- test casts, both a built-in range type and a user-defined one: @@ -82,6 +83,7 @@ select textrange(null, null)::textmultirange; -- select unnest(int4multirange(int4range('5', '6'), int4range('1', '2'))); select unnest(textmultirange(textrange('a', 'b'), textrange('d', 'e'))); +select unnest(textmultirange(textrange('\\\\', repeat('a', 200)), textrange('c', 'd'))); -- -- create some test data and test the operators diff --git a/src/test/regress/sql/rangetypes.sql b/src/test/regress/sql/rangetypes.sql index cb5353de6f..a2d411d0da 100644 --- a/src/test/regress/sql/rangetypes.sql +++ b/src/test/regress/sql/rangetypes.sql @@ -22,7 +22,6 @@ select '[z,a]'::textrange; select ' empty '::textrange; select ' ( empty, empty ) '::textrange; select ' ( " a " " a ", " z " " z " ) '::textrange; -select '(,z)'::textrange; select '(a,)'::textrange; select '[,z]'::textrange; select '[a,]'::textrange;