Bug 117791 - PostgreSQL functions dnm_context_change_context and acs_object_dnm_ctx_add_fn
PostgreSQL functions dnm_context_change_context and acs_object_dnm_ctx_add_fn
Status: CLOSED NOTABUG
Product: Red Hat Web Application Framework
Classification: Retired
Component: other (Show other bugs)
nightly
All Linux
medium Severity medium
: ---
: ---
Assigned To: Aram Kananov
Jon Orris
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-03-08 12:34 EST by Brett Prucha
Modified: 2007-04-18 13:04 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-03-09 09:48:28 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Brett Prucha 2004-03-08 12:34:34 EST
Description of problem:

The PostgreSQL function dnm_context_change_context has a variable 
defined as:

v_new_granted_context = dnm_context_get_granted_context(v_context_id)

This obviously does not make sense because v_context_id has not been 
initialized to anything yet.

Looking at the oracle procedure it looks like it should be:

v_new_granted_context = dnm_context_get_granted_context(p_context_id)


Also, the function acs_object_dnm_ctx_add_fn called by trigger 
acs_object_dnm_ctx_add_trg looks like it should be calling 
dnm_context_add_object(new.object_id,null) not dnm_context_add_object
(new.object_id,0).  But I'm not positive about that one.
Comment 1 Brett Prucha 2004-03-08 14:33:50 EST
Related to the function acs_object_dnm_ctx_add_fn above, 
object_context_dnm_fn called by trigger object_context_dnm_trg should 
also be calling dnm_context_change_context(old.object_id, null) 
instead of dnm_context_change_context(old.object_id, 0)
Comment 2 Aram Kananov 2004-03-09 05:15:04 EST
> v_new_granted_context = dnm_context_get_granted_context(v_context_id)
> 
> This obviously does not make sense because v_context_id has not been 
> initialized to anything yet.

Sorry, but v_context_id _is_ initialized, in the previous line
<code_snippet> 
v_context_id = coalesce(p_context_id,0);
v_new_granted_context = dnm_context_get_granted_context(v_context_id);
</code_snippet> 

> Looking at the oracle procedure it looks like it should be:

Due the fact that pg doesnt support "connect by" and difference in sql 
syntax, the oracle and pg code differs a lot, also there are some
tables in pg for maintaining denormalization which are not exist in
oracle. 

> Also, the function acs_object_dnm_ctx_add_fn called by trigger 
> acs_object_dnm_ctx_add_trg looks like it should be calling 
> dnm_context_add_object(new.object_id,null) not dnm_context_add_object
> (new.object_id,0).  But I'm not positive about that one.

Object with id = 0 is special object which is Root of context
hierarchy, so even if you dont specify context for object, or set it
to null it still points to the object 0.

> object_context_dnm_fn called by trigger object_context_dnm_trg should 
> also be calling dnm_context_change_context(old.object_id, null) 
> instead of dnm_context_change_context(old.object_id, 0)

The in the object_context table only context_id value can be changed,
not the value for object_id
so no need for mangling with old.object_id.

Regards
Comment 3 Brett Prucha 2004-03-09 09:22:43 EST
You are right about v_context_id being initialized.  I guess I was 
starring at too much code that day and missed that.  But there is 
still a problem here.  I get a not null violation constraint on 
dnm_object_1_granted_context.pd_context_id when I try and insert the 
0 object into acs_objects.

Tracing through the code

dnm_context_add_object(0, 0)
dnm_context_get_granted_context(0) [returns null]
    If you pass in null this function will return 0
    However if you pass in a value it will return pd_context_id from
    dnm_object_1_granted_context for the passed in p_object_id.
    Working with a blank database there isn't anything in
    dnm_object_1_granted_context so it returns null
The next line in dnm_context_add_object then trys to insert the null 
value returned by dnm_context_get_granted_context into 
dnm_object_1_granted_context.pd_context_id which fails.

I corrected this problem by changing the trigger to call 
dnm_context_add_object(0, null) which causes 
dnm_context_get_granted_context(null) to be called which then returns 
0.  Their is no bug in dnm_context_change_context but there is one in 
acs_object_dnm_ctx_add_fn.
Comment 4 Aram Kananov 2004-03-09 09:48:28 EST
The object id = 0 is created before creating triggers, and _NEVER_
modified/deleted. 
It has very special purpose, so it is _hardcoded_ 
and denorm api _will_not_work_properly_ without it, producing logical
inconsystency in the denormalization dm. 

So the triggers are never meant to work for this case.
object 0 should be inserted before the creation of triggers.


Note You need to log in before you can comment on or make changes to this bug.