[ 
https://issues.apache.org/jira/browse/TRAFODION-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15507110#comment-15507110
 ] 

David Wayne Birdsall commented on TRAFODION-2223:
-------------------------------------------------

I spent some time playing with the original issue yesterday. There are two 
levels of validation of the WHERE clause. The first is in 
HSGlobalsClass::validateIUSWhereClause (ustat/hs_globals.cpp), where it does a 
parse and checks for certain constructs (the parser looks for the SAMPLE clause 
and qualified column references). If either of those are found, error 9237 
results. However, it explicitly does not check for parsing errors, preferring 
to let later code report those errors. The second level is 
HSCursor::prepareRowsetInternal, which catches any errors in the WHERE clause 
when it prepares a query against the persistent sample table. Unfortunately, 
that method is raising the not-so-nice internal error seen in this case.

This second method is fairly general; in many code paths the internal error is 
the desired one.

It is tempting to push the syntax error check up into 
HSGlobalsClass::validateIUSWhereClause rather than deferring it to the second 
level. I experimented with this, but it is an incomplete solution. One could 
have a syntactically correct WHERE clause, for example, but mistype a column 
name. We would need a bind step to catch that sort of error.

So it seems like the solution is to add a parameter to 
HSCursor::prepareRowsetInternal so that a different error is reported for 
queries using the WHERE clause. The new error would point to the WHERE clause 
itself as the possible culprit.

One final note: The case shows that even though we had an error on this first 
query, the error is ignored by the caller and we continue with update stats 
processing, resulting in another error. That needs to be fixed; we should not 
be ignoring the first error.

> INC UPD STATS: an invalid WHERE predicate results in an internal error
> ----------------------------------------------------------------------
>
>                 Key: TRAFODION-2223
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-2223
>             Project: Apache Trafodion
>          Issue Type: Bug
>          Components: sql-cmp
>         Environment: Probably all
>            Reporter: David Wayne Birdsall
>            Assignee: David Wayne Birdsall
>
> An invalid WHERE predicate on an incremental update statistics command 
> results in an internal error. Here is an example from regression test 
> compGeneral/TEST023. We should give a cleaner error here.
> >>update statistics for table stest on existing columns incremental where 1;
> *** ERROR[9200] UPDATE STATISTICS for table 
> TRAFODION.COMPGENERAL_TEST023.STEST encountered an error (15001) from 
> statement HSCursor::prepareRowsetInternal().
> *** ERROR[15001] A syntax error occurred at or before: 
> SELECT "C1", "C2", "C3", "_SALT_" FROM 
> TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPL
> E_53_1473872773_525053 WHERE  1 FOR READ UNCOMMITTED ACCESS;
>                                         ^ (120 characters from start of SQL 
> statement)
> *** ERROR[8822] The statement was not prepared.
> *** ERROR[9200] UPDATE STATISTICS for table 
> TRAFODION.COMPGENERAL_TEST023.STEST encountered an error (15001) from 
> statement POPULATE_FROM_QUERY.
> *** ERROR[15001] A syntax error occurred at or before: 
> SELECT "C1", "C2", "C3", "_SALT_" FROM 
> TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPL
> E_53_1473872773_525053 WHERE  1 FOR READ UNCOMMITTED ACCESS;
>                                         ^ (120 characters from start of SQL 
> statement)
> *** ERROR[8822] The statement was not prepared.
> --- SQL operation failed with errors.
> >>



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to