rdbms: Regression tests for T364827
Also a small clean up of the function that is now too small to need its own function.
Bug: T364827 Change-Id: If73185e6d2a8ee801a5fd7c6b8af771f150c9280