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 "A B (JIRA)" <ji...@apache.org> on 2007/05/02 20:35:15 UTC

[jira] Commented: (DERBY-2280) DatabaseMetaData.getTypeInfo() UNSIGNED_ATTRIBUTE and AUTO_INCREMENT column returns incorrect information for BLOB & CLOB data type

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

A B commented on DERBY-2280:
----------------------------

Thanks for the updated patch, Saurabh.

I ran jdbcapi/DatabaseMetaDataTest with a clean codeline and it passed for me.  But as you say, if I run it with your changes applied the test fails when checking NULLABILITY.  The failure occurs because the nullability of the UNSIGNED_ATTRIBUTE and AUTO_INCREMENT columns becomes "false" with your changes, wherease it used to be "true".

Without your patch, at least one row in the VALUES clause (actually, two rows--the row for BLOB and the row for CLOB) has a NULL value for UNSIGNED_ATTRIBUTE and AUTO_INCREMENT:

    ('BLOB',2004,2147483647,CAST (NULL AS CHAR),CAST (NULL AS CHAR),'length', \
        1,FALSE,0,CAST (NULL AS BOOLEAN),FALSE,CAST (NULL AS BOOLEAN), \
        CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)),\
    ('CLOB',2005,2147483647,'''','''','length', \
        1,TRUE,1,CAST (NULL AS BOOLEAN),FALSE,CAST (NULL AS BOOLEAN), \
        CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)), \

Since there is at least one row which is null, the type definition for the corresponding columns implicitly becomes nullable, and thus we see (before your changes) a NULLABILITY of "true".

But with your patch applied, every row in the VALUES clause used for getTypeInfo() returns a constant value (TRUE or FALSE) for UNSIGNED_ATTRIBUTE and AUTO_INCREMENT:

         ('BLOB',2004,2147483647,CAST (NULL AS CHAR),CAST (NULL AS CHAR),'length', \
-            1,FALSE,0,CAST (NULL AS BOOLEAN),FALSE,CAST (NULL AS BOOLEAN), \
+            1,FALSE,0,TRUE,FALSE,FALSE, \
             CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)),\
         ('CLOB',2005,2147483647,'''','''','length', \
-            1,TRUE,1,CAST (NULL AS BOOLEAN),FALSE,CAST (NULL AS BOOLEAN), \
+            1,TRUE,1,TRUE,FALSE,FALSE, \
             CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)), \

A constant value that is not null implicitly has a type definition that is not nullable.  So since _all_ rows now have a constant value for the UNSIGNED_ATTRIBUTE and AUTO_INCREMENT columns, the type definitions for those two columns become "not nullable", which translates into a "false" NULLABILITY.

Hence the failure in DatabaseMetaDataTest.

This difference in behavior is, I think, related to the discussion for DERBY-2307.  That issue talks about how the derived nullability of a column for getTypeInfo() is correct for some columns (ex. DATA_TYPE) but incorrect for others (ex. TYPE_NAME).  The difference is that all columns which use an explict CAST operand assume a nullability of "true", while a column that has all constants with no CASTs assumes a nullability of "false".  

That said, it's not clear to me what the nullability of the AUTO_INCREMENT and UNSIGNED_ATTRIBUTE columns should be.  I posted a question to DERBY-2307; we'll have to figure that out before we know how to handle the DatabaseMetaDataTest failure that you are seeing with your patch...

Minor comment on the _v2 patch:

Spacing for the changes to DatabaseMetaDataTest.java are inconsistent.  Some of the new code uses tabs whereas other pieces use spaces.  Since the surrounding (unchanged) code uses 4-space indentation, I think it'd be best to use that for the new code, as well...

> DatabaseMetaData.getTypeInfo() UNSIGNED_ATTRIBUTE and AUTO_INCREMENT column returns incorrect information for BLOB & CLOB data type
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-2280
>                 URL: https://issues.apache.org/jira/browse/DERBY-2280
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.0.2.1, 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.0.0
>            Reporter: Saurabh Vyas
>         Assigned To: Saurabh Vyas
>            Priority: Minor
>         Attachments: Derby-2280.diff, Derby-2280.stat, Derby-2280_v2.diff
>
>
> getTypeInfo() method should return FALSE for UNSIGNED_ATTRIBUTE and AUTO_INCREMENT in case of BLOB & CLOB data type.
> Currently it returns NULL value.

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


Re: [jira] Commented: (DERBY-2280) DatabaseMetaData.getTypeInfo() UNSIGNED_ATTRIBUTE and AUTO_INCREMENT column returns incorrect information for BLOB & CLOB data type

Posted by Saurabh Vyas <Sa...@Sun.COM>.
Thanks a lot Army for your valuable comments & insights. Well currently 
I am on vacation (and will be back on 7th May) so I will look into in 
next week.
Apart as I will submit a new patch with correct spacing (consistent with 
the existing code) and also I 'll follow DERBY-2307 to see whats need to 
be done for NULLABILITY.

Saurabh

A B (JIRA) wrote:
>     [ https://issues.apache.org/jira/browse/DERBY-2280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12493169 ] 
>
> A B commented on DERBY-2280:
> ----------------------------
>
> Thanks for the updated patch, Saurabh.
>
> I ran jdbcapi/DatabaseMetaDataTest with a clean codeline and it passed for me.  But as you say, if I run it with your changes applied the test fails when checking NULLABILITY.  The failure occurs because the nullability of the UNSIGNED_ATTRIBUTE and AUTO_INCREMENT columns becomes "false" with your changes, wherease it used to be "true".
>
> Without your patch, at least one row in the VALUES clause (actually, two rows--the row for BLOB and the row for CLOB) has a NULL value for UNSIGNED_ATTRIBUTE and AUTO_INCREMENT:
>
>     ('BLOB',2004,2147483647,CAST (NULL AS CHAR),CAST (NULL AS CHAR),'length', \
>         1,FALSE,0,CAST (NULL AS BOOLEAN),FALSE,CAST (NULL AS BOOLEAN), \
>         CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)),\
>     ('CLOB',2005,2147483647,'''','''','length', \
>         1,TRUE,1,CAST (NULL AS BOOLEAN),FALSE,CAST (NULL AS BOOLEAN), \
>         CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)), \
>
> Since there is at least one row which is null, the type definition for the corresponding columns implicitly becomes nullable, and thus we see (before your changes) a NULLABILITY of "true".
>
> But with your patch applied, every row in the VALUES clause used for getTypeInfo() returns a constant value (TRUE or FALSE) for UNSIGNED_ATTRIBUTE and AUTO_INCREMENT:
>
>          ('BLOB',2004,2147483647,CAST (NULL AS CHAR),CAST (NULL AS CHAR),'length', \
> -            1,FALSE,0,CAST (NULL AS BOOLEAN),FALSE,CAST (NULL AS BOOLEAN), \
> +            1,FALSE,0,TRUE,FALSE,FALSE, \
>              CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)),\
>          ('CLOB',2005,2147483647,'''','''','length', \
> -            1,TRUE,1,CAST (NULL AS BOOLEAN),FALSE,CAST (NULL AS BOOLEAN), \
> +            1,TRUE,1,TRUE,FALSE,FALSE, \
>              CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)), \
>
> A constant value that is not null implicitly has a type definition that is not nullable.  So since _all_ rows now have a constant value for the UNSIGNED_ATTRIBUTE and AUTO_INCREMENT columns, the type definitions for those two columns become "not nullable", which translates into a "false" NULLABILITY.
>
> Hence the failure in DatabaseMetaDataTest.
>
> This difference in behavior is, I think, related to the discussion for DERBY-2307.  That issue talks about how the derived nullability of a column for getTypeInfo() is correct for some columns (ex. DATA_TYPE) but incorrect for others (ex. TYPE_NAME).  The difference is that all columns which use an explict CAST operand assume a nullability of "true", while a column that has all constants with no CASTs assumes a nullability of "false".  
>
> That said, it's not clear to me what the nullability of the AUTO_INCREMENT and UNSIGNED_ATTRIBUTE columns should be.  I posted a question to DERBY-2307; we'll have to figure that out before we know how to handle the DatabaseMetaDataTest failure that you are seeing with your patch...
>
> Minor comment on the _v2 patch:
>
> Spacing for the changes to DatabaseMetaDataTest.java are inconsistent.  Some of the new code uses tabs whereas other pieces use spaces.  Since the surrounding (unchanged) code uses 4-space indentation, I think it'd be best to use that for the new code, as well...
>
>   
>> DatabaseMetaData.getTypeInfo() UNSIGNED_ATTRIBUTE and AUTO_INCREMENT column returns incorrect information for BLOB & CLOB data type
>> -----------------------------------------------------------------------------------------------------------------------------------
>>
>>                 Key: DERBY-2280
>>                 URL: https://issues.apache.org/jira/browse/DERBY-2280
>>             Project: Derby
>>          Issue Type: Bug
>>          Components: JDBC
>>    Affects Versions: 10.0.2.1, 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.0.0
>>            Reporter: Saurabh Vyas
>>         Assigned To: Saurabh Vyas
>>            Priority: Minor
>>         Attachments: Derby-2280.diff, Derby-2280.stat, Derby-2280_v2.diff
>>
>>
>> getTypeInfo() method should return FALSE for UNSIGNED_ATTRIBUTE and AUTO_INCREMENT in case of BLOB & CLOB data type.
>> Currently it returns NULL value.
>>     
>
>