Ticket #3124 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

single quote problem in postgresql validation query (PostGIS layer)

Reported by: christiangda Owned by: pramsey
Priority: normal Milestone: 5.4.2 release
Component: PostGIS Interface Version: 5.4
Severity: normal Keywords:
Cc: pramsey, sdlime

Description

When you use a PostGIS layer passing to it the geometry (see attachment map), the layer is drawed, but PostgreSQL log show this error:


VET-idleERROR: syntax error at or near "0105000020E610000007000000010200000002000000030000" at character 269 VET-idleSTATEMENT: select attname from pg_attribute, pg_constraint, pg_class where pg_constraint.conrelid = pg_class.oid and pg_class.oid = pg_attribute.attrelid and pg_constraint.contype = 'p' and pg_constraint.conkey[1] = pg_attribute.attnum and pg_class.relname = '(SELECT 1 as oid, '0105000020E610000007000000010200000002000000030000BFEDBA50C0190000782F072540C3A056D0EDBA50C0FDADEBCF2C072540010200000002000000C3A056D0EDBA50C0FDADEBCF2C07254061601029F2BA50C01C1D82E73307254001020000000200000061601029F2BA50C01C1D82E733072540EB17E849F6BA50C0A13009A33A072540010200000002000000EB17E849F6BA50C0A13009A33A07254083EA883EF4BA50C0046956478407254001020000000200000083EA883EF4BA50C00469564784072540396D4E91F3BA50C0806332219D072540010200000002000000396D4E91F3BA50C0806332219D072540396D4E91F3BA50C0826332219D072540010200000002000000396D4E91F3BA50C0806332219D072540020080FCF3BA50C0EEFFFFDB9D072540'::geometry AS the_geom) AS FOO' and pg_table_is_visible(pg_class.oid) and pg_constraint.conkey[2] is null


The problem are the two single quote in the argument "pg_class.relname =" see:

'(SELECT 1 as oid, '0,

if you can chage it to '(SELECT 1 as oid, 0 in runtime when you detect single quote within the string, maybe the proble was fixed.


1 Download the attachment map 2 shp2img -m sample.map -o sample.jpg 3 tail -30 your_postgresql_log_file.log


Attachments

sample.map Download (1.5 KB) - added by christiangda 4 years ago.
Map file
pg_subselect.patch Download (0.7 KB) - added by pramsey 4 years ago.

Change History

Changed 4 years ago by christiangda

Map file

  Changed 4 years ago by sdlime

  • owner changed from sdlime to mapserver-bugs@…
  • component changed from MapServer C Library to PostGIS Interface

  Changed 4 years ago by sdlime

  • cc pramsey, sdlime added

Changed 4 years ago by pramsey

follow-up: ↓ 4   Changed 4 years ago by pramsey

  • owner changed from mapserver-bugs@… to pramsey

Since the data source is not a table, the primary key cannot be looked up. As an interim measure, here is a patch which provides a reasonable error message. You can work around the problem by specifying a 'using unique' item in your data line, which will skip the primary key lookup and this error. In the longer term, with the one-pass query, the need for a primary key diminishes sharply, and the code should be examined to push the testing requirement into just those code paths which need it.

in reply to: ↑ 3   Changed 4 years ago by christiangda

  • status changed from new to closed
  • resolution set to fixed

Replying to pramsey:

Since the data source is not a table, the primary key cannot be looked up. As an interim measure, here is a patch which provides a reasonable error message. You can work around the problem by specifying a 'using unique' item in your data line, which will skip the primary key lookup and this error. In the longer term, with the one-pass query, the need for a primary key diminishes sharply, and the code should be examined to push the testing requirement into just those code paths which need it.

Thanks a lot, This solved my problem!.

  Changed 4 years ago by pramsey

Applied to trunk at r9310 and to 5.4 branch at r9309

Note: See TracTickets for help on using tickets.