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
public class PostgreSqlDbmsBean extends AbstractDbmsBean
-
-
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 Constructor Description PostgreSqlDbmsBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
changeColumnDefinition(Connection c, String table, String column, String sqlType, boolean isNullable)
void
dropIndex(Connection c, String table, String index)
void
dropPrimaryKey(Connection c, String tableName)
Drops the primary key on a table.List<DbmsBean.ColumnDefinition>
getColumns(Connection c, @NotNull String table, @Nullable String column)
@NotNull String
getConcat(String... values)
Provide 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 constraintsDatabaseType
getDatabaseType()
Detect used database typeSet<String>
getIndexNames(@NotNull Connection c, @NotNull String table, @Nullable String column)
Returns indices set up on a given table, optionally narrowed down to a column.Collection<DbmsBean.IndexDefinition>
getIndices(@NotNull Connection c, @NotNull String table)
@NotNull String
getQuery(@NotNull SqlQueryProvider sqlQueryProvider)
Provide a different SQL query depending on SQL engine used.boolean
isPostgreSql()
protected boolean
isTable(List<String> definitionColumns)
boolean
isTablePresent(@NotNull Connection c, @NotNull String tableName)
Checks whether given table is present in the databaseprotected String
quoteIfNeeded(String name)
Some tables in db can be stored in a case sensitive manner.void
renameColumn(Connection c, String tableName, String oldName, String newName)
Rename columns.void
resizeVarcharColumn(@NotNull Connection connection, String tableName, String columnName, int newSize, boolean isNullable, @Nullable String defaultValue)
-
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, isColumnPresent, isColumnPresent, isColumnPresent, isH2, isHsqldb, isMsSqlServer, isMySql, isOracle, migrateColumnType, newColumnDefinition, quote, toLowerCase
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.utils.db.DbmsBean
getCatalog
-
-
-
-
Method Detail
-
getQuery
@NotNull public @NotNull String getQuery(@NotNull @NotNull SqlQueryProvider sqlQueryProvider)
Description copied from interface:DbmsBean
Provide a different SQL query depending on SQL engine used.- Returns:
-
getConcat
@NotNull public @NotNull String getConcat(String... values)
Description copied from interface:DbmsBean
Provide 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:DbmsBean
Fetch 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:
isPostgreSql
in interfaceDbmsBean
- Overrides:
isPostgreSql
in classAbstractDbmsBean
- Returns:
- true if db configured in Hibernate is PostgreSQL
-
getDatabaseType
public DatabaseType getDatabaseType()
Description copied from interface:BambooDatabaseTypeProvider
Detect used database type- Returns:
- database type
-
dropPrimaryKey
public void dropPrimaryKey(Connection c, String tableName) throws SQLException
Description copied from interface:DbmsBean
Drops 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:
changeColumnDefinition
in classAbstractDbmsBean
- Throws:
SQLException
-
dropIndex
public void dropIndex(Connection c, String table, String index) throws SQLException
- Specified by:
dropIndex
in interfaceDbmsBean
- Overrides:
dropIndex
in classAbstractDbmsBean
- Throws:
SQLException
-
renameColumn
public void renameColumn(Connection c, String tableName, String oldName, String newName) throws SQLException
Description copied from interface:DbmsBean
Rename columns.- Specified by:
renameColumn
in interfaceDbmsBean
- Specified by:
renameColumn
in classAbstractDbmsBean
- Throws:
SQLException
-
quoteIfNeeded
protected String quoteIfNeeded(String name)
Description copied from class:AbstractDbmsBean
Some 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:
quoteIfNeeded
in classAbstractDbmsBean
-
getIndexNames
public Set<String> getIndexNames(@NotNull @NotNull Connection c, @NotNull @NotNull String table, @Nullable @Nullable String column) throws SQLException
Description copied from interface:DbmsBean
Returns 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:
getIndexNames
in interfaceDbmsBean
- Overrides:
getIndexNames
in classAbstractDbmsBean
- Throws:
SQLException
-
getIndices
public Collection<DbmsBean.IndexDefinition> getIndices(@NotNull @NotNull Connection c, @NotNull @NotNull String table) throws SQLException
- Specified by:
getIndices
in interfaceDbmsBean
- Overrides:
getIndices
in classAbstractDbmsBean
- Throws:
SQLException
-
isTablePresent
public boolean isTablePresent(@NotNull @NotNull Connection c, @NotNull @NotNull String tableName) throws SQLException
Description copied from interface:DbmsBean
Checks whether given table is present in the database- Specified by:
isTablePresent
in interfaceDbmsBean
- Overrides:
isTablePresent
in 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
protected boolean isTable(List<String> definitionColumns)
- Overrides:
isTable
in classAbstractDbmsBean
-
getColumns
public List<DbmsBean.ColumnDefinition> getColumns(Connection c, @NotNull @NotNull String table, @Nullable @Nullable String column) throws SQLException
- Specified by:
getColumns
in interfaceDbmsBean
- Overrides:
getColumns
in classAbstractDbmsBean
- Throws:
SQLException
-
-