use 'limit 0' when gathering metadata, also we don't need getFieldSize at all
This commit is contained in:
parent
ef6f1060d3
commit
92b22558fd
1 changed files with 22 additions and 27 deletions
|
@ -99,26 +99,22 @@ postgis_datasource::postgis_datasource(parameters const& params)
|
||||||
|
|
||||||
// collect attribute desc
|
// collect attribute desc
|
||||||
s.str("");
|
s.str("");
|
||||||
s << "select * from " << table_ << " limit 1";
|
s << "select * from " << table_ << " limit 0";
|
||||||
rs=conn->executeQuery(s.str());
|
rs=conn->executeQuery(s.str());
|
||||||
if (rs->next())
|
|
||||||
{
|
|
||||||
int count = rs->getNumFields();
|
int count = rs->getNumFields();
|
||||||
for (int i=0;i<count;++i)
|
for (int i=0;i<count;++i)
|
||||||
{
|
{
|
||||||
std::string fld_name=rs->getFieldName(i);
|
std::string fld_name=rs->getFieldName(i);
|
||||||
int length = rs->getFieldLength(i);
|
|
||||||
|
|
||||||
int type_oid = rs->getTypeOID(i);
|
int type_oid = rs->getTypeOID(i);
|
||||||
switch (type_oid)
|
switch (type_oid)
|
||||||
{
|
{
|
||||||
case 21: // int2
|
case 21: // int2
|
||||||
case 23: // int4
|
case 23: // int4
|
||||||
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Integer,false,length));
|
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Integer));
|
||||||
break;
|
break;
|
||||||
case 700: // float4
|
case 700: // float4
|
||||||
case 701: // float8
|
case 701: // float8
|
||||||
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double,false,length));
|
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double));
|
||||||
case 1042: // bpchar
|
case 1042: // bpchar
|
||||||
case 1043: // varchar
|
case 1043: // varchar
|
||||||
case 25: // text
|
case 25: // text
|
||||||
|
@ -134,7 +130,6 @@ postgis_datasource::postgis_datasource(parameters const& params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
std::string const postgis_datasource::name_="postgis";
|
std::string const postgis_datasource::name_="postgis";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue