Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.3.1, 2.3.2, 2.4-M3
-
Component/s: jdbc-postgis plugin
-
Labels:None
-
Environment:This problem was reported against 2.3.1 with postgresql + postgis 8.2.
Description
Thanks to Enam for the original report :-D
Apparently we are asking for the max integer value which is a little bit more that the legal limit.
public static void main(String[] args) throws Exception { Map params = new HashMap(); params.put("dbtype", "postgis"); //must be postgis params.put("host", "localhost"); //the name or ip address of the machine running PostGIS params.put("port", new Integer(5432)); //the port that PostGIS is running on (generally 5432) params.put("database", "postgres"); //the name of the database to connect to. params.put("user", "postgres"); //the user to connect with params.put("passwd", "pass"); //the password of the user. DataStore pgDatastore = DataStoreFinder.getDataStore(params); pgDatastore.createSchema(someSchema); }
Results in the following message:
- java.io.IOException: ERROR: length for type varchar cannot exceed 10485760
This issue is marked minor as you can work around it by actually mentioning the string length:
// bad AttributeType cgi = AttributeTypeFactory.newAttributeType("propertyName", String.class); // good AttributeType cgi = AttributeTypeFactory.newAttributeType("propertyName", String.class, true, 30);
Long term I would like to see datastores provide their own FeatureTypeFactory so this kind of thing is not a problem ever again (and we can be sure that the GeoTools FeatureType is always a representation of what the data store can support).
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;
}