Repository: incubator-trafodion
Updated Branches:
  refs/heads/master b07378dc0 -> 06635c5cc


[TRAFODION-2223] Improve error reporting on bad incremental WHERE clause


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/25077b5a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/25077b5a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/25077b5a

Branch: refs/heads/master
Commit: 25077b5a340d23e6949ef3f976b142b13e63cdf1
Parents: 9439b68
Author: Dave Birdsall <dbirds...@apache.org>
Authored: Wed Sep 21 19:01:12 2016 +0000
Committer: Dave Birdsall <dbirds...@apache.org>
Committed: Wed Sep 21 19:01:12 2016 +0000

----------------------------------------------------------------------
 core/sql/bin/SqlciErrors.txt                    |  8 +--
 core/sql/regress/compGeneral/EXPECTED023        | 70 +++++++++++---------
 core/sql/regress/compGeneral/TEST023            |  7 ++
 core/sql/sqlcomp/DefaultConstants.h             |  2 -
 core/sql/sqlcomp/nadefaults.cpp                 |  5 --
 core/sql/ustat/hs_cli.cpp                       |  7 +-
 core/sql/ustat/hs_const.h                       |  5 +-
 core/sql/ustat/hs_globals.cpp                   | 34 +++++++---
 core/sql/ustat/hs_yacc.y                        | 48 +++-----------
 .../asciidoc/_chapters/update_stats_msgs.adoc   | 15 +++++
 10 files changed, 105 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index 17eb12d..3113d4a 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -1866,8 +1866,8 @@ drop the default context
 9216 ZZZZZ 99999 BEGINNER MAJOR DBADMIN UPDATE STATISTICS cannot be on EVERY 
COLUMN for LOG tables. 
 9217 ZZZZZ 99999 BEGINNER INFRM DBADMIN The statement will have no effect 
because no histograms are currently maintained for the table.
 9218 ZZZZZ 99999 BEGINNER INFRM DBADMIN The statement will have no effect 
because no histograms need to be updated.
-9219 ZZZZZ 99999 ADVANCED MAJOR DBADMIN The NECESSARY clause is only allowed 
on tables of schema version 2300 or higher.
-9220 ZZZZZ 99999 BEGINNER INFRM DBADMIN The temporary workspace schema 
$0~string0.PUBLIC_ACCESS_SCHEMA does not exist. Query plan could be improved if 
PUBLIC_ACCESS_SCHEMA is created in $0~string0 catalog.
+9219 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Incremental UPDATE STATISTICS: An 
operation failed, possibly due to an invalid WHERE clause.
+9220 ZZZZZ 99999 BEGINNER INFRM DBADMIN --- unused ---
 9221 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Incremental UPDATE STATISTICS cannot 
be performed due to the absence of the IUS persistent sample table for 
$0~string0.  Use a regular UPDATE STATISTICS command with the sample clause and 
PERSISTENT first to create such a persistent sample table.
 9222 ZZZZZ 99999 BEGINNER MINOR LOGONLY Incremental UPDATE STATISTICS: the 
rowcount in an interval for column $0~String0 changed more than the percentage 
specified by CQD USTAT_IUS_INTERVAL_ROWCOUNT_CHANGE_THRESHOLD. A regular UPDATE 
STATISTICS is performed instead.
 9223 ZZZZZ 99999 BEGINNER MINOR LOGONLY Incremental UPDATE STATISTICS: the 
total rowcount for column $0~String0 changed more than the percentage specified 
by CQD USTAT_IUS_TOTAL_ROWCOUNT_CHANGE_THRESHOLD. A regular UPDATE STATISTICS 
is performed instead.
@@ -1879,9 +1879,9 @@ drop the default context
 9230 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Incremental UPDATE STATISTICS: $0~int0 
columns could not be processed due to insufficient memory, and are being 
processed by regular UPDATE STATISTICS instead.
 9231 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Incremental UPDATE STATISTICS: only 
RANDOM <percentage> PERCENT is allowed as the sampling specification with 
PERSISTENT.
 9232 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Incremental UPDATE STATISTICS: cannot 
proceed because of the on-going IUS transaction originated at $0~String0. 
-9233 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Incremental UPDATE STATISTICS: could 
not store search condition used for IUS because it exceeds $0~int0 characters. 
+9233 ZZZZZ 99999 BEGINNER MAJOR DBADMIN --- unused --- 
 9234 ZZZZZ 99999 BEGINNER MINOR LOGONLY Incremental UPDATE STATISTICS: a new 
high frequency value is detected for column $0~string0. A regular UPDATE 
STATISTICS is performed instead.
-9235 ZZZZZ 99999 BEGINNER MINOR LOGONLY Incremental UPDATE STATISTICS 
$0~String0.
+9235 ZZZZZ 99999 BEGINNER MINOR LOGONLY --- unused ---
 9236 ZZZZZ 99999 BEGINNER MINOR LOGONLY Incremental UPDATE STATISTICS: the 
histogram for column $0~string0 is empty. A regular UPDATE STATISTICS is 
performed instead.
 9237 ZZZZZ 99999 BEGINNER MINOR LOGONLY Incremental UPDATE STATISTICS: WHERE 
clause of an IUS statement cannot contain $0~String0.
 9238 ZZZZZ 99999 BEGINNER INFRM DBADMIN Histograms were updated successfully, 
but partition statistics could not be updated from file labels.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/regress/compGeneral/EXPECTED023
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED023 
b/core/sql/regress/compGeneral/EXPECTED023
index 8996b0d..8461ac1 100644
--- a/core/sql/regress/compGeneral/EXPECTED023
+++ b/core/sql/regress/compGeneral/EXPECTED023
@@ -119,7 +119,7 @@ STEST_EMPTY
 OBJECT_NAME                                                                    
                                                                                
                                                                                
                   SAMPLE_NAME                                                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                         REASON  LAST_WHERE_PREDICATE
 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ------  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_42_1473872687_899942                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      M                                                         
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
+STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_01_1474483126_801601                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      M                                                         
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
 
 --- 1 row(s) selected.
 >>-- should see one row
@@ -135,7 +135,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_42_1473872687_899942
+TRAF_SAMPLE_01_1474483126_801601
 
 --- SQL operation complete.
 >> -- should be stest, stest_empty, stestc, sb_* tables + a sample table
@@ -159,7 +159,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_51_1473872720_555851
+TRAF_SAMPLE_1_1474483161_60841
 
 --- SQL operation complete.
 >> -- should be stest, stest_empty, stestc, sb_* tables + a different sample 
 >> table
@@ -169,7 +169,7 @@ TRAF_SAMPLE_51_1473872720_555851
 OBJECT_NAME                                                                    
                                                                                
                                                                                
                   SAMPLE_NAME                                                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                         REASON  LAST_WHERE_PREDICATE
 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ------  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_51_1473872720_555851                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      M                                                         
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
+STEST                                                                          
                                                                                
                                                                                
                   TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_1_1474483161_60841 
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                         M                                      
                                                                                
                                                                                
                                      
                                                                                
                                                                                
                                                                                
                                
 
 --- 1 row(s) selected.
 >>-- should see one row
@@ -216,7 +216,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_81_1473872746_376381
+TRAF_SAMPLE_67_1474483187_693567
 
 --- SQL operation complete.
 >> -- should be stest, stest_empty, stestc, sb_* tables + another sample table
@@ -226,7 +226,7 @@ TRAF_SAMPLE_81_1473872746_376381
 OBJECT_NAME                                                                    
                                                                                
                                                                                
                   SAMPLE_NAME                                                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                         REASON  LAST_WHERE_PREDICATE
 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ------  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_81_1473872746_376381                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      I                                                         
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
+STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_67_1474483187_693567                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      I                                                         
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
 
 --- 1 row(s) selected.
 >>-- should see one row
@@ -250,7 +250,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_53_1473872773_525053
+TRAF_SAMPLE_85_1474483214_345185
 
 --- SQL operation complete.
 >> -- should be stest, stest_empty, stestc, sb_* tables + another sample table
@@ -260,7 +260,7 @@ TRAF_SAMPLE_53_1473872773_525053
 OBJECT_NAME                                                                    
                                                                                
                                                                                
                   SAMPLE_NAME                                                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                         REASON  LAST_WHERE_PREDICATE
 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ------  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_53_1473872773_525053                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      I                                                         
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
+STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_85_1474483214_345185                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      I                                                         
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
 
 --- 1 row(s) selected.
 >>-- should see one row
@@ -301,6 +301,10 @@ STEST
 >>
 >>-- These two CQDs are to get around annoying 9222 and 9224 warnings
 >>-- that happen non-deterministically due to "gaps" in the sample histograms.
+>>-- Note: The warnings now only appear if "update statistics log on" is in 
+>>-- force, which it isn't here. Nevertheless the CQDs encourage the exercise
+>>-- of a particular code path within the incremental update stats code so
+>>-- we leave them here.
 >>cqd USTAT_IUS_INTERVAL_ROWCOUNT_CHANGE_THRESHOLD '0.15';
 
 --- SQL operation complete.
@@ -317,7 +321,7 @@ STEST
 OBJECT_NAME                                                                    
                                                                                
                                                                                
                   SAMPLE_NAME                                                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                         REASON  LAST_WHERE_PREDICATE
 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ------  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_53_1473872773_525053                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      I        c1 >= 100000                                     
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
+STEST                                                                          
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_85_1474483214_345185                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      I        c1 >= 100000                                     
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
 
 --- 1 row(s) selected.
 >>
@@ -374,8 +378,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_34_1473872821_557534
-TRAF_SAMPLE_53_1473872773_525053
+TRAF_SAMPLE_06_1474483266_729006
+TRAF_SAMPLE_85_1474483214_345185
 
 --- SQL operation complete.
 >>
@@ -384,7 +388,7 @@ TRAF_SAMPLE_53_1473872773_525053
 OBJECT_NAME                                                                    
                                                                                
                                                                                
                   SAMPLE_NAME                                                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                         REASON  LAST_WHERE_PREDICATE
 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ------  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STESTC                                                                         
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_34_1473872821_557534                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      I        c1 >= 'naaaa'                                    
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
+STESTC                                                                         
                                                                                
                                                                                
                   
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_06_1474483266_729006                  
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      I        c1 >= 'naaaa'                                    
                                                                                
                                                                                
                   
                                                                                
                                                                                
                                                                                
                                
 
 --- 1 row(s) selected.
 >>
@@ -409,8 +413,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_34_1473872821_557534
-TRAF_SAMPLE_53_1473872773_525053
+TRAF_SAMPLE_06_1474483266_729006
+TRAF_SAMPLE_85_1474483214_345185
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables"
@@ -435,8 +439,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_34_1473872821_557534
-TRAF_SAMPLE_53_1473872773_525053
+TRAF_SAMPLE_06_1474483266_729006
+TRAF_SAMPLE_85_1474483214_345185
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables"
@@ -464,8 +468,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_34_1473872821_557534
-TRAF_SAMPLE_53_1473872773_525053
+TRAF_SAMPLE_06_1474483266_729006
+TRAF_SAMPLE_85_1474483214_345185
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables"
@@ -473,20 +477,11 @@ TRAF_SAMPLE_53_1473872773_525053
 >>-- attempt to do incremental with an invalid where clause
 >>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[9219] Incremental UPDATE STATISTICS: An operation failed, possibly 
due to an invalid WHERE clause.
 
 *** 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;
+E_85_1474483214_345185 WHERE  1 FOR READ UNCOMMITTED ACCESS;
                                         ^ (120 characters from start of SQL 
statement)
 
 *** ERROR[8822] The statement was not prepared.
@@ -504,12 +499,23 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_34_1473872821_557534
-TRAF_SAMPLE_53_1473872773_525053
+TRAF_SAMPLE_06_1474483266_729006
+TRAF_SAMPLE_85_1474483214_345185
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables"
 >>
+>>-- attempt to do incremental with a syntactically valid but semantically 
invalid where clause
+>>update statistics for table stest on existing columns incremental where 
badcol > 5;
+
+*** ERROR[9219] Incremental UPDATE STATISTICS: An operation failed, possibly 
due to an invalid WHERE clause.
+
+*** ERROR[4001] Column BADCOL is not found.  Tables in scope: 
TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_85_1474483214_345185.  Default 
schema: TRAFODION.SEABASE.
+
+*** ERROR[8822] The statement was not prepared.
+
+--- SQL operation failed with errors.
+>>
 >>-- attempt to do incremental when no persistent sample exists
 >>update statistics for table stestc remove sample;
 
@@ -545,7 +551,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_53_1473872773_525053
+TRAF_SAMPLE_85_1474483214_345185
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables" except only one sample table

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/regress/compGeneral/TEST023
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/TEST023 
b/core/sql/regress/compGeneral/TEST023
index 1e8431d..e527c23 100755
--- a/core/sql/regress/compGeneral/TEST023
+++ b/core/sql/regress/compGeneral/TEST023
@@ -181,6 +181,10 @@ insert into stest values (100000,1,1),
 
 -- These two CQDs are to get around annoying 9222 and 9224 warnings
 -- that happen non-deterministically due to "gaps" in the sample histograms.
+-- Note: The warnings now only appear if "update statistics log on" is in 
+-- force, which it isn't here. Nevertheless the CQDs encourage the exercise
+-- of a particular code path within the incremental update stats code so
+-- we leave them here.
 cqd USTAT_IUS_INTERVAL_ROWCOUNT_CHANGE_THRESHOLD '0.15';
 cqd USTAT_IUS_INTERVAL_UEC_CHANGE_THRESHOLD '0.15'; 
 
@@ -256,6 +260,9 @@ update statistics for table stest on existing columns 
incremental where 1;
 
 get tables; -- should be the same as previous "get tables"
 
+-- attempt to do incremental with a syntactically valid but semantically 
invalid where clause
+update statistics for table stest on existing columns incremental where badcol 
> 5;
+
 -- attempt to do incremental when no persistent sample exists
 update statistics for table stestc remove sample;
 update statistics for table stestc on existing columns incremental where c1 >= 
'naaaa';

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/sqlcomp/DefaultConstants.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/DefaultConstants.h 
b/core/sql/sqlcomp/DefaultConstants.h
index be9bf5a..0b32ce1 100644
--- a/core/sql/sqlcomp/DefaultConstants.h
+++ b/core/sql/sqlcomp/DefaultConstants.h
@@ -3319,8 +3319,6 @@ enum DefaultConstants
 
   USTAT_IUS_NO_BLOCK,
 
-  USTAT_IUS_SIMPLE_SYNTAX,
-
   // Collect reorg stats. Default is ON and stats are collected. 
   // This cqd is added in case
   // one need to go back to the old behavior of no reorg stats, or if a problem

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp
index c9d73b4..bc6ee00 100644
--- a/core/sql/sqlcomp/nadefaults.cpp
+++ b/core/sql/sqlcomp/nadefaults.cpp
@@ -3548,11 +3548,6 @@ XDDkwd__(SUBQUERY_UNNESTING,                     "ON"),
   DDkwd__(USTAT_IUS_NO_BLOCK,                   "OFF"),
   DDansi_(USTAT_IUS_PERSISTENT_CBF_PATH,        "SYSTEM"),
 
-  // if turned on, IUS incremental statements will not take any "on existing" 
or
-  // "on necessary" clause
-  DDkwd__(USTAT_IUS_SIMPLE_SYNTAX,                "OFF"),
-
-
   DDflt0_(USTAT_IUS_TOTAL_ROWCOUNT_CHANGE_THRESHOLD, "0.05"),
   DDflt0_(USTAT_IUS_TOTAL_UEC_CHANGE_THRESHOLD, "0.05"),
   DDkwd__(USTAT_IUS_USE_PERIODIC_SAMPLING,        "OFF"),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp
index 6ac6c2f..1260566 100644
--- a/core/sql/ustat/hs_cli.cpp
+++ b/core/sql/ustat/hs_cli.cpp
@@ -2680,8 +2680,11 @@ Lng32 HSCursor::prepareRowsetInternal
 (const char *cliStr, NABoolean orderAndGroup,
  HSColGroupStruct *group, Lng32 maxRows)
   {
-    HSErrorCatcher errorCatcher(retcode_, -UERR_INTERNAL_ERROR,
-                                "HSCursor::prepareRowsetInternal()", TRUE);
+    // Not needed, as there is an error catcher in all of the caller's
+    // code paths. (And having two of them results in double reporting
+    // of the errors.)
+    //HSErrorCatcher errorCatcher(retcode_, -UERR_INTERNAL_ERROR,
+    //                            "HSCursor::prepareRowsetInternal()", TRUE);
     HSLogMan *LM = HSLogMan::Instance();
     HSColGroupStruct *col = group;
     Lng32 numResults = 0;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/ustat/hs_const.h
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_const.h b/core/sql/ustat/hs_const.h
index 4e292a2..3646a38 100644
--- a/core/sql/ustat/hs_const.h
+++ b/core/sql/ustat/hs_const.h
@@ -144,8 +144,7 @@ enum USTAT_ERROR_CODES {UERR_SYNTAX_ERROR                   
 = 15001,
                         UERR_EVERY_COLUMN_NOT_ALLOWED_FOR_LOG  = 9216,
                         UERR_WARNING_NO_EXISTING_HISTOGRAMS  = 9217,
                         UERR_WARNING_NO_OBSOLETE_HISTOGRAMS  = 9218,
-                        UERR_NECESSARY_REQUIRES_AUTOMATION   = 9219,
-                        UERR_WARNING_NO_PUBLIC_ACCESS_SCHEMA = 9220,
+                        UERR_IUS_BAD_WHERE_CLAUSE            = 9219,
                         UERR_IUS_NO_PERSISTENT_SAMPLE        = 9221,
                         UERR_WARNING_IUS_TOO_MUCH_RC_CHANGE_INTERVAL = 9222,
                         UERR_WARNING_IUS_TOO_MUCH_RC_CHANGE_TOTAL = 9223,
@@ -157,9 +156,7 @@ enum USTAT_ERROR_CODES {UERR_SYNTAX_ERROR                   
 = 15001,
                         UERR_WARNING_IUS_INSUFFICIENT_MEMORY = 9230,
                         UERR_IUS_WRONG_RANDOM                = 9231,
                         UERR_IUS_IN_PROGRESS                 = 9232,
-                        UERR_WARNING_IUS_WHERE_CLAUSE_TOO_LONG = 9233,
                         UERR_IUS_INSERT_NONMFV_OVERFLOW      = 9234,
-                        UERR_IUS_ON_CLAUSE                   = 9235,
                         UERR_IUS_NO_EXISTING_STATS           = 9236,
                         UERR_IUS_WHERE_CLAUSE                = 9237,
                         UERR_WARNING_FILESTATS_FAILED        = 9238,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index f194c23..70adda5 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -5814,8 +5814,12 @@ Lng32 HSGlobalsClass::doFullIUS(Int64 currentSampleSize,
      //
      if ( colsSelected == 0 ) {
        if ( ranOutOfMem ) {
-         diagsArea << DgSqlCode(UERR_WARNING_IUS_INSUFFICIENT_MEMORY)
-                   << DgInt0(moreColsForIUS());
+         if (LM->LogNeeded())
+           {
+             // only do the warning diagnostic if logging is enabled
+             diagsArea << DgSqlCode(UERR_WARNING_IUS_INSUFFICIENT_MEMORY)
+                       << DgInt0(moreColsForIUS());
+           }
          break;  // Let RUS handle the rest
        } else {
          if (LM->LogNeeded())
@@ -13180,9 +13184,10 @@ Int32 
HSGlobalsClass::estimateAndTestIUSStats(HSColGroupStruct* group,
                           "  u = too much UEC change",
                 group->colSet[0].colname->data());
         LM->Log(LM->msg);
+        // only issue the warning diagnostic if logging is on
+        diagsArea << DgSqlCode(shapeTestError)
+                  << DgString0(group->colSet[0].colname->data());
         }
-     diagsArea << DgSqlCode(shapeTestError)
-               << DgString0(group->colSet[0].colname->data());
      LM->StopTimer();
      return shapeTestError;
      }
@@ -13221,8 +13226,12 @@ Int32 
HSGlobalsClass::estimateAndTestIUSStats(HSColGroupStruct* group,
 
   if ( (totalRC > (UInt64)origTotalRC) &&
       delta((UInt64)origTotalRC, totalRC)/origTotalRC > rcTotalChangeThreshold 
)  {
-     diagsArea << DgSqlCode(UERR_WARNING_IUS_TOO_MUCH_RC_CHANGE_TOTAL)
-               << DgString0(group->colSet[0].colname->data());
+     if (LM->LogNeeded()) 
+       {
+         // only do the warning diagnostic if logging is enabled
+         diagsArea << DgSqlCode(UERR_WARNING_IUS_TOO_MUCH_RC_CHANGE_TOTAL)
+                   << DgString0(group->colSet[0].colname->data());
+       }
      LM->StopTimer();
      return UERR_WARNING_IUS_TOO_MUCH_RC_CHANGE_TOTAL;
   }
@@ -13235,8 +13244,12 @@ Int32 
HSGlobalsClass::estimateAndTestIUSStats(HSColGroupStruct* group,
 
   if ((totalUEC > (UInt64)origTotalUEC) && 
       delta((UInt64)origTotalUEC, totalUEC)/origTotalUEC > 
uecTotalChangeThreshold ) {
-     diagsArea << DgSqlCode(UERR_WARNING_IUS_TOO_MUCH_UEC_CHANGE_TOTAL)
-               << DgString0(group->colSet[0].colname->data());
+     if (LM->LogNeeded()) 
+       {
+         // only do the warning diagnostic if logging is enabled
+         diagsArea << DgSqlCode(UERR_WARNING_IUS_TOO_MUCH_UEC_CHANGE_TOTAL)
+                   << DgString0(group->colSet[0].colname->data());
+       }
      LM->StopTimer();
      return UERR_WARNING_IUS_TOO_MUCH_UEC_CHANGE_TOTAL;
   }
@@ -15992,7 +16005,10 @@ Lng32 HSInMemoryTable::populate(NAString& queryText)
   Int64 rowsLeft;
   HSCursor popCursor;
 
-  HSErrorCatcher errorCatcher(retcode, - UERR_INTERNAL_ERROR, 
+  // the most likely error is on a prepare due to a bad WHERE clause
+  // from the UPDATE STATS command itself; e.g. a syntax error or
+  // perhaps a bad column reference due to a typo
+  HSErrorCatcher errorCatcher(retcode, - UERR_IUS_BAD_WHERE_CLAUSE, 
                               "POPULATE_FROM_QUERY", TRUE);
   LM->Log("Preparing rowset...");
   // Allocate descriptors and statements for CLI and prepare rowset by

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/core/sql/ustat/hs_yacc.y
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_yacc.y b/core/sql/ustat/hs_yacc.y
index 0ee1ca4..aaca423 100644
--- a/core/sql/ustat/hs_yacc.y
+++ b/core/sql/ustat/hs_yacc.y
@@ -374,22 +374,7 @@ histogram_options : CLEAR
                         hs_globals_y->optFlags |= CLEAR_OPT;
                       }
                  |  on_clause_wrapper interval_clause
-                 |  incremental_clause
-                      {
-                         if (CmpCommon::getDefault(USTAT_IUS_SIMPLE_SYNTAX) == 
DF_OFF) {
-                           HSFuncMergeDiags(- UERR_IUS_ON_CLAUSE,
-                                              ": the on existing/necessary 
clause is missing");
-                           return -1;
-                         }
-                      }
                  |  on_clause_wrapper incremental_clause
-                      {
-                         if (CmpCommon::getDefault(USTAT_IUS_SIMPLE_SYNTAX) == 
DF_ON) {
-                           HSFuncMergeDiags(- UERR_IUS_ON_CLAUSE,
-                                            "does not take any on-clause");
-                           return -1;
-                         }
-                      }
                  |  on_clause_wrapper sample_clause
                  |  on_clause_wrapper interval_clause sample_clause
                  |  on_clause_wrapper sample_clause interval_clause
@@ -434,31 +419,18 @@ incremental_clause :   INCREMENTAL WHERE WHERE_CONDITION
                        if 
(CmpCommon::getDefault(USTAT_INCREMENTAL_UPDATE_STATISTICS) == DF_OFF) {
                          HSFuncMergeDiags(-UERR_IUS_IS_DISABLED);
                        }
-                       
-                       if (CmpCommon::getDefault(USTAT_IUS_SIMPLE_SYNTAX) == 
DF_ON) {
-                         // Via grammar, the incremental clause can only used 
without the
-                         // on_clause. So it is safe to set the IUS_OPT flag.
-                         hs_globals_y->optFlags |= IUS_OPT;
-                         hs_globals_y->optFlags |= EXISTING_OPT;
-                         hs_globals_y->optFlags |= NECESSARY_OPT;
-
-                         Lng32 retcode = 0;
-                         if (retcode = AddExistingColumns())
-                            HSHandleError(retcode);
-                       } else {
 
-                          if (hs_globals_y->optFlags & (REG_GROUP_OPT | 
EVERYCOL_OPT | EVERYKEY_OPT ))
-                            HSFuncMergeDiags(-UERR_WRONG_ON_CLAUSE_FOR_IUS, 
"INCREMENTAL");
+                      if (hs_globals_y->optFlags & (REG_GROUP_OPT | 
EVERYCOL_OPT | EVERYKEY_OPT ))
+                        HSFuncMergeDiags(-UERR_WRONG_ON_CLAUSE_FOR_IUS, 
"INCREMENTAL");
+                      else
+                        {
+                          // This check is here to make sure we cover all the 
possible
+                          // ON clause alternatives
+                          if (!(hs_globals_y->optFlags & (EXISTING_OPT | 
NECESSARY_OPT)))
+                             HSFuncMergeDiags(-UERR_WRONG_ON_CLAUSE_FOR_IUS, 
"INCREMENTAL");
                           else
-                            {
-                              // This assert is here to make sure we covered 
all other possible ON
-                              // clauses in the check above.
-                              if (!(hs_globals_y->optFlags & (EXISTING_OPT | 
NECESSARY_OPT)))
-                                 
HSFuncMergeDiags(-UERR_WRONG_ON_CLAUSE_FOR_IUS, "INCREMENTAL");
-                              else
-                                 hs_globals_y->optFlags |= IUS_OPT;
-                            }
-                       }
+                             hs_globals_y->optFlags |= IUS_OPT;
+                        }
                 }
 ;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25077b5a/docs/messages_guide/src/asciidoc/_chapters/update_stats_msgs.adoc
----------------------------------------------------------------------
diff --git a/docs/messages_guide/src/asciidoc/_chapters/update_stats_msgs.adoc 
b/docs/messages_guide/src/asciidoc/_chapters/update_stats_msgs.adoc
index d3174ac..9c7d9d9 100644
--- a/docs/messages_guide/src/asciidoc/_chapters/update_stats_msgs.adoc
+++ b/docs/messages_guide/src/asciidoc/_chapters/update_stats_msgs.adoc
@@ -297,6 +297,21 @@ that lack statistics and need them.
 *Recovery:* If this was not the intended statement correct and resubmit. 
Otherwise no recovery
 is necessary.
 
+[[SQL-9219]]
+== SQL 9219
+
+```
+Incremental UPDATE STATISTICS: An operation failed, possibly due to an invalid 
WHERE clause.
+```
+
+*Cause:* UPDATE STATISTICS INCREMENTAL was specified but an operation such as 
a sample table
+update failed. This message is accompanied by another message giving more 
detail on the failure. Often this is caused by a bad WHERE clause on the UPDATE 
STATSITICS INCREMENTAL statement.
+
+*Effect:* The operation is a no-op.
+
+*Recovery:* If the WHERE clause is in error, correct and resubmit. If this 
does not correct the problem, 
+contact {project-support}.
+
 <<<
 [[SQL-9221]]
 == SQL 9221

Reply via email to