Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a62ec6

Browse files
author
Maxim Orlov
committed
Use more detailed message in record insert error.
In case of inserting a erroneous record in variable show clear messages, if it isamount of fields or fields types are wrong.
1 parent992db9f commit6a62ec6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

‎expected/pg_variables.out‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ ERROR: variable "j1" requires "jsonb" value
563563
SELECT pgv_insert('vars3', 'r1', tab) FROM tab;
564564
ERROR: there is a record in the variable "r1" with same key
565565
SELECT pgv_insert('vars3', 'r1', row(1, 'str1', 'str2'));
566-
ERROR: new record structurediffers fromvariable "r1" structure
566+
ERROR: new record structurehave 3 attributes, butvariable "r1" structure have 2.
567567
SELECT pgv_insert('vars3', 'r1', row(1, 1));
568-
ERROR: new recordstructurediffers from variable "r1" structure
568+
ERROR: new recordattribute type for attribute number 2differs from variable "r1" structure. You may need explicit type casts.
569569
SELECT pgv_insert('vars3', 'r1', row('str1', 'str1'));
570-
ERROR: new recordstructurediffers from variable "r1" structure
570+
ERROR: new recordattribute type for attribute number 1differs from variable "r1" structure. You may need explicit type casts.
571571
SELECT pgv_select('vars3', 'r1', ARRAY[[1,2]]); -- fail
572572
ERROR: searching for elements in multidimensional arrays is not supported
573573
-- Test variables caching

‎pg_variables_record.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ check_attributes(Variable *variable, TupleDesc tupdesc)
188188
if (record->tupdesc->natts!=tupdesc->natts)
189189
ereport(ERROR,
190190
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
191-
errmsg("new record structure differs from variable \"%s\" "
192-
"structure",GetName(variable))));
191+
errmsg("new record structure have %d attributes, but variable "
192+
"\"%s\" structure have %d.",
193+
tupdesc->natts,GetName(variable),record->tupdesc->natts)));
193194

194195
/* Second, check columns type. */
195196
for (i=0;i<tupdesc->natts;i++)
@@ -202,8 +203,10 @@ check_attributes(Variable *variable, TupleDesc tupdesc)
202203
|| (attr1->atttypmod!=attr2->atttypmod))
203204
ereport(ERROR,
204205
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
205-
errmsg("new record structure differs from variable \"%s\" "
206-
"structure",GetName(variable))));
206+
errmsg("new record attribute type for attribute number %d "
207+
"differs from variable \"%s\" structure. You may "
208+
"need explicit type casts.",
209+
i+1,GetName(variable))));
207210
}
208211
}
209212

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp