Type context constant and sql performance fix