@@ -563,11 +563,13 @@ ERROR: variable "j1" requires "jsonb" value
563563SELECT pgv_insert('vars3', 'r1', tab) FROM tab;
564564ERROR: there is a record in the variable "r1" with same key
565565SELECT pgv_insert('vars3', 'r1', row(1, 'str1', 'str2'));
566- ERROR: new record structurediffers from variable "r1" structure
566+ ERROR: new record structurehave 3 attributes, but variable "r1" structure have 2.
567567SELECT pgv_insert('vars3', 'r1', row(1, 1));
568- ERROR: new record structure differs from variable "r1" structure
568+ ERROR: new record attribute type for attribute number 2 differs from variable "r1" structure.
569+ HINT: You may need explicit type casts.
569570SELECT pgv_insert('vars3', 'r1', row('str1', 'str1'));
570- ERROR: new record structure differs from variable "r1" structure
571+ ERROR: new record attribute type for attribute number 1 differs from variable "r1" structure.
572+ HINT: You may need explicit type casts.
571573SELECT pgv_select('vars3', 'r1', ARRAY[[1,2]]); -- fail
572574ERROR: searching for elements in multidimensional arrays is not supported
573575-- Test variables caching
@@ -929,3 +931,60 @@ SELECT * FROM pgv_list() order by package, name;
929931---------+------+------------------
930932(0 rows)
931933
934+ -- Check insert of record with various amount of fields
935+ CREATE TEMP TABLE foo(id int, t text);
936+ INSERT INTO foo VALUES (0, 'str00');
937+ SELECT pgv_insert('vars', 'r1', row(1, 'str1'::text, 'str2'::text));
938+ pgv_insert
939+ ------------
940+
941+ (1 row)
942+
943+ SELECT pgv_select('vars', 'r1');
944+ pgv_select
945+ ---------------
946+ (1,str1,str2)
947+ (1 row)
948+
949+ SELECT pgv_insert('vars', 'r1', foo) FROM foo;
950+ ERROR: new record structure have 2 attributes, but variable "r1" structure have 3.
951+ SELECT pgv_select('vars', 'r1');
952+ pgv_select
953+ ---------------
954+ (1,str1,str2)
955+ (1 row)
956+
957+ SELECT pgv_insert('vars', 'r2', row(1, 'str1'));
958+ pgv_insert
959+ ------------
960+
961+ (1 row)
962+
963+ SELECT pgv_insert('vars', 'r2', foo) FROM foo;
964+ ERROR: new record attribute type for attribute number 2 differs from variable "r2" structure.
965+ HINT: You may need explicit type casts.
966+ SELECT pgv_select('vars', 'r2');
967+ pgv_select
968+ ------------
969+ (1,str1)
970+ (1 row)
971+
972+ SELECT pgv_insert('vars', 'r3', row(1, 'str1'::text));
973+ pgv_insert
974+ ------------
975+
976+ (1 row)
977+
978+ SELECT pgv_insert('vars', 'r3', foo) FROM foo;
979+ pgv_insert
980+ ------------
981+
982+ (1 row)
983+
984+ SELECT pgv_select('vars', 'r3');
985+ pgv_select
986+ ------------
987+ (1,str1)
988+ (0,str00)
989+ (2 rows)
990+