Skip to content

Commit

Permalink
add the basic test cases for "make installcheck"
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaowing committed Mar 1, 2018
1 parent 15c53ef commit 4dbc3bb
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
Expand Down
44 changes: 44 additions & 0 deletions expected/douban_fdw.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
CREATE EXTENSION douban_fdw;
CREATE SERVER doubansv FOREIGN DATA WRAPPER douban_fdw;
CREATE FOREIGN TABLE top250(rating REAL, title TEXT, genres VARCHAR(64), casts VARCHAR(256), collectcount INTEGER, originname TEXT, directors VARCHAR(256), year VARCHAR(32)) SERVER doubansv OPTIONS(rank_name 'top250');
SELECT count(1) FROM top250;
count
-------
250
(1 row)

SELECT rating, title, CAST(year AS INT) FROM top250 WHERE rating > 9.2 ORDER BY title DESC;
rating | title | year
--------+----------------+------
9.5 | 霸王别姬 | 1993
9.4 | 阿甘正传 | 1994
9.4 | 这个杀手不太冷 | 1994
9.4 | 辛德勒的名单 | 1993
9.6 | 肖申克的救赎 | 1994
9.5 | 美丽人生 | 1997
9.3 | 盗梦空间 | 2010
9.3 | 海豚湾 | 2009
9.3 | 机器人总动员 | 2008
9.6 | 控方证人 | 1957
9.4 | 十二怒汉 | 1957
(11 rows)

SELECT rating, title, CAST(year AS INT) FROM top250 WHERE CAST(year AS INT) = 1994 ORDER BY title;
rating | title | year
--------+----------------+------
8.6 | 东邪西毒 | 1994
8.8 | 低俗小说 | 1994
9.1 | 活着 | 1994
8.7 | 燃情岁月 | 1994
8.9 | 狮子王 | 1994
9.6 | 肖申克的救赎 | 1994
9.4 | 这个杀手不太冷 | 1994
8.7 | 重庆森林 | 1994
8.8 | 阳光灿烂的日子 | 1994
9.4 | 阿甘正传 | 1994
9.1 | 饮食男女 | 1994
(11 rows)

DROP FOREIGN TABLE top250;
DROP SERVER doubansv;
DROP EXTENSION douban_fdw CASCADE;
13 changes: 13 additions & 0 deletions sql/douban_fdw.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE EXTENSION douban_fdw;
CREATE SERVER doubansv FOREIGN DATA WRAPPER douban_fdw;
CREATE FOREIGN TABLE top250(rating REAL, title TEXT, genres VARCHAR(64), casts VARCHAR(256), collectcount INTEGER, originname TEXT, directors VARCHAR(256), year VARCHAR(32)) SERVER doubansv OPTIONS(rank_name 'top250');

SELECT count(1) FROM top250;

SELECT rating, title, CAST(year AS INT) FROM top250 WHERE rating > 9.2 ORDER BY title DESC;

SELECT rating, title, CAST(year AS INT) FROM top250 WHERE CAST(year AS INT) = 1994 ORDER BY title;

DROP FOREIGN TABLE top250;
DROP SERVER doubansv;
DROP EXTENSION douban_fdw CASCADE;

0 comments on commit 4dbc3bb

Please sign in to comment.