001package gudusoft.gsqlparser;
002
003/**
004 * Whether a table reference was found in the catalog metadata ({@code TSQLEnv}).
005 *
006 * <p>This is a fact about the TABLE, and it is separate from which table a column belongs to.
007 * In {@code SELECT amount FROM orders} the column {@code amount} belongs to {@code orders}; that
008 * is decided by the structure of the statement and does not depend on the catalog. Whether the
009 * catalog holds a table {@code orders} is a second question, answered here. Oracle
010 * {@code orders} names the table {@code ORDERS}, so a catalog holding only {@code "Orders"}
011 * answers {@link #NOT_FOUND}, while the column keeps its source table and its lineage.</p>
012 *
013 * <p>Read it with {@code TTable.getCatalogStatus()}. It replaces guessing from
014 * {@code TTable.getResolvedTable() == null}, which cannot tell "looked and did not find" from
015 * "did not look", and from {@code TTable.isResolved()}, which only says a lookup was attempted.</p>
016 *
017 * @see gudusoft.gsqlparser.nodes.TTable#getCatalogStatus()
018 */
019public enum ETableCatalogStatus {
020    /**
021     * No catalog lookup applies: the environment holds no metadata to check against, or the
022     * reference is not a catalog object at all (a CTE reference, a subquery, a table function,
023     * a table variable), or no resolver has examined the table.
024     */
025    NOT_CHECKED,
026    /** The catalog holds this table; {@code TTable.getResolvedTable()} is that catalog entry. */
027    FOUND,
028    /**
029     * The environment holds catalog metadata, this is a base table reference, and it is not in
030     * it. "Not in the metadata that was supplied" is all it claims: a system object the
031     * metadata does not list (Oracle {@code DUAL}) and a temporary table the script never
032     * declares are reported here too, truthfully.
033     */
034    NOT_FOUND
035}