Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#3124 closed defect (fixed)

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 (2)

sample.map (1.5 KB ) - added by christiangda 15 years ago.
Map file
pg_subselect.patch (747 bytes ) - added by pramsey 15 years ago.

Download all attachments as: .zip

Change History (7)

by christiangda, 15 years ago

Attachment: sample.map added

Map file

comment:1 by sdlime, 15 years ago

Component: MapServer C LibraryPostGIS Interface
Owner: changed from sdlime to mapserver-bugs@…

comment:2 by sdlime, 15 years ago

Cc: pramsey sdlime added

by pramsey, 15 years ago

Attachment: pg_subselect.patch added

comment:3 by pramsey, 15 years ago

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 comment:4 by christiangda, 15 years ago

Resolution: fixed
Status: newclosed

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!.

comment:5 by pramsey, 15 years ago

Applied to trunk at r9310 and to 5.4 branch at r9309

Note: See TracTickets for help on using tickets.