Commit 12cc9566 authored by Michael Paquier's avatar Michael Paquier

Improve some error wording with multirange type parsing

Braces were referred in some error messages as only brackets (not curly
brackets or curly braces), which can be confusing as other types of
brackets could be used.

While on it, add one test to check after the case of junk characters
detected after a right brace.

Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/20210514.153153.1814935914483287479.horikyota.ntt@gmail.com
parent ba356a39
...@@ -146,7 +146,7 @@ multirange_in(PG_FUNCTION_ARGS) ...@@ -146,7 +146,7 @@ multirange_in(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("malformed multirange literal: \"%s\"", errmsg("malformed multirange literal: \"%s\"",
input_str), input_str),
errdetail("Missing left bracket."))); errdetail("Missing left brace.")));
/* consume ranges */ /* consume ranges */
parse_state = MULTIRANGE_BEFORE_RANGE; parse_state = MULTIRANGE_BEFORE_RANGE;
...@@ -282,7 +282,7 @@ multirange_in(PG_FUNCTION_ARGS) ...@@ -282,7 +282,7 @@ multirange_in(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("malformed multirange literal: \"%s\"", errmsg("malformed multirange literal: \"%s\"",
input_str), input_str),
errdetail("Junk after right bracket."))); errdetail("Junk after right brace.")));
ret = make_multirange(mltrngtypoid, rangetyp, range_count, ranges); ret = make_multirange(mltrngtypoid, rangetyp, range_count, ranges);
PG_RETURN_MULTIRANGE_P(ret); PG_RETURN_MULTIRANGE_P(ret);
......
...@@ -7,12 +7,17 @@ select ''::textmultirange; ...@@ -7,12 +7,17 @@ select ''::textmultirange;
ERROR: malformed multirange literal: "" ERROR: malformed multirange literal: ""
LINE 1: select ''::textmultirange; LINE 1: select ''::textmultirange;
^ ^
DETAIL: Missing left bracket. DETAIL: Missing left brace.
select '{,}'::textmultirange; select '{,}'::textmultirange;
ERROR: malformed multirange literal: "{,}" ERROR: malformed multirange literal: "{,}"
LINE 1: select '{,}'::textmultirange; LINE 1: select '{,}'::textmultirange;
^ ^
DETAIL: Expected range start. DETAIL: Expected range start.
select '{(,)}.'::textmultirange;
ERROR: malformed multirange literal: "{(,)}."
LINE 1: select '{(,)}.'::textmultirange;
^
DETAIL: Junk after right brace.
select '{[a,c),}'::textmultirange; select '{[a,c),}'::textmultirange;
ERROR: malformed multirange literal: "{[a,c),}" ERROR: malformed multirange literal: "{[a,c),}"
LINE 1: select '{[a,c),}'::textmultirange; LINE 1: select '{[a,c),}'::textmultirange;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
-- negative tests; should fail -- negative tests; should fail
select ''::textmultirange; select ''::textmultirange;
select '{,}'::textmultirange; select '{,}'::textmultirange;
select '{(,)}.'::textmultirange;
select '{[a,c),}'::textmultirange; select '{[a,c),}'::textmultirange;
select '{,[a,c)}'::textmultirange; select '{,[a,c)}'::textmultirange;
select '{-[a,z)}'::textmultirange; select '{-[a,z)}'::textmultirange;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment