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

Dag H. Wanvik commented on DERBY-3043:
--------------------------------------

I notice that using the user's name explicitly as a schema name:
 
CREATE TABLE blogs.BLOGSCOM__BLOGS__USERS(..) 

avoids the problem. The autocreation of a user schema happens only at execute 
time (CreateTableConstantAction calls
getSchemaDescriptorForCreate), wheres the binding of the CHECK constraint which 
references the column whose binding gives the error precedes that point in time.

When the table has an explicit schema, the binding proceeds OK since 
FromBaseTable#getMatchingColumn finds a schema, whereas in the error case, it 
attempts to bind the table (needed, since current schema is not known a priori 
now), ca line 2532:

        if(exposedTableName.getSchemaName() == null && correlationName == null)
            exposedTableName.bind(this.getDataDictionary());    
<-----------------only done if no explicit schema in create stmt

and this ultimately fails.

> 'Schema <schemaname> does not exist' when constraint used in table definition
> -----------------------------------------------------------------------------
>
>                 Key: DERBY-3043
>                 URL: https://issues.apache.org/jira/browse/DERBY-3043
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4
>         Environment: Mac OS 10
>            Reporter: geoff hendrey
>            Assignee: Bryan Pendleton
>
> https://issues.apache.org/jira/browse/DERBY-568#action_12524420
> In the response to my original comment post, which you can find via the 
> permalink above, I was encouraged to file this as a new issue.
> verified this back to 10.1.2.1 with the following ij script.
> connect 'jdbc:derby:wombat;create=true;user=blogs';
> CREATE TABLE BLOGSCOM__BLOGS__USERS(PK INTEGER NOT NULL GENERATED ALWAYS AS 
> IDENTITY,username VARCHAR(16) NOT NULL CONSTRAINT 
> BLOGSCOM__BLOGS__USERS_UNIQUE_username UNIQUE CONSTRAINT 
> BLOGSCOM__BLOGS__USERS_PASSWORD_username CHECK(LENGTH(username)>7),password 
> VARCHAR (32672) NOT NULL , PRIMARY KEY(PK));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to