Package org.pgcodekeeper.core.schema
Class AbstractDatabase
java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.AbstractDatabase
- All Implemented Interfaces:
IHashable,IDatabase,IStatement,IStatementContainer
- Direct Known Subclasses:
ChDatabase,MsDatabase,PgDatabase
Abstract base class representing a database schema.
Contains schemas, handles database-specific operations, and manages object references
and analysis launchers for PostgreSQL, Microsoft SQL, and ClickHouse databases.
-
Field Summary
Fields inherited from class org.pgcodekeeper.core.schema.PgStatement
GO -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnalysisLauncher(AbstractAnalysisLauncher launcher) Add 'analysis launcher' for deferred analyze.voidaddLib(AbstractDatabase lib, String libName, String owner) Adds a library database to this database, merging its objects and analysis launchers.voidaddReference(String fileName, PgObjLocation loc) Adds an object reference to the specified file.voidaddSchema(AbstractSchema schema) Adds a schema to this database.appendAlterSQL(PgStatement newCondition, SQLScript script) Fill script with object changes and return change typevoidClears all analysis launchers and trims the internal list to size.booleancompare(PgStatement obj) This method does not account for nested child PgStatements.booleanDeep part ofPgStatement.equals(Object).voidcomputeChildrenHash(Hasher hasher) voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.booleancontainsSchema(String name) voidCopies analysis launchers from another database to this one.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.Gets the database that contains this statement.voidgetDropSQL(SQLScript script, boolean optionExists) Generates DROP SQL for this statement.getObjReferences(String name) Gets the list of object overrides for this database.Returns schema of given name or null if the schema has not been found.Getter forschemas.final PgStatementResolves and returns a database statement based on the provided generic column specification.final DbObjTypeGets the type of this database object.static Map<String,PgStatement> Creates a map of all database objects with their qualified names as keys.voidsetDefaultSchema(String name) voidsetVersion(SupportedPgVersion version) final AbstractDatabaseCopies all object properties into a new object and leaves all its children empty.Methods inherited from class org.pgcodekeeper.core.schema.PgStatement
addAllDeps, addDep, addPrivilege, appendAlterComments, appendComments, appendOwnerSQL, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, deepCopy, equals, getAuthor, getBareName, getChildren, getComment, getDbType, getDeps, getDescendants, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSQL, getTwin, getTypeName, hasChildren, hashCode, isLib, isOwned, isSubElement, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, toStringMethods inherited from interface org.pgcodekeeper.core.schema.IStatement
getBareName, getComment, getName, getParent, getQualifiedNameMethods inherited from interface org.pgcodekeeper.core.schema.IStatementContainer
addChild, getChild
-
Method Details
-
getOverrides
Gets the list of object overrides for this database.- Returns:
- the list of overrides
-
getStatementType
Description copied from interface:IStatementGets the type of this database object.- Specified by:
getStatementTypein interfaceIStatement- Returns:
- the database object type
-
getDatabase
Description copied from interface:IStatementGets the database that contains this statement.- Specified by:
getDatabasein interfaceIStatement- Returns:
- the containing database
-
getVersion
-
setVersion
-
getObjReferences
-
getObjReferences
-
addReference
Adds an object reference to the specified file.- Parameters:
fileName- the file name to associate with the locationloc- the object location to add
-
getAnalysisLaunchers
-
clearAnalysisLaunchers
public void clearAnalysisLaunchers()Clears all analysis launchers and trims the internal list to size. -
addAnalysisLauncher
Add 'analysis launcher' for deferred analyze.- Parameters:
launcher- launcher that contains almost everything needed to analyze a statement contained in it
-
getSchemas
Getter forschemas. The list cannot be modified.- Specified by:
getSchemasin interfaceIDatabase- Returns:
schemas
-
addSchema
Adds a schema to this database.- Parameters:
schema- the schema to add
-
setDefaultSchema
-
getDefaultSchema
-
containsSchema
-
getSchema
Returns schema of given name or null if the schema has not been found. If schema name is null then default schema is returned. -
getCreationSQL
Description copied from class:PgStatementGenerates the SQL statements needed to create this database object. This is an abstract method that must be implemented by subclasses to provide the specific CREATE SQL for each object type.- Specified by:
getCreationSQLin classPgStatement- Parameters:
script- the SQL script to append creation statements to
-
appendAlterSQL
Description copied from class:PgStatementFill script with object changes and return change type- Specified by:
appendAlterSQLin classPgStatement- Parameters:
newCondition- new object statescript- script to collect changes- Returns:
- object change type
-
getDropSQL
Description copied from class:PgStatementGenerates DROP SQL for this statement.- Overrides:
getDropSQLin classPgStatement- Parameters:
script- the SQL script to append the DROP statement tooptionExists- whether to include "IF EXISTS" in the DROP statement
-
computeHash
Description copied from interface:IHashableComputes the hash of the implementing object using the provided hasher. The implementation should call appropriateputmethods on the hasher for all fields that should contribute to the hash value.- Specified by:
computeHashin interfaceIHashable- Parameters:
hasher- the hasher instance to use for hash computation
-
computeChildrenHash
-
addLib
Adds a library database to this database, merging its objects and analysis launchers.- Parameters:
lib- the library database to addlibName- the name of the libraryowner- the owner to set for owned objects
-
listPgObjects
Creates a map of all database objects with their qualified names as keys.- Parameters:
db- the database to list objects from- Returns:
- a map of qualified names to statements
-
copyLaunchers
Copies analysis launchers from another database to this one.- Parameters:
db- the database to copy launchers from
-
compare
Description copied from class:PgStatementThis method does not account for nested child PgStatements. Shallow version ofPgStatement.equals(Object)- Overrides:
comparein classPgStatement
-
compareChildren
Description copied from class:PgStatementDeep part ofPgStatement.equals(Object). Compares all object's child PgStatements for equality.- Overrides:
compareChildrenin classPgStatement
-
shallowCopy
Description copied from class:PgStatementCopies all object properties into a new object and leaves all its children empty.- Specified by:
shallowCopyin classPgStatement- Returns:
- shallow copy of a DB object.
-
getStatement
Resolves and returns a database statement based on the provided generic column specification.- Parameters:
gc- the generic column specification containing type and naming information- Returns:
- the resolved statement, or null if not found
-