[postgis-tickets] [PostGIS] #3701: Escape double quotes issue in pgsql2shp

PostGIS trac at osgeo.org
Thu Feb 2 08:08:11 PST 2017


#3701: Escape double quotes issue in pgsql2shp
----------------------+--------------------------------
  Reporter:  kalxas   |      Owner:  pramsey
      Type:  defect   |     Status:  new
  Priority:  medium   |  Milestone:  PostGIS PostgreSQL
 Component:  postgis  |    Version:  2.2.x
Resolution:           |   Keywords:
----------------------+--------------------------------

Comment (by kalxas):

 Reposting:

 I have an issue when I try to create shapefile using pgsql2shp if column
 alias contains double quotes. For example, my SQL query is:

 {{{
 SELECT
 c1 AS "geom",
 c2 AS """quoteColumn"
 FROM t1
 }}}

 I store this sql in a file, and if I run from console

 {{{
 $ pgsql2shp -r -g geom -f results -h localhost -u userName -P password
 databaseName "`cat query.sql`" 1>/dev/null
 }}}

 I get following error:

 {{{
 Error executing main scan query: ERROR:  zero-length delimited identifier
 at or near """"
 LINE 1: DECLARE cur CURSOR FOR SELECT ""quoteColumn",ST_AsEWKB(ST_Se...
 }}}

 If I change sql to:

 {{{
 SELECT
 c1 AS "geom",
 c2 AS """""quoteColumn"
 FROM t1
 }}}

 I got different error:

 {{{
 Error executing main scan query: ERROR:  column ""quoteColumn" does not
 exist
 LINE 1: DECLARE cur CURSOR FOR SELECT """quoteColumn",ST_AsEWKB(ST_S...
                                       ^
 HINT:  Perhaps you meant to reference the column
 "__pgsql2shp22020_tmp_table.""quoteColumn".
 }}}

 I use `pgsql2shp RELEASE: 2.2.1 (r14555)` on Ubuntu 16.04 LTS and don't
 have any issues if column alias in sql doesn't contain double quotes.

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3701#comment:1>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list