I provided a code snippet. Sure, I would provide the example as you suggested 
but I am not exactly sure that I understand what it should look like. Here is 
my best try:
/**
* This section throws exception
**/

String querystr = "DROP ALL";
Query query = QueryFactory.create(querystr); 

if( query.isSelectType() ){ // evaluated TRUE
        m_triplestore.enterCriticalSection(Lock.READ) ;
        try {
            QueryExecution qexec = QueryExecutionFactory.create(query, 
m_triplestore) ;
            ResultSet results = qexec.execSelect() ;
            print(outFormat, out, results);
            qexec.close();
        } finally { 
            m_triplestore.leaveCriticalSection(); 
        }
}


/**
* This section works fine
**/

String querystr = "DROP ALL";
Query query = QueryFactory.create(querystr); 
m_triplestore.enterCriticalSection(Lock.WRITE);
try {
            UpdateRequest updateRequest = UpdateFactory.create(querystr);
            UpdateAction.execute(updateRequest, m_triplestore);
}catch (Exception e){
            log.debug(e);
} finally {
            m_triplestore.commit();
            TDB.sync(m_triplestore);
            m_triplestore.leaveCriticalSection();
 }


So, the problem is that the query "DROP ALL" is evaluated as a SELECT query by 
query.isSelectType() method instead of being evaluated as an update query.

Milorad


ps. We use jena 2.6.4/arq 2.8.7/tdb 0.8.10 and we still didn't hit the limits 
in our development, so far so good (we are limited to Java 5). Migrating to new 
versions of Jena would usually require some efforts investment, so we will 
probably stick with the current version for some time. Does Jena 7 require Java 
6 or not?




>________________________________
> From: Andy Seaborne <[email protected]>
>To: [email protected] 
>Sent: Monday, March 5, 2012 1:44 PM
>Subject: Re: DROP query
> 
>On 05/03/12 12:31, Milorad Tosic wrote:
>> jena 2.6.4
>
>I get parse error for that as well.
>
>If you think it's a bug, please could provide a complete, minimal example?
>
>(Jena 2.7.0 has been released)
>
>    Andy
>
>>
>>
>>
>>
>>> ________________________________
>>> From: Andy Seaborne<[email protected]>
>>> To: [email protected]
>>> Sent: Monday, March 5, 2012 12:34 PM
>>> Subject: Re: DROP query
>>>
>>> On 05/03/12 07:39, Milorad Tosic wrote:
>>>> Hi,
>>>>
>>>> DROP clause is part of UPDATE SPARQL specification and  in ARQ queries it 
>>>> is processed accordingly with UpdateRequest as well as other UPDATE type 
>>>> requests, while SELECT type queries are processed with QueryExecution. So, 
>>>> in a query processor code, that accepts arbitrary SPARQL query, one must 
>>>> resolve type of the input query first and then apply appropriate class. I 
>>>> do the query type resolution as follows:
>>>>
>>>>                Query query = QueryFactory.create(querystr);
>>>>                if( query.isAskType() ){
>>>>                    executeAskSPARQL(querystr,out,outFormat);
>>>>                }else if( query.isConstructType() ){
>>>>                    executeConstructSPARQL(querystr,out,outFormat);
>>>>                }else if( query.isDescribeType() ){
>>>>                    executeDescribeSPARQL(querystr,out,outFormat);
>>>>                }else if( query.isSelectType() ){
>>>>                    executeQuerySPARQL(querystr, out, outFormat);
>>>>                }else{
>>>>                    // UPDATE is handled here
>>>>                    executeUpdateSPARQL(querystr);
>>>>                }
>>>>
>>>> However, DROP evaluates true on query.isSelectType() and ends up firing 
>>>> exception within executeQuerySPARQL. If DROP is processed by 
>>>> executeUpdateSPARQL, as it should be, everithing is fine.
>>>
>>>                Query query = QueryFactory.create(querystr);
>>>
>>> This should throw an exception if a DROP update request is passed in then 
>>> the rest of the code does not execute.
>>>
>>>
>>> Query query = QueryFactory.create("DROP GRAPH<http://example/g>") ;
>>> ==>
>>> Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: 
>>> Encountered " "drop" "DROP "" at line 1, column 1.
>>> Was expecting one of:
>>>      "base" ...
>>>      "prefix" ...
>>>      "select" ...
>>>      "describe" ...
>>>      "construct" ...
>>>      "ask" ...
>>>
>>>>
>>>> I would say that DROP evaluating true by query.isSelectType() is a bug?
>>>
>>> Which version are you running?
>>>
>>>      Andy
>>>
>>>>
>>>> Regards,
>>>> Milorad
>>>>
>>>
>>>
>>>
>>>
>
>
>
>

Reply via email to