Class PgDumpLoader

java.lang.Object
org.pgcodekeeper.core.loader.DatabaseLoader
org.pgcodekeeper.core.loader.PgDumpLoader

public class PgDumpLoader extends DatabaseLoader
Database loader for SQL dump files. Parses SQL scripts using ANTLR and builds database schema objects with support for different parsing modes and statement overrides.
Author:
fordfrog
  • Constructor Details

    • PgDumpLoader

      public PgDumpLoader(InputStreamProvider input, String inputObjectName, ISettings settings, IMonitor monitor, int monitoringLevel)
      Creates a new dump loader with full configuration.
      Parameters:
      input - the input stream provider for the SQL dump
      inputObjectName - name of the input object for error reporting
      settings - loader settings and configuration
      monitor - progress monitor for tracking parsing progress
      monitoringLevel - level of progress monitoring detail
    • PgDumpLoader

      public PgDumpLoader(InputStreamProvider input, String inputObjectName, ISettings settings, IMonitor monitor)
      Creates a new dump loader with default monitoring level of 1.
      Parameters:
      input - the input stream provider for the SQL dump
      inputObjectName - name of the input object for error reporting
      settings - loader settings and configuration
      monitor - progress monitor for tracking parsing progress
    • PgDumpLoader

      public PgDumpLoader(InputStreamProvider input, String inputObjectName, ISettings settings)
      Creates a new dump loader with null progress monitor and no monitoring.
      Parameters:
      input - the input stream provider for the SQL dump
      inputObjectName - name of the input object for error reporting
      settings - loader settings and configuration
    • PgDumpLoader

      public PgDumpLoader(Path inputFile, ISettings settings, IMonitor monitor, int monitoringLevel)
      This constructor creates InputStreamProvider using inputFile parameter.
    • PgDumpLoader

      public PgDumpLoader(Path inputFile, ISettings settings, IMonitor monitor)
      Creates a new dump loader for a file path with default monitoring level of 1.
      Parameters:
      inputFile - the path to the SQL dump file
      settings - loader settings and configuration
      monitor - progress monitor for tracking parsing progress
    • PgDumpLoader

      public PgDumpLoader(Path inputFile, ISettings settings)
      Creates a new dump loader for a file path with null progress monitor and no monitoring.
      Parameters:
      inputFile - the path to the SQL dump file
      settings - loader settings and configuration
  • Method Details

    • setMode

      public void setMode(ParserListenerMode mode)
      Sets the parser listener mode for controlling parsing behavior.
      Parameters:
      mode - the parser listener mode to set
    • setOverridesMap

      public void setOverridesMap(Map<PgStatement,StatementOverride> overrides)
      Sets the statement overrides map for customizing parsed statements.
      Parameters:
      overrides - map of statement overrides
    • load

      Description copied from class: DatabaseLoader
      Loads database schema without performing full analysis.
      Specified by:
      load in class DatabaseLoader
      Returns:
      the loaded database schema
      Throws:
      IOException - if database loading fails
      InterruptedException - if the loading process is interrupted
    • loadAsync

      public AbstractDatabase loadAsync(AbstractDatabase d, Queue<AntlrTask<?>> antlrTasks) throws InterruptedException
      Loads SQL dump asynchronously into the provided database with default schema setup. Creates and adds a default schema based on database type, then delegates to loadDatabase.
      Parameters:
      d - the target database to load into
      antlrTasks - queue for managing ANTLR parsing tasks
      Returns:
      the loaded database with parsed SQL objects
      Throws:
      InterruptedException - if parsing is interrupted
    • loadDatabase

      public AbstractDatabase loadDatabase(AbstractDatabase intoDb, Queue<AntlrTask<?>> antlrTasks) throws InterruptedException
      Loads SQL dump into the specified database using ANTLR parsing. Selects appropriate parser listener based on database type and override configuration. Supports PostgreSQL, Microsoft SQL Server, and ClickHouse databases.
      Parameters:
      intoDb - the target database to load parsed objects into
      antlrTasks - queue for managing ANTLR parsing tasks
      Returns:
      the database with loaded SQL objects
      Throws:
      InterruptedException - if parsing is interrupted