Update platform-specific-expected-file support so that platforms can be

specified by regular-expression patterns.  Add some more files.
This commit is contained in:
Tom Lane 2000-01-09 20:54:36 +00:00
parent 4f9d74f98b
commit b86ca72f39
9 changed files with 1760 additions and 128 deletions

View File

@ -9,17 +9,15 @@ Regression test instructions and analysis.
<Para> <Para>
The PostgreSQL regression tests are a comprehensive set of tests for the The PostgreSQL regression tests are a comprehensive set of tests for the
SQL implementation embedded in PostgreSQL developed by Jolly Chen and SQL implementation embedded in PostgreSQL. They test standard SQL
Andrew Yu. It tests standard SQL operations as well as the extended operations as well as the extended capabilities of PostgreSQL.
capabilities of PostgreSQL.
</Para> </Para>
<Para> <Para>
These tests have recently been revised by Marc Fournier and Thomas Lockhart The regression tests were originally developed by Jolly Chen and Andrew Yu,
and are now packaged as and were extensively revised/repackaged by Marc Fournier and Thomas Lockhart.
functional units which should make them easier to run and easier to interpret. From <ProductName>PostgreSQL</ProductName> v6.1 onward
From <ProductName>PostgreSQL</ProductName> v6.1 onward the regression tests are current for every official release.
the regression tests are current for every official release.
</Para> </Para>
<Para> <Para>
@ -66,19 +64,18 @@ The runtime path is /usr/local/pgsql (other paths are possible).
<Title>Regression Environment</Title> <Title>Regression Environment</Title>
<Para> <Para>
The regression test is invoked by the <Command>make</Command> command which compiles To prepare for regression testing, do <Command>make all</Command> in the regression test
a <Acronym>C</Acronym> program into a shared library directory. This compiles a <Acronym>C</Acronym> program with PostgreSQL extension functions
in the current directory. Localized shell scripts are also created in into a shared library. Localized SQL scripts and output-comparison
the current directory. The output file templates are massaged into the files are also created for the tests that need them. The localization
<FileName>./expected/*.out</FileName> files. The localization replaces macros in the source replaces macros in the source files with absolute pathnames and user names.
files with absolute pathnames and user names.
</Para> </Para>
<Para> <Para>
Normally, the regression test should be run as the pg_superuser since Normally, the regression tests should be run as the postgres user since
the 'src/test/regress' directory and sub-directories are owned by the the 'src/test/regress' directory and sub-directories are owned by the
pg_superuser. If you run the regression test as another user the postgres user. If you run the regression test as another user the
'src/test/regress' directory tree should be writeable to that user. 'src/test/regress' directory tree must be writeable to that user.
</Para> </Para>
<Para> <Para>
@ -132,7 +129,7 @@ The runtime path is /usr/local/pgsql (other paths are possible).
expected/ . .out files that represent what we *expect* the results to expected/ . .out files that represent what we *expect* the results to
look like look like
results/ .. .out files that represent what the results *actually* look results/ .. .out files that contain what the results *actually* look
like. Also used as temporary storage for table copy testing. like. Also used as temporary storage for table copy testing.
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -296,25 +293,6 @@ The runtime path is /usr/local/pgsql (other paths are possible).
</Sect2> </Sect2>
<Sect2>
<Title>OID differences</Title>
<Para>
There are several places where PostgreSQL OID (object identifiers) appear
in 'regress.out'. OID's are unique 32-bit integers which are generated
by the PostgreSQL backend whenever a table row is inserted or updated.
If you run the regression test on a non-virgin database or run it multiple
times, the OID's reported will have different values.
The following SQL statements in 'misc.out' have shown this behavior:
QUERY: SELECT user_relns() AS user_relns ORDER BY user_relns;
The 'a,523676' row is composed from an OID.
</Para>
</Sect2>
<Sect2> <Sect2>
<Title>Date and time differences</Title> <Title>Date and time differences</Title>
@ -431,5 +409,55 @@ The runtime path is /usr/local/pgsql (other paths are possible).
</Sect2> </Sect2>
</Sect1> </Sect1>
<Sect1>
<Title>Platform-specific comparison files</Title>
<Para>
Since some of the tests inherently produce platform-specific results,
we have provided a way to supply platform-specific result comparison
files. Frequently, the same variation applies to multiple platforms;
rather than supplying a separate comparison file for every platform,
there is a mapping file that defines which comparison file to use.
So, to eliminate bogus test "failures" for a particular platform,
you must choose or make a variant result file, and then add a line
to the mapping file, which is "resultmap".
</Para>
<Para>
Each line in the mapping file is of the form
<ProgramListing>
testname/platformnamepattern=comparisonfilename
</ProgramListing>
The test name is just the name of the particular regression test module.
The platform name pattern is a pattern in the style of expr(1) (that is,
a regular expression with an implicit ^ anchor at the start). It is matched
against the platform name as printed by config.guess. The comparison
file name is the name of the substitute result comparison file.
</Para>
<Para>
For example: the int2 regress test includes a deliberate entry of a value
that is too large to fit in int2. The specific error message that is
produced is platform-dependent; our reference platform emits
<ProgramListing>
ERROR: pg_atoi: error reading "100000": Numerical result out of range
</ProgramListing>
but a fair number of other Unix platforms emit
<ProgramListing>
ERROR: pg_atoi: error reading "100000": Result too large
</ProgramListing>
Therefore, we provide a variant comparison file, int2-too-large.out,
that includes this spelling of the error message. To silence the
bogus "failure" message on HPPA platforms, resultmap includes
<ProgramListing>
int2/hppa=int2-too-large
</ProgramListing>
which will trigger on any machine for which config.guess's output
begins with 'hppa'. Other lines in resultmap select the variant
comparison file for other platforms where it's appropriate.
</Para>
</Sect1>
</Chapter> </Chapter>

View File

@ -3,10 +3,12 @@ Introduction
The PostgreSQL regression tests are a comprehensive set of tests for the The PostgreSQL regression tests are a comprehensive set of tests for the
SQL implementation embedded in PostgreSQL. They test standard SQL SQL implementation embedded in PostgreSQL. They test standard SQL
operations as well as the extensibility capabilities of PostgreSQL. operations as well as the extended capabilities of PostgreSQL.
The regression tests were originally developed by Jolly Chen and Andrew Yu, The regression tests were originally developed by Jolly Chen and Andrew Yu,
and were extensively revised/repackaged by Marc Fournier and Thomas Lockhart. and were extensively revised/repackaged by Marc Fournier and Thomas Lockhart.
From PostgreSQL v6.1 onward the regression tests are current for every
official release.
Some properly installed and fully functional PostgreSQL installations Some properly installed and fully functional PostgreSQL installations
can fail some of these regression tests due to artifacts of floating point can fail some of these regression tests due to artifacts of floating point
@ -17,12 +19,17 @@ Introduction
Preparation Preparation
To prepare for regression testing, do "make all". This compiles To prepare for regression testing, do "make all" in the regression test
a 'C' program with PostgreSQL extension functions into a shared library directory. This compiles a 'C' program with PostgreSQL extension functions
in the current directory. Localized SQL scripts and output-comparison into a shared library. Localized SQL scripts and output-comparison
files are also created for the tests that need them. The localization files are also created for the tests that need them. The localization
replaces macros in the source files with absolute pathnames and user names. replaces macros in the source files with absolute pathnames and user names.
Normally, the regression tests should be run as the postgres user since
the 'src/test/regress' directory and sub-directories are owned by the
postgres user. If you run the regression test as another user the
'src/test/regress' directory tree must be writeable to that user.
It was formerly necessary to run the postmaster with system time zone It was formerly necessary to run the postmaster with system time zone
set to PST, but this is no longer required. You can run the regression set to PST, but this is no longer required. You can run the regression
tests under your normal postmaster configuration. The test script will tests under your normal postmaster configuration. The test script will
@ -64,11 +71,6 @@ Running the regression test
need an already-installed postmaster. Instead, runcheck creates need an already-installed postmaster. Instead, runcheck creates
a temporary installation under the regress directory. a temporary installation under the regress directory.
Normally, the regression tests should be run as the postgres user since
the 'src/test/regress' directory and sub-directories are owned by the
postgres user. If you run the regression test as another user the
'src/test/regress' directory tree must be writeable to that user.
Comparing expected/actual output Comparing expected/actual output
The results are in files in the ./results directory. These results The results are in files in the ./results directory. These results
@ -172,11 +174,12 @@ Platform-specific comparison files
to the mapping file, which is "resultmap". to the mapping file, which is "resultmap".
Each line in the mapping file is of the form Each line in the mapping file is of the form
testname/platformname=comparisonfilename testname/platformnamepattern=comparisonfilename
The test name is just the name of the particular regression test module. The test name is just the name of the particular regression test module.
The platform name is the platform name as printed by config.guess (in The platform name pattern is a pattern in the style of expr(1) (that is,
the toplevel PostgreSQL src directory), or any prefix of it. The a regular expression with an implicit ^ anchor at the start). It is matched
comparison file name is the name of the substitute result comparison file. against the platform name as printed by config.guess. The comparison
file name is the name of the substitute result comparison file.
For example: the int2 regress test includes a deliberate entry of a value For example: the int2 regress test includes a deliberate entry of a value
that is too large to fit in int2. The specific error message that is that is too large to fit in int2. The specific error message that is

View File

@ -0,0 +1,532 @@
--
-- GEOMETRY
--
--
-- Points
--
SELECT '' AS four, center(f1) AS center
FROM BOX_TBL;
four | center
------+---------
| (1,1)
| (2,2)
| (2.5,3)
| (3,3)
(4 rows)
SELECT '' AS four, (@@ f1) AS center
FROM BOX_TBL;
four | center
------+---------
| (1,1)
| (2,2)
| (2.5,3)
| (3,3)
(4 rows)
SELECT '' AS six, point(f1) AS center
FROM CIRCLE_TBL;
six | center
-----+-----------
| (0,0)
| (1,2)
| (1,3)
| (1,2)
| (100,200)
| (100,0)
(6 rows)
SELECT '' AS six, (@@ f1) AS center
FROM CIRCLE_TBL;
six | center
-----+-----------
| (0,0)
| (1,2)
| (1,3)
| (1,2)
| (100,200)
| (100,0)
(6 rows)
SELECT '' AS two, (@@ f1) AS center
FROM POLYGON_TBL
WHERE (# f1) > 2;
two | center
-----+-------------------------------------
| (1.33333333333333,1.33333333333333)
| (2.33333333333333,1.33333333333333)
(2 rows)
-- "is horizontal" function
SELECT '' AS two, p1.f1
FROM POINT_TBL p1
WHERE ishorizontal(p1.f1, point '(0,0)');
two | f1
-----+---------
| (0,0)
| (-10,0)
(2 rows)
-- "is horizontal" operator
SELECT '' AS two, p1.f1
FROM POINT_TBL p1
WHERE p1.f1 ?- point '(0,0)';
two | f1
-----+---------
| (0,0)
| (-10,0)
(2 rows)
-- "is vertical" function
SELECT '' AS one, p1.f1
FROM POINT_TBL p1
WHERE isvertical(p1.f1, point '(5.1,34.5)');
one | f1
-----+------------
| (5.1,34.5)
(1 row)
-- "is vertical" operator
SELECT '' AS one, p1.f1
FROM POINT_TBL p1
WHERE p1.f1 ?| point '(5.1,34.5)';
one | f1
-----+------------
| (5.1,34.5)
(1 row)
--
-- Line segments
--
-- intersection
SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
FROM LSEG_TBL l, POINT_TBL p;
ERROR: Unable to identify an operator '#' for types 'lseg' and 'point'
You will have to retype this query using an explicit cast
-- closest point
SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
FROM LSEG_TBL l, POINT_TBL p;
thirty | f1 | s | closest
--------+------------+-------------------------------+---------------------------------------
| (0,0) | [(1,2),(3,4)] | (1,2)
| (-10,0) | [(1,2),(3,4)] | (1,2)
| (-3,4) | [(1,2),(3,4)] | (1,2)
| (5.1,34.5) | [(1,2),(3,4)] | (3,4)
| (-5,-12) | [(1,2),(3,4)] | (1,2)
| (10,10) | [(1,2),(3,4)] | (3,4)
| (0,0) | [(0,0),(6,6)] | (0,0)
| (-10,0) | [(0,0),(6,6)] | (0,0)
| (-3,4) | [(0,0),(6,6)] | (0.5,0.5)
| (5.1,34.5) | [(0,0),(6,6)] | (6,6)
| (-5,-12) | [(0,0),(6,6)] | (0,0)
| (10,10) | [(0,0),(6,6)] | (6,6)
| (0,0) | [(10,-10),(-3,-4)] | (-2.04878048780488,-4.4390243902439)
| (-10,0) | [(10,-10),(-3,-4)] | (-3,-4)
| (-3,4) | [(10,-10),(-3,-4)] | (-3,-4)
| (5.1,34.5) | [(10,-10),(-3,-4)] | (-3,-4)
| (-5,-12) | [(10,-10),(-3,-4)] | (-1.60487804878049,-4.64390243902439)
| (10,10) | [(10,-10),(-3,-4)] | (2.39024390243902,-6.48780487804878)
| (0,0) | [(-1000000,200),(300000,-40)] | (0.0028402365895872,15.384614860264)
| (-10,0) | [(-1000000,200),(300000,-40)] | (-9.99715942258202,15.3864610140472)
| (-3,4) | [(-1000000,200),(300000,-40)] | (-2.99789812267519,15.3851688427303)
| (5.1,34.5) | [(-1000000,200),(300000,-40)] | (5.09647083221496,15.3836744976925)
| (-5,-12) | [(-1000000,200),(300000,-40)] | (-4.99494420845634,15.3855375281616)
| (10,10) | [(-1000000,200),(300000,-40)] | (10.000993741978,15.3827690473092)
| (0,0) | [(11,22),(33,44)] | (11,22)
| (-10,0) | [(11,22),(33,44)] | (11,22)
| (-3,4) | [(11,22),(33,44)] | (11,22)
| (5.1,34.5) | [(11,22),(33,44)] | (14.3,25.3)
| (-5,-12) | [(11,22),(33,44)] | (11,22)
| (10,10) | [(11,22),(33,44)] | (11,22)
(30 rows)
--
-- Lines
--
--
-- Boxes
--
SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL;
six | box
-----+----------------------------------------------------------------------------
| (2.12132034355964,2.12132034355964),(-2.12132034355964,-2.12132034355964)
| (71.7106781186547,72.7106781186547),(-69.7106781186547,-68.7106781186547)
| (4.53553390593274,6.53553390593274),(-2.53553390593274,-0.535533905932737)
| (3.12132034355964,4.12132034355964),(-1.12132034355964,-0.121320343559642)
| (107.071067811865,207.071067811865),(92.9289321881345,192.928932188135)
| (170.710678118655,70.7106781186547),(29.2893218813453,-70.7106781186547)
(6 rows)
-- translation
SELECT '' AS twentyfour, b.f1 + p.f1 AS translation
FROM BOX_TBL b, POINT_TBL p;
twentyfour | translation
------------+-------------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
| (-8,2),(-10,0)
| (-7,3),(-9,1)
| (-7.5,3.5),(-7.5,2.5)
| (-7,3),(-7,3)
| (-1,6),(-3,4)
| (0,7),(-2,5)
| (-0.5,7.5),(-0.5,6.5)
| (0,7),(0,7)
| (7.1,36.5),(5.1,34.5)
| (8.1,37.5),(6.1,35.5)
| (7.6,38),(7.6,37)
| (8.1,37.5),(8.1,37.5)
| (-3,-10),(-5,-12)
| (-2,-9),(-4,-11)
| (-2.5,-8.5),(-2.5,-9.5)
| (-2,-9),(-2,-9)
| (12,12),(10,10)
| (13,13),(11,11)
| (12.5,13.5),(12.5,12.5)
| (13,13),(13,13)
(24 rows)
SELECT '' AS twentyfour, b.f1 - p.f1 AS translation
FROM BOX_TBL b, POINT_TBL p;
twentyfour | translation
------------+---------------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
| (12,2),(10,0)
| (13,3),(11,1)
| (12.5,3.5),(12.5,2.5)
| (13,3),(13,3)
| (5,-2),(3,-4)
| (6,-1),(4,-3)
| (5.5,-0.5),(5.5,-1.5)
| (6,-1),(6,-1)
| (-3.1,-32.5),(-5.1,-34.5)
| (-2.1,-31.5),(-4.1,-33.5)
| (-2.6,-31),(-2.6,-32)
| (-2.1,-31.5),(-2.1,-31.5)
| (7,14),(5,12)
| (8,15),(6,13)
| (7.5,15.5),(7.5,14.5)
| (8,15),(8,15)
| (-8,-8),(-10,-10)
| (-7,-7),(-9,-9)
| (-7.5,-6.5),(-7.5,-7.5)
| (-7,-7),(-7,-7)
(24 rows)
-- scaling and rotation
SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation
FROM BOX_TBL b, POINT_TBL p;
twentyfour | rotation
------------+-----------------------------
| (0,0),(0,0)
| (0,0),(0,0)
| (0,0),(0,0)
| (0,0),(0,0)
| (0,0),(-20,-20)
| (-10,-10),(-30,-30)
| (-25,-25),(-25,-35)
| (-30,-30),(-30,-30)
| (0,2),(-14,0)
| (-7,3),(-21,1)
| (-17.5,2.5),(-21.5,-0.5)
| (-21,3),(-21,3)
| (0,79.2),(-58.8,0)
| (-29.4,118.8),(-88.2,39.6)
| (-73.5,104.1),(-108,99)
| (-88.2,118.8),(-88.2,118.8)
| (14,0),(0,-34)
| (21,-17),(7,-51)
| (29.5,-42.5),(17.5,-47.5)
| (21,-51),(21,-51)
| (0,40),(0,0)
| (0,60),(0,20)
| (0,60),(-10,50)
| (0,60),(0,60)
(24 rows)
SELECT '' AS twenty, b.f1 / p.f1 AS rotation
FROM BOX_TBL b, POINT_TBL p
WHERE (p.f1 <-> point '(0,0)') >= 1;
twenty | rotation
--------+-----------------------------------------------------------------------------------
| (0,0),(-0.2,-0.2)
| (-0.1,-0.1),(-0.3,-0.3)
| (-0.25,-0.25),(-0.25,-0.35)
| (-0.3,-0.3),(-0.3,-0.3)
| (0.08,0),(0,-0.56)
| (0.12,-0.28),(0.04,-0.84)
| (0.26,-0.7),(0.1,-0.82)
| (0.12,-0.84),(0.12,-0.84)
| (0.0651176557643925,0),(0,-0.0483449262493217)
| (0.0976764836465887,-0.0241724631246608),(0.0325588278821962,-0.0725173893739825)
| (0.109762715208919,-0.0562379754328844),(0.0813970697054906,-0.0604311578116521)
| (0.0976764836465887,-0.0725173893739825),(0.0976764836465887,-0.0725173893739825)
| (0,0.0828402366863905),(-0.201183431952663,0)
| (-0.100591715976331,0.124260355029586),(-0.301775147928994,0.0414201183431953)
| (-0.251479289940828,0.103550295857988),(-0.322485207100592,0.0739644970414201)
| (-0.301775147928994,0.124260355029586),(-0.301775147928994,0.124260355029586)
| (0.2,0),(0,0)
| (0.3,0),(0.1,0)
| (0.3,0.05),(0.25,0)
| (0.3,0),(0.3,0)
(20 rows)
--
-- Paths
--
SET geqo TO 'off';
SELECT '' AS eight, points(f1) AS npoints, f1 AS path FROM PATH_TBL;
eight | npoints | path
-------+---------+---------------------------
| 2 | [(1,2),(3,4)]
| 2 | ((1,2),(3,4))
| 4 | [(0,0),(3,0),(4,5),(1,6)]
| 2 | ((1,2),(3,4))
| 2 | ((1,2),(3,4))
| 2 | [(1,2),(3,4)]
| 2 | [(11,12),(13,14)]
| 2 | ((11,12),(13,14))
(8 rows)
SELECT '' AS four, path(f1) FROM POLYGON_TBL;
four | path
------+---------------------
| ((2,0),(2,4),(0,0))
| ((3,1),(3,3),(1,0))
| ((0,0))
| ((0,1),(0,1))
(4 rows)
-- translation
SELECT '' AS eight, p1.f1 + point '(10,10)' AS dist_add
FROM PATH_TBL p1;
eight | dist_add
-------+-----------------------------------
| [(11,12),(13,14)]
| ((11,12),(13,14))
| [(10,10),(13,10),(14,15),(11,16)]
| ((11,12),(13,14))
| ((11,12),(13,14))
| [(11,12),(13,14)]
| [(21,22),(23,24)]
| ((21,22),(23,24))
(8 rows)
-- scaling and rotation
SELECT '' AS eight, p1.f1 * point '(2,-1)' AS dist_mul
FROM PATH_TBL p1;
eight | dist_mul
-------+------------------------------
| [(4,3),(10,5)]
| ((4,3),(10,5))
| [(0,0),(6,-3),(13,6),(8,11)]
| ((4,3),(10,5))
| ((4,3),(10,5))
| [(4,3),(10,5)]
| [(34,13),(40,15)]
| ((34,13),(40,15))
(8 rows)
RESET geqo;
--
-- Polygons
--
-- containment
SELECT '' AS twentyfour, p.f1, poly.f1, poly.f1 ~ p.f1 AS contains
FROM POLYGON_TBL poly, POINT_TBL p;
twentyfour | f1 | f1 | contains
------------+------------+---------------------+----------
| (0,0) | ((2,0),(2,4),(0,0)) | t
| (-10,0) | ((2,0),(2,4),(0,0)) | f
| (-3,4) | ((2,0),(2,4),(0,0)) | f
| (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
| (-5,-12) | ((2,0),(2,4),(0,0)) | f
| (10,10) | ((2,0),(2,4),(0,0)) | f
| (0,0) | ((3,1),(3,3),(1,0)) | f
| (-10,0) | ((3,1),(3,3),(1,0)) | f
| (-3,4) | ((3,1),(3,3),(1,0)) | f
| (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
| (-5,-12) | ((3,1),(3,3),(1,0)) | f
| (10,10) | ((3,1),(3,3),(1,0)) | f
| (0,0) | ((0,0)) | t
| (-10,0) | ((0,0)) | f
| (-3,4) | ((0,0)) | f
| (5.1,34.5) | ((0,0)) | f
| (-5,-12) | ((0,0)) | f
| (10,10) | ((0,0)) | f
| (0,0) | ((0,1),(0,1)) | f
| (-10,0) | ((0,1),(0,1)) | f
| (-3,4) | ((0,1),(0,1)) | f
| (5.1,34.5) | ((0,1),(0,1)) | f
| (-5,-12) | ((0,1),(0,1)) | f
| (10,10) | ((0,1),(0,1)) | f
(24 rows)
SELECT '' AS twentyfour, p.f1, poly.f1, p.f1 @ poly.f1 AS contained
FROM POLYGON_TBL poly, POINT_TBL p;
twentyfour | f1 | f1 | contained
------------+------------+---------------------+-----------
| (0,0) | ((2,0),(2,4),(0,0)) | t
| (-10,0) | ((2,0),(2,4),(0,0)) | f
| (-3,4) | ((2,0),(2,4),(0,0)) | f
| (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
| (-5,-12) | ((2,0),(2,4),(0,0)) | f
| (10,10) | ((2,0),(2,4),(0,0)) | f
| (0,0) | ((3,1),(3,3),(1,0)) | f
| (-10,0) | ((3,1),(3,3),(1,0)) | f
| (-3,4) | ((3,1),(3,3),(1,0)) | f
| (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
| (-5,-12) | ((3,1),(3,3),(1,0)) | f
| (10,10) | ((3,1),(3,3),(1,0)) | f
| (0,0) | ((0,0)) | t
| (-10,0) | ((0,0)) | f
| (-3,4) | ((0,0)) | f
| (5.1,34.5) | ((0,0)) | f
| (-5,-12) | ((0,0)) | f
| (10,10) | ((0,0)) | f
| (0,0) | ((0,1),(0,1)) | f
| (-10,0) | ((0,1),(0,1)) | f
| (-3,4) | ((0,1),(0,1)) | f
| (5.1,34.5) | ((0,1),(0,1)) | f
| (-5,-12) | ((0,1),(0,1)) | f
| (10,10) | ((0,1),(0,1)) | f
(24 rows)
SELECT '' AS four, points(f1) AS npoints, f1 AS polygon
FROM POLYGON_TBL;
four | npoints | polygon
------+---------+---------------------
| 3 | ((2,0),(2,4),(0,0))
| 3 | ((3,1),(3,3),(1,0))
| 1 | ((0,0))
| 2 | ((0,1),(0,1))
(4 rows)
SELECT '' AS four, polygon(f1)
FROM BOX_TBL;
four | polygon
------+-------------------------------------------
| ((0,0),(0,2),(2,2),(2,0))
| ((1,1),(1,3),(3,3),(3,1))
| ((2.5,2.5),(2.5,3.5),(2.5,3.5),(2.5,2.5))
| ((3,3),(3,3),(3,3),(3,3))
(4 rows)
SELECT '' AS four, polygon(f1)
FROM PATH_TBL WHERE isclosed(f1);
four | polygon
------+-------------------
| ((1,2),(3,4))
| ((1,2),(3,4))
| ((1,2),(3,4))
| ((11,12),(13,14))
(4 rows)
SELECT '' AS four, f1 AS open_path, polygon( pclose(f1)) AS polygon
FROM PATH_TBL
WHERE isopen(f1);
four | open_path | polygon
------+---------------------------+---------------------------
| [(1,2),(3,4)] | ((1,2),(3,4))
| [(0,0),(3,0),(4,5),(1,6)] | ((0,0),(3,0),(4,5),(1,6))
| [(1,2),(3,4)] | ((1,2),(3,4))
| [(11,12),(13,14)] | ((11,12),(13,14))
(4 rows)
-- convert circles to polygons using the default number of points
SELECT '' AS six, polygon(f1)
FROM CIRCLE_TBL;
six | polygon
-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ((-3,0),(-2.59807621135076,1.50000000000442),(-1.49999999999116,2.59807621135842),(1.53102359017709e-11,3),(1.50000000001768,2.59807621134311),(2.59807621136607,1.4999999999779),(3,-3.06204718035418e-11),(2.59807621133545,-1.50000000003094),(1.49999999996464,-2.59807621137373),(-4.59307077053127e-11,-3),(-1.5000000000442,-2.5980762113278),(-2.59807621138138,-1.49999999995138))
| ((-99,2),(-85.6025403783588,52.0000000001473),(-48.9999999997054,88.602540378614),(1.00000000051034,102),(51.0000000005893,88.6025403781036),(87.6025403788692,51.9999999992634),(101,1.99999999897932),(87.6025403778485,-48.0000000010313),(50.9999999988214,-84.6025403791243),(0.999999998468976,-98),(-49.0000000014732,-84.6025403775933),(-85.6025403793795,-47.9999999983795))
| ((-4,3),(-3.33012701891794,5.50000000000737),(-1.49999999998527,7.3301270189307),(1.00000000002552,8),(3.50000000002946,7.33012701890518),(5.33012701894346,5.49999999996317),(6,2.99999999994897),(5.33012701889242,0.499999999948437),(3.49999999994107,-1.33012701895622),(0.999999999923449,-2),(-1.50000000007366,-1.33012701887967),(-3.33012701896897,0.500000000081028))
| ((-2,2),(-1.59807621135076,3.50000000000442),(-0.499999999991161,4.59807621135842),(1.00000000001531,5),(2.50000000001768,4.59807621134311),(3.59807621136607,3.4999999999779),(4,1.99999999996938),(3.59807621133545,0.499999999969062),(2.49999999996464,-0.598076211373729),(0.999999999954069,-1),(-0.500000000044197,-0.598076211327799),(-1.59807621138138,0.500000000048616))
| ((90,200),(91.3397459621641,205.000000000015),(95.0000000000295,208.660254037861),(100.000000000051,210),(105.000000000059,208.66025403781),(108.660254037887,204.999999999926),(110,199.999999999898),(108.660254037785,194.999999999897),(104.999999999882,191.339745962088),(99.9999999998469,190),(94.9999999998527,191.339745962241),(91.3397459620621,195.000000000162))
| ((0,0),(13.3974596216412,50.0000000001473),(50.0000000002946,86.602540378614),(100.00000000051,100),(150.000000000589,86.6025403781036),(186.602540378869,49.9999999992634),(200,-1.02068239345139e-09),(186.602540377848,-50.0000000010313),(149.999999998821,-86.6025403791243),(99.999999998469,-100),(49.9999999985268,-86.6025403775933),(13.3974596206205,-49.9999999983795))
(6 rows)
-- convert the circle to an 8-point polygon
SELECT '' AS six, polygon(8, f1)
FROM CIRCLE_TBL;
six | polygon
-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ((-3,0),(-2.12132034355423,2.12132034356506),(1.53102359017709e-11,3),(2.12132034357588,2.1213203435434),(3,-3.06204718035418e-11),(2.12132034353258,-2.12132034358671),(-4.59307077053127e-11,-3),(-2.12132034359753,-2.12132034352175))
| ((-99,2),(-69.7106781184743,72.7106781188352),(1.00000000051034,102),(71.710678119196,72.7106781181135),(101,1.99999999897932),(71.7106781177526,-68.7106781195569),(0.999999998468976,-98),(-69.7106781199178,-68.7106781173917))
| ((-4,3),(-2.53553390592372,6.53553390594176),(1.00000000002552,8),(4.5355339059598,6.53553390590567),(6,2.99999999994897),(4.53553390588763,-0.535533905977846),(0.999999999923449,-2),(-2.53553390599589,-0.535533905869586))
| ((-2,2),(-1.12132034355423,4.12132034356506),(1.00000000001531,5),(3.12132034357588,4.1213203435434),(4,1.99999999996938),(3.12132034353258,-0.121320343586707),(0.999999999954069,-1),(-1.12132034359753,-0.121320343521752))
| ((90,200),(92.9289321881526,207.071067811884),(100.000000000051,210),(107.07106781192,207.071067811811),(110,199.999999999898),(107.071067811775,192.928932188044),(99.9999999998469,190),(92.9289321880082,192.928932188261))
| ((0,0),(29.2893218815257,70.7106781188352),(100.00000000051,100),(170.710678119196,70.7106781181135),(200,-1.02068239345139e-09),(170.710678117753,-70.7106781195569),(99.999999998469,-100),(29.2893218800822,-70.7106781173917))
(6 rows)
--
-- Circles
--
SELECT '' AS six, circle(f1, 50.0)
FROM POINT_TBL;
six | circle
-----+-----------------
| <(0,0),50>
| <(-10,0),50>
| <(-3,4),50>
| <(5.1,34.5),50>
| <(-5,-12),50>
| <(10,10),50>
(6 rows)
SELECT '' AS four, circle(f1)
FROM BOX_TBL;
four | circle
------+-------------------------
| <(1,1),1.4142135623731>
| <(2,2),1.4142135623731>
| <(2.5,3),0.5>
| <(3,3),0>
(4 rows)
SELECT '' AS two, circle(f1)
FROM POLYGON_TBL
WHERE (# f1) >= 3;
two | circle
-----+--------------------------------------------------------
| <(1.33333333333333,1.33333333333333),2.04168905063636>
| <(2.33333333333333,1.33333333333333),1.47534300379185>
(2 rows)
SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS distance
FROM CIRCLE_TBL c1, POINT_TBL p1
WHERE (p1.f1 <-> c1.f1) > 0
ORDER BY distance, circle, point using <<;
twentyfour | circle | point | distance
------------+----------------+------------+------------------
| <(100,0),100> | (5.1,34.5) | 0.97653192697797
| <(1,2),3> | (-3,4) | 1.47213595499958
| <(0,0),3> | (-3,4) | 2
| <(100,0),100> | (-3,4) | 3.07764064044152
| <(100,0),100> | (-5,-12) | 5.68348972285122
| <(1,3),5> | (-10,0) | 6.40175425099138
| <(1,3),5> | (10,10) | 6.40175425099138
| <(0,0),3> | (-10,0) | 7
| <(1,2),3> | (-10,0) | 8.18033988749895
| <(1,2),3> | (10,10) | 9.0415945787923
| <(0,0),3> | (-5,-12) | 10
| <(100,0),100> | (-10,0) | 10
| <(0,0),3> | (10,10) | 11.142135623731
| <(1,3),5> | (-5,-12) | 11.1554944214035
| <(1,2),3> | (-5,-12) | 12.2315462117278
| <(1,3),5> | (5.1,34.5) | 26.7657047773223
| <(1,2),3> | (5.1,34.5) | 29.757594539282
| <(0,0),3> | (5.1,34.5) | 31.8749193547455
| <(100,200),10> | (5.1,34.5) | 180.778038568384
| <(100,200),10> | (10,10) | 200.237960416286
| <(100,200),10> | (-3,4) | 211.415898254845
| <(100,200),10> | (0,0) | 213.606797749979
| <(100,200),10> | (-10,0) | 218.254244210267
| <(100,200),10> | (-5,-12) | 226.577682802077
(24 rows)

View File

@ -0,0 +1,532 @@
--
-- GEOMETRY
--
--
-- Points
--
SELECT '' AS four, center(f1) AS center
FROM BOX_TBL;
four | center
------+---------
| (1,1)
| (2,2)
| (2.5,3)
| (3,3)
(4 rows)
SELECT '' AS four, (@@ f1) AS center
FROM BOX_TBL;
four | center
------+---------
| (1,1)
| (2,2)
| (2.5,3)
| (3,3)
(4 rows)
SELECT '' AS six, point(f1) AS center
FROM CIRCLE_TBL;
six | center
-----+-----------
| (0,0)
| (1,2)
| (1,3)
| (1,2)
| (100,200)
| (100,0)
(6 rows)
SELECT '' AS six, (@@ f1) AS center
FROM CIRCLE_TBL;
six | center
-----+-----------
| (0,0)
| (1,2)
| (1,3)
| (1,2)
| (100,200)
| (100,0)
(6 rows)
SELECT '' AS two, (@@ f1) AS center
FROM POLYGON_TBL
WHERE (# f1) > 2;
two | center
-----+-------------------------------------
| (1.33333333333333,1.33333333333333)
| (2.33333333333333,1.33333333333333)
(2 rows)
-- "is horizontal" function
SELECT '' AS two, p1.f1
FROM POINT_TBL p1
WHERE ishorizontal(p1.f1, point '(0,0)');
two | f1
-----+---------
| (0,0)
| (-10,0)
(2 rows)
-- "is horizontal" operator
SELECT '' AS two, p1.f1
FROM POINT_TBL p1
WHERE p1.f1 ?- point '(0,0)';
two | f1
-----+---------
| (0,0)
| (-10,0)
(2 rows)
-- "is vertical" function
SELECT '' AS one, p1.f1
FROM POINT_TBL p1
WHERE isvertical(p1.f1, point '(5.1,34.5)');
one | f1
-----+------------
| (5.1,34.5)
(1 row)
-- "is vertical" operator
SELECT '' AS one, p1.f1
FROM POINT_TBL p1
WHERE p1.f1 ?| point '(5.1,34.5)';
one | f1
-----+------------
| (5.1,34.5)
(1 row)
--
-- Line segments
--
-- intersection
SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
FROM LSEG_TBL l, POINT_TBL p;
ERROR: Unable to identify an operator '#' for types 'lseg' and 'point'
You will have to retype this query using an explicit cast
-- closest point
SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
FROM LSEG_TBL l, POINT_TBL p;
thirty | f1 | s | closest
--------+------------+-------------------------------+---------------------------------------
| (0,0) | [(1,2),(3,4)] | (1,2)
| (-10,0) | [(1,2),(3,4)] | (1,2)
| (-3,4) | [(1,2),(3,4)] | (1,2)
| (5.1,34.5) | [(1,2),(3,4)] | (3,4)
| (-5,-12) | [(1,2),(3,4)] | (1,2)
| (10,10) | [(1,2),(3,4)] | (3,4)
| (0,0) | [(0,0),(6,6)] | (-0,0)
| (-10,0) | [(0,0),(6,6)] | (0,0)
| (-3,4) | [(0,0),(6,6)] | (0.5,0.5)
| (5.1,34.5) | [(0,0),(6,6)] | (6,6)
| (-5,-12) | [(0,0),(6,6)] | (0,0)
| (10,10) | [(0,0),(6,6)] | (6,6)
| (0,0) | [(10,-10),(-3,-4)] | (-2.04878048780488,-4.4390243902439)
| (-10,0) | [(10,-10),(-3,-4)] | (-3,-4)
| (-3,4) | [(10,-10),(-3,-4)] | (-3,-4)
| (5.1,34.5) | [(10,-10),(-3,-4)] | (-3,-4)
| (-5,-12) | [(10,-10),(-3,-4)] | (-1.60487804878049,-4.64390243902439)
| (10,10) | [(10,-10),(-3,-4)] | (2.39024390243902,-6.48780487804878)
| (0,0) | [(-1000000,200),(300000,-40)] | (0.0028402365895872,15.384614860264)
| (-10,0) | [(-1000000,200),(300000,-40)] | (-9.99715942258202,15.3864610140473)
| (-3,4) | [(-1000000,200),(300000,-40)] | (-2.99789812267519,15.3851688427303)
| (5.1,34.5) | [(-1000000,200),(300000,-40)] | (5.09647083221496,15.3836744976925)
| (-5,-12) | [(-1000000,200),(300000,-40)] | (-4.99494420845634,15.3855375281616)
| (10,10) | [(-1000000,200),(300000,-40)] | (10.000993741978,15.3827690473092)
| (0,0) | [(11,22),(33,44)] | (11,22)
| (-10,0) | [(11,22),(33,44)] | (11,22)
| (-3,4) | [(11,22),(33,44)] | (11,22)
| (5.1,34.5) | [(11,22),(33,44)] | (14.3,25.3)
| (-5,-12) | [(11,22),(33,44)] | (11,22)
| (10,10) | [(11,22),(33,44)] | (11,22)
(30 rows)
--
-- Lines
--
--
-- Boxes
--
SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL;
six | box
-----+----------------------------------------------------------------------------
| (2.12132034355964,2.12132034355964),(-2.12132034355964,-2.12132034355964)
| (71.7106781186548,72.7106781186548),(-69.7106781186548,-68.7106781186548)
| (4.53553390593274,6.53553390593274),(-2.53553390593274,-0.535533905932738)
| (3.12132034355964,4.12132034355964),(-1.12132034355964,-0.121320343559643)
| (107.071067811865,207.071067811865),(92.9289321881345,192.928932188135)
| (170.710678118655,70.7106781186548),(29.2893218813452,-70.7106781186548)
(6 rows)
-- translation
SELECT '' AS twentyfour, b.f1 + p.f1 AS translation
FROM BOX_TBL b, POINT_TBL p;
twentyfour | translation
------------+-------------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
| (-8,2),(-10,0)
| (-7,3),(-9,1)
| (-7.5,3.5),(-7.5,2.5)
| (-7,3),(-7,3)
| (-1,6),(-3,4)
| (0,7),(-2,5)
| (-0.5,7.5),(-0.5,6.5)
| (0,7),(0,7)
| (7.1,36.5),(5.1,34.5)
| (8.1,37.5),(6.1,35.5)
| (7.6,38),(7.6,37)
| (8.1,37.5),(8.1,37.5)
| (-3,-10),(-5,-12)
| (-2,-9),(-4,-11)
| (-2.5,-8.5),(-2.5,-9.5)
| (-2,-9),(-2,-9)
| (12,12),(10,10)
| (13,13),(11,11)
| (12.5,13.5),(12.5,12.5)
| (13,13),(13,13)
(24 rows)
SELECT '' AS twentyfour, b.f1 - p.f1 AS translation
FROM BOX_TBL b, POINT_TBL p;
twentyfour | translation
------------+---------------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
| (12,2),(10,0)
| (13,3),(11,1)
| (12.5,3.5),(12.5,2.5)
| (13,3),(13,3)
| (5,-2),(3,-4)
| (6,-1),(4,-3)
| (5.5,-0.5),(5.5,-1.5)
| (6,-1),(6,-1)
| (-3.1,-32.5),(-5.1,-34.5)
| (-2.1,-31.5),(-4.1,-33.5)
| (-2.6,-31),(-2.6,-32)
| (-2.1,-31.5),(-2.1,-31.5)
| (7,14),(5,12)
| (8,15),(6,13)
| (7.5,15.5),(7.5,14.5)
| (8,15),(8,15)
| (-8,-8),(-10,-10)
| (-7,-7),(-9,-9)
| (-7.5,-6.5),(-7.5,-7.5)
| (-7,-7),(-7,-7)
(24 rows)
-- scaling and rotation
SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation
FROM BOX_TBL b, POINT_TBL p;
twentyfour | rotation
------------+-----------------------------
| (0,0),(0,0)
| (0,0),(0,0)
| (0,0),(0,0)
| (0,0),(0,0)
| (-0,0),(-20,-20)
| (-10,-10),(-30,-30)
| (-25,-25),(-25,-35)
| (-30,-30),(-30,-30)
| (-0,2),(-14,0)
| (-7,3),(-21,1)
| (-17.5,2.5),(-21.5,-0.5)
| (-21,3),(-21,3)
| (0,79.2),(-58.8,0)
| (-29.4,118.8),(-88.2,39.6)
| (-73.5,104.1),(-108,99)
| (-88.2,118.8),(-88.2,118.8)
| (14,-0),(0,-34)
| (21,-17),(7,-51)
| (29.5,-42.5),(17.5,-47.5)
| (21,-51),(21,-51)
| (0,40),(0,0)
| (0,60),(0,20)
| (0,60),(-10,50)
| (0,60),(0,60)
(24 rows)
SELECT '' AS twenty, b.f1 / p.f1 AS rotation
FROM BOX_TBL b, POINT_TBL p
WHERE (p.f1 <-> point '(0,0)') >= 1;
twenty | rotation
--------+-----------------------------------------------------------------------------------
| (0,-0),(-0.2,-0.2)
| (-0.1,-0.1),(-0.3,-0.3)
| (-0.25,-0.25),(-0.25,-0.35)
| (-0.3,-0.3),(-0.3,-0.3)
| (0.08,-0),(0,-0.56)
| (0.12,-0.28),(0.04,-0.84)
| (0.26,-0.7),(0.1,-0.82)
| (0.12,-0.84),(0.12,-0.84)
| (0.0651176557643925,0),(0,-0.0483449262493217)
| (0.0976764836465887,-0.0241724631246608),(0.0325588278821962,-0.0725173893739825)
| (0.109762715208919,-0.0562379754328844),(0.0813970697054906,-0.0604311578116521)
| (0.0976764836465887,-0.0725173893739825),(0.0976764836465887,-0.0725173893739825)
| (-0,0.0828402366863905),(-0.201183431952663,0)
| (-0.100591715976331,0.124260355029586),(-0.301775147928994,0.0414201183431953)
| (-0.251479289940828,0.103550295857988),(-0.322485207100592,0.0739644970414201)
| (-0.301775147928994,0.124260355029586),(-0.301775147928994,0.124260355029586)
| (0.2,0),(0,0)
| (0.3,0),(0.1,0)
| (0.3,0.05),(0.25,0)
| (0.3,0),(0.3,0)
(20 rows)
--
-- Paths
--
SET geqo TO 'off';
SELECT '' AS eight, points(f1) AS npoints, f1 AS path FROM PATH_TBL;
eight | npoints | path
-------+---------+---------------------------
| 2 | [(1,2),(3,4)]
| 2 | ((1,2),(3,4))
| 4 | [(0,0),(3,0),(4,5),(1,6)]
| 2 | ((1,2),(3,4))
| 2 | ((1,2),(3,4))
| 2 | [(1,2),(3,4)]
| 2 | [(11,12),(13,14)]
| 2 | ((11,12),(13,14))
(8 rows)
SELECT '' AS four, path(f1) FROM POLYGON_TBL;
four | path
------+---------------------
| ((2,0),(2,4),(0,0))
| ((3,1),(3,3),(1,0))
| ((0,0))
| ((0,1),(0,1))
(4 rows)
-- translation
SELECT '' AS eight, p1.f1 + point '(10,10)' AS dist_add
FROM PATH_TBL p1;
eight | dist_add
-------+-----------------------------------
| [(11,12),(13,14)]
| ((11,12),(13,14))
| [(10,10),(13,10),(14,15),(11,16)]
| ((11,12),(13,14))
| ((11,12),(13,14))
| [(11,12),(13,14)]
| [(21,22),(23,24)]
| ((21,22),(23,24))
(8 rows)
-- scaling and rotation
SELECT '' AS eight, p1.f1 * point '(2,-1)' AS dist_mul
FROM PATH_TBL p1;
eight | dist_mul
-------+------------------------------
| [(4,3),(10,5)]
| ((4,3),(10,5))
| [(0,0),(6,-3),(13,6),(8,11)]
| ((4,3),(10,5))
| ((4,3),(10,5))
| [(4,3),(10,5)]
| [(34,13),(40,15)]
| ((34,13),(40,15))
(8 rows)
RESET geqo;
--
-- Polygons
--
-- containment
SELECT '' AS twentyfour, p.f1, poly.f1, poly.f1 ~ p.f1 AS contains
FROM POLYGON_TBL poly, POINT_TBL p;
twentyfour | f1 | f1 | contains
------------+------------+---------------------+----------
| (0,0) | ((2,0),(2,4),(0,0)) | t
| (-10,0) | ((2,0),(2,4),(0,0)) | f
| (-3,4) | ((2,0),(2,4),(0,0)) | f
| (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
| (-5,-12) | ((2,0),(2,4),(0,0)) | f
| (10,10) | ((2,0),(2,4),(0,0)) | f
| (0,0) | ((3,1),(3,3),(1,0)) | f
| (-10,0) | ((3,1),(3,3),(1,0)) | f
| (-3,4) | ((3,1),(3,3),(1,0)) | f
| (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
| (-5,-12) | ((3,1),(3,3),(1,0)) | f
| (10,10) | ((3,1),(3,3),(1,0)) | f
| (0,0) | ((0,0)) | t
| (-10,0) | ((0,0)) | f
| (-3,4) | ((0,0)) | f
| (5.1,34.5) | ((0,0)) | f
| (-5,-12) | ((0,0)) | f
| (10,10) | ((0,0)) | f
| (0,0) | ((0,1),(0,1)) | f
| (-10,0) | ((0,1),(0,1)) | f
| (-3,4) | ((0,1),(0,1)) | f
| (5.1,34.5) | ((0,1),(0,1)) | f
| (-5,-12) | ((0,1),(0,1)) | f
| (10,10) | ((0,1),(0,1)) | f
(24 rows)
SELECT '' AS twentyfour, p.f1, poly.f1, p.f1 @ poly.f1 AS contained
FROM POLYGON_TBL poly, POINT_TBL p;
twentyfour | f1 | f1 | contained
------------+------------+---------------------+-----------
| (0,0) | ((2,0),(2,4),(0,0)) | t
| (-10,0) | ((2,0),(2,4),(0,0)) | f
| (-3,4) | ((2,0),(2,4),(0,0)) | f
| (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
| (-5,-12) | ((2,0),(2,4),(0,0)) | f
| (10,10) | ((2,0),(2,4),(0,0)) | f
| (0,0) | ((3,1),(3,3),(1,0)) | f
| (-10,0) | ((3,1),(3,3),(1,0)) | f
| (-3,4) | ((3,1),(3,3),(1,0)) | f
| (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
| (-5,-12) | ((3,1),(3,3),(1,0)) | f
| (10,10) | ((3,1),(3,3),(1,0)) | f
| (0,0) | ((0,0)) | t
| (-10,0) | ((0,0)) | f
| (-3,4) | ((0,0)) | f
| (5.1,34.5) | ((0,0)) | f
| (-5,-12) | ((0,0)) | f
| (10,10) | ((0,0)) | f
| (0,0) | ((0,1),(0,1)) | f
| (-10,0) | ((0,1),(0,1)) | f
| (-3,4) | ((0,1),(0,1)) | f
| (5.1,34.5) | ((0,1),(0,1)) | f
| (-5,-12) | ((0,1),(0,1)) | f
| (10,10) | ((0,1),(0,1)) | f
(24 rows)
SELECT '' AS four, points(f1) AS npoints, f1 AS polygon
FROM POLYGON_TBL;
four | npoints | polygon
------+---------+---------------------
| 3 | ((2,0),(2,4),(0,0))
| 3 | ((3,1),(3,3),(1,0))
| 1 | ((0,0))
| 2 | ((0,1),(0,1))
(4 rows)
SELECT '' AS four, polygon(f1)
FROM BOX_TBL;
four | polygon
------+-------------------------------------------
| ((0,0),(0,2),(2,2),(2,0))
| ((1,1),(1,3),(3,3),(3,1))
| ((2.5,2.5),(2.5,3.5),(2.5,3.5),(2.5,2.5))
| ((3,3),(3,3),(3,3),(3,3))
(4 rows)
SELECT '' AS four, polygon(f1)
FROM PATH_TBL WHERE isclosed(f1);
four | polygon
------+-------------------
| ((1,2),(3,4))
| ((1,2),(3,4))
| ((1,2),(3,4))
| ((11,12),(13,14))
(4 rows)
SELECT '' AS four, f1 AS open_path, polygon( pclose(f1)) AS polygon
FROM PATH_TBL
WHERE isopen(f1);
four | open_path | polygon
------+---------------------------+---------------------------
| [(1,2),(3,4)] | ((1,2),(3,4))
| [(0,0),(3,0),(4,5),(1,6)] | ((0,0),(3,0),(4,5),(1,6))
| [(1,2),(3,4)] | ((1,2),(3,4))
| [(11,12),(13,14)] | ((11,12),(13,14))
(4 rows)
-- convert circles to polygons using the default number of points
SELECT '' AS six, polygon(f1)
FROM CIRCLE_TBL;
six | polygon
-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ((-3,0),(-2.59807621135332,1.5),(-1.5,2.59807621135332),(-1.83690953073357e-16,3),(1.5,2.59807621135332),(2.59807621135332,1.5),(3,3.67381906146713e-16),(2.59807621135332,-1.5),(1.5,-2.59807621135332),(5.5107285922007e-16,-3),(-1.5,-2.59807621135332),(-2.59807621135332,-1.5))
| ((-99,2),(-85.6025403784439,52),(-49,88.6025403784439),(0.999999999999994,102),(51,88.6025403784439),(87.6025403784439,52),(101,2.00000000000001),(87.6025403784439,-48),(51,-84.6025403784438),(1.00000000000002,-98),(-49,-84.6025403784439),(-85.6025403784438,-48))
| ((-4,3),(-3.33012701892219,5.5),(-1.5,7.33012701892219),(1,8),(3.5,7.33012701892219),(5.33012701892219,5.5),(6,3),(5.33012701892219,0.500000000000001),(3.5,-1.33012701892219),(1,-2),(-1.5,-1.33012701892219),(-3.33012701892219,0.499999999999998))
| ((-2,2),(-1.59807621135332,3.5),(-0.5,4.59807621135332),(1,5),(2.5,4.59807621135332),(3.59807621135332,3.5),(4,2),(3.59807621135332,0.500000000000001),(2.5,-0.598076211353315),(1,-1),(-0.5,-0.598076211353316),(-1.59807621135332,0.499999999999999))
| ((90,200),(91.3397459621556,205),(95,208.660254037844),(100,210),(105,208.660254037844),(108.660254037844,205),(110,200),(108.660254037844,195),(105,191.339745962156),(100,190),(95,191.339745962156),(91.3397459621556,195))
| ((0,0),(13.3974596215561,50),(50,86.6025403784439),(100,100),(150,86.6025403784439),(186.602540378444,50),(200,1.22460635382238e-14),(186.602540378444,-50),(150,-86.6025403784438),(100,-100),(50,-86.6025403784439),(13.3974596215562,-50))
(6 rows)
-- convert the circle to an 8-point polygon
SELECT '' AS six, polygon(8, f1)
FROM CIRCLE_TBL;
six | polygon
-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ((-3,0),(-2.12132034355964,2.12132034355964),(-1.83690953073357e-16,3),(2.12132034355964,2.12132034355964),(3,3.67381906146713e-16),(2.12132034355964,-2.12132034355964),(5.5107285922007e-16,-3),(-2.12132034355964,-2.12132034355964))
| ((-99,2),(-69.7106781186548,72.7106781186548),(0.999999999999994,102),(71.7106781186547,72.7106781186548),(101,2.00000000000001),(71.7106781186548,-68.7106781186547),(1.00000000000002,-98),(-69.7106781186547,-68.7106781186548))
| ((-4,3),(-2.53553390593274,6.53553390593274),(1,8),(4.53553390593274,6.53553390593274),(6,3),(4.53553390593274,-0.535533905932737),(1,-2),(-2.53553390593274,-0.535533905932738))
| ((-2,2),(-1.12132034355964,4.12132034355964),(1,5),(3.12132034355964,4.12132034355964),(4,2),(3.12132034355964,-0.121320343559642),(1,-1),(-1.12132034355964,-0.121320343559643))
| ((90,200),(92.9289321881345,207.071067811865),(100,210),(107.071067811865,207.071067811865),(110,200),(107.071067811865,192.928932188135),(100,190),(92.9289321881345,192.928932188135))
| ((0,0),(29.2893218813452,70.7106781186548),(100,100),(170.710678118655,70.7106781186548),(200,1.22460635382238e-14),(170.710678118655,-70.7106781186547),(100,-100),(29.2893218813453,-70.7106781186548))
(6 rows)
--
-- Circles
--
SELECT '' AS six, circle(f1, 50.0)
FROM POINT_TBL;
six | circle
-----+-----------------
| <(0,0),50>
| <(-10,0),50>
| <(-3,4),50>
| <(5.1,34.5),50>
| <(-5,-12),50>
| <(10,10),50>
(6 rows)
SELECT '' AS four, circle(f1)
FROM BOX_TBL;
four | circle
------+-------------------------
| <(1,1),1.4142135623731>
| <(2,2),1.4142135623731>
| <(2.5,3),0.5>
| <(3,3),0>
(4 rows)
SELECT '' AS two, circle(f1)
FROM POLYGON_TBL
WHERE (# f1) >= 3;
two | circle
-----+--------------------------------------------------------
| <(1.33333333333333,1.33333333333333),2.04168905063636>
| <(2.33333333333333,1.33333333333333),1.47534300379185>
(2 rows)
SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS distance
FROM CIRCLE_TBL c1, POINT_TBL p1
WHERE (p1.f1 <-> c1.f1) > 0
ORDER BY distance, circle, point using <<;
twentyfour | circle | point | distance
------------+----------------+------------+-------------------
| <(100,0),100> | (5.1,34.5) | 0.976531926977964
| <(1,2),3> | (-3,4) | 1.47213595499958
| <(0,0),3> | (-3,4) | 2
| <(100,0),100> | (-3,4) | 3.07764064044151
| <(100,0),100> | (-5,-12) | 5.68348972285122
| <(1,3),5> | (-10,0) | 6.40175425099138
| <(1,3),5> | (10,10) | 6.40175425099138
| <(0,0),3> | (-10,0) | 7
| <(1,2),3> | (-10,0) | 8.18033988749895
| <(1,2),3> | (10,10) | 9.0415945787923
| <(0,0),3> | (-5,-12) | 10
| <(100,0),100> | (-10,0) | 10
| <(0,0),3> | (10,10) | 11.142135623731
| <(1,3),5> | (-5,-12) | 11.1554944214035
| <(1,2),3> | (-5,-12) | 12.2315462117278
| <(1,3),5> | (5.1,34.5) | 26.7657047773224
| <(1,2),3> | (5.1,34.5) | 29.757594539282
| <(0,0),3> | (5.1,34.5) | 31.8749193547455
| <(100,200),10> | (5.1,34.5) | 180.778038568384
| <(100,200),10> | (10,10) | 200.237960416286
| <(100,200),10> | (-3,4) | 211.415898254845
| <(100,200),10> | (0,0) | 213.606797749979
| <(100,200),10> | (-10,0) | 218.254244210267
| <(100,200),10> | (-5,-12) | 226.577682802077
(24 rows)

View File

@ -0,0 +1,215 @@
--
-- INT2
-- NOTE: int2 operators never check for over/underflow!
-- Some of these answers are consequently numerically incorrect.
--
CREATE TABLE INT2_TBL(f1 int2);
INSERT INTO INT2_TBL(f1) VALUES ('0');
INSERT INTO INT2_TBL(f1) VALUES ('1234');
INSERT INTO INT2_TBL(f1) VALUES ('-1234');
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
ERROR: pg_atoi: error in "34.5": can't parse ".5"
-- largest and smallest values
INSERT INTO INT2_TBL(f1) VALUES ('32767');
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
-- bad input values -- should give warnings
INSERT INTO INT2_TBL(f1) VALUES ('100000');
ERROR: pg_atoi: error reading "100000": Math result not representable
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
SELECT '' AS five, INT2_TBL.*;
five | f1
------+--------
| 0
| 1234
| -1234
| 32767
| -32767
(5 rows)
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
four | f1
------+--------
| 1234
| -1234
| 32767
| -32767
(4 rows)
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
four | f1
------+--------
| 1234
| -1234
| 32767
| -32767
(4 rows)
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
one | f1
-----+----
| 0
(1 row)
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
one | f1
-----+----
| 0
(1 row)
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
two | f1
-----+--------
| -1234
| -32767
(2 rows)
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
two | f1
-----+--------
| -1234
| -32767
(2 rows)
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
three | f1
-------+--------
| 0
| -1234
| -32767
(3 rows)
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
three | f1
-------+--------
| 0
| -1234
| -32767
(3 rows)
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
two | f1
-----+-------
| 1234
| 32767
(2 rows)
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
two | f1
-----+-------
| 1234
| 32767
(2 rows)
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
three | f1
-------+-------
| 0
| 1234
| 32767
(3 rows)
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
three | f1
-------+-------
| 0
| 1234
| 32767
(3 rows)
-- positive odds
SELECT '' AS one, i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
one | f1
-----+-------
| 32767
(1 row)
-- any evens
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
three | f1
-------+-------
| 0
| 1234
| -1234
(3 rows)
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+-------
| 0 | 0
| 1234 | 2468
| -1234 | -2468
| 32767 | -2
| -32767 | 2
(5 rows)
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 0
| 1234 | 2468
| -1234 | -2468
| 32767 | 65534
| -32767 | -65534
(5 rows)
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 2
| 1234 | 1236
| -1234 | -1232
| 32767 | -32767
| -32767 | -32765
(5 rows)
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 2
| 1234 | 1236
| -1234 | -1232
| 32767 | 32769
| -32767 | -32765
(5 rows)
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+-------
| 0 | -2
| 1234 | 1232
| -1234 | -1236
| 32767 | 32765
| -32767 | 32767
(5 rows)
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | -2
| 1234 | 1232
| -1234 | -1236
| 32767 | 32765
| -32767 | -32769
(5 rows)
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 0
| 1234 | 617
| -1234 | -617
| 32767 | 16383
| -32767 | -16383
(5 rows)
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 0
| 1234 | 617
| -1234 | -617
| 32767 | 16383
| -32767 | -16383
(5 rows)

View File

@ -0,0 +1,315 @@
--
-- INT4
-- WARNING: int4 operators never check for over/underflow!
-- Some of these answers are consequently numerically incorrect.
--
CREATE TABLE INT4_TBL(f1 int4);
INSERT INTO INT4_TBL(f1) VALUES ('0');
INSERT INTO INT4_TBL(f1) VALUES ('123456');
INSERT INTO INT4_TBL(f1) VALUES ('-123456');
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
ERROR: pg_atoi: error in "34.5": can't parse ".5"
-- largest and smallest values
INSERT INTO INT4_TBL(f1) VALUES ('2147483647');
INSERT INTO INT4_TBL(f1) VALUES ('-2147483647');
-- bad input values -- should give warnings
INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
ERROR: pg_atoi: error reading "1000000000000": Math result not representable
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
SELECT '' AS five, INT4_TBL.*;
five | f1
------+-------------
| 0
| 123456
| -123456
| 2147483647
| -2147483647
(5 rows)
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0';
four | f1
------+-------------
| 123456
| -123456
| 2147483647
| -2147483647
(4 rows)
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0';
four | f1
------+-------------
| 123456
| -123456
| 2147483647
| -2147483647
(4 rows)
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0';
one | f1
-----+----
| 0
(1 row)
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0';
one | f1
-----+----
| 0
(1 row)
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0';
two | f1
-----+-------------
| -123456
| -2147483647
(2 rows)
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0';
two | f1
-----+-------------
| -123456
| -2147483647
(2 rows)
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0';
three | f1
-------+-------------
| 0
| -123456
| -2147483647
(3 rows)
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0';
three | f1
-------+-------------
| 0
| -123456
| -2147483647
(3 rows)
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0';
two | f1
-----+------------
| 123456
| 2147483647
(2 rows)
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0';
two | f1
-----+------------
| 123456
| 2147483647
(2 rows)
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0';
three | f1
-------+------------
| 0
| 123456
| 2147483647
(3 rows)
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0';
three | f1
-------+------------
| 0
| 123456
| 2147483647
(3 rows)
-- positive odds
SELECT '' AS one, i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
one | f1
-----+------------
| 2147483647
(1 row)
-- any evens
SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
three | f1
-------+---------
| 0
| 123456
| -123456
(3 rows)
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+---------
| 0 | 0
| 123456 | 246912
| -123456 | -246912
| 2147483647 | -2
| -2147483647 | 2
(5 rows)
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+---------
| 0 | 0
| 123456 | 246912
| -123456 | -246912
| 2147483647 | -2
| -2147483647 | 2
(5 rows)
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+-------------
| 0 | 2
| 123456 | 123458
| -123456 | -123454
| 2147483647 | -2147483647
| -2147483647 | -2147483645
(5 rows)
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+-------------
| 0 | 2
| 123456 | 123458
| -123456 | -123454
| 2147483647 | -2147483647
| -2147483647 | -2147483645
(5 rows)
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+------------
| 0 | -2
| 123456 | 123454
| -123456 | -123458
| 2147483647 | 2147483645
| -2147483647 | 2147483647
(5 rows)
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+------------
| 0 | -2
| 123456 | 123454
| -123456 | -123458
| 2147483647 | 2147483645
| -2147483647 | 2147483647
(5 rows)
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+-------------
| 0 | 0
| 123456 | 61728
| -123456 | -61728
| 2147483647 | 1073741823
| -2147483647 | -1073741823
(5 rows)
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+-------------
| 0 | 0
| 123456 | 61728
| -123456 | -61728
| 2147483647 | 1073741823
| -2147483647 | -1073741823
(5 rows)
--
-- more complex expressions
--
-- variations on unary minus parsing
SELECT -2+3 AS one;
one
-----
1
(1 row)
SELECT 4-2 AS two;
two
-----
2
(1 row)
SELECT 2- -1 AS three;
three
-------
3
(1 row)
SELECT 2 - -2 AS four;
four
------
4
(1 row)
SELECT int2 '2' * int2 '2' = int2 '16' / int2 '4' AS true;
true
------
t
(1 row)
SELECT int4 '2' * int2 '2' = int2 '16' / int4 '4' AS true;
true
------
t
(1 row)
SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true;
true
------
t
(1 row)
SELECT int4 '1000' < int4 '999' AS false;
false
-------
f
(1 row)
SELECT 4! AS twenty_four;
twenty_four
-------------
24
(1 row)
SELECT !!3 AS six;
six
-----
6
(1 row)
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
ten
-----
10
(1 row)
SELECT 2 + 2 / 2 AS three;
three
-------
3
(1 row)
SELECT (2 + 2) / 2 AS two;
two
-----
2
(1 row)
SELECT dsqrt(float8 '64') AS eight;
eight
-------
8
(1 row)
SELECT |/float8 '64' AS eight;
eight
-------
8
(1 row)
SELECT ||/float8 '27' AS three;
three
-------
3
(1 row)

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.38 2000/01/09 07:53:58 tgl Exp $ # $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.39 2000/01/09 20:54:36 tgl Exp $
# #
if [ $# -eq 0 ] if [ $# -eq 0 ]
then then
@ -27,16 +27,34 @@ else
ECHO_C='\c' ECHO_C='\c'
fi fi
if [ -d ./obj ]; then
cd ./obj
fi
PGTZ="PST8PDT"; export PGTZ PGTZ="PST8PDT"; export PGTZ
PGDATESTYLE="Postgres,US"; export PGDATESTYLE PGDATESTYLE="Postgres,US"; export PGDATESTYLE
#FRONTEND=monitor
FRONTEND="psql $HOSTLOC -n -e -q" FRONTEND="psql $HOSTLOC -n -e -q"
# ----------
# Scan resultmap file to find which platform-specific expected files to use.
# The format of each line of the file is
# testname/hostnamepattern=substitutefile
# where the hostnamepattern is evaluated per the rules of expr(1) --- namely,
# it is a standard regular expression with an implicit ^ at the start.
# ----------
SUBSTLIST=""
exec 4<resultmap
while read LINE <&4
do
HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
if [ `expr "$hostname" : "$HOSTPAT"` -ne 0 ]
then
SUBSTLIST="$SUBSTLIST $LINE"
fi
done
exec 4<&-
if [ -d ./obj ]; then
cd ./obj
fi
echo "=============== Notes... =================" echo "=============== Notes... ================="
echo "postmaster must already be running for the regression tests to succeed." echo "postmaster must already be running for the regression tests to succeed."
echo "Please report any apparent problems to ports@postgresql.org" echo "Please report any apparent problems to ports@postgresql.org"
@ -94,32 +112,19 @@ do
$FRONTEND regression < sql/${tst}.sql > results/${tst}.out 2>&1 $FRONTEND regression < sql/${tst}.sql > results/${tst}.out 2>&1
# #
# Check resultmap to see if we should compare to a # Check list extracted from resultmap to see if we should compare
# system-specific result file. The format of the .similar file is # to a system-specific expected file.
# testname/hostname=substitutefile
# There shouldn't be multiple matches, but take the last if there are. # There shouldn't be multiple matches, but take the last if there are.
# #
EXPECTED="expected/${tst}.out" EXPECTED="expected/${tst}.out"
SUBST=`grep "^$tst/$hostname=" resultmap | sed 's/^.*=//' | tail -1` for LINE in $SUBSTLIST
if test "$SUBST" do
then EXPECTED="expected/${SUBST}.out" if [ `expr "$LINE" : "$tst/"` -ne 0 ]
else then
# Next look for a .similar entry that is a prefix of $hostname. SUBST=`echo "$LINE" | sed 's/^.*=//'`
# If there are multiple matches, take the last one. EXPECTED="expected/${SUBST}.out"
exec 4<resultmap
while read LINE <&4
do
SIMHOST=`expr "$LINE" : '\(.*\)='`
MATCH=`expr "$tst/$hostname" : "$SIMHOST"`
if test "$MATCH" != 0
then SUBST=`echo "$LINE" | sed 's/^.*=//'`
fi fi
done done
exec 4<&-
if test "$SUBST"
then EXPECTED="expected/${SUBST}.out"
fi
fi
if [ `diff ${DIFFOPT} ${EXPECTED} results/${tst}.out | wc -l` -ne 0 ] if [ `diff ${DIFFOPT} ${EXPECTED} results/${tst}.out | wc -l` -ne 0 ]
then then

View File

@ -1,4 +1,8 @@
int2/hppa=int2-too-large int2/hppa=int2-too-large
int4/hppa=int4-too-large int4/hppa=int4-too-large
geometry/hppa2.0=geometry-hppa2.0 int2/i.86-pc-linux-gnulibc=int2-not-representable
int4/i.86-pc-linux-gnulibc=int4-not-representable
geometry/hppa1\.1=geometry-hppa1.1
geometry/hppa2\.0=geometry-hppa2.0
geometry/i.86-.*-gnulibc=geometry-i86-gnulibc
horology/hppa=horology-no-DST-before-1970 horology/hppa=horology-no-DST-before-1970

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.5 2000/01/09 07:53:58 tgl Exp $ # $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.6 2000/01/09 20:54:36 tgl Exp $
# ---------- # ----------
# Check call syntax # Check call syntax
@ -79,16 +79,23 @@ PGDATESTYLE="Postgres,US"; export PGDATESTYLE
FRONTEND="$BINDIR/psql $HOSTLOC -n -e -q" FRONTEND="$BINDIR/psql $HOSTLOC -n -e -q"
# ---------- # ----------
# Prepare temp file holding combined test script. # Scan resultmap file to find which platform-specific expected files to use.
# The format of each line of the file is
# testname/hostnamepattern=substitutefile
# where the hostnamepattern is evaluated per the rules of expr(1) --- namely,
# it is a standard regular expression with an implicit ^ at the start.
# ---------- # ----------
TESTLIST="/tmp/testlist.$$" SUBSTLIST=""
TESTS=./sql/run_check.tests exec 4<resultmap
( while read LINE <&4
cat $TESTS do
for name in $extratests ; do HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
echo "test $name" if [ `expr "$hostname" : "$HOSTPAT"` -ne 0 ]
done then
) > $TESTLIST SUBSTLIST="$SUBSTLIST $LINE"
fi
done
exec 4<&-
# ---------- # ----------
# Catch SIGINT and SIGTERM to shutdown the postmaster # Catch SIGINT and SIGTERM to shutdown the postmaster
@ -104,7 +111,6 @@ trap ' echo ""
echo "" echo ""
fi fi
echo "" echo ""
rm $TESTLIST
exit 1 exit 1
' 2 15 ' 2 15
@ -221,15 +227,21 @@ fi
# ---------- # ----------
# Run the regression tests specified in the $TESTLIST file # Run the regression tests specified in the ./sql/run_check.tests file
# ---------- # ----------
echo "=============== Running regression queries... ================" echo "=============== Running regression queries... ================"
echo "" > regression.diffs echo "" > regression.diffs
echo "" > regress.out echo "" > regress.out
TESTS=./sql/run_check.tests
lno=0 lno=0
while read line (
do cat $TESTS
for name in $extratests ; do
echo "test $name"
done
) | while read line ; do
# ---------- # ----------
# Count line numbers and skip comments and empty lines # Count line numbers and skip comments and empty lines
# ---------- # ----------
@ -256,8 +268,7 @@ do
pargroup=$name pargroup=$name
parntests=0 parntests=0
parpar=0 parpar=0
while read line while read line ; do
do
# ---------- # ----------
# Again count line numbers and skip comments # Again count line numbers and skip comments
# ---------- # ----------
@ -334,14 +345,14 @@ do
> results/${name}.out 2>&1 > results/${name}.out 2>&1
$ECHO_N " $name" $ECHO_C $ECHO_N " $name" $ECHO_C
) & ) &
done </dev/null done
wait wait
echo "" echo ""
# ---------- # ----------
# Setup status information for the diff check below # Setup status information for the diff check below
# ---------- # ----------
checklist=$parlist checklist="$parlist"
checkpname=1 checkpname=1
;; ;;
@ -357,7 +368,7 @@ do
# ---------- # ----------
# Setup status information for the diff check below # Setup status information for the diff check below
# ---------- # ----------
checklist=$name checklist="$name"
checkpname=0 checkpname=0
;; ;;
@ -379,55 +390,43 @@ do
# old format, so checkresults will still find the proper # old format, so checkresults will still find the proper
# information. # information.
# ---------- # ----------
for tst in $checklist ; do for name in $checklist ; do
if [ $checkpname -ne 0 ] if [ $checkpname -ne 0 ]
then then
pnam=`echo $tst | awk '{printf "%-20.20s", $1;}'` pnam=`echo $name | awk '{printf "%-20.20s", $1;}'`
$ECHO_N " test $pnam ... " $ECHO_C $ECHO_N " test $pnam ... " $ECHO_C
fi fi
# #
# Check resultmap to see if we should compare to a # Check list extracted from resultmap to see if we should compare
# system-specific result file. The format of the file is # to a system-specific expected file.
# testname/hostname=substitutefile
# There shouldn't be multiple matches, but take the last if there are. # There shouldn't be multiple matches, but take the last if there are.
# #
EXPECTED="expected/${tst}.out" EXPECTED="expected/${name}.out"
SUBST=`grep "^$tst/$hostname=" resultmap | sed 's/^.*=//' | tail -1` for LINE in $SUBSTLIST
if test "$SUBST" do
then EXPECTED="expected/${SUBST}.out" if [ `expr "$LINE" : "$name/"` -ne 0 ]
else then
# Next look for a .similar entry that is a prefix of $hostname. SUBST=`echo "$LINE" | sed 's/^.*=//'`
# If there are multiple matches, take the last one. EXPECTED="expected/${SUBST}.out"
while read LINE
do
SIMHOST=`expr "$LINE" : '\(.*\)='`
MATCH=`expr "$tst/$hostname" : "$SIMHOST"`
echo "$LINE $SIMHOST $MATCH"
if test "$MATCH" != 0
then SUBST=`echo "$LINE" | sed 's/^.*=//'`
fi fi
done <resultmap done
if test "$SUBST"
then EXPECTED="expected/${SUBST}.out"
fi
fi
if [ `diff -w ${EXPECTED} results/${tst}.out | wc -l` -ne 0 ] if [ `diff -w ${EXPECTED} results/${name}.out | wc -l` -ne 0 ]
then then
( diff -wC3 ${EXPECTED} results/${tst}.out ; \ ( diff -wC3 ${EXPECTED} results/${name}.out ; \
echo "" ; \ echo "" ; \
echo "----------------------" ; \ echo "----------------------" ; \
echo "" ; \ echo "" ; \
) >> regression.diffs ) >> regression.diffs
echo "FAILED" echo "FAILED"
echo "$tst .. failed" >> regress.out echo "$name .. failed" >> regress.out
else else
echo "ok" echo "ok"
echo "$tst .. ok" >> regress.out echo "$name .. ok" >> regress.out
fi fi
done done
done <$TESTLIST | tee run_check.out 2>&1 done | tee run_check.out 2>&1
# ---------- # ----------
# Finally kill the postmaster we started # Finally kill the postmaster we started
@ -435,6 +434,5 @@ done <$TESTLIST | tee run_check.out 2>&1
echo "=============== Terminating regression postmaster ================" echo "=============== Terminating regression postmaster ================"
kill -15 $PMPID kill -15 $PMPID
rm $TESTLIST
exit 0 exit 0