diff --git a/.gitignore b/.gitignore index 0110226..df40661 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ *.o *.so /results/ -/*--*.sql diff --git a/Makefile b/Makefile index e8cffe6..855dc8e 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,10 @@ PG_CONFIG = pg_config PKG_CONFIG = pkg-config -extension_version = 1 - EXTENSION = uri MODULE_big = uri OBJS = uri.o -DATA = uri--0--1.sql -DATA_built = uri--$(extension_version).sql +DATA = uri--0.sql uri--1.sql uri--0--1.sql ifeq (no,$(shell $(PKG_CONFIG) liburiparser || echo no)) $(warning liburiparser not registed with pkg-config, build might fail) @@ -21,6 +18,3 @@ REGRESS_OPTS = --inputdir=test PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS) - -uri--$(extension_version).sql: uri.sql - cat $^ >$@ diff --git a/uri--0.sql b/uri--0.sql new file mode 100644 index 0000000..edf5261 --- /dev/null +++ b/uri--0.sql @@ -0,0 +1,202 @@ +SET client_min_messages = warning; + + +CREATE TYPE uri; + +CREATE FUNCTION uri_in(cstring) RETURNS uri + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_out(uri) RETURNS cstring + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE TYPE uri ( + INTERNALLENGTH = -1, + INPUT = uri_in, + OUTPUT = uri_out +); + + +CREATE CAST (uri AS text) WITH INOUT AS ASSIGNMENT; +CREATE CAST (text AS uri) WITH INOUT AS ASSIGNMENT; + + +CREATE FUNCTION uri_scheme(uri) RETURNS text + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_userinfo(uri) RETURNS text + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_host(uri) RETURNS text + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_host_inet(uri) RETURNS inet + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_port(uri) RETURNS integer + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_query(uri) RETURNS text + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_fragment(uri) RETURNS text + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_path(uri) RETURNS text + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_path_array(uri) RETURNS text[] + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + + +CREATE FUNCTION uri_normalize(uri) RETURNS uri + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + + +CREATE FUNCTION uri_lt(uri, uri) RETURNS boolean + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_le(uri, uri) RETURNS boolean + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_eq(uri, uri) RETURNS boolean + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_ne(uri, uri) RETURNS boolean + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_ge(uri, uri) RETURNS boolean + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_gt(uri, uri) RETURNS boolean + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE FUNCTION uri_cmp(uri, uri) RETURNS integer + IMMUTABLE + STRICT + LANGUAGE C + AS '$libdir/uri'; + +CREATE OPERATOR < ( + LEFTARG = uri, + RIGHTARG = uri, + COMMUTATOR = >, + NEGATOR = >=, + RESTRICT = scalarltsel, + JOIN = scalarltjoinsel, + PROCEDURE = uri_lt +); + +CREATE OPERATOR <= ( + LEFTARG = uri, + RIGHTARG = uri, + COMMUTATOR = >=, + NEGATOR = >, + RESTRICT = scalarltsel, + JOIN = scalarltjoinsel, + PROCEDURE = uri_le +); + +CREATE OPERATOR = ( + LEFTARG = uri, + RIGHTARG = uri, + COMMUTATOR = =, + NEGATOR = <>, + RESTRICT = eqsel, + JOIN = eqjoinsel, + HASHES, + MERGES, + PROCEDURE = uri_eq +); + +CREATE OPERATOR <> ( + LEFTARG = uri, + RIGHTARG = uri, + COMMUTATOR = <>, + NEGATOR = =, + RESTRICT = neqsel, + JOIN = neqjoinsel, + PROCEDURE = uri_ne +); + +CREATE OPERATOR >= ( + LEFTARG = uri, + RIGHTARG = uri, + COMMUTATOR = <=, + NEGATOR = <, + RESTRICT = scalargtsel, + JOIN = scalargtjoinsel, + PROCEDURE = uri_ge +); + +CREATE OPERATOR > ( + LEFTARG = uri, + RIGHTARG = uri, + COMMUTATOR = <, + NEGATOR = <=, + RESTRICT = scalargtsel, + JOIN = scalargtjoinsel, + PROCEDURE = uri_gt +); + +CREATE OPERATOR CLASS uri_ops + DEFAULT FOR TYPE uri USING btree AS + OPERATOR 1 < , + OPERATOR 2 <= , + OPERATOR 3 = , + OPERATOR 4 >= , + OPERATOR 5 > , + FUNCTION 1 uri_cmp(uri, uri); diff --git a/uri.sql b/uri--1.sql similarity index 100% rename from uri.sql rename to uri--1.sql