001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2006-2012 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.util;
011
012import mondrian.olap.MondrianProperties;
013import mondrian.spi.Dialect;
014
015import org.apache.log4j.Logger;
016
017/**
018 * Holder for constants which indicate whether particular issues have been
019 * fixed. Reference one of those constants in your code, and it is clear which
020 * code can be enabled when the bug is fixed. Generally a constant is removed
021 * when its bug is fixed.
022 *
023 * <h3>Cleanup items</h3>
024 *
025 * The following is a list of cleanup items. They are not bugs per se:
026 * functionality is not wrong, just the organization of the code. If they were
027 * bugs, they would be in jira. It makes sense to have the list here, so that
028 * referenced class, method and variable names show up as uses in code searches.
029 *
030 * <dl>
031 *
032 * <dt>Obsolete {@link mondrian.olap.Id.Segment}</dt>
033 * <dd>Replace it by {@link org.olap4j.mdx.IdentifierSegment}. Likewise
034 * {@link mondrian.olap.Id.Quoting} with {@link org.olap4j.mdx.Quoting}.
035 * Should wait until after the mondrian 4 'big bang', because there are ~300
036 * uses of Segment in the code.</dd>
037 *
038 * </dl>
039 *
040 * @author jhyde
041 * @since Oct 11, 2006
042 */
043public class Bug {
044    /**
045     * Whether Mondrian is 100% compatible with Microsoft Analysis Services
046     * 2005. We know that it is not, so this constant is {@code false}.
047     *
048     * <p>Use this
049     * field to flag test cases whose behavior is intentionally different from
050     * SSAS. If the behavior is <em>un</em>intentionally different and something
051     * we want to fix, log a bug, add a new {@code BugMondrianXxxFixed} constant
052     * to this class, and make the test case conditional on that constant
053     * instead.
054     *
055     * <p>See also the property
056     * {@link mondrian.olap.MondrianProperties#SsasCompatibleNaming},
057     * which allows the user to choose certain behaviors which are compatible
058     * with SSAS 2005 but incompatible with Mondrian's previous behavior.
059     */
060    public static final boolean Ssas2005Compatible = false;
061
062    /**
063     * If you want to tag a piece of code in mondrian that needs to be changed
064     * when we upgrade to a future version of olap4j, reference this function.
065     * It will always return false.
066     */
067    public static boolean olap4jUpgrade(String reason) {
068        return false;
069    }
070
071    /**
072     * Whether
073     * <a href="http://jira.pentaho.com/browse/MONDRIAN-229">MONDRIAN-229,
074     * "NON EMPTY when hierarchy's default member is not 'all'"</a>
075     * is fixed.
076     */
077    public static final boolean BugMondrian229Fixed = false;
078
079    // Properties relating to checkin 7641.
080    // This is part of the junit test Checkin_7641 that
081    // shows that there is a difference when the default
082    // member is not the one used in an axis.
083    // When Checkin 7641 is resolved, then this System property access and
084    // boolean should go away.
085    // (What's the bug associated with this??)
086
087    public static final boolean Checkin7641UseOptimizer = false;
088
089    /**
090     * Whether
091     * <a href="http://jira.pentaho.com/browse/MONDRIAN-207">MONDRIAN-207,
092     * "IS EMPTY and IS NULL"</a> is fixed.
093     */
094    public static final boolean BugMondrian207Fixed = false;
095
096    /**
097     * Whether
098     * <a href="http://jira.pentaho.com/browse/MONDRIAN-446">bug MONDRIAN-446,
099     * "Make Native NonEmpty consistant with MSAS"</a>
100     * is fixed.
101     */
102    public static final boolean BugMondrian446Fixed = false;
103
104    /**
105     * Whether
106     * <a href="http://jira.pentaho.com/browse/MONDRIAN-313">bug MONDRIAN-313,
107     * "Predicate references RolapStar.Column when used in AggStar"</a>
108     * is fixed.
109     */
110    public static final boolean BugMondrian313Fixed = false;
111
112    /**
113     * Whether
114     * <a href="http://jira.pentaho.com/browse/MONDRIAN-314">bug MONDRIAN-314,
115     * "Predicate sometimes has null RolapStar.Column"</a>
116     * is fixed.
117     */
118    public static final boolean BugMondrian314Fixed = false;
119
120    /**
121     * Whether
122     * <a href="http://jira.pentaho.com/browse/MONDRIAN-328">bug MONDRIAN-328,
123     * "CrossJoin no empty optimizer eliminates calculated member"</a>
124     * is fixed.
125     */
126    public static final boolean BugMondrian328Fixed = false;
127
128    /**
129     * Whether
130     * <a href="http://jira.pentaho.com/browse/MONDRIAN-361">bug MONDRIAN-361,
131     * "Aggregate Tables not working with Shared Dimensions"</a>
132     * is fixed.
133     *
134     */
135    public static final boolean BugMondrian361Fixed = false;
136
137    /**
138     * Whether
139     * <a href="http://jira.pentaho.com/browse/MONDRIAN-441">bug MONDRIAN-441,
140     * "Parent-child hierarchies: &lt;Join&gt; used in dimension"</a>
141     * is fixed.
142     */
143    public static final boolean BugMondrian441Fixed = false;
144
145    /**
146     * Whether
147     * <a href="http://jira.pentaho.com/browse/MONDRIAN-486">bug MONDRIAN-486,
148     * "HighCardinalityTest test cases disabled"</a>
149     * is fixed.
150     */
151    public static final boolean BugMondrian486Fixed = false;
152
153    /**
154     * Whether bug <a href="http://jira.pentaho.com/browse/MONDRIAN-495">
155     * MONDRIAN-495, "Table filter concept does not support dialects."</a>
156     * is fixed.
157     */
158    public static final boolean BugMondrian495Fixed = false;
159
160    /**
161     * Whether
162     * <a href="http://jira.pentaho.com/browse/MONDRIAN-503">bug MONDRIAN-503,
163     * "RolapResultTest disabled"</a>
164     * is fixed.
165     */
166    public static final boolean BugMondrian503Fixed = false;
167
168    /**
169     * Whether
170     * <a href="http://jira.pentaho.com/browse/MONDRIAN-555">bug MONDRIAN-555,
171     * "Compound slicer counts cells twice in certain cases"</a> is fixed.
172     * If a set in the slicer contains the same member more than once, or more
173     * generally, if the regions overlap, then mondrian counts the overlaps
174     * twice, whereas SSAS 2005 does not.
175     */
176    public static final boolean BugMondrian555Fixed = false;
177
178    /**
179     * Whether
180     * <a href="http://jira.pentaho.com/browse/MONDRIAN-584">bug MONDRIAN-584,
181     * "Native evaluation returns enumerated members in the wrong order"</a>
182     * is fixed. A query that includes { Gender.M, Gender.F } should return
183     * results where the Gender.M values are returned before the Gender.F
184     * values.
185     */
186    public static final boolean BugMondrian584Fixed = false;
187
188    /**
189     * Whether
190     * <a href="http://jira.pentaho.com/browse/MONDRIAN-641">bug MONDRIAN-641,
191     * "Large NON EMPTY result performs poorly with ResultStyle.ITERABLE"</a>
192     */
193    public static final boolean BugMondrian641Fixed = false;
194
195    /**
196     * Whether
197     * <a href="http://jira.pentaho.com/browse/MONDRIAN-648">bug MONDRIAN-648,
198     * "AS operator has lower precedence than required by MDX specification"</a>
199     * is fixed.
200     */
201    public static final boolean BugMondrian648Fixed = false;
202
203    /**
204     * Whether
205     * <a href="http://jira.pentaho.com/browse/MONDRIAN-687">bug MONDRIAN-687,
206     * "Format treats negative numbers differently than SSAS"</a>
207     * is fixed.
208     */
209    public static final boolean BugMondrian687Fixed = false;
210
211    /**
212     * Whether bug
213     * <a href="http://jira.pentaho.com/browse/MONDRIAN-747">bug MONDRIAN-747,
214     * "When joining a shared dimension into a cube at a level
215     * other than its leaf level, Mondrian gives wrong results"</a> is fixed.
216     */
217    public static final boolean BugMondrian747Fixed = false;
218
219    /**
220     * Whether
221     * <a href="http://jira.pentaho.com/browse/MONDRIAN-759">bug MONDRIAN-759,
222     * "use dynamic parameters and PreparedStatement for frequently executed SQL
223     * patterns"</a> is fixed.
224     */
225    public static final boolean BugMondrian759Fixed = false;
226
227    /**
228     * Whether
229     * <a href="http://jira.pentaho.com/browse/MONDRIAN-785">bug MONDRIAN-785,
230     * "Native evaluation does not respect ordering"</a> is fixed.
231     */
232    public static final boolean BugMondrian785Fixed = false;
233
234    /**
235     * Whether
236     * <a href="http://jira.pentaho.com/browse/MONDRIAN-1001">bug MONDRIAN-1001,
237     * "Tests disabled due to property trigger issues"</a> is fixed.
238     */
239    public static final boolean BugMondrian1001Fixed = false;
240
241    /**
242     * Whether RolapCubeMember and RolapMember have been fully segregated; any
243     * piece of code should be working with one or the other, not both.
244     */
245    public static final boolean BugSegregateRolapCubeMemberFixed = false;
246
247    /**
248     * Returns whether to avoid a test because the memory monitor may cause it
249     * to fail.
250     *
251     * <p>Some tests fail if memory monitor is switched on, and Access and
252     * Derby tend to use a lot of memory because they are embedded.
253     *
254     * @param dialect Dialect
255     * @return Whether to avoid a test
256     */
257    public static boolean avoidMemoryOverflow(Dialect dialect) {
258        return dialect.getDatabaseProduct() == Dialect.DatabaseProduct.ACCESS
259            && MondrianProperties.instance().MemoryMonitor.get();
260    }
261
262    /**
263     * Returns true if we are running against
264     * {@link mondrian.spi.Dialect.DatabaseProduct#LUCIDDB} and we wish to
265     * avoid slow tests.
266     *
267     * <p>This is because some tests involving parent-child hierarchies are
268     * very slow. If we are running performance tests (indicated by the
269     * {@code mondrian.test.PerforceTest} logger set at
270     * {@link org.apache.log4j.Level#DEBUG} or higher), we expect the suite to
271     * take a long time, so we enable the tests.
272     *
273     * <p>Fixing either {@link #BugMondrian759Fixed MONDRIAN-759} or
274     * <a href="http://issues.eigenbase.org/browse/FRG-400">FRG-400, "rewrite
275     * statements containing literals to use internally-managed dynamic
276     * parameters instead"</a> would solve the problem.
277     *
278     * @return Whether we are running LucidDB and we wish to avoid slow tests.
279     */
280    public static boolean avoidSlowTestOnLucidDB(Dialect dialect) {
281        return
282            !BugMondrian759Fixed
283            && dialect.getDatabaseProduct() == Dialect.DatabaseProduct.LUCIDDB
284            && !Logger.getLogger("mondrian.test.PerformanceTest")
285                .isDebugEnabled();
286    }
287}
288
289// End Bug.java