]> granicus.if.org Git - postgis/commitdiff
Column name length limitation removed. Patch submitted by Bernhard
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 26 Apr 2002 16:13:33 +0000 (16:13 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 26 Apr 2002 16:13:33 +0000 (16:13 +0000)
Reiter <bernhard@intevation.de>

git-svn-id: http://svn.osgeo.org/postgis/trunk@139 b70326c6-7e19-0410-871a-916f4a2858ee

loader/pgsql2shp.c

index 8e47889d20b5b5ef72c5d64e01cee5641d317241..bf3bcd3c9178ae427561140efb04f411a23d95fa 100644 (file)
@@ -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);