timescaledb/test/sql/histogram_test.sql
Erik Nordström 500563ffe5 Add support for PostgreSQL 10
The extension now works with PostgreSQL 10, while
retaining compatibility with version 9.6.

PostgreSQL 10 has numerous internal changes to functions and
APIs, which necessitates various glue code and compatibility
wrappers to seamlessly retain backwards compatiblity with older
versions.

Test output might also differ between versions. In particular,
the psql client generates version-specific output with `\d` and
EXPLAINs might differ due to new query optimizations. The test
suite has been modified as follows to handle these issues. First,
tests now use version-independent functions to query system
catalogs instead of using `\d`. Second, changes have been made to
the test suite to be able to verify some test outputs against
version-dependent reference files.
2017-11-10 09:44:20 +01:00

45 lines
1.5 KiB
SQL

-- table 1
CREATE TABLE "hitest1"(key real, val varchar(40));
-- insertions
INSERT INTO "hitest1" VALUES(0, 'hi');
INSERT INTO "hitest1" VALUES(1, 'sup');
INSERT INTO "hitest1" VALUES(2, 'hello');
INSERT INTO "hitest1" VALUES(3, 'yo');
INSERT INTO "hitest1" VALUES(4, 'howdy');
INSERT INTO "hitest1" VALUES(5, 'hola');
INSERT INTO "hitest1" VALUES(6, 'ya');
INSERT INTO "hitest1" VALUES(1, 'sup');
INSERT INTO "hitest1" VALUES(2, 'hello');
INSERT INTO "hitest1" VALUES(1, 'sup');
-- table 2
CREATE TABLE "hitest2"(name varchar(30), score integer, qualify boolean);
-- insertions
INSERT INTO "hitest2" VALUES('Tom', 6, TRUE);
INSERT INTO "hitest2" VALUES('Mary', 4, FALSE);
INSERT INTO "hitest2" VALUES('Jaq', 3, FALSE);
INSERT INTO "hitest2" VALUES('Jane', 10, TRUE);
-- standard 2 bucket
SELECT histogram(key, 0, 9, 2) FROM hitest1;
-- standard multi-bucket
SELECT histogram(key, 0, 9, 5) FROM hitest1;
-- standard 3 bucket
SELECT val, histogram(key, 0, 7, 3) FROM hitest1 GROUP BY val ORDER BY val;
-- standard element beneath lb
SELECT histogram(key, 1, 7, 3) FROM hitest1;
-- standard element above ub
SELECT histogram(key, 0, 3, 3) FROM hitest1;
-- standard element beneath and above lb and ub, respectively
SELECT histogram(key, 1, 3, 2) FROM hitest1;
-- standard 1 bucket
SELECT histogram(key, 1, 3, 1) FROM hitest1;
-- standard 2 bucket
SELECT qualify, histogram(score, 0, 10, 2) FROM hitest2 GROUP BY qualify;
-- standard multi-bucket
SELECT qualify, histogram(score, 0, 10, 5) FROM hitest2 GROUP BY qualify