* equalPolicy * * Determine whether two policies are equivalent */
| 955 | * Determine whether two policies are equivalent |
| 956 | */ |
| 957 | static bool |
| 958 | equalPolicy(RowSecurityPolicy *policy1, RowSecurityPolicy *policy2) |
| 959 | { |
| 960 | int i; |
| 961 | Oid *r1, |
| 962 | *r2; |
| 963 | |
| 964 | if (policy1 != NULL) |
| 965 | { |
| 966 | if (policy2 == NULL) |
| 967 | return false; |
| 968 | |
| 969 | if (policy1->polcmd != policy2->polcmd) |
| 970 | return false; |
| 971 | if (policy1->hassublinks != policy2->hassublinks) |
| 972 | return false; |
| 973 | if (strcmp(policy1->policy_name, policy2->policy_name) != 0) |
| 974 | return false; |
| 975 | if (ARR_DIMS(policy1->roles)[0] != ARR_DIMS(policy2->roles)[0]) |
| 976 | return false; |
| 977 | |
| 978 | r1 = (Oid *) ARR_DATA_PTR(policy1->roles); |
| 979 | r2 = (Oid *) ARR_DATA_PTR(policy2->roles); |
| 980 | |
| 981 | for (i = 0; i < ARR_DIMS(policy1->roles)[0]; i++) |
| 982 | { |
| 983 | if (r1[i] != r2[i]) |
| 984 | return false; |
| 985 | } |
| 986 | |
| 987 | if (!equal(policy1->qual, policy2->qual)) |
| 988 | return false; |
| 989 | if (!equal(policy1->with_check_qual, policy2->with_check_qual)) |
| 990 | return false; |
| 991 | } |
| 992 | else if (policy2 != NULL) |
| 993 | return false; |
| 994 | |
| 995 | return true; |
| 996 | } |
| 997 | |
| 998 | /* |
| 999 | * equalRSDesc |