[postgis-users] pgsql2shp bugfix: hard limit removed
Bernhard Reiter
bernhard@intevation.de
Thu Apr 25 18:04:45 2002
---------------------- multipart/signed attachment
--i9LlY+UWpKt15+FH
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
--=20
Professional Service for Free Software (intevation.net) =20
The FreeGIS Project (freegis.org)
Association for a Free Informational Infrastructure (ffii.org)
FSF Europe (fsfeurope.org)
--i9LlY+UWpKt15+FH
? postgis-cvs20020425-pgsql2shp.patch
Index: pgsql2shp.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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=3D=3D-1 && type !=3D OID){ //-1 represents variable size in post=
gres, this should not occur, but use 32 bytes in case it does
=09
- query1 =3D (char *)malloc(60); //hardcoded size for the following query
- strcpy(query1,"select max(octet_length(");
+ //( this is ugly: don't forget counting the length=20
+ // when changing the fixed query strings )
+ query1 =3D (char *)malloc(
+ 24+strlen(PQfname(res, i))+8+strlen(table)+1 );=20
+ =09
+ strncpy(query1,"select max(octet_length(",24+1);
strcat(query1,PQfname(res, i));
- strcat(query1,")) from ");
+ strncat(query1,")) from ",8);
strcat(query1,table);
res2 =3D PQexec(conn, query1); =09
+
free(query1);
if(PQntuples(res2) > 0 ){
char *temp_int =3D (char *)PQgetvalue(res2, 0, 0);
--i9LlY+UWpKt15+FH--
---------------------- multipart/signed attachment
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 248 bytes
Desc: not available
Url : http://lists.refractions.net/pipermail/postgis-users/attachments/20020425/92ba3c95/attachment.bin
---------------------- multipart/signed attachment--