Check ejabberd.rosterusers for consistency

There are 9 allowed states in
http://tools.ietf.org/html/rfc6121#appendix-A

There are two paths [1] from mutually unsubscribed to mutually subscribed.
Let's call our example users Fred and George, and the paths A and B.

Path A is:
1) Fred sends <presence type='subscribe' to='george@YOUR.DOMAIN.HERE'/>
2) George sends <presence type='subscribe' to='fred@YOUR.DOMAIN.HERE'/>
3) George sends <presence type='subscribed' to='fred@YOUR.DOMAIN.HERE'/>
4) Fred sends <presence type='subscribed' to='george@YOUR.DOMAIN.HERE'/>

Path B is:
1) Fred sends <presence type='subscribe' to='george@YOUR.DOMAIN.HERE'/>
2b) George sends <presence type='subscribed' to='fred@YOUR.DOMAIN.HERE'/>
3b) George sends <presence type='subscribe' to='fred@YOUR.DOMAIN.HERE'/>
4) Fred sends <presence type='subscribed' to='george@YOUR.DOMAIN.HERE'/>

[1] Ignoring paths that involve <presence type='unsubscribe'>,
    and symmetrically-opposite descriptions of the above-described paths.

This select statement asserts that the state our users' rosteritems
reach after each step is correct and consistent.
Both users must be on the same domain for this check to be meaningful.

'--' comments at the end of lines correspond to the step that's just been
completed from the above list. (I wrote the full transition diagram on a
post-it note, but I think that the above list is approximately as clear.)
Check ejabberd.rosterusers for invalid states

I refer the reader to:
http://tools.ietf.org/html/rfc6121#appendix-A
for the list of valid states.