Package com.atlassian.bamboo.utils.db
Class PostgreSqlDbmsBean
java.lang.Object
com.atlassian.bamboo.utils.db.AbstractDbmsBean
com.atlassian.bamboo.utils.db.PostgreSqlDbmsBean
- All Implemented Interfaces:
BambooDatabaseTypeProvider,DbmsBean
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.bamboo.utils.db.DbmsBean
DbmsBean.ColumnDefinition, DbmsBean.ConstraintDefinition, DbmsBean.IndexDefinition -
Field Summary
Fields inherited from class com.atlassian.bamboo.utils.db.AbstractDbmsBean
LARGE_STRING_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidchangeColumnDefinition(Connection c, String table, String column, String sqlType, boolean isNullable) voiddropIndex(Connection c, String table, String index) voiddropPrimaryKey(Connection c, String tableName) Drops the primary key on a table.getColumns(Connection c, @NotNull String table, @Nullable String column) @NotNull StringProvide a different SQL concatenation operator depending on SQL engine used.@NotNull Collection<DbmsBean.ConstraintDefinition> getConstraints(Connection connection, @NotNull String table, @Nullable String column) Fetch information about constraintsDetect used database typegetIndexNames(@NotNull Connection c, @NotNull String table, @Nullable String column) Returns indices set up on a given table, optionally narrowed down to a column.getIndices(@NotNull Connection c, @NotNull String table) @NotNull StringgetQuery(@NotNull SqlQueryProvider sqlQueryProvider) Provide a different SQL query depending on SQL engine used.booleanprotected booleanbooleanisTablePresent(@NotNull Connection c, @NotNull String tableName) Checks whether given table is present in the databaseprotected StringquoteIfNeeded(String name) Some tables in db can be stored in a case sensitive manner.voidrenameColumn(Connection c, String tableName, String oldName, String newName) Rename columns.voidresizeVarcharColumn(@NotNull Connection connection, String tableName, String columnName, int newSize, boolean isNullable, @Nullable String defaultValue) protected StringunquoteIfNeeded(String name) Methods inherited from class com.atlassian.bamboo.utils.db.AbstractDbmsBean
actuallyChangeColumnToNotNull, addColumn, changeColumnToNotNull, changeColumnType, changeTableNameToUpperCase, clobEquals, createColumn, createIndex, createPrimaryKey, createUniqueConstraint, dropColumn, dropConstraint, dropConstraints, dropForeignKeyConstraint, dropIndexIfExists, dropTable, getColumnDefinition, getColumnDefinitionString, getConstraintDefinitions, getConstraintType, getLargeTextTypeName, getSchema, getSchemaUncached, getSqlTypeName, getTables, hasIndexOnColumns, isColumnPresent, isColumnPresent, isColumnPresent, isH2, isMsSqlServer, isMySql, isOracle, migrateColumnType, newColumnDefinition, quote, toLowerCaseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.bamboo.utils.db.DbmsBean
getCatalog
-
Constructor Details
-
PostgreSqlDbmsBean
public PostgreSqlDbmsBean()
-
-
Method Details
-
getQuery
Description copied from interface:DbmsBeanProvide a different SQL query depending on SQL engine used.- Parameters:
sqlQueryProvider-- Returns:
-
getConcat
Description copied from interface:DbmsBeanProvide a different SQL concatenation operator depending on SQL engine used.- Parameters:
values- the values to concatenate.- Returns:
- the concatenation SQL to append to a query.
-
getConstraints
@NotNull public @NotNull Collection<DbmsBean.ConstraintDefinition> getConstraints(Connection connection, @NotNull @NotNull String table, @Nullable @Nullable String column) throws SQLException Description copied from interface:DbmsBeanFetch information about constraints- Throws:
SQLException
-
resizeVarcharColumn
public void resizeVarcharColumn(@NotNull @NotNull Connection connection, String tableName, String columnName, int newSize, boolean isNullable, @Nullable @Nullable String defaultValue) throws SQLException - Throws:
SQLException
-
isPostgreSql
public boolean isPostgreSql()- Specified by:
isPostgreSqlin interfaceDbmsBean- Overrides:
isPostgreSqlin classAbstractDbmsBean- Returns:
- true if db configured in Hibernate is PostgreSQL
-
getDatabaseType
Description copied from interface:BambooDatabaseTypeProviderDetect used database type- Returns:
- database type
-
dropPrimaryKey
Description copied from interface:DbmsBeanDrops the primary key on a table.- Throws:
SQLException
-
changeColumnDefinition
protected void changeColumnDefinition(Connection c, String table, String column, String sqlType, boolean isNullable) throws SQLException - Overrides:
changeColumnDefinitionin classAbstractDbmsBean- Throws:
SQLException
-
dropIndex
- Specified by:
dropIndexin interfaceDbmsBean- Overrides:
dropIndexin classAbstractDbmsBean- Throws:
SQLException
-
renameColumn
public void renameColumn(Connection c, String tableName, String oldName, String newName) throws SQLException Description copied from interface:DbmsBeanRename columns.- Specified by:
renameColumnin interfaceDbmsBean- Specified by:
renameColumnin classAbstractDbmsBean- Throws:
SQLException
-
quoteIfNeeded
Description copied from class:AbstractDbmsBeanSome tables in db can be stored in a case sensitive manner. Then ala == ALA != "Ala" != "alA". This method ensures that the names leaving this bean can be used in a non-ambigous manner.- Overrides:
quoteIfNeededin classAbstractDbmsBean
-
unquoteIfNeeded
- Overrides:
unquoteIfNeededin classAbstractDbmsBean
-
getIndexNames
public Set<String> getIndexNames(@NotNull @NotNull Connection c, @NotNull @NotNull String table, @Nullable @Nullable String column) throws SQLException Description copied from interface:DbmsBeanReturns indices set up on a given table, optionally narrowed down to a column. For H2, it will also return implicit indices set up to support FK relationships. For SQL Server, it will return implicit PK indices. Case of returned index names is database specific - all comparisons should be case-independent.- Specified by:
getIndexNamesin interfaceDbmsBean- Overrides:
getIndexNamesin classAbstractDbmsBean- Throws:
SQLException
-
getIndices
public Collection<DbmsBean.IndexDefinition> getIndices(@NotNull @NotNull Connection c, @NotNull @NotNull String table) throws SQLException - Specified by:
getIndicesin interfaceDbmsBean- Overrides:
getIndicesin classAbstractDbmsBean- Throws:
SQLException
-
isTablePresent
public boolean isTablePresent(@NotNull @NotNull Connection c, @NotNull @NotNull String tableName) throws SQLException Description copied from interface:DbmsBeanChecks whether given table is present in the database- Specified by:
isTablePresentin interfaceDbmsBean- Overrides:
isTablePresentin classAbstractDbmsBean- Parameters:
c- connection used to verify DB table existencetableName- name of DB table- Returns:
- true if database is accessible and table exists, false otherwise
- Throws:
SQLException- if a database error occurs or connection is closed
-
isTable
- Overrides:
isTablein classAbstractDbmsBean
-
getColumns
public List<DbmsBean.ColumnDefinition> getColumns(Connection c, @NotNull @NotNull String table, @Nullable @Nullable String column) throws SQLException - Specified by:
getColumnsin interfaceDbmsBean- Overrides:
getColumnsin classAbstractDbmsBean- Throws:
SQLException
-