db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6361) Valid statements rejected if Derby has not implicitly created the current user's schema.
Date Wed, 02 Oct 2013 08:36:24 GMT

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

Knut Anders Hatlen commented on DERBY-6361:
-------------------------------------------

The generated UPDATE statement doesn't have any unqualified names, and doesn't reference the
ROOT schema, so it should be able the compile even if there is no ROOT schema. The reason
why it fails, seems to be that DMLModStatementNode.parseAndBindGenerationClauses() sets the
compilation schema to the current schema at the time of the ALTER TABLE statement that added
the generated column:

{code}
                //
                // Unqualified function references should resolve to the
                // current schema at the time that the table was
                // created/altered. See DERBY-3945.
                //
                SchemaDescriptor    originalCurrentSchema = getSchemaDescriptor( di.getOriginalCurrentSchema(),
true );
                compilerContext.pushCompilationSchema( originalCurrentSchema );
{code}

This also seems to cause problems when the generated column is added by CREATE TABLE from
a non-existing schema, but the error won't be seen until you try to add rows to that table:

{noformat}
ij version 10.11
ij> connect 'jdbc:derby:memory:db;create=true;user=root';
ij> create table app.t1(x int, y int generated always as (-x));
0 rows inserted/updated/deleted
ij> insert into app.t1(x) values 1,2,3;
ERROR 42Y07: Schema 'ROOT' does not exist (errorCode = 30000)
ij> connect 'jdbc:derby:memory:db;user=app';
ij(CONNECTION1)> insert into app.t1(x) values 1,2,3;
ERROR 42Y07: Schema 'ROOT' does not exist (errorCode = 30000)
{noformat}

This also fails with the patch, by the way.

> Valid statements rejected if Derby has not implicitly created the current user's schema.
> ----------------------------------------------------------------------------------------
>
>                 Key: DERBY-6361
>                 URL: https://issues.apache.org/jira/browse/DERBY-6361
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>            Reporter: Rick Hillegas
>            Assignee: Rick Hillegas
>         Attachments: derby-6361-01-aa-createDefaultSchema.diff
>
>
> There are many examples of statements failing because Derby has not implicitly created
the schema associated with the current user. You don't see this if the schema is the default
APP schema. But if the user is anyone other than APP, then various statements can fail. Maybe
we should implicitly create a schema even if the user isn't APP. Right now, you get an error
like this:
> ERROR 42Y07: Schema 'ROOT' does not exist
> The following script shows an example of this problem:
> connect 'jdbc:derby:memory:db;create=true;user=esq';
> create table licreq( domain varchar( 10 ) );
> connect 'jdbc:derby:memory:db;user=root';
> -- fails
> ALTER TABLE esq.licreq ADD COLUMN u_domain GENERATED ALWAYS AS (UPPER(domain));
> connect 'jdbc:derby:memory:db;user=app';
> -- succeeds
> ALTER TABLE esq.licreq ADD COLUMN u_domain GENERATED ALWAYS AS (UPPER(domain));



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message