Query about using arrays (for accessing pg_group)
Query about using arrays (for accessing pg_group)
От:
Greg Wickham <greg@geelong.com>
Дата:
Howdy, Am trying to implement a user/group based security model for accessing a database which is tightly integrated with the postgresql security model. The problem I am having is that I am not sure how to check which groups a user is in. For example, if I have a user (with id of 21) in a group, I'm not sure how to start off with the user id and pull out the group name using normal sql. If I try the half intuitive approach z=> select groname from pg_group where grolist = 21; ERROR: Unable to identify an operator '=' for types '_int4' and 'int4' You will have to retype this query using an explicit cast The cause of my problem is the use of an array to store the user id's associated with a group. Not sure how to get around this. Any ideas? Please cc replies to me as I think I've fallen off this list. tia, -Greg ------------------------------------------------------------------ www.geelong.com Greg Wickham P.O. Box 1426 greg@geelong.com Geelong VIC 3220 Ph: (+61 407) 854 566 ------------------------------------------------------------------ wheNufiNdu'RselFindAngeRwheNu'rThreAtenEdbyAstrAngeRwheNitlOoksLik
Re: Query about using arrays (for accessing pg_group)
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Greg Wickham writes: > If I try the half intuitive approach > z=> select groname from pg_group where grolist = 21; > ERROR: Unable to identify an operator '=' for types '_int4' and 'int4' > You will have to retype this query using an explicit cast > The cause of my problem is the use of an array to store the user id's > associated with a group. Not sure how to get around this. You need a function that will return true if any of the elements of an int4 array is equal to a particular int4 value. See contrib/array/ for one way to do it. regards, tom lane