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

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

Just a thought...

In GenericLanguageConnectionContext, there is a method which looks like this:

        public PreparedStatement prepareInternalStatement(SchemaDescriptor 
compilationSchema, String sqlText, boolean isForReadOnly, boolean forMetaData) 
            throws StandardException 
        {
            return connFactory.getStatement(compilationSchema, sqlText, 
isForReadOnly).prepare(this, forMetaData);
        }

Would it work if we added something like
    if (forMetaData) compilationSchema = systemSchema;
to this method?

> In soft upgrade mode, the metadata queries do not get compiled in SYS schema. 
> This will cause problems in future releases of Derby.
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-2946
>                 URL: https://issues.apache.org/jira/browse/DERBY-2946
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.4.0.0
>            Reporter: Mamta A. Satoor
>
> EmbedDatabaseMetaData implements metadata queries. The implementation of 
> metadata queries in EmbedDatabaseMetaData checks if we are in soft upgrade 
> mode (getPreparedQuery() has following code)
> if (notInSoftUpgradeMode())
>       s = getPreparedQueryUsingSystemTables(queryName, net);
> else {
>       try {
>               //Can't use stored prepared statements because we are in soft 
> upgrade
>               //mode and hence need to get metadata sql from 
> metadata.properties file 
>               //or metadata_net.properties
>               String queryText = getQueryFromDescription(queryName, net);
>               s = getEmbedConnection().prepareMetaDataStatement(queryText);
>       } catch (Throwable t) {
>               throw handleException(t);
>       } 
> }
> So, when running in soft upgrade mode, we do not go through SYSSTATEMENT but 
> this will cause the metadata query to run in whatever the current schema may 
> be rather than in SYS schema. This is not a problem in Derby 10.3 release 
> because during soft upgarde, the collation will always be UCS_BASIC and hence 
> collation mismatch can't happen.
> But in Derby 10.3, a user can create a database with territory based 
> collation. When such a database will be in soft upgrade mode for say Derby 
> 10.4, the metadata queries will run into problem if they are run in a user 
> schema. This is because in soft upgrade mode, we do not go through 
> SYSSTATEMENTS and instead compile the metadata queries in current schema. If 
> the current schema is user schema, then character string literals in metadata 
> queries will get the collation type of territory based and when compared with 
> character string colunms from SYS tables with collation type of UCS_BASIC, we 
> will end up getting compilation error for the metadata queries. So, before 
> the next release, we will have to fix this problem. One solution may be to 
> somehow make the current compilation schema as SYS when running the metadata 
> queries in soft upgrade mode.

-- 
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