[sql] add some more internal state functions