Repository navigation
Open
Description
When using Oracle, SortBy is only applied to each page, it is not applied to all the data before paging. Is this deliberate? ie, if I submit a pull request to fix this is it likely to be accepted or rejected?
eg, in the following request note the startIndex and SortBy:
<GetFeature xmlns="http://www.opengis.net/wfs/2.0" service="WFS" version="2.0.0" startIndex="1000" count="1000" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Query typeNames="wfs:Planning_Application_Polygons" srsName="EPSG:27700" xmlns:wfs="http://mapserver.gis.umn.edu/mapserver">
<Filter xmlns="http://www.opengis.net/fes/2.0">
<BBOX>
<ValueReference>SHAPE</ValueReference>
<Envelope xmlns="http://www.opengis.net/gml/3.2" srsName="EPSG:27700">
<lowerCorner>139987.2407923497 -3524.05645833332</lowerCorner>
<upperCorner>316170.54920765024 157942.01645833335</upperCorner>
</Envelope>
</BBOX>
</Filter>
<SortBy xmlns="">
<SortProperty>
<PropertyName>DATEMODIFIED</PropertyName>
<SortOrder>DESC</SortOrder>
</SortProperty>
</SortBy>
</Query>
</GetFeature>
This results in the following SQL, note that ROWNUM is included in the inner query:
SELECT * from (
SELECT atmp.*, ROWNUM rnum from (
SELECT "REFVAL", "KEYVAL", "DATEMODIFIED", "ADDRESS", "DESCRIPTION", "OBJECTID", rownum, SHAPE
FROM PA_V1_6_DCAPPLICATIONS_POLY
WHERE ISPAVISIBLE = 1 AND SDO_FILTER( SHAPE, MDSYS.SDO_GEOMETRY(2003, :srid, NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),:ordinates ),'querytype=window') = 'TRUE'
ORDER BY "DATEMODIFIED" DESC
) atmp
where ROWNUM<=2000
)
where rnum >=1001
What I would like the SQL to be is this, so that the ordering is done before the paging:
SELECT * from (
SELECT atmp.*, ROWNUM rnum from (
SELECT btmp.*, ROWNUM from (
SELECT "REFVAL", "KEYVAL", "DATEMODIFIED", "ADDRESS", "DESCRIPTION", "OBJECTID", SHAPE
FROM PA_V1_6_DCAPPLICATIONS_POLY
WHERE ISPAVISIBLE = 1 AND SDO_FILTER( SHAPE, MDSYS.SDO_GEOMETRY(2003, :srid, NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),:ordinates ),'querytype=window') = 'TRUE'
ORDER BY "DATEMODIFIED" DESC
) btmp
) atmp
where ROWNUM<=2000
)
where rnum >=1001
Metadata
Metadata
Assignees
Labels
No labels
Activity
rouault commentedon Mar 26, 2026
clearly not
add oracle subquery to apply sortBy before rownum paging - MapServer#…
JamieIdox commentedon Mar 26, 2026
I have a suggested solution here: JamieIdox@8c64ac2
I am happy to do a pull request but I basically have zero knowledge of c and don't have a build environment so I haven't even checked it builds.
geographika commentedon Mar 27, 2026
@JamieIdox - unfortunately we don't have CI in place to test the Oracle driver, or it would have been fairly straight-forward to add a test for this. Please open a PR anyway, as this is a valid bug, and maybe another MapServer Oracle user will be able to test.
msmitherdc commentedon Mar 27, 2026
@geographika I can build and test a pr
JamieIdox commentedon Mar 27, 2026
I'm assuming that this error is not due to my changes?
geographika commentedon Mar 28, 2026
No, this was due to GitHub Actions updating ubuntu-latest from Ubuntu 22.04 to Ubuntu 24.04.
Oracle: add subquery to apply sortBy before rownum paging - #7463 (#7464
[Backport branch-8-6] Oracle: add subquery to apply sortBy before row…
Revert "Oracle: add subquery to apply sortBy before rownum paging - #…
Revert "Oracle: add subquery to apply sortBy before rownum paging - #…