db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From banda...@apache.org
Subject svn commit: r190182 - in /incubator/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/ testing/org/apache/derbyTesting/functionTests/tests/lang/ testing/org/apache/derbyTesting/functionTests/tests/tools/
Date Sat, 11 Jun 2005 23:39:45 GMT
Author: bandaram
Date: Sat Jun 11 16:39:44 2005
New Revision: 190182

URL: http://svn.apache.org/viewcvs?rev=190182&view=rev
Log:
Add more tests for synonym and also set implicitCreateSchema to true.

Submitted by Satheesh Bandaram (satheesh@sourcery.org)

Modified:
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java?rev=190182&r1=190181&r2=190182&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java
Sat Jun 11 16:39:44 2005
@@ -201,6 +201,7 @@
 
 			case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
 				String targetSchema;
+				implicitCreateSchema = true;
 				TableName t = (TableName) targetObject;
 				if (t.getSchemaName() != null)
 					targetSchema = t.getSchemaName();
@@ -257,13 +258,8 @@
 						this.getFullName(),
 						targetSchema+"."+targetTable);
 
-		// Raise error if targetSchema doesn't exists
-		SchemaDescriptor targetSD = getSchemaDescriptor(targetSchema);
-
-		// Synonym can't be defined on temporary tables.
-		TableDescriptor targetTD = getTableDescriptor(targetTable, targetSD);
-		if (targetTD != null &&
-			targetTD.getTableType() == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE)
+		SchemaDescriptor targetSD = getSchemaDescriptor(targetSchema, false);
+		if ((targetSD != null) && isSessionSchema(targetSD))
 			throw StandardException.newException(SQLState.LANG_OPERATION_NOT_ALLOWED_ON_SESSION_SCHEMA_TABLES);
 
 		return this;

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out?rev=190182&r1=190181&r2=190182&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out
Sat Jun 11 16:39:44 2005
@@ -216,6 +216,54 @@
 0 rows inserted/updated/deleted
 ij> drop synonym synPrimary;
 0 rows inserted/updated/deleted
+ij> -- Tests with non existant schemas
+----- Implicitly creates junkSchema
+create synonym junkSchema.syn1 for table2;
+0 rows inserted/updated/deleted
+WARNING 01522: The newly defined synonym 'SYN1' resolved to the object 'JUNKSCHEMA.TABLE2'
which is currently undefined. : 
+ij> select * from junkSchema.syn1;
+ERROR 42X05: Table 'JUNKSCHEMA.TABLE2' does not exist.
+ij> set schema junkSchema;
+0 rows inserted/updated/deleted
+ij> create table table2(c char(10));
+0 rows inserted/updated/deleted
+ij> select * from syn1;
+C         
+-----
+ij> set schema APP;
+0 rows inserted/updated/deleted
+ij> -- Should resolve to junkSchema.table2
+select * from junkSchema.syn1;
+C         
+-----
+ij> drop table junkSchema.table2;
+0 rows inserted/updated/deleted
+ij> -- Should fail. Need to drop synonym first
+drop schema junkSchema restrict;
+ERROR X0Y54: Schema 'JUNKSCHEMA' cannot be dropped because it is not empty.
+ij> drop synonym junkSchema.syn1;
+0 rows inserted/updated/deleted
+ij> drop schema junkSchema restrict;
+0 rows inserted/updated/deleted
+ij> -- Test with target schema missing
+create synonym mySynonym for notPresent.t1;
+0 rows inserted/updated/deleted
+WARNING 01522: The newly defined synonym 'MYSYNONYM' resolved to the object 'NOTPRESENT.T1'
which is currently undefined. : 
+ij> select * from mySynonym;
+ERROR 42Y07: Schema 'NOTPRESENT' does not exist
+ij> create table notPresent.t1(j int, c char(10));
+0 rows inserted/updated/deleted
+ij> insert into notPresent.t1 values (100, 'satheesh');
+1 row inserted/updated/deleted
+ij> -- Should resolve now
+select * from mySynonym;
+J |C         
+-----
+100 |satheesh  
+ij> drop table notPresent.t1;
+0 rows inserted/updated/deleted
+ij> drop synonym mySynonym;
+0 rows inserted/updated/deleted
 ij> -- Positive test case with three levels of synonym chaining
 create schema synonymSchema;
 0 rows inserted/updated/deleted

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out?rev=190182&r1=190181&r2=190182&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out
Sat Jun 11 16:39:44 2005
@@ -216,6 +216,54 @@
 0 rows inserted/updated/deleted
 ij> drop synonym synPrimary;
 0 rows inserted/updated/deleted
+ij> -- Tests with non existant schemas
+----- Implicitly creates junkSchema
+create synonym junkSchema.syn1 for table2;
+0 rows inserted/updated/deleted
+WARNING 01522: The newly defined synonym 'SYN1' resolved to the object 'JUNKSCHEMA.TABLE2'
which is currently undefined. : 
+ij> select * from junkSchema.syn1;
+ERROR 42X05: Table 'JUNKSCHEMA.TABLE2' does not exist.
+ij> set schema junkSchema;
+0 rows inserted/updated/deleted
+ij> create table table2(c char(10));
+0 rows inserted/updated/deleted
+ij> select * from syn1;
+C         
+-----
+ij> set schema APP;
+0 rows inserted/updated/deleted
+ij> -- Should resolve to junkSchema.table2
+select * from junkSchema.syn1;
+C         
+-----
+ij> drop table junkSchema.table2;
+0 rows inserted/updated/deleted
+ij> -- Should fail. Need to drop synonym first
+drop schema junkSchema restrict;
+ERROR X0Y54: Schema 'JUNKSCHEMA' cannot be dropped because it is not empty.
+ij> drop synonym junkSchema.syn1;
+0 rows inserted/updated/deleted
+ij> drop schema junkSchema restrict;
+0 rows inserted/updated/deleted
+ij> -- Test with target schema missing
+create synonym mySynonym for notPresent.t1;
+0 rows inserted/updated/deleted
+WARNING 01522: The newly defined synonym 'MYSYNONYM' resolved to the object 'NOTPRESENT.T1'
which is currently undefined. : 
+ij> select * from mySynonym;
+ERROR 42Y07: Schema 'NOTPRESENT' does not exist
+ij> create table notPresent.t1(j int, c char(10));
+0 rows inserted/updated/deleted
+ij> insert into notPresent.t1 values (100, 'satheesh');
+1 row inserted/updated/deleted
+ij> -- Should resolve now
+select * from mySynonym;
+J |C         
+-----
+100 |satheesh  
+ij> drop table notPresent.t1;
+0 rows inserted/updated/deleted
+ij> drop synonym mySynonym;
+0 rows inserted/updated/deleted
 ij> -- Positive test case with three levels of synonym chaining
 create schema synonymSchema;
 0 rows inserted/updated/deleted

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out?rev=190182&r1=190181&r2=190182&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
Sat Jun 11 16:39:44 2005
@@ -219,6 +219,54 @@
 0 rows inserted/updated/deleted
 ij> drop synonym synPrimary;
 0 rows inserted/updated/deleted
+ij> -- Tests with non existant schemas
+-- Implicitly creates junkSchema
+create synonym junkSchema.syn1 for table2;
+0 rows inserted/updated/deleted
+WARNING 01522: The newly defined synonym 'SYN1' resolved to the object 'JUNKSCHEMA.TABLE2'
which is currently undefined.
+ij> select * from junkSchema.syn1;
+ERROR 42X05: Table 'JUNKSCHEMA.TABLE2' does not exist.
+ij> set schema junkSchema;
+0 rows inserted/updated/deleted
+ij> create table table2(c char(10));
+0 rows inserted/updated/deleted
+ij> select * from syn1;
+C         
+----------
+ij> set schema APP;
+0 rows inserted/updated/deleted
+ij> -- Should resolve to junkSchema.table2
+select * from junkSchema.syn1;
+C         
+----------
+ij> drop table junkSchema.table2;
+0 rows inserted/updated/deleted
+ij> -- Should fail. Need to drop synonym first
+drop schema junkSchema restrict;
+ERROR X0Y54: Schema 'JUNKSCHEMA' cannot be dropped because it is not empty.
+ij> drop synonym junkSchema.syn1;
+0 rows inserted/updated/deleted
+ij> drop schema junkSchema restrict;
+0 rows inserted/updated/deleted
+ij> -- Test with target schema missing
+create synonym mySynonym for notPresent.t1;
+0 rows inserted/updated/deleted
+WARNING 01522: The newly defined synonym 'MYSYNONYM' resolved to the object 'NOTPRESENT.T1'
which is currently undefined.
+ij> select * from mySynonym;
+ERROR 42Y07: Schema 'NOTPRESENT' does not exist
+ij> create table notPresent.t1(j int, c char(10));
+0 rows inserted/updated/deleted
+ij> insert into notPresent.t1 values (100, 'satheesh');
+1 row inserted/updated/deleted
+ij> -- Should resolve now
+select * from mySynonym;
+J          |C         
+----------------------
+100        |satheesh  
+ij> drop table notPresent.t1;
+0 rows inserted/updated/deleted
+ij> drop synonym mySynonym;
+0 rows inserted/updated/deleted
 ij> -- Positive test case with three levels of synonym chaining
 create schema synonymSchema;
 0 rows inserted/updated/deleted

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql?rev=190182&r1=190181&r2=190182&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql
Sat Jun 11 16:39:44 2005
@@ -139,6 +139,35 @@
 drop table primaryTab;
 drop synonym synPrimary;
 
+-- Tests with non existant schemas
+-- Implicitly creates junkSchema
+create synonym junkSchema.syn1 for table2;
+select * from junkSchema.syn1;
+set schema junkSchema;
+create table table2(c char(10));
+select * from syn1;
+set schema APP;
+
+-- Should resolve to junkSchema.table2
+select * from junkSchema.syn1;
+drop table junkSchema.table2;
+
+-- Should fail. Need to drop synonym first
+drop schema junkSchema restrict;
+drop synonym junkSchema.syn1;
+drop schema junkSchema restrict;
+
+-- Test with target schema missing
+create synonym mySynonym for notPresent.t1;
+select * from mySynonym;
+create table notPresent.t1(j int, c char(10));
+insert into notPresent.t1 values (100, 'satheesh');
+-- Should resolve now
+select * from mySynonym;
+
+drop table notPresent.t1;
+drop synonym mySynonym;
+
 -- Positive test case with three levels of synonym chaining
 
 create schema synonymSchema;

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql?rev=190182&r1=190181&r2=190182&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
Sat Jun 11 16:39:44 2005
@@ -61,6 +61,12 @@
 create view v1 (dum, dee, dokie) as select a.c, a.i, a.vc from bar.t1 as a;
 
 -- ----------------------------------------------
+-- Synonyms
+-- ----------------------------------------------
+
+create synonym syn1 for bar.t1;
+
+-- ----------------------------------------------
 -- Triggers
 -- ----------------------------------------------
 



Mime
View raw message