if (cstate->opts.on_error == COPY_ON_ERROR_SET_NULL)
{
- int attr_count = list_length(cstate->attnumlist);
-
/*
* When data type conversion fails and ON_ERROR is SET_NULL, we need
* ensure that the input column allow null values. ExecConstraints()
* check must be performed during the initial string-to-datum
* conversion (see CopyFromTextLikeOneRow()).
*/
- cstate->domain_with_constraint = palloc0_array(bool, attr_count);
+ cstate->domain_with_constraint = palloc0_array(bool, num_phys_attrs);
foreach_int(attno, cstate->attnumlist)
{
- int i = foreach_current_index(attno);
-
Form_pg_attribute att = TupleDescAttr(tupDesc, attno - 1);
- cstate->domain_with_constraint[i] = DomainHasConstraints(att->atttypid, NULL);
+ cstate->domain_with_constraint[attno - 1] = DomainHasConstraints(att->atttypid, NULL);
}
}
ERROR: domain d_int_not_null does not allow null values
DETAIL: ON_ERROR SET_NULL cannot be applied because column "a" (domain d_int_not_null) does not accept null values.
CONTEXT: COPY t_on_error_null, line 1, column a: null input
+COPY t_on_error_null(c, a) FROM STDIN WITH (on_error set_null); -- fail
+ERROR: domain d_int_not_null does not allow null values
+DETAIL: ON_ERROR SET_NULL cannot be applied because column "a" (domain d_int_not_null) does not accept null values.
+CONTEXT: COPY t_on_error_null, line 1, column a: null input
COPY t_on_error_null FROM STDIN WITH (on_error set_null); -- fail
ERROR: domain d_int_not_null does not allow null values
DETAIL: ON_ERROR SET_NULL cannot be applied because column "a" (domain d_int_not_null) does not accept null values.