Forum OpenACS Development: plpgsql bug?

Collapse
Posted by Jon Griffin on
I am trying to add a calendar to a group whenever a new group is created.

The problem is that acs-object doesn't seem to like the fact that due to the transaction, the group_id doesn't really exist.

This makes sense, except that I would think PG would actually create the row and then rollback if it didn't complete. Of course, there is every possibility it is my code ;) pc_group__new returns the acs_object which was generated from the form. This is in team__new()

Here is the relevant code:


v_team_id := pc_group__new (
    null,
    p_team_code || ''-'' || p_name,
    p_context_id,
    p_district_id,
    ''team''
  );

  -- now create a default calendar
   v_calendar_id:= calendar__new (
      null,               -- calendar_id
      p_team_code,        -- calendar_name
      ''calendar'',       -- object_type
      p_creation_user,    -- owner_id
      ''f'',              -- private_p
      p_context_id,       -- package_id
      null,               -- context_id
      now(),              -- creation
      v_team_id,          -- owner
      null                -- ip
   );
Collapse
2: Re: plpgsql bug? (response to 1)
Posted by Don Baccus on
It should be visible so ... have you tried executing this "by hand" in PSQL?  Do the pc_group_new() op in a select outside a transaction, record the value returned, and use it in the second call as the arg passed as v_team_id???

If this fails then transaction visibility is not an issue.

If it works, on the other hand, try to bundle up a test case for the PG folks to comment on ...

Because offhand it should work.

Collapse
3: Re: plpgsql bug? (response to 1)
Posted by Mark Aufflick on
According to the official Postgresql book, all changes to the database are visible within the transaction, but invisible to anyone else (until the transaction is committed).