00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <cctype>
00028 #include "invariant_verifier.hh"
00029
00030
00031
00032
00033
00034
00035 TInvariantVerifier::TInvariantVerifier (void) :
00036 mpcl::invariant::IVerifier<TStackValue*> (eFULL_SQL_LEVEL)
00037 {
00038
00039 addInvariant ( eSQL92_F_5_4_A ,
00040 eSTRICT_SQL_92 ,
00041 "<schema name> can not contain an <embedded variable name>" );
00042 addInvariant ( eSQL92_F_5_4_B ,
00043 eSTRICT_SQL_92 ,
00044 "<authorization identifier> can not contain an <embedded "
00045 "variable name>" );
00046 addInvariant ( eSQL92_F_5_4_C ,
00047 eSTRICT_SQL_92 ,
00048 "<cursor name> can not contain an <embedded variable name>" );
00049 addInvariant ( eSQL92_F_17_A_A ,
00050 eSTRICT_SQL_92 ,
00051 "language shall not contain any <declare search condition>" );
00052 addInvariant ( eSQL92_F_17_A_B ,
00053 eSTRICT_SQL_92 ,
00054 "language shall not contain any <search condition value "
00055 "specification>" );
00056 addInvariant ( eSQL92_F_19_1_A ,
00057 eSTRICT_SQL_92 ,
00058 "<embedded variable name> can not contain a namespaces nor "
00059 "arrays nor functions" );
00060 addInvariant ( eSQL92_F_19_2_A ,
00061 eSTRICT_SQL_92 ,
00062 "<condition action> can not contain a <throw> action" );
00063 addInvariant ( eSQL92_SR_5_2_P8 ,
00064 eFULL_SQL_LEVEL ,
00065 "<regular identifier> shall not has more than 128 characters" );
00066 addInvariant ( eSQL92_SR_5_2_P9 ,
00067 eFULL_SQL_LEVEL ,
00068 "<delimited identifier body> shall not has more than 128 "
00069 "characters" );
00070 addInvariant ( eSQL92_SR_5_3_P21 ,
00071 eFULL_SQL_LEVEL ,
00072 "within <datetime literal>, <years value> shall contain four "
00073 "digits" );
00074 addInvariant ( eSQL92_SR_8_2_P1 ,
00075 eFULL_SQL_LEVEL ,
00076 "the <row value constructor>s shall be of the same degree" );
00077 addInvariant ( eSQL92_SR_11_3_P5 ,
00078 eFULL_SQL_LEVEL ,
00079 "a <temporary table declaration> shall contain at least one "
00080 "<column definition>" );
00081 addInvariant ( eSQL92_SR_11_19_P10 ,
00082 eFULL_SQL_LEVEL ,
00083 "the number of <column name>s in the <view column list> shall"
00084 " be the same as the degree of the table specified by the "
00085 "<query expression>" );
00086 addInvariant ( eSQL92_SR_13_5_P1 ,
00087 eFULL_SQL_LEVEL ,
00088 "the number of elements in the <select list> shall be the "
00089 "same as the number of elements in the <select target list>" );
00090 addInvariant ( eSQL92_SR_13_8_P5 ,
00091 eFULL_SQL_LEVEL ,
00092 "the degree of the <query expression> must be equal to "
00093 "the number of columns in <insert column list>" );
00094 addInvariant ( eSQL92_SR_13_11_P4 ,
00095 eFULL_SQL_LEVEL ,
00096 "a <table definition> shall contain at least one "
00097 "<column definition>" );
00098 addInvariant ( eSQL92_LR_5_2_P1 ,
00099 eINTERMEDIATE_SQL_LEVEL ,
00100 "no <identifier body> shall end in an <underscore>" );
00101 addInvariant ( eSQL92_LR_5_2_P2_A ,
00102 eENTRY_SQL_LEVEL ,
00103 "no <regular identifier> or <delimited identifier body> shall"
00104 " contain more than 18 <character representation>s" );
00105 addInvariant ( eSQL92_LR_5_2_P2_B ,
00106 eENTRY_SQL_LEVEL ,
00107 "an <identifier body> shall contain no <simple Latin lower ca"
00108 "se letter>" );
00109 addInvariant ( eSQL92_LR_6_3_P2_B ,
00110 eENTRY_SQL_LEVEL ,
00111 "the optional <key word> AS shall not be specified" );
00112 addInvariant ( eSQL92_LR_6_3_P2_C ,
00113 eENTRY_SQL_LEVEL ,
00114 "<derived column list> shall not be specified" );
00115 addInvariant ( eSQL92_LR_6_8_P1 ,
00116 eINTERMEDIATE_SQL_LEVEL ,
00117 "language shall contain no <time precision> or "
00118 "<timestamp precision>" );
00119 addInvariant ( eSQL92_LR_6_8_P2 ,
00120 eENTRY_SQL_LEVEL ,
00121 "language shall not contain any <datetime value function>" );
00122 addInvariant ( eSQL92_LR_6_11_P2_A ,
00123 eENTRY_SQL_LEVEL ,
00124 "a <value expression> shall not be a "
00125 "<datetime value expression>" );
00126 addInvariant ( eSQL92_LR_6_11_P2_B ,
00127 eENTRY_SQL_LEVEL ,
00128 "a <value expression> shall not be a "
00129 "<interval value expression>" );
00130 addInvariant ( eSQL92_LR_6_11_P2_C ,
00131 eENTRY_SQL_LEVEL ,
00132 "a <value expression primary> shall not be a "
00133 "<case expression>" );
00134 addInvariant ( eSQL92_LR_6_11_P2_D ,
00135 eENTRY_SQL_LEVEL ,
00136 "a <value expression primary> shall not be a "
00137 "<cast specification>" );
00138 addInvariant ( eSQL92_LR_8_9_P2 ,
00139 eENTRY_SQL_LEVEL ,
00140 "language shall not contain any <unique predicate>" );
00141 addInvariant ( eSQL92_LR_8_10_P1 ,
00142 eINTERMEDIATE_SQL_LEVEL ,
00143 "language shall not contain any <match predicate>" );
00144 addInvariant ( eSQL92_LR_11_4_P2_A ,
00145 eENTRY_SQL_LEVEL ,
00146 "a <column definition> shall not contain a <domain name>" );
00147 addInvariant ( eSQL92_LR_11_10_P2 ,
00148 eENTRY_SQL_LEVEL ,
00149 "language shall not contain any <alter table statement>" );
00150 addInvariant ( eSQL92_LR_13_1_P1_A ,
00151 eINTERMEDIATE_SQL_LEVEL ,
00152 "a <declare cursor> shall not specify INSENSITIVE" );
00153 addInvariant ( eSQL92_LR_13_1_P2_A ,
00154 eENTRY_SQL_LEVEL ,
00155 "a <declare cursor> shall not specify SCROLL" );
00156 addInvariant ( eSQL92_LR_13_1_P2_B ,
00157 eENTRY_SQL_LEVEL ,
00158 "a <cursor specification> shall not contain an "
00159 "<updatability clause>" );
00160 addInvariant ( eSQL92_LR_13_3_P2_A ,
00161 eENTRY_SQL_LEVEL ,
00162 "a <fetch statement> shall not specify a "
00163 "<fetch orientation>" );
00164 addInvariant ( eSQL92_LR_13_3_P2_B ,
00165 eENTRY_SQL_LEVEL ,
00166 "a <fetch statement> shall not specify FROM" );
00167
00168 }
00169
00170
00171
00172
00173
00174
00175 bool TInvariantVerifier::verify (long int liINVARIANT_IDENTIFIER) const
00176 {
00177
00178 using mpcl::text::TString;
00179
00180 bool gSuccess = false;
00181
00182 switch (liINVARIANT_IDENTIFIER)
00183 {
00184 case eSQL92_SR_5_2_P8:
00185 case eSQL92_SR_5_2_P9:
00186 {
00187 gSuccess = ( tArgumentArray [0]->yCode.length() <= 128 );
00188 break;
00189 }
00190 case eSQL92_SR_5_3_P21:
00191 {
00192 size_t zOffset = 0;
00193
00194 zOffset = tArgumentArray [0]->yCode.find ('-');
00195 gSuccess = ( zOffset == 3 );
00196 break;
00197 }
00198 case eSQL92_SR_8_2_P1:
00199 case eSQL92_SR_11_19_P10:
00200 case eSQL92_SR_13_5_P1:
00201 case eSQL92_SR_13_8_P5:
00202 {
00203 gSuccess = ( tArgumentArray [0]->gHasAsterisk ||
00204 ( tArgumentArray [0]->iItemCount == tArgumentArray [1]->iItemCount ) );
00205 break;
00206 }
00207 case eSQL92_SR_11_3_P5:
00208 case eSQL92_SR_13_11_P4:
00209 {
00210 gSuccess = ( tArgumentArray [0]->gHasColumnDefinition );
00211 break;
00212 }
00213 case eSQL92_LR_5_2_P1:
00214 {
00215 TString& ryCode = tArgumentArray [0]->yCode;
00216 size_t zLastCharacter = ryCode.length() - 1;
00217
00218 gSuccess = ( ryCode [zLastCharacter] != '_' );
00219 break;
00220 }
00221 case eSQL92_LR_5_2_P2_A:
00222 {
00223 gSuccess = ( tArgumentArray [0]->yCode.length() <= 18 );
00224 break;
00225 }
00226 case eSQL92_LR_5_2_P2_B:
00227 {
00228 TString& ryCode = tArgumentArray [0]->yCode;
00229 size_t zStringLength = ryCode.length();
00230
00231 gSuccess = true;
00232 for (register size_t J = 0; ( J < zStringLength ) ;++J)
00233 {
00234 if ( islower (ryCode [J]) )
00235 {
00236 gSuccess = false;
00237 break;
00238 }
00239 }
00240 break;
00241 }
00242 case eSQL92_F_5_4_A:
00243 case eSQL92_F_5_4_B:
00244 case eSQL92_F_19_1_A:
00245 case eSQL92_F_19_2_A:
00246 case eSQL92_LR_6_3_P2_B:
00247 case eSQL92_LR_6_3_P2_C:
00248 case eSQL92_LR_6_8_P1:
00249 case eSQL92_LR_6_8_P2:
00250 case eSQL92_LR_6_11_P2_A:
00251 case eSQL92_LR_6_11_P2_B:
00252 case eSQL92_LR_6_11_P2_C:
00253 case eSQL92_LR_6_11_P2_D:
00254 case eSQL92_LR_8_9_P2:
00255 case eSQL92_LR_8_10_P1:
00256 case eSQL92_LR_11_4_P2_A:
00257 case eSQL92_LR_11_10_P2:
00258 case eSQL92_LR_13_1_P1_A:
00259 case eSQL92_LR_13_1_P2_A:
00260 case eSQL92_LR_13_1_P2_B:
00261 case eSQL92_LR_13_3_P2_A:
00262 case eSQL92_LR_13_3_P2_B:
00263 {
00264 break;
00265 }
00266 }
00267 return gSuccess;
00268
00269 }