Class AbstractSql2008Backend
- All Implemented Interfaces:
Backend
- Direct Known Subclasses:
Firebird
Paging uses the standard OFFSET and FETCH FIRST clauses instead of the
window function of AbstractSql2003Backend.
- Author:
- harald
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringFETCH FIRST string.static final StringOFFSET string.Fields inherited from class AbstractSql2003Backend
RESERVED_WORDS_SQL2003, SQL_WINDOW_1, SQL_WINDOW_2, SQL_WINDOW_LIMIT, SQL_WINDOW_OFFSETFields inherited from class AbstractSql92Backend
RESERVED_WORDS_SQL92, SQL_COALESCE, SQL_FOR_UPDATEFields inherited from class AbstractBackend
TYPE_BIGINT, TYPE_BIT, TYPE_BLOB, TYPE_BOOL, TYPE_BOOLEAN, TYPE_BYTE, TYPE_BYTEA, TYPE_CHAR_1, TYPE_CLOB, TYPE_DATE, TYPE_DATETIME, TYPE_DATETIME_6, TYPE_DATETIME_YEAR_TO_SECOND, TYPE_DECIMAL, TYPE_DECIMAL_19, TYPE_DOUBLE, TYPE_DOUBLE_PRECISION, TYPE_FLOAT, TYPE_FLOAT4, TYPE_FLOAT8, TYPE_INT, TYPE_INT2, TYPE_INT4, TYPE_INT8, TYPE_INTEGER, TYPE_JSON, TYPE_JSONB, TYPE_LONGBLOB, TYPE_LONGTEXT, TYPE_NCHAR_1, TYPE_NUMBER, TYPE_NUMBER_1, TYPE_NUMBER_10, TYPE_NUMBER_19, TYPE_NUMBER_5, TYPE_NVARCHAR, TYPE_NVARCHAR_MAX, TYPE_REAL, TYPE_SMALLFLOAT, TYPE_SMALLINT, TYPE_TEXT, TYPE_TIME, TYPE_TIME_6, TYPE_TIMESTAMP, TYPE_TINYINT, TYPE_UUID, TYPE_VARBINARY_MAX, TYPE_VARCHAR, TYPE_XML, TYPE_XMLTYPEFields inherited from interface Backend
SQL_ALLSTAR, SQL_ALTER_COLUMN, SQL_ALTER_INDEX, SQL_ALTER_TABLE, SQL_AND, SQL_ANDNOT, SQL_ARRAY_ALL, SQL_ARRAY_ALL_PAR, SQL_ARRAY_ANY, SQL_ARRAY_ANY_PAR, SQL_ARRAY_IN, SQL_ARRAY_IN_PAR, SQL_ARRAY_NOT_IN, SQL_ARRAY_NOT_IN_PAR, SQL_ARRAY_PAR, SQL_COMMA, SQL_COMMA_PAR, SQL_DELETE, SQL_DELETE_FROM, SQL_DOT_STAR, SQL_EQUAL, SQL_EQUAL_PAR, SQL_EQUAL_PAR_COMMA, SQL_EQUAL_ZERO, SQL_EXISTS, SQL_FROM, SQL_GREATER, SQL_GREATER_PAR, SQL_GREATEROREQUAL, SQL_GREATEROREQUAL_PAR, SQL_GROUPBY, SQL_IF_EXISTS, SQL_INSERT_INTO, SQL_INSERT_VALUES, SQL_ISNOTNULL, SQL_ISNULL, SQL_LEFT_PARENTHESIS, SQL_LESS, SQL_LESS_PAR, SQL_LESSOREQUAL, SQL_LESSOREQUAL_PAR, SQL_LIKE, SQL_LIKE_PAR, SQL_MAX, SQL_MIN, SQL_NOT, SQL_NOTEQUAL, SQL_NOTEQUAL_PAR, SQL_NOTEQUAL_ZERO, SQL_NOTLIKE, SQL_NOTLIKE_PAR, SQL_OR, SQL_ORDERBY, SQL_ORNOT, SQL_PAR, SQL_PAR_COMMA, SQL_PLUS_ONE, SQL_RIGHT_PARENTHESIS, SQL_SELECT, SQL_SELECT_ALL_FROM, SQL_SET, SQL_SORTASC, SQL_SORTDESC, SQL_UPDATE, SQL_WHERE, SQL_WHEREALL, SQL_WHEREAND, SQL_WHERENOTHING, SQL_WHEREOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildSelectSql(StringBuilder sqlBuilder, boolean writeLock, int limit, int offset) Creates a select statement string from an inner SQL string.intsetTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset) Sets optional parameters after applying the original parameters.Methods inherited from class AbstractSql2003Backend
getReservedWords, isSequenceSupported, setLeadingSelectParameters, sqlCreateSequence, sqlNextFromSequenceMethods inherited from class AbstractSql92Backend
getCoalesceKeyword, isLeadingSelectMissing, removeLeadingSelect, sqlCreateForeignKey, sqlCreateSequenceComment, sqlCreateUniqueConstraint, sqlDropConstraint, sqlDropForeignKeyMethods inherited from class AbstractBackend
assertValidName, buildSelectSql, columnTypeNullDefaultToString, columnTypeToString, createColumnMetaData, createConnection, createIndexColumnMetaData, createIndexMetaData, createPassword, createScriptRunner, createTableMetaData, createXADataSource, enrichIndexDeferrability, getBlockCommentBegin, getBlockCommentBegins, getBlockCommentEnd, getBlockCommentEnds, getDefaultSchema, getDefaultSize, getDummySelect, getEmptyString, getIndexMetaDataCommentColumnName, getJson, getMaxNameLength, getMaxScale, getMaxSize, getMetaData, getMigrationStrategy, getModelMetaData, getSingleLineComment, getSingleLineComments, getStatementSeparator, getStatementSeparators, getTableHeaders, getTableMetaData, getXADataSourceClassName, isAliasRequiredForSubSelect, isArrayOperatorSupported, isClobSupported, isCommunicationLinkException, isConstraintException, isDatabaseInMemory, isDefaultEqual, isDeprecated, isDropIfExistsEnabled, isDropIfExistsSupported, isExceptionErrorCodeMatching, isExceptionStateMatching, isExceptionStateStartingWith, isExpressionReferringToTableBeingUpdatedSupported, isExtraCommitRequired, isFilteredIndexSupported, isFunctionBasedIndexSupported, isJsonSupported, isMatchingName, isPosixEscapeSyntaxSupported, isReleaseSavepointSupported, isReservedSchemaName, isReservedTableName, isReservedWord, isSchemaSupported, isSetConstraintsDeferredSupported, isSqlxmlSupported, isTemporaryName, isTransientTransactionException, isTxRequiredForFetchsize, isUUIDSupported, jdbcTypeToSqlType, jdbcTypeToSqlType, normalizeDefault, optimizeSql, reduceSql, reduceSql, setArray, setDataSourceProperty, setDropIfExistsEnabled, setJson, sqlAddColumn, sqlAlterColumnComment, sqlAlterColumnDefault, sqlAlterColumnNullConstraint, sqlAlterColumnNullConstraint, sqlAlterColumnType, sqlAlterIndexComment, sqlAlterTableComment, sqlAsBeforeTableAlias, sqlComment, sqlCreateColumn, sqlCreateColumnComment, sqlCreateIndex, sqlCreateIndexComment, sqlCreateSchema, sqlCreateTableAttributeWithoutComment, sqlCreateTableClosing, sqlCreateTableComment, sqlCreateTableIntro, sqlCreateTableIntroWithoutComment, sqlDropColumn, sqlDropIndex, sqlDropTable, sqlFunction, sqlJoin, sqlJoinSelects, sqlJoinSelects, sqlRenameAndAlterColumnType, sqlRenameColumn, sqlRenameIndex, sqlRenameTable, sqlSetConstraintsDeferred, sqlTypeToString, sqlUpdateToNotNull, toInternalType, toQuotedString, toString, validateVersion, valueToLiteralMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Backend
getBackendId, getDriverClassName, getName, isMatchingUrl
-
Field Details
-
SQL_OFFSET
-
SQL_FETCH_FIRST
-
-
Constructor Details
-
AbstractSql2008Backend
public AbstractSql2008Backend()Parent constructor.
-
-
Method Details
-
buildSelectSql
Creates a select statement string from an inner SQL string.sqlBuilderis anything like[SELECT] FROM... WHERE... ORDER BY....
It is decorated with a leadingSELECT, if missing, plus optional LIMIT, OFFSET and FOR UPDATE clauses according to the given parameters.Notice that not all backends support a write lock combined with a limit or offset.
With a limit or offset, the original select is wrapped into an enclosing select that filters by row number. A write lock cannot be combined with a limit or offset, since most databases refuse
FOR UPDATEwithin a nested select.The clauses follow the order of the SQL standard: the OFFSET clause precedes the FETCH FIRST clause and the locking clause comes last. The trailing parameters are bound in the same order (see
setTrailingSelectParameters(BackendPreparedStatement, int, int, int)).- Specified by:
buildSelectSqlin interfaceBackend- Overrides:
buildSelectSqlin classAbstractSql2003Backend- Parameters:
sqlBuilder- the SQL builder, initially containing the inner SQL with or without leadingSELECTwriteLock- true if the select should write-locklimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause
-
setTrailingSelectParameters
public int setTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset) Sets optional parameters after applying the original parameters.Because the limit is applied as an upper bound of the row number, it is bound as
offset + limit.The offset is bound before the limit, which is the number of rows to fetch.
- Specified by:
setTrailingSelectParametersin interfaceBackend- Overrides:
setTrailingSelectParametersin classAbstractSql2003Backend- Parameters:
stmt- the prepared statementindex- the first parameter indexlimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause- Returns:
- the next parameter index
-