In new-portal/tcl/portal-procs.xql, 2 queries fail because of the
postgres acs_object_id_seq view hack that allows postgres to use
oracle-like syntax for accessing sequences.
The queries are portal::add_element_to_region.template_params_insert,
and portal::add_element_to_region.params_insert.
Both queries are similar. The first one is:
insert into portal_element_parameters
(parameter_id, element_id, config_required_p, configured_p, key,
value)
select acs_object_id_seq.nextval, :new_element_id,
config_required_p, configured_p, key, value
from portal_datasource_def_params where datasource_id= :ds_id
The reason the queries fail is that the select may return more than
one row from portal_datasource_def_params. For each row being
inserted, you would want a different parameter_id (the primary key,
which is being generated from acs_object_id_seq). However, because
acs_object_id_seq is not a real sequence, but rather is a view on the
sequence t_acs_object_id_seq, postgres only accesses it once in the
above select statement. When there is more than one row, a duplicate
key violation occurs immediately.
The only way to fix this is to instead say nextval('t_object_id_seq').
Postgres then gives a different value for each row.
Has anyone else notice this type of behavior elsewhere?