Do not use floating point numbers to store money! Only fixed-point numbers, i.e. numeric .
First, how to count by array. For example, a subquery:
select sum(u.price) from unnest(Сomposition) u
Default value
In the default subquery can not write. Well, it's okay, you can wrap the subquery in the store and it will be possible. But here it is impossible to refer to other fields from default . And here it is already. Default value is not appropriate.
Trigger
Judging by the names of the fields, you initially do not need a default , but a trigger. default filled only once - with insert , though only if this field has not been assigned a value. And to make an update by changing the array - and from the business point of view, the field will simply lie, it will not be updated with update . But triggers can always keep the field up to date, even when you try to enter a value yourself.
CREATE OR REPLACE FUNCTION prixod_trigger_func() RETURNS trigger AS $TRIGGER$ BEGIN NEW."Total" = (select sum(u.price) from unnest(NEW."Сomposition") u); return NEW; END; $TRIGGER$ LANGUAGE plpgsql; CREATE TRIGGER prixod_trigger BEFORE INSERT OR UPDATE ON "Prixod" FOR EACH ROW EXECUTE PROCEDURE prixod_trigger_func();.
But I don’t think you should use an array of composite types instead of a separate table. The id in the type will have to be monitored independently, FK will not hang if necessary, refer to it from somewhere else. And to the trigger all the same what to consider, can go to another table.