From e65163c6fccc7f37739c29b4eb90e87fef912c27 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 26 Apr 2002 16:13:33 +0000 Subject: [PATCH] Column name length limitation removed. Patch submitted by Bernhard Reiter git-svn-id: http://svn.osgeo.org/postgis/trunk@139 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/pgsql2shp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c index 8e47889d2..bf3bcd3c9 100644 --- a/loader/pgsql2shp.c +++ b/loader/pgsql2shp.c @@ -256,12 +256,17 @@ printf(conn_string); } 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);