Class PostgreSqlDdlBuilder
java.lang.Object
org.jumpmind.db.platform.AbstractDdlBuilder
org.jumpmind.db.platform.postgresql.PostgreSqlDdlBuilder
- All Implemented Interfaces:
IDdlBuilder
- Direct Known Subclasses:
GreenplumDdlBuilder,PostgreSqlDdlBuilder95
-
Field Summary
Fields inherited from class org.jumpmind.db.platform.AbstractDdlBuilder
caseSensitive, databaseInfo, databaseName, delimitedIdentifierModeOn, log, scriptModeOn, SIZE_PLACEHOLDER, sqlCommentsOn -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateTable(Table table, StringBuilder ddl, boolean temporary, boolean recreate) Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).protected voiddropTable(Table table, StringBuilder ddl, boolean temporary, boolean recreate) Outputs the DDL to drop the table.getSelectLastIdentityValues(Table table) Generates the SQL for querying the id that was created in the last insertion operation.getSqlType(Column column) Returns the full SQL type specification (including size and precision/scale) for the given column.static booleanstatic booleanmapDefaultValue(Object defaultValue, Column column) protected voidprintDefaultValue(String defaultValue, Column column, StringBuilder ddl) Prints the default value of the column.protected voidprocessChange(Database currentModel, Database desiredModel, AddColumnChange change, StringBuilder ddl) protected booleanprocessChange(Database currentModel, Database desiredModel, ColumnAutoIncrementChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, ColumnDefaultValueChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, ColumnRequiredChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, ColumnSizeChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, PrimaryKeyChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, RemoveColumnChange change, StringBuilder ddl) protected voidprocessTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, List<TableChange> changes, StringBuilder ddl) Allows database-specific implementations to handle changes in a database specific manner.protected booleanshouldUseQuotes(String defaultValue, Column column) protected booleanprotected voidwriteCastExpression(Column sourceColumn, Column targetColumn, StringBuilder ddl) Writes a cast expression that converts the value of the source column to the data type of the target column.protected voidwriteColumnAutoIncrementStmt(Table table, Column column, StringBuilder ddl) Prints that the column is an auto increment column.voidwriteExternalIndexDropStmt(Table table, IIndex index, StringBuilder ddl) Generates the statement to drop a non-embedded index from the database.protected voidwriteGeneratedColumn(Table table, Column column, StringBuilder ddl) Methods inherited from class org.jumpmind.db.platform.AbstractDdlBuilder
addEscapedCharSequence, alterDatabase, alterDatabase, alterTable, areColumnSizesTheSame, areEqual, areMappedTypesTheSame, copy, createBackupTableFor, createExternalForeignKeys, createExternalForeignKeys, createTable, createTables, createTables, createTemporaryTable, dropExternalForeignKeys, dropTable, dropTables, dropTables, dropTemporaryTable, escapeStringValue, filterChanges, filterColumnSqlType, findCorrespondingForeignKey, findForeignKey, findTable, fixLastIdentityValues, getBackupTableFor, getBareNativeType, getColumnName, getColumnTypeDdl, getConstraintName, getCopyDataColumnMapping, getCopyDataColumnOrderedMapping, getDatabaseInfo, getDefaultValueHelper, getDefinitionForGeneratedColumn, getDeleteSql, getDelimitedIdentifier, getDetectedChanges, getForeignKeyName, getFullyQualifiedIndexNameShorten, getFullyQualifiedTableNameShorten, getGapLimitSize, getIndent, getIndexName, getInsertSql, getNativeDefaultValue, getNativeType, getRealTargetTableFor, getSize, getTableName, getTemporaryTableFor, getTemporaryTableFor, getUpdateSql, getValueAsString, getValueDateFormat, getValueLocale, getValueNumberFormat, getValueTimeFormat, hasSize, initCteExpression, isAlterDatabase, isCaseSensitive, isDelimitedIdentifierModeOn, isFullTextIndex, isScriptModeOn, isSpecifyIdentityGapLimit, isSqlCommentsOn, isValidDefaultValue, mergeOrRemovePlatformTypes, printComment, printEndOfStatement, printIdentifier, printIndent, println, println, printlnIdentifier, printStartOfEmbeddedStatement, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChanges, processChanges, processTableStructureChanges, processTableStructureChanges, renameTable, restoreTableFromBackup, setCaseSensitive, setDelimitedIdentifierModeOn, setIndent, setScriptModeOn, setSqlCommentsOn, setValueDateFormat, setValueLocale, setValueNumberFormat, setValueTimeFormat, shortenName, shouldGeneratePrimaryKeys, writeCascadeAttributesForForeignKey, writeCascadeAttributesForForeignKeyDelete, writeCascadeAttributesForForeignKeyUpdate, writeColumn, writeColumnDefaultValue, writeColumnDefaultValueStmt, writeColumnEmbeddedPrimaryKey, writeColumnNotNullableStmt, writeColumnNullableStmt, writeColumns, writeColumnType, writeColumnTypeDefaultRequired, writeColumnUniqueStmt, writeCopyDataStatement, writeCopyDataStatement, writeEmbeddedForeignKeysStmt, writeEmbeddedIndexCreateStmt, writeEmbeddedIndicesStmt, writeEmbeddedPrimaryKeysStmt, writeExternalForeignKeyCreateStmt, writeExternalForeignKeyDropStmt, writeExternalIndexCreate, writeExternalIndexCreateStmt, writeExternalIndicesCreateStmt, writeExternalPrimaryKeysCreateStmt, writeFixLastIdentityValues, writeForeignReferences, writeIdentityGapLimit, writeLocalReferences, writePrimaryKeyStmt, writeTableAlterStmt, writeTableComment, writeTableCreationStmt, writeTableCreationStmtEnding
-
Constructor Details
-
PostgreSqlDdlBuilder
public PostgreSqlDdlBuilder()
-
-
Method Details
-
mapDefaultValue
- Specified by:
mapDefaultValuein interfaceIDdlBuilder- Overrides:
mapDefaultValuein classAbstractDdlBuilder
-
isUsePseudoSequence
public static boolean isUsePseudoSequence() -
isMapCharToJson
public static boolean isMapCharToJson() -
dropTable
Description copied from class:AbstractDdlBuilderOutputs the DDL to drop the table. Note that this method does not drop foreign keys to this table. Use#dropTable(Database, Table)if you want that.- Overrides:
dropTablein classAbstractDdlBuilderrecreate- TODO
-
writeAlterColumnDataTypeToBigInt
- Overrides:
writeAlterColumnDataTypeToBigIntin classAbstractDdlBuilder
-
writeExternalIndexDropStmt
Description copied from class:AbstractDdlBuilderGenerates the statement to drop a non-embedded index from the database.- Overrides:
writeExternalIndexDropStmtin classAbstractDdlBuilder
-
createTable
Description copied from class:AbstractDdlBuilderOutputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).- Overrides:
createTablein classAbstractDdlBuilderrecreate- TODO
-
writeColumnAutoIncrementStmt
Description copied from class:AbstractDdlBuilderPrints that the column is an auto increment column.- Overrides:
writeColumnAutoIncrementStmtin classAbstractDdlBuilder
-
writeGeneratedColumn
- Overrides:
writeGeneratedColumnin classAbstractDdlBuilder
-
getSelectLastIdentityValues
Description copied from class:AbstractDdlBuilderGenerates the SQL for querying the id that was created in the last insertion operation. This is obviously only useful for pk fields that are auto-incrementing. A database that does not support this, will returnnull.- Overrides:
getSelectLastIdentityValuesin classAbstractDdlBuilder- Parameters:
table- The table- Returns:
- The sql, or
nullif the database does not support this
-
writeCastExpression
Description copied from class:AbstractDdlBuilderWrites a cast expression that converts the value of the source column to the data type of the target column. Per default, simply the name of the source column is written thereby assuming that any casts happen implicitly.- Overrides:
writeCastExpressionin classAbstractDdlBuilder
-
processTableStructureChanges
protected void processTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, List<TableChange> changes, StringBuilder ddl) Description copied from class:AbstractDdlBuilderAllows database-specific implementations to handle changes in a database specific manner. Any handled change should be applied to the given current model (which is a copy of the real original model) and be removed from the list of changes.
In the default implementation, allAddPrimaryKeyChangechanges are applied via anALTER TABLE ADD CONSTRAINTstatement.- Overrides:
processTableStructureChangesin classAbstractDdlBuilder- Parameters:
currentModel- The current database schemadesiredModel- The desired database schemasourceTable- The original tabletargetTable- The desired tablechanges- The change objects for the target table
-
processChange
protected void processChange(Database currentModel, Database desiredModel, PrimaryKeyChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, AddColumnChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, RemoveColumnChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, ColumnDefaultValueChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, ColumnRequiredChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, ColumnSizeChange change, StringBuilder ddl) -
processChange
protected boolean processChange(Database currentModel, Database desiredModel, ColumnAutoIncrementChange change, StringBuilder ddl) -
printDefaultValue
Description copied from class:AbstractDdlBuilderPrints the default value of the column.- Overrides:
printDefaultValuein classAbstractDdlBuilder
-
shouldUseQuotes
- Overrides:
shouldUseQuotesin classAbstractDdlBuilder
-
getSqlType
Description copied from class:AbstractDdlBuilderReturns the full SQL type specification (including size and precision/scale) for the given column.- Specified by:
getSqlTypein interfaceIDdlBuilder- Overrides:
getSqlTypein classAbstractDdlBuilder- Parameters:
column- The column- Returns:
- The full SQL type string including the size
-