[Geoserver-devel] App-schema test failure with oracle

Hi Ben & Jody,

I recently are trying to fix the Jenkins geoserver app-shcema online testing failure. (http://ares.opengeo.org/jenkins/view/geoserver/job/geoserver-master-app-schema-online/)

After I reproduced the problem at my developing machine , I found the issue may come org.geoserver.test.onlineTest.setup.AppSchemaTestOracleSetup.createTables. and it looks because the spatialIndex was not cleared after being used , and it then keep being added to the query.

after I added one line code to clear the spatialIndex in the loop, the Jenkins job works fine now.

Can someone review the code and confirm that this is a right fix.

Lingbo Jiang

Software Engineer
DP&S CSIRO
Cnr Vimiera & Pembroke Roads
MARSFIELD NSW 2122
Ph:+61-2-9372 4696
www.csiro.au/

//////////////////////////////////////

private void createTables(Map<String, File> propertyFiles, String parser)
            throws IllegalAttributeException, NoSuchElementException, IOException {
      
        StringBuffer buf = new StringBuffer();
        StringBuffer spatialIndex = new StringBuffer();
        // drop table procedure I copied from Victor's Oracle_Data_ref_set.sql
        buf
                .append("CREATE OR REPLACE PROCEDURE DROP_TABLE_OR_VIEW(TabName in Varchar2) IS ")
                .append("temp number:=0;")
                .append(" tes VARCHAR2 (200) := TabName;")
                .append(" drp_stmt VARCHAR2 (200):=null;")
                .append("BEGIN select count(*) into temp from user_tables where TABLE_NAME = tes;")
                .append("if temp = 1 then drp_stmt := 'Drop Table '||tes;")
                .append("EXECUTE IMMEDIATE drp_stmt;")
                 // drop views too
                .append("else select count(*) into temp from user_views where VIEW_NAME = tes;")
                .append("if temp = 1 then drp_stmt := 'Drop VIEW '||tes;")
                .append("EXECUTE IMMEDIATE drp_stmt;end if;end if;")
                .append("EXCEPTION WHEN OTHERS THEN ")
                .append(
                        "raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);")
                .append("END DROP_TABLE_OR_VIEW;\n");

        for (String fileName : propertyFiles.keySet()) {
                       ..................
                       ............Skip many line code............
                       .................
                       id = feature.getIdentifier();
                    // insert primary key
                    values[valueIndex] = "'" + id.toString() + "'";
                    buf.append(StringUtils.join(values, ","));
                    buf.append(")\n");
                }
            }
            buf.append(spatialIndex.toString());
            //////////////////////////
            spatialIndex.delete(0, spatialIndex.length()); /////// Since spatialIndex did not cleared , it will be added in next loop.
            //////////////////////////
            if (buf.length() > 0) {
                this.sql = buf.toString();
            }
        }
    }

I created a jira task for this issue (https://osgeo-org.atlassian.net/browse/GEOS-7069).

And pullrequest as well (https://github.com/geoserver/geoserver/pull/1102/files).

Lingbo Jiang

Software Engineer
DP&S CSIRO
Cnr Vimiera & Pembroke Roads
MARSFIELD NSW 2122
Ph:+61-2-9372 4696
www.csiro.au/
________________________________________
From: Lingbo.Jiang@anonymised.com [Lingbo.Jiang@anonymised.com]
Sent: Thursday, June 11, 2015 11:16 AM
To: jody.garnett@anonymised.com; ben@anonymised.com
Cc: geoserver-devel@lists.sourceforge.net
Subject: [ExternalEmail] [Geoserver-devel] App-schema test failure with oracle

Hi Ben & Jody,

I recently are trying to fix the Jenkins geoserver app-shcema online testing failure. (http://ares.opengeo.org/jenkins/view/geoserver/job/geoserver-master-app-schema-online/)

After I reproduced the problem at my developing machine , I found the issue may come org.geoserver.test.onlineTest.setup.AppSchemaTestOracleSetup.createTables. and it looks because the spatialIndex was not cleared after being used , and it then keep being added to the query.

after I added one line code to clear the spatialIndex in the loop, the Jenkins job works fine now.

Can someone review the code and confirm that this is a right fix.

Lingbo Jiang

Software Engineer
DP&S CSIRO
Cnr Vimiera & Pembroke Roads
MARSFIELD NSW 2122
Ph:+61-2-9372 4696
www.csiro.au/

//////////////////////////////////////

private void createTables(Map<String, File> propertyFiles, String parser)
            throws IllegalAttributeException, NoSuchElementException, IOException {

        StringBuffer buf = new StringBuffer();
        StringBuffer spatialIndex = new StringBuffer();
        // drop table procedure I copied from Victor's Oracle_Data_ref_set.sql
        buf
                .append("CREATE OR REPLACE PROCEDURE DROP_TABLE_OR_VIEW(TabName in Varchar2) IS ")
                .append("temp number:=0;")
                .append(" tes VARCHAR2 (200) := TabName;")
                .append(" drp_stmt VARCHAR2 (200):=null;")
                .append("BEGIN select count(*) into temp from user_tables where TABLE_NAME = tes;")
                .append("if temp = 1 then drp_stmt := 'Drop Table '||tes;")
                .append("EXECUTE IMMEDIATE drp_stmt;")
                 // drop views too
                .append("else select count(*) into temp from user_views where VIEW_NAME = tes;")
                .append("if temp = 1 then drp_stmt := 'Drop VIEW '||tes;")
                .append("EXECUTE IMMEDIATE drp_stmt;end if;end if;")
                .append("EXCEPTION WHEN OTHERS THEN ")
                .append(
                        "raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);")
                .append("END DROP_TABLE_OR_VIEW;\n");

        for (String fileName : propertyFiles.keySet()) {
                       ..................
                       ............Skip many line code............
                       .................
                       id = feature.getIdentifier();
                    // insert primary key
                    values[valueIndex] = "'" + id.toString() + "'";
                    buf.append(StringUtils.join(values, ","));
                    buf.append(")\n");
                }
            }
            buf.append(spatialIndex.toString());
            //////////////////////////
            spatialIndex.delete(0, spatialIndex.length()); /////// Since spatialIndex did not cleared , it will be added in next loop.
            //////////////////////////
            if (buf.length() > 0) {
                this.sql = buf.toString();
            }
        }
    }
------------------------------------------------------------------------------
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Jody,

FYI this looks good and has been merged by Victor. See the pull request for discussion.

Kind regards,
Ben.

On 11/06/15 14:28, Lingbo.Jiang@anonymised.com wrote:

I created a jira task for this issue (https://osgeo-org.atlassian.net/browse/GEOS-7069).

And pullrequest as well (https://github.com/geoserver/geoserver/pull/1102/files).

Lingbo Jiang

Software Engineer
DP&S CSIRO
Cnr Vimiera & Pembroke Roads
MARSFIELD NSW 2122
Ph:+61-2-9372 4696
www.csiro.au/
________________________________________
From: Lingbo.Jiang@anonymised.com [Lingbo.Jiang@anonymised.com]
Sent: Thursday, June 11, 2015 11:16 AM
To: jody.garnett@anonymised.com; ben@anonymised.com
Cc: geoserver-devel@lists.sourceforge.net
Subject: [ExternalEmail] [Geoserver-devel] App-schema test failure with oracle

Hi Ben & Jody,

I recently are trying to fix the Jenkins geoserver app-shcema online testing failure. (http://ares.opengeo.org/jenkins/view/geoserver/job/geoserver-master-app-schema-online/)

After I reproduced the problem at my developing machine , I found the issue may come org.geoserver.test.onlineTest.setup.AppSchemaTestOracleSetup.createTables. and it looks because the spatialIndex was not cleared after being used , and it then keep being added to the query.

after I added one line code to clear the spatialIndex in the loop, the Jenkins job works fine now.

Can someone review the code and confirm that this is a right fix.

Lingbo Jiang

Software Engineer
DP&S CSIRO
Cnr Vimiera & Pembroke Roads
MARSFIELD NSW 2122
Ph:+61-2-9372 4696
www.csiro.au/

//////////////////////////////////////

private void createTables(Map<String, File> propertyFiles, String parser)
             throws IllegalAttributeException, NoSuchElementException, IOException {

         StringBuffer buf = new StringBuffer();
         StringBuffer spatialIndex = new StringBuffer();
         // drop table procedure I copied from Victor's Oracle_Data_ref_set.sql
         buf
                 .append("CREATE OR REPLACE PROCEDURE DROP_TABLE_OR_VIEW(TabName in Varchar2) IS ")
                 .append("temp number:=0;")
                 .append(" tes VARCHAR2 (200) := TabName;")
                 .append(" drp_stmt VARCHAR2 (200):=null;")
                 .append("BEGIN select count(*) into temp from user_tables where TABLE_NAME = tes;")
                 .append("if temp = 1 then drp_stmt := 'Drop Table '||tes;")
                 .append("EXECUTE IMMEDIATE drp_stmt;")
                  // drop views too
                 .append("else select count(*) into temp from user_views where VIEW_NAME = tes;")
                 .append("if temp = 1 then drp_stmt := 'Drop VIEW '||tes;")
                 .append("EXECUTE IMMEDIATE drp_stmt;end if;end if;")
                 .append("EXCEPTION WHEN OTHERS THEN ")
                 .append(
                         "raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);")
                 .append("END DROP_TABLE_OR_VIEW;\n");

         for (String fileName : propertyFiles.keySet()) {
                        ..................
                        ............Skip many line code............
                        .................
                        id = feature.getIdentifier();
                     // insert primary key
                     values[valueIndex] = "'" + id.toString() + "'";
                     buf.append(StringUtils.join(values, ","));
                     buf.append(")\n");
                 }
             }
             buf.append(spatialIndex.toString());
             //////////////////////////
             spatialIndex.delete(0, spatialIndex.length()); /////// Since spatialIndex did not cleared , it will be added in next loop.
             //////////////////////////
             if (buf.length() > 0) {
                 this.sql = buf.toString();
             }
         }
     }
------------------------------------------------------------------------------
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand