Lack of SQL function `is_context_attached`

It's convenient to have information if given context is attached. Calling twice hive.app_context_attach generates ERROR: Unknown context account_history or context is already attached error.