Opened 19 years ago

Closed 19 years ago

#957 closed defect (later)

msQueryByAttributes monkey's with a layer's filter causing a segfault

Reported by: hobu Owned by: sdlime
Priority: high Milestone:
Component: MapServer C Library Version: unspecified
Severity: normal Keywords:
Cc:

Description

I don't know if this is a bug or a feature, but here is what was provoking my
problem.

I have a layer that has null attributes in it.  This layer is in SDE.  I have a
filter defined to FILTER "where COUNT_ is not NULL" to prevent it from querying
out <null> values that cause the expression parser to choke.

So, once this is done, I want to be able to queryByAttributes from the layer as
well.  This time, however, I'm querying from the STATE column.  When I attempt
to do this from mapscript with a layer that already has its FILTER set, a
segfault erupts.

Am I misusing FILTER's?
---------------------------------------------------
Python script that provokes the error:
---------------------------------------------------
#!/usr/bin/python
import mapscript
amap = mapscript.mapObj('/home/hobu/prs/prs.map')
counties = amap.getLayerByName("counties")
qstring = "UPPER(STATE) = '46'"
qryresult = counties.queryByAttributes(amap,'STATE',qstring,mapscript.MS_MULTIPLE)
print 'done'
---------------------------------------------------

---------------------------------------------------
Relevant mapfile definition
---------------------------------------------------
  LAYER  
    NAME         counties
    TYPE         POLYGON
    CONNECTION "sde.cssm.iastate.edu,port:5151,sde,username,password"
    CONNECTIONTYPE sde
    DATA "SDEDATA.SDEDATA_counties_noreg,shape,SDE.DEFAULT"
    TEMPLATE "/home/hobu/psudataview/templates/footer.html"
    STATUS       ON
    DEBUG ON
    FILTER "where COUNT_ is not NULL"
END
---------------------------------------------------

---------------------------------------------------
GDB output
---------------------------------------------------
0x00c80343 in strlen () from /lib/tls/libc.so.6
(gdb) bt
#0  0x00c80343 in strlen () from /lib/tls/libc.so.6
#1  0x00c80085 in strdup () from /lib/tls/libc.so.6
#2  0x0022a21f in msQueryByAttributes (map=0xb75af008, qlayer=163439776,
qitem=0x9b7431c "STATE", 
    qstring=0x0, mode=1) at mapquery.c:258
#3  0x001d00de in layerObj_queryByAttributes (self=0x0, map=0x0, qitem=0x0,
qstring=0x0, mode=0)
    at mapscript_wrap.c:1672
#4  0x001ec3d0 in _wrap_layerObj_queryByAttributes (self=0x0, args=0x0) at
mapscript_wrap.c:15534
#5  0x080d18e4 in PyCFunction_Call ()
#6  0x080b3d67 in PyObject_Call ()
#7  0x0807d0a3 in PyEval_GetFuncDesc ()
#8  0x0807b031 in PyEval_EvalCode ()
#9  0x0807b65e in PyEval_EvalCodeEx ()
#10 0x0807cbbb in PyEval_GetFuncDesc ()
#11 0x0807ab33 in PyEval_EvalCode ()
#12 0x0807b65e in PyEval_EvalCodeEx ()
#13 0x08078555 in PyEval_EvalCode ()
#14 0x08098569 in PyRun_FileExFlags ()
#15 0x080974d0 in PyRun_SimpleFileExFlags ()
#16 0x08096e1a in PyRun_AnyFileExFlags ()
#17 0x08053ac9 in Py_Main ()
#18 0x08053519 in main ()
---------------------------------------------------

Change History (5)

comment:1 by sdlime, 19 years ago

Status: newassigned
Summary: msQueryByAttributes monkey's with a layer's filter causing a segfault msQueryByAttributes monkey's with a layer's filter causing a segfault
The code should temporarily override the filter and create a new one for the 
attribute filter and then restore the original. Can you try the same test with 
a shapefile and see if you get the same error. I'm curious if this could be SDE 
specific. Should be easy to fix I think.

Steve

comment:2 by sdlime, 19 years ago

Howard, anything new on this? Have you tested with a shapefile?

Steve

comment:3 by sdlime, 19 years ago

I'll ask again, anything new? I need to know if this should be persued before
4.4 is released. I don't have SDE to test against so if shapefiles produced the
same error that would help. On the otherhand it may be an SDE-only issue...

Steve

comment:4 by hobu, 19 years ago

I don't have time to pursue this before the release, and I suggest we table it
until after the release.  The issue is small enough that I was able to easily
work around it.

comment:5 by sdlime, 19 years ago

Resolution: later
Status: assignedclosed
Fine by me...
Note: See TracTickets for help on using tickets.