[postgis-users] pgsql2shp bugfix: hard limit removed
Bernhard Reiter
bernhard at intevation.de
Thu Apr 25 10:04:45 PDT 2002
There was one hard limit in pgsql2shp
and we've managed to hit it here.
To save other people's time, here is a patch removing this hard
limit, which might have hit you with long column or table names.
(Patch is against cvs version from today, but also tested on cvs20020227)
Note: The buffer handling of the pgsql2shp is rather ugly code.
Bernhard
--
Professional Service for Free Software (intevation.net)
The FreeGIS Project (freegis.org)
Association for a Free Informational Infrastructure (ffii.org)
FSF Europe (fsfeurope.org)
-------------- next part --------------
? postgis-cvs20020425-pgsql2shp.patch
Index: pgsql2shp.c
===================================================================
RCS file: /home/cvs/postgis/postgis/loader/pgsql2shp.c,v
retrieving revision 1.9
diff -u -r1.9 pgsql2shp.c
--- pgsql2shp.c 2002/03/14 19:35:19 1.9
+++ pgsql2shp.c 2002/04/25 16:55:48
@@ -256,12 +256,17 @@
}
if(size==-1 && type != OID){ //-1 represents variable size in postgres, this should not occur, but use 32 bytes in case it does
- query1 = (char *)malloc(60); //hardcoded size for the following query
- strcpy(query1,"select max(octet_length(");
+ //( this is ugly: don't forget counting the length
+ // when changing the fixed query strings )
+ query1 = (char *)malloc(
+ 24+strlen(PQfname(res, i))+8+strlen(table)+1 );
+
+ strncpy(query1,"select max(octet_length(",24+1);
strcat(query1,PQfname(res, i));
- strcat(query1,")) from ");
+ strncat(query1,")) from ",8);
strcat(query1,table);
res2 = PQexec(conn, query1);
+
free(query1);
if(PQntuples(res2) > 0 ){
char *temp_int = (char *)PQgetvalue(res2, 0, 0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 248 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20020425/92ba3c95/attachment.pgp>
More information about the postgis-users
mailing list