pguri/test/sql/test.sql

64 lines
1.8 KiB
MySQL
Raw Normal View History

2015-02-18 04:23:18 +00:00
\pset null _null_
SET client_min_messages = warning;
2015-02-18 04:23:18 +00:00
CREATE TABLE test (a serial, b uri);
INSERT INTO test (b)
VALUES ('http://www.postgresql.org/'),
('http://www.postgresql.org/docs/devel/static/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS'),
('http://www.postgresql.org:591/'),
('http://www.postgresql.org:80/'),
2015-02-18 04:23:18 +00:00
('https://duckduckgo.com/?q=postgresql&ia=about'),
('ftp://ftp.gnu.org/gnu/bison'),
('mailto:foo@example.com'),
('ssh://username@review.openstack.org:29418/openstack/nova.git'),
('ssh://foobar@review.openstack.org:29418/openstack/nova.git'),
('ssh://review.openstack.org:29418/openstack/nova.git'),
2015-02-18 04:23:18 +00:00
('http://admin:password@192.168.0.1'),
('http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html'),
('http://[1080::8:800:200C:417A]/foo'),
('http://host:'),
2015-02-18 04:23:18 +00:00
(''),
2015-04-04 02:49:52 +00:00
('/'),
('foobar'),
('/foobar');
2015-02-18 04:23:18 +00:00
2015-04-12 20:01:03 +00:00
-- normalization test values from <https://tools.ietf.org/html/rfc3986#section-6.2.2>
INSERT INTO test (b)
VALUES ('HTTP://www.EXAMPLE.com/'),
('http://www.ex%41mple.com/'),
('eXAMPLE://a/./b/../b/%63/%7bfoo%7d');
2015-02-18 04:23:18 +00:00
SELECT * FROM test;
-- error cases
SELECT uri 'http://host:port/';
2015-02-18 04:23:18 +00:00
\x on
SELECT b AS uri,
2015-04-12 20:01:03 +00:00
uri_normalize(b),
2015-02-18 04:23:18 +00:00
uri_scheme(b),
uri_userinfo(b),
uri_host(b),
uri_host_inet(b),
uri_port(b),
uri_path(b),
2015-04-04 02:49:52 +00:00
uri_path_array(b),
2015-02-18 04:23:18 +00:00
uri_query(b),
uri_fragment(b)
FROM test;
\x off
SELECT DISTINCT b FROM test ORDER BY b;
CREATE TABLE test2 (x text, y uri);
INSERT INTO test2 VALUES ('foo', 'http://www.postgresql.org/');
-- check hashing (issue petere/pguri#3)
SET enable_nestloop = off;
SET enable_mergejoin = off;
SELECT * FROM test JOIN test2 ON b = y AND a = 1;