"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hsqldb/src/org/hsqldb/RangeVariable.java" between
hsqldb-2.7.1.zip and hsqldb-2.7.2.zip

About: HSQLDB (HyperSQL DataBase) is a SQL relational database engine written in Java. It supports nearly full ANSI-92 SQL (BNF format) and full core SQL:2008.

RangeVariable.java  (hsqldb-2.7.1):RangeVariable.java  (hsqldb-2.7.2)
/* Copyright (c) 2001-2022, The HSQL Development Group /* Copyright (c) 2001-2023, The HSQL Development Group
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* Redistributions of source code must retain the above copyright notice, this * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* Redistributions in binary form must reproduce the above copyright notice, * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
skipping to change at line 57 skipping to change at line 57
import org.hsqldb.lib.OrderedLongHashSet; import org.hsqldb.lib.OrderedLongHashSet;
import org.hsqldb.navigator.RangeIterator; import org.hsqldb.navigator.RangeIterator;
import org.hsqldb.navigator.RowIterator; import org.hsqldb.navigator.RowIterator;
import org.hsqldb.persist.PersistentStore; import org.hsqldb.persist.PersistentStore;
import org.hsqldb.types.Type; import org.hsqldb.types.Type;
/** /**
* Metadata for range variables, including conditions. * Metadata for range variables, including conditions.
* *
* @author Fred Toussi (fredt@users dot sourceforge.net) * @author Fred Toussi (fredt@users dot sourceforge.net)
* @version 2.6.1 * @version 2.7.2
* @since 1.9.0 * @since 1.9.0
*/ */
public class RangeVariable { public class RangeVariable {
static final RangeVariable[] emptyArray = new RangeVariable[]{}; static final RangeVariable[] emptyArray = new RangeVariable[]{};
// //
public static final int TABLE_RANGE = 1; public static final int TABLE_RANGE = 1;
public static final int TRANSITION_RANGE = 2; public static final int TRANSITION_RANGE = 2;
public static final int PARAMETER_RANGE = 3; public static final int PARAMETER_RANGE = 3;
skipping to change at line 1890 skipping to change at line 1890
if (e == null) { if (e == null) {
return; return;
} }
if (e instanceof ExpressionLogical) { if (e instanceof ExpressionLogical) {
if (((ExpressionLogical) e).isTerminal) { if (((ExpressionLogical) e).isTerminal) {
terminalCondition = e; terminalCondition = e;
} }
} }
nonIndexCondition = addToNonIndexCondition(e);
ExpressionLogical.andExpressions(nonIndexCondition, e);
isFalse = Expression.EXPR_FALSE.equals(nonIndexCondition); isFalse = Expression.EXPR_FALSE.equals(nonIndexCondition);
if (rangeIndex == null || rangeIndex.getColumnCount() == 0) { if (rangeIndex == null || rangeIndex.getColumnCount() == 0) {
return; return;
} }
if (indexedColumnCount == 0) { if (indexedColumnCount == 0) {
return; return;
} }
skipping to change at line 1918 skipping to change at line 1918
switch (e.getType()) { switch (e.getType()) {
case OpTypes.GREATER : case OpTypes.GREATER :
case OpTypes.GREATER_EQUAL : case OpTypes.GREATER_EQUAL :
case OpTypes.GREATER_EQUAL_PRE : { case OpTypes.GREATER_EQUAL_PRE : {
// replaces existing condition // replaces existing condition
if (opType == OpTypes.NOT) { if (opType == OpTypes.NOT) {
if (indexCols[indexedColumnCount - 1] == colIndex) { if (indexCols[indexedColumnCount - 1] == colIndex) {
nonIndexCondition = addToNonIndexCondition(
ExpressionLogical.andExpressions( indexCond[indexedColumnCount - 1]);
nonIndexCondition,
indexCond[indexedColumnCount - 1]);
indexCond[indexedColumnCount - 1] = e; indexCond[indexedColumnCount - 1] = e;
opType = e.opType; opType = e.opType;
opTypes[indexedColumnCount - 1] = e.opType; opTypes[indexedColumnCount - 1] = e.opType;
if (e.getType() == OpTypes.GREATER_EQUAL_PRE if (e.getType() == OpTypes.GREATER_EQUAL_PRE
&& indexedColumnCount == 1) { && indexedColumnCount == 1) {
indexEndCond[indexedColumnCount - 1] = indexEndCond[indexedColumnCount - 1] =
ExpressionLogical.andExpressions( ExpressionLogical.andExpressions(
indexEndCond[indexedColumnCount - 1], indexEndCond[indexedColumnCount - 1],
e.nodes[2]); e.nodes[2]);
skipping to change at line 1952 skipping to change at line 1951
if (opType == OpTypes.GREATER if (opType == OpTypes.GREATER
|| opType == OpTypes.GREATER_EQUAL || opType == OpTypes.GREATER_EQUAL
|| opType == OpTypes.GREATER_EQUAL_PRE || opType == OpTypes.GREATER_EQUAL_PRE
|| opType == OpTypes.NOT) { || opType == OpTypes.NOT) {
if (opTypeEnd != OpTypes.MAX) { if (opTypeEnd != OpTypes.MAX) {
break; break;
} }
if (indexCols[indexedColumnCount - 1] == colIndex) { if (indexCols[indexedColumnCount - 1] == colIndex) {
indexEndCond[indexedColumnCount - 1] = e; indexEndCond[indexedColumnCount - 1] = e;
indexEndCondition =
ExpressionLogical.andExpressions( addToIndexEndCondition(e);
indexEndCondition, e);
opTypeEnd = e.opType; opTypeEnd = e.opType;
opTypesEnd[indexedColumnCount - 1] = e.opType; opTypesEnd[indexedColumnCount - 1] = e.opType;
} }
} else { } else {
addToIndexEndConditions(e); addToIndexEndConditions(e);
} }
break; break;
} }
default : default :
skipping to change at line 2002 skipping to change at line 2001
if (opType == OpTypes.EQUAL || opType == OpTypes.IS_NULL) { if (opType == OpTypes.EQUAL || opType == OpTypes.IS_NULL) {
if (indexedColumnCount < rangeIndex.getColumnCount()) { if (indexedColumnCount < rangeIndex.getColumnCount()) {
if (rangeIndex.getColumns()[indexedColumnCount] if (rangeIndex.getColumns()[indexedColumnCount]
== e.getLeftNode().getColumnIndex()) { == e.getLeftNode().getColumnIndex()) {
Expression condition = Expression condition =
ExpressionLogical.newNotNullCondition( ExpressionLogical.newNotNullCondition(
e.getLeftNode()); e.getLeftNode());
indexCond[indexedColumnCount] = condition; indexCond[indexedColumnCount] = condition;
indexEndCond[indexedColumnCount] = e; indexEndCond[indexedColumnCount] = e;
indexEndCondition =
ExpressionLogical.andExpressions(indexEndCondition, addToIndexEndCondition(e);
e);
opType = OpTypes.NOT; opType = OpTypes.NOT;
opTypes[indexedColumnCount] = OpTypes.NOT; opTypes[indexedColumnCount] = OpTypes.NOT;
opTypeEnd = e.opType; opTypeEnd = e.opType;
opTypesEnd[indexedColumnCount] = e.opType; opTypesEnd[indexedColumnCount] = e.opType;
indexedColumnCount++; indexedColumnCount++;
return true; return true;
} }
} }
skipping to change at line 2084 skipping to change at line 2083
break; break;
} }
case OpTypes.IS_NULL : case OpTypes.IS_NULL :
case OpTypes.EQUAL : { case OpTypes.EQUAL : {
indexCond = exprList; indexCond = exprList;
for (int i = 0; i < colCount; i++) { for (int i = 0; i < colCount; i++) {
Expression e = exprList[i]; Expression e = exprList[i];
indexEndCond[i] = e; indexEndCond[i] = e;
indexEndCondition =
ExpressionLogical.andExpressions(indexEndCondition, addToIndexEndCondition(e);
e);
opType = e.opType; opType = e.opType;
opTypes[i] = e.opType; opTypes[i] = e.opType;
opTypesEnd[i] = e.opType; opTypesEnd[i] = e.opType;
} }
opTypeEnd = opType; opTypeEnd = opType;
break; break;
} }
default : default :
throw Error.runtimeError(ErrorCode.U_S0500, throw Error.runtimeError(ErrorCode.U_S0500,
"RangeVariable"); "RangeVariable");
} }
indexedColumnCount = colCount; indexedColumnCount = colCount;
hasIndex = true; hasIndex = true;
} }
boolean addToIndexEndCondition(Expression e) {
indexEndCondition =
ExpressionLogical.andExpressions(indexEndCondition, e);
return true;
}
boolean addToNonIndexCondition(Expression e) {
nonIndexCondition =
ExpressionLogical.andExpressions(nonIndexCondition, e);
return true;
}
private void reverseIndexCondition() { private void reverseIndexCondition() {
if (indexedColumnCount == 0) { if (indexedColumnCount == 0) {
reversed = true; reversed = true;
return; return;
} }
if (opType == OpTypes.EQUAL || opType == OpTypes.IS_NULL) { if (opType == OpTypes.EQUAL || opType == OpTypes.IS_NULL) {
skipping to change at line 2132 skipping to change at line 2147
indexEndCond = temp; indexEndCond = temp;
int[] temptypes = opTypes; int[] temptypes = opTypes;
opTypes = opTypesEnd; opTypes = opTypesEnd;
opTypesEnd = temptypes; opTypesEnd = temptypes;
for (int i = 0; i < indexedColumnCount; i++) { for (int i = 0; i < indexedColumnCount; i++) {
Expression e = indexEndCond[i]; Expression e = indexEndCond[i];
indexEndCondition = addToIndexEndCondition(e);
ExpressionLogical.andExpressions(indexEndCondition, e);
} }
if (indexedColumnCount > 1 if (indexedColumnCount > 1
&& opTypes[indexedColumnCount - 1] == OpTypes.MAX) { && opTypes[indexedColumnCount - 1] == OpTypes.MAX) {
indexedColumnCount--; indexedColumnCount--;
opTypes[indexedColumnCount] = 0; opTypes[indexedColumnCount] = 0;
opTypesEnd[indexedColumnCount] = 0; opTypesEnd[indexedColumnCount] = 0;
} }
 End of changes. 9 change blocks. 
19 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)