Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 81137 invoked from network); 5 Sep 2007 05:50:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Sep 2007 05:50:56 -0000 Received: (qmail 64894 invoked by uid 500); 5 Sep 2007 05:50:51 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 64861 invoked by uid 500); 5 Sep 2007 05:50:51 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 64850 invoked by uid 99); 5 Sep 2007 05:50:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2007 22:50:51 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Sep 2007 05:50:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7D8901A9832; Tue, 4 Sep 2007 22:50:35 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r572880 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/conn/ testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/ Date: Wed, 05 Sep 2007 05:50:34 -0000 To: derby-commits@db.apache.org From: mamta@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070905055035.7D8901A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mamta Date: Tue Sep 4 22:50:34 2007 New Revision: 572880 URL: http://svn.apache.org/viewvc?rev=572880&view=rev Log: DERBY-2946 The character string literals take their collation from the current compilation schema. Derby's metadata queries have lots of comparisons where a character string literal is compared with a character string column from SYS schema. The character string columns from SYS schema have the collation of UCS_BASIC. If the metadata queries get run with user schema as current compilation schema, then the character string constants in metadata queries will get a collation of territory based and this mismatch in collation of character string constants and character string columns will cause the metadata queries to fail. This situation can arise in the current softupgrade code. In softupgrade mode, we do not ensure that the current compilation schema is SYS schema. A simple change in GenericLanguageConnectionContext(GLCC) takes care of that problem. In GLCC, with this checkin, we check if the query being executed is a metadata query and if yes, then we should set the current compilation s chema to be SYS schema for that metadata query execution. This takes care of the soft upgrade problem. Outside of soft upgrade mode, we do not have problems with metadata queries because during a normal run/hard upgrade, we go to SYSSTATEMENTS to run metadata queries and that code path ensures that the current compilation schema is SYS schema. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_4.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=572880&r1=572879&r2=572880&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java Tue Sep 4 22:50:34 2007 @@ -750,6 +750,15 @@ public PreparedStatement prepareInternalStatement(SchemaDescriptor compilationSchema, String sqlText, boolean isForReadOnly, boolean forMetaData) throws StandardException { + if (forMetaData) { + //DERBY-2946 + //Make sure that metadata queries always run with SYS as + //compilation schema. This will make sure that the collation + //type of character string constants will be UCS_BASIC which + //is also the collation of character string columns belonging + //to system tables. + compilationSchema = getDataDictionary().getSystemSchemaDescriptor(); + } return connFactory.getStatement(compilationSchema, sqlText, isForReadOnly).prepare(this, forMetaData); } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_4.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_4.java?rev=572880&r1=572879&r2=572880&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_4.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_4.java Tue Sep 4 22:50:34 2007 @@ -42,6 +42,26 @@ *
10.4 Upgrade issues +
    +
  • testMetaDataQueryRunInSYScompilationSchema - DERBY-2946 + Make sure that metadata queries get run with SYS schema as the current + compilation schema rather than a user schema as the current compilation + schema. This is because if the user is inside a user schema in a collated + database and if the meta data query gets run inside the user schema, then + we will run into collation mismatch errors for a subclause like following + in the WHERE clause. + P.SELECTPRIV = 'Y' + The reason for error is that the left hand side of the = operation will + have collation type of UCS_BASIC because that column belongs to a table + from system schema. But the collation type of the right hand will be + territory based if the current compilation schema is user schema. But if + the current compilation schema is set to SYS schema, then right hand side + will also have collation of UCS_BASIC and hence there won't be any + collation mismatch. + Background info : character string constants pick up the collation of the + current compilation schema. +
+ */ public class Changes10_4 extends UpgradeChange { @@ -63,11 +83,51 @@ } /** - * Just a place holder until we add actual tests. + * Check that even though we have set schema to a user schema, the + * metadata queries get run with compilation schema as SYS. + * DERBY-2946 + * Test added for 10.4. * @throws SQLException * */ - public void testRemoveMeAfterRealTestIsAdded() throws SQLException + public void testMetaDataQueryRunInSYScompilationSchema() throws SQLException { + //This test is for databases with territory based collation. That + //feature was added in 10.3 codeline and hence there is no point in + //doing any testing with pre-10.3 databases. + if (!oldAtLeast(10, 3)) + return; + + DataSource ds = JDBCDataSource.getDataSourceLogical("COLLATED_DB_10_3"); + + switch (getPhase()) + { + case PH_CREATE: + // create the database if it was not already created. Note the + // JDBC url attributes. + JDBCDataSource.setBeanProperty( + ds, "ConnectionAttributes", "create=true;territory=no;collation=TERRITORY_BASED"); + ds.getConnection().close(); + break; + + case PH_SOFT_UPGRADE: + case PH_POST_SOFT_UPGRADE: + case PH_HARD_UPGRADE: + case PH_POST_HARD_UPGRADE: + Connection con = ds.getConnection(); + //First make the current schema as a user schema. And then run a + //metadata query to make sure that it runs fine. If it does (which + //is the expected behavior), then it will mean that the metadata + //query is getting run with SYS as the compilation schema rather + //than the current schema which is APP. + Statement s = con.createStatement(); + s.execute("SET SCHEMA APP"); + + DatabaseMetaData dmd = con.getMetaData(); + ResultSet rs = dmd.getTables(null,"APP",null,null); + JDBC.assertDrainResults(rs); + s.close(); + break; + } } } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?rev=572880&r1=572879&r2=572880&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java Tue Sep 4 22:50:34 2007 @@ -67,6 +67,7 @@ * The databases are shutdown at the end of each phase. */ static final String[] ADDITIONAL_DBS = { + "COLLATED_DB_10_3",//db with territory based collation "NO_ENCRYPT_10_2", "ENCRYPT_10_2" }; Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java?rev=572880&r1=572879&r2=572880&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java Tue Sep 4 22:50:34 2007 @@ -112,7 +112,7 @@ {10, 1, 3, 1}, // 10.1.3.1 (Jun 30, 2006 / SVN 417277) {10, 2, 1, 6}, // 10.2.1.6 (Oct 02, 2006 / SVN 452058) {10, 2, 2, 0}, // 10.2.2.0 (Dec 12, 2006 / SVN 485682) - {10, 3, 1, 4}, // 10.3.1.4 (Aug 30, 2007 / SVN 571336) + {10, 3, 1, 4}, // 10.3.1.4 (Aug 1, 2007 / SVN 561794) }; /**