db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1365695 - in /db/derby/code/branches/10.5: ./ java/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/SystemCatalogTest.java
Date Wed, 25 Jul 2012 18:54:58 GMT
Author: mamta
Date: Wed Jul 25 18:54:57 2012
New Revision: 1365695

URL: http://svn.apache.org/viewvc?rev=1365695&view=rev
Log:
DERBY-5407 When run across the network, dblook produces unusable DDL for VARCHAR FOR BIT DATA
columns.

Backporting only the test from 10.6 to 10.5. The bug doesn't exist in 10.5 but there is no
test code coverage for SYSCOLUMNS.COLUMNDATATYPE in 10.5 and hence putting the test in 10.5

Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/   (props changed)
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SystemCatalogTest.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
  Merged /db/derby/code/branches/10.6:r1365674
  Merged /db/derby/code/trunk:r1364690

Propchange: db/derby/code/branches/10.5/java/
------------------------------------------------------------------------------
  Merged /db/derby/code/branches/10.6/java:r1365674

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SystemCatalogTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SystemCatalogTest.java?rev=1365695&r1=1365694&r2=1365695&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SystemCatalogTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SystemCatalogTest.java
Wed Jul 25 18:54:57 2012
@@ -25,6 +25,9 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.ResultSet;
+import java.sql.Types;
+
+import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.TestConfiguration;
@@ -40,7 +43,7 @@ import junit.framework.TestSuite;
  */
 public class SystemCatalogTest extends BaseJDBCTestCase {
 
-	public SystemCatalogTest(String name) {
+    public SystemCatalogTest(String name) {
 		super(name);
 	}
 	
@@ -531,6 +534,113 @@ public class SystemCatalogTest extends B
 		s.execute("drop table uniquekey3");
 		s.close();
 	}
+
+	/**
+	 * This test creates a table with all supported datatypes aqnd ensures 
+	 * that bound embedded and network server return the identical datatypes
+	 * for those datatypes. DERBY-5407
+	 * @throws SQLException
+	 */
+	public void testColumnDatatypesOfAllDataTypesInSystemCatalogs() throws SQLException {
+		int totalNumOfColumnDatatypes = 21;
+		Statement s = createStatement();
+		s.execute("create table allTypesTable (" +
+			"    a01 bigint," +
+			"    a02 blob,\n" +
+			"    a03 char( 1 ),\n" +
+			"    a04 char( 1 ) for bit data ,\n" +
+			"    a05 clob,\n" +
+			"    a06 date,\n" +
+			"    a07 decimal,\n" +
+			"    a08 double,\n" +
+			"    a09 float,\n" +
+			"    a10 int,\n" +
+			"    a11 long varchar,\n" +
+			"    a12 long varchar for bit data,\n" +
+			"    a13 numeric,\n" +
+			"    a14 real,\n" +
+			"    a15 smallint,\n" +
+			"    a16 time,\n" +
+			"    a17 timestamp,\n" +
+			"    a18 varchar(10),\n" +
+			"    a19 varchar(10) for bit data,\n" +
+			"    a20 xml\n" +
+        	")");
+		ResultSet rs = s.executeQuery("select columndatatype "+
+			"from sys.systables, sys.syscolumns "+
+			"where tablename='ALLTYPESTABLE' "+
+			"and tableid=referenceid "+
+			"order by columnname");
+		for (int i=1; i<=totalNumOfColumnDatatypes; i++)
+		{
+			rs.next();
+			switch(i)
+			{
+			case 1 :
+				assertTrue(rs.getString(1).startsWith("BIGINT"));
+				break;
+			case 2 :
+				assertTrue(rs.getString(1).startsWith("BLOB(2147483647)"));
+				break;
+			case 3 :
+				assertTrue(rs.getString(1).startsWith("CHAR(1)"));
+				break;
+			case 4 :
+				assertTrue(rs.getString(1).startsWith("CHAR (1) FOR BIT DATA"));
+				break;
+			case 5 :
+				assertTrue(rs.getString(1).startsWith("CLOB(2147483647)"));
+				break;
+			case 6 :
+				assertTrue(rs.getString(1).startsWith("DATE"));
+				break;
+			case 7 :
+				assertTrue(rs.getString(1).startsWith("DECIMAL(5,0)"));
+				break;
+			case 8 :
+				assertTrue(rs.getString(1).startsWith("DOUBLE"));
+				break;
+			case 9 :
+				assertTrue(rs.getString(1).startsWith("DOUBLE"));
+				break;
+			case 10 :
+				assertTrue(rs.getString(1).startsWith("INTEGER"));
+				break;
+			case 11 :
+				assertTrue(rs.getString(1).startsWith("LONG VARCHAR"));
+				break;
+			case 12 :
+				assertTrue(rs.getString(1).startsWith("LONG VARCHAR FOR BIT DATA"));
+				break;
+			case 13 :
+				assertTrue(rs.getString(1).startsWith("NUMERIC(5,0)"));
+				break;
+			case 14 :
+				assertTrue(rs.getString(1).startsWith("REAL"));
+				break;
+			case 15 :
+				assertTrue(rs.getString(1).startsWith("SMALLINT"));
+				break;
+			case 16 :
+				assertTrue(rs.getString(1).startsWith("TIME"));
+				break;
+			case 17 :
+				assertTrue(rs.getString(1).startsWith("TIMESTAMP"));
+				break;
+			case 18 :
+				assertTrue(rs.getString(1).startsWith("VARCHAR(10)"));
+				break;
+			case 19 :
+				assertTrue(rs.getString(1).startsWith("VARCHAR (10) FOR BIT DATA"));
+				break;
+			case 20 :
+				assertTrue(rs.getString(1).startsWith("XML"));
+				break;
+			}
+		}
+		rs.close();
+		s.execute("drop table ALLTYPESTABLE");
+	}
 	
 	/**
 	 * Check that column datatypes are reported correctly, both in



Mime
View raw message