id
stringlengths
22
25
commit_message
stringlengths
137
6.96k
diffs
listlengths
0
63
derby-DERBY-4224-8b8fe9f9
DERBY-4312 SQLException XJ215 on insert with setCharacterStream() and autocommit off in mailjdbc test DERBY-4224 Commit after setAsciiStream() makes execution fail with the client driver Use of a stream after performing commit was incorrectly causing an exception. Also fixes setBinaryStream(); git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@796020 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4228-08b83a83
DERBY-4228: Remove unused pre-i18n constructors in BatchUpdateException git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@774471 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/client/org/apache/derby/client/am/BatchUpdateException.java", "hunks": [ { "added": [], "header": "@@ -21,7 +21,6 @@", "removed": [ "import org.apache.derby.iapi.services.info.JVMInfo;" ] }, { "added": [], "header": "@@ -75,36 +74,4 @@ public class BatchUpdateException extends java.sql.BatchUpdateException {", "removed": [ " ", " //-----------------old constructors - to be removed when i18n is complete", " //-----------------------------------------------", "", " // Temporary constructor until all error keys are defined.", " public BatchUpdateException(LogWriter logWriter) {", " this(logWriter, null, null, SqlException.DEFAULT_ERRCODE, null);", " }", "", " // Temporary constructor until all error keys are defined.", " public BatchUpdateException(LogWriter logWriter, int[] updateCounts) {", " this(logWriter, null, null, SqlException.DEFAULT_ERRCODE, updateCounts);", " }", "", " // Temporary constructor until all error keys are defined.", " public BatchUpdateException(LogWriter logWriter, String reason, int[] updateCounts) {", " this(logWriter, reason, null, SqlException.DEFAULT_ERRCODE, updateCounts);", " }", "", " // Temporary constructor until all error keys are defined.", " public BatchUpdateException(LogWriter logWriter, String reason, String sqlState, int[] updateCounts) {", " this(logWriter, reason, sqlState, SqlException.DEFAULT_ERRCODE, updateCounts);", " }", "", " // Temporary constructor until all error keys are defined.", " public BatchUpdateException(LogWriter logWriter, String reason, String sqlState, int errorCode, int[] updateCounts) {", " super(reason, sqlState, errorCode, updateCounts);", " if (logWriter != null) {", " logWriter.traceDiagnosable(this);", " }", " }", "" ] } ] } ]
derby-DERBY-4230-53cbb534
DERBY-4230 DatabaseMetaData.getColumns() returns extra column from view with group by and expression in SELECT list git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@777500 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java", "hunks": [ { "added": [ "\t\t// System columns should only include visible columns DERBY-4230", "\t\tcolInfos = new ColumnInfo[queryExpression.getResultColumns().visibleSize()];" ], "header": "@@ -220,7 +220,8 @@ public class CreateViewNode extends DDLStatementNode", "removed": [ "\t\tcolInfos = new ColumnInfo[queryExpression.getResultColumns().size()];" ] } ] } ]
derby-DERBY-4232-52acd5a8
DERBY-4232: XAResource.setTransactionTimeout() makes XAResource.start() fail with the client driver Only send the timeout property when start() is called with TMNOFLAGS, as specified in DRDAv4 (volume 3, SYNCCTL, page 872). git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@788674 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4239-731568d3
DERBY-4239 In the case of inplace compress it is necessary to get a valid checkpoint into the log file after any other log record for the table being compressed. This insures that if redo recovery is run, it will not be applied to any log record before the compress. This is necessary as compress will basically destroy a page and redo recovery will get various errors if it tries to apply a redo page operation at page version N against a new page. Before this fix the requested checkpoint would not be executed if a checkpoint was already in progress. The problem is that there is no way to tell if the executing checkpoint is after all operations on the table. So the fix in this case waits for the checkpoint to finish and starts a new one. The changes also apply this new behavior to all calls to checkpoint which previously had marked that the routine should wait until the checkpoint finished. This will affect backup and checkpoints initiated by a user calling the system procedure. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@780352 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/store/raw/RawStore.java", "hunks": [ { "added": [ " // checkpoint with \"wait\" = false. If set to true shutdown", " // might loop forever if we are shutting down on a serious ", " // error where some factory has already shut down and thus", " // log checkpoint always returns false.", "" ], "header": "@@ -367,6 +367,11 @@ public final class RawStore implements RawStoreFactory, ModuleControl, ModuleSup", "removed": [] }, { "added": [ "\t\tlogFactory.checkpoint(this, dataFactory, xactFactory, true);" ], "header": "@@ -468,7 +473,7 @@ public final class RawStore implements RawStoreFactory, ModuleControl, ModuleSup", "removed": [ "\t\tlogFactory.checkpoint(this, dataFactory, xactFactory, false);" ] } ] }, { "file": "java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java", "hunks": [ { "added": [ "", " @param rsf The RawStoreFactory to use to do the checkpoint.", " @param df The DataFactory to use to do the checkpoint. ", " @param tf The TransactionFactory to use to do the checkpoint.", " @param wait If an existing checkpoint is in progress, then if", " wait=true then this routine will wait for the ", " checkpoint to complete and the do another checkpoint", " and wait for it to finish before returning.", "", "\tpublic boolean checkpoint(", " RawStoreFactory rsf,", " DataFactory df,", " TransactionFactory tf, ", " boolean wait)", "\t\tif (inReplicationSlavePreMode) ", " {", "\t\t\t// Writing a checkpoint updates the log files and the log.ctrl" ], "header": "@@ -1476,16 +1476,27 @@ public final class LogToFile implements LogFactory, ModuleControl, ModuleSupport", "removed": [ "\tpublic boolean checkpoint(RawStoreFactory rsf,", "\t\t\t\t\t\t\t DataFactory df,", "\t\t\t\t\t\t\t TransactionFactory tf, ", "\t\t\t\t\t\t\t boolean wait)", "\t\tif (inReplicationSlavePreMode) {", "\t\t\t// Writing a checkpoing updates the log files and the log.ctrl" ] }, { "added": [ "\t\tboolean done = checkpointWithTran(null, rsf, df, tf, wait);", " @param rsf The RawStoreFactory to use to do the checkpoint.", " @param df The DataFactory to use to do the checkpoint. ", " @param tf The TransactionFactory to use to do the checkpoint.", " @param wait If an existing checkpoint is in progress, then if", " wait=true then this routine will wait for the ", " checkpoint to complete and the do another checkpoint", " and wait for it to finish before returning.", "", "\tprotected boolean checkpointWithTran(", " RawTransaction cptran, ", " RawStoreFactory rsf,", " DataFactory df,", " TransactionFactory tf,", " boolean wait)", "\t\tLogInstant redoLWM;", " // we may be called to stop the database after a bad error, make sure" ], "header": "@@ -1493,55 +1504,35 @@ public final class LogToFile implements LogFactory, ModuleControl, ModuleSupport", "removed": [ "\t\tboolean done = checkpointWithTran(null, rsf, df, tf);", "", "\t\t//above checpoint call will return 'false' without", "\t\t//performing the checkpoint if some other thread is doing checkpoint. ", "\t\t//In cases like backup it is necesary to wait for the ", "\t\t//checkpoint to complete before copying the files. 'wait' flag get passed ", "\t\t//in as 'true' by such cases.", "\t\t//When wait flag is true, we will wait here until the other thread which", "\t\t//is actually doing the the checkpoint completes.", " ", "\t\tif(!done && wait)", "\t\t{", "\t\t\tsynchronized(this)", "\t\t\t{", "\t\t\t\t//wait until the thread that is doing the checkpoint completes it.", "\t\t\t\twhile(inCheckpoint)", "\t\t\t\t{", "\t\t\t\t\ttry", "\t\t\t\t\t{", "\t\t\t\t\t\twait();", "\t\t\t\t\t}\t", "\t\t\t\t\tcatch (InterruptedException ie)", "\t\t\t\t\t{", "\t\t\t\t\t\tthrow StandardException.interrupt(ie);", "\t\t\t\t\t}\t", "\t\t\t\t}", "\t\t\t\tdone = true;", "\t\t\t}", "\t\t}", "", "\tprotected boolean checkpointWithTran(RawTransaction cptran, ", "\t\t\t\t\t\t\t RawStoreFactory rsf,", "\t\t\t\t\t\t\t DataFactory df,", "\t\t\t\t\t\t\t TransactionFactory tf)", "\t\tboolean proceed = true;", "\t\tLogInstant redoLWM;", "\t\t// we may be called to stop the database after a bad error, make sure" ] }, { "added": [ "\t\tboolean proceed = true;", " do", " {", " synchronized (this)", " if (corrupt != null)", " {", " // someone else found a problem in the raw store. ", " throw StandardException.newException(", " SQLState.LOG_STORE_CORRUPT, corrupt);", " }", " approxLogLength = endPosition; // current end position", " if (!inCheckpoint)", " {", " // no checkpoint in progress, change status to indicate", " // this code is doing the checkpoint.", " inCheckpoint = true;", "", " // break out of loop and continue to execute checkpoint", " // in this routine.", " break;", " }", " else", " {", " // There is a checkpoint in progress.", "", " if (wait)", " {", " // wait until the thread executing the checkpoint ", " // completes.", "", "", " // In some cases like backup and compress it is not ", " // enough that a checkpoint is in progress, the timing ", " // is important.", " // In the case of compress it is necessary that the ", " // redo low water mark be moved forward past all ", " // operations up to the current time, so that a redo of", " // the subsequent compress operation is guaranteed", " // to not encounter any log record on the container ", " // previous to the compress. In this case the 'wait'", " // flag is passed in as 'true'.", " //", " // When wait is true and another thread is currently", " // executing the checkpoint, execution waits here until", " // the other thread which is actually doing the the ", " // checkpoint completes. And then the code will loop", " // until this thread executes the checkpoint.", " ", " while (inCheckpoint)", " {", " try", " {", " wait();", " }\t", " catch (InterruptedException ie)", " {", " throw StandardException.interrupt(ie);", " }\t", " }", " }", " else", " {", " // caller did not want to wait for already executing", " // checkpoint to finish. Routine will return false", " // upon exiting the loop.", " proceed = false;", " }", " }", "", " // don't return from inside of a sync block", " }", " }", " while (proceed);", "\t\t// needCPtran == true if not supplied with a pre-started transaction" ], "header": "@@ -1550,31 +1541,90 @@ public final class LogToFile implements LogFactory, ModuleControl, ModuleSupport", "removed": [ "\t\tsynchronized (this)", "\t\t{", "\t\t\t// has someone else found a problem in the raw store? ", "\t\t\tif (corrupt != null)", "\t\t\t\tthrow StandardException.newException(SQLState.LOG_STORE_CORRUPT, corrupt);", " }", "\t\t\t// if another checkpoint is in progress, don't do anything", "\t\t\tif (inCheckpoint == true)", "\t\t\t\tproceed = false;", "\t\t\telse", "\t\t\t\tinCheckpoint = true;", "\t\t\tapproxLogLength = endPosition; // current end position", "\t\t\t// don't return from inside of a sync block", "\t\t}", "\t\t// needCPtran == true if we are not supplied with a pre-started transaction" ] }, { "added": [ "", "\t\t\t\t//checkpoint, set the amount of log written from last ", " //checkpoint to zero.", "\t\t\t}", " else", "\t\t\t\t//value of amount of log written for this file. Later it will", "\t\t\t\t//be subtracted when we switch the log file or while ", " //calculating whether we are due a for checkpoint at flush time." ], "header": "@@ -1593,18 +1643,21 @@ public final class LogToFile implements LogFactory, ModuleControl, ModuleSupport", "removed": [ "\t\t\t\t//checkpoint, set the amount of log written from last checkpoint to zero.", "\t\t\t}else", "\t\t\t\t//value of amount of log writtent for this file. Later it will", "\t\t\t\t//be subtracted when we switch the log file or while calculating whether ", "\t\t\t\t//we are due a for checkpoint a flush time." ] } ] } ]
derby-DERBY-424-6d9c32af
DERBY-424: Basically, the problem is that, during the compile phase of views, the reference to the view gets replaced by the view definition, which causes us to loose the information that the view might have belonged in SESSION schema. In order to fix this, during the bind phase in FromList, before the view gets replaced by its definition, I find out if the view is from SESSION schema, If yes, then I save this information in FromList and this gets used by FromList when it is asked if it has any items referencing SESSION schema objects. This information is again lost during the optimization and generate phase and hence I moved the check for SESSION schema reference to right after the bind phase in GenericStatement. If there is a reference to SESSION schema object, GenericStatement will remove the statement from the cache. Submitted by Mamta Satoor (msatoor@gmail.com) git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@326959 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java", "hunks": [ { "added": [ "\t * Return true if the query node for this statement references SESSION schema", "\t * tables/views.", "\t * This method gets called at the very beginning of the compile phase of any statement.", "\t * If the statement which needs to be compiled is already found in cache, then there is", "\t * no need to compile it again except the case when the statement is referencing SESSION", "\t * schema objects. There is a small window where such a statement might get cached ", "\t * temporarily (a statement referencing SESSION schema object will be removed from the", "\t * cache after the bind phase is over because that is when we know for sure that the ", "\t * statement is referencing SESSION schema objects.)" ], "header": "@@ -866,7 +866,15 @@ recompileOutOfDatePlan:", "removed": [ "\t * Return true if the query node for this statement references SESSION schema tables." ] }, { "added": [ "\t", "\t/**", "\t * Return true if the QueryTreeNode references SESSION schema tables/views.", "\t * The return value is also saved in the local field because it will be ", "\t * used by referencesSessionSchema() method. ", "\t * This method gets called when the statement is not found in cache and ", "\t * hence it is getting compiled.", "\t * At the beginning of compilation for any statement, first we check if", "\t * the statement's plan already exist in the cache. If not, then we add", "\t * the statement to the cache and continue with the parsing and binding.", "\t * At the end of the binding, this method gets called to see if the ", "\t * QueryTreeNode references a SESSION schema object. If it does, then", "\t * we want to remove it from the cache, since any statements referencing", "\t * SESSION schema objects should never get cached. ", "\t *", "\t * @return\ttrue if references SESSION schema tables/views, else false", "\t */", "\tpublic boolean referencesSessionSchema(QueryTreeNode qt)", "\tthrows StandardException {", "\t\t//If the query references a SESSION schema table (temporary or permanent), then", "\t\t// mark so in this statement", "\t\treferencesSessionSchema = qt.referencesSessionSchema();", "\t\treturn(referencesSessionSchema);", "\t}" ], "header": "@@ -874,6 +882,30 @@ recompileOutOfDatePlan:", "removed": [] }, { "added": [ "\tvoid completeCompile(QueryTreeNode qt)" ], "header": "@@ -886,23 +918,15 @@ recompileOutOfDatePlan:", "removed": [ "\t\t@return\ttrue if there is a reference to SESSION schema tables, else false", "", "\tboolean completeCompile(QueryTreeNode qt)", "\t\t//If the query references a SESSION schema table (temporary or permanent), then mark so in this statement", "\t\t//This information will be used by EXECUTE STATEMENT if it is executing a statement that was created with NOCOMPILE. Because", "\t\t//of NOCOMPILE, we could not catch SESSION schema table reference by the statement at CREATE STATEMENT time. Need to catch", "\t\t//such statements at EXECUTE STATEMENT time when the query is getting compiled.", "\t\treferencesSessionSchema = qt.referencesSessionSchema();", "" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/GenericStatement.java", "hunks": [ { "added": [ "\t\t\t\t\t//Derby424 - In order to avoid caching select statements referencing", "\t\t\t\t\t// any SESSION schema objects (including statements referencing views", "\t\t\t\t\t// in SESSION schema), we need to do the SESSION schema object check", "\t\t\t\t\t// here. ", "\t\t\t\t\t//a specific eg for statement referencing a view in SESSION schema ", "\t\t\t\t\t//CREATE TABLE t28A (c28 int)", "\t\t\t\t\t//INSERT INTO t28A VALUES (280),(281)", "\t\t\t\t\t//CREATE VIEW SESSION.t28v1 as select * from t28A", "\t\t\t\t\t//SELECT * from SESSION.t28v1 should show contents of view and we", "\t\t\t\t\t// should not cache this statement because a user can later define", "\t\t\t\t\t// a global temporary table with the same name as the view name.", "\t\t\t\t\t//Following demonstrates that", "\t\t\t\t\t//DECLARE GLOBAL TEMPORARY TABLE SESSION.t28v1(c21 int, c22 int) not", "\t\t\t\t\t// logged", "\t\t\t\t\t//INSERT INTO SESSION.t28v1 VALUES (280,1),(281,2)", "\t\t\t\t\t//SELECT * from SESSION.t28v1 should show contents of global temporary", "\t\t\t\t\t//table and not the view. Since this select statement was not cached", "\t\t\t\t\t// earlier, it will be compiled again and will go to global temporary", "\t\t\t\t\t// table to fetch data. This plan will not be cached either because", "\t\t\t\t\t// select statement is using SESSION schema object.", "\t\t\t\t\t//", "\t\t\t\t\t//Following if statement makes sure that if the statement is", "\t\t\t\t\t// referencing SESSION schema objects, then we do not want to cache it.", "\t\t\t\t\t// We will remove the entry that was made into the cache for ", "\t\t\t\t\t//this statement at the beginning of the compile phase.", "\t\t\t\t\t//The reason we do this check here rather than later in the compile", "\t\t\t\t\t// phase is because for a view, later on, we loose the information that", "\t\t\t\t\t// it was referencing SESSION schema because the reference", "\t\t\t\t\t//view gets replaced with the actual view definition. Right after", "\t\t\t\t\t// binding, we still have the information on the view and that is why", "\t\t\t\t\t// we do the check here.", "\t\t\t\t\tif (preparedStmt.referencesSessionSchema(qt)) {", "\t\t\t\t\t\tif (foundInCache)", "\t\t\t\t\t\t\t((GenericLanguageConnectionContext)lcc).removeStatement(this);", "\t\t\t\t\t}", "\t\t\t\t\t" ], "header": "@@ -345,6 +345,42 @@ public class GenericStatement", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/FromList.java", "hunks": [ { "added": [ "\t// FromList could have a view in it's list. If the view is defined in SESSION", "\t// schema, then we do not want to cache the statement's plan. This boolean", "\t// will help keep track of such a condition.", "\tprivate boolean referencesSessionSchema;", "", "" ], "header": "@@ -61,6 +61,12 @@ public class FromList extends QueryTreeNodeVector implements OptimizableList", "removed": [] }, { "added": [ "\t\t// Following if will return true if this FromList object had any VIEWs", "\t\t// from SESSION schema as elements. This information is gathered during", "\t\t// the bindTables method. At the end of the bindTables, we loose", "\t\t// the information on VIEWs since they get replaced with their view", "\t\t// definition. Hence, we need to intercept in the middle on the bindTables", "\t\t// method and save that information in referencesSeesionSchema field.", "\t\tif (referencesSessionSchema) return true;", "" ], "header": "@@ -208,6 +214,14 @@ public class FromList extends QueryTreeNodeVector implements OptimizableList", "removed": [] } ] } ]
derby-DERBY-4241-bde5241e
DERBY-4241: Improve transition from read-only to writable Clob representation When a store stream Clob is going to be modified, it will be written out to the temporary area of Derby and represented as a TemporaryClob. The transfer of the data is done in a sub-optimal manner for two reasons; o for transfer of the complete Clob, the copy method operates on the byte level and we're not able to save the character length. o for transfer of parts of the Clob (i.e. truncation), we have to first decode the UTF-8 encoding to find the byte count and then transfer the same bytes. This fix addresses both issues by improving the length caching and by adding a method that counts the charactes "on-the-fly" while copying raw bytes. Patch file: derby-4241-2b-utf8AwareCopy.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@958522 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java", "hunks": [ { "added": [ "import java.io.UTFDataFormatException;", "import org.apache.derby.iapi.services.i18n.MessageService;", "import org.apache.derby.shared.common.reference.MessageId;" ], "header": "@@ -26,16 +26,19 @@ import java.io.EOFException;", "removed": [] }, { "added": [ " throw new EOFException(MessageService.getTextMessage(", " MessageId.STREAM_PREMATURE_EOF,", " new Long(length), new Long(sz)));" ], "header": "@@ -381,8 +384,9 @@ class LOBStreamControl {", "removed": [ " throw new EOFException(\"Reached end-of-stream \" +", " \"prematurely at \" + sz + \", expected \" + length);" ] }, { "added": [ " // If we copied until EOF, and we read more data than the length of the", " // marker, see if we have a Derby end-of-stream marker.", " long curLength = getLength();", " if (length == Long.MAX_VALUE && curLength > 2) {" ], "header": "@@ -391,9 +395,10 @@ class LOBStreamControl {", "removed": [ " // If we copied until EOF, see if we have a Derby end-of-stream marker.", " if (length == Long.MAX_VALUE) {", " long curLength = getLength();" ] } ] }, { "file": "java/engine/org/apache/derby/impl/jdbc/TemporaryClob.java", "hunks": [ { "added": [ " long knownLength = clob.getCharLengthIfKnown();", " if (knownLength == -1) {", " // Decode UTF-8 data and copy until EOF, obtain char length.", " this.cachedCharLength = this.bytes.copyUtf8Data(", " clob.getRawByteStream(), Long.MAX_VALUE);", " } else {", " // We already know the character length, and can copy raw bytes", " // without decoding the UTF-8 data.", " // Specify LONG.MAX_VALUE to copy data until EOF.", " this.cachedCharLength = knownLength;", " this.bytes.copyData(clob.getRawByteStream(), Long.MAX_VALUE);", " }" ], "header": "@@ -495,8 +495,18 @@ final class TemporaryClob implements InternalClob {", "removed": [ " // Specify LONG.MAX_VALUE to copy data until EOF.", " this.bytes.copyData(clob.getRawByteStream(), Long.MAX_VALUE);" ] } ] } ]
derby-DERBY-4241-dac5aed9
DERBY-4241: Improve transition from read-only to writable Clob representation. Added the new method InternalClob.getCharLengthIfKnown, which allows for determining if the length of the Clob is known or not at the time of the method invocation. If the length is unknown, it will not be calculated as this may be an expensive operation. This method was added to allow for performance optimizations, where the optimal action depends on whether the character length is known or not. Patch file: derby-4241-1a-InternalClob.getLengthIfKnown.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@782600 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/jdbc/TemporaryClob.java", "hunks": [ { "added": [ " /**", " * Returns the cached character count for the Clob, if any.", " *", " * @return The number of characters in the Clob, or {@code -1} if unknown.", " */", " public synchronized long getCharLengthIfKnown() {", " checkIfValid();", " // Treat a cached value of zero as a special case.", " return (cachedCharLength == 0 ? -1 : cachedCharLength);", " }", "" ], "header": "@@ -329,6 +329,17 @@ final class TemporaryClob implements InternalClob {", "removed": [] } ] } ]
derby-DERBY-4244-9bfc704b
DERBY-4244: ALTER TABLE ASSERT in ADD COLUMN with autocommit off This patch was contributed by Eranda Sooriyabandara (070468D at gmail dot com) An ALTER TABLE ... ADD COLUMN statement which specifies to add a column to a table may also include any column constraints which apply to that column. For example, to add a column to a table and at the same time indicate that the column should be the primary key of the table, this statement is used: alter table t0 add column c2 int not null default 0 primary key; If the table already contains a primary key, this statement fails, as the table cannot have more than one primary key. However, the check for the duplicate primary key was occurring at execution time, *after* the column had already been added to the table. Then, during that same transaction, subsequent ALTER TABLE statements affecting that table failed with internal ASSERT messages because the data dictionary data structures were inconsistent. This patch adds logic to the compilation processing of the ALTER TABLE statement to check for a duplicate PRIMARY KEY constraint at compile time, before the ALTER TABLE statement has begun execution. This way, when such a duplicate constraint is rejected, the rejection occurs prior to execution of the table, allowing for more straightforward cleanup. The patch also re-enables a portion of the AlterTableTest, which had been disabled due to this problem. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@795459 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList;" ], "header": "@@ -32,6 +32,7 @@ import org.apache.derby.iapi.error.StandardException;", "removed": [] }, { "added": [ "import org.apache.derby.impl.sql.execute.CreateConstraintConstantAction;" ], "header": "@@ -41,6 +42,7 @@ import org.apache.derby.iapi.types.StringDataValue;", "removed": [] } ] } ]
derby-DERBY-4245-0f92bc7c
DERBY-4245 (partial): Sorting a table containing a CLOB fails after upgrade to 10.5. Fixes the NPE bug for both clean 10.5 databases and upgraded databases. Note that there is a remaining bug for upgraded databases that will be fixed with a subsequent patch under this issue. Patch file: derby-4245-2a-sqlclob_fix.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@784701 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/types/SQLClob.java", "hunks": [ { "added": [ " rewindStream(stream, csd.getDataOffset());", " rewindStream(stream, 0);" ], "header": "@@ -236,11 +236,11 @@ public class SQLClob", "removed": [ " rewindStream(csd.getDataOffset());", " rewindStream(0);" ] }, { "added": [ " rewindStream(stream, read);" ], "header": "@@ -342,7 +342,7 @@ public class SQLClob", "removed": [ " rewindStream(read);" ] }, { "added": [ " rewindStream((InputStream)in, hdrLen);", " final InputStream srcIn = (InputStream)in;", " final boolean markSet = srcIn.markSupported();", " srcIn.mark(MAX_STREAM_HEADER_LENGTH);" ], "header": "@@ -686,11 +686,12 @@ public class SQLClob", "removed": [ " rewindStream(hdrLen);", " final boolean markSet = stream.markSupported();", " stream.mark(MAX_STREAM_HEADER_LENGTH);" ] }, { "added": [ " srcIn.reset();", " InputStreamUtil.skipFully(srcIn, hdrInfo.headerLength());", " } else if (in instanceof Resetable) {", " rewindStream(srcIn, hdrInfo.headerLength());" ], "header": "@@ -707,11 +708,11 @@ public class SQLClob", "removed": [ " stream.reset();", " InputStreamUtil.skipFully(stream, hdrInfo.headerLength());", " } else if (stream instanceof Resetable) {", " rewindStream(hdrInfo.headerLength());" ] }, { "added": [ " * @param in input stream to rewind", " * @param offset number of bytes to skip", " private void rewindStream(InputStream in, long offset)", " ((Resetable)in).resetStream();", " InputStreamUtil.skipFully(in, offset);" ], "header": "@@ -763,14 +764,15 @@ public class SQLClob", "removed": [ " * @param pos number of bytes to skip", " private void rewindStream(long pos)", " ((Resetable)stream).resetStream();", " InputStreamUtil.skipFully(stream, pos);" ] } ] } ]
derby-DERBY-4245-250dbe6e
DERBY-4245: Sorting a table containing a CLOB fails after upgrade to 10.5. Lowered the sort buffer to the minimum (through derby.storage.sortBufferMax), and the number of rows inserted in the test. Patch file: derby-4245-4a-adjust_sort_buffer_test.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@790162 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4245-ea2ac9f9
DERBY-4245: Sorting a table containing a CLOB fails after upgrade to 10.5. A regression test using LOBs in a sort. The sort should be external, but if the test is run with a large enough JVM heap it won't be. There are two options to fix that: reduce the heap size or increase the number of rows in the test table. Patch file: derby-4245-1c-test.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@785104 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4246-dfbf41ee
DERBY-4246 .replicationTests.ReplicationRun_Local_3_p5).testReplication_Local_3_p5_DERBY_3878()' fails w/ "Could not perform operation 'stopSlave' because the database '...' has not been booted Patch derby-4246-2 adds extra logic to the stop slave action after the master is killed. This logic anticipates the slave's state changes before its down. This logic was also present in ReplicationRun_Local_StateTest_part1_1, so this patch factors this out into a new method to stopSlave in ReplicationRun. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@785131 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4249-3b4b552c
DERBY-4249 Create a simple store recovery test in JUnit On failure print launched process error stream as well as ouput. patch derby4249_showlaunchederr_diff.txt git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1159337 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4249-8f56d99d
DERBY-4249 Create a simple store recovery test in JUnit Contributed by Siddharth Srivastava Simple test to verify recovery. - Connect, create a table, commit and shutdown the database. - fork a jvm, add one row, commit, add another row, exit the jvm. - Reconnect with the first jvm and verify that the first row is there and the second is not. Launches a junit method for forked jvm and reports any errors back. Currently disabled for weme due to DERBY-4647. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1158949 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4256-fecd96aa
DERBY-4256: Allow ALTER TABLE to increase the max size of BLOB or CLOB This patch was contributed by Eranda Sooriyabandara (070468D at gmail dot com) This patch enhances the Derby ALTER TABLE command so that it allows the maximum length limit of a BLOB or CLOB column to be increased. The patch also adds some new regression tests verifying the new functionality, and adjusts the text of the ALTER TABLE error message to make it more clear that it is legal to increase the length of a VARCHAR, BLOB, or CLOB column. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@802985 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4260-a3e94cbe
DERBY-4260: Make derbynet/NetworkServerControlClientCommandTest run regardless of the locale This patch was contributed by Houx Zhang (houxzhang @ gmail dot com). This patch modifies the NetworkServerControlClientCommandTest to pass -Dderby.ui.locale=en_US when running the sub-commands of the test, to ensure that the test assertions, which look for specific English language strings, find the expected values. That way, the test will pass, even if run in a shell environment where the locale is set to a non-English value. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1095247 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4263-cf61371e
DERBY-4263: PropertySetter isn't able to recognize JDK without version number in path. Added a new algorithm for detecting JDKs on the system. The root search locations are the same as before, but instead of relying on version numbers in the JDK directory, jar files and the sub directory structure of the directories are examined. The new algorithm will try to select JDKs from the same vendor as the running JVM if possible. If the new algorithm fails for some reason, the old one will be used. If both the new and the old algorithm fail, a last attempt will be made by configuring the build with the running JVM only. If the more "exotic" approaches are used, a warning message will be printed to default out. As before, more information can be extracted by setting printCompilerProperties=true when invoking ant. Patch file: derby-4263-1b-jdk_detection_by_jars.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@801924 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/build/org/apache/derbyPreBuild/PropertySetter.java", "hunks": [ { "added": [ "import java.io.FilenameFilter;", "import java.io.IOException;", "import java.util.Collections;", "import java.util.jar.JarFile;", "import java.util.jar.Manifest;" ], "header": "@@ -23,13 +23,18 @@ package org.apache.derbyPreBuild;", "removed": [] }, { "added": [ " * <li>If we don't recognize the vendor of the running vm, print a warning", " * message and then try to set the classpath properties using the JDK with the", " * highest implementation version from any vendor matching the required", " * specification version. If a vendor has chosen to deviate significantly from", " * the file layout of other JDKs, the detection will most likely fail.", " * People using JDKs with a more exotic file layout should specify the library", " * directory explicitly through ant.properties, or resort to setting the compile", " * classpath manually.", " * </li>" ], "header": "@@ -71,7 +76,15 @@ import org.apache.tools.ant.taskdefs.Property;", "removed": [ " * <li>Otherwise, if we don't recognize the vm vendor, we abort the build.</li>" ] }, { "added": [ " /** JDK vendor as reported by Java through the property 'java.vendor'. */", " private String jdkVendor;" ], "header": "@@ -124,6 +137,8 @@ public class PropertySetter extends Task", "removed": [] }, { "added": [ " /**", " * Simple class holding information about a JDK.", " * Note that the values will never be {@code null}. If a piece of", " * information is missing, {@code UNKNOWN} will be used. If the JDK home", " * variable is {@code null}, a runtime exception will be thrown.", " */", " //@Immutable", " private static final class JDKInfo {", " /** Constant used when information is missing. */", " public static final String UNKNOWN = \"unknown\";", " /** The specification version of the JVM (i.e \"1.6\"). */", " public final String specificationVersion;", " /** The implementation version of the JVM (i.e. \"1.6.0_14\" or \"6.0\"). */", " public final String implementationVersion;", " /** The JDK implementation vendor. */", " public final String vendor;", " /** Path to the JDK home directory. */", " public final String path;", "", " JDKInfo(String vendor, String spec, String impl, String path) {", " this.vendor = (vendor == null ? UNKNOWN : vendor);", " this.specificationVersion = (spec == null ? UNKNOWN : spec);", " this.implementationVersion = (impl == null ? UNKNOWN : impl);", " this.path = path;", " if (path == null) {", " throw new IllegalArgumentException(\"JDK home cannot be null\");", " }", " }", "", " public String toString() {", " return (\"vendor=\" + vendor + \", specVersion=\" +", " specificationVersion + \", implVersion=\" +", " implementationVersion + \", path=\" + path);", " }", " }", "" ], "header": "@@ -165,6 +180,42 @@ public class PropertySetter extends Task", "removed": [] }, { "added": [ " jdkVendor = getProperty(JDK_VENDOR, \"\");", " else {", " // We don't know anything about this vendor. Print a warning", " // message and try to continue.", " echo(\"Unrecognized VM vendor: '\" + jdkVendor + \"'\");", " echo(\"An attempt to configure the required JDKs will be made,\" +", " \" but the build may fail.\");", " echo(\"In case of problems:\\n\" +", " \" - consult BUILDING.html and set the required \" +", " \"properties manually\\n\" +", " \" - set the property printCompilerProperties to true \" +", " \"and ask the Derby development community for help\\n\" +", " \" (please provide the debug output from running ant)\"", " );", " setForMostJDKsJARInspection(\"1.4\", \"1.5\", \"1.6\");", " setForMostJDKs(\"1.4\", \"1.5\", \"1.6\");", " }" ], "header": "@@ -233,14 +284,27 @@ public class PropertySetter extends Task", "removed": [ " String jdkVendor = getProperty( JDK_VENDOR );", "", " if ( jdkVendor == null ) { jdkVendor = \"\"; }", " " ] }, { "added": [ " setForMostJDKsJARInspection(\"1.4\", \"5.0\", \"6.0\");" ], "header": "@@ -295,6 +359,7 @@ public class PropertySetter extends Task", "removed": [] }, { "added": [ " setForMostJDKsJARInspection(\"1.4\", \"1.5\", \"1.6\");", " setForMostJDKs( \"1.4\", \"1.5\", \"1.6\" );" ], "header": "@@ -313,7 +378,8 @@ public class PropertySetter extends Task", "removed": [ " setForMostJDKs( \"1.4.\", \"1.5.\", \"1.6\" );" ] }, { "added": [ " /**", " * Sets the properties needed to compile using most JDKs.", " * <p>", " * Will search for JDK based on a list of root directories. A JDK is", " * identified by certain files and the content of JAR file manifests.", " */", " private void setForMostJDKsJARInspection(", " String seed14, String seed15, String seed16)", " throws Exception {", " String default_j14lib = getProperty( J14LIB );", " String default_j15lib = getProperty( J15LIB );", " String default_j16lib = getProperty( J16LIB );", "", " // Obtain a list of all JDKs available to us, then specify which one to", " // use for the different versions we require.", " List<JDKInfo> jdks = locateJDKs(getJdkSearchPath());", " if (default_j14lib == null) {", " default_j14lib = getJreLib(jdks, seed14, jdkVendor);", " }", " if (default_j15lib == null) {", " default_j15lib = getJreLib(jdks, seed15, jdkVendor);", " }", " if (default_j16lib == null) {", " default_j16lib = getJreLib(jdks, seed16, jdkVendor);", " }", "", " defaultSetter(default_j14lib, default_j15lib, default_j16lib);", " }", "" ], "header": "@@ -322,6 +388,35 @@ public class PropertySetter extends Task", "removed": [] }, { "added": [ " // JDK heuristics based on inspecting JARs.", "", " /**", " * Searches for JDKs in the specified directories.", " *", " * @param jdkParentDirectories a list of parent directories to search in", " * @return A list containing information objects for JDKs found on the", " * system. If no JDKs were found, the list will be empty.", " */", " private List<JDKInfo> locateJDKs(List<File> jdkParentDirectories) {", " ArrayList<JDKInfo> jdks = new ArrayList<JDKInfo>();", " if (jdkParentDirectories == null) {", " return jdks;", " }", "", " File jreLibRel = new File(\"jre\", \"lib\");", " String[] jarsRelative = new String[] {", " // Special cases for IBM JDKs.", " new File(jreLibRel, \"core.jar\").getPath(),", " new File(jreLibRel, \"vm.jar\").getPath(),", " // Default JAR file to look for, used be most JDKs.", " new File(jreLibRel, \"rt.jar\").getPath(),", " };", " for (File jdkParentDirectory : jdkParentDirectories) {", " // Limit the search to the directories in the parent directory.", " // Don't descend into sub directories.", " File[] possibleJdkRoots = jdkParentDirectory.listFiles(", " new FileFilter() {", "", " /** Accepts only directories. */", " public boolean accept(File pathname) {", " return pathname.isDirectory();", " }", " });", " for (File f : possibleJdkRoots) {", " File rtArchive = new File(f, jreLibRel.getPath());", " if (!rtArchive.exists()) {", " // Bail out, we only understand JDKs that have a jre/lib dir", " continue;", " }", " // Look for the various JARs that identify a JDK and see if a", " // implementation version is specified in the manifest.", " for (String jar : jarsRelative) {", " rtArchive = new File(f, jar);", " if (rtArchive.exists()) {", " // Jar found.", " Manifest mf;", " try {", " JarFile rtJar = new JarFile(rtArchive);", " mf = rtJar.getManifest();", " } catch (IOException ioeIgnored) {", " // Obtaining the manifest failed for some reason.", " // If in debug mode, let the user know.", " if (isSet(PROPERTY_SETTER_DEBUG_FLAG)) {", " echo(\"Failed to obtain manifest for \" +", " rtArchive.getAbsolutePath() + \": \" +", " ioeIgnored.getMessage());", " }", " continue;", " }", " JDKInfo jdk = inspectJarManifest(mf, f);", " if (jdk != null) {", " jdks.add(jdk);", " break;", " }", " }", " rtArchive = null; // Reset", " }", " if (rtArchive == null) {", " // We didn't find any of the jars we were looking for, or", " // the manifests didn't contain an implementation version.", " // Continue with the next potential JDK root.", " continue;", " }", " }", " }", " return jdks;", " }", "", " /**", " * Inspects the specified manifest to obtain information about the JDK.", " *", " * @param mf manifest from a JDK jar file", " * @param jdkHome the home directory of the JDK", " * @return An information object for the JDK, or {@code null} if no", " * information was found.", " */", " private JDKInfo inspectJarManifest(Manifest mf, File jdkHome) {", " // The manifest may be null, as it is optional.", " if (mf == null) {", " return null;", " }", " JDKInfo info = new JDKInfo(", " mf.getMainAttributes().getValue(\"Implementation-Vendor\"),", " mf.getMainAttributes().getValue(\"Specification-Version\"),", " mf.getMainAttributes().getValue(\"Implementation-Version\"),", " jdkHome.getAbsolutePath());", " if (!info.implementationVersion.equals(JDKInfo.UNKNOWN)) {", " // Make sure we have javac", " File jdkBin = new File(jdkHome, \"bin\");", " File[] javac = jdkBin.listFiles(new FilenameFilter() {", "", " public boolean accept(File dir, String name) {", " return name.toLowerCase().startsWith(\"javac\");", " }", " });", " if (javac == null || javac.length == 0) {", " return null;", " }", " //javac located, we're good to go.", " if (isSet(PROPERTY_SETTER_DEBUG_FLAG)) {", " System.out.println(\"found JDK: \" + info);", " }", " return info;", " }", " return null;", " }", "", " /**", " * Returns the path to the most suitable JDK found on the system.", " * <p>", " * The selection is taken based on the specification version and potentially", " * the JDK vendor.", " *", " * @param jdks the JDKs we can choose from", " * @param specificationVersion the specification version we want, i.e.", " * \"1.4\" or \"1.6\". {@code null} allows all valid versions.", " * @param vendor the vendor to prefer, if any", " * @return The path to the chosen JDK, or {@code null} if no suitable JDK", " * was found.", " */", " private String getJreLib(List<JDKInfo> jdks,", " String specificationVersion, String vendor) {", " // If we have no candidate JDKs, just return null at once.", " if (jdks == null || jdks.size() == 0) {", " return null;", " }", " final String jreLib = new File(\"jre\", \"lib\").getPath();", " ArrayList<JDKInfo> candidates = new ArrayList<JDKInfo>();", " ArrayList<String> versions = new ArrayList<String>();", " // Get the JDKs with the requested specification version.", " // Because some vendors are unable to correctly specify the meta data,", " // we have to look at the implementation version only.", " for (JDKInfo jdk : jdks) {", " String implVersion = jdk.implementationVersion;", " if (isValidVersion(implVersion, specificationVersion)) {", " candidates.add(jdk);", " if (!versions.contains(implVersion)) {", " versions.add(implVersion);", " }", " }", " }", " // See if we found any suitable JDKs.", " if (candidates.size() == 0) {", " if (isSet(PROPERTY_SETTER_DEBUG_FLAG)) {", " System.out.println(\"INFO: No valid JDK with specification \" +", " \"version '\" + specificationVersion + \"' found\");", " }", " return null;", " }", "", " // Sort and reverse the version list (highest first).", " Collections.sort(versions);", " Collections.reverse(versions);", "", " // Try to find a JVM of the same vendor first. If that fails, return", " // the highest version suitable JDK from any vendor.", " String[] targetVendors = new String[] {", " vendor,", " null // insignificant, ignores vendor and compares version only", " };", " for (String targetVendor : targetVendors) {", " for (String version : versions) {", " for (JDKInfo jdk : candidates) {", " if (jdk.implementationVersion.equals(version) &&", " isSameVendor(targetVendor, jdk.vendor)) {", " if (isSet(PROPERTY_SETTER_DEBUG_FLAG)) {", " System.out.println(", " \"Chosen JDK for specification version \" +", " specificationVersion + \" (vendor \" +", " (targetVendor == null ? \"ignored\"", " : jdkVendor) +", " \"): \" + jdk);", " }", " return new File(jdk.path, jreLib).getAbsolutePath();", " }", " }", " }", " }", " return null;", " }", "", " /**", " * Tells if the specified implementation version is representing a valid JDK", " * version and if it satisfies the specification version.", " *", " * @param implVersion the version string to check", " * @param specVersion the specification version to satisfy", " * @return {@code true} if a valid version, {@code false} if not.", " */", " private static boolean isValidVersion(String implVersion,", " String specVersion) {", " // Don't allow null as a version.", " if (implVersion == null) {", " return false;", " }", " // Don't allow early access versions.", " // This rule should at least match Sun EA versions.", " if (implVersion.contains(\"ea\")) {", " return false;", " }", "", " // See if the implementation version matches the specification version.", " if (specVersion == null) {", " return true;", " }", " // The current way of comparing the versions, is to check if the", " // specification version can be found as part of the implementation", " // version. For instance spec=1.6, matches impl=1.6.0_14.", " return implVersion.contains(specVersion);", " }", "", " /**", " * Tells if the two vendor names are representing the same vendor.", " *", " * @param targetVendor target vendor name, or {@code null} or whitespace /", " * empty string if insignificant", " * @param vendor the candidate vendor name to compare with", " * @return {@code true} if considered the same or {@code targetVendor} is", " * {@code null}, {@code false} if not.", " */", " private static boolean isSameVendor(String targetVendor, String vendor) {", " // If there is no target vendor, return true.", " if (targetVendor == null || targetVendor.trim().equals(\"\")) {", " return true;", " }", " // If we have a target vendor, but no vendor name to compare with,", " // always return false.", " if (vendor == null || vendor.trim().equals(\"\")) {", " return false;", " }", " // Normalize both the vendor names and compare.", " String target = normalizeVendorName(targetVendor);", " String candidate = normalizeVendorName(vendor);", " // Implement special cases here, if required.", " return candidate.equals(target);", " }", "", " /**", " * Normalizes the vendor name for the purpose of vendor name matching.", " *", " * @param vendorName the vendor name as reported by the VM or similar", " * @return A normalized vendor name suitable for vendor name matching.", " */", " private static String normalizeVendorName(String vendorName) {", " // Currently we only replace commas with the empty string. The reason", " // for doing this is that the vendor name specified in the jar file", " // manifest differes from the one return by the JVM itself for the Sun", " // JDKs. For instance:", " // - from JAR: Sun Microsystems, Inc.", " // - from running VM: Sun Microsystems Inc.", " // (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6851869)", " return vendorName.replaceAll(\",\", \"\");", " }", "" ], "header": "@@ -467,6 +562,271 @@ public class PropertySetter extends Task", "removed": [] }, { "added": [ "", " // Refresh the properties snapshot to reflect the latest changes.", " refreshProperties();" ], "header": "@@ -491,6 +851,9 @@ public class PropertySetter extends Task", "removed": [] }, { "added": [ " // Build a string of the search path, which may contain multiple values.", " buffer.append(\"jdkSearchPath = \");", " try {", " List<File> paths = getJdkSearchPath();", " for (File path : paths) {", " buffer.append(path.getPath()).append(\", \");", " }", " // Remove the trailing \", \".", " buffer.deleteCharAt(buffer.length() -1);", " buffer.deleteCharAt(buffer.length() -1);", "", " } catch (Exception e) {", " buffer.append(\"unknown (reason: \").append(e.getMessage().trim()).", " append(\")\");", " }", " buffer.append(\"\\n\");" ], "header": "@@ -796,6 +1159,22 @@ public class PropertySetter extends Task", "removed": [] } ] } ]
derby-DERBY-4269-1966619e
DERBY-5830: Make DoubleProperties.propertyNames() thread-safe Don't store the property values in the intermediate Hashtable as they are not needed. They may be null if the Properties instances are modified after the recursive calls to Properties.propertyNames(), and trying to store a null value in a Hashtable results in a NullPointerException, causing issues such as DERBY-4269. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1353852 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/util/DoubleProperties.java", "hunks": [ { "added": [ "import java.util.Collections;", "import java.util.HashSet;", "import java.util.Properties;" ], "header": "@@ -21,8 +21,10 @@", "removed": [ "import java.util.Properties;" ] }, { "added": [ " Only the put(), propertyNames() and getProperty() methods are supported" ], "header": "@@ -31,7 +33,7 @@ import java.util.Enumeration;", "removed": [ " Only the put(), keys() and getProperty() methods are supported" ] }, { "added": [ " HashSet names = new HashSet();", " addAllNames(write, names);", " addAllNames(read, names);", " return Collections.enumeration(names);", "", " /**", " * Add all property names in the Properties object {@code src} to the", " * HashSet {@code dest}.", " */", " private static void addAllNames(Properties src, HashSet dest) {", " if (src != null) {", " for (Enumeration e = src.propertyNames(); e.hasMoreElements(); ) {", " dest.add(e.nextElement());", " }", " }", " }" ], "header": "@@ -60,23 +62,21 @@ public final class DoubleProperties extends Properties {", "removed": [ "", "\t\tProperties p = new Properties();", "", "\t\tif (write != null) {", "", "\t\t\tfor (Enumeration e = write.propertyNames(); e.hasMoreElements(); ) {", "\t\t\t\tString key = (String) e.nextElement();", "\t\t\t\tp.put(key, write.getProperty(key));", "\t\t\t}", "\t\t}", "", "\t\tif (read != null) {", "\t\t\tfor (Enumeration e = read.propertyNames(); e.hasMoreElements(); ) {", "\t\t\t\tString key = (String) e.nextElement();", "\t\t\t\tp.put(key, read.getProperty(key));", "\t\t\t}", "\t\t}", "\t\treturn p.keys();" ] } ] } ]
derby-DERBY-4269-2cd035c1
DERBY-4269 Failover did not succeed in 2 min.: testReplication_Local_3_p6_autocommit_OK Patch fix-ignored-runtime-exceptions-b git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1356766 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/db/SlaveDatabase.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.reference.MessageId;", "import org.apache.derby.impl.store.replication.ReplicationLogger;" ], "header": "@@ -37,6 +37,8 @@ import org.apache.derby.jdbc.InternalDriver;", "removed": [] }, { "added": [ " } catch (Exception e) {", " // We get here when SlaveController#stopSlave has been called,", " // a fatal Derby exception has been thrown, or if a run-time", " // error is thrown. Log the error unconditionally to make sure", " // it can be observed, since if this happens during or after", " // recovery on a failover, there will be no connection attempt", " // failing with the error. New connection attempts will just", " // hang...", "", " ReplicationLogger rl = new ReplicationLogger(dbname);", " rl.logError(MessageId.REPLICATION_FATAL_ERROR, e);", " ", " if (e instanceof StandardException) {", " handleShutdown((StandardException)e);", " }", " } " ], "header": "@@ -321,11 +323,22 @@ public class SlaveDatabase extends BasicDatabase {", "removed": [ " } catch (StandardException se) {", " // We get here when SlaveController#stopSlave has been", " // called, or if a fatal exception has been thrown.", " handleShutdown(se);", " }" ] } ] } ]
derby-DERBY-4270-ccf708c8
DERBY-4270 Make replication tests save derby.log and database when a failure occurs Patch derby-4270-2 adds an overload of TestCase.runBare to ReplicationRun which does this desired copying on the same pattern as done for "normal" tests in BaseTestCase.runBare. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@785139 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4273-66edb713
DERBY-4273: A lock could not be obtained within the time requested error in testBTreeForwardScan_fetchRows_resumeAfterWait_nonUnique_split Use DatabasePropertyTestSetup to set timeout in ResultSetMiscTest and SetTransactionIsolationTest, so that the values are reset before IndexSplitDeadlockTest starts. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@788968 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4274-beaa0a43
DERBY-4274: SYSCS_UPDATE_STATISTICS takes unnecessary table lock Return just after the statistics have been updated to prevent the generic ALTER TABLE code from locking the table exclusively. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@785570 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4275-5a56eb0a
DERBY-4275: Query executions fail when compressing a table using SYSCS_UTIL.SYSCS_COMPRESS_TABLE Move invalidation of dependent statements until the system tables have been updated with information about the new conglomerates created by compression or truncation. This is to prevent that statements executing concurrently get recompiled too early and don't see the new conglomerates (and therefore fail on subsequent executions because they cannot find the old conglomerates). git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1142583 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java", "hunks": [ { "added": [ "\t\t/* Prepare all dependents to invalidate. (This is their chance" ], "header": "@@ -388,7 +388,7 @@ class AlterTableConstantAction extends DDLSingleTableConstantAction", "removed": [ "\t\t/* Prepare all dependents to invalidate. (This is there chance" ] }, { "added": [], "header": "@@ -2090,14 +2090,6 @@ class AlterTableConstantAction extends DDLSingleTableConstantAction", "removed": [ "\t\t// invalidate any prepared statements that depended on this table ", " // (including this one), this fixes problem with threads that start up ", " // and block on our lock, but do not see they have to recompile their ", " // plan. We now invalidate earlier however they still might recompile", " // using the old conglomerate id before we commit our DD changes.", "\t\t//", "\t\tdm.invalidateFor(td, DependencyManager.COMPRESS_TABLE, lcc);", "" ] }, { "added": [ " // Now that the updated information is available in the system tables,", " // we should invalidate all statements that use the old conglomerates", " dm.invalidateFor(td, DependencyManager.COMPRESS_TABLE, lcc);", "" ], "header": "@@ -2221,6 +2213,10 @@ class AlterTableConstantAction extends DDLSingleTableConstantAction", "removed": [] }, { "added": [], "header": "@@ -2305,15 +2301,6 @@ class AlterTableConstantAction extends DDLSingleTableConstantAction", "removed": [ "\t\t// invalidate any prepared statements that", "\t\t// depended on this table (including this one)", "\t\t// bug 3653 has threads that start up and block on our lock, but do", "\t\t// not see they have to recompile their plan. We now invalidate earlier", "\t\t// however they still might recompile using the old conglomerate id before we", "\t\t// commit our DD changes.", "\t\t//", "\t\tdm.invalidateFor(td, DependencyManager.TRUNCATE_TABLE, lcc);", "" ] } ] } ]
derby-DERBY-4276-45f64ada
DERBY-4276 Update demo's to remove references to com.ibm.db2.jcc.DB2Driver Contributed by Lily Wei (lilywei at yahoo dot com) git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@788105 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/demo/nserverdemo/NsSample.java", "hunks": [ { "added": [ " 2.\tloads the derby client JDBC driver" ], "header": "@@ -41,8 +41,7 @@ import java.io.PrintWriter;", "removed": [ " 2.\tloads the IBM DB2 JDBC Universal driver or derby client JDBC driver", " (default is the derby client JDBC driver)" ] }, { "added": [ "\tpublic static final String DERBY_CLIENT_DRIVER = \"org.apache.derby.jdbc.ClientDriver\";" ], "header": "@@ -66,8 +65,7 @@ import java.io.PrintWriter;", "removed": [ "\tpublic static final String DB2_JDBC_UNIVERSAL_DRIVER = new String(\"com.ibm.db2.jcc.DB2Driver\");", " public static final String DERBY_CLIENT_DRIVER = \"org.apache.derby.jdbc.ClientDriver\";" ] }, { "added": [], "header": "@@ -82,7 +80,6 @@ public class NsSample {", "removed": [ "\tprivate static final String CS_NS_DBURL= \"jdbc:derby:net://localhost:\"+NETWORKSERVER_PORT+\"/NSSampledb;create=true;retrieveMessagesFromServerOnGetMessage=true;deferPrepares=true;\";" ] }, { "added": [], "header": "@@ -105,9 +102,6 @@ public class NsSample {", "removed": [ " // Determine which JDBC driver we are using with Derby", " parseArguments(args);", "" ] }, { "added": [ "\t\tproperties.setProperty(\"user\",\"derbyuser\");", "\t\tproperties.setProperty(\"password\",\"pass\");" ], "header": "@@ -170,8 +164,8 @@ public class NsSample {", "removed": [ "\t\tproperties.setProperty(\"user\",\"cloud\");", "\t\tproperties.setProperty(\"password\",\"scape\");" ] } ] }, { "file": "java/demo/nserverdemo/SimpleNetworkClientSample.java", "hunks": [ { "added": [ " * 1) loads the Derby Network Client driver", " * Before running this program, please make sure that Derby Network Server is up" ], "header": "@@ -36,14 +36,14 @@ import javax.sql.DataSource;", "removed": [ " * 1) loads the DB2 Universal JDBC Driver or the Derby Network Client driver", " * Before running this program, please make sure that Clouscape Network Server is up" ] }, { "added": [ "" ], "header": "@@ -63,11 +63,7 @@ public class SimpleNetworkClientSample", "removed": [ "\t/**", "\t * DB2 JDBC UNIVERSAL DRIVER class names", "\t */", "\tprivate static final String DB2_JDBC_UNIVERSAL_DRIVER = \"com.ibm.db2.jcc.DB2Driver\";", "\tprivate static final String DB2_JCC_DS = \"com.ibm.db2.jcc.DB2SimpleDataSource\";" ] }, { "added": [], "header": "@@ -77,7 +73,6 @@ public static final String DERBY_CLIENT_DRIVER = \"org.apache.derby.jdbc.ClientDr", "removed": [ "\t * This URL is for the DB2 JDBC Universal Driver" ] }, { "added": [], "header": "@@ -106,8 +101,6 @@ public static final String DERBY_CLIENT_DRIVER = \"org.apache.derby.jdbc.ClientDr", "removed": [ " // Determine which JDBC driver to use", " parseArguments(args);" ] }, { "added": [], "header": "@@ -205,15 +198,6 @@ public static final String DERBY_CLIENT_DRIVER = \"org.apache.derby.jdbc.ClientDr", "removed": [ " // The following is only applicable to the DB2 JDBC driver", " if(jdbcDataSource.equals( DB2_JCC_DS))", " {", "\t\t\t// driver type must be 4 to access Derby Network Server", "\t\t\tMethod drivertype = nsDataSource.getMethod(\"setDriverType\", methodParams);", "\t\t\targs = new Object[] {new Integer(4)};", "\t\t\tdrivertype.invoke(ds, args);", " }", "" ] }, { "added": [ "\t\tproperties.setProperty(\"user\",\"derbyuser\");", "\t\tproperties.setProperty(\"password\",\"pass\");" ], "header": "@@ -243,8 +227,8 @@ public static final String DERBY_CLIENT_DRIVER = \"org.apache.derby.jdbc.ClientDr", "removed": [ "\t\tproperties.setProperty(\"user\",\"cloud\");", "\t\tproperties.setProperty(\"password\",\"scape\");" ] } ] }, { "file": "java/demo/simple/SimpleApp.java", "hunks": [ { "added": [], "header": "@@ -72,9 +72,6 @@ public class SimpleApp", "removed": [ " * <li><code>jccjdbcclient</code> - will use the DB2 Universal JDBC", " * network client driver, also known as JCC, to access the Network", " * Server. This driver is not part of the Derby distribution.</li>" ] }, { "added": [ " * creating a table in the database, and inserting, updating and retrieving", " * some data. Some of the retrieved data is then verified (compared) against", " * doing shutdown unless you know that no one else needs to access the" ], "header": "@@ -101,14 +98,14 @@ public class SimpleApp", "removed": [ " * creating a table in the database, and inserting, updating and retreiving", " * some data. Some of the retreived data is then verified (compared) against", " * doing shutdown unless you know that noone else needs to access the" ] }, { "added": [ " int number; // street number retrieved from the database" ], "header": "@@ -254,7 +251,7 @@ public class SimpleApp", "removed": [ " int number; // street number retreived from the database" ] }, { "added": [ " // To shut down a specific database only, but keep the" ], "header": "@@ -329,7 +326,7 @@ public class SimpleApp", "removed": [ " // To shut down a specific database only, but keeep the" ] } ] } ]
derby-DERBY-4277-f910400c
DERBY-4277: Replacing simple connect() with waitForConnect(). git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@789601 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4278-8f75194d
DERBY-4278: Batch inserts with Clobs fails with the embedded driver. Explicitly set whether the Clob is written to a soft upgraded database or not, as there isn't enough context at write time (run-time) to decide it then. Patch file: derby-4278-1a-regression_test.diff, derby-4278-2a-fix.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@790135 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/types/SQLClob.java", "hunks": [ { "added": [ " SQLClob clone = new SQLClob(getString());", " // Copy the soft upgrade mode state.", " clone.inSoftUpgradeMode = inSoftUpgradeMode;", " return clone;" ], "header": "@@ -102,7 +102,10 @@ public class SQLClob", "removed": [ "\t\t\treturn new SQLClob(getString());" ] } ] }, { "file": "java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.sql.dictionary.DataDictionary;" ], "header": "@@ -64,6 +64,7 @@ import java.sql.Types;", "removed": [] }, { "added": [ " /**", " * Tells if we're accessing a database in soft upgrade mode or not.", " * <p>", " * This is lazily set if we need it.", " * @see #isSoftUpgraded()", " */", " private Boolean inSoftUpgradeMode;" ], "header": "@@ -91,6 +92,13 @@ public abstract class EmbedPreparedStatement", "removed": [] }, { "added": [ " dvd.setSoftUpgradeMode(isSoftUpgraded());" ], "header": "@@ -735,6 +743,7 @@ public abstract class EmbedPreparedStatement", "removed": [] } ] } ]
derby-DERBY-4279-7fc54b9c
DERBY-4279: Statement cache deadlock When requesting a recompile of a statement, don't wait for other threads compiling the same statement, but instead create a new instance of the statement. Patch contributed by Brett Wooldridge <brett.wooldridge@gmail.com>. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@956504 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java", "hunks": [ { "added": [ "\tpublic PreparedStatement rePrepare(LanguageConnectionContext lcc)", "\t\t\treturn ps;", "", "\t\treturn this;" ], "header": "@@ -223,14 +223,14 @@ public class GenericPreparedStatement", "removed": [ "\tpublic void rePrepare(LanguageConnectionContext lcc) ", "", "\t\t\tif (SanityManager.DEBUG)", "\t\t\t\tSanityManager.ASSERT(ps == this, \"ps != this\");" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/GenericStatement.java", "hunks": [ { "added": [ "\t\t\tfor (;;)", "\t\t\t{", "\t\t\t\tif (preparedStmt.compilingStatement)", "\t\t\t\t{", "\t\t\t\t\tpreparedStmt = new GenericPreparedStatement(this);", "\t\t\t\t\tbreak;", "\t\t\t\t}", "\t\t\t\tif (foundInCache)", "\t\t\t\t{", "\t\t\t\t\tif (preparedStmt.referencesSessionSchema())", "\t\t\t\t\t{" ], "header": "@@ -171,11 +171,18 @@ public class GenericStatement", "removed": [ "\t\t\tfor (;;) {", "", "\t\t\t\tif (foundInCache) {", "\t\t\t\t\tif (preparedStmt.referencesSessionSchema()) {" ] }, { "added": [ "\t\t\t\tbreak;" ], "header": "@@ -189,15 +196,7 @@ public class GenericStatement", "removed": [ "\t\t\t\tif (!preparedStmt.compilingStatement) {", "\t\t\t\t\tbreak;", "\t\t\t\t}", "", "\t\t\t\ttry {", "\t\t\t\t\tpreparedStmt.wait();", "\t\t\t\t} catch (InterruptedException ie) {", "\t\t\t\t\tthrow StandardException.interrupt(ie);", "\t\t\t\t}" ] }, { "added": [], "header": "@@ -542,7 +541,6 @@ public class GenericStatement", "removed": [ "\t\t\t\tpreparedStmt.notifyAll();" ] } ] } ]
derby-DERBY-4279-85132a2e
DERBY-4279: Statement cache deadlock Backing out revision 956504 while investigating problems that appeared after the change. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@958529 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java", "hunks": [ { "added": [ "\tpublic void rePrepare(LanguageConnectionContext lcc) ", "\t\t\tif (SanityManager.DEBUG)", "\t\t\t\tSanityManager.ASSERT(ps == this, \"ps != this\");", "\t\t}" ], "header": "@@ -223,14 +223,14 @@ public class GenericPreparedStatement", "removed": [ "\tpublic PreparedStatement rePrepare(LanguageConnectionContext lcc)", "\t\t\treturn ps;", "\t\t}", "\t\treturn this;" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/GenericStatement.java", "hunks": [ { "added": [ "\t\t\tfor (;;) {", "", "\t\t\t\tif (foundInCache) {", "\t\t\t\t\tif (preparedStmt.referencesSessionSchema()) {" ], "header": "@@ -171,18 +171,11 @@ public class GenericStatement", "removed": [ "\t\t\tfor (;;)", "\t\t\t{", "\t\t\t\tif (preparedStmt.compilingStatement)", "\t\t\t\t{", "\t\t\t\t\tpreparedStmt = new GenericPreparedStatement(this);", "\t\t\t\t\tbreak;", "\t\t\t\t}", "\t\t\t\tif (foundInCache)", "\t\t\t\t{", "\t\t\t\t\tif (preparedStmt.referencesSessionSchema())", "\t\t\t\t\t{" ] }, { "added": [ "\t\t\t\tif (!preparedStmt.compilingStatement) {", "\t\t\t\t\tbreak;", "\t\t\t\t}", "", "\t\t\t\ttry {", "\t\t\t\t\tpreparedStmt.wait();", "\t\t\t\t} catch (InterruptedException ie) {", "\t\t\t\t\tthrow StandardException.interrupt(ie);", "\t\t\t\t}" ], "header": "@@ -196,7 +189,15 @@ public class GenericStatement", "removed": [ "\t\t\t\tbreak;" ] }, { "added": [ "\t\t\t\tpreparedStmt.notifyAll();" ], "header": "@@ -541,6 +542,7 @@ public class GenericStatement", "removed": [] } ] } ]
derby-DERBY-4279-f52a901a
DERBY-4279: Statement cache deadlock Modified ResultColumnList.generateHolderMethod to only take a lock when obtaining row template(s) if the data dictionary is in DDL_MODE. The lock that used to be obtained was a CIS lock/latch. The purpose of this change is to avoid the deadlocks that have been observed in some scenarios when statements are being compiled or recompiled. Patch contributed by Brett Wooldridge (brett dot wooldridge at gmail dot com). Patch file: patch4279_2.txt git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1365661 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java", "hunks": [ { "added": [ "\t\t\t\tLanguageConnectionContext lcc = getLanguageConnectionContext();", "\t\t\t\tDataDictionary dd = lcc.getDataDictionary();", "\t\t\t\t", "\t\t\t\tint isolationLevel = (dd.getCacheMode() == DataDictionary.DDL_MODE) ? ", "\t\t\t\t\t\tTransactionController.ISOLATION_READ_COMMITTED : TransactionController.ISOLATION_NOLOCK;", "", "\t\t\t\tcc = lcc.getTransactionCompile().openConglomerate(", "\t\t\t\t\t\tconglomerateId,", " false,", "\t\t\t\t\t\t0,", "\t\t\t\t\t\tTransactionController.MODE_RECORD,", "\t\t\t\t\t\tisolationLevel);", "" ], "header": "@@ -1634,13 +1634,19 @@ public class ResultColumnList extends QueryTreeNodeVector", "removed": [ "\t\t\t\tcc = getLanguageConnectionContext().", "\t\t\t\t\t\tgetTransactionCompile().openConglomerate(", "\t\t\t\t\t\t\tconglomerateId,", " false,", "\t\t\t\t\t\t\t0,", "\t\t\t\t\t\t\tTransactionController.MODE_RECORD,", "\t\t\t\t\t\t\tTransactionController.ISOLATION_READ_COMMITTED);" ] } ] } ]
derby-DERBY-428-10e77784
DERBY-428: PreparedStatement.executeBatch hangs if batch is too large This patch contains a server-side change, a client-side change, and a test. The server-side change is to call ensureLength() in DDMWriter.startDDM(). The DDMWriter working buffer is designed to dynamically grow to accomodate the data being written; this dynamic growth is implemented using a coding rule which requires that all DDMWriter internal routines must call ensureLength to communicate the buffer size requirements prior to writing bytes into the buffer. StartDDM was missing the call to ensureLength. The client-side change is due to the fact that DRDA imposes a hard limit of 65535 elements in a single correlated request because the correlation identifier is a two byte unsigned integer. Prior to this change, the correlation identifiers would wrap around when we added the 65536th element into the batch, which breaks the DRDA protocol rule that requires correlation IDs in a single request be always increasing. This change causes the client to throw an exception if it is asked to execute a batch containing more than 65534 elements. The reason for the number 65534, rather than 65535, is that the value 0xFFFF is reserved for special use. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@387895 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-428-505bb8a1
DERBY-1533: ArrayIndexOutOfBoundsException in DDMReader DERBY-1533 follows in a series of bugs (DERBY-170, DERBY-428, DERBY-491, DERBY-492, DERBY-614 among others) which have to do with the particulars of the DRDA protocols used for handling long messages and large amounts of data. In this particular issue, the problems involve the situation in which the server is receiving a message which is segmented across multiple layer A blocks using DSS continuations. This is a relatively unusual case, as generally large amounts of data flow from the server to the client, not vice versa. This change contains two modifications to DDMReader, as well as some tests: 1) The Network Server method DDMReader.compressBLayerData was incorrect in several respects. Rather than going through that code in detail, I noticed that an almost identical version of this routine exists in the DerbyNetClient, in the class Reply, and I am pretty confident that the client side code is working, so I just wholesale modified the server's compressBLayerData method so that it matched the client's method. 2) When the client is sending parameter data to the server, and the data to be sent is a large array of bytes for a blob, the client, the client may send the data inline as DRDA_TYPE_NVARBYTE, or it may externalize the data and send it as DRDA_TYPE_NLOBBYTES. I believe that similar things happen with CLOB. The client makes this decision based on the length of the data to be sent; short values are sent inline, and long values are sent externalized. When the server receives the data, it must decide whether it is reading an inline string of bytes, or externalized data, and it, too, makes this decision based on the length of the data. However, the server's code for this was comparing the length of the byte string against the amount of data left in the current segment, as opposed to comparing it against the constant threshold value for switching from inline bytes to externalized bytes; hence if a long byte string happened to start late in a buffer, and was then segmented (continued) into a subsequent buffer, the server would mistakenly think the byte string was being sent as externalized bytes, when in fact it was sent as inline bytes. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@430077 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/DDMReader.java", "hunks": [ { "added": [ "\t\tif (length < DssConstants.MAX_DSS_LENGTH)" ], "header": "@@ -1321,7 +1321,7 @@ class DDMReader", "removed": [ "\t\tif (length < dssLength)" ] } ] } ]
derby-DERBY-4282-37f88617
DERBY-4282: Strange behavior with "where current of" in CheckConstraintTest This patch was contributed by Eranda Sooriyabandara (070468D at gmail dot com) This patch addresses an issue involving the binding of check constraints in queries which use the "where current of" construction to refer to the current row of an open cursor. The update statement was failing with a "column not found" error, complaining about the column referred to by the check constraint. The problem arises in the processing of ResultColumnList.expandToAll, which is used to construct ResultColumn instances for the columns in the table; these result column instances are then used when the check constraint is bound. ResultColumnList.java was constructing the ResultColumn instances as unnamed, which caused an internal name "SQLCOL1" to be generated, which later then caused the check constraint binding to fail. The solution is simply to ensure that the ResultColumn references that are built by expandToAll are named according to the column names. The patch also adds several new test cases. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@803336 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4287-03e89c8c
DERBY-4287 call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager Also wraps call to FileOutputStream git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@788436 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/services/bytecode/BCClass.java", "hunks": [ { "added": [ "import java.security.AccessController;" ], "header": "@@ -40,6 +40,7 @@ import org.apache.derby.iapi.util.ByteArray;", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/services/bytecode/GClass.java", "hunks": [ { "added": [ "import java.io.FileNotFoundException;", "import java.security.AccessController;", "import java.security.PrivilegedActionException;", "import java.security.PrivilegedExceptionAction;" ], "header": "@@ -32,8 +32,12 @@ import org.apache.derby.iapi.services.monitor.Monitor;", "removed": [] }, { "added": [ "\t\tfinal File classFile = new File(dir,filename);", "\t\tFileOutputStream fos = null;", "\t\t\ttry {", "\t\t\t\tfos = (FileOutputStream)AccessController.doPrivileged(", "\t\t\t\t\t\tnew PrivilegedExceptionAction() {", "\t\t\t\t\t\t\tpublic Object run()", "\t\t\t\t\t\t\tthrows FileNotFoundException {", "\t\t\t\t\t\t\t\treturn new FileOutputStream(classFile);", "\t\t\t\t\t\t\t}", "\t\t\t\t\t\t});", "\t\t\t} catch (PrivilegedActionException pae) {", "\t\t\t\tthrow (FileNotFoundException)pae.getCause();", "\t\t\t}", "\t\t\tfos.write(bytecode.getArray(),", "\t\t\tfos.flush();", "\t\t\tfos.close();" ], "header": "@@ -72,20 +76,30 @@ public abstract class GClass implements ClassBuilder {", "removed": [ "\t\tFile classFile = new File(dir,filename);", "", "\t\t\tFileOutputStream fis = new FileOutputStream(classFile);", "\t\t\tfis.write(bytecode.getArray(),", "\t\t\tfis.flush();", "\t\t\tfis.close();" ] } ] } ]
derby-DERBY-4292-07e72c36
DERBY-4292 creation of FileInputStream in org.apache.derby.impl.tools.ij.Main not wrapped in privilege block which can cause problems running under SecurityManager Contributed by Tiago R. Espinha (tiago at espinhas dot net) git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@794112 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/tools/org/apache/derby/impl/tools/ij/Main.java", "hunks": [ { "added": [ "import java.security.PrivilegedActionException;", "import java.security.PrivilegedExceptionAction;" ], "header": "@@ -39,6 +39,8 @@ import java.io.IOException;", "removed": [] }, { "added": [ " \tfinal String inFile1 = file;", " \tin1 = (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {", " \t\t\t\tpublic Object run() throws FileNotFoundException {", " \t\t\t\t\t\treturn new FileInputStream(inFile1);", " \t\t\t\t}", " \t\t\t});", " } catch (PrivilegedActionException e) {" ], "header": "@@ -114,12 +116,17 @@ public class Main {", "removed": [ " in1 = new FileInputStream(file);", " } catch (FileNotFoundException e) {" ] } ] } ]
derby-DERBY-4293-23ecfcf9
DERBY-4293: Mutable public static variables Made more static variables final and/or private, and created accessor method to prevent direct access to public static array. Patch contributed by Sebb <sebb@apache.org>. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@789684 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/client/org/apache/derby/client/am/Configuration.java", "hunks": [ { "added": [ " public static final String jreLevel;// = \"1.3.0\"; // default level if unable to read", " public static final int jreLevelMajor;// = 1;", " public static final int jreLevelMinor;// = 3;" ], "header": "@@ -42,9 +42,9 @@ public class Configuration {", "removed": [ " public static String jreLevel = \"1.3.0\"; // default level if unable to read", " public static int jreLevelMajor = 1;", " public static int jreLevelMinor = 3;" ] }, { "added": [ " private static ProductVersionHolder dncProductVersionHolder__;" ], "header": "@@ -56,7 +56,7 @@ public class Configuration {", "removed": [ " public static ProductVersionHolder dncProductVersionHolder__;" ] }, { "added": [ " // We will not set package VERSION in the initial release.", " public static final String dncPackageVersion = null;" ], "header": "@@ -73,9 +73,9 @@ public class Configuration {", "removed": [ " // We will not set packagge VERSION in the initial release.", " public static String dncPackageVersion = null;" ] }, { "added": [ " private static final String packageNameForDNC = \"org.apache.derby.client\"; // NOTUSED" ], "header": "@@ -130,7 +130,7 @@ public class Configuration {", "removed": [ " private static final String packageNameForDNC = \"org.apache.derby.client\";" ] }, { "added": [ " String _jreLevel;", " _jreLevel = System.getProperty(\"java.version\");", " _jreLevel = \"1.3.0\";", " jreLevel = _jreLevel;", " int _jreLevelMajor = 1;", " int _jreLevelMinor = 3;" ], "header": "@@ -140,12 +140,17 @@ public class Configuration {", "removed": [ " jreLevel = System.getProperty(\"java.version\");" ] } ] }, { "file": "java/client/org/apache/derby/client/am/Version.java", "hunks": [ { "added": [ " static final MessageUtil msgutil = SqlException.getMessageUtil();" ], "header": "@@ -27,7 +27,7 @@ import org.apache.derby.shared.common.reference.MessageId;", "removed": [ " static MessageUtil msgutil = SqlException.getMessageUtil();" ] }, { "added": [ " return Configuration.getProductVersionHolder().getVersionBuildString(true);" ], "header": "@@ -36,7 +36,7 @@ public abstract class Version {", "removed": [ " return Configuration.dncProductVersionHolder__.getVersionBuildString(true);" ] } ] }, { "file": "java/client/org/apache/derby/jdbc/ClientBaseDataSource.java", "hunks": [ { "added": [], "header": "@@ -25,7 +25,6 @@ import java.io.Serializable;", "removed": [ "import java.security.PrivilegedActionException;" ] }, { "added": [ " static final boolean SUPPORTS_EUSRIDPWD;", " boolean supports_eusridpwd = false;" ], "header": "@@ -66,10 +65,11 @@ public abstract class ClientBaseDataSource implements Serializable, Referenceabl", "removed": [ " static boolean SUPPORTS_EUSRIDPWD = false;" ] } ] }, { "file": "java/engine/org/apache/derby/iapi/types/JSQLType.java", "hunks": [ { "added": [ "\tstatic\tprivate\tfinal\tString[]\tprimitiveNames =" ], "header": "@@ -72,7 +72,7 @@ public final class JSQLType implements Formatable", "removed": [ "\tstatic\tpublic\tfinal\tString[]\tprimitiveNames =" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java", "hunks": [ { "added": [ "\t\t case JSQLType.JAVA_PRIMITIVE: return JSQLType.getPrimitiveName( myType.getPrimitiveKind() );" ], "header": "@@ -95,7 +95,7 @@ abstract class JavaValueNode extends QueryTreeNode", "removed": [ "\t\t case JSQLType.JAVA_PRIMITIVE: return JSQLType.primitiveNames[ myType.getPrimitiveKind() ];" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java", "hunks": [ { "added": [ "\t\t case JSQLType.JAVA_PRIMITIVE: return JSQLType.getPrimitiveName( jsqlType.getPrimitiveKind() );" ], "header": "@@ -1095,7 +1095,7 @@ abstract class MethodCallNode extends JavaValueNode", "removed": [ "\t\t case JSQLType.JAVA_PRIMITIVE: return JSQLType.primitiveNames[ jsqlType.getPrimitiveKind() ];" ] }, { "added": [ "\t\t\t\t\t\tprimParmTypeNames[i] = JSQLType.getPrimitiveName( jsqlType.getPrimitiveKind() );" ], "header": "@@ -1155,7 +1155,7 @@ abstract class MethodCallNode extends JavaValueNode", "removed": [ "\t\t\t\t\t\tprimParmTypeNames[i] = JSQLType.primitiveNames[ jsqlType.getPrimitiveKind() ];" ] } ] } ]
derby-DERBY-4297-93f457a6
DERBY-4297: Removed method that was no longer used after the main fix git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@890448 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/GenericStatement.java", "hunks": [ { "added": [], "header": "@@ -615,18 +615,6 @@ public class GenericStatement", "removed": [ "\tprivate static long getElapsedTimeMillis(long beginTime)", "\t{", "\t\tif (beginTime != 0)", "\t\t{", "\t\t\treturn System.currentTimeMillis() - beginTime;", "\t\t}", "\t\telse", "\t\t{", "\t\t\treturn 0;", "\t\t}", "\t}", "" ] } ] } ]
derby-DERBY-4304-2f0f84fc
DERBY-4304 During server shutdown substeps, catch any exception thrown, print it to console along with stack trace and then move on to the next substep rather than re-throwing the exception after console printing. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@798742 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java", "hunks": [ { "added": [ " \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);" ], "header": "@@ -819,8 +819,7 @@ public final class NetworkServerControlImpl {", "removed": [ " consolePropertyMessage(\"DRDA_UnexpectedException.S\", true);", " consoleExceptionPrintTrace(exception);" ] }, { "added": [ " \t\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);" ], "header": "@@ -831,8 +830,7 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);", " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ " \t\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);" ], "header": "@@ -854,8 +852,7 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);", " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ " \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);" ], "header": "@@ -867,8 +864,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);", "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ " \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);" ], "header": "@@ -878,8 +874,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);", "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ " \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);" ], "header": "@@ -887,8 +882,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);", "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\t\tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);" ], "header": "@@ -919,8 +913,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);", "\t\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t//Print the passed exception on the console and ignore it after that", "\tprivate void consolePrintAndIgnore(String msgProp, ", "\t\t\tException e, boolean printTimeStamp) {", "\t\t// catch the exception consolePropertyMessage will throw since we", "\t\t// just want to print information about it and move on.", "\t\ttry {", "\t\t\tconsolePropertyMessage(msgProp, true);", "\t\t} catch (Exception ce) {} ", "\t\tconsoleExceptionPrintTrace(e);\t\t", "\t}", "\t" ], "header": "@@ -928,6 +921,17 @@ public final class NetworkServerControlImpl {", "removed": [] } ] } ]
derby-DERBY-4304-6a9299ae
DERBY-4304 When running in insane mode, the stack trace of the exception was not getting printed in the console log file logs/serverConsoleOutput.log The reason for this is that the code was doing following consolePropertyMessage("DRDA_UnexpectedException.S", exception.getMessage()); consoleExceptionPrintTrace(exception); That is, the stack trace printing was happening after the call to consolePropertyMessage. The call to consolePropertyMessage results into a call to consolePropertyMessageWork which may throw an exception back depending on the type of the error it is handling. If this method does throw an exception, then consoleExceptionPrintTrace does not get a chance to dump the stack trace into the logs/serverConsoleOutput. (Probably in sane mode, there is some other additional place where we do the stack trace printing and that is why we saw the stack trace despite consolePropertyMessage throwing an exception.) To fix the problem, I have switched the order of the 2 calls above and that makes sure that we do print the stack trace for debugging purpose. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@796316 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java", "hunks": [ { "added": [ " consoleExceptionPrintTrace(exception);" ], "header": "@@ -819,9 +819,9 @@ public final class NetworkServerControlImpl {", "removed": [ " consoleExceptionPrintTrace(exception);" ] }, { "added": [ " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -832,9 +832,9 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -856,9 +856,9 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -870,9 +870,9 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -882,9 +882,9 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -892,9 +892,9 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -925,9 +925,9 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\t\tconsoleExceptionPrintTrace(exception);" ] } ] } ]
derby-DERBY-4304-75134de4
Backing out change 796316 for DERBY-4304 until I can figure out the cause of NPE in DerbyNetAutoStart Starting test case 1. java.lang.NullPointerException at org.apache.derby.impl.services.jmx.JMXManagementService.unregisterMBean(JMXManagementService.java:286) at org.apache.derby.impl.services.jmx.JMXManagementService.unregisterMBean(JMXManagementService.java:277) at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(NetworkServerControlImpl.java:892) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:599) at org.apache.derby.iapi.jdbc.DRDAServerStarter.run(DRDAServerStarter.java:236) at java.lang.Thread.run(Thread.java:735) Starting test case 2. java.lang.NullPointerException at org.apache.derby.impl.services.jmx.JMXManagementService.unregisterMBean(JMXManagementService.java:286) at org.apache.derby.impl.services.jmx.JMXManagementService.unregisterMBean(JMXManagementService.java:277) at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(NetworkServerControlImpl.java:892) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:599) at org.apache.derby.iapi.jdbc.DRDAServerStarter.run(DRDAServerStarter.java:236) at java.lang.Thread.run(Thread.java:735) git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@796372 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java", "hunks": [ { "added": [ " consoleExceptionPrintTrace(exception);" ], "header": "@@ -819,9 +819,9 @@ public final class NetworkServerControlImpl {", "removed": [ " consoleExceptionPrintTrace(exception);" ] }, { "added": [ " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -832,9 +832,9 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -856,9 +856,9 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -870,9 +870,9 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -882,9 +882,9 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -892,9 +892,9 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsoleExceptionPrintTrace(exception);" ] }, { "added": [ "\t\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -925,9 +925,9 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\t\tconsoleExceptionPrintTrace(exception);" ] } ] } ]
derby-DERBY-4304-892eebf1
DERBY-4304 During one of the server shutdown steps, DERBY-4306 was throwing a npe(we have fixed DERBY-4306 now) and the shutdown exception handling code was calling following method on that npe consolePropertyMessage("DRDA_UnexpectedException.S", exception.getMessage()); consoleExceptionPrintTrace(exception); but the call exception.getMessage() on npe was returning null and consolePropertyMessage is not written to handle null 2nd param for this call of consolePropertyMessage. But the work done by this particular type of consolePropertyMessage method is also done by the next call in the shutdown exception handling which is consoleExceptionPrintTrace. Because of this, I have replaced the consolePropertyMessage("DRDA_UnexpectedException.S", exception.getMessage()); call with consolePropertyMessage("DRDA_UnexpectedException.S", true); This change makes sure we do not run into npe when exception.getMessage() is null. I am not sure if we should enter a new jira entry to make consolePropertyMessage("DRDA_UnexpectedException.S", exception.getMessage()); handle a null 2nd param. junit tests with this change ran into intermittent upgrade test failures. One last step remaining is may be write a new method which is a subset of consolePropertyMessage because consolePropertyMessage handles the exception printing and then goes ahead and throws the exception again. For our purposes in this jira entry, we do not want the exception to be thrown back. instead, we want to move on to the next step in server shutdown. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@798347 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java", "hunks": [ { "added": [ " consolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -819,8 +819,7 @@ public final class NetworkServerControlImpl {", "removed": [ " consolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " exception.getMessage());" ] }, { "added": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -832,8 +831,7 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " \t\t\t\t\t\t\texception.getMessage());" ] }, { "added": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -856,8 +854,7 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " \t\t\t\t\t\t\texception.getMessage());" ] }, { "added": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -870,8 +867,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());" ] }, { "added": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -882,8 +878,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());" ] }, { "added": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -892,8 +887,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());" ] }, { "added": [ "\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -925,8 +919,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\t\texception.getMessage());" ] } ] } ]
derby-DERBY-4304-d49d499c
DERBY-4304 Committing changes which puts a new try catch block around all of the server shutdown code in case if there is some exception being thrown which is not getting caught. The catch block will log into the log file but if that fails for some reason, it will also just dump the stack trace using ex.printStackTrace(). git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@803548 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java", "hunks": [ { "added": [ "\t\ttry {", "\t\t\t// wait until we are told to shutdown or someone sends an InterruptedException", "\t synchronized(shutdownSync) {", "\t try {", "\t\t\t\t\tshutdownSync.wait();", "\t }", "\t catch (InterruptedException e)", "\t {", "\t shutdown = true;", "\t }", "\t }", "\t ", "\t try {", "\t AccessController.doPrivileged(", "\t new PrivilegedAction() {", "\t public Object run() {", "\t // Need to interrupt the memcheck thread if it is sleeping.", "\t if (mc != null)", "\t mc.interrupt();", "", "\t //interrupt client thread", "\t clientThread.interrupt();", "", "\t return null;", "\t }", "\t });", "\t } catch (Exception exception) {", "\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t }", "\t\t\t", "\t \t\t// Close out the sessions", "\t \t\tsynchronized(sessionTable) {", "\t \t\t\tfor (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )", "\t \t\t\t{\t", "\t \t\t\t\tSession session = (Session) e.nextElement();", "\t \t\t\t\ttry {", "\t \t\t\t\t\tsession.close();", "\t \t\t\t\t} catch (Exception exception) {", "\t \t\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t \t\t\t\t}", "\t \t\t\t}", "\t \t\t}", "", "\t\t\tsynchronized (threadList)", "\t\t\t{", "\t \t\t\t//interupt any connection threads still active", "\t \t\t\tfor (int i = 0; i < threadList.size(); i++)", "\t \t\t\t{", "\t \t\t\t\ttry {", "\t \t\t\t\t\tfinal DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);", "\t \t ", "\t \t \t\t\t\tthreadi.close();", "\t \t\t\t\t\tAccessController.doPrivileged(", "\t \t\t\t\t\t\t\t\tnew PrivilegedAction() {", "\t \t\t\t\t\t\t\t\t\tpublic Object run() {", "\t \t\t\t\t\t\t\t\t\t\tthreadi.interrupt();", "\t \t\t\t\t\t\t\t\t\t\treturn null;", "\t \t\t\t\t\t\t\t\t\t}", "\t \t\t\t\t\t\t\t\t});", "\t \t\t\t\t} catch (Exception exception) {", "\t \t\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t \t\t\t\t}", "\t \t\t\t}", "\t \t\t\tthreadList.clear();", "\t\t\t}", "\t\t \t", "\t\t // close the listener socket", "\t\t try{", "\t\t serverSocket.close();", "\t\t }catch(IOException e){", "\t\t\t\tconsolePropertyMessage(\"DRDA_ListenerClose.S\", true);", "\t\t } catch (Exception exception) {", "\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t\t }", "", "\t\t\t// Wake up those waiting on sessions, so", "\t\t\t// they can close down", "\t\t try{", "\t\t\t\tsynchronized (runQueue) {", "\t\t\t\t\trunQueue.notifyAll();", "\t\t\t\t}\t", "\t\t } catch (Exception exception) {", "\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t\t }", "\t ", "\t // And now unregister any MBeans.", "\t\t try {", "\t\t mgmtService.unregisterMBean(versionMBean);", "\t\t mgmtService.unregisterMBean(networkServerMBean);", "\t\t } catch (Exception exception) {", "\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t\t }", "", "\t\t\tif (shutdownDatabasesOnShutdown) {", "", "\t\t\t\t// Shutdown Derby", "\t\t\t\ttry {", "\t\t\t\t\t// tell driver to shutdown the engine", "\t\t\t\t\tif (cloudscapeDriver != null) {", "\t\t\t\t\t\t// DERBY-2109: pass user credentials for driver shutdown", "\t\t\t\t\t\tfinal Properties p = new Properties();", "\t\t\t\t\t\tif (userArg != null) {", "\t\t\t\t\t\t\tp.setProperty(\"user\", userArg);", "\t\t\t\t\t\t}", "\t\t\t\t\t\tif (passwordArg != null) {", "\t\t\t\t\t\t\tp.setProperty(\"password\", passwordArg);", "\t\t\t\t\t\t}", "\t\t\t\t\t\tcloudscapeDriver.connect(\"jdbc:derby:;shutdown=true\", p);", "\t\t\t\t} catch (SQLException sqle) {", "\t\t\t\t\t// If we can't shutdown Derby, perhaps, authentication has", "\t\t\t\t\t// failed or System Privileges weren't granted. We will just", "\t\t\t\t\t// print a message to the console and proceed.", "\t\t\t\t\tString expectedState =", "\t\t\t\t\t\tStandardException.getSQLStateFromIdentifier(", "\t\t\t\t\t\t\t\tSQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);", "\t\t\t\t\tif (!expectedState.equals(sqle.getSQLState())) {", "\t\t\t\t\t\tconsolePropertyMessage(\"DRDA_ShutdownWarning.I\",", "\t\t\t\t\t\t\t\t\t\t\t sqle.getMessage());", "\t\t\t\t} catch (Exception exception) {", "\t\t\t\t\tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t\t\tconsolePropertyMessage(\"DRDA_ShutdownSuccess.I\", new String [] ", "\t\t\t\t\t\t\t {att_srvclsnm, versionString});", "\t\t\t", "\t\t} catch (Exception ex) {", "\t\t\ttry {", "\t\t\t\t//If the console printing is not available, then we have", "\t\t\t\t//a simple stack trace print below to atleast print some", "\t\t\t\t//exception info", "\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", ex, true);\t\t\t\t", "\t\t\t} catch (Exception e) {}", "\t\t\tex.printStackTrace();", "\t\t}" ], "header": "@@ -793,132 +793,143 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t// wait until we are told to shutdown or someone sends an InterruptedException", " synchronized(shutdownSync) {", " try {", "\t\t\t\tshutdownSync.wait();", " }", " catch (InterruptedException e)", " {", " shutdown = true;", " }", " }", " ", " try {", " AccessController.doPrivileged(", " new PrivilegedAction() {", " public Object run() {", " // Need to interrupt the memcheck thread if it is sleeping.", " if (mc != null)", " mc.interrupt();", "", " //interrupt client thread", " clientThread.interrupt();", "", " return null;", " }", " });", " } catch (Exception exception) {", " \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", " }", "\t\t", " \t\t// Close out the sessions", " \t\tsynchronized(sessionTable) {", " \t\t\tfor (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )", " \t\t\t{\t", " \t\t\t\tSession session = (Session) e.nextElement();", " \t\t\t\ttry {", " \t\t\t\t\tsession.close();", " \t\t\t\t} catch (Exception exception) {", " \t\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", " \t\t\t\t}", " \t\t\t}", " \t\t}", "", "\t\tsynchronized (threadList)", "\t\t{", " \t\t\t//interupt any connection threads still active", " \t\t\tfor (int i = 0; i < threadList.size(); i++)", " \t\t\t{", " \t\t\t\ttry {", " \t\t\t\t\tfinal DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);", " \t ", " \t \t\t\t\tthreadi.close();", " \t\t\t\t\tAccessController.doPrivileged(", " \t\t\t\t\t\t\t\tnew PrivilegedAction() {", " \t\t\t\t\t\t\t\t\tpublic Object run() {", " \t\t\t\t\t\t\t\t\t\tthreadi.interrupt();", " \t\t\t\t\t\t\t\t\t\treturn null;", " \t\t\t\t\t\t\t\t\t}", " \t\t\t\t\t\t\t\t});", " \t\t\t\t} catch (Exception exception) {", " \t\t \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", " \t\t\t\t}", " \t\t\t}", " \t\t\tthreadList.clear();", "\t\t}", "\t \t", "\t // close the listener socket", "\t try{", "\t serverSocket.close();", "\t }catch(IOException e){", "\t\t\tconsolePropertyMessage(\"DRDA_ListenerClose.S\", true);", "\t } catch (Exception exception) {", " \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t }", "", "\t\t// Wake up those waiting on sessions, so", "\t\t// they can close down", "\t try{", "\t\t\tsynchronized (runQueue) {", "\t\t\t\trunQueue.notifyAll();", "\t\t\t}\t", "\t } catch (Exception exception) {", " \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t }", " ", " // And now unregister any MBeans.", "\t try {", "\t mgmtService.unregisterMBean(versionMBean);", "\t mgmtService.unregisterMBean(networkServerMBean);", "\t } catch (Exception exception) {", " \tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t }", "", "\t\tif (shutdownDatabasesOnShutdown) {", "", "\t\t\t// Shutdown Derby", "\t\t\ttry {", "\t\t\t\t// tell driver to shutdown the engine", "\t\t\t\tif (cloudscapeDriver != null) {", "\t\t\t\t\t// DERBY-2109: pass user credentials for driver shutdown", "\t\t\t\t\tfinal Properties p = new Properties();", "\t\t\t\t\tif (userArg != null) {", "\t\t\t\t\t\tp.setProperty(\"user\", userArg);", "\t\t\t\t\tif (passwordArg != null) {", "\t\t\t\t\t\tp.setProperty(\"password\", passwordArg);", "\t\t\t\t\tcloudscapeDriver.connect(\"jdbc:derby:;shutdown=true\", p);", "\t\t\t\t}", "\t\t\t} catch (SQLException sqle) {", "\t\t\t\t// If we can't shutdown Derby, perhaps, authentication has", "\t\t\t\t// failed or System Privileges weren't granted. We will just", "\t\t\t\t// print a message to the console and proceed.", "\t\t\t\tString expectedState =", "\t\t\t\t\tStandardException.getSQLStateFromIdentifier(", "\t\t\t\t\t\t\tSQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);", "\t\t\t\tif (!expectedState.equals(sqle.getSQLState())) {", "\t\t\t\t\tconsolePropertyMessage(\"DRDA_ShutdownWarning.I\",", "\t\t\t\t\t\t\t\t\t\t sqle.getMessage());", "\t\t\t} catch (Exception exception) {", "\t\t\t\tconsolePrintAndIgnore(\"DRDA_UnexpectedException.S\", exception, true);", "\t\t}", "\t\tconsolePropertyMessage(\"DRDA_ShutdownSuccess.I\", new String [] ", "\t\t\t\t\t\t {att_srvclsnm, versionString});" ] } ] } ]
derby-DERBY-4304-e01e5d79
DERBY-4304 I have made changes to NetworkServerControlImpl.java so we handle the exceptions during different steps of server shutdown and continue with the next step in shutdown rather than bailing out after the first exception. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@794303 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java", "hunks": [ { "added": [ " try {", " AccessController.doPrivileged(", " new PrivilegedAction() {", " public Object run() {", " // Need to interrupt the memcheck thread if it is sleeping.", " if (mc != null)", " mc.interrupt();", "", " //interrupt client thread", " clientThread.interrupt();", "", " return null;", " }", " });", " } catch (Exception exception) {", " consolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " exception.getMessage());", " consoleExceptionPrintTrace(exception);", " }", " \t\t\t\ttry {", " \t\t\t\t\tsession.close();", " \t\t\t\t} catch (Exception exception) {", " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " \t\t\t\t\t\t\texception.getMessage());", " \t\t\t\t\tconsoleExceptionPrintTrace(exception);", " \t\t\t\t}" ], "header": "@@ -804,26 +804,38 @@ public final class NetworkServerControlImpl {", "removed": [ " AccessController.doPrivileged(", " new PrivilegedAction() {", " public Object run() {", " // Need to interrupt the memcheck thread if it is sleeping.", " if (mc != null)", " mc.interrupt();", "", " //interrupt client thread", " clientThread.interrupt();", "", " return null;", " }", " });", " \t\t\t\tsession.close();" ] }, { "added": [ " \t\t\t\ttry {", " \t\t\t\t\tfinal DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);", " \t ", " \t \t\t\t\tthreadi.close();", " \t\t\t\t\tAccessController.doPrivileged(", " \t\t\t\t\t\t\t\tnew PrivilegedAction() {", " \t\t\t\t\t\t\t\t\tpublic Object run() {", " \t\t\t\t\t\t\t\t\t\tthreadi.interrupt();", " \t\t\t\t\t\t\t\t\t\treturn null;", " \t\t\t\t\t\t\t\t\t}", " \t\t\t\t\t\t\t\t});", " \t\t\t\t} catch (Exception exception) {", " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " \t\t\t\t\t\t\texception.getMessage());", " \t\t\t\t\tconsoleExceptionPrintTrace(exception);", " \t\t\t\t}" ], "header": "@@ -832,16 +844,22 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\t\tfinal DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);", " ", " \t\t\t\tthreadi.close();", "\t\t\t\tAccessController.doPrivileged(", "\t\t\t\t\t\t\tnew PrivilegedAction() {", "\t\t\t\t\t\t\t\tpublic Object run() {", "\t\t\t\t\t\t\t\t\tthreadi.interrupt();", "\t\t\t\t\t\t\t\t\treturn null;", "\t\t\t\t\t\t\t\t}", "\t\t\t\t\t\t\t});" ] }, { "added": [ "\t } catch (Exception exception) {", "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());", "\t\t\tconsoleExceptionPrintTrace(exception);", "\t try{", "\t\t\tsynchronized (runQueue) {", "\t\t\t\trunQueue.notifyAll();", "\t\t\t}\t", "\t } catch (Exception exception) {", "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());", "\t\t\tconsoleExceptionPrintTrace(exception);", "\t }", "\t try {", "\t mgmtService.unregisterMBean(versionMBean);", "\t mgmtService.unregisterMBean(networkServerMBean);", "\t } catch (Exception exception) {", "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());", "\t\t\tconsoleExceptionPrintTrace(exception);", "\t }" ], "header": "@@ -851,18 +869,33 @@ public final class NetworkServerControlImpl {", "removed": [ "", "\t\tsynchronized (runQueue) {", "\t\t\trunQueue.notifyAll();", "\t\t}\t", " mgmtService.unregisterMBean(versionMBean);", " mgmtService.unregisterMBean(networkServerMBean);" ] }, { "added": [ "\t\t\t} catch (Exception exception) {", "\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\t\texception.getMessage());", "\t\t\t\tconsoleExceptionPrintTrace(exception);" ], "header": "@@ -891,6 +924,10 @@ public final class NetworkServerControlImpl {", "removed": [] } ] } ]
derby-DERBY-4305-c9868628
DERBY-4305 - Make changes to test harness class j9_foundation 11 to support newer version of IBM's JSR169 implementation committing the change to move to weme 6.2 git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@795095 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/testing/org/apache/derbyTesting/functionTests/harness/j9_foundation11.java", "hunks": [ { "added": [ " <p>This class is for IBM's J9 jdk 1.3., foundation class library; v 2.4 (weme6.2)" ], "header": "@@ -25,7 +25,7 @@ import java.util.StringTokenizer;", "removed": [ " <p>This class is for IBM's J9 jdk 1.3., foundation class library; v 2.3 (weme6.1)" ] }, { "added": [ "\t\tsetJavaCmd(wshome+\"/weme6.2/bin/j9\");" ], "header": "@@ -53,7 +53,7 @@ public class j9_foundation11 extends jvm {", "removed": [ "\t\tsetJavaCmd(wshome+\"/weme6.1/bin/j9\");" ] }, { "added": [ " // for now, assume we're only interested in doing this for weme6.2_foundation, worry about" ], "header": "@@ -82,7 +82,7 @@ public class j9_foundation11 extends jvm {", "removed": [ " // for now, assume we're only interested in doing this for weme6.1_foundation, worry about" ] }, { "added": [ " // note, assuming jclFoundation classes sit under weme6.2/lib/jclFoundation11", " // and that jdbc.jar sits under weme6.2/lib", " sb.append(\" -Xbootclasspath/a:\" + wshome + \"/weme6.2/lib/jclFoundation11/classes.zip\"", " + pathsep + wshome + \"/weme6.2/lib/jclFoundation11/locale.zip\"", " + pathsep + wshome + \"/weme6.2/lib/jdbc.jar\");" ], "header": "@@ -90,12 +90,12 @@ public class j9_foundation11 extends jvm {", "removed": [ " // note, assuming jclFoundation classes sit under weme6.1/lib/jclFoundation11", " // and that jdbc.jar sits under weme6.1/lib", " sb.append(\" -Xbootclasspath/a:\" + wshome + \"/weme6.1/lib/jclFoundation11/classes.zip\"", " + pathsep + wshome + \"/weme6.1/lib/jclFoundation11/locale.zip\"", " + pathsep + wshome + \"/weme6.1/lib/jdbc.jar\");" ] } ] } ]
derby-DERBY-4306-892eebf1
DERBY-4304 During one of the server shutdown steps, DERBY-4306 was throwing a npe(we have fixed DERBY-4306 now) and the shutdown exception handling code was calling following method on that npe consolePropertyMessage("DRDA_UnexpectedException.S", exception.getMessage()); consoleExceptionPrintTrace(exception); but the call exception.getMessage() on npe was returning null and consolePropertyMessage is not written to handle null 2nd param for this call of consolePropertyMessage. But the work done by this particular type of consolePropertyMessage method is also done by the next call in the shutdown exception handling which is consoleExceptionPrintTrace. Because of this, I have replaced the consolePropertyMessage("DRDA_UnexpectedException.S", exception.getMessage()); call with consolePropertyMessage("DRDA_UnexpectedException.S", true); This change makes sure we do not run into npe when exception.getMessage() is null. I am not sure if we should enter a new jira entry to make consolePropertyMessage("DRDA_UnexpectedException.S", exception.getMessage()); handle a null 2nd param. junit tests with this change ran into intermittent upgrade test failures. One last step remaining is may be write a new method which is a subset of consolePropertyMessage because consolePropertyMessage handles the exception printing and then goes ahead and throws the exception again. For our purposes in this jira entry, we do not want the exception to be thrown back. instead, we want to move on to the next step in server shutdown. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@798347 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java", "hunks": [ { "added": [ " consolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -819,8 +819,7 @@ public final class NetworkServerControlImpl {", "removed": [ " consolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " exception.getMessage());" ] }, { "added": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -832,8 +831,7 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " \t\t\t\t\t\t\texception.getMessage());" ] }, { "added": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -856,8 +854,7 @@ public final class NetworkServerControlImpl {", "removed": [ " \t\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", " \t\t\t\t\t\t\texception.getMessage());" ] }, { "added": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -870,8 +867,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());" ] }, { "added": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -882,8 +878,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());" ] }, { "added": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -892,8 +887,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\texception.getMessage());" ] }, { "added": [ "\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\", true);" ], "header": "@@ -925,8 +919,7 @@ public final class NetworkServerControlImpl {", "removed": [ "\t\t\t\tconsolePropertyMessage(\"DRDA_UnexpectedException.S\",\t\t\t", "\t\t\t\t\t\texception.getMessage());" ] } ] } ]
derby-DERBY-4310-5b78c4e3
DERBY-4310 jdbcapi.XATest passes but shows Table/View 'APP.FOO' does not exist. under logs/serverConsoleOutput.log DERBY-4155 jdbcapi/XATest.java doesn't seem to be running anywhere The problem was actually an embedded issue that close() tried to reprepare the statement which would fail if dependencies had been dropped. This caused a failur in proper shutdown of network server which could cause a hang after running XATest. Contributed by Tiago Espinha (tiago at espinhas dot net) git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@800523 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4311-d13a3acc
DERBY-4311: BaseJDBCTestCase.assertErrorCode() never fails Removed the broken methods. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@795092 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4312-8b8fe9f9
DERBY-4312 SQLException XJ215 on insert with setCharacterStream() and autocommit off in mailjdbc test DERBY-4224 Commit after setAsciiStream() makes execution fail with the client driver Use of a stream after performing commit was incorrectly causing an exception. Also fixes setBinaryStream(); git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@796020 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4313-df7db9ea
DERBY-4313: JDBC.dropUsingDMD() may skip dropping objects Only remove DDL statements from the list of statements to execute if they were successful. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@796834 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/testing/org/apache/derbyTesting/junit/JDBC.java", "hunks": [ { "added": [ "\t\t\tif (result == Statement.EXECUTE_FAILED)", "\t\t\telse if (result == Statement.SUCCESS_NO_INFO || result >= 0) {", "\t\t\t\tddl.set(i, null);", "\t\t\t}" ], "header": "@@ -392,17 +392,14 @@ public class JDBC {", "removed": [ "\t\t\tif (result == -3 /* Statement.EXECUTE_FAILED*/)", "\t\t\telse if (result == -2/*Statement.SUCCESS_NO_INFO*/)", "\t\t\t\tdidDrop = true;", "\t\t\telse if (result >= 0)", " ", " if (didDrop)", " ddl.set(i, null);" ] } ] } ]
derby-DERBY-4314-2f3d0522
DERBY-4314 With derby client setTrasactionIsolation executes and commits even if isolation has not changed. Contributed by Lily Wei (lilywei at yahoo dot com) and Kristian Waagan setTransactionIsolation will no longer commit. Piggybacking of the isolation level was implemented to avoid a performance impact. There is specialized logic for XA Resume and Join to make sure the client isolation is in sync with the server. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@940620 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/client/org/apache/derby/client/am/Connection.java", "hunks": [ { "added": [ "import org.apache.derby.client.net.NetXAResource;" ], "header": "@@ -26,6 +26,7 @@ import org.apache.derby.jdbc.ClientDataSource;", "removed": [] }, { "added": [ " /**", " * The default isolation level, enforced on connection resets.", " * <p>", " * Note that this value may be changed upon connection initialization in", " * the future, as the server can piggy-back the isolation level.", " */", " private int defaultIsolation = TRANSACTION_READ_COMMITTED;" ], "header": "@@ -104,6 +105,13 @@ public abstract class Connection implements java.sql.Connection,", "removed": [] }, { "added": [ " //This avoids assertion like DERBY-4343 by short-circuiting", " //setTransactionIsolation. Before this check, for case as users", " //obtaining the pooled connection for the third time, the variable", " //isolation_ is reset Connection.completeReset. ", " //Isolation_ remain as UNKNOWN until getTransactionIsolation is called", " //or a different statement causing a change of the isolation level", " //is executed.We might think about change the default value for Isolation_", " //to DERBY_TRANSACTION_READ_COMMITTED. With introducing ", " //getTransactionIsolationX and this check, assertion is never reach. ", " //As part of DERBY-4314 fix, the client driver should act as embedded ", " //and return here, otherwise setTransactionIsolation will commit ", " //the transaction which is not the intention.", " if (level == getTransactionIsolationX()) ", "\t return;", "" ], "header": "@@ -909,6 +917,21 @@ public abstract class Connection implements java.sql.Connection,", "removed": [] }, { "added": [ "", " if (agent_.loggingEnabled()) {", " agent_.logWriter_.traceEntry(this, \"getTransactionIsolation\", isolation_);", " }", " try {", " // Per jdbc spec (see java.sql.Connection.close() javadoc).", " checkForClosedConnection();", " return getTransactionIsolationX();", " } catch (SqlException se) {", " throw se.getSQLException();", " }", " }", "", " public int getTransactionIsolationX() throws SQLException {" ], "header": "@@ -1010,7 +1033,20 @@ public abstract class Connection implements java.sql.Connection,", "removed": [ " \t" ] }, { "added": [], "header": "@@ -1019,9 +1055,6 @@ public abstract class Connection implements java.sql.Connection,", "removed": [ " if (agent_.loggingEnabled()) {", " agent_.logWriter_.traceExit(this, \"getTransactionIsolation\", isolation_);", " }" ] }, { "added": [ " /**", " * Sets the default isolation level of the connection upon connection", " * initialization.", " * <p>", " * Note that depending on the server version, the default isolation value", " * may not be piggy-backed on the initialization flow. In that case, the", " * default is assumed / hardcoded to be READ_COMMITTED.", " *", " * @param pbIsolation isolation level as specified by", " * {@code java.sql.Connection}", " */", " public void completeInitialPiggyBackIsolation(int pbIsolation) {", " if (SanityManager.DEBUG) {", " SanityManager.ASSERT(", " pbIsolation == ", " java.sql.Connection.TRANSACTION_READ_UNCOMMITTED ||", " pbIsolation ==", " java.sql.Connection.TRANSACTION_READ_COMMITTED ||", " pbIsolation ==", " java.sql.Connection.TRANSACTION_REPEATABLE_READ ||", " pbIsolation ==", " java.sql.Connection.TRANSACTION_SERIALIZABLE,", " \"Invalid isolation level value: \" + pbIsolation);", " }", " defaultIsolation = isolation_ = pbIsolation;", " }", "" ], "header": "@@ -2093,6 +2126,33 @@ public abstract class Connection implements java.sql.Connection,", "removed": [] }, { "added": [ " /**", " * Sets the current schema upon connection initialization.", " *", " * @param pbSchema the schema name", " */", " public void completeInitialPiggyBackSchema(String pbSchema) {", " currentSchemaName_ = pbSchema;", " }", "" ], "header": "@@ -2100,6 +2160,15 @@ public abstract class Connection implements java.sql.Connection,", "removed": [] }, { "added": [ " boolean closeStatementsOnClose,", " NetXAResource xares)" ], "header": "@@ -2149,7 +2218,8 @@ public abstract class Connection implements java.sql.Connection,", "removed": [ " boolean closeStatementsOnClose)" ] } ] }, { "file": "java/client/org/apache/derby/client/net/NetConnectionReply.java", "hunks": [ { "added": [ " parseInitialPBSD(netConnection);" ], "header": "@@ -299,6 +299,7 @@ public class NetConnectionReply extends Reply", "removed": [] } ] }, { "file": "java/client/org/apache/derby/client/net/NetXAResource.java", "hunks": [ { "added": [ "import java.sql.SQLException;" ], "header": "@@ -41,6 +41,7 @@ package org.apache.derby.client.net;", "removed": [] }, { "added": [ " private boolean keepIsolationLevel;" ], "header": "@@ -87,6 +88,7 @@ public class NetXAResource implements XAResource {", "removed": [] } ] } ]
derby-DERBY-4314-45a82041
DERBY-6066(Client should use a prepared statement rather than regular statement for Connection.getTransactionIsolation) This commit has the client user a PreparedStatement rather than a Statement to get the current isolation level. Additionally, we found while working on this issue, that the calls to get isolation level were not always getting sent to the server side. The research on this found following The get transaction isolation call will be sent to the server on the wire in at least following 2 cases 1)When a newer client is working with the older versions of servers(ie server that do not have support for isolation level caching) - Server version 10.3 and earlier do not support isolation level caching and hence when a newer client(10.4 and higher) is talking to a 10.3 and earlier server, there will be no information available about the current isolation level on the client side and client will ask for the isolation level from the server by sending "VALUES CURRENT ISOLATION" over the wire. For server versions 10.4 and above, there is a possibility that the current isolation level was already piggybacked to the client as part of some other client server communication and hence the current isolation level is already available to the client and there is no need to send "VALUES CURRENT ISOLATION" over the wire to the server. 2)Additionally, as per DERBY-4314 and write up on piggybacking at http://wiki.apache.org/db-derby/Derby3192Writeup, there might be cases, where even though server has support for isolation level caching, server has not had a chance to send the isolation level piggybacked to the client as part of some other communication between client and server and hence the client will actually need to send "VALUES CURRENT ISOLATION" to the server to get the current isolation level. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1450499 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/client/org/apache/derby/client/am/Connection.java", "hunks": [ { "added": [ " private PreparedStatement getTransactionIsolationPrepStmt = null;" ], "header": "@@ -99,7 +99,7 @@ public abstract class Connection", "removed": [ " private Statement getTransactionIsolationStmt = null;" ] }, { "added": [ " if (getTransactionIsolationPrepStmt != null) {", " getTransactionIsolationPrepStmt.close();", " getTransactionIsolationPrepStmt = null;" ], "header": "@@ -804,15 +804,15 @@ public abstract class Connection", "removed": [ " if (getTransactionIsolationStmt != null) {", " getTransactionIsolationStmt.close();", " getTransactionIsolationStmt = null;" ] }, { "added": [], "header": "@@ -1084,7 +1084,6 @@ public abstract class Connection", "removed": [ " " ] }, { "added": [ " // DERBY-6066(Client should use a prepared statement rather than ", " // regular statement for Connection.getTransactionIsolation)", " // Following code(which actually sends the get transaction ", " // isolation call to the server on the wire) will be executed ", " // in at least following 2 cases", " // 1)When a newer client is working with the older versions of ", " // servers(ie server that do not have support for isolation ", " // level caching) - Server version 10.3 and earlier do not ", " // support isolation level caching and hence when a newer ", " // client(10.4 and higher) is talking to a 10.3 and earlier ", " // server, the if condition above will be false and the code ", " // will reach here to get the isolation level from the server ", " // by sending \"VALUES CURRENT ISOLATION\" over the wire. For ", " // server versions 10.4 and above, the if condition above can ", " // be true if the isolation level was already piggybacked to ", " // the client as part of some other client server communication", " // and hence the current isolation level is already available to ", " // the client and there is no need to send ", " // \"VALUES CURRENT ISOLATION\" over the wire to the server.", " // 2)Additionally, as per DERBY-4314 and write up on piggybacking", " // at http://wiki.apache.org/db-derby/Derby3192Writeup, there ", " // might be cases, where even though server has support for ", " // isolation level caching, server has not had a chance to ", " // send the isolation level piggybacked to the client as part ", " // of some other communication between client and server and ", " // hence the if condition above will be false and client will", " // actually need to send \"VALUES CURRENT ISOLATION\" to the ", " // server to get the current isolation level.", " // " ], "header": "@@ -1102,6 +1101,35 @@ public abstract class Connection", "removed": [] }, { "added": [ " if (getTransactionIsolationPrepStmt == null || ", " !(getTransactionIsolationPrepStmt.openOnClient_ &&", " getTransactionIsolationPrepStmt.openOnServer_)) {", " \tgetTransactionIsolationPrepStmt =", " prepareStatementX(", " \"VALUES CURRENT ISOLATION\",", " java.sql.ResultSet.TYPE_FORWARD_ONLY,", " holdability(),", " java.sql.Statement.NO_GENERATED_KEYS,", " null, null);", " rs = getTransactionIsolationPrepStmt.executeQuery();" ], "header": "@@ -1116,17 +1144,21 @@ public abstract class Connection", "removed": [ " if (getTransactionIsolationStmt == null || ", " !(getTransactionIsolationStmt.openOnClient_ &&", " getTransactionIsolationStmt.openOnServer_)) {", " getTransactionIsolationStmt =", " createStatementX(java.sql.ResultSet.TYPE_FORWARD_ONLY,", " holdability());", " rs = getTransactionIsolationStmt.executeQuery(\"values current isolation\");" ] } ] } ]
derby-DERBY-4314-baab96fc
DERBY-4343 ASSERT FAILED calling setTransactionIsolation checking isolation_ == level on pooled connection Contributed by Lily Wei lilywei at yahoo dot com This is just the test case for this issue. The issue itself was actually fixed with DERBY-4314. Also included is one DERBY-4314 test case to make sure piggybacking works ok after statement execution. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@942908 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4315-419a664d
DERBY-4315: Clean up error reporting when sending an InputStream from the client to the server. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1037716 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/client/org/apache/derby/client/net/Request.java", "hunks": [ { "added": [ "\t\t\t\t} catch (Exception e) {", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t new ClientMessageId(SQLState.NET_EXCEPTION_ON_READ)," ], "header": "@@ -317,14 +317,14 @@ public class Request {", "removed": [ "\t\t\t\t} catch (java.io.IOException e) {", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t new ClientMessageId(SQLState.NET_IOEXCEPTION_ON_READ)," ] }, { "added": [ "\t\t} catch (Exception e) {", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t SQLState.NET_EXCEPTION_ON_STREAMLEN_VERIFICATION)," ], "header": "@@ -359,12 +359,12 @@ public class Request {", "removed": [ "\t\t} catch (java.io.IOException e) {", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t SQLState.NET_IOEXCEPTION_ON_STREAMLEN_VERIFICATION)," ] } ] }, { "file": "java/shared/org/apache/derby/shared/common/reference/SQLState.java", "hunks": [ { "added": [ " String NET_EXCEPTION_ON_READ = \"XN014.S\";", " String NET_EXCEPTION_ON_STREAMLEN_VERIFICATION = \"XN016.S\";" ], "header": "@@ -1603,9 +1603,9 @@ public interface SQLState {", "removed": [ " String NET_IOEXCEPTION_ON_READ = \"XN014.S\";", " String NET_IOEXCEPTION_ON_STREAMLEN_VERIFICATION = \"XN016.S\";" ] } ] } ]
derby-DERBY-4316-4e1fb4cc
DERBY-4316: Embedded and client don't agree on whether to continue after error in batch Added a test case that shows the difference. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@795549 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4319-17227cff
DERBY-4319 hang in suites.all with ibm 1.5 on AIX after ttestDefaultProperties Make sure spawned network server process is destroyed if the hang occurs on SpawnedProcess.complete(). This does not address the core reason for the hang which is still not well understood and currently does not reproduce on the aix machine with the problem. DERBY-4319 will stay open while we wait for the problem to reappear. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1079548 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/testing/org/apache/derbyTesting/junit/SpawnedProcess.java", "hunks": [ { "added": [ " /*Complete the method", " * @param destroy true to destroy it, false to wait indefinitely to complete ", " */", " public int complete(boolean destroy) throws InterruptedException, IOException {", " return complete(destroy, -1L);", " }", " ", " * @param destroy True to destroy it, false to wait for it to complete ", " * based on timeout.", " * ", " * @param timeout milliseconds to wait until finished or else destroy.", " * -1 don't timeout", " * ", " public int complete(boolean destroy, long timeout) throws InterruptedException, IOException {", " int exitCode;", " if (timeout >= 0 ) {", " long totalwait = -1;", " while (totalwait < timeout) {", " try { ", " exitCode = javaProcess.exitValue();", " //if no exception thrown, exited normally", " destroy = false;", " break;", " }catch (IllegalThreadStateException ite) {", " if (totalwait >= timeout) {", " destroy = true;", " break;", " } else {", " totalwait += 1000;", " Thread.sleep(1000);", " }", " }", " }", " \t}", " exitCode = javaProcess.waitFor();" ], "header": "@@ -126,15 +126,47 @@ public final class SpawnedProcess {", "removed": [ " * @param destroy True to destroy it, false to wait for it to complete.", " public int complete(boolean destroy) throws InterruptedException, IOException {", " int exitCode = javaProcess.waitFor();" ] } ] } ]
derby-DERBY-4319-23a45382
DERBY-4319 hang in suites.all with ibm 1.5 on AIX after ttestDefaultProperties disable for now ttestDefaultProperties and ttestSetPortPriority on AIX IBM 1.5, which can make the test fail. This does not fix the issue. Also add BaseTestCase.isPlatform(String) method and OsName class to faciltate platform exclusions from test runs. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1081494 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/testing/org/apache/derbyTesting/junit/OsName.java", "hunks": [ { "added": [ "/*", " *", " * Derby - Class org.apache.derbyTesting.junit.OsName", " *", " * Licensed to the Apache Software Foundation (ASF) under one or more", " * contributor license agreements. See the NOTICE file distributed with", " * this work for additional information regarding copyright ownership.", " * The ASF licenses this file to You under the Apache License, Version 2.0", " * (the \"License\"); you may not use this file except in compliance with", " * the License. You may obtain a copy of the License at", " *", " * http://www.apache.org/licenses/LICENSE-2.0", " *", " * Unless required by applicable law or agreed to in writing, ", " * software distributed under the License is distributed on an ", " * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, ", " * either express or implied. See the License for the specific ", " * language governing permissions and limitations under the License.", " */", "", "package org.apache.derbyTesting.junit;", "", "/**", " * OsName is used to store constants for the System Property os.name ", " * that can be passed to the BaseTestCase.isPlatform(String) method.", " * Started this class with a few known values.", " * TODO: Expand for all known os.names for platforms running Derby tests", " *", " */", "public class OsName {", "", " ", " public static final String LINUX = \"Linux\";", " public static final String MACOS = \"Mac OS\";", " public static final String MACOSX = \"Mac OS X\";", " public static final String AIX = \"AIX\";", " public static final String OS400 = \"OS/400\";", " public static final String ZOS = \"z/OS\";", " public static final String WINDOWSXP = \"Windows XP\";", " ", " ", "}" ], "header": "@@ -0,0 +1,42 @@", "removed": [] } ] } ]
derby-DERBY-4322-cdf28110
DERBY-4322 intermittent failure in runtimeinfo. Contributed by Myrna van Lunteren. The theory is that this failure is caused by a problem in the previous test DerbyNetAutostart which launches a process to start the server and can be left pinging if the check for the server in the launching process, does not allow enough time for the server to come up. The pings increment the session number as seen by runtimeinfo. So the changes are to DerbyNetAutoStart and are to 1) Make sure the server launching process retries enough times for the launched process comes up. 2) Make sure if something does go wrong, the launched process is destroyed git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@925377 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4323-d34116da
DERBY-4323: test failure in lang.ErrorMessageTest with IBM iseries IBM 1.5 Make the two threads that race for locks do as little as possible in order to reduce the risk of missing the two-second window for constructing the deadlock. That is, move query compilation and thread startup out so that the participating threads only perform query execution. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1402043 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/testing/org/apache/derbyTesting/functionTests/util/Barrier.java", "hunks": [ { "added": [ "/*", " * Derby - Class org.apache.derbyTesting.functionTests.util.Barrier", " *", " * Licensed to the Apache Software Foundation (ASF) under one or more", " * contributor license agreements. See the NOTICE file distributed with", " * this work for additional information regarding copyright ownership.", " * The ASF licenses this file to You under the Apache License, Version 2.0", " * (the \"License\"); you may not use this file except in compliance with", " * the License. You may obtain a copy of the License at", " *", " * http://www.apache.org/licenses/LICENSE-2.0", " *", " * Unless required by applicable law or agreed to in writing,", " * software distributed under the License is distributed on an", " * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,", " * either express or implied. See the License for the specific", " * language governing permissions and limitations under the License.", " */", "", "package org.apache.derbyTesting.functionTests.util;", "", "import junit.framework.Assert;", "", "/**", " * In the absence of java.util.concurrent.CyclicBarrier on some of the", " * platforms we test, create our own barrier class. This class allows", " * threads to wait for one another on specific locations, so that they", " * know they're all in the expected state.", " */", "public class Barrier {", " /** Number of threads to wait for at the barrier. */", " private int numThreads;", "", " /** Create a barrier for the specified number of threads. */", " public Barrier(int numThreads) {", " this.numThreads = numThreads;", " }", "", " /**", " * Wait until {@code numThreads} have called {@code await()} on this", " * barrier, then proceed.", " *", " * @throws InterruptedException if the thread is interrupted while", " * waiting for the other threads to reach the barrier.", " */", " public synchronized void await() throws InterruptedException {", " Assert.assertTrue(", " \"Too many threads reached the barrier\", numThreads > 0);", "", " if (--numThreads <= 0) {", " // All threads have reached the barrier. Go ahead!", " notifyAll();", " }", "", " // Some threads haven't reached the barrier yet. Let's wait.", " while (numThreads > 0) {", " wait();", " }", " }", "}" ], "header": "@@ -0,0 +1,60 @@", "removed": [] } ] } ]
derby-DERBY-4326-c275ab3e
DERBY-4326 Rather than quiting out of ClientThread for InterruptedException and IOException, we should first check if the exceptions aree raised because of server being shutdown. If yes, then we should quit out of ClientThread. Otherwise, we should log the exception and close the client socket that got the exception and go back to the infinite loop waiting for next client connection. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@823659 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/ClientThread.java", "hunks": [ { "added": [ " if (parent.getShutdown()) {", " // This is a shutdown and we'll just exit the", " // thread. NOTE: This is according to the logic", " // before this rewrite. I am not convinced that it", " // is allways the case, but will not alter the", " // behaviour since it is not within the scope of", " // this change (DERBY-2108).", " \tclientSocket.close();", " \t return;", " }", " parent.consoleExceptionPrintTrace(ie);", " if (clientSocket != null)", " clientSocket.close();" ], "header": "@@ -92,13 +92,19 @@ final class ClientThread extends Thread {", "removed": [ " // This is a shutdown and we'll just exit the", " // thread. NOTE: This is according to the logic", " // before this rewrite. I am not convinced that it", " // is allways the case, but will not alter the", " // behaviour since it is not within the scope of", " // this change (DERBY-2108).", " return;" ] }, { "added": [ " if (clientSocket != null)", " clientSocket.close();", " if (parent.getShutdown()) {", " return; // Exit the thread", " } ", " parent.consoleExceptionPrintTrace(ioe);" ], "header": "@@ -115,17 +121,17 @@ final class ClientThread extends Thread {", "removed": [ " if (!parent.getShutdown()) {", " parent.consoleExceptionPrintTrace(ioe);", " if (clientSocket != null)", " clientSocket.close();", " }", " return; // Exit the thread" ] } ] } ]
derby-DERBY-4330-0a6a8464
DERBY-4330 NullPointerException or assert failure when re-executing PreparedStatement after lock timeout Patch derby-4330c fixes this issue. The problem is that when a timeout happens (or a deadlock), the result set tree for prepared statements for some queries is partically in a closed, partially in an open state. (The issue was reported for a join query, but exists for others queries as well). This causes problems when the result set tree is being reused, i.e. when the prpared statement is attempted re-executed after the timeout, since the tree is expected to be fully closed at that time, cuasing the assert or NPE. The fix ensures that the tree is left in a fully closed state in such cases. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@804271 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4331-397f968f
DERBY-4331 Fixes a number of sort avoidance bugs that were introduced by the fix for DERBY-3926. This check in backs out the equi-join part of the DERBY-3926. The changes for this were isolated and were the only changes to FromBaseTable.java. Backing out only this part of the 3926 checkin fixes new problems identified in DERBY-4331, and continues to fix the problem queries in DERBY-3926. Knowledge of equijoin is no longer used as a factor for sort avoidance. Also included is an update to the wisconsin tests. A number of diffs resulted from different join order to maintain a sort avoidance plan. 2 queries identified in DERBY-4339 no longer use sort avoidance. The new test cases were reported as part of 4331 were added to the OrderByAndSortAvoidance test. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@801481 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java", "hunks": [ { "added": [], "header": "@@ -462,13 +462,6 @@ public class FromBaseTable extends FromTable", "removed": [ "\t\t\t\t\t//Check if the order by column has equijoin on another ", "\t\t\t\t\t//column which is already identified as an ordered column", "\t\t\t\t\tif (doesOrderByColumnHaveEquiJoin(", "\t\t\t\t\t\t\tirg, predList, rowOrdering))", "\t\t\t\t\t\trowOrdering.columnAlwaysOrdered(this, ", "\t\t\t\t\t\t\t\tbaseColumnPositions[i]);", "" ] } ] } ]
derby-DERBY-4336-adf7016c
DERBY-4336: Remove Blob and Clob interface methods from the list of unsupported methods in UnsupportedVetter. Removed now implemented methods in the Blob/Clob JDBC interface from the list of unsupported methods in jdbc4.UnsupportedVetter. Also removed the update[BC]lob-methods in the ResultSet interface. Patch file: derby-4336-1a.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@800799 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4338-3392df81
DERBY-4338 Network client raises error "executeQuery method can not be used for update" when sql is preceded by /* */ comments This patch, derby-4338-d, fixes the seen bug, and also generalizes the method used by the client driver to find the first significant (non-comment) SQL statement identifier, i.e. a keyword. This is needed by the client's statement classification logic. For certain input strings the old method also gave wrong results, cf. the new test cases added. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@809643 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/client/org/apache/derby/client/am/Statement.java", "hunks": [ { "added": [ " sqlUpdateMode_ = 0;", " // See if the statement starts with one or more comments; if so, move", " // past the comments and get the first token of the actual statement to", " // be executed.", " String firstToken = getStatementToken(sql);", " if (firstToken == null) {", " // entire statement was just one or more comments; pass it as a", " // query to the server and let the server deal with it.", " sqlMode_ = isQuery__;", " return;" ], "header": "@@ -2319,59 +2319,21 @@ public class Statement implements java.sql.Statement, StatementCallbackInterface", "removed": [ " String delims = \"\\t\\n\\r\\f=? (\";", " java.util.StringTokenizer tokenizer = null;", " String firstToken = null;", "", " // See if the statement starts with a comment; if so, move", " // past the comment and get the first token of the actual", " // statement to be executed. Note: must use \"startsWith\"", " // when looking for the comment delimiters instead of", " // \"equals\" because there may not be whitespace between the", " // the delimiter and the comment itself, ex \"--my comment\".", " if (sql.trim().startsWith(\"--\")) {", "", " // Read each line of the statement until we find a", " // line that is NOT a comment.", " int lastEndLine = -1;", " String endline = \"\\n\\r\\f\";", " tokenizer = new java.util.StringTokenizer(sql, endline, true);", " while (tokenizer.hasMoreTokens()) {", " firstToken = tokenizer.nextToken();", " if (endline.indexOf(firstToken) != -1)", " // this is some sort of newline (\"\\n\", \"\\r\", or \"\\f\").", " lastEndLine = sql.indexOf(firstToken, lastEndLine+1);", " else if (!firstToken.trim().startsWith(\"--\"))", " break;", " }", " if (firstToken.startsWith(\"--\")) {", " // entire statement was just one or more comments; pass it as", " // a query to the server and let the server deal with it.", " sqlMode_ = isQuery__;", " return;", " }", " else {", " // we have a non-comment line; get a tokenizer for the", " // statement beginning at the start of this line.", " tokenizer = new java.util.StringTokenizer(", " sql.substring(lastEndLine+1), delims);", " }", " }", " else {", " // there aren't any leading comments, so just get the first token", " // in the SQL statement.", " tokenizer = new java.util.StringTokenizer(sql, delims);", " }", " if (!tokenizer.hasMoreTokens()) {", " throw new SqlException(agent_.logWriter_, ", " new ClientMessageId(SQLState.NO_TOKENS_IN_SQL_TEXT), sql);", " sqlUpdateMode_ = 0;", " firstToken = tokenizer.nextToken();" ] } ] } ]
derby-DERBY-4339-397f968f
DERBY-4331 Fixes a number of sort avoidance bugs that were introduced by the fix for DERBY-3926. This check in backs out the equi-join part of the DERBY-3926. The changes for this were isolated and were the only changes to FromBaseTable.java. Backing out only this part of the 3926 checkin fixes new problems identified in DERBY-4331, and continues to fix the problem queries in DERBY-3926. Knowledge of equijoin is no longer used as a factor for sort avoidance. Also included is an update to the wisconsin tests. A number of diffs resulted from different join order to maintain a sort avoidance plan. 2 queries identified in DERBY-4339 no longer use sort avoidance. The new test cases were reported as part of 4331 were added to the OrderByAndSortAvoidance test. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@801481 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java", "hunks": [ { "added": [], "header": "@@ -462,13 +462,6 @@ public class FromBaseTable extends FromTable", "removed": [ "\t\t\t\t\t//Check if the order by column has equijoin on another ", "\t\t\t\t\t//column which is already identified as an ordered column", "\t\t\t\t\tif (doesOrderByColumnHaveEquiJoin(", "\t\t\t\t\t\t\tirg, predList, rowOrdering))", "\t\t\t\t\t\trowOrdering.columnAlwaysOrdered(this, ", "\t\t\t\t\t\t\t\tbaseColumnPositions[i]);", "" ] } ] } ]
derby-DERBY-4342-7017a351
DERBY-4342: SQLSTATE 38000 (NullPointerException) at inner self join and value(x1, x2...) Override ValueNode.remapColumnReferencesToExpressions() in CoalesceFunctionNode so that its arguments are properly remapped. The lack of remapping made the generated code access the wrong result set, eventually causing the NullPointerException. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@819006 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4343-baab96fc
DERBY-4343 ASSERT FAILED calling setTransactionIsolation checking isolation_ == level on pooled connection Contributed by Lily Wei lilywei at yahoo dot com This is just the test case for this issue. The issue itself was actually fixed with DERBY-4314. Also included is one DERBY-4314 test case to make sure piggybacking works ok after statement execution. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@942908 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4347-86ce4291
DERBY-4347 ; Provide a property to increase network server start timeout for JUnit tests This introduces the optional property 'derby.tests.networkServerStartTimeout' which takes an int signifying the new wait time in seconds. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@814815 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java", "hunks": [ { "added": [ " /** Setting maximum wait time to 40 seconds by default. On some platforms", " * For even slower systems (or for faster systems) the default value can", " * be overwritten using the property derby.tests.networkServerStartTimeout", " * (which is in seconds, rather than milliseconds)", " private static final long DEFAULT_WAIT_TIME = 40000;", " private static final long WAIT_TIME = getWaitTime();" ], "header": "@@ -41,13 +41,17 @@ import org.apache.derby.drda.NetworkServerControl;", "removed": [ " /** Setting maximum wait time to 40 seconds. On some platforms", " private static final long WAIT_TIME = 40000;" ] }, { "added": [ " ", " /*", " * set the period before network server times out on start up based on the", " * value passed in with property derby.tests.networkServerStartTimeout", " * in seconds, or use the default", " * for example: with DEFAULT_WAIT_TIME set to 40000, i.e. 40 seconds,", " * setting the property like so: ", " * -Dderby.tests.networkServerStartTimeout=60", " * would extend the timeout to 1 minute.", " * If an invalid value is passed in (eg. 'abc') the calling test will fail", " */", " public static long getWaitTime() {", " long waitTime = DEFAULT_WAIT_TIME;", " String waitString = BaseTestCase.getSystemProperty(", " \"derby.tests.networkServerStartTimeout\");", " if (waitString != null && waitString.length() != 0)", " {", " try {", " waitTime = (Long.parseLong(waitString)*1000);", " } catch (Exception e) {", " e.printStackTrace();", " fail(\"trouble setting WAIT_TIME from passed in property \" +", " \"derby.tests.networkServerStartTimeout\");", " }", " }", " return waitTime;", " }", "" ], "header": "@@ -629,4 +633,32 @@ final public class NetworkServerTestSetup extends BaseTestSetup {", "removed": [] } ] } ]
derby-DERBY-4348-0b97566f
DERBY-4348: Copy table content with "INSERT INTO table SELECT FROM (...)" statement leads to corrupt data NormalizeResultSet can in some cases replace a holder object in its DataValueDescriptor cache with a holder object that's also used in BulkTableScanResultSet's cache, and thereby corrupting BulkTableScanResultSet's fetch buffer when the holder object is modified. This patch makes NormalizeResultSet store the cached holder objects in a separate data structure to prevent them from being replaced. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@808850 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java", "hunks": [ { "added": [ " } else {", " SanityManager.THROWASSERT(\"cachedDest is null\");", " }" ], "header": "@@ -627,7 +627,9 @@ public final class DataTypeDescriptor implements Formatable", "removed": [ "\t\t\t}" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java", "hunks": [ { "added": [ " /**", " * This array contains data value descriptors that can be used (and reused)", " * by normalizeRow() to hold the normalized column values.", " */", " private final DataValueDescriptor[] cachedDestinations;", "" ], "header": "@@ -52,6 +52,12 @@ class NormalizeResultSet extends NoPutResultSetImpl", "removed": [] }, { "added": [ " cachedDestinations = new DataValueDescriptor[numCols];" ], "header": "@@ -107,6 +113,7 @@ class NormalizeResultSet extends NoPutResultSetImpl", "removed": [] }, { "added": [], "header": "@@ -350,10 +357,6 @@ class NormalizeResultSet extends NoPutResultSetImpl", "removed": [ "\t\tint\t\t\t\t\twhichCol;", "", "\t\tif (desiredTypes == null) { desiredTypes = fetchResultTypes( resultDescription ); }", "" ] }, { "added": [ " normalizedCol = normalizeColumn(", " getDesiredType(i), sourceRow, i,", " getCachedDestination(i), resultDescription);" ], "header": "@@ -367,8 +370,9 @@ class NormalizeResultSet extends NoPutResultSetImpl", "removed": [ " normalizedCol = normalizeColumn", " ( desiredTypes[i - 1], sourceRow, i, normalizedRow.getColumn(i), resultDescription );" ] } ] } ]
derby-DERBY-4356-bdbc3cb2
DERBY-4356: Better insulate ManagementMBeanTest from environment left over from previous JUnit tests. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@807685 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4357-38a34c2c
DERBY-4357: A couple more tests for restricted vtis. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@832423 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4357-86f2ca10
DERBY-4357: Add public api for restricted table functions. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@829078 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/vti/Restriction.java", "hunks": [ { "added": [ "/*", "", " Derby - Class org.apache.derby.vti.Restriction", "", " Licensed to the Apache Software Foundation (ASF) under one or more", " contributor license agreements. See the NOTICE file distributed with", " this work for additional information regarding copyright ownership.", " The ASF licenses this file to You under the Apache License, Version 2.0", " (the \"License\"); you may not use this file except in compliance with", " the License. You may obtain a copy of the License at", "", " http://www.apache.org/licenses/LICENSE-2.0", "", " Unless required by applicable law or agreed to in writing, software", " distributed under the License is distributed on an \"AS IS\" BASIS,", " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", " See the License for the specific language governing permissions and", " limitations under the License.", "", " */", "package org.apache.derby.vti;", "", "import java.sql.SQLException;", "", "/**", " <p>", " * An expression to be pushed into a Table Function so that the Table Function", " * can short-circuit its processing and return fewer rows. A restriction is represented", " * as a binary tree. The non-leaf nodes are ANDs and ORs. The leaf nodes", " * are ColumnQualifiers. A ColumnQualifier", " * is a simple expression comparing a constant value to a column in", " * the Table Function.", " * </p>", " */", "public abstract class Restriction", "{", " /** An AND of two Restrictions */", " public static class AND extends Restriction", " {", " private Restriction _leftChild;", " private Restriction _rightChild;", "", " /** AND together two other Restrictions */", " public AND( Restriction leftChild, Restriction rightChild )", " {", " _leftChild = leftChild;", " _rightChild = rightChild;", " }", "", " /** Get the left Restriction */", " public Restriction getLeftChild() { return _leftChild; }", "", " /** Get the right Restriction */", " public Restriction getRightChild() { return _rightChild; }", " }", "", " /** An OR of two Restrictions */", " public static class OR extends Restriction", " {", " private Restriction _leftChild;", " private Restriction _rightChild;", "", " /** OR together two other Restrictions */", " public OR( Restriction leftChild, Restriction rightChild )", " {", " _leftChild = leftChild;", " _rightChild = rightChild;", " }", "", " /** Get the left Restriction */", " public Restriction getLeftChild() { return _leftChild; }", "", " /** Get the right Restriction */", " public Restriction getRightChild() { return _rightChild; }", " }", "", " /**", " <p>", " * A simple comparison of a column to a constant value. The comparison", " * has the form:", " * </p>", " *", " * <blockquote><pre>", " * column OP constant", " * </pre></blockquote>", " *", " * <p>", " * where OP is one of the following:", " * </p>", " *", " * <blockquote><pre>", " * < = <= > >=", " * </pre></blockquote>", " */", " public static class ColumnQualifier extends Restriction", " {", " ////////////////////////////////////////////////////////////////////////////////////////", " //", " // CONSTANTS", " //", " ////////////////////////////////////////////////////////////////////////////////////////", " ", " /**\t Ordering operation constant representing '<' **/", " public static final int ORDER_OP_LESSTHAN = 1;", "", " /**\t Ordering operation constant representing '=' **/", " public static final int ORDER_OP_EQUALS = 2;", "", " /**\t Ordering operation constant representing '<=' **/", " public static final int ORDER_OP_LESSOREQUALS = 3;", "", " /**\t Ordering operation constant representing '>' **/", " public static final int ORDER_OP_GREATERTHAN = 4;", "", " /**\t Ordering operation constant representing '>=' **/", " public static final int ORDER_OP_GREATEROREQUALS = 5;", "", " ////////////////////////////////////////////////////////////////////////////////////////", " //", " // STATE", " //", " ////////////////////////////////////////////////////////////////////////////////////////", "", " /** name of column being restricted */", " private String _columnName;", "", " /** comparison operator, one of the ORDER_OP constants */", " private int _comparisonOperator;", "", " /** null handling */", " private boolean _nullEqualsNull;", "", " /** value to compare the column to */", " private Object _constantOperand;", " ", " ////////////////////////////////////////////////////////////////////////////////////////", " //", " // CONSTRUCTORS", " //", " ////////////////////////////////////////////////////////////////////////////////////////", "", " /**", " * <p>", " * Construct from pieces.", " * </p>", " *", " * @param columnName Name of column as declared in the CREATE FUNCTION statement.", " * @param comparisonOperator One of the ORDER_OP constants.", " * @param nullEqualsNull True if NULLS should be treated like ordinary values which sort before all other values. Used to encode IS NULL comparisons.", " * @param constantOperand Constant value to which the column should be compared.", " */", " public ColumnQualifier", " (", " String columnName,", " int comparisonOperator,", " boolean nullEqualsNull,", " Object constantOperand", " )", " {", " _columnName = columnName;", " _comparisonOperator = comparisonOperator;", " _nullEqualsNull = nullEqualsNull;", " _constantOperand = constantOperand;", " }", " ", " ////////////////////////////////////////////////////////////////////////////////////////", " //", " // ACCESSORS", " //", " ////////////////////////////////////////////////////////////////////////////////////////", " ", " /**", " * <p>", " * The name of the column being compared.", " * </p>", " */", " public String getColumnName() { return _columnName; }", "", " /**", " * <p>", " * The type of comparison to perform. This is one of the ORDER_OP constants", " * defined above.", " * </p>", " */", " public int getComparisonOperator() { return _comparisonOperator; }", "", " /**", " * <p>", " * Specifies how nulls behave in comparisons. If true, then nulls are", " * treated as values which sort before all other values; and the = comparison", " * between two nulls evaluates to TRUE. If this method returns false, then", " * any comparison involving a null evaluates to UNKNOWN. This is useful", " * for encoding IS NULL comparisons.", " * </p>", " */", " public boolean nullEqualsNull() { return _nullEqualsNull; }", "", " /**", " * <p>", " * Get the constant value to which the column should be compared. The", " * constant value must be an Object of the Java type which corresponds to", " * the SQL type of the column. The column's SQL type was declared in the CREATE FUNCTION statement.", " * The mapping of SQL types to Java types is defined in table 4 of chapter 14", " * of the original JDBC 1 specification (dated 1996). Bascially, these are the Java", " * wrapper values you would expect. For instance, SQL INT maps to java.lang.Integer, SQL CHAR", " * maps to java.lang.String, etc..", " * </p>", " */", " public Object getConstantOperand() { return _constantOperand; }", " }", " ", "}", "" ], "header": "@@ -0,0 +1,213 @@", "removed": [] } ] } ]
derby-DERBY-4357-a2d08471
DERBY-4357: Pass projections and restrictions through to RestrictedVTIs. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@831072 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java", "hunks": [ { "added": [ "\t\t@param erdNumber\t\tint for referenced column BitSet (so it can be turned back into an object)", "\t\t@param optimizerEstimatedRowCount\tEstimated total # of rows by optimizer", "\t\t@param returnTypeNumber\tWhich saved object contains the return type (a multi-set) serialized as a byte array", "\t\t@param vtiProjectionNumber\tWhich saved object contains the projection for a RestrictedVTI", "\t\t@param vtiRestrictionNumber\tWhich saved object contains the restriction for a RestrictedVTI" ], "header": "@@ -644,16 +644,15 @@ public interface ResultSetFactory {", "removed": [ "\t\t@param erdNumber\t\tint for referenced column BitSet ", "\t\t\t\t\t\t\t\t(so it can be turned back into an object)", "\t\t@param optimizerEstimatedRowCount\tEstimated total # of rows by", "\t\t\t\t\t\t\t\t\t\t\toptimizer", "\t\t@param returnTypeNumber\tWhich saved object contains the return type", "\t\t\t\t\t\t\t\t(a multi-set) serialized as a byte array" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/FromVTI.java", "hunks": [ { "added": [ "import org.apache.derby.vti.RestrictedVTI;", "import org.apache.derby.vti.Restriction;" ], "header": "@@ -63,6 +63,8 @@ import org.apache.derby.catalog.UUID;", "removed": [] }, { "added": [ "import java.lang.reflect.Method;" ], "header": "@@ -76,6 +78,7 @@ import org.apache.derby.iapi.sql.execute.ExecutionContext;", "removed": [] }, { "added": [ "import java.util.HashMap;", "import java.util.HashSet;" ], "header": "@@ -85,6 +88,8 @@ import java.sql.SQLException;", "removed": [] }, { "added": [ "\tboolean\t\t\t\tisRestrictedTableFunction;" ], "header": "@@ -108,6 +113,7 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [] }, { "added": [ " private String[] projectedColumnNames; // for RestrictedVTIs", " private Restriction vtiRestriction; // for RestrictedVTIs", "" ], "header": "@@ -150,6 +156,9 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [] }, { "added": [ "" ], "header": "@@ -480,6 +489,7 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [] }, { "added": [ "", " if ( isDerbyStyleTableFunction )", " {", " Method boundMethod = (Method) methodCall.getResolvedMethod();", "", " isRestrictedTableFunction = RestrictedVTI.class.isAssignableFrom( boundMethod.getReturnType() );", " }", "" ], "header": "@@ -554,7 +564,14 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [ " " ] }, { "added": [ " /**", " * Compute the projection and restriction to be pushed to the external", " * table function if it is a RestrictedVTI. This method is called by the", " * parent ProjectRestrictNode at code generation time. See DERBY-4357.", " *", " * @param parentProjection The column list which the parent ProjectRestrictNode expects to return.", " * @param parentPredicates The full list of predicates to be applied by the parent ProjectRestrictNode", " */", " void computeProjectionAndRestriction( ResultColumnList parentProjection, PredicateList parentPredicates )", " throws StandardException", " {", " // nothing to do if this is a not a restricted table function", " if ( !isRestrictedTableFunction ) { return; }", "", " computeRestriction( parentPredicates, computeProjection( parentProjection ) );", " }", " /**", " * Fills in the array of projected column names suitable for handing to", " * RestrictedVTI.initScan(). Returns a mapping of the exposed column names", " * to the actual names of columns in the table function. This is useful", " * because the predicate refers to the exposed column names.", " *", " * @param parentProjection The column list which the parent ProjectRestrictNode expects to return.", " */", " private HashMap computeProjection( ResultColumnList parentProjection ) throws StandardException", " {", " HashSet projectedColumns = new HashSet();", " HashMap nameMap = new HashMap();", " String[] exposedNames = parentProjection.getColumnNames();", " int projectedCount = exposedNames.length;", "", " for ( int i = 0; i < projectedCount; i++ ) { projectedColumns.add( exposedNames[ i ] ); }", "", " ResultColumnList allVTIColumns = getResultColumns();", " int totalColumnCount = allVTIColumns.size();", "", " projectedColumnNames = new String[ totalColumnCount ];", "", " for ( int i = 0; i < totalColumnCount; i++ )", " {", " ResultColumn column = allVTIColumns.getResultColumn( i + 1 );", " String exposedName = column.getName();", "", " if ( projectedColumns.contains( exposedName ) )", " {", " String baseName = column.getBaseColumnNode().getColumnName();", " ", " projectedColumnNames[ i ] = baseName;", "", " nameMap.put( exposedName, baseName );", " }", " }", "", " return nameMap;", " }", " /**", " * Fills in the restriction to be handed to a RestrictedVTI at run-time.", " *", " * @param parentPredicates The full list of predicates to be applied by the parent ProjectRestrictNode", " * @param columnNameMap Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.", " */", " private void computeRestriction( PredicateList parentPredicates, HashMap columnNameMap )", " throws StandardException", " {", " if ( parentPredicates == null ) { return; }", "", " int predicateCount = parentPredicates.size();", "", " // walk the list, looking for qualifiers, that is, WHERE clause", " // fragments (conjuncts) which can be pushed into the table function", " for ( int i = 0; i < predicateCount; i++ )", " {", " Predicate predicate = (Predicate) parentPredicates.elementAt( i );", "", " if ( predicate.isQualifier() )", " {", " // A Predicate has a top level AND node", " Restriction newRestriction = makeRestriction( predicate.getAndNode(), columnNameMap );", "", " // If newRestriction is null, then we are confused. Don't push", " // the restriction into the table function", " if ( newRestriction == null )", " {", " vtiRestriction = null;", " return;", " }", "", " // If we get here, then we still understand the restriction", " // we're compiling.", "", " if ( vtiRestriction == null ) { vtiRestriction = newRestriction; }", " else { vtiRestriction = new Restriction.AND( vtiRestriction, newRestriction ); }", " }", " }", " }", " /**", " * Turn a compile-time WHERE clause fragment into a run-time", " * Restriction. Returns null if the clause could not be understood.", " *", " * @param clause The clause which should be turned into a Restriction.", " * @param columnNameMap Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.", " */", " private Restriction makeRestriction( ValueNode clause, HashMap columnNameMap )", " throws StandardException", " {", " if ( clause instanceof AndNode )", " {", " AndNode andOperator = (AndNode) clause;", "", " // strip off trailing vacuous constant if present", " if ( andOperator.getRightOperand() instanceof BooleanConstantNode )", " { return makeRestriction( andOperator.getLeftOperand(), columnNameMap ); }", " ", " Restriction leftRestriction = makeRestriction( andOperator.getLeftOperand(), columnNameMap );", " Restriction rightRestriction = makeRestriction( andOperator.getRightOperand(), columnNameMap );", "", " if ( (leftRestriction == null) || (rightRestriction == null) ) { return null; }", "", " return new Restriction.AND( leftRestriction, rightRestriction );", " }", " else if ( clause instanceof OrNode )", " {", " OrNode orOperator = (OrNode) clause;", " ", " // strip off trailing vacuous constant if present", " if ( orOperator.getRightOperand() instanceof BooleanConstantNode )", " { return makeRestriction( orOperator.getLeftOperand(), columnNameMap ); }", " ", " Restriction leftRestriction = makeRestriction( orOperator.getLeftOperand(), columnNameMap );", " Restriction rightRestriction = makeRestriction( orOperator.getRightOperand(), columnNameMap );", "", " if ( (leftRestriction == null) || (rightRestriction == null) ) { return null; }", "", " return new Restriction.OR( leftRestriction, rightRestriction );", " }", " else if ( clause instanceof BinaryRelationalOperatorNode )", " { return makeLeafRestriction( (BinaryRelationalOperatorNode) clause, columnNameMap ); }", " else if ( clause instanceof IsNullNode )", " { return makeIsNullRestriction( (IsNullNode) clause, columnNameMap ); }", " else { return iAmConfused( clause ); }", " }", " /**", " * Makes a Restriction out of a comparison between a constant and a column", " * in the VTI.", " *", " * @param clause The clause which should be turned into a Restriction.", " * @param columnNameMap Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.", " */", " private Restriction makeLeafRestriction( BinaryRelationalOperatorNode clause, HashMap columnNameMap )", " throws StandardException", " {", " int rawOperator = clause.getOperator();", " ColumnReference rawColumn;", " ValueNode rawValue;", "", " if ( clause.getLeftOperand() instanceof ColumnReference )", " {", " rawColumn = (ColumnReference) clause.getLeftOperand();", " rawValue = clause.getRightOperand();", " }", " else if ( clause.getRightOperand() instanceof ColumnReference )", " {", " rawColumn = (ColumnReference) clause.getRightOperand();", " rawValue = clause.getLeftOperand();", " rawOperator = flipOperator( rawOperator );", " }", " else { return iAmConfused( clause ); }", "", " int comparisonOperator = mapOperator( rawOperator );", " if ( comparisonOperator < 0 ) { return iAmConfused( clause ); }", "", " String columnName = (String) columnNameMap.get( rawColumn.getColumnName() );", " Object constantOperand = squeezeConstantValue( rawValue );", " if ( (columnName == null) || (constantOperand == null) ) { return iAmConfused( clause ); }", "", " return new Restriction.ColumnQualifier( columnName, comparisonOperator, constantOperand );", " }", " /**", " * Makes an IS NULL comparison of a column", " * in the VTI.", " *", " * @param clause The IS NULL (or IS NOT NULL) node", " * @param columnNameMap Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.", " */", " private Restriction makeIsNullRestriction( IsNullNode clause, HashMap columnNameMap )", " throws StandardException", " {", " ColumnReference rawColumn = (ColumnReference) clause.getOperand();", "", " int comparisonOperator = mapOperator( clause.getOperator() );", " if ( comparisonOperator < 0 ) { return iAmConfused( clause ); }", " if (", " (comparisonOperator != Restriction.ColumnQualifier.ORDER_OP_ISNULL) &&", " (comparisonOperator != Restriction.ColumnQualifier.ORDER_OP_ISNOTNULL)", " ) { return iAmConfused( clause ); }", "", " String columnName = (String) columnNameMap.get( rawColumn.getColumnName() );", " if ( columnName == null ) { return iAmConfused( clause ); }", "", " return new Restriction.ColumnQualifier( columnName, comparisonOperator, null );", " }", " /** This is a handy place to put instrumentation for tracing trees which we don't understand */", " private Restriction iAmConfused( ValueNode clause ) throws StandardException", " {", " return null;", " }", " /** Flip the sense of a comparison */", " private int flipOperator( int rawOperator ) throws StandardException", " {", " switch( rawOperator )", " {", " case RelationalOperator.EQUALS_RELOP: return RelationalOperator.EQUALS_RELOP;", " case RelationalOperator.GREATER_EQUALS_RELOP: return RelationalOperator.LESS_EQUALS_RELOP;", " case RelationalOperator.GREATER_THAN_RELOP: return RelationalOperator.LESS_THAN_RELOP;", " case RelationalOperator.LESS_EQUALS_RELOP: return RelationalOperator.GREATER_EQUALS_RELOP;", " case RelationalOperator.LESS_THAN_RELOP: return RelationalOperator.GREATER_THAN_RELOP;", " case RelationalOperator.NOT_EQUALS_RELOP: return RelationalOperator.NOT_EQUALS_RELOP;", "", " case RelationalOperator.IS_NOT_NULL_RELOP:", " case RelationalOperator.IS_NULL_RELOP:", " default:", " if ( SanityManager.DEBUG )", " {", " SanityManager.THROWASSERT( \"Unrecognized relational operator: \" + rawOperator );", " }", " }", "", " return -1;", " }", " /** Map internal operator constants to user-visible ones */", " private int mapOperator( int rawOperator ) throws StandardException", " {", " switch( rawOperator )", " {", " case RelationalOperator.EQUALS_RELOP: return Restriction.ColumnQualifier.ORDER_OP_EQUALS;", " case RelationalOperator.GREATER_EQUALS_RELOP: return Restriction.ColumnQualifier.ORDER_OP_GREATEROREQUALS;", " case RelationalOperator.GREATER_THAN_RELOP: return Restriction.ColumnQualifier.ORDER_OP_GREATERTHAN;", " case RelationalOperator.LESS_EQUALS_RELOP: return Restriction.ColumnQualifier.ORDER_OP_LESSOREQUALS;", " case RelationalOperator.LESS_THAN_RELOP: return Restriction.ColumnQualifier.ORDER_OP_LESSTHAN;", " case RelationalOperator.IS_NULL_RELOP: return Restriction.ColumnQualifier.ORDER_OP_ISNULL;", " case RelationalOperator.IS_NOT_NULL_RELOP: return Restriction.ColumnQualifier.ORDER_OP_ISNOTNULL;", "", " case RelationalOperator.NOT_EQUALS_RELOP:", " default:", " if ( SanityManager.DEBUG )", " {", " SanityManager.THROWASSERT( \"Unrecognized relational operator: \" + rawOperator );", " }", " }", "", " return -1;", " }", " /**", " * Get the constant or parameter reference out of a comparand. Return null", " * if we are confused. A parameter reference is wrapped in an integer array", " * to distinguish it from a constant integer.", " */", " private Object squeezeConstantValue( ValueNode valueNode ) throws StandardException", " {", " if ( valueNode instanceof ParameterNode )", " {", " return new int[] { ((ParameterNode) valueNode).getParameterNumber() };", " }", " else if ( valueNode instanceof ConstantNode )", " {", " return ((ConstantNode) valueNode).getValue().getObject();", " }", " else", " {", " return iAmConfused( valueNode );", " }", " }", " " ], "header": "@@ -1199,6 +1216,279 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java", "hunks": [ { "added": [ "import java.sql.ResultSet;" ], "header": "@@ -58,6 +58,7 @@ import org.apache.derby.catalog.types.RoutineAliasInfo;", "removed": [] }, { "added": [ " /**", " * @return get the Java method or constructor determined during the bind() phase.", " */", " public Member getResolvedMethod()", " {", " return method;", " }", "" ], "header": "@@ -140,6 +141,14 @@ abstract class MethodCallNode extends JavaValueNode", "removed": [] }, { "added": [ "\t\t\t\t requiredType = ResultSet.class.getName();" ], "header": "@@ -767,7 +776,7 @@ abstract class MethodCallNode extends JavaValueNode", "removed": [ "\t\t\t\t requiredType = \"java.sql.ResultSet\";" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java", "hunks": [ { "added": [ " int returnTypeNumber,", " int vtiProjectionNumber,", " int vtiRestrictionNumber" ], "header": "@@ -449,7 +449,9 @@ public class GenericResultSetFactory implements ResultSetFactory", "removed": [ " int returnTypeNumber" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.sql.ParameterValueSet; " ], "header": "@@ -38,6 +38,7 @@ import org.apache.derby.iapi.sql.execute.NoPutResultSet;", "removed": [] }, { "added": [ "import org.apache.derby.vti.RestrictedVTI;", "import org.apache.derby.vti.Restriction;" ], "header": "@@ -59,6 +60,8 @@ import org.apache.derby.iapi.services.io.FormatableHashtable;", "removed": [] }, { "added": [ " private String[] vtiProjection;", " private Restriction vtiRestriction;", "" ], "header": "@@ -102,6 +105,9 @@ class VTIResultSet extends NoPutResultSetImpl", "removed": [] }, { "added": [ " int returnTypeNumber,", " int vtiProjectionNumber,", " int vtiRestrictionNumber" ], "header": "@@ -123,7 +129,9 @@ class VTIResultSet extends NoPutResultSetImpl", "removed": [ " int returnTypeNumber" ] }, { "added": [ " this.vtiProjection = vtiProjectionNumber == -1 ? null :", " (String[])", " activation.getPreparedStatement().getSavedObject(vtiProjectionNumber);", "", " this.vtiRestriction = vtiRestrictionNumber == -1 ? null :", " (Restriction)", " activation.getPreparedStatement().getSavedObject(vtiRestrictionNumber);", "" ], "header": "@@ -143,6 +151,14 @@ class VTIResultSet extends NoPutResultSetImpl", "removed": [] }, { "added": [ "", " if ( userVTI instanceof RestrictedVTI )", " {", " RestrictedVTI restrictedVTI = (RestrictedVTI) userVTI;", "", " restrictedVTI.initScan( vtiProjection, cloneRestriction( activation ) );", " }" ], "header": "@@ -222,6 +238,13 @@ class VTIResultSet extends NoPutResultSetImpl", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/vti/Restriction.java", "hunks": [ { "added": [ "import java.io.Serializable;" ], "header": "@@ -20,6 +20,7 @@", "removed": [] }, { "added": [ "public abstract class Restriction implements Serializable", " /**", " * Turn this Restriction into a string suitable for use in a WHERE clause.", " */", " public abstract String toSQL();", "", " /** Utility method to double quote a string */", " protected String doubleQuote( String raw ) { return \"\\\"\" + raw + \"\\\"\"; }", "", " /** Utility method to parenthesize an expression */", " protected String parenthesize( String raw ) { return \"( \" + raw + \" )\"; }", " ", " /** Derby serializes these objects in PreparedStatements */", " public static final long serialVersionUID = -8205388794606605844L;", " " ], "header": "@@ -32,11 +33,25 @@ import java.sql.SQLException;", "removed": [ "public abstract class Restriction" ] }, { "added": [ " ", " public String toSQL()", " {", " return parenthesize( _leftChild.toSQL() ) + \" AND \" + parenthesize( _rightChild.toSQL() );", " }", " /** Derby serializes these objects in PreparedStatements */", " public static final long serialVersionUID = -8205388794606605844L;", " " ], "header": "@@ -52,11 +67,19 @@ public abstract class Restriction", "removed": [] }, { "added": [ "", " public String toSQL()", " {", " return parenthesize( _leftChild.toSQL() ) + \" OR \" + parenthesize( _rightChild.toSQL() );", " }" ], "header": "@@ -72,6 +95,11 @@ public abstract class Restriction", "removed": [] }, { "added": [ " * < = <= > >= IS NULL IS NOT NULL" ], "header": "@@ -89,7 +117,7 @@ public abstract class Restriction", "removed": [ " * < = <= > >=" ] }, { "added": [ "", " /** Derby serializes these objects in PreparedStatements */", " public static final long serialVersionUID = -8205388794606605844L;", " public static final int ORDER_OP_LESSTHAN = 0;", " public static final int ORDER_OP_EQUALS = 1;", " public static final int ORDER_OP_LESSOREQUALS = 2;", " public static final int ORDER_OP_GREATERTHAN = 3;", " public static final int ORDER_OP_GREATEROREQUALS = 4;", "", " /**\t Ordering operation constant representing 'IS NULL' **/", " public static final int ORDER_OP_ISNULL = 5;", "", " /**\t Ordering operation constant representing 'IS NOT NULL' **/", " public static final int ORDER_OP_ISNOTNULL = 6;", "", " // Visible forms of the constants above", " private String[] OPERATOR_SYMBOLS = new String[] { \"<\", \"=\", \"<=\", \">\", \">=\", \"IS NULL\", \"IS NOT NULL\" };" ], "header": "@@ -99,21 +127,33 @@ public abstract class Restriction", "removed": [ " public static final int ORDER_OP_LESSTHAN = 1;", " public static final int ORDER_OP_EQUALS = 2;", " public static final int ORDER_OP_LESSOREQUALS = 3;", " public static final int ORDER_OP_GREATERTHAN = 4;", " public static final int ORDER_OP_GREATEROREQUALS = 5;" ] }, { "added": [], "header": "@@ -127,9 +167,6 @@ public abstract class Restriction", "removed": [ " /** null handling */", " private boolean _nullEqualsNull;", "" ] }, { "added": [], "header": "@@ -146,20 +183,17 @@ public abstract class Restriction", "removed": [ " * @param nullEqualsNull True if NULLS should be treated like ordinary values which sort before all other values. Used to encode IS NULL comparisons.", " boolean nullEqualsNull,", " _nullEqualsNull = nullEqualsNull;" ] }, { "added": [], "header": "@@ -184,17 +218,6 @@ public abstract class Restriction", "removed": [ " /**", " * <p>", " * Specifies how nulls behave in comparisons. If true, then nulls are", " * treated as values which sort before all other values; and the = comparison", " * between two nulls evaluates to TRUE. If this method returns false, then", " * any comparison involving a null evaluates to UNKNOWN. This is useful", " * for encoding IS NULL comparisons.", " * </p>", " */", " public boolean nullEqualsNull() { return _nullEqualsNull; }", "" ] } ] } ]
derby-DERBY-4357-f6fa9429
DERBY-4357: Check in logic to push restrictions into VTIs when the optimizer chooses to siphon the vti into a hash table. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@831454 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/FromVTI.java", "hunks": [ { "added": [ " void computeProjectionAndRestriction( PredicateList parentPredicates )", " computeRestriction( parentPredicates, computeProjection( ) );", " * RestrictedVTI.initScan(). Returns a map of the exposed column names", " private HashMap computeProjection( ) throws StandardException" ], "header": "@@ -1221,33 +1221,27 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [ " * @param parentProjection The column list which the parent ProjectRestrictNode expects to return.", " void computeProjectionAndRestriction( ResultColumnList parentProjection, PredicateList parentPredicates )", " computeRestriction( parentPredicates, computeProjection( parentProjection ) );", " * RestrictedVTI.initScan(). Returns a mapping of the exposed column names", " private HashMap computeProjection( ResultColumnList parentProjection ) throws StandardException", " HashSet projectedColumns = new HashSet();", " String[] exposedNames = parentProjection.getColumnNames();", " int projectedCount = exposedNames.length;", "", " for ( int i = 0; i < projectedCount; i++ ) { projectedColumns.add( exposedNames[ i ] ); }" ] }, { "added": [ " if ( column.isReferenced() )" ], "header": "@@ -1259,7 +1253,7 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [ " if ( projectedColumns.contains( exposedName ) )" ] }, { "added": [ " if ( canBePushedDown( predicate ) )" ], "header": "@@ -1290,7 +1284,7 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [ " if ( predicate.isQualifier() )" ] }, { "added": [ " /** Return true if the predicate can be pushed into a RestrictedVTI */", " private boolean canBePushedDown( Predicate predicate ) throws StandardException", " {", " JBitSet referencedSet = predicate.getReferencedSet();", "", " // we want this to be a qualifier on only this FROM table */", " return", " (", " predicate.isQualifier() &&", " (referencedSet != null) &&", " (referencedSet.hasSingleBitSet() ) &&", " (referencedSet.get( getTableNumber() ) )", " );", " }" ], "header": "@@ -1311,6 +1305,20 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java", "hunks": [ { "added": [ " //", " // If we are projecting and restricting the stream from a table", " // function, then give the table function all of the information that", " // it needs in order to push the projection and qualifiers into", " // the table function. See DERBY-4357.", " //", " if ( childResult instanceof FromVTI )", " {", " ((FromVTI) childResult).computeProjectionAndRestriction( restrictionList );", " }", "" ], "header": "@@ -1320,6 +1320,17 @@ public class ProjectRestrictNode extends SingleChildResultSetNode", "removed": [] } ] } ]
derby-DERBY-436-b690b7ae
DERBY-5847: Clean up IDE warnings in DRDAConnThread DERBY-436: Clean up imports and static field references in DRDA classes Changed in DRDAConnThread: - Use class name to reference static fields - Use direct references to constants in java.sql.ParameterMetaData instead of JDBC30Translation - Organize imports alphabetically git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1359559 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/impl/drda/DRDAConnThread.java", "hunks": [ { "added": [ "import java.io.IOException;", "import java.io.InputStreamReader;" ], "header": "@@ -22,11 +22,11 @@ package org.apache.derby.impl.drda;", "removed": [ "import java.io.InputStreamReader;", "import java.io.IOException;" ] }, { "added": [ "import org.apache.derby.iapi.error.StandardException;", "import org.apache.derby.iapi.jdbc.AuthenticationService;", "import org.apache.derby.iapi.jdbc.EngineLOB;", "import org.apache.derby.iapi.jdbc.EnginePreparedStatement;", "import org.apache.derby.iapi.jdbc.EngineResultSet;" ], "header": "@@ -48,13 +48,15 @@ import java.util.Date;", "removed": [ "", "import org.apache.derby.iapi.error.StandardException;", "import org.apache.derby.iapi.reference.JDBC30Translation;" ] }, { "added": [], "header": "@@ -62,13 +64,9 @@ import org.apache.derby.iapi.services.monitor.Monitor;", "removed": [ "import org.apache.derby.iapi.jdbc.AuthenticationService;", "import org.apache.derby.iapi.jdbc.EngineLOB;", "import org.apache.derby.iapi.jdbc.EngineResultSet;", "import org.apache.derby.iapi.jdbc.EnginePreparedStatement;" ] }, { "added": [ "\t\tsession.setState(Session.ATTEXC);" ], "header": "@@ -1190,7 +1188,7 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\tsession.setState(session.ATTEXC);" ] }, { "added": [ "\t\t\t\tif (currentLevel == AppRequester.MGR_LEVEL_UNKNOWN)", " {", " }" ], "header": "@@ -1728,8 +1726,10 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\t\t\tif (currentLevel == appRequester.MGR_LEVEL_UNKNOWN)" ] }, { "added": [ " writer.writeScalarString(CodePoint.EXTNAM,", " NetworkServerControlImpl.att_extnam);", " writer.writeScalarString(CodePoint.SRVCLSNM,", " NetworkServerControlImpl.att_srvclsnm);", " writer.writeScalarString(CodePoint.SRVNAM,", " NetworkServerControlImpl.ATT_SRVNAM);", " writer.writeScalarString(CodePoint.SRVRLSLV,", " NetworkServerControlImpl.att_srvrlslv);" ], "header": "@@ -1779,13 +1779,17 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\twriter.writeScalarString(CodePoint.EXTNAM, server.att_extnam);", "\t\twriter.writeScalarString(CodePoint.SRVCLSNM, server.att_srvclsnm);", "\t\twriter.writeScalarString(CodePoint.SRVNAM, server.ATT_SRVNAM);", "\t\twriter.writeScalarString(CodePoint.SRVRLSLV, server.att_srvrlslv);" ] }, { "added": [ " session.setState(", " (securityCheckCode == 0) ? Session.SECACC : Session.ATTEXC);" ], "header": "@@ -2053,10 +2057,8 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\tif (securityCheckCode == 0)", "\t\t\tsession.setState(session.SECACC);", "\t\telse", "\t\t\tsession.setState(session.ATTEXC);" ] }, { "added": [ " if (securityCheckCode == 0) {", " session.setState(Session.CHKSEC);", " }" ], "header": "@@ -3274,8 +3276,9 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\tif (securityCheckCode == 0)", "\t\t\tsession.setState(session.CHKSEC);" ] }, { "added": [ " if (appRequester.getClientType() != AppRequester.DNC_CLIENT) {" ], "header": "@@ -3422,7 +3425,7 @@ class DRDAConnThread extends Thread {", "removed": [ " if (appRequester.getClientType() != appRequester.DNC_CLIENT) {" ] }, { "added": [ "\t\t\t\t\tif ((appRequester.getClientType() == AppRequester.DNC_CLIENT) &&" ], "header": "@@ -3431,7 +3434,7 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\t\t\t\tif ((appRequester.getClientType() == appRequester.DNC_CLIENT) &&" ] }, { "added": [ " writer.writeScalarString(CodePoint.PRDID,", " NetworkServerControlImpl.prdId);" ], "header": "@@ -3550,7 +3553,8 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\twriter.writeScalarString(CodePoint.PRDID, server.prdId);" ] }, { "added": [ " if ((appRequester.getClientType() == AppRequester.DNC_CLIENT) &&" ], "header": "@@ -3564,7 +3568,7 @@ class DRDAConnThread extends Thread {", "removed": [ " if ((appRequester.getClientType() == appRequester.DNC_CLIENT) &&" ] }, { "added": [ " writer.writeScalar2Bytes(CodePoint.CCSIDSBC,", " NetworkServerControlImpl.CCSIDSBC);", " writer.writeScalar2Bytes(CodePoint.CCSIDMBC,", " NetworkServerControlImpl.CCSIDMBC);" ], "header": "@@ -3580,8 +3584,10 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\twriter.writeScalar2Bytes(CodePoint.CCSIDSBC, server.CCSIDSBC);", "\t\twriter.writeScalar2Bytes(CodePoint.CCSIDMBC, server.CCSIDMBC);" ] }, { "added": [ "\t\t\t\t\t\t\t\t\t!= ParameterMetaData.parameterModeOut)" ], "header": "@@ -4585,7 +4591,7 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\t\t\t\t\t\t\t\t!= JDBC30Translation.PARAMETER_MODE_OUT )" ] }, { "added": [ " writer.writeBytes(NetworkServerControlImpl.prdIdBytes_);" ], "header": "@@ -6110,7 +6116,7 @@ class DRDAConnThread extends Thread {", "removed": [ " writer.writeBytes(server.prdIdBytes_);" ] }, { "added": [ " writer.writeBytes(NetworkServerControlImpl.prdIdBytes_);" ], "header": "@@ -6163,7 +6169,7 @@ class DRDAConnThread extends Thread {", "removed": [ " writer.writeBytes(server.prdIdBytes_);" ] }, { "added": [ " boolean nullable = hasRs ?", " (rsmeta.isNullable(i) == ResultSetMetaData.columnNullable) :", " (pmeta.isNullable(i) == ParameterMetaData.parameterNullable);" ], "header": "@@ -6821,8 +6827,9 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\t\tboolean nullable = (hasRs ? (rsmeta.isNullable(i) == rsmeta.columnNullable) :", "\t\t\t\t\t\t\t\t\t\t\t\t (pmeta.isNullable(i) == JDBC30Translation.PARAMETER_NULLABLE));" ] }, { "added": [ " boolean nullable = rtnOutput ?", " (rsmeta.isNullable(jdbcElemNum) == ResultSetMetaData.columnNullable) :", " (pmeta.isNullable(jdbcElemNum) == ParameterMetaData.parameterNullable);" ], "header": "@@ -7694,9 +7701,9 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\tboolean nullable = rtnOutput ? (rsmeta.isNullable(jdbcElemNum) ==", "\t\t\t\t\t\t\t\t\t\tResultSetMetaData.columnNullable) : ", "\t\t\t(pmeta.isNullable(jdbcElemNum) == JDBC30Translation.PARAMETER_NULLABLE);" ] }, { "added": [ "\t\t\tif (mode == ParameterMetaData.parameterModeUnknown)", " if (type != DRDAStatement.NOT_OUTPUT_PARAM) {", " mode = ParameterMetaData.parameterModeInOut;", " }" ], "header": "@@ -7917,14 +7924,15 @@ class DRDAConnThread extends Thread {", "removed": [ "\t\t\tif (mode == JDBC30Translation.PARAMETER_MODE_UNKNOWN)", "\t\t\t\tif (type != DRDAStatement.NOT_OUTPUT_PARAM)", "\t\t\t\t\tmode = JDBC30Translation.PARAMETER_MODE_IN_OUT;" ] } ] } ]
derby-DERBY-436-db4c9953
DERBY-436: Clean up imports and static field references in DRDA classes git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1363662 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/drda/org/apache/derby/drda/NetworkServerControl.java", "hunks": [ { "added": [ "import java.net.InetAddress;" ], "header": "@@ -22,8 +22,8 @@", "removed": [ "import java.net.InetAddress;" ] } ] }, { "file": "java/drda/org/apache/derby/impl/drda/DRDAStatement.java", "hunks": [ { "added": [ "import java.lang.reflect.Array;", "import java.sql.DataTruncation;" ], "header": "@@ -22,12 +22,12 @@", "removed": [ "import java.io.UnsupportedEncodingException;", "import java.lang.reflect.InvocationTargetException;" ] } ] }, { "file": "java/drda/org/apache/derby/impl/drda/DRDAXAProtocol.java", "hunks": [ { "added": [ "", "import javax.transaction.xa.XAException;", "import javax.transaction.xa.XAResource;", "import javax.transaction.xa.Xid;" ], "header": "@@ -20,11 +20,14 @@", "removed": [ "import javax.transaction.xa.*;" ] }, { "added": [ "\t\tint xaRetVal = XAResource.XA_OK;" ], "header": "@@ -246,7 +249,7 @@ class DRDAXAProtocol {", "removed": [ "\t\tint xaRetVal = xaResource.XA_OK;" ] }, { "added": [ "\t\tint xaRetVal = XAResource.XA_OK;" ], "header": "@@ -340,7 +343,7 @@ class DRDAXAProtocol {", "removed": [ "\t\tint xaRetVal = xaResource.XA_OK;" ] }, { "added": [ "\t\tint xaRetVal = XAResource.XA_OK;" ], "header": "@@ -412,7 +415,7 @@ class DRDAXAProtocol {", "removed": [ "\t\tint xaRetVal = xaResource.XA_OK;" ] }, { "added": [ "\t\tint xaRetVal = XAResource.XA_OK;" ], "header": "@@ -440,7 +443,7 @@ class DRDAXAProtocol {", "removed": [ "\t\tint xaRetVal = xaResource.XA_OK;" ] }, { "added": [ "\t\tint xaRetVal;" ], "header": "@@ -469,7 +472,7 @@ class DRDAXAProtocol {", "removed": [ "\t\tint xaRetVal = xaResource.XA_OK;" ] }, { "added": [ "\t\tint xaRetVal = XAResource.XA_OK;" ], "header": "@@ -495,7 +498,7 @@ class DRDAXAProtocol {", "removed": [ "\t\tint xaRetVal = xaResource.XA_OK;" ] } ] }, { "file": "java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java", "hunks": [ { "added": [ "import java.security.AccessController;", "import java.security.Permission;" ], "header": "@@ -33,17 +33,11 @@ import java.io.PrintWriter;", "removed": [ "import javax.net.SocketFactory;", "import javax.net.ServerSocketFactory;", "import javax.net.ssl.SSLServerSocket;", "import javax.net.ssl.SSLSocket;", "import javax.net.ssl.SSLSocketFactory;", "import javax.net.ssl.SSLServerSocketFactory;", "import java.security.Permission;", "import java.security.AccessController;" ] }, { "added": [ "import javax.net.ServerSocketFactory;", "import javax.net.SocketFactory;", "import javax.net.ssl.SSLServerSocket;", "import javax.net.ssl.SSLServerSocketFactory;", "import javax.net.ssl.SSLSocket;", "import javax.net.ssl.SSLSocketFactory;", "import org.apache.derby.iapi.jdbc.AuthenticationService;", "import org.apache.derby.iapi.reference.MessageId;" ], "header": "@@ -58,13 +52,19 @@ import java.util.Properties;", "removed": [ "", "import org.apache.derby.security.SystemPermission;" ] } ] }, { "file": "java/drda/org/apache/derby/impl/drda/XADatabase.java", "hunks": [ { "added": [ "import javax.sql.XAConnection;", "import javax.transaction.xa.XAResource;", "import org.apache.derby.jdbc.EmbeddedXADataSource;" ], "header": "@@ -21,22 +21,13 @@", "removed": [ "import java.sql.Connection;", "", "import javax.transaction.xa.XAResource;", "import javax.sql.XADataSource;", "import javax.sql.XAConnection;", "", "import java.util.Hashtable;", "import java.util.Enumeration;", "", "", "import org.apache.derby.jdbc.EmbeddedXADataSource;", "import org.apache.derby.iapi.jdbc.BrokeredConnection;" ] } ] } ]
derby-DERBY-4361-a505d5a3
DERBY-4361 It was not enough to just the shutdown the database in Windows in order to be able to delete the log file later. The engine needed to be brought down too. I added code in JDBCDataSource for shutting down the engine and used this new method from the ClassLoaderBootTest to shut the engine down. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@812669 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java", "hunks": [ { "added": [ "import javax.sql.DataSource;", "" ], "header": "@@ -25,6 +25,8 @@ import java.sql.SQLException;", "removed": [] }, { "added": [ "", " /**", " * Shutdown the engine described by this data source.", " * The shutdownDatabase property is cleared by this method.", " */", " public static void shutEngine(javax.sql.DataSource ds) throws SQLException {", " setBeanProperty(ds, \"shutdownDatabase\", \"shutdown\");", " JDBCDataSource.setBeanProperty(ds, \"databaseName\", \"\");", " try {", " ds.getConnection();", " Assert.fail(\"Engine failed to shut down\");", " } catch (SQLException e) {", " BaseJDBCTestCase.assertSQLState(\"Engine shutdown\", \"XJ015\", e);", " } finally {", " clearStringBeanProperty(ds, \"shutdownDatabase\");", " }", " }", "" ], "header": "@@ -265,4 +267,22 @@ public class JDBCDataSource {", "removed": [] } ] } ]
derby-DERBY-4365-f8b521a5
DERBY-4365 For JOIN, we were doing a no-op in the method bindUntypedNullsToResultColumns(ResultColumnList) rather than checking for untyped nulls for the left and right resultsets. The changes through this commit now checks for untyped nulls for joins. Added couple more tests (including where a CAST of NULL values should work fine). The derbyall and junit suites ran fine with the exception of known intermittent (DERBY-3757) 'ASSERT FAILED transaction table has null entry when running new StressMultiTest git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@833430 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4367-6391648e
DERBY-4367: Replace Utils.min and Utils.max in the client driver with standard methods in java.lang.Math. Removed methods min and max in Utils, as they duplicate standard methods in java.lang.Math. Replaced all invocations. Patch file: derby-4367-1a-remove_min_max.diff git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@810024 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/client/org/apache/derby/client/am/Utils.java", "hunks": [ { "added": [], "header": "@@ -22,8 +22,6 @@", "removed": [ "import org.apache.derby.iapi.types.SQLBit;", "import org.apache.derby.shared.common.i18n.MessageUtil;" ] } ] }, { "file": "java/client/org/apache/derby/client/net/NetConnection.java", "hunks": [ { "added": [], "header": "@@ -32,7 +32,6 @@ import org.apache.derby.client.am.ClientMessageId;", "removed": [ "import org.apache.derby.client.am.Utils;" ] }, { "added": [ " int extnamTruncateLength = Math.min(extnam_.length(), NetConfiguration.PRDDTA_APPL_ID_FIXED_LEN);" ], "header": "@@ -1325,7 +1324,7 @@ public class NetConnection extends org.apache.derby.client.am.Connection {", "removed": [ " int extnamTruncateLength = Utils.min(extnam_.length(), NetConfiguration.PRDDTA_APPL_ID_FIXED_LEN);" ] } ] }, { "file": "java/client/org/apache/derby/client/net/NetConnectionRequest.java", "hunks": [ { "added": [], "header": "@@ -26,7 +26,6 @@ import javax.transaction.xa.Xid;", "removed": [ "import org.apache.derby.client.am.Utils;" ] }, { "added": [ " int extnamTruncateLength = Math.min(extnam.length()," ], "header": "@@ -431,7 +430,7 @@ public class NetConnectionRequest extends Request implements ConnectionRequestIn", "removed": [ " int extnamTruncateLength = Utils.min(extnam.length()," ] } ] }, { "file": "java/client/org/apache/derby/client/net/Request.java", "hunks": [ { "added": [], "header": "@@ -21,10 +21,8 @@", "removed": [ "import org.apache.derby.client.am.EncryptionManager;", "import org.apache.derby.client.am.Utils;" ] }, { "added": [ "\t\t\tbytesToRead = Math.min(leftToRead, DssConstants.MAX_DSS_LEN - 6 - 4 - 1 - extendedLengthByteCount);", "\t\t\tbytesToRead = Math.min(leftToRead, DssConstants.MAX_DSS_LEN - 6 - 4 - extendedLengthByteCount);" ], "header": "@@ -294,9 +292,9 @@ public class Request {", "removed": [ "\t\t\tbytesToRead = Utils.min(leftToRead, DssConstants.MAX_DSS_LEN - 6 - 4 - 1 - extendedLengthByteCount);", "\t\t\tbytesToRead = Utils.min(leftToRead, DssConstants.MAX_DSS_LEN - 6 - 4 - extendedLengthByteCount);" ] }, { "added": [ "\t\t\tbytesToRead = Math.min(leftToRead, DssConstants.MAX_DSS_LEN - 6 - 4 - 1 - extendedLengthByteCount);", "\t\t\tbytesToRead = Math.min(leftToRead, DssConstants.MAX_DSS_LEN - 6 - 4 - extendedLengthByteCount);" ], "header": "@@ -455,9 +453,9 @@ public class Request {", "removed": [ "\t\t\tbytesToRead = Utils.min(leftToRead, DssConstants.MAX_DSS_LEN - 6 - 4 - 1 - extendedLengthByteCount);", "\t\t\tbytesToRead = Utils.min(leftToRead, DssConstants.MAX_DSS_LEN - 6 - 4 - extendedLengthByteCount);" ] }, { "added": [ " if ((Math.min(2 + leftToRead, 32767)) > (bytes_.length - offset_)) {" ], "header": "@@ -742,7 +740,7 @@ public class Request {", "removed": [ " if ((Utils.min(2 + leftToRead, 32767)) > (bytes_.length - offset_)) {" ] }, { "added": [ " newBytesToRead = Math.min(leftToRead, 32765);" ], "header": "@@ -752,7 +750,7 @@ public class Request {", "removed": [ " newBytesToRead = Utils.min(leftToRead, 32765);" ] } ] } ]
derby-DERBY-4372-c7c53056
DERBY-4372: Wrong result for simple join when index is created If the inner table in the join is restricted by an explicit or implicit IN list on an indexed column, an index range scan is performed between the smallest value and the greatest value in the IN list. If the first element in the IN list was NULL, the methods that calculated the minimum and maximum values always returned NULL, which resulted in a range scan between NULL and NULL, and no rows were found. If some other element in the IN list was NULL, it was simply ignored. This patch makes the methods always return the min or max non-NULL value, if such a value exists. Since the index scan is not supposed to return the NULL values anyway, it is safe to ignore them. The edge case where all the values are NULL still returns NULL for both min and max. This makes the index scan return no rows, which is correct because X IN (NULL, NULL) is never true, regardless of the actual value of X. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@816531 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/execute/BaseExpressionActivation.java", "hunks": [ { "added": [ "\t * <p>", "\t * {@code null} for the unused parameters and place them at the end.", "\t * If more than 4 input values, call this multiple times to", "\t * </p>", "\t * <p>", "\t * If all the input values are SQL NULL, return SQL NULL. Otherwise, return", "\t * the minimum value of the non-NULL inputs.", "\t * </p>", "\t *" ], "header": "@@ -46,12 +46,20 @@ public abstract class BaseExpressionActivation", "removed": [ "\t * NULL. If more than 4 input values, call this multiple times to" ] }, { "added": [ "\t\tif (v2 != null &&", "\t\t\t\t(minVal.isNull() || judge.lessThan(v2, minVal).equals(true)))", "\t\tif (v3 != null &&", "\t\t\t\t(minVal.isNull() || judge.lessThan(v3, minVal).equals(true)))", "\t\tif (v4 != null &&", "\t\t\t\t(minVal.isNull() || judge.lessThan(v4, minVal).equals(true)))", "\t * <p>", "\t * {@code null} for the unused parameters and place them at the end.", "\t * If more than 4 input values, call this multiple times to", "\t * </p>", "\t * <p>", "\t * If all the input values are SQL NULL, return SQL NULL. Otherwise, return", "\t * the maximum value of the non-NULL inputs.", "\t * </p>", "\t *" ], "header": "@@ -77,23 +85,34 @@ public abstract class BaseExpressionActivation", "removed": [ "\t\tif (v2 != null && judge.lessThan(v2, minVal).equals(true))", "\t\tif (v3 != null && judge.lessThan(v3, minVal).equals(true))", "\t\tif (v4 != null && judge.lessThan(v4, minVal).equals(true))", "\t * NULL. If more than 4 input values, call this multiple times to" ] } ] } ]
derby-DERBY-4373-7b429a31
DERBY-3823 NullPointerException in stress.multi test Adding a test case showing that in case of a network server, an open resulset's metadata can get changed underneath it but it is not reflected in the metadata. The test creates a table with one of column as varchar(5). It inserts 1000 rows and then opens a reulset on that table with varchar column as one of the columns. The test verifies that the reulset's metadata at this point shows the length of the column as 5. Next, while the resulset is still open, the tests does an ALTER TABLE to increase the varchar column's length to 8. In case of embedded mode, this fails because of the open resulset. In case of network server, because of prefetching of rows, the ALTER TABLE is allowed but when the test gets the resulset's metadata again and checks the length of varchar column, it still shows the length to be 5 rather than 8. There are couple other jiras related to network server prefetching, namely, DERBY-3839 and DERBY-4373. Once DERBY-3823 is fixed, we should see the change in metadata reflected in resultset's metadata. A fix for DERBY-3823 will cause the following the test added here to fail. Right now, the new test accepts the incorrect metadata length obtained through the resultset's metadata after ALTER TABLE has been performed in network server mode. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1182570 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4376-5ce87314
DERBY-4376: Simple select runs forever A MultiProbeTableScanResultSet performes one index scan per distinct element in the IN list. Changing the start and stop positions of the underlying index scan, and moving to the next element in the IN list, happens when the scan controller is reopened. However, the reopening of the scan controller is controlled by TableScanResultSet, which skips the reopening if the current start and stop positions are guaranteed to make the scan return zero rows. Basically, if the start/stop positions are initialized with NULLs, the scan is not reopened, and we do not move to the next element of the IN list. We therefore just keep on retrying at the same position in the IN list, and the query execution is stuck forever. This patch moves all the multi-probe logic out of TableScanResultSet and into MultiProbeTableScanResultSet, and instead adds methods that MPTSRS can override where different logic is needed. In short: 1) Initialization of the start/stop keys has been factored out of TSRS.openCore()/TSRS.reopenCore() into a helper method initStartAndStopKey(). 2) MPTSRS overrides initStartAndStopKey() and updates the keys with the actual probe value. This ensures that the keys now have the correct values when TSRS.reopenCore() calls skipScan(). 3) Methods in TSRS that take a probeValue argument have been removed, since MPTSRS.initStartAndStopKey() now does all the work with retrieving the probe value and updating the keys. 4) Since the next probe value is fetched earlier now MPTSRS.reopenScanController() can no longer use the return value from getNextProbeValue() to decide whether or not it should be a no-op (it should be a no-op if the next probe value was null, which means that the probe list has been exhausted). To ensure that we don't open scans in those cases, set a flag in initStartAndStopKey() to indicate whether or not the probe list was exhausted, and override skipScan() to check that flag and return true if no new probe value was found. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@816536 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/execute/MultiProbeTableScanResultSet.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.sql.execute.ExecIndexRow;" ], "header": "@@ -28,11 +28,11 @@ import org.apache.derby.iapi.services.loader.GeneratedMethod;", "removed": [ "import org.apache.derby.iapi.store.access.TransactionController;" ] }, { "added": [ " /**", " * Tells whether or not we should skip the next attempt to (re)open the", " * scan controller. If it is {@code true} it means that the previous call", " * to {@link #initStartAndStopKey()} did not find a new probe value, which", " * means that the probe list is exhausted and we shouldn't perform a scan.", " */", " private boolean skipNextScan;", "" ], "header": "@@ -88,6 +88,14 @@ class MultiProbeTableScanResultSet extends TableScanResultSet", "removed": [] }, { "added": [], "header": "@@ -214,29 +222,6 @@ class MultiProbeTableScanResultSet extends TableScanResultSet", "removed": [ " /**", " * Open the scan controller", " *", " * @param tc transaction controller; will open one if null.", " * @exception StandardException thrown on failure to open", " */", " protected void openScanController(TransactionController tc)", " throws StandardException", " {", " /* If we're opening the scan controller for the first time then", " * we want to use the first value in the (now sorted) list as", " * the start/stop key. That's what we pass in here.", " */", " openScanController(tc, probeValues[0]);", "", " /* probeValIndex should be the index of the *next* value to", " * use. Since we just positioned ourselves at the 0th probe", " * value with the above call, the next value we want is the", " * one at index \"1\".", " */", " probeValIndex = 1;", " }", "" ] }, { "added": [ " // TableScanResultSet.reopenScanController() will reset rowsThisScan", " // because it thinks this is a completely new scan. However, we want", " // it to reflect the total number of rows seen in the multi-probe", " // scan, so we keep the original value and restore it after reopening", " // the controller. Instead, we reset rowsThisScan to 0 each time", " // initStartAndStopKey() is called on the first probe value.", " long rows = rowsThisScan;", " super.reopenScanController();", " rowsThisScan = rows;", " }", "", " /**", " * Initialize the start key and the stop key used in the scan. Both keys", " * will be set to the probe value. If no new probe value was found (the", " * probe list was exhausted), the flag skipNextScan will be {@code true}", " * when the method returns to prevent a new scan from being reopened with", " * a missing or incorrect probe value.", " */", " void initStartAndStopKey() throws StandardException {", "", " // Make sure the fields are initialized with a placeholder.", " // startPosition and stopPosition will always be non-null in a", " // MultiProbeTableScanResultSet, and they will always be initialized", " // to the first value in the probe list. They will be changed to", " // the actual probe value later in this method.", " super.initStartAndStopKey();", "" ], "header": "@@ -298,6 +283,33 @@ class MultiProbeTableScanResultSet extends TableScanResultSet", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java", "hunks": [ { "added": [ "\tfinal boolean sameStartStopPosition;" ], "header": "@@ -82,7 +82,7 @@ class TableScanResultSet extends ScanResultSet", "removed": [ "\tprivate boolean sameStartStopPosition;" ] }, { "added": [ " initStartAndStopKey();" ], "header": "@@ -244,19 +244,7 @@ class TableScanResultSet extends ScanResultSet", "removed": [ "", "\t\tif (startKeyGetter != null)", "\t\t{", "\t\t\tstartPosition = (ExecIndexRow) startKeyGetter.invoke(activation);", "\t\t\tif (sameStartStopPosition)", "\t\t\t{", "\t\t\t\tstopPosition = startPosition;", "\t\t\t}", "\t\t}", "\t\tif (stopKeyGetter != null)", "\t\t{", "\t\t\tstopPosition = (ExecIndexRow) stopKeyGetter.invoke(activation);", "\t\t}" ] }, { "added": [ " /**", " * Initialize the {@code startPosition} and {@code stopPosition} fields", " * which are used to limit the rows returned by the scan.", " */", " void initStartAndStopKey() throws StandardException {", " if (startKeyGetter != null) {", " startPosition = (ExecIndexRow) startKeyGetter.invoke(activation);", " if (sameStartStopPosition) {", " stopPosition = startPosition;", " }", " }", " if (stopKeyGetter != null) {", " stopPosition = (ExecIndexRow) stopKeyGetter.invoke(activation);", " }", " }", "" ], "header": "@@ -327,6 +315,22 @@ class TableScanResultSet extends ScanResultSet", "removed": [] }, { "added": [], "header": "@@ -334,76 +338,12 @@ class TableScanResultSet extends ScanResultSet", "removed": [ "\t{", "\t\topenScanController(tc, (DataValueDescriptor)null);", "\t}", "", "\t/*", "\t** Does the work of openScanController.", "\t**", "\t** @param tc transaction controller; will open one if null.", "\t** @param probeValue If non-null then we will open the scan controller", "\t** and position it using the received probeValue as the start key.", "\t** Otherwise we'll use whatever value is in startPosition (if non-", "\t** null) as the start key.", "\t*/", "\tprotected void openScanController(TransactionController tc,", "\t\tDataValueDescriptor probeValue) throws StandardException", "\t\t/* If we have a probe value then we do the \"probe\" by positioning", "\t\t * the scan at the first row matching the value. The way to do", "\t\t * that is to use the value as a start key, which is what will", "\t\t * happen if we plug it into first column of \"startPositionRow\".", "\t\t * So in this case startPositionRow[0] functions as a \"place-holder\"", "\t\t * for the probe value. The same goes for stopPositionRow[0].", "\t\t *", "\t\t * Note that it *is* possible for a start/stop key to contain more", "\t\t * than one column (ex. if we're scanning a multi-column index). In", "\t\t * that case we plug probeValue into the first column of the start", "\t\t * and/or stop key and leave the rest of the key as it is. As an ", "\t\t * example, assume we have the following predicates:", "\t\t *", "\t\t * ... where d in (1, 20000) and b > 200 and b <= 500", "\t\t *", "\t\t * And assume further that we have an index defined on (d, b).", "\t\t * In this case it's possible that we have TWO start predicates", "\t\t * and TWO stop predicates: the IN list will give us \"d = probeVal\",", "\t\t * which is a start predicate and a stop predicate; then \"b > 200\"", "\t\t * may give us a second start predicate, while \"b <= 500\" may give", "\t\t * us a second stop predicate. So in this situation we want our", "\t\t * start key to be:", "\t\t *", "\t\t * (probeValue, 200)", "\t\t *", "\t\t * and our stop key to be:", "\t\t *", "\t\t * (probeValue, 500).", "\t\t *", "\t\t * This will effectively limit the scan so that it only returns", "\t\t * rows whose \"D\" column equals probeValue and whose \"B\" column", "\t\t * falls in the range of 200 thru 500.", "\t\t *", "\t\t * Note: Derby currently only allows a single start/stop predicate", "\t\t * per column. See PredicateList.orderUsefulPredicates().", "\t\t */", "\t\tif (probeValue != null)", "\t\t{", "\t\t\tstartPositionRow[0] = probeValue;", "", "\t\t \t/* If the start key and stop key are the same, we've already set", "\t\t\t * stopPosition equal to startPosition as part of openCore().", "\t\t\t * So by putting the probe value into startPositionRow[0], we", "\t\t\t * also put it into stopPositionRow[0].", "\t\t\t */", "\t\t\tif (!sameStartStopPosition)", "\t\t\t\tstopPositionRow[0] = probeValue;", "\t\t}", "" ] }, { "added": [ " rowsThisScan = 0;" ], "header": "@@ -460,45 +400,13 @@ class TableScanResultSet extends ScanResultSet", "removed": [ "\t{", "\t\treopenScanController((DataValueDescriptor)null);", "\t}", "", "\t/*", "\t** Does the work of reopenScanController.", "\t**", "\t** @param probeValue If non-null then we will open the scan controller", "\t** and position it using the received probeValue as the start key.", "\t** Otherwise we'll use whatever value is in startPosition (if non-", "\t** null) as the start key.", "\t*/", "\tprotected void reopenScanController(DataValueDescriptor probeValue)", "\t\tthrows StandardException", "\t\t/* If we have a probe value then we do the \"probe\" by using the", "\t\t * value as a start and stop key. See openScanController() for", "\t\t * details. Note that in this case we do *not* want to reset", "\t\t * the rowsThisScan variable because we are going to be doing", "\t\t * multiple \"probes\" for a single scan. Logic to detect when", "\t\t * when we've actually started a new scan (as opposed to just", "\t\t * repositioning an existing scan based on a probe value) is", "\t\t * in MultiProbeTableScanResultSet.reopenScanController(),", "\t\t * and that method will then take care of resetting the variable", "\t\t * (if needed) for probing scans.", "\t\t */", "\t\tif (probeValue != null)", "\t\t{", "\t\t\tstartPositionRow[0] = probeValue;", "\t\t\tif (!sameStartStopPosition)", "\t\t\t\tstopPositionRow[0] = probeValue;", "\t\t}", "\t\telse", "\t\t\trowsThisScan = 0;" ] } ] } ]
derby-DERBY-4378-c95594cc
DERBY-4378: Create test cases for MultiProbeTableScanResultSet with duplicates in the probe list git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1507212 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-438-006805f8
DERBY-438 (partial) Add testing of BLOBs in triggers with larger BLOB values. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@397315 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-438-19f33c64
DERBY-438 (partial) Move ReaderToUTF8Stream.java from the JDBC implementation to the types package so that it can be used directly by SQLCLob. This class converts from a Reader (stream) format to the on-disk format for character types. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@393973 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/types/ReaderToUTF8Stream.java", "hunks": [ { "added": [ " Derby - Class org.apache.derby.iapi.types.ReaderToUTF8Stream" ], "header": "@@ -1,6 +1,6 @@", "removed": [ " Derby - Class org.apache.derby.impl.jdbc.ReaderToUTF8Stream" ] }, { "added": [ "package org.apache.derby.iapi.types;" ], "header": "@@ -18,7 +18,7 @@", "removed": [ "package org.apache.derby.impl.jdbc;" ] }, { "added": [ "\tConverts a java.io.Reader to the on-disk UTF8 format used by Derby", " for character types.", "public final class ReaderToUTF8Stream" ], "header": "@@ -28,12 +28,12 @@ import java.io.UTFDataFormatException;", "removed": [ "import org.apache.derby.iapi.types.TypeId;", "\tConverts a java.io.Reader to the on-disk UTF8 format used by Cloudscape.", "final class ReaderToUTF8Stream" ] } ] }, { "file": "java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.types.ReaderToUTF8Stream;" ], "header": "@@ -39,6 +39,7 @@ import org.apache.derby.iapi.sql.execute.CursorActivation;", "removed": [] } ] } ]
derby-DERBY-438-2c65d7cb
DERBY-438 Support statement triggers for BLOB and CLOB types. Change the trigger virtual tables to implement PreparedStatement instead of ResultSet. This allows the mechanism to use the java.sql.ResultSet generated from the language internal ResultSet directly, rather than through a wrapper. The wrapper approach caused issues when the wrapper's JDBC version does not match the version running in the engine. BLOB/CLOB caused problems with statement triggers as the wrapper only supported JDBC 1.2. Add tests for BLOB (will add CLOB in subsequent patch), also add upgrade tests across release boundaries to ensure trigger modifications in 10.2 do not break in soft upgrade mode. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@409422 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/catalog/TriggerNewTransitionRows.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.reference.JDBC20Translation;", "" ], "header": "@@ -22,6 +22,8 @@ package org.apache.derby.catalog;", "removed": [] }, { "added": [ "public final class TriggerNewTransitionRows extends org.apache.derby.vti.UpdatableVTITemplate " ], "header": "@@ -43,7 +45,7 @@ import java.math.BigDecimal;", "removed": [ "public class TriggerNewTransitionRows extends org.apache.derby.vti.VTITemplate " ] } ] }, { "file": "java/engine/org/apache/derby/catalog/TriggerOldTransitionRows.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.reference.JDBC20Translation;", "" ], "header": "@@ -22,6 +22,8 @@ package org.apache.derby.catalog;", "removed": [] }, { "added": [ "public class TriggerOldTransitionRows extends org.apache.derby.vti.UpdatableVTITemplate" ], "header": "@@ -44,7 +46,7 @@ import java.math.BigDecimal;", "removed": [ "public class TriggerOldTransitionRows extends org.apache.derby.vti.VTITemplate" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/FromVTI.java", "hunks": [ { "added": [ " " ], "header": "@@ -534,7 +534,7 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [ "" ] }, { "added": [ " ", " String vtiType = version2 ?", " \"java.sql.PreparedStatement\" : \"java.sql.ResultSet\";", " vtiType, Modifier.PUBLIC);" ], "header": "@@ -1273,11 +1273,14 @@ public class FromVTI extends FromTable implements VTIEnvironment", "removed": [ "\t\t\tversion2 ? \"java.sql.PreparedStatement\" : \"java.sql.ResultSet\", Modifier.PUBLIC);" ] } ] } ]
derby-DERBY-438-40bcd6b2
DERBY-438 (partial) Clarify by adding comments or re-naming variables the expected format of stream values passed to internal data types. The internal data types always work in streams that represent the on-disk format of the data type and not the application visible stream. Some code in SQLBinary and SQLBLob is incorrect and will be fixed in a subsequent commit. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@393570 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/types/DataType.java", "hunks": [ { "added": [ "\tpublic void setValue(InputStream theStream, int valueLength) throws StandardException" ], "header": "@@ -993,7 +993,7 @@ public abstract class DataType", "removed": [ "\tpublic void setValue(InputStream theStream, int streamLength) throws StandardException" ] } ] }, { "file": "java/engine/org/apache/derby/iapi/types/SQLBinary.java", "hunks": [ { "added": [ "\t/**", "\t * Value as a stream, this stream represents the on-disk", " * format of the value. That is it has length information", " * encoded in the first fe bytes.", "\t\tLength of the value in bytes when this value", " is set as a stream. Represents the length of the", " value itself and not the length of the stream", " which contains this length encoded as the first", " few bytes. If the value of the stream is unknown", " then this will be set to -1. If this value is", " not set as a stream then this value should be ignored.", "\tint streamValueLength;" ], "header": "@@ -111,16 +111,23 @@ abstract class SQLBinary", "removed": [ "\t/*", "\t * stream state", "\t\tLength of the stream in units relevant to the type,", "\t\tin this case bytes.", "\tint streamLength;" ] }, { "added": [ "\t\tstreamValueLength = -1;" ], "header": "@@ -139,7 +146,7 @@ abstract class SQLBinary", "removed": [ "\t\tstreamLength = -1;" ] }, { "added": [ "\t\t\t\tstreamValueLength = -1;" ], "header": "@@ -203,7 +210,7 @@ abstract class SQLBinary", "removed": [ "\t\t\t\tstreamLength = -1;" ] }, { "added": [ "\t\t\tif (streamValueLength != -1)", "\t\t\t\treturn streamValueLength;" ], "header": "@@ -223,8 +230,8 @@ abstract class SQLBinary", "removed": [ "\t\t\tif (streamLength != -1)", "\t\t\t\treturn streamLength;" ] }, { "added": [ "\t\tstreamValueLength = -1;" ], "header": "@@ -283,7 +290,7 @@ abstract class SQLBinary", "removed": [ "\t\tstreamLength = -1;" ] }, { "added": [ "\t\tstreamValueLength = -1;" ], "header": "@@ -303,7 +310,7 @@ abstract class SQLBinary", "removed": [ "\t\tstreamLength = -1;" ] }, { "added": [ " /**", " * Read the value from an input stream. The length", " * encoded in the input stream has already been read", " * and determined to be unknown.", " */", " private void readFromStream(InputStream in) throws IOException {" ], "header": "@@ -356,7 +363,12 @@ abstract class SQLBinary", "removed": [ "\tprivate void readFromStream(InputStream in) throws IOException {" ] }, { "added": [ "\t\tstreamValueLength = -1;" ], "header": "@@ -395,7 +407,7 @@ abstract class SQLBinary", "removed": [ "\t\tstreamLength = -1;" ] }, { "added": [ " /**", " * Set me to the value represented by this stream.", " * The format of the stream is the on-disk format", " * described in this class's javadoc. That is the", " * length is encoded in the first few bytes of the", " * stream.", " */", "\t\tstreamValueLength = -1;" ], "header": "@@ -515,11 +527,18 @@ abstract class SQLBinary", "removed": [ "\t\tstreamLength = -1;" ] }, { "added": [ " * Set the value from the stream which is in the on-disk format.", " * @param theStream On disk format of the stream", " * @param valueLength length of the logical value in bytes.", "\tpublic final void setValue(InputStream theStream, int valueLength)", "\t\tthis.streamValueLength = valueLength;" ], "header": "@@ -542,14 +561,15 @@ abstract class SQLBinary", "removed": [ "\t * @see SQLBit#setValue", "\t *", "\tpublic final void setValue(InputStream theStream, int streamLength)", "\t\tthis.streamLength = streamLength;" ] }, { "added": [ "\t\t\tstreamValueLength = theValueBinary.streamValueLength;" ], "header": "@@ -559,7 +579,7 @@ abstract class SQLBinary", "removed": [ "\t\t\tstreamLength = theValueBinary.streamLength;" ] } ] }, { "file": "java/engine/org/apache/derby/iapi/types/SQLBlob.java", "hunks": [ { "added": [ "\t\t\tstreamValueLength = -1; // unknown" ], "header": "@@ -170,7 +170,7 @@ public class SQLBlob extends SQLBinary", "removed": [ "\t\t\tstreamLength = -1; // unknown" ] } ] }, { "file": "java/engine/org/apache/derby/iapi/types/SQLChar.java", "hunks": [ { "added": [ " /**", " * Set this value to the on-disk format stream.", " */", "\tpublic final void setStream(InputStream newStream)" ], "header": "@@ -433,7 +433,10 @@ public class SQLChar", "removed": [ "\tpublic void setStream(InputStream newStream)" ] }, { "added": [ " /**", " * Set the value from the stream which is in the on-disk format.", " * @param theStream On disk format of the stream", " * @param valueLength length of the logical value in characters.", " */", "\tpublic final void setValue(InputStream theStream, int valueLength)", " setStream(theStream);" ], "header": "@@ -1178,19 +1181,14 @@ readingLoop:", "removed": [ "\t/**", "\t * @see SQLChar#setValue", "\t *", "\t */", "\tpublic void setValue(InputStream theStream, int streamLength)", "\t\tvalue = null;", "\t\trawLength = -1;", "\t\tstream = theStream;", "\t\t// clear out the int array as well, so it will stay current", "\t\tintArray = null;", "\t\tintLength = 0;", "\t\tcKey = null;" ] }, { "added": [ "", " /**", "\t * The value as a stream in the on-disk format.", "\tInputStream stream;" ], "header": "@@ -2731,10 +2729,11 @@ readingLoop:", "removed": [ "\t/*", "\t * stream state", "\tprotected InputStream stream;" ] } ] } ]
derby-DERBY-438-4dbb0ff3
DERBY-438 (partial) Consolidate code around converting application character streams (Readers) to the internal stored form (modified UTF8). Pushed handling of LimitReader into ReaderToUTF8Stream to avoid duplicated code and ReaderToUTF8Stream having to make assumptions about the caller setting up the LimitReader correctly. Added comments and clarifications to LimitReader and ReaderToUTF8Stream. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@397316 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/services/io/LimitReader.java", "hunks": [ { "added": [ "public final class LimitReader extends Reader implements Limit ", "\tprivate int remainingCharacters;", "\tprivate boolean limitInPlace;" ], "header": "@@ -27,10 +27,10 @@ import java.io.IOException;", "removed": [ "public class LimitReader extends Reader implements Limit ", "\tprotected int remainingBytes;", "\tprotected boolean limitInPlace;" ] }, { "added": [ "\t\tif (remainingCharacters == 0)", "\t\t\tremainingCharacters--;" ], "header": "@@ -49,13 +49,13 @@ public class LimitReader extends Reader implements Limit", "removed": [ "\t\tif (remainingBytes == 0)", "\t\t\tremainingBytes--;" ] }, { "added": [ "\t\tif (remainingCharacters == 0)", "\t\tif (remainingCharacters < len) ", "\t\t\tlen = remainingCharacters; // end of file", "\t\t\tremainingCharacters -= len;" ], "header": "@@ -65,17 +65,17 @@ public class LimitReader extends Reader implements Limit", "removed": [ "\t\tif (remainingBytes == 0)", "\t\tif (remainingBytes < len) ", "\t\t\tlen = remainingBytes; // end of file", "\t\t\tremainingBytes -= len;" ] }, { "added": [ "\t\tif (remainingCharacters == 0)", "\t\tif (remainingCharacters < count)", "\t\t\tcount = remainingCharacters;", "\t\tremainingCharacters -= count;" ], "header": "@@ -85,14 +85,14 @@ public class LimitReader extends Reader implements Limit", "removed": [ "\t\tif (remainingBytes == 0)", "\t\tif (remainingBytes < count)", "\t\t\tcount = remainingBytes;", "\t\tremainingBytes -= count;" ] }, { "added": [ "\t\tcall up to and including length characters can be read from", " or skipped in the stream.", " Any attempt to read more than length characters will" ], "header": "@@ -104,8 +104,9 @@ public class LimitReader extends Reader implements Limit", "removed": [ "\t\tcall up to and including length bytes can be read from or skipped in", "\t\tthe stream. Any attempt to read more than length bytes will" ] }, { "added": [ "\t\tremainingCharacters = length;" ], "header": "@@ -114,7 +115,7 @@ public class LimitReader extends Reader implements Limit", "removed": [ "\t\tremainingBytes = length;" ] }, { "added": [ " * @return the remaining characters left to be read from the stream", " return remainingCharacters;" ], "header": "@@ -122,11 +123,11 @@ public class LimitReader extends Reader implements Limit", "removed": [ " * @return the remaining bytes left to be read from the stream", " return remainingBytes;" ] } ] }, { "file": "java/engine/org/apache/derby/iapi/types/ReaderToUTF8Stream.java", "hunks": [ { "added": [ " /**", " * Application's reader wrapped in a LimitReader.", " */" ], "header": "@@ -36,7 +36,9 @@ import org.apache.derby.iapi.services.io.LimitReader;", "removed": [ "" ] }, { "added": [ " /** Number of characters to truncate from this stream", " The SQL standard allows for truncation of trailing spaces ", " for clobs,varchar,char.", " If zero, no characters are truncated.", " */", " private static final char SPACE =' ';", " /**", " * Length of the final value, after truncation if any,", " * in characters.", " this stream needs to fit into a column of colWidth", " if truncation error happens ,then the error message includes ", " information about the column width.", " */", " private final int valueLength; ", " /**", " * Create a stream with truncation.", " */", " \tpublic ReaderToUTF8Stream(Reader appReader, int valueLength,int numCharsToTruncate)", " this.reader = new LimitReader(appReader);", " reader.setLimit(valueLength);", " buffer = new byte[BUFSIZE];", " blen = -1; ", " this.valueLength = valueLength;" ], "header": "@@ -48,25 +50,34 @@ public final class ReaderToUTF8Stream", "removed": [ " // Number of characters to truncate from this stream", " // The SQL standard allows for truncation of trailing spaces ", " // for clobs,varchar,char.", " private final char SPACE =' ';", " // this stream needs to fit into a column of colWidth", " // if truncation error happens ,then the error message includes ", " // information about the column width which is why this variable", " // is needed.", " private int colWidth; ", "\tpublic ReaderToUTF8Stream(LimitReader reader,int length,int numCharsToTruncate)", "\t\tthis.reader = reader;", "\t\tbuffer = new byte[BUFSIZE];", "\t\tblen = -1;", " this.colWidth = length;" ] }, { "added": [ " for (;;)" ], "header": "@@ -218,7 +229,7 @@ public final class ReaderToUTF8Stream", "removed": [ " do" ] } ] }, { "file": "java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java", "hunks": [ { "added": [ "", " int truncationLength = 0;" ], "header": "@@ -681,11 +681,10 @@ public abstract class EmbedPreparedStatement", "removed": [ " ", " LimitReader limitIn = new LimitReader(reader);", " ReaderToUTF8Stream utfIn = null;" ] } ] }, { "file": "java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java", "hunks": [ { "added": [ " ", " int truncationLength = 0;" ], "header": "@@ -2753,13 +2753,11 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ "", " LimitReader limitIn = new LimitReader(reader);", " ", " ReaderToUTF8Stream utfIn = null;" ] }, { "added": [ " if (usableLength > colWidth) { ", " truncationLength = usableLength - colWidth;", " }", " ReaderToUTF8Stream utfIn = new ReaderToUTF8Stream(", " reader, usableLength, truncationLength);", " " ], "header": "@@ -2781,20 +2779,15 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ " if (colWidth < length)", "", " // keep information with the stream about how much data", " // needs to be truncated, and colWidth info to give proper", " // truncation message", " utfIn = new ReaderToUTF8Stream(", " limitIn, colWidth, ((int) length) - usableLength);", " } else {", " utfIn = new ReaderToUTF8Stream(", " limitIn, usableLength, ((int)length) - usableLength);", " limitIn.setLimit(usableLength);" ] } ] } ]
derby-DERBY-438-581dc2b8
DERBY-438 (partial) Optimize Blob.length() to avoid reading the whole stream if the length is encoded in the stream from the store or the length has already been obtained once. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@397313 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java", "hunks": [ { "added": [ " // blob is either bytes or stream", " /*", " * Length of the BLOB if known. Set to -1 if", " * the current length of the BLOB is not known.", " */", " private long myLength = -1;", " " ], "header": "@@ -70,9 +70,15 @@ import java.io.IOException;", "removed": [ " // clob is either bytes or stream" ] }, { "added": [ " myLength = dvdBytes.length;" ], "header": "@@ -107,6 +113,7 @@ final class EmbedBlob extends ConnectionChild implements Blob", "removed": [] }, { "added": [ " if (myLength != -1)", " return myLength;", " ", " // we have a stream" ], "header": "@@ -208,12 +215,13 @@ final class EmbedBlob extends ConnectionChild implements Blob", "removed": [ " if (isBytes)", " return myBytes.length;", " // we have a stream" ] }, { "added": [ " // If possible get the length from the encoded", " // length at the front of the raw stream.", " if ((myLength = biStream.getLength()) != -1) {", " biStream.close();", " return myLength;", " }", " ", " // Otherwise have to read the entire stream!" ], "header": "@@ -221,6 +229,14 @@ final class EmbedBlob extends ConnectionChild implements Blob", "removed": [] }, { "added": [ " // Save for future uses.", " myLength = pos;", " biStream.close();" ], "header": "@@ -228,6 +244,9 @@ final class EmbedBlob extends ConnectionChild implements Blob", "removed": [] } ] } ]
derby-DERBY-438-5c205222
DERBY-438 (partial) Consistwnt handling of binary streams for updateXXX, namely check the length correctly if it is greater than the 2Gb supported by Derby. Add some comments to SQLBinary to clarify the format. Save the length when reading a binary stream from the store into an application, will be used in a subsequent checkin. Ensure eof handling when reading the binary value length in the on-disk format is handled correctly. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@393880 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/types/SQLBinary.java", "hunks": [ { "added": [ " Length is encoded to support Cloudscape 5.x databases where the length was stored as the number of bits.", " The first bit of the first byte indicates if the format is an old (Cloudscape 5.x) style or a new Derby style.", " Derby then uses the next two bits to indicate how the length is encoded.", " <LI> (5.x format zero) 4 byte Java format integer value 0 - either <raw data> is 0 bytes/bits or an unknown number of bytes.", " <LI> (5.x format bits) 4 byte Java format integer value >0 (positive) - number of bits in <raw data>, number of bytes in <raw data>", " <LI> (Derby format) 1 byte encoded length (0 <= L <= 31) - number of bytes of <raw data> - encoded = 0x80 & L", " <LI> (Derby format) 3 byte encoded length (32 <= L < 64k) - number of bytes of <raw data> - encoded = 0xA0 <L as Java format unsigned short>", " <LI> (Derby format) 5 byte encoded length (64k <= L < 2G) - number of bytes of <raw data> - encoded = 0xC0 <L as Java format integer>", " <BR>", " When the value was written from a byte array the Derby encoded byte", " length format was always used from Derby 10.0 onwards (ie. all open", " source versions).", " <BR>", " When the value was written from a stream (e.g. PreparedStatement.setBinaryStream)", " then the Cloudscape '5.x format zero' was used by 10.0 and 10.1.", " The was due to the class RawToBinaryFormatStream always writing", " four zero bytes for the length before the data.", " <BR>", " The Cloudscape '5.x format bits' format I think was never used by Derby." ], "header": "@@ -72,21 +72,32 @@ import java.sql.PreparedStatement;", "removed": [ " Length is encoded to support 5.x databases where the length was stored as the number of bits.", " The first bit of the first byte indicates if the format is an old (5.x) style or a new 8.1 style.", " 8.1 then uses the next two bits to indicate how the length is encoded.", " <LI> (5.x format) 4 byte Java format integer value 0 - either <raw data> is 0 bytes/bits or an unknown number of bytes.", " <LI> (5.x format) 4 byte Java format integer value >0 (positive) - number of bits in <raw data>, number of bytes in <raw data>", " <LI> (8.1 format) 1 byte encoded length (0 <= L <= 31) - number of bytes of <raw data> - encoded = 0x80 & L", " <LI> (8.1 format) 3 byte encoded length (32 <= L < 64k) - number of bytes of <raw data> - encoded = 0xA0 <L as Java format unsigned short>", " <LI> (8.1 format) 5 byte encoded length (64k <= L < 2G) - number of bytes of <raw data> - encoded = 0xC0 <L as Java format integer>" ] }, { "added": [ " /**", " * Read the encoded length of the value from the on-disk format.", " * ", " * @see SQLBinary", " */", "\t\t", "\t\tif (bl == -1)", " int len;" ], "header": "@@ -325,12 +336,18 @@ abstract class SQLBinary", "removed": [ "\t\tint len = 0;", "\t\tif (len < 0)" ] } ] }, { "file": "java/engine/org/apache/derby/impl/jdbc/BinaryToRawStream.java", "hunks": [ { "added": [ "\tSimply read and save the length information.", " /**", " * Length of the value represented by this stream.", " * Set to -1 if the length is unknown.", " */", " private int length;", "\tBinaryToRawStream(InputStream in, Object parent) ", "\t\tif (bl == -1)" ], "header": "@@ -29,27 +29,30 @@ import java.io.EOFException;", "removed": [ "\tSimply remove the length information.", "\tpublic BinaryToRawStream(InputStream in, Object parent) ", "\t\t// no need to calculate the actual length", "\t\t// int len = 0;", "\t\tif (bl < 0)" ] }, { "added": [ "\t\t\t\tif (v1 == -1 || v2 == -1 || v3 == -1 || v4 == -1)", " length = (((v1 & 0xff) << 24) |", " ((v2 & 0xff) << 16) |", " ((v3 & 0xff) << 8) |", " (v4 & 0xff));" ], "header": "@@ -61,9 +64,12 @@ extends java.io.FilterInputStream", "removed": [ "\t\t\t\tif (v1 < 0 || v2 < 0 || v3 < 0 || v4 < 0)", " //len = (((v1 & 0xff) << 24) | ((v2 & 0xff) << 16) | ((v3 & 0xff) << 8) | (v4 & 0xff));" ] }, { "added": [ "\t\t\t\tif (v1 == -1 || v2 == -1)", " length = (((v1 & 0xff) << 8) + (v2 & 0xff));", "\t\t\t\tlength = bl & 0x1F;" ], "header": "@@ -71,14 +77,14 @@ extends java.io.FilterInputStream", "removed": [ "\t\t\t\tif (v1 < 0 || v2 < 0)", " //len = (((v1 & 0xff) << 8) + (v2 & 0xff));", "\t\t\t\t// len = bl & 0x1F;" ] } ] }, { "file": "java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java", "hunks": [ { "added": [], "header": "@@ -2658,8 +2658,6 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ "\t\tif (length < 0) //we are doing the check here and not in updateBinaryStreamInternal becuase updateClob needs to pass -1 for length.", "\t\t\tthrow newSQLException(SQLState.NEGATIVE_STREAM_LENGTH);" ] }, { "added": [ "\tprivate void updateBinaryStreamInternal(int columnIndex,", "\t\t\t\t\t\tjava.io.InputStream x, long length, String updateMethodName)", " if (length < 0)", " throw newSQLException(SQLState.NEGATIVE_STREAM_LENGTH);", " ", " // max number of bytes that can be set to be inserted ", " // in Derby is 2Gb-1 (ie Integer.MAX_VALUE). ", " // (e.g into a blob column).", " if (length > Integer.MAX_VALUE ) {", " throw newSQLException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE,", " getColumnSQLType(columnIndex));", " }", " ", " try {", "\t\t\tgetDVDforColumnToBeUpdated(columnIndex, updateMethodName).setValue(", " new RawToBinaryFormatStream(x, (int) length), (int) length);" ], "header": "@@ -2670,12 +2668,24 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ "\tprotected void updateBinaryStreamInternal(int columnIndex,", "\t\t\t\t\t\tjava.io.InputStream x, int length, String updateMethodName)", "\t\ttry {", "\t\t\tgetDVDforColumnToBeUpdated(columnIndex, updateMethodName).setValue(new RawToBinaryFormatStream(x, length), length);" ] }, { "added": [ " private void updateCharacterStreamInternal(int columnIndex,", "\t\t\t\t\t\tjava.io.Reader reader, long length, String updateMethodName)", " ", " // check for -ve length here ", " if (length < 0) ", " throw newSQLException(SQLState.NEGATIVE_STREAM_LENGTH);", "", " // max number of characters that can be set to be inserted ", " // in Derby is 2Gb-1 (ie Integer.MAX_VALUE). ", " // (e.g into a CLOB column).", " if (length > Integer.MAX_VALUE ) {", " throw newSQLException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE,", " getColumnSQLType(columnIndex));", " } ", " int usableLength = (int) length;" ], "header": "@@ -2719,30 +2729,35 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ " protected void updateCharacterStreamInternal(int columnIndex,", "\t\t\t\t\t\tjava.io.Reader reader, int length, String updateMethodName)", " // currently the max number of chars that is allowed in update", " // via updateCharacterStream or updateClob interface", " // is Integer.MAX_INT ( 2Gb -1) for clobs.", " // check for -ve length here ", " if (length < 0) ", " throw newSQLException(SQLState.NEGATIVE_STREAM_LENGTH);", "", " int usableLength = length;" ] }, { "added": [ " limitIn, colWidth, ((int) length) - usableLength);", " limitIn, usableLength, ((int)length) - usableLength);", " utfIn, (int) usableLength);" ], "header": "@@ -2772,15 +2787,15 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ " limitIn, colWidth, length - usableLength);", " limitIn, usableLength, length - usableLength);", " utfIn, length);" ] }, { "added": [ " else {", " long length = x.length();", " updateBinaryStreamInternal(columnIndex, x.getBinaryStream(), length, \"updateBlob\");", " }" ], "header": "@@ -3881,8 +3896,10 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ " else", " updateBinaryStreamInternal(columnIndex, x.getBinaryStream(), -1, \"updateBlob\");" ] }, { "added": [ " ", " long length = x.length();" ], "header": "@@ -3931,23 +3948,8 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ "", " // 1. max number of characters that can be updated into a clob ", " // column is 2Gb-1 which is Integer.MAX_INT.", " // This means that we do not allow any updates of clobs where", " // clob.length() > Integer.MAX_INT. For now, we cast the x.length()", " // to int as a result. This will work ok for valid clob values that", " // derby supports. If we ever decide to increase these limits for ", " // clobs, in that case the cast of x.Length() to int would not be ", " // appropriate.", " //", " // 2. Note, x.length() needs to be called before retrieving the", " // stream using x.getCharacterStream() because EmbedClob.length()", " // will read from the stream and drain the stream.", " // Hence the need to declare this local variable to store the ", " // length. The cast from long to int, can make length -ve. The ", " // length will be checked later in updateCharacterStreamInternal", " int length = (int)x.length();" ] }, { "added": [ " ", " final String getColumnSQLType(int column)", " {", " return resultDescription.getColumnDescriptor(column)", " .getType().getTypeId().getSQLTypeName();", " }", "\tprivate final SQLException dataTypeConversion(String targetType, int column) {", " getColumnSQLType(column));", "\tprivate final SQLException dataTypeConversion(int column, String targetType) {", " getColumnSQLType(column), targetType);" ], "header": "@@ -4302,15 +4304,21 @@ public abstract class EmbedResultSet extends ConnectionChild", "removed": [ "\tprotected final SQLException dataTypeConversion(String targetType, int column) {", "\t\t\tresultDescription.getColumnDescriptor(column).getType().getTypeId().getSQLTypeName());", "\tprotected final SQLException dataTypeConversion(int column, String targetType) {", "\t\t\tresultDescription.getColumnDescriptor(column).getType().getTypeId().getSQLTypeName(), targetType);" ] } ] } ]
derby-DERBY-438-96b9662f
DERBY-438 (partial) Ensure internal conversions of JDBC objects to BLOBs provide the conversion using RawToBinaryFormatStream from the raw binary stream to the on-disk format stream as required by the data type api. Make RawToBinaryFormatStream encode the length of the value in the first bytes as defined in the format described in SQLBinary. Ensure the code handles this encoded lenght correctly. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@394109 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/types/RawToBinaryFormatStream.java", "hunks": [ { "added": [ "\tlength of the value.", " <P>", " If the length of the stream is known then it is encoded", " as the first bytes in the stream in the defined format.", " <BR>", " If the length is unknown then the first four bytes will", " be zero, indicating unknown length.", " <BR>", " ", " @see SQLBinary", "public final class RawToBinaryFormatStream extends LimitInputStream {", " /**", " * Number of bytes of length encoding.", " * ", " */", "\tprivate int encodedOffset;", " ", " /**", " * Encoding of the length in bytes which will be", " * seen as the first encodedLength.length bytes of", " * this stream.", " */", " private byte[] encodedLength;" ], "header": "@@ -31,13 +31,33 @@ import org.apache.derby.iapi.reference.SQLState;", "removed": [ "\tlength of the value. In this case 0 is always written.", "public class RawToBinaryFormatStream extends LimitInputStream {", "\tprivate int dummyBytes = 4;" ] }, { "added": [ "", " ", " if (length <= 31)", " {", " encodedLength = new byte[1]; ", " encodedLength[0] = (byte) (0x80 | (length & 0xff));", " }", " else if (length <= 0xFFFF)", " {", " encodedLength = new byte[3];", " encodedLength[0] = (byte) 0xA0;", " encodedLength[1] = (byte)(length >> 8);", " encodedLength[2] = (byte)(length); ", " }", " else", " {", " encodedLength = new byte[5];", " encodedLength[0] = (byte) 0xC0;", " encodedLength[1] = (byte)(length >> 24);", " encodedLength[2] = (byte)(length >> 16);", " encodedLength[3] = (byte)(length >> 8);", " encodedLength[4] = (byte)(length);", " }", " else", " {", " // unknown length, four zero bytes", " encodedLength = new byte[4];", " }" ], "header": "@@ -49,9 +69,37 @@ public class RawToBinaryFormatStream extends LimitInputStream {", "removed": [] }, { "added": [ "\t\tif (encodedOffset < encodedLength.length) {", " return encodedLength[encodedOffset++] & 0xff;", " \t\t}", "\t\tif (ret == -1)" ], "header": "@@ -65,14 +113,13 @@ public class RawToBinaryFormatStream extends LimitInputStream {", "removed": [ "\t\tif (dummyBytes != 0) {", "\t\t\tdummyBytes--;", "\t\t\treturn 0;", "\t\t}", "\t\tif (ret < 0)" ] }, { "added": [ "\t\t\tif (c != -1)" ], "header": "@@ -109,7 +156,7 @@ public class RawToBinaryFormatStream extends LimitInputStream {", "removed": [ "\t\t\tif (c >= 0)" ] } ] }, { "file": "java/engine/org/apache/derby/iapi/types/SQLBinary.java", "hunks": [ { "added": [ " ", " \t\t\t\tstream = null;" ], "header": "@@ -205,22 +205,14 @@ abstract class SQLBinary", "removed": [ "", "\t\t\t\t} else if ( stream instanceof NewByteArrayInputStream )", "\t\t\t\t{", "\t\t\t\t\t// this piece of code handles the case that a stream has been", "\t\t\t\t\t// opened on the bit value. the stream will have already called", "\t\t\t\t\t// readExternal() on the underlying FormatableBitSet. we just need to", "\t\t\t\t\t// retrieve the byte array from that stream.", "\t\t\t\t\tNewByteArrayInputStream\tnbais = (NewByteArrayInputStream) stream;", "\t\t\t\t\tdataValue = nbais.getData();", "\t\t\t\tstream = null;" ] }, { "added": [ " ", " byte li = (byte) bl;", "\t\tif ((li & ((byte) 0x80)) != 0)", "\t\t\tif (li == ((byte) 0xC0))", "\t\t\t{ ", " \t\t\t}", "\t\t\telse if (li == ((byte) 0xA0))", "\t\t\t\tlen = li & 0x1F;", " " ], "header": "@@ -346,25 +338,28 @@ abstract class SQLBinary", "removed": [ "\t\tif ((bl & 0x80) != 0)", "\t\t\tif (bl == 0xC0)", "\t\t\t{", "\t\t\t}", "\t\t\telse if (bl == 0xA0)", "\t\t\t\tlen = bl & 0x1F;" ] } ] }, { "file": "java/engine/org/apache/derby/iapi/types/SQLBlob.java", "hunks": [ { "added": [ "\t * @throws StandardException ", "\t\tthrows SQLException, StandardException", " Blob blob = resultSet.getBlob(colNumber);", " if (blob == null)", " setToNull();", " else", " setObject(blob);" ], "header": "@@ -164,14 +164,17 @@ public class SQLBlob extends SQLBinary", "removed": [ "\t\tthrows SQLException", "\t\t\tstream = resultSet.getBinaryStream(colNumber);", "\t\t\tstreamValueLength = -1; // unknown", "\t\t\tdataValue = null;" ] }, { "added": [ " ", " long vbl = vb.length();", " if (vbl < 0L || vbl > Integer.MAX_VALUE)", " throw this.outOfRange();", " ", " setValue(new RawToBinaryFormatStream(", " vb.getBinaryStream(), (int) vbl),", " (int) vbl);", " " ], "header": "@@ -205,13 +208,19 @@ public class SQLBlob extends SQLBinary", "removed": [ " stream = vb.getBinaryStream();", " streamValueLength = -1; // unknown", " dataValue = null;" ] } ] } ]
derby-DERBY-438-c56ecebc
DERBY-438 (partial) Move RawToBinaryStreamFormat.java from org.apache.derby.impl.jdbc to org.apache.derby.iapi.types to allow its use in SQLBlob and SQLBinary (in a future commit). This will allow the setting of the internal binary types from JDBC objects in a consistent manner. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@393579 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/iapi/types/RawToBinaryFormatStream.java", "hunks": [ { "added": [ " Derby - Class org.apache.derby.iapi.types.RawToBinaryFormatStream" ], "header": "@@ -1,6 +1,6 @@", "removed": [ " Derby - Class org.apache.derby.impl.jdbc.RawToBinaryFormatStream" ] }, { "added": [ "package org.apache.derby.iapi.types;" ], "header": "@@ -18,10 +18,9 @@", "removed": [ "package org.apache.derby.impl.jdbc;", "import java.io.FilterInputStream;" ] }, { "added": [ "\tto the on-disk format of the binary types by prepending the", "public class RawToBinaryFormatStream extends LimitInputStream {" ], "header": "@@ -31,12 +30,12 @@ import org.apache.derby.iapi.reference.SQLState;", "removed": [ "\tto the format of the binary types by prepending the", "class RawToBinaryFormatStream extends LimitInputStream {" ] } ] }, { "file": "java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.types.RawToBinaryFormatStream;" ], "header": "@@ -38,6 +38,7 @@ import org.apache.derby.iapi.sql.Activation;", "removed": [] } ] } ]
derby-DERBY-438-ed90c539
DERBY-438 (partial) Add statement trigger tests involving selecting large CLOB values. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@410702 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4380-d491ea3c
DERBY-4380: Subqueries not allowed in ON clause Removed the check that disallowed subqueries in ON clauses. Also removed the double binding of the ON clause in JoinNode since it made the query tree inconsistent for some kinds of subqueries. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@882106 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/JoinNode.java", "hunks": [ { "added": [], "header": "@@ -799,40 +799,13 @@ public class JoinNode extends TableOperatorNode", "removed": [ "\t\t\t/* First bind with all tables in the from clause, to detect ambiguous", "\t\t\t * references. Push the left and right children to the front of the", "\t\t\t * fromListParam before binding the join clause. (We will", "\t\t\t * remove it before returning.) Valid column references in", "\t\t\t * the join clause are limited to columns from the 2 tables being", "\t\t\t * joined", "\t\t\t */", "\t\t\tfromListParam.insertElementAt(rightResultSet, 0);", "\t\t\tfromListParam.insertElementAt(leftResultSet, 0);", "\t\t\t\t\t\t\t\t\t fromListParam, subqueryList,", "\t\t\t\t\t\t\t\t\t aggregateVector);", "", "\t\t\t/* Now bind with two tables being joined. If this raises column not found exception,", "\t\t\t * then we have a reference to other tables in the from clause. Raise invalid", "\t\t\t * ON clause error to match DB2.", "\t\t\t */", "\t\t\ttry {", "\t\t\t\tjoinClause = joinClause.bindExpression(", "\t\t\t} catch (StandardException se) {", "\t\t\t\tif (se.getSQLState().equals(SQLState.LANG_COLUMN_NOT_FOUND))", "\t\t\t\t\tthrow StandardException.newException(SQLState.LANG_DB2_ON_CLAUSE_INVALID); ", "\t\t\t\tthrow se;", "\t\t\t}", "", "\t\t\t/* DB2 doesn't allow subquerries in the ON clause */", "\t\t\tif (subqueryList.size() > 0)", "\t\t\t\tthrow StandardException.newException(SQLState.LANG_DB2_ON_CLAUSE_INVALID); " ] } ] } ]
derby-DERBY-4381-894a72f1
DERBY-4381; Connection to Derby database using jar subprotocol doesn't work if the path has round braket in it adding a test and changing search for matching bracket to be from the last occurrence. fix suggested by Rafael Soares (rafael dot enq at gmail dot com) git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1602054 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/io/JarStorageFactory.java", "hunks": [ { "added": [ "import org.apache.derby.iapi.services.info.JVMInfo;" ], "header": "@@ -25,6 +25,7 @@ import java.io.File;", "removed": [] } ] } ]
derby-DERBY-4381-d54c775b
DERBY-4381; Connection to Derby database using jar subprotocol doesn't work if the path has round bracket in it fixing formatting, comments, and removing an unnecessary import git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1602232 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4387-54d942e9
DERBY-4387 Infinite loop in PredicateList.joinClauseTransitiveClosure() This patch, derby-4387, fixes a corner case of the closure code in which the outer and the inner table is the same. This led to adding the same, new predicate twice to the same table, causing the infinite loop. The patch also adds a test case, which, without the fix, shows the infinite loop. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@887246 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4388-f8d48a3c
DERBY-4388: NullPointerException in RIGHT JOIN with NOT BETWEEN Clone the left operand when performing not-elimination in BetweenOperatorNode to prevent ColumnReferences from being shared, as they can be remapped during optimization. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@822289 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4393-c4caf0a6
DERBY-4393 - lang.SequenceTest fails w/ "Sequence 'ALPHA_SEQ' already exists." on phoneME/cvm. Do cleanup in testcases to make the testcases independent of running order. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@822641 13f79535-47bb-0310-9956-ffa450edef68
[]
derby-DERBY-4397-2060c4a6
DERBY-4397 Allow ORDER BY in subqueries Patch derby-4397-2 which implements this functionality and also adds a new test, OrderByInSubqueries. This patch also solves DERBY-4. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@891952 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java", "hunks": [ { "added": [ "\tprivate OrderByList orderByList;" ], "header": "@@ -68,7 +68,7 @@ public class CreateViewNode extends DDLStatementNode", "removed": [ "" ] }, { "added": [ "\t * @param orderCols ORDER BY list" ], "header": "@@ -80,6 +80,7 @@ public class CreateViewNode extends DDLStatementNode", "removed": [] }, { "added": [ "\t\t\t\t Object qeText,", "\t\t\t\t Object orderCols)" ], "header": "@@ -88,7 +89,8 @@ public class CreateViewNode extends DDLStatementNode", "removed": [ "\t\t\t\t Object qeText)" ] }, { "added": [ "\t\tthis.orderByList = (OrderByList)orderCols;" ], "header": "@@ -96,6 +98,7 @@ public class CreateViewNode extends DDLStatementNode", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java", "hunks": [ { "added": [ "\tstatic void\tbindRowScopedExpression" ], "header": "@@ -677,7 +677,7 @@ abstract class DMLModStatementNode extends DMLStatementNode", "removed": [ "\tvoid\tbindRowScopedExpression" ] }, { "added": [ "\t/**", "\t * Prints the sub-nodes of this object. See QueryTreeNode.java for", "\t * how tree printing is supposed to work.", "\t *", "\t * @param depth\t\tThe depth of this node in the tree", "\t */", "", "\tpublic void printSubNodes(int depth)", "\t{", "\t\tif (SanityManager.DEBUG)", "\t\t{", "\t\t\tsuper.printSubNodes(depth);", "", "\t\t\tprintLabel(depth, \"targetTableName: \");", "\t\t\ttargetTableName.treePrint(depth + 1);", "", "\t\t\tif (resultColumnList != null)", "\t\t\t{", "\t\t\t\tprintLabel(depth, \"resultColumnList: \");", "\t\t\t\tresultColumnList.treePrint(depth + 1);", "\t\t\t}", "\t\t}", "\t}", "" ], "header": "@@ -1914,6 +1914,30 @@ abstract class DMLModStatementNode extends DMLStatementNode", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java", "hunks": [ { "added": [ "", "", "\t\t\t\tOrderByList orderByList = cvn.getOrderByList();", "" ], "header": "@@ -2237,12 +2237,14 @@ public class FromBaseTable extends FromTable", "removed": [ "\t", "\t" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java", "hunks": [ { "added": [ "\tprivate OrderByList orderByList;" ], "header": "@@ -46,6 +46,7 @@ import org.apache.derby.iapi.util.JBitSet;", "removed": [] }, { "added": [ "\t * @param orderByList ORDER BY list if any, or null", "\t\t\t\t\tObject orderByList,", "\t\tthis.orderByList = (OrderByList)orderByList;" ], "header": "@@ -57,18 +58,21 @@ public class FromSubquery extends FromTable", "removed": [] }, { "added": [ "", "\t\t\tif (orderByList != null)", "\t\t\t{", "\t\t\t\tprintLabel(depth, \"orderByList: \");", "\t\t\t\torderByList.treePrint(depth + 1);", "\t\t\t}" ], "header": "@@ -89,6 +93,12 @@ public class FromSubquery extends FromTable", "removed": [] }, { "added": [ "\t\tif (orderByList != null) {", "\t\t\torderByList.pullUpOrderByColumns(subquery);", "\t\t}", "" ], "header": "@@ -200,7 +210,10 @@ public class FromSubquery extends FromTable", "removed": [ "\t\t" ] }, { "added": [ "\t\tif (orderByList != null) {", "\t\t\torderByList.bindOrderByColumns(subquery);", "\t\t}", "" ], "header": "@@ -219,6 +232,10 @@ public class FromSubquery extends FromTable", "removed": [] }, { "added": [ "\t\t// Push the order by list down to the ResultSet", "\t\tif (orderByList != null)", "\t\t{", "\t\t\t// If we have more than 1 ORDERBY columns, we may be able to", "\t\t\t// remove duplicate columns, e.g., \"ORDER BY 1, 1, 2\".", "\t\t\tif (orderByList.size() > 1)", "\t\t\t{", "\t\t\t\torderByList.removeDupColumns();", "\t\t\t}", "", "\t\t\tsubquery.pushOrderByList(orderByList);", "\t\t\torderByList = null;", "\t\t}", "", "\t\t * Another complication is that we want to be able to only push" ], "header": "@@ -325,13 +342,27 @@ public class FromSubquery extends FromTable", "removed": [ "\t\t * Another complication is that we want to be able to only only push" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/InsertNode.java", "hunks": [ { "added": [ "\tprivate OrderByList orderByList;" ], "header": "@@ -110,6 +110,7 @@ public final class InsertNode extends DMLModStatementNode", "removed": [] }, { "added": [ " * @param orderByList The order by list for the source result set, null if", "\t *\t\t\tno order by list", "\t\t\tObject targetProperties,", " Object orderByList)" ], "header": "@@ -124,13 +125,16 @@ public final class InsertNode extends DMLModStatementNode", "removed": [ "\t\t\tObject targetProperties)" ] }, { "added": [ "\t\tthis.orderByList = (OrderByList) orderByList;" ], "header": "@@ -144,6 +148,7 @@ public final class InsertNode extends DMLModStatementNode", "removed": [] }, { "added": [ "\t\t\tif (orderByList != null) {", "\t\t\t\tprintLabel(depth, \"orderByList: \");", "\t\t\t\torderByList.treePrint(depth + 1);", "\t\t\t}", "" ], "header": "@@ -206,6 +211,11 @@ public final class InsertNode extends DMLModStatementNode", "removed": [] }, { "added": [ "\t\t// Bind the ORDER BY columns", "\t\tif (orderByList != null)", "\t\t{", "\t\t\torderByList.pullUpOrderByColumns(resultSet);", "", "\t\t\t// The select list may have new columns now, make sure to bind", "\t\t\t// those.", "\t\t\tsuper.bindExpressions();", "", "\t\t\torderByList.bindOrderByColumns(resultSet);", "\t\t}", "" ], "header": "@@ -421,6 +431,18 @@ public final class InsertNode extends DMLModStatementNode", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/OrderByList.java", "hunks": [ { "added": [ "\tprivate int resultSetNumber = -1;" ], "header": "@@ -76,6 +76,7 @@ public class OrderByList extends OrderedColumnList", "removed": [] }, { "added": [ "\t *\tBind the update columns by their names to the target resultset of the", "\t * cursor specification. This variant is used by InsertNode.", "\t *", "\t * \t@param target\tThe underlying result set", "\t *\t@exception StandardException\t\tThrown on error" ], "header": "@@ -112,12 +113,11 @@ public class OrderByList extends OrderedColumnList", "removed": [ "\t\tBind the update columns by their names to the target resultset", "\t\tof the cursor specification.", "", "\t\t@param target\tThe underlying result set", "\t", "\t\t@exception StandardException\t\tThrown on error" ] }, { "added": [ "" ], "header": "@@ -149,7 +149,7 @@ public class OrderByList extends OrderedColumnList", "removed": [ "\t" ] }, { "added": [ "\t\tresultSetNumber = cc.getNextResultSetNumber();" ], "header": "@@ -387,7 +387,7 @@ public class OrderByList extends OrderedColumnList", "removed": [ "\t\tint resultSetNumber = cc.getNextResultSetNumber();" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java", "hunks": [ { "added": [ "\t/**", "\t * Print call stack for debug purposes", "\t */", "", "\tpublic void stackPrint()", "\t{", "\t\tif (SanityManager.DEBUG)", "\t\t{", "\t\t\tdebugPrint(\"Stacktrace:\\n\");", "\t\t\tException e = new Exception(\"dummy\");", " StackTraceElement[] st= e.getStackTrace();", " for (int i=0; i<st.length; i++) {", " debugPrint(st[i] + \"\\n\");", " }", "", "\t\t\tdebugFlush();", "\t\t}", "\t}", "" ], "header": "@@ -342,6 +342,25 @@ public abstract class QueryTreeNode implements Visitable", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java", "hunks": [ { "added": [ "\t\t\t if ((! countMismatchAllowed) && visibleSize() != nameList.size())", "\t\t\t\t\t\"The size of the 2 lists is expected to be the same. \" +", "\t\t\t\t\t\"visibleSize() = \" + visibleSize() +", "\t\t\t\t\t\", nameList.size() = \" + nameList.size());", "\t\tint size = (countMismatchAllowed) ? nameList.size() : visibleSize();" ], "header": "@@ -646,15 +646,16 @@ public class ResultColumnList extends QueryTreeNodeVector", "removed": [ "\t\t\t if ((! countMismatchAllowed) && size() != nameList.size())", "\t\t\t\t\t\"The size of the 2 lists is expected to be the same. size() = \" +", "\t\t\t\t\tsize() + \", nameList.size() = \" + nameList.size());", "\t\tint size = (countMismatchAllowed) ? nameList.size() : size();" ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java", "hunks": [ { "added": [ "\t\tif (!inOrder ||", " resultColumns.visibleSize() < target.resultColumnList.size()) {" ], "header": "@@ -935,7 +935,8 @@ public abstract class ResultSetNode extends QueryTreeNode", "removed": [ "\t\tif (!inOrder || resultColumns.size() < target.resultColumnList.size()) {" ] }, { "added": [ "\tprivate ResultColumn genNewRCForInsert(TableDescriptor targetTD," ], "header": "@@ -1001,7 +1002,7 @@ public abstract class ResultSetNode extends QueryTreeNode", "removed": [ "\tResultColumn genNewRCForInsert(TableDescriptor targetTD," ] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/SelectNode.java", "hunks": [ { "added": [ "\t * o It does not have an ORDER BY clause (pushed from FromSubquery)." ], "header": "@@ -1342,6 +1342,7 @@ public class SelectNode extends ResultSetNode", "removed": [] }, { "added": [ "\t\t/* Don't flatten if selectNode now has an order by */", "\t\tif ((orderByList != null) &&", "\t\t\t (orderByList.size() > 0))", "\t\t{", "\t\t\treturn false;", "\t\t}", "" ], "header": "@@ -1385,6 +1386,13 @@ public class SelectNode extends ResultSetNode", "removed": [] } ] }, { "file": "java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java", "hunks": [ { "added": [ "\tprivate OrderByList orderByList;", "" ], "header": "@@ -166,6 +166,8 @@ public class SubqueryNode extends ValueNode", "removed": [] }, { "added": [ "\t * @param orderCols ORDER BY list", "\t\t\t\t\t\t\tObject leftOperand,", "\t\t\t\t\t Object orderCols)", "\t\tthis.orderByList = (OrderByList)orderCols;" ], "header": "@@ -201,15 +203,18 @@ public class SubqueryNode extends ValueNode", "removed": [ "\t\t\t\t\t\t\tObject leftOperand)" ] }, { "added": [ "", "\t\t\tif (orderByList != null)", "\t\t\t{", "\t\t\t\tprintLabel(depth, \"orderByList: \");", "\t\t\t\torderByList.treePrint(depth + 1);", "\t\t\t}" ], "header": "@@ -269,6 +274,12 @@ public class SubqueryNode extends ValueNode", "removed": [] }, { "added": [ "\t\tif (orderByList != null) {", "\t\t\torderByList.pullUpOrderByColumns(resultSet);", "\t\t}", "", "\t\tif (orderByList != null) {", "\t\t\torderByList.bindOrderByColumns(resultSet);", "\t\t}", "" ], "header": "@@ -504,11 +515,19 @@ public class SubqueryNode extends ValueNode", "removed": [] }, { "added": [ "\t\t\t orderByList == null &&" ], "header": "@@ -625,6 +644,7 @@ public class SubqueryNode extends ValueNode", "removed": [] }, { "added": [ "\t\t\t orderByList == null &&" ], "header": "@@ -694,6 +714,7 @@ public class SubqueryNode extends ValueNode", "removed": [] }, { "added": [ "\t\t// Push the order by list down to the ResultSet", "\t\tif (orderByList != null) {", "\t\t\t// If we have more than 1 ORDERBY columns, we may be able to", "\t\t\t// remove duplicate columns, e.g., \"ORDER BY 1, 1, 2\".", "\t\t\tif (orderByList.size() > 1)", "\t\t\t{", "\t\t\t\torderByList.removeDupColumns();", "\t\t\t}", "", "\t\t\tresultSet.pushOrderByList(orderByList);", "\t\t\torderByList = null;", "\t\t}", "", "" ], "header": "@@ -788,6 +809,20 @@ public class SubqueryNode extends ValueNode", "removed": [] } ] } ]
derby-DERBY-4397-7b48c50b
DERBY-4397 Allow ORDER BY in subqueries Patch derby-4397-sortavoidance-a, which makes sort avoidance work in the simple case of a subquery with order by on a base table which has a suitable index. The fix avoids the result columns assumed by the order by list from changing after they have been bound, to include a level of VCNs, which is not correct (this happened as a side effect of copying result columns from the subquery up to the FromSubquery node). A new test case the verify sort avoidance in this case has been added. git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@899588 13f79535-47bb-0310-9956-ffa450edef68
[ { "file": "java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java", "hunks": [ { "added": [ " /* NOTE: If the size of the derived column list is less than" ], "header": "@@ -258,12 +258,7 @@ public class FromSubquery extends FromTable", "removed": [ "\t\t/* Now that we've bound the expressions in the subquery, we ", "\t\t * can propagate the subquery's RCL up to the FromSubquery.", "\t\t * Get the subquery's RCL, assign shallow copy back to", "\t\t * it and create new VirtualColumnNodes for the original's", "\t\t * ResultColumn.expressions.", "\t\t * NOTE: If the size of the derived column list is less than" ] } ] } ]