Thanks for the quick work. Let me know when the patch is applied 2.3.x
branch. 

Regards,
Enam


Jody Garnett wrote:
> 
> Nice thank you this is great!
> 
> Let's create a bug report and then apply your fix :-) Thanks so much for 
> the research etc...
> I have some time as I wait for a GeoTools build to finish so I will 
> create the bug report for you ...
> - http://jira.codehaus.org/browse/GEOT-1348
> 
> I have applied your fix on trunk, if you like it we can ask that it be 
> applied to 2.3.x as well. The revision number of
> the commit is marked on the bug report, the bug report will be marked 
> resolved until you confirm you
> are happy etc...
> 
> As long as you have the ability to test - the following bug looks to be 
> related:
> - http://jira.codehaus.org/browse/GEOT-1061
> 
> Andrea I do not have a 2.3.x checkout here at work - can you apply this 
> fix to 2.3.x please?
> Jody
>> This happens when the schema defines an attribute without the length of
>> the field :
>>
>> AttributeType cgi = AttributeTypeFactory.newAttributeType("propertyName",
>> String.class);
>>
>> This goes away when we set the length to less than 10485760 using
>>
>> AttributeType cgi = AttributeTypeFactory.newAttributeType("propertyName",
>> String.class, true, 30);
>>
>> I tried the generated sql statement and the same error is thrown. Here is
>> the error :
>>
>> ERROR: length for type varchar cannot exceed 10485760
>> SQL state: 22023
>>
>> It seems like when generating the sql, the max value for VARCHAR comes up
>> to be MAX_INT. However, postgresql requires it to be less than or equal
>> to 10485760. From what I understand from the code in
>> PostgisDataStore.java, the createSchema method should do a check for this
>> case:
>>
>> if (length < 1) {
>>       LOGGER.warning("FeatureType did not specify string length;
>> defaulted to 256");
>>       length = 256;
>> }
>> else if (length > MAX_ALLOWED_VALUE) // this is the check that I think
>> should be added and MAX_ALLOWED_VALUE should be set to 10485760
>> {
>>       length = MAX_ALLOWED_VALUE;
>> }
>>
>> The complete method follows :
>>
>> private StringBuffer makeSqlCreate(AttributeType[] attributeType)
>>         throws IOException {
>>         StringBuffer buf = new StringBuffer("");
>>
>>         for (int i = 0; i < attributeType.length; i++) {
>>             String typeName = null;
>>             typeName = (String)
>> CLASS_MAPPINGS.get(attributeType[i].getType());
>>             if (typeName == null)
>>                 typeName = (String)
>> GEOM_CLASS_MAPPINGS.get(attributeType[i].getType());
>>
>>             if (typeName != null) {
>>                 if (attributeType[i] instanceof GeometryAttributeType) {
>>                     typeName = "GEOMETRY";
>>                 } else if (typeName.equals("VARCHAR")) {
>>                         int length = -1;
>>                         Filter f = attributeType[i].getRestriction();
>>                         if(f !=null && f!=Filter.ALL && f != Filter.NONE
>> && (f.getFilterType() == FilterType.COMPARE_LESS_THAN ||
>> f.getFilterType() == FilterType.COMPARE_LESS_THAN_EQUAL)){
>>                                 try{
>>                                 CompareFilter cf = (CompareFilter)f;
>>                                 if(cf.getLeftValue() instanceof
>> LengthFunction){
>>                                         length =
>> Integer.parseInt(((LiteralExpression)cf.getRightValue()).getLiteral().toString());
>>                                 }else{
>>                                         if(cf.getRightValue() instanceof
>> LengthFunction){
>>                                         length =
>> Integer.parseInt(((LiteralExpression)cf.getLeftValue()).getLiteral().toString());
>>                                 }
>>                                 }
>>                                 }catch(NumberFormatException e){
>>                                         length = 256;
>>                                 }
>>                         }else{
>>                                 length = 256;
>>                         }
>>
>>                         if (length < 1) {
>>                                 LOGGER.warning("FeatureType did not
>> specify string length; defaulted to 256");
>>                                 length = 256;
>>                         }
>>                   else if (length > MAX_ALLOWED_VALUE)
>>                   {
>>                         length = MAX_ALLOWED_VALUE;
>>                   }
>>
>>                     typeName = typeName + "(" + length + ")";
>>                 }
>>
>>                 if (!attributeType[i].isNillable()) {
>>                     typeName = typeName + " NOT NULL";
>>                 }
>>
>>                 //TODO review!!! Is toString() always OK???
>>                 Object defaultValue =
>> attributeType[i].createDefaultValue();
>>
>>                 if (defaultValue != null) {
>>                     typeName = typeName + " DEFAULT '"
>>                         + defaultValue.toString() + "'";
>>                 }
>>
>>                 buf.append(" \"" + attributeType[i].getName() + "\" " +
>> typeName + ",");
>>
>>             } else {
>>                 String msg;
>>                 if (attributeType[i] == null) {
>>                         msg = "AttributeType was null!";
>>                 } else {
>>                         msg = "Type '" + attributeType[i].getType() + "'
>> not supported!";
>>                 }
>>                 throw (new IOException(msg));
>>             }
>>         }
>>
>>         return buf.deleteCharAt(buf.length()-1);
>>     }
>>
>> Regards,
>> Enamul Haque
>> R & D, Redknee Inc.
>>
>> -----Original Message-----
>> From: Jody Garnett [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, June 19, 2007 3:44 PM
>> To: Enamul Haque
>> Cc: [email protected]
>> Subject: Re: [Geotools-gt2-users] Postgis DataStore
>>
>> Enam wrote:
>>   
>>> Not sure if this has been posted before. I'm getting an exception when
>>> calling createSchema() :
>>>
>>> It seems like any attribute of type string uses VARCHAR(2147483647). Am
>>> I
>>> doing something wrong here ?
>>>
>>>     
>> Sounds like we are doing something wrong? Can you do some research and
>> let us know what we are supposed to be using to represent String? When I
>> first saw your message I wondered if the createSchema statement was
>> resulting in an SQL request that was too long.
>>
>> You can always try doing the same SQL as create schema generates by hand
>> while you experiment...
>> Cheers,
>> Jody
>>   
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Postgis-DataStore-tf3944630.html#a11204198
Sent from the geotools-gt2-users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to