# 33.2. Test Evaluation

33.2.1. Error Message Differences

33.2.2. Locale Differences

33.2.3. Date and Time Differences

33.2.4. Floating-Point Differences

33.2.5. Row Ordering Differences

33.2.6. Insufficient Stack Depth

33.2.7. The “random” Test

33.2.8. Configuration Parameters

Some properly installed and fully functional PostgreSQL installations can “fail” some of these regression tests due to platform-specific artifacts such as varying floating-point representation and message wording. The tests are currently evaluated using a simplediffcomparison against the outputs generated on a reference system, so the results are sensitive to small system differences. When a test is reported as “failed”, always examine the differences between expected and actual results; you might find that the differences are not significant. Nonetheless, we still strive to maintain accurate reference files across all supported platforms, so it can be expected that all tests pass.

The actual outputs of the regression tests are in files in thesrc/test/regress/resultsdirectory. The test script usesdiffto compare each output file against the reference outputs stored in thesrc/test/regress/expecteddirectory. Any differences are saved for your inspection insrc/test/regress/regression.diffs. (When running a test suite other than the core tests, these files of course appear in the relevant subdirectory, notsrc/test/regress.)

If you don't like thediffoptions that are used by default, set the environment variablePG_REGRESS_DIFF_OPTS, for instancePG_REGRESS_DIFF_OPTS='-c'. (Or you can rundiffyourself, if you prefer.)

If for some reason a particular platform generates a “failure” for a given test, but inspection of the output convinces you that the result is valid, you can add a new comparison file to silence the failure report in future test runs. SeeSection 33.3for details.

# 33.2.1. Error Message Differences

Some of the regression tests involve intentional invalid input values. Error messages can come from either the PostgreSQL code or from the host platform system routines. In the latter case, the messages can vary between platforms, but should reflect similar information. These differences in messages will result in a “failed” regression test that can be validated by inspection.

# 33.2.2. Locale Differences

If you run the tests against a server that was initialized with a collation-order locale other than C, then there might be differences due to sort order and subsequent failures. The regression test suite is set up to handle this problem by providing alternate result files that together are known to handle a large number of locales.

To run the tests in a different locale when using the temporary-installation method, pass the appropriate locale-related environment variables on themakecommand line, for example:

make check LANG=de_DE.utf8

(The regression test driver unsetsLC_ALL, so it does not work to choose the locale using that variable.) To use no locale, either unset all locale-related environment variables (or set them toC) or use the following special invocation:

make check NO_LOCALE=1

When running the tests against an existing installation, the locale setup is determined by the existing installation. To change it, initialize the database cluster with a different locale by passing the appropriate options toinitdb.

In general, it is advisable to try to run the regression tests in the locale setup that is wanted for production use, as this will exercise the locale- and encoding-related code portions that will actually be used in production. Depending on the operating system environment, you might get failures, but then you will at least know what locale-specific behaviors to expect when running real applications.

# 33.2.3. Date and Time Differences

大多数日期和时间结果取决于时区环境。参考文件是为时区生成的PST8PDT(加州伯克利),如果测试不在该时区设置下运行,就会出现明显的失败。回归测试驱动程序设置环境变量PGTZPST8PDT,这通常可以确保正确的结果。

# 33.2.4.浮点差

有些测试涉及计算64位浮点数(双精度)来自表列。涉及数学函数的结果差异双精度观察到了柱子。这个浮动8几何学测试特别容易在不同的平台之间产生微小的差异,甚至在不同的编译器优化设置下。需要通过人眼对比来确定这些差异的真正意义,这些差异通常位于小数点右侧10位。

有些系统显示负零为零-0,而其他人只是表现出来0.

有些系统发出错误信号战俘()exp()differently from the mechanism expected by the current PostgreSQL code.

# 33.2.5. Row Ordering Differences

You might see differences in which the same rows are output in a different order than what appears in the expected file. In most cases this is not, strictly speaking, a bug. Most of the regression test scripts are not so pedantic as to use anORDER BYfor every singleSELECT, and so their result row orderings are not well-defined according to the SQL specification. In practice, since we are looking at the same queries being executed on the same data by the same software, we usually get the same result ordering on all platforms, so the lack ofORDER BYis not a problem. Some queries do exhibit cross-platform ordering differences, however. When testing against an already-installed server, ordering differences can also be caused by non-C locale settings or non-default parameter settings, such as custom values ofwork_memor the planner cost parameters.

Therefore, if you see an ordering difference, it's not something to worry about, unless the query does have anORDER BYthat your result is violating. However, please report it anyway, so that we can add anORDER BYto that particular query to eliminate the bogus“failure” in future releases.

You might wonder why we don't order all the regression test queries explicitly to get rid of this issue once and for all. The reason is that that would make the regression tests less useful, not more, since they'd tend to exercise query plan types that produce ordered results to the exclusion of those that don't.

# 33.2.6. Insufficient Stack Depth

If theerrorstest results in a server crash at theselect infinite_recurse()command, it means that the platform's limit on process stack size is smaller than themax_stack_depthparameter indicates. This can be fixed by running the server under a higher stack size limit (4MB is recommended with the default value ofmax_stack_depth). If you are unable to do that, an alternative is to reduce the value ofmax_stack_depth.

On platforms supportinggetrlimit(), the server should automatically choose a safe value ofmax_stack_depth; so unless you've manually overridden this setting, a failure of this kind is a reportable bug.

# 33.2.7. The “random” Test

Therandomtest script is intended to produce random results. In very rare cases, this causes that regression test to fail. Typing:

diff results/random.out expected/random.out

should produce only one or a few lines of differences. You need not worry unless the random test fails repeatedly.

# 33.2.8. Configuration Parameters

When running the tests against an existing installation, some non-default parameter settings could cause the tests to fail. For example, changing parameters such asenable_seqscanorenable_indexscancould cause plan changes that would affect the results of tests that useEXPLAIN.