Class NoCurrentDatabaseRefusal

All Implemented Interfaces:
Serializable

public final class NoCurrentDatabaseRefusal extends RuntimeException
Live's refusal of a statement that needs a current database the session does not have, naming what the statement was doing, with no compilation-error prefix:
   Cannot perform CREATE TABLE. This session does not have a current database. Call 'USE DATABASE', or use a qualified name.
 

A session gets there by dropping its current database, which leaves CURRENT_DATABASE() and CURRENT_SCHEMA() both NULL. The refusal usually names the statement's own kind, which the command visitor enters as each statement starts, so a refusal raised deep inside name resolution still names it. A few lookups name themselves instead, whatever the statement: a FROM clause is a SELECT, a CLONE source a CLONE. They pass that name to naming(java.lang.String).

The missing prefix matters beyond the text. The refusal is raised while the statement compiles, so a DML write must never wrap it in its row-time envelope, and this type is how the envelope tells.

See Also:
  • Method Details

    • enter

      public static String enter(String kind)
      The statement about to run, by the name live gives it.
      Parameters:
      kind - the statement's name
      Returns:
      the enclosing statement's name, for exit(java.lang.String)
    • exit

      public static void exit(String enclosing)
      The statement has ended, and the enclosing one's name applies again.
      Parameters:
      enclosing - what enter(java.lang.String) returned
    • forStatement

      public static RuntimeException forStatement()
      The refusal, naming the statement running now.
      Returns:
      the refusal to throw
    • naming

      public static NoCurrentDatabaseRefusal naming(String kind)
      The refusal, naming an operation of its own.
      Parameters:
      kind - what the refusal names: SELECT for a FROM clause, CLONE for a CLONE source
      Returns:
      the refusal to throw