package com.alibaba.druid.sql.dialect.postgresql.visitor;

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
import com.alibaba.druid.sql.dialect.postgresql.ast.PGSQLIndexSpec;
import com.alibaba.druid.sql.dialect.postgresql.ast.PGSQLPartition;
import com.alibaba.druid.sql.dialect.postgresql.ast.PGSQLPartitionBy;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGBoxExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCidrExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCircleExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGColumnSimpleDefinitionExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGExtractExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGInetExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGLineSegmentsExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGMacAddrExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGOptionValue;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGPointExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGPolygonExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGSQLObjectCollection;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGSchemaTables;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGTypeCastExpr;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.constraint.PGConstraint;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.constraint.PGStorageParameter;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.tablesource.PGExprTableSource;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.tablesource.PGMethodInvokeTableSource;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.tablesource.PGRowsFromTableSource;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.tablesource.PGSubqueryTableSource;
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.tablesource.PGValuesTableSource;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGAlterDatabaseStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGAlterIndexStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGAlterSchemaStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGAlterSequenceStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGAlterTableStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGAlterViewStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGConnectToStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGCreateDatabaseStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGCreateIndexStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGCreateSchemaStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGCreateSeqenceStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGCreateTableSpaceStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGCreateTableStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGCreateViewStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGDeleteStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGDropSchemaStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGDropSequenceStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGFunctionTableSource;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGGrantStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGInsertStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectQueryBlock;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGShowStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGStartTransactionStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGUpdateStatement;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableAddColumn;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableAddConstraint;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableAlterColumn;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableAlterColumnOptions;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableCluster;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableDisableEnabelTrigger;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableDropColumn;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableDropConstraint;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableInheriteOrNotParentTable;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableOf;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableRenameColumn;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableRenameConstraint;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableRenameTo;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableSetNewTableSpace;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableSetReset;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableSetSchema;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableSetTableSpace;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableSetWith;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGAlterTableValidateConstraint;
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.alterTable.PGColumnDefinition;
import com.alibaba.druid.sql.repository.SchemaRepository;
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
import com.alibaba.druid.stat.TableStat;
import com.alibaba.druid.util.PGUtils;

public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisitor {
   public PGSchemaStatVisitor() {
      super(DbType.postgresql);
   }

   public PGSchemaStatVisitor(SchemaRepository repository) {
      super(repository);
   }

   public DbType getDbType() {
      return DbType.postgresql;
   }

   public void endVisit(PGSelectQueryBlock x) {
      this.endVisit((SQLSelectQueryBlock)x);
   }

   public boolean visit(PGSelectQueryBlock x) {
      return this.visit((SQLSelectQueryBlock)x);
   }

   public void endVisit(PGSelectQueryBlock.FetchClause x) {
   }

   public boolean visit(PGSelectQueryBlock.FetchClause x) {
      return true;
   }

   public void endVisit(PGSelectQueryBlock.ForClause x) {
   }

   public boolean visit(PGSelectQueryBlock.ForClause x) {
      return true;
   }

   public void endVisit(PGDeleteStatement x) {
   }

   public boolean visit(PGDeleteStatement x) {
      if (this.repository != null && x.getParent() == null) {
         this.repository.resolve((SQLStatement)x);
      }

      if (x.getWith() != null) {
         x.getWith().accept(this);
      }

      SQLTableSource using = x.getUsing();
      if (using != null) {
         using.accept(this);
      }

      x.putAttribute("_original_use_mode", this.getMode());
      this.setMode(x, TableStat.Mode.Delete);
      TableStat stat = this.getTableStat(x.getTableName());
      stat.incrementDeleteCount();
      this.accept(x.getWhere());
      return false;
   }

   public void endVisit(PGInsertStatement x) {
   }

   public boolean visit(PGInsertStatement x) {
      if (this.repository != null && x.getParent() == null) {
         this.repository.resolve((SQLStatement)x);
      }

      if (x.getWith() != null) {
         x.getWith().accept(this);
      }

      x.putAttribute("_original_use_mode", this.getMode());
      this.setMode(x, TableStat.Mode.Insert);
      SQLName tableName = x.getTableName();
      TableStat stat = this.getTableStat(tableName);
      stat.incrementInsertCount();
      this.accept(x.getColumns());
      this.accept(x.getQuery());
      return false;
   }

   public void endVisit(PGSelectStatement x) {
      this.endVisit((SQLSelectStatement)x);
   }

   public boolean visit(PGSelectStatement x) {
      return this.visit((SQLSelectStatement)x);
   }

   public void endVisit(PGUpdateStatement x) {
   }

   public boolean isPseudoColumn(long hash) {
      return PGUtils.isPseudoColumn(hash);
   }

   public boolean visit(PGUpdateStatement x) {
      if (this.repository != null && x.getParent() == null) {
         this.repository.resolve((SQLStatement)x);
      }

      if (x.getWith() != null) {
         x.getWith().accept(this);
      }

      TableStat stat = this.getTableStat(x.getTableName());
      stat.incrementUpdateCount();
      this.accept(x.getFrom());
      this.accept(x.getItems());
      this.accept(x.getWhere());
      return false;
   }

   public void endVisit(PGFunctionTableSource x) {
   }

   public boolean visit(PGFunctionTableSource x) {
      return true;
   }

   public void endVisit(PGTypeCastExpr x) {
   }

   public boolean visit(PGTypeCastExpr x) {
      x.getExpr().accept(this);
      return false;
   }

   public void endVisit(PGExtractExpr x) {
   }

   public boolean visit(PGExtractExpr x) {
      return true;
   }

   public void endVisit(PGBoxExpr x) {
   }

   public boolean visit(PGBoxExpr x) {
      return true;
   }

   public void endVisit(PGPointExpr x) {
   }

   public boolean visit(PGPointExpr x) {
      return true;
   }

   public void endVisit(PGMacAddrExpr x) {
   }

   public boolean visit(PGMacAddrExpr x) {
      return true;
   }

   public void endVisit(PGInetExpr x) {
   }

   public boolean visit(PGInetExpr x) {
      return true;
   }

   public void endVisit(PGCidrExpr x) {
   }

   public boolean visit(PGCidrExpr x) {
      return true;
   }

   public void endVisit(PGPolygonExpr x) {
   }

   public boolean visit(PGPolygonExpr x) {
      return true;
   }

   public void endVisit(PGCircleExpr x) {
   }

   public boolean visit(PGCircleExpr x) {
      return true;
   }

   public void endVisit(PGLineSegmentsExpr x) {
   }

   public boolean visit(PGLineSegmentsExpr x) {
      return true;
   }

   public void endVisit(PGShowStatement x) {
   }

   public boolean visit(PGShowStatement x) {
      return true;
   }

   public void endVisit(PGStartTransactionStatement x) {
   }

   public boolean visit(PGStartTransactionStatement x) {
      return true;
   }

   public void endVisit(PGConnectToStatement x) {
   }

   public boolean visit(PGConnectToStatement x) {
      return true;
   }

   public void endVisit(PGCreateSchemaStatement x) {
   }

   public boolean visit(PGCreateSchemaStatement x) {
      return true;
   }

   public void endVisit(PGDropSchemaStatement x) {
   }

   public boolean visit(PGDropSchemaStatement x) {
      return true;
   }

   public void endVisit(PGAlterSchemaStatement x) {
   }

   public boolean visit(PGAlterSchemaStatement x) {
      return true;
   }

   public void endVisit(PGOptionValue x) {
   }

   public boolean visit(PGOptionValue x) {
      return true;
   }

   public void endVisit(PGCreateTableStatement.PGTableDistributedBy x) {
   }

   public boolean visit(PGCreateTableStatement.PGTableDistributedBy x) {
      return true;
   }

   public void endVisit(PGAlterTableAddConstraint x) {
   }

   public boolean visit(PGAlterTableAddConstraint x) {
      return true;
   }

   public void endVisit(PGAlterTableAddConstraint.PGAlterTableAddConstraintUsingIndex x) {
   }

   public boolean visit(PGAlterTableAddConstraint.PGAlterTableAddConstraintUsingIndex x) {
      return true;
   }

   public void endVisit(PGAlterTableAlterColumn x) {
   }

   public boolean visit(PGAlterTableAlterColumn x) {
      return true;
   }

   public void endVisit(PGAlterTableAlterColumnOptions x) {
   }

   public boolean visit(PGAlterTableAlterColumnOptions x) {
      return true;
   }

   public void endVisit(PGAlterTableAlterColumnOptions.PGAlterTableAlterColumnOptionValue x) {
   }

   public boolean visit(PGAlterTableAlterColumnOptions.PGAlterTableAlterColumnOptionValue x) {
      return true;
   }

   public void endVisit(PGAlterTableCluster x) {
   }

   public boolean visit(PGAlterTableCluster x) {
      return true;
   }

   public void endVisit(PGAlterTableDisableEnabelTrigger x) {
   }

   public boolean visit(PGAlterTableDisableEnabelTrigger x) {
      return true;
   }

   public void endVisit(PGAlterTableDropColumn x) {
   }

   public boolean visit(PGAlterTableDropColumn x) {
      return true;
   }

   public void endVisit(PGAlterTableDropConstraint x) {
   }

   public boolean visit(PGAlterTableDropConstraint x) {
      return true;
   }

   public void endVisit(PGConstraint x) {
   }

   public boolean visit(PGConstraint x) {
      return true;
   }

   public void endVisit(PGConstraint.PGConstraintCheck x) {
   }

   public boolean visit(PGConstraint.PGConstraintCheck x) {
      return true;
   }

   public void endVisit(PGConstraint.PGIndexParamaters x) {
   }

   public boolean visit(PGConstraint.PGIndexParamaters x) {
      return true;
   }

   public void endVisit(PGConstraint.PGUnique x) {
   }

   public boolean visit(PGConstraint.PGUnique x) {
      return true;
   }

   public void endVisit(PGConstraint.PGForeignKey x) {
   }

   public boolean visit(PGConstraint.PGForeignKey x) {
      return true;
   }

   public void endVisit(PGConstraint.PGReference x) {
   }

   public boolean visit(PGConstraint.PGReference x) {
      return true;
   }

   public void endVisit(PGColumnSimpleDefinitionExpr x) {
   }

   public boolean visit(PGColumnSimpleDefinitionExpr x) {
      return true;
   }

   public void endVisit(PGValuesTableSource.ValueRow x) {
   }

   public boolean visit(PGValuesTableSource.ValueRow x) {
      return true;
   }

   public void endVisit(PGAlterTableInheriteOrNotParentTable x) {
   }

   public boolean visit(PGAlterTableInheriteOrNotParentTable x) {
      return true;
   }

   public void endVisit(PGAlterTableOf x) {
   }

   public boolean visit(PGAlterTableOf x) {
      return true;
   }

   public void endVisit(PGAlterTableRenameColumn x) {
   }

   public boolean visit(PGAlterTableRenameColumn x) {
      return true;
   }

   public void endVisit(PGAlterTableRenameConstraint x) {
   }

   public boolean visit(PGAlterTableRenameConstraint x) {
      return true;
   }

   public void endVisit(PGAlterTableRenameTo x) {
   }

   public boolean visit(PGAlterTableRenameTo x) {
      return true;
   }

   public void endVisit(PGAlterTableSetNewTableSpace x) {
   }

   public boolean visit(PGAlterTableSetNewTableSpace x) {
      return true;
   }

   public void endVisit(PGAlterTableSetReset x) {
   }

   public boolean visit(PGAlterTableSetReset x) {
      return true;
   }

   public void endVisit(PGAlterTableSetReset.StorageParameter x) {
   }

   public boolean visit(PGAlterTableSetReset.StorageParameter x) {
      return true;
   }

   public void endVisit(PGAlterTableSetSchema x) {
   }

   public boolean visit(PGAlterTableSetSchema x) {
      return true;
   }

   public void endVisit(PGAlterTableSetTableSpace x) {
   }

   public boolean visit(PGAlterTableSetTableSpace x) {
      return true;
   }

   public void endVisit(PGAlterTableSetWith x) {
   }

   public boolean visit(PGAlterTableSetWith x) {
      return true;
   }

   public void endVisit(PGAlterTableSetWith.PGAlterTableDistributeByOption x) {
   }

   public boolean visit(PGAlterTableSetWith.PGAlterTableDistributeByOption x) {
      return true;
   }

   public void endVisit(PGAlterTableValidateConstraint x) {
   }

   public boolean visit(PGAlterTableValidateConstraint x) {
      return true;
   }

   public boolean visit(PGSQLPartitionBy x) {
      return true;
   }

   public boolean visit(PGSQLIndexSpec x) {
      return true;
   }

   public boolean visit(PGSelectQueryBlock.ForClauses x) {
      return true;
   }

   public void endVisit(PGSelectQueryBlock.ForClauses x) {
   }

   public boolean visit(PGCreateSeqenceStatement x) {
      return true;
   }

   public boolean visit(PGCreateTableSpaceStatement x) {
      return true;
   }

   public boolean visit(PGAlterViewStatement x) {
      return true;
   }

   public boolean visit(PGSQLObjectCollection x) {
      return true;
   }

   public void endVisit(PGSQLObjectCollection x) {
   }

   public void endVisit(PGGrantStatement x) {
   }

   public boolean visit(PGGrantStatement x) {
      return true;
   }

   public void endVisit(PGSubqueryTableSource x) {
   }

   public boolean visit(PGSubqueryTableSource x) {
      return true;
   }

   public void endVisit(PGMethodInvokeTableSource x) {
   }

   public boolean visit(PGMethodInvokeTableSource x) {
      return true;
   }

   public void endVisit(PGExprTableSource x) {
   }

   public boolean visit(PGExprTableSource x) {
      return true;
   }

   public void endVisit(PGRowsFromTableSource x) {
   }

   public boolean visit(PGRowsFromTableSource x) {
      return true;
   }

   public void endVisit(PGAlterDatabaseStatement x) {
   }

   public boolean visit(PGAlterDatabaseStatement x) {
      return true;
   }

   public void endVisit(PGValuesTableSource x) {
   }

   public boolean visit(PGValuesTableSource x) {
      return true;
   }

   public void endVisit(PGAlterIndexStatement x) {
   }

   public boolean visit(PGAlterIndexStatement x) {
      return true;
   }

   public void endVisit(PGAlterSequenceStatement x) {
   }

   public boolean visit(PGAlterSequenceStatement x) {
      return true;
   }

   public void endVisit(PGAlterTableStatement x) {
   }

   public boolean visit(PGAlterTableStatement x) {
      return true;
   }

   public void endVisit(PGAlterTableAddColumn x) {
   }

   public boolean visit(PGAlterTableAddColumn x) {
      return true;
   }

   public void endVisit(PGCreateDatabaseStatement x) {
   }

   public boolean visit(PGCreateDatabaseStatement x) {
      return true;
   }

   public void endVisit(PGConstraint.PGPrimaryKey x) {
   }

   public boolean visit(PGConstraint.PGPrimaryKey x) {
      return true;
   }

   public void endVisit(PGCreateTableStatement x) {
   }

   public boolean visit(PGCreateTableStatement x) {
      return true;
   }

   public void endVisit(PGColumnDefinition x) {
   }

   public boolean visit(PGColumnDefinition x) {
      return true;
   }

   public void endVisit(PGStorageParameter x) {
   }

   public boolean visit(PGStorageParameter x) {
      return true;
   }

   public void endVisit(PGSchemaTables x) {
   }

   public boolean visit(PGSchemaTables x) {
      return true;
   }

   public boolean visit(PGCreateViewStatement x) {
      return true;
   }

   public boolean visit(PGDropSequenceStatement x) {
      return true;
   }

   public boolean visit(PGSQLPartition x) {
      return true;
   }

   public boolean visit(PGCreateIndexStatement x) {
      return true;
   }
}
