From: Mark Cave-Ayland Date: Fri, 3 Feb 2012 21:04:01 +0000 (+0000) Subject: Fix construction of pgsql2shp's main retrieval query in ShpDumperOpenTable(). X-Git-Tag: 2.0.0alpha4~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2fff943f5e40e9950432bf2eff6ccb630c49d9f;p=postgis Fix construction of pgsql2shp's main retrieval query in ShpDumperOpenTable(). This fixes a regression which caused pgsql2shp to generate an incorrect SQL query for tables without any geo columns. git-svn-id: http://svn.osgeo.org/postgis/trunk@9020 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/pgsql2shp-core.c b/loader/pgsql2shp-core.c index fde9c071c..6a8166c74 100644 --- a/loader/pgsql2shp-core.c +++ b/loader/pgsql2shp-core.c @@ -1902,20 +1902,25 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state) for (i = 0; i < state->fieldcount; i++) { + /* Comma-separated column names */ + if (i > 0) + strcat(state->main_scan_query, ","); + if (state->config->binary) sprintf(buf, "\"%s\"::text", state->pgfieldnames[i]); else sprintf(buf, "\"%s\"", state->pgfieldnames[i]); strcat(state->main_scan_query, buf); - - /* Comma-separated column names */ - strcat(state->main_scan_query, ","); } /* If we found a valid geometry/geography column then use it */ if (state->geo_col_name) { + /* If this is the (only) column, no need for the initial comma */ + if (state->fieldcount > 0) + strcat(state->main_scan_query, ","); + if (state->big_endian) { if (state->pgis_major_version > 0)