/*
 * This file is generated by jOOQ.
 */
package ervu_secret.ervu_secret.db_beans.pg_catalog.tables;


import ervu_secret.ervu_secret.db_beans.pg_catalog.PgCatalog;
import ervu_secret.ervu_secret.db_beans.pg_catalog.tables.records.PgStatProgressClusterRecord;

import java.util.Collection;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
import org.jooq.SQL;
import org.jooq.Schema;
import org.jooq.Select;
import org.jooq.Stringly;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class PgStatProgressCluster extends TableImpl<PgStatProgressClusterRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>pg_catalog.pg_stat_progress_cluster</code>
     */
    public static final PgStatProgressCluster PG_STAT_PROGRESS_CLUSTER = new PgStatProgressCluster();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<PgStatProgressClusterRecord> getRecordType() {
        return PgStatProgressClusterRecord.class;
    }

    /**
     * The column <code>pg_catalog.pg_stat_progress_cluster.pid</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Integer> PID = createField(DSL.name("pid"), SQLDataType.INTEGER, this, "");

    /**
     * The column <code>pg_catalog.pg_stat_progress_cluster.datid</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Long> DATID = createField(DSL.name("datid"), SQLDataType.BIGINT, this, "");

    /**
     * The column <code>pg_catalog.pg_stat_progress_cluster.datname</code>.
     */
    public final TableField<PgStatProgressClusterRecord, String> DATNAME = createField(DSL.name("datname"), SQLDataType.VARCHAR, this, "");

    /**
     * The column <code>pg_catalog.pg_stat_progress_cluster.relid</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Long> RELID = createField(DSL.name("relid"), SQLDataType.BIGINT, this, "");

    /**
     * The column <code>pg_catalog.pg_stat_progress_cluster.command</code>.
     */
    public final TableField<PgStatProgressClusterRecord, String> COMMAND = createField(DSL.name("command"), SQLDataType.CLOB, this, "");

    /**
     * The column <code>pg_catalog.pg_stat_progress_cluster.phase</code>.
     */
    public final TableField<PgStatProgressClusterRecord, String> PHASE = createField(DSL.name("phase"), SQLDataType.CLOB, this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stat_progress_cluster.cluster_index_relid</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Long> CLUSTER_INDEX_RELID = createField(DSL.name("cluster_index_relid"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stat_progress_cluster.heap_tuples_scanned</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Long> HEAP_TUPLES_SCANNED = createField(DSL.name("heap_tuples_scanned"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stat_progress_cluster.heap_tuples_written</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Long> HEAP_TUPLES_WRITTEN = createField(DSL.name("heap_tuples_written"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stat_progress_cluster.heap_blks_total</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Long> HEAP_BLKS_TOTAL = createField(DSL.name("heap_blks_total"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stat_progress_cluster.heap_blks_scanned</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Long> HEAP_BLKS_SCANNED = createField(DSL.name("heap_blks_scanned"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stat_progress_cluster.index_rebuild_count</code>.
     */
    public final TableField<PgStatProgressClusterRecord, Long> INDEX_REBUILD_COUNT = createField(DSL.name("index_rebuild_count"), SQLDataType.BIGINT, this, "");

    private PgStatProgressCluster(Name alias, Table<PgStatProgressClusterRecord> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private PgStatProgressCluster(Name alias, Table<PgStatProgressClusterRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "pg_stat_progress_cluster" as  SELECT s.pid,
         s.datid,
         d.datname,
         s.relid,
             CASE s.param1
                 WHEN 1 THEN 'CLUSTER'::text
                 WHEN 2 THEN 'VACUUM FULL'::text
                 ELSE NULL::text
             END AS command,
             CASE s.param2
                 WHEN 0 THEN 'initializing'::text
                 WHEN 1 THEN 'seq scanning heap'::text
                 WHEN 2 THEN 'index scanning heap'::text
                 WHEN 3 THEN 'sorting tuples'::text
                 WHEN 4 THEN 'writing new heap'::text
                 WHEN 5 THEN 'swapping relation files'::text
                 WHEN 6 THEN 'rebuilding index'::text
                 WHEN 7 THEN 'performing final cleanup'::text
                 ELSE NULL::text
             END AS phase,
         (s.param3)::oid AS cluster_index_relid,
         s.param4 AS heap_tuples_scanned,
         s.param5 AS heap_tuples_written,
         s.param6 AS heap_blks_total,
         s.param7 AS heap_blks_scanned,
         s.param8 AS index_rebuild_count
        FROM (pg_stat_get_progress_info('CLUSTER'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
          LEFT JOIN pg_database d ON ((s.datid = d.oid)));
        """), where);
    }

    /**
     * Create an aliased <code>pg_catalog.pg_stat_progress_cluster</code> table
     * reference
     */
    public PgStatProgressCluster(String alias) {
        this(DSL.name(alias), PG_STAT_PROGRESS_CLUSTER);
    }

    /**
     * Create an aliased <code>pg_catalog.pg_stat_progress_cluster</code> table
     * reference
     */
    public PgStatProgressCluster(Name alias) {
        this(alias, PG_STAT_PROGRESS_CLUSTER);
    }

    /**
     * Create a <code>pg_catalog.pg_stat_progress_cluster</code> table reference
     */
    public PgStatProgressCluster() {
        this(DSL.name("pg_stat_progress_cluster"), null);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : PgCatalog.PG_CATALOG;
    }

    @Override
    public PgStatProgressCluster as(String alias) {
        return new PgStatProgressCluster(DSL.name(alias), this);
    }

    @Override
    public PgStatProgressCluster as(Name alias) {
        return new PgStatProgressCluster(alias, this);
    }

    @Override
    public PgStatProgressCluster as(Table<?> alias) {
        return new PgStatProgressCluster(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public PgStatProgressCluster rename(String name) {
        return new PgStatProgressCluster(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public PgStatProgressCluster rename(Name name) {
        return new PgStatProgressCluster(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public PgStatProgressCluster rename(Table<?> name) {
        return new PgStatProgressCluster(name.getQualifiedName(), null);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatProgressCluster where(Condition condition) {
        return new PgStatProgressCluster(getQualifiedName(), aliased() ? this : null, null, condition);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatProgressCluster where(Collection<? extends Condition> conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatProgressCluster where(Condition... conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatProgressCluster where(Field<Boolean> condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public PgStatProgressCluster where(SQL condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public PgStatProgressCluster where(@Stringly.SQL String condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public PgStatProgressCluster where(@Stringly.SQL String condition, Object... binds) {
        return where(DSL.condition(condition, binds));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public PgStatProgressCluster where(@Stringly.SQL String condition, QueryPart... parts) {
        return where(DSL.condition(condition, parts));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatProgressCluster whereExists(Select<?> select) {
        return where(DSL.exists(select));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatProgressCluster whereNotExists(Select<?> select) {
        return where(DSL.notExists(select));
    }
}
