'Fetch the oid for schema.table_name.
Several reflection methods require the table oid.  The idea for using
this method is that it can be fetched one time and cached for
subsequent calls.'

@reflection.cache
def get_table_oid(self, connection, table_name, schema=None, **kw):

    table_oid = None
    if (schema is not None):
        schema_where_clause = 'n.nspname    =    :schema'
    else:
        schema_where_clause = 'pg_catalog.pg_table_is_visible(c.oid)'
    query = ("\n                                                SELECT    c.oid\n                                                FROM    pg_catalog.pg_class    c\n                                                LEFT    JOIN    pg_catalog.pg_namespace    n    ON    n.oid    =    c.relnamespace\n                                                WHERE    (%s)\n                                                AND    c.relname    =    :table_name    AND    c.relkind    in    ('r','v')\n                                " % schema_where_clause)
    table_name = util.text_type(table_name)
    if (schema is not None):
        schema = util.text_type(schema)
    s = sql.text(query).bindparams(table_name=sqltypes.Unicode)
    s = s.columns(oid=sqltypes.Integer)
    if schema:
        s = s.bindparams(sql.bindparam('schema', type_=sqltypes.Unicode))
    c = connection.execute(s, table_name=table_name, schema=schema)
    table_oid = c.scalar()
    if (table_oid is None):
        raise exc.NoSuchTableError(table_name)
    return table_oid
