Skip to content

Commit

Permalink
Use hint instead of long message #32
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Orlov committed Dec 9, 2020
1 parent 1b37d66 commit 2e3f14f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions expected/pg_variables.out
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,11 @@ ERROR: there is a record in the variable "r1" with same key
SELECT pgv_insert('vars3', 'r1', row(1, 'str1', 'str2'));
ERROR: new record structure have 3 attributes, but variable "r1" structure have 2.
SELECT pgv_insert('vars3', 'r1', row(1, 1));
ERROR: new record attribute type for attribute number 2 differs from variable "r1" structure. You may need explicit type casts.
ERROR: new record attribute type for attribute number 2 differs from variable "r1" structure.
HINT: You may need explicit type casts.
SELECT pgv_insert('vars3', 'r1', row('str1', 'str1'));
ERROR: new record attribute type for attribute number 1 differs from variable "r1" structure. You may need explicit type casts.
ERROR: new record attribute type for attribute number 1 differs from variable "r1" structure.
HINT: You may need explicit type casts.
SELECT pgv_select('vars3', 'r1', ARRAY[[1,2]]); -- fail
ERROR: searching for elements in multidimensional arrays is not supported
-- Test variables caching
Expand Down Expand Up @@ -959,7 +961,8 @@ SELECT pgv_insert('vars', 'r2', row(1, 'str1'));
(1 row)

SELECT pgv_insert('vars', 'r2', foo) FROM foo;
ERROR: new record attribute type for attribute number 2 differs from variable "r2" structure. You may need explicit type casts.
ERROR: new record attribute type for attribute number 2 differs from variable "r2" structure.
HINT: You may need explicit type casts.
SELECT pgv_select('vars', 'r2');
pgv_select
------------
Expand Down
6 changes: 3 additions & 3 deletions pg_variables_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ check_attributes(Variable *variable, TupleDesc tupdesc)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("new record attribute type for attribute number %d "
"differs from variable \"%s\" structure. You may "
"need explicit type casts.",
i + 1, GetName(variable))));
"differs from variable \"%s\" structure.",
i + 1, GetName(variable)),
errhint("You may need explicit type casts.")));
}
}

Expand Down

0 comments on commit 2e3f14f

Please sign in to comment.