fud30_group_cache table, shouldn't it be a view? [message #167259] |
Sat, 26 May 2012 06:41 |
NeXuS
Messages: 121 Registered: July 2010 Location: South Korea
Karma: 5
|
Senior Member Contributing Core Developer |
|
|
I am actually a little surprised by this, and I may be wrong in the understanding of the DB structure, but it seems to me that all the data in fud30_group_cache is already contained in other tables, so why isn't it a view?
|
|
|
|
Re: fud30_group_cache table, shouldn't it be a view? [message #167347 is a reply to message #167262] |
Sat, 09 June 2012 10:03 |
NeXuS
Messages: 121 Registered: July 2010 Location: South Korea
Karma: 5
|
Senior Member Contributing Core Developer |
|
|
I am about to patch the source tree, I would just have a few other heads check my view formulation
-- GROUP LEADERS
SELECT gm.user_id, gr.resource_id, gm.group_id,
BIT_OR( gm.group_members_opt ) AS group_cache_opts
FROM fud30_group_members gm
INNER JOIN fud30_group_resources gr
ON gr.group_id=gm.group_id
WHERE ( gm.group_members_opt>=65536 )
AND ( gm.group_members_opt & 65536 ) > 0
AND ( gm.group_members_opt & 131072 )
GROUP BY user_id, resource_id, group_id
UNION
-- GROUP MEMBERS
SELECT gm.user_id, gr.resource_id, gr.group_id,
BIT_AND( gm.group_members_opt ) AS group_cache_opts
FROM fud30_group_members AS gm
INNER JOIN fud30_group_resources AS gr
ON gr.group_id=gm.group_id
WHERE ( gm.group_members_opt>=65536 )
AND ( gm.group_members_opt & 65536 ) > 0
GROUP BY user_id, resource_id, group_id;
By the way, the result generated by the statement above is different from fud30_group_cache: in fud30_group_cache, group_id is always 0, here it is set properly. I am not sure this is the correct behaviour, though, since the key of the caching seems to be (user_id, resource_id) independently of the group_id.
P.S. I am pretty sure this works for MySQL, but the syntax might need to be changed for other engines
[Updated on: Sat, 09 June 2012 10:10] Report message to a moderator
|
|
|
|
|
|
|
Re: fud30_group_cache table, shouldn't it be a view? [message #167448 is a reply to message #167361] |
Fri, 22 June 2012 07:31 |
NeXuS
Messages: 121 Registered: July 2010 Location: South Korea
Karma: 5
|
Senior Member Contributing Core Developer |
|
|
I have a patch ready with the q_bit syntax everyting, but it seems I have hit a problem with MySQL views.
The select statement works as expected but the view gives an error
ERROR 1356 (HY000): View 'fud_test.group_cache' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use
I am filing a bug in a few minutes, let's see if there is any answer.
|
|
|
|
|
|