You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Bryan Pendleton (JIRA)" <ji...@apache.org> on 2016/11/27 17:48:58 UTC

[jira] [Commented] (DERBY-6918) Problem with schema name starting with number followed by a dot

    [ https://issues.apache.org/jira/browse/DERBY-6918?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15700053#comment-15700053 ] 

Bryan Pendleton commented on DERBY-6918:
----------------------------------------

Reproduces for me with the current head of trunk.

Here's the precise stack trace where the problem occurs:
{quote}
ERROR 42Y07: Schema '1' does not exist
	at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:290)
	at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:285)
	at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(DataDictionaryImpl.java:1709)
	at org.apache.derby.iapi.sql.StatementUtil.getSchemaDescriptor(StatementUtil.java:138)
	at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(QueryTreeNode.java:1146)
	at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(QueryTreeNode.java:1121)
	at org.apache.derby.impl.sql.compile.TableName.bind(TableName.java:245)
	at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(FromBaseTable.java:2338)
	at org.apache.derby.impl.sql.compile.FromList.bindTables(FromList.java:348)
	at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(SelectNode.java:490)
	at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(DMLStatementNode.java:190)
	at org.apache.derby.impl.sql.compile.DeleteNode.bindStatement(DeleteNode.java:151)
	at org.apache.derby.impl.sql.compile.DeleteNode.bindStatement(DeleteNode.java:374)
	at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:401)
	at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:99)
	at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:1114)
	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:684)
	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:632)
	at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:372)
	at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:533)
	at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:375)
	at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:251)
	at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
	at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
	at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
	at org.apache.derby.tools.ij.main(ij.java:59)
{quote}

It's possible that the problem arises in this code in DeleteNode.java, where we are
generating an internal "delete" statement to perform the cascading delete:
{code}
			//In case of cascade delete , create nodes for
			//the ref action  dependent tables and bind them.
			if(fkTableNames != null)
			{
				String currentTargetTableName = targetTableDescriptor.getSchemaName() +
						 "." + targetTableDescriptor.getName();

{code}
This code does not seem to be properly using delimited identifiers to manage
the targetTableDescriptor's schema name and table name; it's just pasting them
together, resulting in the simple names "1.a.user" and "1.a.role" being used
for the generated cascaded deletes. 

> Problem with schema name starting with number followed by a dot
> ---------------------------------------------------------------
>
>                 Key: DERBY-6918
>                 URL: https://issues.apache.org/jira/browse/DERBY-6918
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.13.1.1
>            Reporter: Hooman Valibeigi
>
> It seems that there is a problem with schema names that start with a number followed by a dot.
> Please take a look at the following script. Everything works fine but the last line which is a delete statement. Note that having the foreign key constraints was necessary to make it reproduce the problem.
> create schema "1.a";
> create table "1.a"."role"
> (
> "id" integer generated always as identity,
> "name" varchar(255) not null
> );
> alter table "1.a"."role" add constraint "role_pk"
> primary key ("id");
> create table "1.a"."user"
> (
> "id" integer generated always as identity,
> "name" varchar(255) not null
> );
> alter table "1.a"."user" add constraint "user_pk"
> primary key ("id");
> create table "1.a"."user_role"
> (
> "role" integer not null,
> "user" integer not null
> );
> alter table "1.a"."user_role" add constraint "user_role_fk1"
> foreign key ("role")
> references "1.a"."role" ("id")
> on delete cascade;
> alter table "1.a"."user_role" add constraint "user_role_fk2"
> foreign key ("user")
> references "1.a"."user" ("id")
> on delete cascade;
> alter table "1.a"."user_role" add constraint "user_role_u1"
> unique ("user", "role");
> insert into "1.a"."role" ("name") values ('r1');
> insert into "1.a"."user" ("name") values ('u1');
> insert into "1.a"."user_role" ("role","user") values (1,1);
> select * from "1.a"."user";
> delete from "1.a"."user";
> Last delete statement fails. The error is:
> Schema '1' does not exist [SQL State=42Y07, DB Errorcode=20000] 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)