db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: DERBY-1478 : Making the correct collation type available in CreateTableNode for character string type columns
Date Wed, 04 Apr 2007 19:17:33 GMT
Mamta Satoor wrote:
> Hi,
>  
> I just finished committing a patch (revision 525568) which has added 
> collation type and collation derivation to DataTypeDescriptor and there 
> are apis to set and get those values out of DTDs.
>  
> As a next step on language based ordering Jira entry, I want to tackle 
> CREATE TABLE. Create table should pick up the collation requested by the 
> user at create database time and use that for character string type 
> columns. I have not though much about it and going to start researching 
> into it. But what is coming to my mind is that I can write a new api in 
> DataDictionary to return the right collation type 
> (UCS_BASIC/TERRITORY_BASED) for user defined tables and CREATE TABLE 
> will use that collation type to set into DTDs.
>  
> I am not sure if that will cause a problem with system tables because I 
> don't know if system table creation goes through CREATE TABLE node. If 
> they do not, then I think what I am suggesting will work. System table 
> creations will need to make another api call on DataDictionary which 
> will return the collation type for character string types associated 
> with system schema, which is always UCS_BASIC. Another alternative is to 
> hard code UCS_BASIC for system table columns wherever they get created 
> but I think it will be better to have one central location to get both 
> user and system collation types.
>  
> So, 2 new apis in DataDictionary
> public int getCollationTypeForPersistentUserCharacterColumns() - this 
> will return value based on collation property
> public int getCollationTypeForPersistentSystemCharacterColumns() - this 
> will return hard coded UCS_BASIC.
>  
> One improvement could be to have a single api in DataDictionary and pass 
> the user schema vs system schema flag to it and have DataDictionary 
> check that flag and return the correct collation.
> public int getCollationType(boolean systemSchema) - if systemSchema true 
> then return UCS_BASIC, if systemSchema false, then return collation type 
> based on collation property.
>  
> Does anyone have an opinion on if I am on the right track?


The collation you are looking for is a property of the schema, see this 
from your 1478 wiki page:

> 2)<column definition> (of character string type) SQL spec Section 11.1 <schema
definition>, General Rule 3 specifies that the character set associated with schema is
used as the default character set for all <column definitions>.

Thus, since it's a property of the schema, the most logical place for 
this is as a method on SchemaDescriptor,
e.g.

  public int getCollationType();


Dan.



Mime
View raw message