diff --git a/contrib/adminpack/.gitignore b/contrib/adminpack/.gitignore
deleted file mode 100644
index ea9a442f3a157824d42584679b3d22b051609b4a..0000000000000000000000000000000000000000
--- a/contrib/adminpack/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/adminpack.sql
diff --git a/contrib/adminpack/Makefile b/contrib/adminpack/Makefile
index d4413ad1331928954862e674587d8da71e3bbdf7..a127653d705d360ec78b1bd318309f886ff0bda8 100644
--- a/contrib/adminpack/Makefile
+++ b/contrib/adminpack/Makefile
@@ -1,10 +1,11 @@
 # contrib/adminpack/Makefile
 
 MODULE_big = adminpack
-PG_CPPFLAGS = -I$(libpq_srcdir)
-DATA_built = adminpack.sql
-DATA = uninstall_adminpack.sql
 OBJS = adminpack.o
+PG_CPPFLAGS = -I$(libpq_srcdir)
+
+EXTENSION = adminpack
+DATA = adminpack--1.0.sql adminpack--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/adminpack/adminpack.sql.in b/contrib/adminpack/adminpack--1.0.sql
similarity index 97%
rename from contrib/adminpack/adminpack.sql.in
rename to contrib/adminpack/adminpack--1.0.sql
index 6e389975d0877a4b056360cfe18d74f31c9c583b..0502a4c01f3fd6de6ca0ba6daea6f7e14e5d44f1 100644
--- a/contrib/adminpack/adminpack.sql.in
+++ b/contrib/adminpack/adminpack--1.0.sql
@@ -1,4 +1,4 @@
-/* contrib/adminpack/adminpack.sql.in */
+/* contrib/adminpack/adminpack--1.0.sql */
 
 /* ***********************************************
  * Administrative functions for PostgreSQL
diff --git a/contrib/adminpack/adminpack--unpackaged--1.0.sql b/contrib/adminpack/adminpack--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..d1c6aade9c9696425e940f1c329180fdddabfbb6
--- /dev/null
+++ b/contrib/adminpack/adminpack--unpackaged--1.0.sql
@@ -0,0 +1,10 @@
+/* contrib/adminpack/adminpack--unpackaged--1.0.sql */
+
+ALTER EXTENSION adminpack ADD function pg_catalog.pg_file_write(text,text,boolean);
+ALTER EXTENSION adminpack ADD function pg_catalog.pg_file_rename(text,text,text);
+ALTER EXTENSION adminpack ADD function pg_catalog.pg_file_rename(text,text);
+ALTER EXTENSION adminpack ADD function pg_catalog.pg_file_unlink(text);
+ALTER EXTENSION adminpack ADD function pg_catalog.pg_logdir_ls();
+ALTER EXTENSION adminpack ADD function pg_catalog.pg_file_read(text,bigint,bigint);
+ALTER EXTENSION adminpack ADD function pg_catalog.pg_file_length(text);
+ALTER EXTENSION adminpack ADD function pg_catalog.pg_logfile_rotate();
diff --git a/contrib/adminpack/adminpack.control b/contrib/adminpack/adminpack.control
new file mode 100644
index 0000000000000000000000000000000000000000..c79413f378c98d844d51c9b736e158b85e3ddc9b
--- /dev/null
+++ b/contrib/adminpack/adminpack.control
@@ -0,0 +1,6 @@
+# adminpack extension
+comment = 'administrative functions for PostgreSQL'
+default_version = '1.0'
+module_pathname = '$libdir/adminpack'
+relocatable = false
+schema = pg_catalog
diff --git a/contrib/adminpack/uninstall_adminpack.sql b/contrib/adminpack/uninstall_adminpack.sql
deleted file mode 100644
index 682cf677607a1e7657c5ebf6ce73e82700c681be..0000000000000000000000000000000000000000
--- a/contrib/adminpack/uninstall_adminpack.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-/* contrib/adminpack/uninstall_adminpack.sql */
-
-DROP FUNCTION pg_catalog.pg_file_write(text, text, bool) ;
-DROP FUNCTION pg_catalog.pg_file_rename(text, text, text) ;
-DROP FUNCTION pg_catalog.pg_file_rename(text, text) ;
-DROP FUNCTION pg_catalog.pg_file_unlink(text) ;
-DROP FUNCTION pg_catalog.pg_logdir_ls() ;
-DROP FUNCTION pg_catalog.pg_file_read(text, bigint, bigint) ;
-DROP FUNCTION pg_catalog.pg_file_length(text) ;
-DROP FUNCTION pg_catalog.pg_logfile_rotate() ;
diff --git a/contrib/btree_gin/.gitignore b/contrib/btree_gin/.gitignore
index 7cebcf00f84412e7cfd27ff3204957ef0ec6975e..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/btree_gin/.gitignore
+++ b/contrib/btree_gin/.gitignore
@@ -1,3 +1,2 @@
-/btree_gin.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/btree_gin/Makefile b/contrib/btree_gin/Makefile
index 8bc53f72daa054b423f8373b57a6f315e7967a8f..09fd3e6e11da127825cd4d913f5a75151b91e4d2 100644
--- a/contrib/btree_gin/Makefile
+++ b/contrib/btree_gin/Makefile
@@ -3,8 +3,9 @@
 MODULE_big = btree_gin
 OBJS = btree_gin.o
 
-DATA_built = btree_gin.sql
-DATA = uninstall_btree_gin.sql
+EXTENSION = btree_gin
+DATA = btree_gin--1.0.sql btree_gin--unpackaged--1.0.sql
+
 REGRESS = install_btree_gin int2 int4 int8 float4 float8 money oid \
 	timestamp timestamptz time timetz date interval \
 	macaddr inet cidr text varchar char bytea bit varbit \
diff --git a/contrib/btree_gin/btree_gin.sql.in b/contrib/btree_gin/btree_gin--1.0.sql
similarity index 99%
rename from contrib/btree_gin/btree_gin.sql.in
rename to contrib/btree_gin/btree_gin--1.0.sql
index 19cc0b3df4f5a23f3b4f3b2eb918fe9c015bd1f7..08bbff721fbe38c9bafdfd314947bbdcd4c8fa05 100644
--- a/contrib/btree_gin/btree_gin.sql.in
+++ b/contrib/btree_gin/btree_gin--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/btree_gin/btree_gin.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/btree_gin/btree_gin--1.0.sql */
 
 CREATE OR REPLACE FUNCTION gin_btree_consistent(internal, int2, anyelement, int4, internal, internal)
 RETURNS bool
diff --git a/contrib/btree_gin/btree_gin--unpackaged--1.0.sql b/contrib/btree_gin/btree_gin--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..fe1ddeab878ab97ce5fa49ee5e90bd6c367cb8a4
--- /dev/null
+++ b/contrib/btree_gin/btree_gin--unpackaged--1.0.sql
@@ -0,0 +1,116 @@
+/* contrib/btree_gin/btree_gin--unpackaged--1.0.sql */
+
+ALTER EXTENSION btree_gin ADD function gin_btree_consistent(internal,smallint,anyelement,integer,internal,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_value_int2(smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_int2(smallint,smallint,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_int2(smallint,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family int2_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class int2_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_int4(integer,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_int4(integer,integer,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_int4(integer,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family int4_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class int4_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_int8(bigint,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_int8(bigint,bigint,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_int8(bigint,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family int8_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class int8_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_float4(real,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_float4(real,real,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_float4(real,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family float4_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class float4_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_float8(double precision,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_float8(double precision,double precision,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_float8(double precision,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family float8_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class float8_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_money(money,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_money(money,money,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_money(money,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family money_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class money_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_oid(oid,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_oid(oid,oid,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_oid(oid,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family oid_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class oid_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_timestamp(timestamp without time zone,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_timestamp(timestamp without time zone,timestamp without time zone,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_timestamp(timestamp without time zone,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family timestamp_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class timestamp_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_timestamptz(timestamp with time zone,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_timestamptz(timestamp with time zone,timestamp with time zone,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_timestamptz(timestamp with time zone,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family timestamptz_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class timestamptz_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_time(time without time zone,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_time(time without time zone,time without time zone,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_time(time without time zone,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family time_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class time_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_timetz(time with time zone,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_timetz(time with time zone,time with time zone,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_timetz(time with time zone,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family timetz_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class timetz_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_date(date,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_date(date,date,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_date(date,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family date_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class date_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_interval(interval,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_interval(interval,interval,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_interval(interval,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family interval_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class interval_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_macaddr(macaddr,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_macaddr(macaddr,macaddr,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_macaddr(macaddr,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family macaddr_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class macaddr_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_inet(inet,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_inet(inet,inet,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_inet(inet,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family inet_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class inet_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_cidr(cidr,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_cidr(cidr,cidr,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_cidr(cidr,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family cidr_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class cidr_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_text(text,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_text(text,text,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_text(text,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family text_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class text_ops using gin;
+ALTER EXTENSION btree_gin ADD operator family varchar_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class varchar_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_char("char",internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_char("char","char",smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_char("char",internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family char_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class char_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_bytea(bytea,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_bytea(bytea,bytea,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_bytea(bytea,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family bytea_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class bytea_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_bit(bit,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_bit(bit,bit,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_bit(bit,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family bit_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class bit_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_varbit(bit varying,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_varbit(bit varying,bit varying,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_varbit(bit varying,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD operator family varbit_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class varbit_ops using gin;
+ALTER EXTENSION btree_gin ADD function gin_extract_value_numeric(numeric,internal);
+ALTER EXTENSION btree_gin ADD function gin_compare_prefix_numeric(numeric,numeric,smallint,internal);
+ALTER EXTENSION btree_gin ADD function gin_extract_query_numeric(numeric,internal,smallint,internal,internal);
+ALTER EXTENSION btree_gin ADD function gin_numeric_cmp(numeric,numeric);
+ALTER EXTENSION btree_gin ADD operator family numeric_ops using gin;
+ALTER EXTENSION btree_gin ADD operator class numeric_ops using gin;
diff --git a/contrib/btree_gin/btree_gin.control b/contrib/btree_gin/btree_gin.control
new file mode 100644
index 0000000000000000000000000000000000000000..3b2cb2d709d0adbaac4c0c604d8ba178c02fde3f
--- /dev/null
+++ b/contrib/btree_gin/btree_gin.control
@@ -0,0 +1,5 @@
+# btree_gin extension
+comment = 'support for indexing common datatypes in GIN'
+default_version = '1.0'
+module_pathname = '$libdir/btree_gin'
+relocatable = true
diff --git a/contrib/btree_gin/expected/install_btree_gin.out b/contrib/btree_gin/expected/install_btree_gin.out
index 43f11fa263c814eb6ac094671174693cca64fba4..0fae4c5bfe0b4e61237834a47cfff750c8ffa72b 100644
--- a/contrib/btree_gin/expected/install_btree_gin.out
+++ b/contrib/btree_gin/expected/install_btree_gin.out
@@ -1,3 +1 @@
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION btree_gin;
diff --git a/contrib/btree_gin/sql/install_btree_gin.sql b/contrib/btree_gin/sql/install_btree_gin.sql
index f54c8b4a0f38aa5be4ce61b98abc6a5f085d3b3b..0fae4c5bfe0b4e61237834a47cfff750c8ffa72b 100644
--- a/contrib/btree_gin/sql/install_btree_gin.sql
+++ b/contrib/btree_gin/sql/install_btree_gin.sql
@@ -1,5 +1 @@
-SET client_min_messages = warning;
-\set ECHO none
-\i btree_gin.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION btree_gin;
diff --git a/contrib/btree_gin/uninstall_btree_gin.sql b/contrib/btree_gin/uninstall_btree_gin.sql
deleted file mode 100644
index 30324dc709dd07058b28daf639d457dd2ec5bdbe..0000000000000000000000000000000000000000
--- a/contrib/btree_gin/uninstall_btree_gin.sql
+++ /dev/null
@@ -1,98 +0,0 @@
-/* contrib/btree_gin/uninstall_btree_gin.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR FAMILY int2_ops USING gin CASCADE;
-DROP OPERATOR FAMILY int4_ops USING gin CASCADE;
-DROP OPERATOR FAMILY int8_ops USING gin CASCADE;
-DROP OPERATOR FAMILY float4_ops USING gin CASCADE;
-DROP OPERATOR FAMILY float8_ops USING gin CASCADE;
-DROP OPERATOR FAMILY money_ops USING gin CASCADE;
-DROP OPERATOR FAMILY oid_ops USING gin CASCADE;
-DROP OPERATOR FAMILY timestamp_ops USING gin CASCADE;
-DROP OPERATOR FAMILY timestamptz_ops USING gin CASCADE;
-DROP OPERATOR FAMILY time_ops USING gin CASCADE;
-DROP OPERATOR FAMILY timetz_ops USING gin CASCADE;
-DROP OPERATOR FAMILY date_ops USING gin CASCADE;
-DROP OPERATOR FAMILY interval_ops USING gin CASCADE;
-DROP OPERATOR FAMILY macaddr_ops USING gin CASCADE;
-DROP OPERATOR FAMILY inet_ops USING gin CASCADE;
-DROP OPERATOR FAMILY cidr_ops USING gin CASCADE;
-DROP OPERATOR FAMILY text_ops USING gin CASCADE;
-DROP OPERATOR FAMILY varchar_ops USING gin CASCADE;
-DROP OPERATOR FAMILY char_ops USING gin CASCADE;
-DROP OPERATOR FAMILY bytea_ops USING gin CASCADE;
-DROP OPERATOR FAMILY bit_ops USING gin CASCADE;
-DROP OPERATOR FAMILY varbit_ops USING gin CASCADE;
-DROP OPERATOR FAMILY numeric_ops USING gin CASCADE;
-
-DROP FUNCTION gin_btree_consistent(internal, int2, anyelement, int4, internal, internal);
-
-DROP FUNCTION gin_extract_value_int2(int2, internal);
-DROP FUNCTION gin_compare_prefix_int2(int2, int2, int2, internal);
-DROP FUNCTION gin_extract_query_int2(int2, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_int4(int4, internal);
-DROP FUNCTION gin_compare_prefix_int4(int4, int4, int2, internal);
-DROP FUNCTION gin_extract_query_int4(int4, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_int8(int8, internal);
-DROP FUNCTION gin_compare_prefix_int8(int8, int8, int2, internal);
-DROP FUNCTION gin_extract_query_int8(int8, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_float4(float4, internal);
-DROP FUNCTION gin_compare_prefix_float4(float4, float4, int2, internal);
-DROP FUNCTION gin_extract_query_float4(float4, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_float8(float8, internal);
-DROP FUNCTION gin_compare_prefix_float8(float8, float8, int2, internal);
-DROP FUNCTION gin_extract_query_float8(float8, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_money(money, internal);
-DROP FUNCTION gin_compare_prefix_money(money, money, int2, internal);
-DROP FUNCTION gin_extract_query_money(money, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_oid(oid, internal);
-DROP FUNCTION gin_compare_prefix_oid(oid, oid, int2, internal);
-DROP FUNCTION gin_extract_query_oid(oid, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_timestamp(timestamp, internal);
-DROP FUNCTION gin_compare_prefix_timestamp(timestamp, timestamp, int2, internal);
-DROP FUNCTION gin_extract_query_timestamp(timestamp, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_timestamptz(timestamptz, internal);
-DROP FUNCTION gin_compare_prefix_timestamptz(timestamptz, timestamptz, int2, internal);
-DROP FUNCTION gin_extract_query_timestamptz(timestamptz, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_time(time, internal);
-DROP FUNCTION gin_compare_prefix_time(time, time, int2, internal);
-DROP FUNCTION gin_extract_query_time(time, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_timetz(timetz, internal);
-DROP FUNCTION gin_compare_prefix_timetz(timetz, timetz, int2, internal);
-DROP FUNCTION gin_extract_query_timetz(timetz, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_date(date, internal);
-DROP FUNCTION gin_compare_prefix_date(date, date, int2, internal);
-DROP FUNCTION gin_extract_query_date(date, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_interval(interval, internal);
-DROP FUNCTION gin_compare_prefix_interval(interval, interval, int2, internal);
-DROP FUNCTION gin_extract_query_interval(interval, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_macaddr(macaddr, internal);
-DROP FUNCTION gin_compare_prefix_macaddr(macaddr, macaddr, int2, internal);
-DROP FUNCTION gin_extract_query_macaddr(macaddr, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_inet(inet, internal);
-DROP FUNCTION gin_compare_prefix_inet(inet, inet, int2, internal);
-DROP FUNCTION gin_extract_query_inet(inet, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_cidr(cidr, internal);
-DROP FUNCTION gin_compare_prefix_cidr(cidr, cidr, int2, internal);
-DROP FUNCTION gin_extract_query_cidr(cidr, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_text(text, internal);
-DROP FUNCTION gin_compare_prefix_text(text, text, int2, internal);
-DROP FUNCTION gin_extract_query_text(text, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_char("char", internal);
-DROP FUNCTION gin_compare_prefix_char("char", "char", int2, internal);
-DROP FUNCTION gin_extract_query_char("char", internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_bytea(bytea, internal);
-DROP FUNCTION gin_compare_prefix_bytea(bytea, bytea, int2, internal);
-DROP FUNCTION gin_extract_query_bytea(bytea, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_bit(bit, internal);
-DROP FUNCTION gin_compare_prefix_bit(bit, bit, int2, internal);
-DROP FUNCTION gin_extract_query_bit(bit, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_varbit(varbit, internal);
-DROP FUNCTION gin_compare_prefix_varbit(varbit, varbit, int2, internal);
-DROP FUNCTION gin_extract_query_varbit(varbit, internal, int2, internal, internal);
-DROP FUNCTION gin_extract_value_numeric(numeric, internal);
-DROP FUNCTION gin_compare_prefix_numeric(numeric, numeric, int2, internal);
-DROP FUNCTION gin_extract_query_numeric(numeric, internal, int2, internal, internal);
-DROP FUNCTION gin_numeric_cmp(numeric, numeric);
diff --git a/contrib/btree_gist/.gitignore b/contrib/btree_gist/.gitignore
index 46318eaa7b0655ad6476489906acae043d777070..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/btree_gist/.gitignore
+++ b/contrib/btree_gist/.gitignore
@@ -1,3 +1,2 @@
-/btree_gist.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/btree_gist/Makefile b/contrib/btree_gist/Makefile
index e152cd881dedfb5f3b033b8999d70ca836c52762..4b931de08ab5398509a6addc65d63b8f34f28156 100644
--- a/contrib/btree_gist/Makefile
+++ b/contrib/btree_gist/Makefile
@@ -7,8 +7,8 @@ OBJS        = btree_gist.o btree_utils_num.o btree_utils_var.o btree_int2.o btre
               btree_date.o btree_interval.o btree_macaddr.o btree_inet.o btree_text.o \
               btree_bytea.o btree_bit.o btree_numeric.o
 
-DATA_built  = btree_gist.sql
-DATA        = uninstall_btree_gist.sql
+EXTENSION = btree_gist
+DATA = btree_gist--1.0.sql btree_gist--unpackaged--1.0.sql
 
 REGRESS     = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz time timetz \
               date interval macaddr inet cidr text varchar char bytea bit varbit numeric not_equal
diff --git a/contrib/btree_gist/btree_gist.sql.in b/contrib/btree_gist/btree_gist--1.0.sql
similarity index 99%
rename from contrib/btree_gist/btree_gist.sql.in
rename to contrib/btree_gist/btree_gist--1.0.sql
index 01cd30f2defd046bbed982d0ce4072fcc44cdff8..ab6c8c3936e0d8e613fa1692d5c4a67694154965 100644
--- a/contrib/btree_gist/btree_gist.sql.in
+++ b/contrib/btree_gist/btree_gist--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/btree_gist/btree_gist.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/btree_gist/btree_gist--1.0.sql */
 
 CREATE OR REPLACE FUNCTION gbtreekey4_in(cstring)
 RETURNS gbtreekey4
diff --git a/contrib/btree_gist/btree_gist--unpackaged--1.0.sql b/contrib/btree_gist/btree_gist--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..18c14649919e6f1dc571c00d53dab2be58f79aa0
--- /dev/null
+++ b/contrib/btree_gist/btree_gist--unpackaged--1.0.sql
@@ -0,0 +1,172 @@
+/* contrib/btree_gist/btree_gist--unpackaged--1.0.sql */
+
+ALTER EXTENSION btree_gist ADD type gbtreekey4;
+ALTER EXTENSION btree_gist ADD function gbtreekey4_in(cstring);
+ALTER EXTENSION btree_gist ADD function gbtreekey4_out(gbtreekey4);
+ALTER EXTENSION btree_gist ADD type gbtreekey8;
+ALTER EXTENSION btree_gist ADD function gbtreekey8_in(cstring);
+ALTER EXTENSION btree_gist ADD function gbtreekey8_out(gbtreekey8);
+ALTER EXTENSION btree_gist ADD type gbtreekey16;
+ALTER EXTENSION btree_gist ADD function gbtreekey16_in(cstring);
+ALTER EXTENSION btree_gist ADD function gbtreekey16_out(gbtreekey16);
+ALTER EXTENSION btree_gist ADD type gbtreekey32;
+ALTER EXTENSION btree_gist ADD function gbtreekey32_in(cstring);
+ALTER EXTENSION btree_gist ADD function gbtreekey32_out(gbtreekey32);
+ALTER EXTENSION btree_gist ADD type gbtreekey_var;
+ALTER EXTENSION btree_gist ADD function gbtreekey_var_in(cstring);
+ALTER EXTENSION btree_gist ADD function gbtreekey_var_out(gbtreekey_var);
+ALTER EXTENSION btree_gist ADD function gbt_oid_consistent(internal,oid,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_oid_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_decompress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_var_decompress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_oid_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_oid_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_oid_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_oid_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_oid_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_oid_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_int2_consistent(internal,smallint,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int2_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_int2_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int2_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int2_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int2_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_int2_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_int2_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_int4_consistent(internal,integer,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int4_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_int4_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int4_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int4_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int4_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_int4_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_int4_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_int8_consistent(internal,bigint,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int8_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_int8_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int8_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int8_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_int8_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_int8_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_int8_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_float4_consistent(internal,real,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_float4_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_float4_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_float4_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_float4_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_float4_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_float4_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_float4_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_float8_consistent(internal,double precision,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_float8_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_float8_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_float8_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_float8_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_float8_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_float8_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_float8_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_ts_consistent(internal,timestamp without time zone,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_tstz_consistent(internal,timestamp with time zone,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_ts_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_tstz_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_ts_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_ts_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_ts_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_ts_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_timestamp_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_timestamp_ops using gist;
+ALTER EXTENSION btree_gist ADD operator family gist_timestamptz_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_timestamptz_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_time_consistent(internal,time without time zone,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_timetz_consistent(internal,time with time zone,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_time_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_timetz_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_time_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_time_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_time_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_time_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_time_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_time_ops using gist;
+ALTER EXTENSION btree_gist ADD operator family gist_timetz_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_timetz_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_date_consistent(internal,date,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_date_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_date_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_date_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_date_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_date_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_date_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_date_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_intv_consistent(internal,interval,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_intv_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_intv_decompress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_intv_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_intv_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_intv_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_intv_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_interval_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_interval_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_cash_consistent(internal,money,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_cash_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_cash_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_cash_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_cash_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_cash_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_cash_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_cash_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_macad_consistent(internal,macaddr,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_macad_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_macad_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_macad_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_macad_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_macad_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_macaddr_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_macaddr_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_text_consistent(internal,text,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bpchar_consistent(internal,character,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_text_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_bpchar_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_text_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_text_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_text_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_text_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_text_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_text_ops using gist;
+ALTER EXTENSION btree_gist ADD operator family gist_bpchar_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_bpchar_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_bytea_consistent(internal,bytea,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bytea_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_bytea_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bytea_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bytea_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bytea_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_bytea_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_bytea_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_numeric_consistent(internal,numeric,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_numeric_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_numeric_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_numeric_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_numeric_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_numeric_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_numeric_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_numeric_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_bit_consistent(internal,bit,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bit_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_bit_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bit_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bit_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_bit_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_bit_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_bit_ops using gist;
+ALTER EXTENSION btree_gist ADD operator family gist_vbit_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_vbit_ops using gist;
+ALTER EXTENSION btree_gist ADD function gbt_inet_consistent(internal,inet,smallint,oid,internal);
+ALTER EXTENSION btree_gist ADD function gbt_inet_compress(internal);
+ALTER EXTENSION btree_gist ADD function gbt_inet_penalty(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_inet_picksplit(internal,internal);
+ALTER EXTENSION btree_gist ADD function gbt_inet_union(bytea,internal);
+ALTER EXTENSION btree_gist ADD function gbt_inet_same(internal,internal,internal);
+ALTER EXTENSION btree_gist ADD operator family gist_inet_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_inet_ops using gist;
+ALTER EXTENSION btree_gist ADD operator family gist_cidr_ops using gist;
+ALTER EXTENSION btree_gist ADD operator class gist_cidr_ops using gist;
diff --git a/contrib/btree_gist/btree_gist.control b/contrib/btree_gist/btree_gist.control
new file mode 100644
index 0000000000000000000000000000000000000000..10e2f949c11f50723d0031c0f292448147fe5a68
--- /dev/null
+++ b/contrib/btree_gist/btree_gist.control
@@ -0,0 +1,5 @@
+# btree_gist extension
+comment = 'support for indexing common datatypes in GiST'
+default_version = '1.0'
+module_pathname = '$libdir/btree_gist'
+relocatable = true
diff --git a/contrib/btree_gist/expected/init.out b/contrib/btree_gist/expected/init.out
index c8082495456726b08c21d533bb600ec27c54ff4f..afe05346824f28ea6476824027da25b49d8c4f4b 100644
--- a/contrib/btree_gist/expected/init.out
+++ b/contrib/btree_gist/expected/init.out
@@ -1,7 +1 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of btree_gist.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION btree_gist;
diff --git a/contrib/btree_gist/sql/init.sql b/contrib/btree_gist/sql/init.sql
index 7fafde12d8b0a67dd00415546a2d07ed2a887fb4..afe05346824f28ea6476824027da25b49d8c4f4b 100644
--- a/contrib/btree_gist/sql/init.sql
+++ b/contrib/btree_gist/sql/init.sql
@@ -1,9 +1 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of btree_gist.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i btree_gist.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION btree_gist;
diff --git a/contrib/btree_gist/uninstall_btree_gist.sql b/contrib/btree_gist/uninstall_btree_gist.sql
deleted file mode 100644
index 30b9da4c73c690080c904809423a8188c2dd09d3..0000000000000000000000000000000000000000
--- a/contrib/btree_gist/uninstall_btree_gist.sql
+++ /dev/null
@@ -1,280 +0,0 @@
-/* contrib/btree_gist/uninstall_btree_gist.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR CLASS gist_cidr_ops USING gist;
-
-DROP OPERATOR CLASS gist_inet_ops USING gist;
-
-DROP FUNCTION gbt_inet_same(internal, internal, internal);
-
-DROP FUNCTION gbt_inet_union(bytea, internal);
-
-DROP FUNCTION gbt_inet_picksplit(internal, internal);
-
-DROP FUNCTION gbt_inet_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_inet_compress(internal);
-
-DROP FUNCTION gbt_inet_consistent(internal,inet,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_vbit_ops USING gist;
-
-DROP OPERATOR CLASS gist_bit_ops USING gist;
-
-DROP FUNCTION gbt_bit_same(internal, internal, internal);
-
-DROP FUNCTION gbt_bit_union(bytea, internal);
-
-DROP FUNCTION gbt_bit_picksplit(internal, internal);
-
-DROP FUNCTION gbt_bit_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_bit_compress(internal);
-
-DROP FUNCTION gbt_bit_consistent(internal,bit,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_numeric_ops USING gist;
-
-DROP FUNCTION gbt_numeric_same(internal, internal, internal);
-
-DROP FUNCTION gbt_numeric_union(bytea, internal);
-
-DROP FUNCTION gbt_numeric_picksplit(internal, internal);
-
-DROP FUNCTION gbt_numeric_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_numeric_compress(internal);
-
-DROP FUNCTION gbt_numeric_consistent(internal,numeric,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_bytea_ops USING gist;
-
-DROP FUNCTION gbt_bytea_same(internal, internal, internal);
-
-DROP FUNCTION gbt_bytea_union(bytea, internal);
-
-DROP FUNCTION gbt_bytea_picksplit(internal, internal);
-
-DROP FUNCTION gbt_bytea_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_bytea_compress(internal);
-
-DROP FUNCTION gbt_bytea_consistent(internal,bytea,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_bpchar_ops USING gist;
-
-DROP OPERATOR CLASS gist_text_ops USING gist;
-
-DROP FUNCTION gbt_text_same(internal, internal, internal);
-
-DROP FUNCTION gbt_text_union(bytea, internal);
-
-DROP FUNCTION gbt_text_picksplit(internal, internal);
-
-DROP FUNCTION gbt_text_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_bpchar_compress(internal);
-
-DROP FUNCTION gbt_text_compress(internal);
-
-DROP FUNCTION gbt_bpchar_consistent(internal,bpchar,int2,oid,internal);
-
-DROP FUNCTION gbt_text_consistent(internal,text,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_macaddr_ops USING gist;
-
-DROP FUNCTION gbt_macad_same(internal, internal, internal);
-
-DROP FUNCTION gbt_macad_union(bytea, internal);
-
-DROP FUNCTION gbt_macad_picksplit(internal, internal);
-
-DROP FUNCTION gbt_macad_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_macad_compress(internal);
-
-DROP FUNCTION gbt_macad_consistent(internal,macaddr,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_cash_ops USING gist;
-
-DROP FUNCTION gbt_cash_same(internal, internal, internal);
-
-DROP FUNCTION gbt_cash_union(bytea, internal);
-
-DROP FUNCTION gbt_cash_picksplit(internal, internal);
-
-DROP FUNCTION gbt_cash_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_cash_compress(internal);
-
-DROP FUNCTION gbt_cash_consistent(internal,money,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_interval_ops USING gist;
-
-DROP FUNCTION gbt_intv_same(internal, internal, internal);
-
-DROP FUNCTION gbt_intv_union(bytea, internal);
-
-DROP FUNCTION gbt_intv_picksplit(internal, internal);
-
-DROP FUNCTION gbt_intv_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_intv_decompress(internal);
-
-DROP FUNCTION gbt_intv_compress(internal);
-
-DROP FUNCTION gbt_intv_consistent(internal,interval,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_date_ops USING gist;
-
-DROP FUNCTION gbt_date_same(internal, internal, internal);
-
-DROP FUNCTION gbt_date_union(bytea, internal);
-
-DROP FUNCTION gbt_date_picksplit(internal, internal);
-
-DROP FUNCTION gbt_date_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_date_compress(internal);
-
-DROP FUNCTION gbt_date_consistent(internal,date,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_timetz_ops USING gist;
-
-DROP OPERATOR CLASS gist_time_ops USING gist;
-
-DROP FUNCTION gbt_time_same(internal, internal, internal);
-
-DROP FUNCTION gbt_time_union(bytea, internal);
-
-DROP FUNCTION gbt_time_picksplit(internal, internal);
-
-DROP FUNCTION gbt_time_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_timetz_compress(internal);
-
-DROP FUNCTION gbt_time_compress(internal);
-
-DROP FUNCTION gbt_timetz_consistent(internal,timetz,int2,oid,internal);
-
-DROP FUNCTION gbt_time_consistent(internal,time,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_timestamptz_ops USING gist;
-
-DROP OPERATOR CLASS gist_timestamp_ops USING gist;
-
-DROP FUNCTION gbt_ts_same(internal, internal, internal);
-
-DROP FUNCTION gbt_ts_union(bytea, internal);
-
-DROP FUNCTION gbt_ts_picksplit(internal, internal);
-
-DROP FUNCTION gbt_ts_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_tstz_compress(internal);
-
-DROP FUNCTION gbt_ts_compress(internal);
-
-DROP FUNCTION gbt_tstz_consistent(internal,timestamptz,int2,oid,internal);
-
-DROP FUNCTION gbt_ts_consistent(internal,timestamp,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_float8_ops USING gist;
-
-DROP FUNCTION gbt_float8_same(internal, internal, internal);
-
-DROP FUNCTION gbt_float8_union(bytea, internal);
-
-DROP FUNCTION gbt_float8_picksplit(internal, internal);
-
-DROP FUNCTION gbt_float8_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_float8_compress(internal);
-
-DROP FUNCTION gbt_float8_consistent(internal,float8,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_float4_ops USING gist;
-
-DROP FUNCTION gbt_float4_same(internal, internal, internal);
-
-DROP FUNCTION gbt_float4_union(bytea, internal);
-
-DROP FUNCTION gbt_float4_picksplit(internal, internal);
-
-DROP FUNCTION gbt_float4_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_float4_compress(internal);
-
-DROP FUNCTION gbt_float4_consistent(internal,float4,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_int8_ops USING gist;
-
-DROP FUNCTION gbt_int8_same(internal, internal, internal);
-
-DROP FUNCTION gbt_int8_union(bytea, internal);
-
-DROP FUNCTION gbt_int8_picksplit(internal, internal);
-
-DROP FUNCTION gbt_int8_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_int8_compress(internal);
-
-DROP FUNCTION gbt_int8_consistent(internal,int8,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_int4_ops USING gist;
-
-DROP FUNCTION gbt_int4_same(internal, internal, internal);
-
-DROP FUNCTION gbt_int4_union(bytea, internal);
-
-DROP FUNCTION gbt_int4_picksplit(internal, internal);
-
-DROP FUNCTION gbt_int4_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_int4_compress(internal);
-
-DROP FUNCTION gbt_int4_consistent(internal,int4,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_int2_ops USING gist;
-
-DROP FUNCTION gbt_int2_same(internal, internal, internal);
-
-DROP FUNCTION gbt_int2_union(bytea, internal);
-
-DROP FUNCTION gbt_int2_picksplit(internal, internal);
-
-DROP FUNCTION gbt_int2_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_int2_compress(internal);
-
-DROP FUNCTION gbt_int2_consistent(internal,int2,int2,oid,internal);
-
-DROP OPERATOR CLASS gist_oid_ops USING gist;
-
-DROP FUNCTION gbt_oid_same(internal, internal, internal);
-
-DROP FUNCTION gbt_oid_union(bytea, internal);
-
-DROP FUNCTION gbt_oid_picksplit(internal, internal);
-
-DROP FUNCTION gbt_oid_penalty(internal,internal,internal);
-
-DROP FUNCTION gbt_var_decompress(internal);
-
-DROP FUNCTION gbt_decompress(internal);
-
-DROP FUNCTION gbt_oid_compress(internal);
-
-DROP FUNCTION gbt_oid_consistent(internal,oid,int2,oid,internal);
-
-DROP TYPE gbtreekey_var CASCADE;
-
-DROP TYPE gbtreekey32 CASCADE;
-
-DROP TYPE gbtreekey16 CASCADE;
-
-DROP TYPE gbtreekey8 CASCADE;
-
-DROP TYPE gbtreekey4 CASCADE;
diff --git a/contrib/chkpass/.gitignore b/contrib/chkpass/.gitignore
deleted file mode 100644
index 9029d666aa5eec07728e37763539a85451894836..0000000000000000000000000000000000000000
--- a/contrib/chkpass/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/chkpass.sql
diff --git a/contrib/chkpass/Makefile b/contrib/chkpass/Makefile
index 3677dfcb565e09f93ca2b47ea2c4f0fd0ebc8388..b775aef17d97f161f29dbb3861847452aaafaf15 100644
--- a/contrib/chkpass/Makefile
+++ b/contrib/chkpass/Makefile
@@ -2,9 +2,11 @@
 
 MODULE_big = chkpass
 OBJS = chkpass.o
+
+EXTENSION = chkpass
+DATA = chkpass--1.0.sql chkpass--unpackaged--1.0.sql
+
 SHLIB_LINK = $(filter -lcrypt, $(LIBS))
-DATA_built = chkpass.sql
-DATA = uninstall_chkpass.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/chkpass/chkpass.sql.in b/contrib/chkpass/chkpass--1.0.sql
similarity index 88%
rename from contrib/chkpass/chkpass.sql.in
rename to contrib/chkpass/chkpass--1.0.sql
index 3cec0224b0092034a154d035b005793af171c040..aad74683f713641d9f15c1f804e2ed25abae90fb 100644
--- a/contrib/chkpass/chkpass.sql.in
+++ b/contrib/chkpass/chkpass--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/chkpass/chkpass.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/chkpass/chkpass--1.0.sql */
 
 --
 --	Input and output functions and the type itself:
diff --git a/contrib/chkpass/chkpass--unpackaged--1.0.sql b/contrib/chkpass/chkpass--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..bf91950f3c631926ba4982935eda5b7fd1b09863
--- /dev/null
+++ b/contrib/chkpass/chkpass--unpackaged--1.0.sql
@@ -0,0 +1,10 @@
+/* contrib/chkpass/chkpass--unpackaged--1.0.sql */
+
+ALTER EXTENSION chkpass ADD type chkpass;
+ALTER EXTENSION chkpass ADD function chkpass_in(cstring);
+ALTER EXTENSION chkpass ADD function chkpass_out(chkpass);
+ALTER EXTENSION chkpass ADD function raw(chkpass);
+ALTER EXTENSION chkpass ADD function eq(chkpass,text);
+ALTER EXTENSION chkpass ADD function ne(chkpass,text);
+ALTER EXTENSION chkpass ADD operator <>(chkpass,text);
+ALTER EXTENSION chkpass ADD operator =(chkpass,text);
diff --git a/contrib/chkpass/chkpass.control b/contrib/chkpass/chkpass.control
new file mode 100644
index 0000000000000000000000000000000000000000..bd4b3d3d0db4306260434ea0bd3ffe154f0ee57f
--- /dev/null
+++ b/contrib/chkpass/chkpass.control
@@ -0,0 +1,5 @@
+# chkpass extension
+comment = 'data type for auto-encrypted passwords'
+default_version = '1.0'
+module_pathname = '$libdir/chkpass'
+relocatable = true
diff --git a/contrib/chkpass/uninstall_chkpass.sql b/contrib/chkpass/uninstall_chkpass.sql
deleted file mode 100644
index 93ab6eb4ebbdcdca4af6c98b58cfd8d25be6437d..0000000000000000000000000000000000000000
--- a/contrib/chkpass/uninstall_chkpass.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* contrib/chkpass/uninstall_chkpass.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR <>(chkpass, text);
-
-DROP OPERATOR =(chkpass, text);
-
-DROP FUNCTION ne(chkpass, text);
-
-DROP FUNCTION eq(chkpass, text);
-
-DROP FUNCTION raw(chkpass);
-
-DROP TYPE chkpass CASCADE;
diff --git a/contrib/citext/.gitignore b/contrib/citext/.gitignore
index e6268171565d8674bfc4781c707d932302783bdb..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/citext/.gitignore
+++ b/contrib/citext/.gitignore
@@ -1,3 +1,2 @@
-/citext.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/citext/Makefile b/contrib/citext/Makefile
index c868eca884794c71bee0f5667f674bb9ed1f5b56..65942528dd030090a6a41b994c59bb09b8226df4 100644
--- a/contrib/citext/Makefile
+++ b/contrib/citext/Makefile
@@ -1,8 +1,10 @@
 # contrib/citext/Makefile
 
 MODULES = citext
-DATA_built = citext.sql
-DATA = uninstall_citext.sql
+
+EXTENSION = citext
+DATA = citext--1.0.sql citext--unpackaged--1.0.sql
+
 REGRESS = citext
 
 ifdef USE_PGXS
diff --git a/contrib/citext/citext.sql.in b/contrib/citext/citext--1.0.sql
similarity index 99%
rename from contrib/citext/citext.sql.in
rename to contrib/citext/citext--1.0.sql
index 7056d0ead370e61ed82eb0e0a28739d30eb77592..13cff8134a45911b529962e0f804b0bcde25718e 100644
--- a/contrib/citext/citext.sql.in
+++ b/contrib/citext/citext--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/citext/citext.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/citext/citext--1.0.sql */
 
 --
 --  PostgreSQL code for CITEXT.
diff --git a/contrib/citext/citext--unpackaged--1.0.sql b/contrib/citext/citext--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..7dcdc39413a3cdcdd73c393116378efb8a8d067f
--- /dev/null
+++ b/contrib/citext/citext--unpackaged--1.0.sql
@@ -0,0 +1,76 @@
+/* contrib/citext/citext--unpackaged--1.0.sql */
+
+ALTER EXTENSION citext ADD type citext;
+ALTER EXTENSION citext ADD function citextin(cstring);
+ALTER EXTENSION citext ADD function citextout(citext);
+ALTER EXTENSION citext ADD function citextrecv(internal);
+ALTER EXTENSION citext ADD function citextsend(citext);
+ALTER EXTENSION citext ADD function citext(character);
+ALTER EXTENSION citext ADD function citext(boolean);
+ALTER EXTENSION citext ADD function citext(inet);
+ALTER EXTENSION citext ADD cast (citext as text);
+ALTER EXTENSION citext ADD cast (citext as character varying);
+ALTER EXTENSION citext ADD cast (citext as character);
+ALTER EXTENSION citext ADD cast (text as citext);
+ALTER EXTENSION citext ADD cast (character varying as citext);
+ALTER EXTENSION citext ADD cast (character as citext);
+ALTER EXTENSION citext ADD cast (boolean as citext);
+ALTER EXTENSION citext ADD cast (inet as citext);
+ALTER EXTENSION citext ADD function citext_eq(citext,citext);
+ALTER EXTENSION citext ADD function citext_ne(citext,citext);
+ALTER EXTENSION citext ADD function citext_lt(citext,citext);
+ALTER EXTENSION citext ADD function citext_le(citext,citext);
+ALTER EXTENSION citext ADD function citext_gt(citext,citext);
+ALTER EXTENSION citext ADD function citext_ge(citext,citext);
+ALTER EXTENSION citext ADD operator <>(citext,citext);
+ALTER EXTENSION citext ADD operator =(citext,citext);
+ALTER EXTENSION citext ADD operator >(citext,citext);
+ALTER EXTENSION citext ADD operator >=(citext,citext);
+ALTER EXTENSION citext ADD operator <(citext,citext);
+ALTER EXTENSION citext ADD operator <=(citext,citext);
+ALTER EXTENSION citext ADD function citext_cmp(citext,citext);
+ALTER EXTENSION citext ADD function citext_hash(citext);
+ALTER EXTENSION citext ADD operator family citext_ops using btree;
+ALTER EXTENSION citext ADD operator class citext_ops using btree;
+ALTER EXTENSION citext ADD operator family citext_ops using hash;
+ALTER EXTENSION citext ADD operator class citext_ops using hash;
+ALTER EXTENSION citext ADD function citext_smaller(citext,citext);
+ALTER EXTENSION citext ADD function citext_larger(citext,citext);
+ALTER EXTENSION citext ADD function min(citext);
+ALTER EXTENSION citext ADD function max(citext);
+ALTER EXTENSION citext ADD function texticlike(citext,citext);
+ALTER EXTENSION citext ADD function texticnlike(citext,citext);
+ALTER EXTENSION citext ADD function texticregexeq(citext,citext);
+ALTER EXTENSION citext ADD function texticregexne(citext,citext);
+ALTER EXTENSION citext ADD operator !~(citext,citext);
+ALTER EXTENSION citext ADD operator ~(citext,citext);
+ALTER EXTENSION citext ADD operator !~*(citext,citext);
+ALTER EXTENSION citext ADD operator ~*(citext,citext);
+ALTER EXTENSION citext ADD operator !~~(citext,citext);
+ALTER EXTENSION citext ADD operator ~~(citext,citext);
+ALTER EXTENSION citext ADD operator !~~*(citext,citext);
+ALTER EXTENSION citext ADD operator ~~*(citext,citext);
+ALTER EXTENSION citext ADD function texticlike(citext,text);
+ALTER EXTENSION citext ADD function texticnlike(citext,text);
+ALTER EXTENSION citext ADD function texticregexeq(citext,text);
+ALTER EXTENSION citext ADD function texticregexne(citext,text);
+ALTER EXTENSION citext ADD operator !~(citext,text);
+ALTER EXTENSION citext ADD operator ~(citext,text);
+ALTER EXTENSION citext ADD operator !~*(citext,text);
+ALTER EXTENSION citext ADD operator ~*(citext,text);
+ALTER EXTENSION citext ADD operator !~~(citext,text);
+ALTER EXTENSION citext ADD operator ~~(citext,text);
+ALTER EXTENSION citext ADD operator !~~*(citext,text);
+ALTER EXTENSION citext ADD operator ~~*(citext,text);
+ALTER EXTENSION citext ADD function regexp_matches(citext,citext);
+ALTER EXTENSION citext ADD function regexp_matches(citext,citext,text);
+ALTER EXTENSION citext ADD function regexp_replace(citext,citext,text);
+ALTER EXTENSION citext ADD function regexp_replace(citext,citext,text,text);
+ALTER EXTENSION citext ADD function regexp_split_to_array(citext,citext);
+ALTER EXTENSION citext ADD function regexp_split_to_array(citext,citext,text);
+ALTER EXTENSION citext ADD function regexp_split_to_table(citext,citext);
+ALTER EXTENSION citext ADD function regexp_split_to_table(citext,citext,text);
+ALTER EXTENSION citext ADD function strpos(citext,citext);
+ALTER EXTENSION citext ADD function replace(citext,citext,citext);
+ALTER EXTENSION citext ADD function split_part(citext,citext,integer);
+ALTER EXTENSION citext ADD function translate(citext,citext,text);
diff --git a/contrib/citext/citext.control b/contrib/citext/citext.control
new file mode 100644
index 0000000000000000000000000000000000000000..3eb01a3360861472a62d6a59a3c03b18c3d8dcb3
--- /dev/null
+++ b/contrib/citext/citext.control
@@ -0,0 +1,5 @@
+# citext extension
+comment = 'data type for case-insensitive character strings'
+default_version = '1.0'
+module_pathname = '$libdir/citext'
+relocatable = true
diff --git a/contrib/citext/expected/citext.out b/contrib/citext/expected/citext.out
index 66ea5ee6ff571943ce1fe6b0b0d3a0c83e228fce..5392a7d1f37c7e9a43714fa7b6d384166cb12b1a 100644
--- a/contrib/citext/expected/citext.out
+++ b/contrib/citext/expected/citext.out
@@ -1,12 +1,7 @@
 --
 --  Test citext datatype
 --
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of citext.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
+CREATE EXTENSION citext;
 -- Test the operators and indexing functions
 -- Test = and <>.
 SELECT 'a'::citext = 'a'::citext AS t;
diff --git a/contrib/citext/expected/citext_1.out b/contrib/citext/expected/citext_1.out
index c5ca1f6c54104e7466d9c693788c1d2e738c5b92..5316ad0cda7b42985e52644ea1f3ddb3edbd4d57 100644
--- a/contrib/citext/expected/citext_1.out
+++ b/contrib/citext/expected/citext_1.out
@@ -1,12 +1,7 @@
 --
 --  Test citext datatype
 --
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of citext.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
+CREATE EXTENSION citext;
 -- Test the operators and indexing functions
 -- Test = and <>.
 SELECT 'a'::citext = 'a'::citext AS t;
diff --git a/contrib/citext/sql/citext.sql b/contrib/citext/sql/citext.sql
index 2f9b46665c8d6966a1b0657fc13269ef354d3761..07497401a4d123e12c6ce168ab781573e40b9651 100644
--- a/contrib/citext/sql/citext.sql
+++ b/contrib/citext/sql/citext.sql
@@ -2,15 +2,7 @@
 --  Test citext datatype
 --
 
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of citext.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i citext.sql
-RESET client_min_messages;
-\set ECHO all
+CREATE EXTENSION citext;
 
 -- Test the operators and indexing functions
 
diff --git a/contrib/citext/uninstall_citext.sql b/contrib/citext/uninstall_citext.sql
deleted file mode 100644
index 468987ad82663b7a0b6bdc86f33513be128fec68..0000000000000000000000000000000000000000
--- a/contrib/citext/uninstall_citext.sql
+++ /dev/null
@@ -1,80 +0,0 @@
-/* contrib/citext/uninstall_citext.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR CLASS citext_ops USING btree CASCADE;
-DROP OPERATOR CLASS citext_ops USING hash CASCADE;
-
-DROP AGGREGATE min(citext);
-DROP AGGREGATE max(citext);
-
-DROP OPERATOR = (citext, citext);
-DROP OPERATOR <> (citext, citext);
-DROP OPERATOR < (citext, citext);
-DROP OPERATOR <= (citext, citext);
-DROP OPERATOR >= (citext, citext);
-DROP OPERATOR > (citext, citext);
-
-DROP OPERATOR ~ (citext, citext);
-DROP OPERATOR ~* (citext, citext);
-DROP OPERATOR !~ (citext, citext);
-DROP OPERATOR !~* (citext, citext);
-DROP OPERATOR ~~ (citext, citext);
-DROP OPERATOR ~~* (citext, citext);
-DROP OPERATOR !~~ (citext, citext);
-DROP OPERATOR !~~* (citext, citext);
-
-DROP OPERATOR ~ (citext, text);
-DROP OPERATOR ~* (citext, text);
-DROP OPERATOR !~ (citext, text);
-DROP OPERATOR !~* (citext, text);
-DROP OPERATOR ~~ (citext, text);
-DROP OPERATOR ~~* (citext, text);
-DROP OPERATOR !~~ (citext, text);
-DROP OPERATOR !~~* (citext, text);
-
-DROP CAST (citext AS text);
-DROP CAST (citext AS varchar);
-DROP CAST (citext AS bpchar);
-DROP CAST (text AS citext);
-DROP CAST (varchar AS citext);
-DROP CAST (bpchar AS citext);
-DROP CAST (boolean AS citext);
-DROP CAST (inet AS citext);
-
-DROP FUNCTION citext(bpchar);
-DROP FUNCTION citext(boolean);
-DROP FUNCTION citext(inet);
-DROP FUNCTION citext_eq(citext, citext);
-DROP FUNCTION citext_ne(citext, citext);
-DROP FUNCTION citext_lt(citext, citext);
-DROP FUNCTION citext_le(citext, citext);
-DROP FUNCTION citext_gt(citext, citext);
-DROP FUNCTION citext_ge(citext, citext);
-DROP FUNCTION citext_cmp(citext, citext);
-DROP FUNCTION citext_hash(citext);
-DROP FUNCTION citext_smaller(citext, citext);
-DROP FUNCTION citext_larger(citext, citext);
-DROP FUNCTION texticlike(citext, citext);
-DROP FUNCTION texticnlike(citext, citext);
-DROP FUNCTION texticregexeq(citext, citext);
-DROP FUNCTION texticregexne(citext, citext);
-DROP FUNCTION texticlike(citext, text);
-DROP FUNCTION texticnlike(citext, text);
-DROP FUNCTION texticregexeq(citext, text);
-DROP FUNCTION texticregexne(citext, text);
-DROP FUNCTION regexp_matches( citext, citext );
-DROP FUNCTION regexp_matches( citext, citext, text );
-DROP FUNCTION regexp_replace( citext, citext, text );
-DROP FUNCTION regexp_replace( citext, citext, text, text );
-DROP FUNCTION regexp_split_to_array( citext, citext );
-DROP FUNCTION regexp_split_to_array( citext, citext, text );
-DROP FUNCTION regexp_split_to_table( citext, citext );
-DROP FUNCTION regexp_split_to_table( citext, citext, text );
-DROP FUNCTION strpos( citext, citext );
-DROP FUNCTION replace( citext, citext, citext );
-DROP FUNCTION split_part( citext, citext, int );
-DROP FUNCTION translate( citext, citext, text );
-
-DROP TYPE citext CASCADE;
diff --git a/contrib/cube/.gitignore b/contrib/cube/.gitignore
index 9f60da507879ce66fd20f1f3af6fbf1d3d2cd652..a6484a05e7332d3df5dac6b1bb5effede80542ae 100644
--- a/contrib/cube/.gitignore
+++ b/contrib/cube/.gitignore
@@ -1,5 +1,4 @@
 /cubeparse.c
 /cubescan.c
-/cube.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile
index 4fee79f84eb069c38bd3dd21570e9d4d4eb8ed4a..19fd7dc658f7daa561653d97ffb77ce123341fa7 100644
--- a/contrib/cube/Makefile
+++ b/contrib/cube/Makefile
@@ -3,8 +3,9 @@
 MODULE_big = cube
 OBJS= cube.o cubeparse.o
 
-DATA_built = cube.sql
-DATA = uninstall_cube.sql
+EXTENSION = cube
+DATA = cube--1.0.sql cube--unpackaged--1.0.sql
+
 REGRESS = cube
 
 EXTRA_CLEAN = y.tab.c y.tab.h
diff --git a/contrib/cube/cube.sql.in b/contrib/cube/cube--1.0.sql
similarity index 98%
rename from contrib/cube/cube.sql.in
rename to contrib/cube/cube--1.0.sql
index a7e6b1d2b97ff6d25f89c0f02948baad0edb0a0b..18d69a548823a1c495310f89671be33a7f4be3c4 100644
--- a/contrib/cube/cube.sql.in
+++ b/contrib/cube/cube--1.0.sql
@@ -1,10 +1,6 @@
-/* contrib/cube/cube.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/cube/cube--1.0.sql */
 
 -- Create the user-defined type for N-dimensional boxes
---
 
 CREATE OR REPLACE FUNCTION cube_in(cstring)
 RETURNS cube
diff --git a/contrib/cube/cube--unpackaged--1.0.sql b/contrib/cube/cube--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..866c18a2898550bcb9017f7df5915f2ae2cfe7a4
--- /dev/null
+++ b/contrib/cube/cube--unpackaged--1.0.sql
@@ -0,0 +1,53 @@
+/* contrib/cube/cube--unpackaged--1.0.sql */
+
+ALTER EXTENSION cube ADD type cube;
+ALTER EXTENSION cube ADD function cube_in(cstring);
+ALTER EXTENSION cube ADD function cube(double precision[],double precision[]);
+ALTER EXTENSION cube ADD function cube(double precision[]);
+ALTER EXTENSION cube ADD function cube_out(cube);
+ALTER EXTENSION cube ADD function cube_eq(cube,cube);
+ALTER EXTENSION cube ADD function cube_ne(cube,cube);
+ALTER EXTENSION cube ADD function cube_lt(cube,cube);
+ALTER EXTENSION cube ADD function cube_gt(cube,cube);
+ALTER EXTENSION cube ADD function cube_le(cube,cube);
+ALTER EXTENSION cube ADD function cube_ge(cube,cube);
+ALTER EXTENSION cube ADD function cube_cmp(cube,cube);
+ALTER EXTENSION cube ADD function cube_contains(cube,cube);
+ALTER EXTENSION cube ADD function cube_contained(cube,cube);
+ALTER EXTENSION cube ADD function cube_overlap(cube,cube);
+ALTER EXTENSION cube ADD function cube_union(cube,cube);
+ALTER EXTENSION cube ADD function cube_inter(cube,cube);
+ALTER EXTENSION cube ADD function cube_size(cube);
+ALTER EXTENSION cube ADD function cube_subset(cube,integer[]);
+ALTER EXTENSION cube ADD function cube_distance(cube,cube);
+ALTER EXTENSION cube ADD function cube_dim(cube);
+ALTER EXTENSION cube ADD function cube_ll_coord(cube,integer);
+ALTER EXTENSION cube ADD function cube_ur_coord(cube,integer);
+ALTER EXTENSION cube ADD function cube(double precision);
+ALTER EXTENSION cube ADD function cube(double precision,double precision);
+ALTER EXTENSION cube ADD function cube(cube,double precision);
+ALTER EXTENSION cube ADD function cube(cube,double precision,double precision);
+ALTER EXTENSION cube ADD function cube_is_point(cube);
+ALTER EXTENSION cube ADD function cube_enlarge(cube,double precision,integer);
+ALTER EXTENSION cube ADD operator >(cube,cube);
+ALTER EXTENSION cube ADD operator >=(cube,cube);
+ALTER EXTENSION cube ADD operator <(cube,cube);
+ALTER EXTENSION cube ADD operator <=(cube,cube);
+ALTER EXTENSION cube ADD operator &&(cube,cube);
+ALTER EXTENSION cube ADD operator <>(cube,cube);
+ALTER EXTENSION cube ADD operator =(cube,cube);
+ALTER EXTENSION cube ADD operator <@(cube,cube);
+ALTER EXTENSION cube ADD operator @>(cube,cube);
+ALTER EXTENSION cube ADD operator ~(cube,cube);
+ALTER EXTENSION cube ADD operator @(cube,cube);
+ALTER EXTENSION cube ADD function g_cube_consistent(internal,cube,integer,oid,internal);
+ALTER EXTENSION cube ADD function g_cube_compress(internal);
+ALTER EXTENSION cube ADD function g_cube_decompress(internal);
+ALTER EXTENSION cube ADD function g_cube_penalty(internal,internal,internal);
+ALTER EXTENSION cube ADD function g_cube_picksplit(internal,internal);
+ALTER EXTENSION cube ADD function g_cube_union(internal,internal);
+ALTER EXTENSION cube ADD function g_cube_same(cube,cube,internal);
+ALTER EXTENSION cube ADD operator family cube_ops using btree;
+ALTER EXTENSION cube ADD operator class cube_ops using btree;
+ALTER EXTENSION cube ADD operator family gist_cube_ops using gist;
+ALTER EXTENSION cube ADD operator class gist_cube_ops using gist;
diff --git a/contrib/cube/cube.control b/contrib/cube/cube.control
new file mode 100644
index 0000000000000000000000000000000000000000..ddc8d2e5d1ab07abe0bc2d399241cc6b00d54c64
--- /dev/null
+++ b/contrib/cube/cube.control
@@ -0,0 +1,5 @@
+# cube extension
+comment = 'data type for multidimensional cubes'
+default_version = '1.0'
+module_pathname = '$libdir/cube'
+relocatable = true
diff --git a/contrib/cube/expected/cube.out b/contrib/cube/expected/cube.out
index ae7b5b22c2fae3a12f08c77e9b4d0b50133a44b7..05cf3eae3cafa820dd19d06fc940ebbd33568fa8 100644
--- a/contrib/cube/expected/cube.out
+++ b/contrib/cube/expected/cube.out
@@ -1,13 +1,7 @@
 --
 --  Test cube datatype
 --
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of cube.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION cube;
 --
 -- testing the input and output functions
 --
diff --git a/contrib/cube/expected/cube_1.out b/contrib/cube/expected/cube_1.out
index f27e832d6317c41ae02e28a42d1e132c9d9628cf..fefebf5fb943e761ac907af42f2177cbf1e16a72 100644
--- a/contrib/cube/expected/cube_1.out
+++ b/contrib/cube/expected/cube_1.out
@@ -1,13 +1,7 @@
 --
 --  Test cube datatype
 --
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of cube.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION cube;
 --
 -- testing the input and output functions
 --
diff --git a/contrib/cube/expected/cube_2.out b/contrib/cube/expected/cube_2.out
index f534ccf0b53a454d81536ce71f3ee772576807e3..6d15d635700bc9ca141073026e4cc68c1761a5cf 100644
--- a/contrib/cube/expected/cube_2.out
+++ b/contrib/cube/expected/cube_2.out
@@ -1,13 +1,7 @@
 --
 --  Test cube datatype
 --
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of cube.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION cube;
 --
 -- testing the input and output functions
 --
diff --git a/contrib/cube/sql/cube.sql b/contrib/cube/sql/cube.sql
index 5c12183dfd7a23b6a18a8e7e9814914cf1288d12..02e068edf4df1cb7c3f26ead232b8816a141649b 100644
--- a/contrib/cube/sql/cube.sql
+++ b/contrib/cube/sql/cube.sql
@@ -2,15 +2,7 @@
 --  Test cube datatype
 --
 
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of cube.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i cube.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION cube;
 
 --
 -- testing the input and output functions
diff --git a/contrib/cube/uninstall_cube.sql b/contrib/cube/uninstall_cube.sql
deleted file mode 100644
index aa7119e0d0e508691c0bae950925942a65188b13..0000000000000000000000000000000000000000
--- a/contrib/cube/uninstall_cube.sql
+++ /dev/null
@@ -1,98 +0,0 @@
-/* contrib/cube/uninstall_cube.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR CLASS gist_cube_ops USING gist;
-
-DROP OPERATOR CLASS cube_ops USING btree;
-
-DROP FUNCTION g_cube_same(cube, cube, internal);
-
-DROP FUNCTION g_cube_union(internal, internal);
-
-DROP FUNCTION g_cube_picksplit(internal, internal);
-
-DROP FUNCTION g_cube_penalty(internal,internal,internal);
-
-DROP FUNCTION g_cube_decompress(internal);
-
-DROP FUNCTION g_cube_compress(internal);
-
-DROP FUNCTION g_cube_consistent(internal,cube,int,oid,internal);
-
-DROP OPERATOR ~ (cube, cube);
-
-DROP OPERATOR @ (cube, cube);
-
-DROP OPERATOR <@ (cube, cube);
-
-DROP OPERATOR @> (cube, cube);
-
-DROP OPERATOR <> (cube, cube);
-
-DROP OPERATOR = (cube, cube);
-
-DROP OPERATOR && (cube, cube);
-
-DROP OPERATOR >= (cube, cube);
-
-DROP OPERATOR <= (cube, cube);
-
-DROP OPERATOR > (cube, cube);
-
-DROP OPERATOR < (cube, cube);
-
-DROP FUNCTION cube_enlarge(cube, float8, int4);
-
-DROP FUNCTION cube_is_point(cube);
-
-DROP FUNCTION cube(cube, float8, float8);
-
-DROP FUNCTION cube(cube, float8);
-
-DROP FUNCTION cube(float8, float8);
-
-DROP FUNCTION cube(float8[], float8[]);
-
-DROP FUNCTION cube(float8[]);
-
-DROP FUNCTION cube_subset(cube, int4[]);
-
-DROP FUNCTION cube(float8);
-
-DROP FUNCTION cube_ur_coord(cube, int4);
-
-DROP FUNCTION cube_ll_coord(cube, int4);
-
-DROP FUNCTION cube_dim(cube);
-
-DROP FUNCTION cube_distance(cube, cube);
-
-DROP FUNCTION cube_size(cube);
-
-DROP FUNCTION cube_inter(cube, cube);
-
-DROP FUNCTION cube_union(cube, cube);
-
-DROP FUNCTION cube_overlap(cube, cube);
-
-DROP FUNCTION cube_contained(cube, cube);
-
-DROP FUNCTION cube_contains(cube, cube);
-
-DROP FUNCTION cube_cmp(cube, cube);
-
-DROP FUNCTION cube_ge(cube, cube);
-
-DROP FUNCTION cube_le(cube, cube);
-
-DROP FUNCTION cube_gt(cube, cube);
-
-DROP FUNCTION cube_lt(cube, cube);
-
-DROP FUNCTION cube_ne(cube, cube);
-
-DROP FUNCTION cube_eq(cube, cube);
-
-DROP TYPE cube CASCADE;
diff --git a/contrib/dblink/.gitignore b/contrib/dblink/.gitignore
index fb7e8728bcffd5b5cdd405a8cbd4f0d21ca79c44..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/dblink/.gitignore
+++ b/contrib/dblink/.gitignore
@@ -1,3 +1,2 @@
-/dblink.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/dblink/Makefile b/contrib/dblink/Makefile
index fdfd03a4cf7b1a2f14fce4341ee319bc4fcd9e68..ac637480eb5a76d14667e050eb552101f6489ce2 100644
--- a/contrib/dblink/Makefile
+++ b/contrib/dblink/Makefile
@@ -1,15 +1,15 @@
 # contrib/dblink/Makefile
 
 MODULE_big = dblink
-PG_CPPFLAGS = -I$(libpq_srcdir)
 OBJS	= dblink.o
+PG_CPPFLAGS = -I$(libpq_srcdir)
 SHLIB_LINK = $(libpq)
 SHLIB_PREREQS = submake-libpq
 
-DATA_built = dblink.sql
-DATA = uninstall_dblink.sql
-REGRESS = dblink
+EXTENSION = dblink
+DATA = dblink--1.0.sql dblink--unpackaged--1.0.sql
 
+REGRESS = dblink
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/dblink/dblink.sql.in b/contrib/dblink/dblink--1.0.sql
similarity index 97%
rename from contrib/dblink/dblink.sql.in
rename to contrib/dblink/dblink--1.0.sql
index 3c9d66e7df1ae1a0da04f3bcb6bdf85e80f16d35..e9137828f139fe2ef0e75de9daaa4a934ea92a41 100644
--- a/contrib/dblink/dblink.sql.in
+++ b/contrib/dblink/dblink--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/dblink/dblink.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/dblink/dblink--1.0.sql */
 
 -- dblink_connect now restricts non-superusers to password
 -- authenticated connections
diff --git a/contrib/dblink/dblink--unpackaged--1.0.sql b/contrib/dblink/dblink--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..b6d184b4a2c096484d7c19c20644bee0d5249f17
--- /dev/null
+++ b/contrib/dblink/dblink--unpackaged--1.0.sql
@@ -0,0 +1,43 @@
+/* contrib/dblink/dblink--unpackaged--1.0.sql */
+
+ALTER EXTENSION dblink ADD function dblink_connect(text);
+ALTER EXTENSION dblink ADD function dblink_connect(text,text);
+ALTER EXTENSION dblink ADD function dblink_connect_u(text);
+ALTER EXTENSION dblink ADD function dblink_connect_u(text,text);
+ALTER EXTENSION dblink ADD function dblink_disconnect();
+ALTER EXTENSION dblink ADD function dblink_disconnect(text);
+ALTER EXTENSION dblink ADD function dblink_open(text,text);
+ALTER EXTENSION dblink ADD function dblink_open(text,text,boolean);
+ALTER EXTENSION dblink ADD function dblink_open(text,text,text);
+ALTER EXTENSION dblink ADD function dblink_open(text,text,text,boolean);
+ALTER EXTENSION dblink ADD function dblink_fetch(text,integer);
+ALTER EXTENSION dblink ADD function dblink_fetch(text,integer,boolean);
+ALTER EXTENSION dblink ADD function dblink_fetch(text,text,integer);
+ALTER EXTENSION dblink ADD function dblink_fetch(text,text,integer,boolean);
+ALTER EXTENSION dblink ADD function dblink_close(text);
+ALTER EXTENSION dblink ADD function dblink_close(text,boolean);
+ALTER EXTENSION dblink ADD function dblink_close(text,text);
+ALTER EXTENSION dblink ADD function dblink_close(text,text,boolean);
+ALTER EXTENSION dblink ADD function dblink(text,text);
+ALTER EXTENSION dblink ADD function dblink(text,text,boolean);
+ALTER EXTENSION dblink ADD function dblink(text);
+ALTER EXTENSION dblink ADD function dblink(text,boolean);
+ALTER EXTENSION dblink ADD function dblink_exec(text,text);
+ALTER EXTENSION dblink ADD function dblink_exec(text,text,boolean);
+ALTER EXTENSION dblink ADD function dblink_exec(text);
+ALTER EXTENSION dblink ADD function dblink_exec(text,boolean);
+ALTER EXTENSION dblink ADD type dblink_pkey_results;
+ALTER EXTENSION dblink ADD function dblink_get_pkey(text);
+ALTER EXTENSION dblink ADD function dblink_build_sql_insert(text,int2vector,integer,text[],text[]);
+ALTER EXTENSION dblink ADD function dblink_build_sql_delete(text,int2vector,integer,text[]);
+ALTER EXTENSION dblink ADD function dblink_build_sql_update(text,int2vector,integer,text[],text[]);
+ALTER EXTENSION dblink ADD function dblink_current_query();
+ALTER EXTENSION dblink ADD function dblink_send_query(text,text);
+ALTER EXTENSION dblink ADD function dblink_is_busy(text);
+ALTER EXTENSION dblink ADD function dblink_get_result(text);
+ALTER EXTENSION dblink ADD function dblink_get_result(text,boolean);
+ALTER EXTENSION dblink ADD function dblink_get_connections();
+ALTER EXTENSION dblink ADD function dblink_cancel_query(text);
+ALTER EXTENSION dblink ADD function dblink_error_message(text);
+ALTER EXTENSION dblink ADD function dblink_get_notify();
+ALTER EXTENSION dblink ADD function dblink_get_notify(text);
diff --git a/contrib/dblink/dblink.control b/contrib/dblink/dblink.control
new file mode 100644
index 0000000000000000000000000000000000000000..4333a9b61897ea0a9f053d7de927f8bf0aae7cc7
--- /dev/null
+++ b/contrib/dblink/dblink.control
@@ -0,0 +1,5 @@
+# dblink extension
+comment = 'connect to other PostgreSQL databases from within a database'
+default_version = '1.0'
+module_pathname = '$libdir/dblink'
+relocatable = true
diff --git a/contrib/dblink/expected/dblink.out b/contrib/dblink/expected/dblink.out
index 15848dd92293b6e04a3e3a3faba98b8b2e1e6ebf..511dd5efcfbe1fc6bb663a3bcf1525530df69d88 100644
--- a/contrib/dblink/expected/dblink.out
+++ b/contrib/dblink/expected/dblink.out
@@ -1,14 +1,4 @@
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
---
--- Define the functions and test data
--- therein.
---
--- Turn off echoing so that expected file does not depend on
--- contents of dblink.sql.
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION dblink;
 CREATE TABLE foo(f1 int, f2 text, f3 text[], primary key (f1,f2));
 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
 INSERT INTO foo VALUES (0,'a','{"a0","b0","c0"}');
diff --git a/contrib/dblink/sql/dblink.sql b/contrib/dblink/sql/dblink.sql
index 062bc9ee0ee47af5d46a555329bc3aef4befc82c..8c8ffe233cfc0147b1f168bada925fbe12a56b52 100644
--- a/contrib/dblink/sql/dblink.sql
+++ b/contrib/dblink/sql/dblink.sql
@@ -1,17 +1,4 @@
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
---
--- Define the functions and test data
--- therein.
---
--- Turn off echoing so that expected file does not depend on
--- contents of dblink.sql.
-SET client_min_messages = warning;
-\set ECHO none
-\i dblink.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION dblink;
 
 CREATE TABLE foo(f1 int, f2 text, f3 text[], primary key (f1,f2));
 INSERT INTO foo VALUES (0,'a','{"a0","b0","c0"}');
diff --git a/contrib/dblink/uninstall_dblink.sql b/contrib/dblink/uninstall_dblink.sql
deleted file mode 100644
index 365728a6d7c3ba79c4d29a16640b8e5d0f5008b8..0000000000000000000000000000000000000000
--- a/contrib/dblink/uninstall_dblink.sql
+++ /dev/null
@@ -1,86 +0,0 @@
-/* contrib/dblink/uninstall_dblink.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION dblink_current_query ();
-
-DROP FUNCTION dblink_build_sql_update (text, int2vector, int4, _text, _text);
-
-DROP FUNCTION dblink_build_sql_delete (text, int2vector, int4, _text);
-
-DROP FUNCTION dblink_build_sql_insert (text, int2vector, int4, _text, _text);
-
-DROP FUNCTION dblink_get_pkey (text);
-
-DROP TYPE dblink_pkey_results;
-
-DROP FUNCTION dblink_exec (text,bool);
-
-DROP FUNCTION dblink_exec (text);
-
-DROP FUNCTION dblink_exec (text,text,bool);
-
-DROP FUNCTION dblink_exec (text,text);
-
-DROP FUNCTION dblink (text,bool);
-
-DROP FUNCTION dblink (text);
-
-DROP FUNCTION dblink (text,text,bool);
-
-DROP FUNCTION dblink (text,text);
-
-DROP FUNCTION dblink_close (text,text,bool);
-
-DROP FUNCTION dblink_close (text,text);
-
-DROP FUNCTION dblink_close (text,bool);
-
-DROP FUNCTION dblink_close (text);
-
-DROP FUNCTION dblink_fetch (text,text,int,bool);
-
-DROP FUNCTION dblink_fetch (text,text,int);
-
-DROP FUNCTION dblink_fetch (text,int,bool);
-
-DROP FUNCTION dblink_fetch (text,int);
-
-DROP FUNCTION dblink_open (text,text,text,bool);
-
-DROP FUNCTION dblink_open (text,text,text);
-
-DROP FUNCTION dblink_open (text,text,bool);
-
-DROP FUNCTION dblink_open (text,text);
-
-DROP FUNCTION dblink_disconnect (text);
-
-DROP FUNCTION dblink_disconnect ();
-
-DROP FUNCTION dblink_connect (text, text);
-
-DROP FUNCTION dblink_connect (text);
-
-DROP FUNCTION dblink_connect_u (text, text);
-
-DROP FUNCTION dblink_connect_u (text);
-
-DROP FUNCTION dblink_cancel_query(text);
-
-DROP FUNCTION dblink_error_message(text);
-
-DROP FUNCTION dblink_get_connections();
-
-DROP FUNCTION dblink_get_result(text);
-
-DROP FUNCTION dblink_get_result(text, boolean);
-
-DROP FUNCTION dblink_is_busy(text);
-
-DROP FUNCTION dblink_send_query(text, text);
-
-DROP FUNCTION dblink_get_notify();
-
-DROP FUNCTION dblink_get_notify(text);
diff --git a/contrib/dict_int/.gitignore b/contrib/dict_int/.gitignore
index 932dda6d8419fda794f24485cca753382ade74cd..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/dict_int/.gitignore
+++ b/contrib/dict_int/.gitignore
@@ -1,3 +1,2 @@
-/dict_int.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/dict_int/Makefile b/contrib/dict_int/Makefile
index 17d9eaa5f7af8a428b12dd08d8d0a06fba3fd1ad..3a3fc368dc6ade3ccef13cd72eb96514c33af1df 100644
--- a/contrib/dict_int/Makefile
+++ b/contrib/dict_int/Makefile
@@ -2,8 +2,10 @@
 
 MODULE_big = dict_int
 OBJS = dict_int.o
-DATA_built = dict_int.sql
-DATA = uninstall_dict_int.sql
+
+EXTENSION = dict_int
+DATA = dict_int--1.0.sql dict_int--unpackaged--1.0.sql
+
 REGRESS = dict_int
 
 ifdef USE_PGXS
diff --git a/contrib/dict_int/dict_int.sql.in b/contrib/dict_int/dict_int--1.0.sql
similarity index 80%
rename from contrib/dict_int/dict_int.sql.in
rename to contrib/dict_int/dict_int--1.0.sql
index 9d7ef7d9c124e18568ab2be4652ff186b4d69d17..a0e2b9af64215a5563d6e697d61534e6eb659040 100644
--- a/contrib/dict_int/dict_int.sql.in
+++ b/contrib/dict_int/dict_int--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/dict_int/dict_int.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/dict_int/dict_int--1.0.sql */
 
 CREATE OR REPLACE FUNCTION dintdict_init(internal)
         RETURNS internal
diff --git a/contrib/dict_int/dict_int--unpackaged--1.0.sql b/contrib/dict_int/dict_int--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..f89218a565c0c43b018b7f46c66328316b913350
--- /dev/null
+++ b/contrib/dict_int/dict_int--unpackaged--1.0.sql
@@ -0,0 +1,6 @@
+/* contrib/dict_int/dict_int--unpackaged--1.0.sql */
+
+ALTER EXTENSION dict_int ADD function dintdict_init(internal);
+ALTER EXTENSION dict_int ADD function dintdict_lexize(internal,internal,internal,internal);
+ALTER EXTENSION dict_int ADD text search template intdict_template;
+ALTER EXTENSION dict_int ADD text search dictionary intdict;
diff --git a/contrib/dict_int/dict_int.control b/contrib/dict_int/dict_int.control
new file mode 100644
index 0000000000000000000000000000000000000000..6e2d2b351ae22ade056df8a6516ded017130e7fe
--- /dev/null
+++ b/contrib/dict_int/dict_int.control
@@ -0,0 +1,5 @@
+# dict_int extension
+comment = 'text search dictionary template for integers'
+default_version = '1.0'
+module_pathname = '$libdir/dict_int'
+relocatable = true
diff --git a/contrib/dict_int/expected/dict_int.out b/contrib/dict_int/expected/dict_int.out
index 7feb493e153f10870e6b3a55457bd6085df041b0..3b766ec52ade4616d613b77fa646a285ab1221a7 100644
--- a/contrib/dict_int/expected/dict_int.out
+++ b/contrib/dict_int/expected/dict_int.out
@@ -1,10 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of this file.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION dict_int;
 --lexize
 select ts_lexize('intdict', '511673');
  ts_lexize 
diff --git a/contrib/dict_int/sql/dict_int.sql b/contrib/dict_int/sql/dict_int.sql
index 3a335f8f3d038a31313a7c8e082bcb4560b758e5..8ffec6b77089a45984068d7f38f693f450eefa90 100644
--- a/contrib/dict_int/sql/dict_int.sql
+++ b/contrib/dict_int/sql/dict_int.sql
@@ -1,12 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of this file.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i dict_int.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION dict_int;
 
 --lexize
 select ts_lexize('intdict', '511673');
diff --git a/contrib/dict_int/uninstall_dict_int.sql b/contrib/dict_int/uninstall_dict_int.sql
deleted file mode 100644
index 0467fa22baad2e887fb2ff951c04d14e3e9ba951..0000000000000000000000000000000000000000
--- a/contrib/dict_int/uninstall_dict_int.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-/* contrib/dict_int/uninstall_dict_int.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP TEXT SEARCH DICTIONARY intdict;
-
-DROP TEXT SEARCH TEMPLATE intdict_template;
-
-DROP FUNCTION dintdict_init(internal);
-
-DROP FUNCTION dintdict_lexize(internal,internal,internal,internal);
diff --git a/contrib/dict_xsyn/.gitignore b/contrib/dict_xsyn/.gitignore
index 0ebd61caaff987bd2d6451a6a52365ac813d0e8c..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/dict_xsyn/.gitignore
+++ b/contrib/dict_xsyn/.gitignore
@@ -1,3 +1,2 @@
-/dict_xsyn.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/dict_xsyn/Makefile b/contrib/dict_xsyn/Makefile
index 8b737f09fcc399a2d84674aea69a425a422b1522..ce92baa47895290012db15a28d7f9e33e8d4ee2f 100644
--- a/contrib/dict_xsyn/Makefile
+++ b/contrib/dict_xsyn/Makefile
@@ -2,9 +2,11 @@
 
 MODULE_big = dict_xsyn
 OBJS = dict_xsyn.o
-DATA_built = dict_xsyn.sql
-DATA = uninstall_dict_xsyn.sql
+
+EXTENSION = dict_xsyn
+DATA = dict_xsyn--1.0.sql dict_xsyn--unpackaged--1.0.sql
 DATA_TSEARCH = xsyn_sample.rules
+
 REGRESS = dict_xsyn
 
 ifdef USE_PGXS
diff --git a/contrib/dict_xsyn/dict_xsyn.sql.in b/contrib/dict_xsyn/dict_xsyn--1.0.sql
similarity index 80%
rename from contrib/dict_xsyn/dict_xsyn.sql.in
rename to contrib/dict_xsyn/dict_xsyn--1.0.sql
index 7d48c9209f594fcbd91d74ad9a3717336b22a42c..0b6a21730fdc627fa0664cb67a4343a0d6b35069 100644
--- a/contrib/dict_xsyn/dict_xsyn.sql.in
+++ b/contrib/dict_xsyn/dict_xsyn--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/dict_xsyn/dict_xsyn.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/dict_xsyn/dict_xsyn--1.0.sql */
 
 CREATE OR REPLACE FUNCTION dxsyn_init(internal)
         RETURNS internal
diff --git a/contrib/dict_xsyn/dict_xsyn--unpackaged--1.0.sql b/contrib/dict_xsyn/dict_xsyn--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..6fe0285f799f96552272b3d5bfd72a121f6f041a
--- /dev/null
+++ b/contrib/dict_xsyn/dict_xsyn--unpackaged--1.0.sql
@@ -0,0 +1,6 @@
+/* contrib/dict_xsyn/dict_xsyn--unpackaged--1.0.sql */
+
+ALTER EXTENSION dict_xsyn ADD function dxsyn_init(internal);
+ALTER EXTENSION dict_xsyn ADD function dxsyn_lexize(internal,internal,internal,internal);
+ALTER EXTENSION dict_xsyn ADD text search template xsyn_template;
+ALTER EXTENSION dict_xsyn ADD text search dictionary xsyn;
diff --git a/contrib/dict_xsyn/dict_xsyn.control b/contrib/dict_xsyn/dict_xsyn.control
new file mode 100644
index 0000000000000000000000000000000000000000..3fd465a95577471ae99b42b63a21ad31eac71ac9
--- /dev/null
+++ b/contrib/dict_xsyn/dict_xsyn.control
@@ -0,0 +1,5 @@
+# dict_xsyn extension
+comment = 'text search dictionary template for extended synonym processing'
+default_version = '1.0'
+module_pathname = '$libdir/dict_xsyn'
+relocatable = true
diff --git a/contrib/dict_xsyn/expected/dict_xsyn.out b/contrib/dict_xsyn/expected/dict_xsyn.out
index d91697a97e9b9c9542df26c9ee020a03c915d0c0..9b95e135591dea094da884b58afd2413b828357c 100644
--- a/contrib/dict_xsyn/expected/dict_xsyn.out
+++ b/contrib/dict_xsyn/expected/dict_xsyn.out
@@ -1,10 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of this file.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION dict_xsyn;
 -- default configuration - match first word and return it among with all synonyms
 ALTER TEXT SEARCH DICTIONARY xsyn (RULES='xsyn_sample', KEEPORIG=true, MATCHORIG=true, KEEPSYNONYMS=true, MATCHSYNONYMS=false);
 --lexize
diff --git a/contrib/dict_xsyn/sql/dict_xsyn.sql b/contrib/dict_xsyn/sql/dict_xsyn.sql
index 9db0851700c87c00cb36d234df3e83e5753bfc84..49511061d0cdaeedbf0566a7fa35a7c6e0e554a7 100644
--- a/contrib/dict_xsyn/sql/dict_xsyn.sql
+++ b/contrib/dict_xsyn/sql/dict_xsyn.sql
@@ -1,12 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of this file.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i dict_xsyn.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION dict_xsyn;
 
 -- default configuration - match first word and return it among with all synonyms
 ALTER TEXT SEARCH DICTIONARY xsyn (RULES='xsyn_sample', KEEPORIG=true, MATCHORIG=true, KEEPSYNONYMS=true, MATCHSYNONYMS=false);
diff --git a/contrib/dict_xsyn/uninstall_dict_xsyn.sql b/contrib/dict_xsyn/uninstall_dict_xsyn.sql
deleted file mode 100644
index 68f9579c0561c58b07bdcd956e761ed635f7e14c..0000000000000000000000000000000000000000
--- a/contrib/dict_xsyn/uninstall_dict_xsyn.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-/* contrib/dict_xsyn/uninstall_dict_xsyn.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP TEXT SEARCH DICTIONARY xsyn;
-
-DROP TEXT SEARCH TEMPLATE xsyn_template;
-
-DROP FUNCTION dxsyn_init(internal);
-
-DROP FUNCTION dxsyn_lexize(internal,internal,internal,internal);
diff --git a/contrib/earthdistance/.gitignore b/contrib/earthdistance/.gitignore
index 366a0a399e7cf1f5b3a7c941126f0e7ef9f93aac..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/earthdistance/.gitignore
+++ b/contrib/earthdistance/.gitignore
@@ -1,3 +1,2 @@
-/earthdistance.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/earthdistance/Makefile b/contrib/earthdistance/Makefile
index 8328e5f8285287427e9b69b4d875edea7af63ef7..49f6e6675fc67df745b62bb55356be99a7e5c6bd 100644
--- a/contrib/earthdistance/Makefile
+++ b/contrib/earthdistance/Makefile
@@ -1,8 +1,10 @@
 # contrib/earthdistance/Makefile
 
 MODULES = earthdistance
-DATA_built = earthdistance.sql
-DATA = uninstall_earthdistance.sql
+
+EXTENSION = earthdistance
+DATA = earthdistance--1.0.sql earthdistance--unpackaged--1.0.sql
+
 REGRESS = earthdistance
 
 LDFLAGS_SL += $(filter -lm, $(LIBS))
diff --git a/contrib/earthdistance/earthdistance.sql.in b/contrib/earthdistance/earthdistance--1.0.sql
similarity index 93%
rename from contrib/earthdistance/earthdistance.sql.in
rename to contrib/earthdistance/earthdistance--1.0.sql
index a4ce812584682a314fd06f7f64295c63ac14a77e..0a2af648de2c592aee1633360c29f66655eafcfd 100644
--- a/contrib/earthdistance/earthdistance.sql.in
+++ b/contrib/earthdistance/earthdistance--1.0.sql
@@ -1,9 +1,4 @@
-/* contrib/earthdistance/earthdistance.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
--- The earth functions rely on contrib/cube having been installed and loaded.
+/* contrib/earthdistance/earthdistance--1.0.sql */
 
 -- earth() returns the radius of the earth in meters. This is the only
 -- place you need to change things for the cube base distance functions
diff --git a/contrib/earthdistance/earthdistance--unpackaged--1.0.sql b/contrib/earthdistance/earthdistance--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..2d5919cc72d70b7bd0bf88628289e56a58fbafaa
--- /dev/null
+++ b/contrib/earthdistance/earthdistance--unpackaged--1.0.sql
@@ -0,0 +1,13 @@
+/* contrib/earthdistance/earthdistance--unpackaged--1.0.sql */
+
+ALTER EXTENSION earthdistance ADD function earth();
+ALTER EXTENSION earthdistance ADD type earth;
+ALTER EXTENSION earthdistance ADD function sec_to_gc(double precision);
+ALTER EXTENSION earthdistance ADD function gc_to_sec(double precision);
+ALTER EXTENSION earthdistance ADD function ll_to_earth(double precision,double precision);
+ALTER EXTENSION earthdistance ADD function latitude(earth);
+ALTER EXTENSION earthdistance ADD function longitude(earth);
+ALTER EXTENSION earthdistance ADD function earth_distance(earth,earth);
+ALTER EXTENSION earthdistance ADD function earth_box(earth,double precision);
+ALTER EXTENSION earthdistance ADD function geo_distance(point,point);
+ALTER EXTENSION earthdistance ADD operator <@>(point,point);
diff --git a/contrib/earthdistance/earthdistance.control b/contrib/earthdistance/earthdistance.control
new file mode 100644
index 0000000000000000000000000000000000000000..afd2ff4f95502ed1fb4ab09f390ca541d6f0496e
--- /dev/null
+++ b/contrib/earthdistance/earthdistance.control
@@ -0,0 +1,6 @@
+# earthdistance extension
+comment = 'calculate great-circle distances on the surface of the Earth'
+default_version = '1.0'
+module_pathname = '$libdir/earthdistance'
+relocatable = true
+requires = 'cube'
diff --git a/contrib/earthdistance/expected/earthdistance.out b/contrib/earthdistance/expected/earthdistance.out
index 5f5645b700fe07e7a7edd5f3a76fed1986a21091..8a3fc749c1cf4708b552f7e252fa14c68fe4d43d 100644
--- a/contrib/earthdistance/expected/earthdistance.out
+++ b/contrib/earthdistance/expected/earthdistance.out
@@ -1,13 +1,8 @@
 --
 --  Test earth distance functions
 --
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of earthdistance.sql or cube.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION cube;
+CREATE EXTENSION earthdistance;
 --
 -- The radius of the Earth we are using.
 --
diff --git a/contrib/earthdistance/sql/earthdistance.sql b/contrib/earthdistance/sql/earthdistance.sql
index ad68b5635dd6a33cd1a7872028cd52bdbd25590c..e494c350ce9d67d5937c2a766c2e06de46ccb0c5 100644
--- a/contrib/earthdistance/sql/earthdistance.sql
+++ b/contrib/earthdistance/sql/earthdistance.sql
@@ -2,16 +2,8 @@
 --  Test earth distance functions
 --
 
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of earthdistance.sql or cube.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i ../cube/cube.sql
-\i earthdistance.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION cube;
+CREATE EXTENSION earthdistance;
 
 --
 -- The radius of the Earth we are using.
diff --git a/contrib/earthdistance/uninstall_earthdistance.sql b/contrib/earthdistance/uninstall_earthdistance.sql
deleted file mode 100644
index dfd7d524ab7b13355a375e80ee1e607f29587731..0000000000000000000000000000000000000000
--- a/contrib/earthdistance/uninstall_earthdistance.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-/* contrib/earthdistance/uninstall_earthdistance.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR <@> (point, point);
-
-DROP FUNCTION geo_distance (point, point);
-
-DROP FUNCTION earth_box(earth, float8);
-
-DROP FUNCTION earth_distance(earth, earth);
-
-DROP FUNCTION longitude(earth);
-
-DROP FUNCTION latitude(earth);
-
-DROP FUNCTION ll_to_earth(float8, float8);
-
-DROP FUNCTION gc_to_sec(float8);
-
-DROP FUNCTION sec_to_gc(float8);
-
-DROP DOMAIN earth;
-
-DROP FUNCTION earth();
diff --git a/contrib/fuzzystrmatch/.gitignore b/contrib/fuzzystrmatch/.gitignore
deleted file mode 100644
index f4962c630bac00ba36929c1cc9a9809a4083b24d..0000000000000000000000000000000000000000
--- a/contrib/fuzzystrmatch/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/fuzzystrmatch.sql
diff --git a/contrib/fuzzystrmatch/Makefile b/contrib/fuzzystrmatch/Makefile
index 9cdf3f87e3e1ed850b2972cf9cc6a2b0ac530033..74728a30b567e1f4d311bfa707c410f34a3d0041 100644
--- a/contrib/fuzzystrmatch/Makefile
+++ b/contrib/fuzzystrmatch/Makefile
@@ -2,8 +2,9 @@
 
 MODULE_big = fuzzystrmatch
 OBJS = fuzzystrmatch.o dmetaphone.o
-DATA_built = fuzzystrmatch.sql
-DATA = uninstall_fuzzystrmatch.sql
+
+EXTENSION = fuzzystrmatch
+DATA = fuzzystrmatch--1.0.sql fuzzystrmatch--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.sql.in b/contrib/fuzzystrmatch/fuzzystrmatch--1.0.sql
similarity index 90%
rename from contrib/fuzzystrmatch/fuzzystrmatch.sql.in
rename to contrib/fuzzystrmatch/fuzzystrmatch--1.0.sql
index 0f2ea85e4894ea79b459cfd6ec16d76917c4cba5..1d27f5c3ddd7da3fb83e9826e283a2b2d9b73a1c 100644
--- a/contrib/fuzzystrmatch/fuzzystrmatch.sql.in
+++ b/contrib/fuzzystrmatch/fuzzystrmatch--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/fuzzystrmatch/fuzzystrmatch.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/fuzzystrmatch/fuzzystrmatch--1.0.sql */
 
 CREATE OR REPLACE FUNCTION levenshtein (text,text) RETURNS int
 AS 'MODULE_PATHNAME','levenshtein'
diff --git a/contrib/fuzzystrmatch/fuzzystrmatch--unpackaged--1.0.sql b/contrib/fuzzystrmatch/fuzzystrmatch--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..12077a84ae03cb7aacad6937f42d6ecefe0b6a12
--- /dev/null
+++ b/contrib/fuzzystrmatch/fuzzystrmatch--unpackaged--1.0.sql
@@ -0,0 +1,12 @@
+/* contrib/fuzzystrmatch/fuzzystrmatch--unpackaged--1.0.sql */
+
+ALTER EXTENSION fuzzystrmatch ADD function levenshtein(text,text);
+ALTER EXTENSION fuzzystrmatch ADD function levenshtein(text,text,integer,integer,integer);
+ALTER EXTENSION fuzzystrmatch ADD function levenshtein_less_equal(text,text,integer);
+ALTER EXTENSION fuzzystrmatch ADD function levenshtein_less_equal(text,text,integer,integer,integer,integer);
+ALTER EXTENSION fuzzystrmatch ADD function metaphone(text,integer);
+ALTER EXTENSION fuzzystrmatch ADD function soundex(text);
+ALTER EXTENSION fuzzystrmatch ADD function text_soundex(text);
+ALTER EXTENSION fuzzystrmatch ADD function difference(text,text);
+ALTER EXTENSION fuzzystrmatch ADD function dmetaphone(text);
+ALTER EXTENSION fuzzystrmatch ADD function dmetaphone_alt(text);
diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.control b/contrib/fuzzystrmatch/fuzzystrmatch.control
new file mode 100644
index 0000000000000000000000000000000000000000..e257f0961171e1ce1a56da142521cad1adc9d681
--- /dev/null
+++ b/contrib/fuzzystrmatch/fuzzystrmatch.control
@@ -0,0 +1,5 @@
+# fuzzystrmatch extension
+comment = 'determine similarities and distance between strings'
+default_version = '1.0'
+module_pathname = '$libdir/fuzzystrmatch'
+relocatable = true
diff --git a/contrib/fuzzystrmatch/uninstall_fuzzystrmatch.sql b/contrib/fuzzystrmatch/uninstall_fuzzystrmatch.sql
deleted file mode 100644
index a39c7bfc944690b091304b709fa84349a65d7aa2..0000000000000000000000000000000000000000
--- a/contrib/fuzzystrmatch/uninstall_fuzzystrmatch.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* contrib/fuzzystrmatch/uninstall_fuzzystrmatch.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION dmetaphone_alt (text);
-
-DROP FUNCTION dmetaphone (text);
-
-DROP FUNCTION difference(text,text);
-
-DROP FUNCTION text_soundex(text);
-
-DROP FUNCTION soundex(text);
-
-DROP FUNCTION metaphone (text,int);
-
-DROP FUNCTION levenshtein (text,text,int,int,int);
-
-DROP FUNCTION levenshtein (text,text);
-
-DROP FUNCTION levenshtein_less_equal (text,text,int);
-
-DROP FUNCTION levenshtein_less_equal (text,text,int,int,int,int);
diff --git a/contrib/hstore/.gitignore b/contrib/hstore/.gitignore
index d7af95330c380d468c35f781f34de30ea05709a5..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/hstore/.gitignore
+++ b/contrib/hstore/.gitignore
@@ -1,3 +1,2 @@
-/hstore.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/hstore/Makefile b/contrib/hstore/Makefile
index 1d533fdd60280b1e62610dd7b98cdfb4151de1b4..fce1a32328e8a12f1d495caf2ada480c0669bd38 100644
--- a/contrib/hstore/Makefile
+++ b/contrib/hstore/Makefile
@@ -4,8 +4,9 @@ MODULE_big = hstore
 OBJS = hstore_io.o hstore_op.o hstore_gist.o hstore_gin.o hstore_compat.o \
 	crc32.o
 
-DATA_built = hstore.sql
-DATA = uninstall_hstore.sql
+EXTENSION = hstore
+DATA = hstore--1.0.sql hstore--unpackaged--1.0.sql
+
 REGRESS = hstore
 
 ifdef USE_PGXS
diff --git a/contrib/hstore/expected/hstore.out b/contrib/hstore/expected/hstore.out
index 354fff20fe2b24127ac9ec1ae9a20f72d628e256..083faf8d9c433ba9f34a95f65fed64c0079a6561 100644
--- a/contrib/hstore/expected/hstore.out
+++ b/contrib/hstore/expected/hstore.out
@@ -1,12 +1,6 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of hstore.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-psql:hstore.sql:228: WARNING:  => is deprecated as an operator name
+CREATE EXTENSION hstore;
+WARNING:  => is deprecated as an operator name
 DETAIL:  This name may be disallowed altogether in future versions of PostgreSQL.
-RESET client_min_messages;
 set escape_string_warning=off;
 --hstore;
 select ''::hstore;
diff --git a/contrib/hstore/hstore.sql.in b/contrib/hstore/hstore--1.0.sql
similarity index 99%
rename from contrib/hstore/hstore.sql.in
rename to contrib/hstore/hstore--1.0.sql
index 5b39c189e112e57b245b878f64567af6fbd7347c..d77b14286bdce8af49bdad9620e00c5c4ce827fe 100644
--- a/contrib/hstore/hstore.sql.in
+++ b/contrib/hstore/hstore--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/hstore/hstore.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/hstore/hstore--1.0.sql */
 
 CREATE TYPE hstore;
 
diff --git a/contrib/hstore/hstore--unpackaged--1.0.sql b/contrib/hstore/hstore--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..0eb300ecf511607b8d6ba81839baba5ce255f376
--- /dev/null
+++ b/contrib/hstore/hstore--unpackaged--1.0.sql
@@ -0,0 +1,89 @@
+/* contrib/hstore/hstore--unpackaged--1.0.sql */
+
+ALTER EXTENSION hstore ADD type hstore;
+ALTER EXTENSION hstore ADD function hstore_in(cstring);
+ALTER EXTENSION hstore ADD function hstore_out(hstore);
+ALTER EXTENSION hstore ADD function hstore_recv(internal);
+ALTER EXTENSION hstore ADD function hstore_send(hstore);
+ALTER EXTENSION hstore ADD function hstore_version_diag(hstore);
+ALTER EXTENSION hstore ADD function fetchval(hstore,text);
+ALTER EXTENSION hstore ADD operator ->(hstore,text);
+ALTER EXTENSION hstore ADD function slice_array(hstore,text[]);
+ALTER EXTENSION hstore ADD operator ->(hstore,text[]);
+ALTER EXTENSION hstore ADD function slice(hstore,text[]);
+ALTER EXTENSION hstore ADD function isexists(hstore,text);
+ALTER EXTENSION hstore ADD function exist(hstore,text);
+ALTER EXTENSION hstore ADD operator ?(hstore,text);
+ALTER EXTENSION hstore ADD function exists_any(hstore,text[]);
+ALTER EXTENSION hstore ADD operator ?|(hstore,text[]);
+ALTER EXTENSION hstore ADD function exists_all(hstore,text[]);
+ALTER EXTENSION hstore ADD operator ?&(hstore,text[]);
+ALTER EXTENSION hstore ADD function isdefined(hstore,text);
+ALTER EXTENSION hstore ADD function defined(hstore,text);
+ALTER EXTENSION hstore ADD function delete(hstore,text);
+ALTER EXTENSION hstore ADD function delete(hstore,text[]);
+ALTER EXTENSION hstore ADD function delete(hstore,hstore);
+ALTER EXTENSION hstore ADD operator -(hstore,text);
+ALTER EXTENSION hstore ADD operator -(hstore,text[]);
+ALTER EXTENSION hstore ADD operator -(hstore,hstore);
+ALTER EXTENSION hstore ADD function hs_concat(hstore,hstore);
+ALTER EXTENSION hstore ADD operator ||(hstore,hstore);
+ALTER EXTENSION hstore ADD function hs_contains(hstore,hstore);
+ALTER EXTENSION hstore ADD function hs_contained(hstore,hstore);
+ALTER EXTENSION hstore ADD operator <@(hstore,hstore);
+ALTER EXTENSION hstore ADD operator @>(hstore,hstore);
+ALTER EXTENSION hstore ADD operator ~(hstore,hstore);
+ALTER EXTENSION hstore ADD operator @(hstore,hstore);
+ALTER EXTENSION hstore ADD function tconvert(text,text);
+ALTER EXTENSION hstore ADD function hstore(text,text);
+ALTER EXTENSION hstore ADD operator =>(text,text);
+ALTER EXTENSION hstore ADD function hstore(text[],text[]);
+ALTER EXTENSION hstore ADD function hstore(text[]);
+ALTER EXTENSION hstore ADD cast (text[] as hstore);
+ALTER EXTENSION hstore ADD function hstore(record);
+ALTER EXTENSION hstore ADD function hstore_to_array(hstore);
+ALTER EXTENSION hstore ADD operator %%(NONE,hstore);
+ALTER EXTENSION hstore ADD function hstore_to_matrix(hstore);
+ALTER EXTENSION hstore ADD operator %#(NONE,hstore);
+ALTER EXTENSION hstore ADD function akeys(hstore);
+ALTER EXTENSION hstore ADD function avals(hstore);
+ALTER EXTENSION hstore ADD function skeys(hstore);
+ALTER EXTENSION hstore ADD function svals(hstore);
+ALTER EXTENSION hstore ADD function each(hstore);
+ALTER EXTENSION hstore ADD function populate_record(anyelement,hstore);
+ALTER EXTENSION hstore ADD operator #=(anyelement,hstore);
+ALTER EXTENSION hstore ADD function hstore_eq(hstore,hstore);
+ALTER EXTENSION hstore ADD function hstore_ne(hstore,hstore);
+ALTER EXTENSION hstore ADD function hstore_gt(hstore,hstore);
+ALTER EXTENSION hstore ADD function hstore_ge(hstore,hstore);
+ALTER EXTENSION hstore ADD function hstore_lt(hstore,hstore);
+ALTER EXTENSION hstore ADD function hstore_le(hstore,hstore);
+ALTER EXTENSION hstore ADD function hstore_cmp(hstore,hstore);
+ALTER EXTENSION hstore ADD operator <>(hstore,hstore);
+ALTER EXTENSION hstore ADD operator =(hstore,hstore);
+ALTER EXTENSION hstore ADD operator #>#(hstore,hstore);
+ALTER EXTENSION hstore ADD operator #>=#(hstore,hstore);
+ALTER EXTENSION hstore ADD operator #<#(hstore,hstore);
+ALTER EXTENSION hstore ADD operator #<=#(hstore,hstore);
+ALTER EXTENSION hstore ADD operator family btree_hstore_ops using btree;
+ALTER EXTENSION hstore ADD operator class btree_hstore_ops using btree;
+ALTER EXTENSION hstore ADD function hstore_hash(hstore);
+ALTER EXTENSION hstore ADD operator family hash_hstore_ops using hash;
+ALTER EXTENSION hstore ADD operator class hash_hstore_ops using hash;
+ALTER EXTENSION hstore ADD type ghstore;
+ALTER EXTENSION hstore ADD function ghstore_in(cstring);
+ALTER EXTENSION hstore ADD function ghstore_out(ghstore);
+ALTER EXTENSION hstore ADD function ghstore_compress(internal);
+ALTER EXTENSION hstore ADD function ghstore_decompress(internal);
+ALTER EXTENSION hstore ADD function ghstore_penalty(internal,internal,internal);
+ALTER EXTENSION hstore ADD function ghstore_picksplit(internal,internal);
+ALTER EXTENSION hstore ADD function ghstore_union(internal,internal);
+ALTER EXTENSION hstore ADD function ghstore_same(internal,internal,internal);
+ALTER EXTENSION hstore ADD function ghstore_consistent(internal,internal,integer,oid,internal);
+ALTER EXTENSION hstore ADD operator family gist_hstore_ops using gist;
+ALTER EXTENSION hstore ADD operator class gist_hstore_ops using gist;
+ALTER EXTENSION hstore ADD function gin_extract_hstore(internal,internal);
+ALTER EXTENSION hstore ADD function gin_extract_hstore_query(internal,internal,smallint,internal,internal);
+ALTER EXTENSION hstore ADD function gin_consistent_hstore(internal,smallint,internal,integer,internal,internal);
+ALTER EXTENSION hstore ADD operator family gin_hstore_ops using gin;
+ALTER EXTENSION hstore ADD operator class gin_hstore_ops using gin;
diff --git a/contrib/hstore/hstore.control b/contrib/hstore/hstore.control
new file mode 100644
index 0000000000000000000000000000000000000000..0a57b3487b4392ba73884979d665a6a892b38ebf
--- /dev/null
+++ b/contrib/hstore/hstore.control
@@ -0,0 +1,5 @@
+# hstore extension
+comment = 'store sets of (key, value) pairs'
+default_version = '1.0'
+module_pathname = '$libdir/hstore'
+relocatable = true
diff --git a/contrib/hstore/sql/hstore.sql b/contrib/hstore/sql/hstore.sql
index 58a79675267aecc63ff8f50fe8bdd33ec44c567b..fb6bb59f8a0045b778d6a9bf2e72f7a036752383 100644
--- a/contrib/hstore/sql/hstore.sql
+++ b/contrib/hstore/sql/hstore.sql
@@ -1,12 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of hstore.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i hstore.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION hstore;
 
 set escape_string_warning=off;
 
diff --git a/contrib/hstore/uninstall_hstore.sql b/contrib/hstore/uninstall_hstore.sql
deleted file mode 100644
index a03e43164f8b315b2fccb533adc3034c0124bb07..0000000000000000000000000000000000000000
--- a/contrib/hstore/uninstall_hstore.sql
+++ /dev/null
@@ -1,86 +0,0 @@
-/* contrib/hstore/uninstall_hstore.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR CLASS gist_hstore_ops USING gist CASCADE;
-DROP OPERATOR CLASS gin_hstore_ops USING gin CASCADE;
-DROP OPERATOR CLASS hash_hstore_ops USING hash CASCADE;
-DROP OPERATOR CLASS btree_hstore_ops USING btree CASCADE;
-
-DROP OPERATOR -  ( hstore, text );
-DROP OPERATOR -  ( hstore, text[] );
-DROP OPERATOR -  ( hstore, hstore );
-DROP OPERATOR ?  ( hstore, text );
-DROP OPERATOR ?& ( hstore, text[] );
-DROP OPERATOR ?| ( hstore, text[] );
-DROP OPERATOR -> ( hstore, text );
-DROP OPERATOR -> ( hstore, text[] );
-DROP OPERATOR || ( hstore, hstore );
-DROP OPERATOR @> ( hstore, hstore );
-DROP OPERATOR <@ ( hstore, hstore );
-DROP OPERATOR @  ( hstore, hstore );
-DROP OPERATOR ~  ( hstore, hstore );
-DROP OPERATOR => ( text, text );
-DROP OPERATOR #= ( anyelement, hstore );
-DROP OPERATOR %% ( NONE, hstore );
-DROP OPERATOR %# ( NONE, hstore );
-DROP OPERATOR =  ( hstore, hstore );
-DROP OPERATOR <> ( hstore, hstore );
-DROP OPERATOR #<#  ( hstore, hstore );
-DROP OPERATOR #<=# ( hstore, hstore );
-DROP OPERATOR #>#  ( hstore, hstore );
-DROP OPERATOR #>=# ( hstore, hstore );
-
-DROP CAST (text[] AS hstore);
-
-DROP FUNCTION hstore_eq(hstore,hstore);
-DROP FUNCTION hstore_ne(hstore,hstore);
-DROP FUNCTION hstore_gt(hstore,hstore);
-DROP FUNCTION hstore_ge(hstore,hstore);
-DROP FUNCTION hstore_lt(hstore,hstore);
-DROP FUNCTION hstore_le(hstore,hstore);
-DROP FUNCTION hstore_cmp(hstore,hstore);
-DROP FUNCTION hstore_hash(hstore);
-DROP FUNCTION slice_array(hstore,text[]);
-DROP FUNCTION slice(hstore,text[]);
-DROP FUNCTION fetchval(hstore,text);
-DROP FUNCTION isexists(hstore,text);
-DROP FUNCTION exist(hstore,text);
-DROP FUNCTION exists_any(hstore,text[]);
-DROP FUNCTION exists_all(hstore,text[]);
-DROP FUNCTION isdefined(hstore,text);
-DROP FUNCTION defined(hstore,text);
-DROP FUNCTION delete(hstore,text);
-DROP FUNCTION delete(hstore,text[]);
-DROP FUNCTION delete(hstore,hstore);
-DROP FUNCTION hs_concat(hstore,hstore);
-DROP FUNCTION hs_contains(hstore,hstore);
-DROP FUNCTION hs_contained(hstore,hstore);
-DROP FUNCTION tconvert(text,text);
-DROP FUNCTION hstore(text,text);
-DROP FUNCTION hstore(text[],text[]);
-DROP FUNCTION hstore_to_array(hstore);
-DROP FUNCTION hstore_to_matrix(hstore);
-DROP FUNCTION hstore(record);
-DROP FUNCTION hstore(text[]);
-DROP FUNCTION akeys(hstore);
-DROP FUNCTION avals(hstore);
-DROP FUNCTION skeys(hstore);
-DROP FUNCTION svals(hstore);
-DROP FUNCTION each(hstore);
-DROP FUNCTION populate_record(anyelement,hstore);
-DROP FUNCTION ghstore_compress(internal);
-DROP FUNCTION ghstore_decompress(internal);
-DROP FUNCTION ghstore_penalty(internal,internal,internal);
-DROP FUNCTION ghstore_picksplit(internal, internal);
-DROP FUNCTION ghstore_union(internal, internal);
-DROP FUNCTION ghstore_same(internal, internal, internal);
-DROP FUNCTION ghstore_consistent(internal,internal,int,oid,internal);
-DROP FUNCTION gin_consistent_hstore(internal, int2, internal, int4, internal, internal);
-DROP FUNCTION gin_extract_hstore(internal, internal);
-DROP FUNCTION gin_extract_hstore_query(internal, internal, smallint, internal, internal);
-DROP FUNCTION hstore_version_diag(hstore);
-
-DROP TYPE hstore CASCADE;
-DROP TYPE ghstore CASCADE;
diff --git a/contrib/intagg/Makefile b/contrib/intagg/Makefile
index 9bb1866e78703cd8a754f52ee2c3dbf082c95e18..372c0919a70103688e3902520ebda8c33b450a12 100644
--- a/contrib/intagg/Makefile
+++ b/contrib/intagg/Makefile
@@ -1,6 +1,7 @@
 # contrib/intagg/Makefile
 
-DATA = int_aggregate.sql uninstall_int_aggregate.sql
+EXTENSION = int_aggregate
+DATA = int_aggregate--1.0.sql int_aggregate--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/intagg/int_aggregate.sql b/contrib/intagg/int_aggregate--1.0.sql
similarity index 87%
rename from contrib/intagg/int_aggregate.sql
rename to contrib/intagg/int_aggregate--1.0.sql
index 289e41b671a1ac6771d88caedc3352a77f6d4ab3..3df72c18cf176273d2bec955407bc114268c3cf0 100644
--- a/contrib/intagg/int_aggregate.sql
+++ b/contrib/intagg/int_aggregate--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/intagg/int_aggregate.sql */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/intagg/int_aggregate--1.0.sql */
 
 -- Internal function for the aggregate
 -- Is called for each item in an aggregation
diff --git a/contrib/intagg/int_aggregate--unpackaged--1.0.sql b/contrib/intagg/int_aggregate--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..0bc874e64594111a61acbf3b42f4893c4dc9b1a9
--- /dev/null
+++ b/contrib/intagg/int_aggregate--unpackaged--1.0.sql
@@ -0,0 +1,6 @@
+/* contrib/intagg/int_aggregate--unpackaged--1.0.sql */
+
+ALTER EXTENSION int_aggregate ADD function int_agg_state(internal,integer);
+ALTER EXTENSION int_aggregate ADD function int_agg_final_array(internal);
+ALTER EXTENSION int_aggregate ADD function int_array_aggregate(integer);
+ALTER EXTENSION int_aggregate ADD function int_array_enum(integer[]);
diff --git a/contrib/intagg/int_aggregate.control b/contrib/intagg/int_aggregate.control
new file mode 100644
index 0000000000000000000000000000000000000000..f8e47d5a7fde9e520cf513ea1264c1bf4af6f092
--- /dev/null
+++ b/contrib/intagg/int_aggregate.control
@@ -0,0 +1,4 @@
+# int_aggregate extension
+comment = 'integer aggregator and enumerator (obsolete)'
+default_version = '1.0'
+relocatable = true
diff --git a/contrib/intagg/uninstall_int_aggregate.sql b/contrib/intagg/uninstall_int_aggregate.sql
deleted file mode 100644
index 2e553453250f1fc014da6b5594ae1daa857ec932..0000000000000000000000000000000000000000
--- a/contrib/intagg/uninstall_int_aggregate.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-/* contrib/intagg/uninstall_int_aggregate.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION int_array_enum(int4[]);
-
-DROP AGGREGATE int_array_aggregate (int4);
-
-DROP FUNCTION int_agg_final_array (internal);
-
-DROP FUNCTION int_agg_state (internal, int4);
diff --git a/contrib/intarray/.gitignore b/contrib/intarray/.gitignore
index 761a9b260743d5d85d29b5baadd755395b9a8131..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/intarray/.gitignore
+++ b/contrib/intarray/.gitignore
@@ -1,3 +1,2 @@
-/_int.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/intarray/Makefile b/contrib/intarray/Makefile
index a10d7c6b1f9d353df0f2ce594d813f523a33ab2c..71f820ec4a8cabba828177cb9a909775f3d32508 100644
--- a/contrib/intarray/Makefile
+++ b/contrib/intarray/Makefile
@@ -2,8 +2,10 @@
 
 MODULE_big = _int
 OBJS = _int_bool.o _int_gist.o _int_op.o _int_tool.o _intbig_gist.o _int_gin.o
-DATA_built = _int.sql
-DATA = uninstall__int.sql
+
+EXTENSION = intarray
+DATA = intarray--1.0.sql intarray--unpackaged--1.0.sql
+
 REGRESS = _int
 
 ifdef USE_PGXS
diff --git a/contrib/intarray/expected/_int.out b/contrib/intarray/expected/_int.out
index 596439d3149dca3687605ccd3ce4715bd93cd057..6ed3cc6ced096e2e97665e76ceba7fc139415029 100644
--- a/contrib/intarray/expected/_int.out
+++ b/contrib/intarray/expected/_int.out
@@ -1,10 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of _int.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION intarray;
 SELECT intset(1234);
  intset 
 --------
diff --git a/contrib/intarray/_int.sql.in b/contrib/intarray/intarray--1.0.sql
similarity index 98%
rename from contrib/intarray/_int.sql.in
rename to contrib/intarray/intarray--1.0.sql
index ad224e319bcc9c6f0df6600d709a66cf35c36ea3..5f86ee607f11725e9e69b774064f48fefbcb9546 100644
--- a/contrib/intarray/_int.sql.in
+++ b/contrib/intarray/intarray--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/intarray/_int.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/intarray/intarray--1.0.sql */
 
 --
 -- Create the user-defined type for the 1-D integer arrays (_int4)
diff --git a/contrib/intarray/intarray--unpackaged--1.0.sql b/contrib/intarray/intarray--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..7fd739b0ed44e71cd9b2acdd745709a67f91c55f
--- /dev/null
+++ b/contrib/intarray/intarray--unpackaged--1.0.sql
@@ -0,0 +1,71 @@
+/* contrib/intarray/intarray--unpackaged--1.0.sql */
+
+ALTER EXTENSION intarray ADD type query_int;
+ALTER EXTENSION intarray ADD function bqarr_in(cstring);
+ALTER EXTENSION intarray ADD function bqarr_out(query_int);
+ALTER EXTENSION intarray ADD function querytree(query_int);
+ALTER EXTENSION intarray ADD function boolop(integer[],query_int);
+ALTER EXTENSION intarray ADD function rboolop(query_int,integer[]);
+ALTER EXTENSION intarray ADD operator ~~(query_int,integer[]);
+ALTER EXTENSION intarray ADD operator @@(integer[],query_int);
+ALTER EXTENSION intarray ADD function _int_contains(integer[],integer[]);
+ALTER EXTENSION intarray ADD function _int_contained(integer[],integer[]);
+ALTER EXTENSION intarray ADD function _int_overlap(integer[],integer[]);
+ALTER EXTENSION intarray ADD function _int_same(integer[],integer[]);
+ALTER EXTENSION intarray ADD function _int_different(integer[],integer[]);
+ALTER EXTENSION intarray ADD function _int_union(integer[],integer[]);
+ALTER EXTENSION intarray ADD function _int_inter(integer[],integer[]);
+ALTER EXTENSION intarray ADD operator &&(integer[],integer[]);
+ALTER EXTENSION intarray ADD operator <@(integer[],integer[]);
+ALTER EXTENSION intarray ADD operator @>(integer[],integer[]);
+ALTER EXTENSION intarray ADD operator ~(integer[],integer[]);
+ALTER EXTENSION intarray ADD operator @(integer[],integer[]);
+ALTER EXTENSION intarray ADD function intset(integer);
+ALTER EXTENSION intarray ADD function icount(integer[]);
+ALTER EXTENSION intarray ADD operator #(NONE,integer[]);
+ALTER EXTENSION intarray ADD function sort(integer[],text);
+ALTER EXTENSION intarray ADD function sort(integer[]);
+ALTER EXTENSION intarray ADD function sort_asc(integer[]);
+ALTER EXTENSION intarray ADD function sort_desc(integer[]);
+ALTER EXTENSION intarray ADD function uniq(integer[]);
+ALTER EXTENSION intarray ADD function idx(integer[],integer);
+ALTER EXTENSION intarray ADD operator #(integer[],integer);
+ALTER EXTENSION intarray ADD function subarray(integer[],integer,integer);
+ALTER EXTENSION intarray ADD function subarray(integer[],integer);
+ALTER EXTENSION intarray ADD function intarray_push_elem(integer[],integer);
+ALTER EXTENSION intarray ADD operator +(integer[],integer);
+ALTER EXTENSION intarray ADD function intarray_push_array(integer[],integer[]);
+ALTER EXTENSION intarray ADD operator +(integer[],integer[]);
+ALTER EXTENSION intarray ADD function intarray_del_elem(integer[],integer);
+ALTER EXTENSION intarray ADD operator -(integer[],integer);
+ALTER EXTENSION intarray ADD function intset_union_elem(integer[],integer);
+ALTER EXTENSION intarray ADD operator |(integer[],integer);
+ALTER EXTENSION intarray ADD operator |(integer[],integer[]);
+ALTER EXTENSION intarray ADD function intset_subtract(integer[],integer[]);
+ALTER EXTENSION intarray ADD operator -(integer[],integer[]);
+ALTER EXTENSION intarray ADD operator &(integer[],integer[]);
+ALTER EXTENSION intarray ADD function g_int_consistent(internal,integer[],integer,oid,internal);
+ALTER EXTENSION intarray ADD function g_int_compress(internal);
+ALTER EXTENSION intarray ADD function g_int_decompress(internal);
+ALTER EXTENSION intarray ADD function g_int_penalty(internal,internal,internal);
+ALTER EXTENSION intarray ADD function g_int_picksplit(internal,internal);
+ALTER EXTENSION intarray ADD function g_int_union(internal,internal);
+ALTER EXTENSION intarray ADD function g_int_same(integer[],integer[],internal);
+ALTER EXTENSION intarray ADD operator family gist__int_ops using gist;
+ALTER EXTENSION intarray ADD operator class gist__int_ops using gist;
+ALTER EXTENSION intarray ADD type intbig_gkey;
+ALTER EXTENSION intarray ADD function _intbig_in(cstring);
+ALTER EXTENSION intarray ADD function _intbig_out(intbig_gkey);
+ALTER EXTENSION intarray ADD function g_intbig_consistent(internal,internal,integer,oid,internal);
+ALTER EXTENSION intarray ADD function g_intbig_compress(internal);
+ALTER EXTENSION intarray ADD function g_intbig_decompress(internal);
+ALTER EXTENSION intarray ADD function g_intbig_penalty(internal,internal,internal);
+ALTER EXTENSION intarray ADD function g_intbig_picksplit(internal,internal);
+ALTER EXTENSION intarray ADD function g_intbig_union(internal,internal);
+ALTER EXTENSION intarray ADD function g_intbig_same(internal,internal,internal);
+ALTER EXTENSION intarray ADD operator family gist__intbig_ops using gist;
+ALTER EXTENSION intarray ADD operator class gist__intbig_ops using gist;
+ALTER EXTENSION intarray ADD function ginint4_queryextract(internal,internal,smallint,internal,internal,internal,internal);
+ALTER EXTENSION intarray ADD function ginint4_consistent(internal,smallint,internal,integer,internal,internal,internal,internal);
+ALTER EXTENSION intarray ADD operator family gin__int_ops using gin;
+ALTER EXTENSION intarray ADD operator class gin__int_ops using gin;
diff --git a/contrib/intarray/intarray.control b/contrib/intarray/intarray.control
new file mode 100644
index 0000000000000000000000000000000000000000..7b3d4f78f053adc3c046f77d45f1bdb78cd54498
--- /dev/null
+++ b/contrib/intarray/intarray.control
@@ -0,0 +1,5 @@
+# intarray extension
+comment = 'functions, operators, and index support for 1-D arrays of integers'
+default_version = '1.0'
+module_pathname = '$libdir/_int'
+relocatable = true
diff --git a/contrib/intarray/sql/_int.sql b/contrib/intarray/sql/_int.sql
index 1588e3b5145e2b65bd09ec34775c02dcbf6747b2..b60e936dc520d8308bd16e50681f061dc86e2dfe 100644
--- a/contrib/intarray/sql/_int.sql
+++ b/contrib/intarray/sql/_int.sql
@@ -1,12 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of _int.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i _int.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION intarray;
 
 SELECT intset(1234);
 SELECT icount('{1234234,234234}');
diff --git a/contrib/intarray/uninstall__int.sql b/contrib/intarray/uninstall__int.sql
deleted file mode 100644
index 345ad4464bd3fadef3378ae473d8ade4b880ef73..0000000000000000000000000000000000000000
--- a/contrib/intarray/uninstall__int.sql
+++ /dev/null
@@ -1,128 +0,0 @@
-/* contrib/intarray/uninstall__int.sql */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
-DROP OPERATOR CLASS gin__int_ops USING gin;
-
-DROP FUNCTION ginint4_queryextract(internal, internal, int2, internal, internal, internal, internal);
-
-DROP FUNCTION ginint4_consistent(internal, int2, internal, int4, internal, internal, internal, internal);
-
-DROP OPERATOR CLASS gist__intbig_ops USING gist;
-
-DROP FUNCTION g_intbig_same(internal, internal, internal);
-
-DROP FUNCTION g_intbig_union(internal, internal);
-
-DROP FUNCTION g_intbig_picksplit(internal, internal);
-
-DROP FUNCTION g_intbig_penalty(internal,internal,internal);
-
-DROP FUNCTION g_intbig_decompress(internal);
-
-DROP FUNCTION g_intbig_compress(internal);
-
-DROP FUNCTION g_intbig_consistent(internal,internal,int,oid,internal);
-
-DROP TYPE intbig_gkey CASCADE;
-
-DROP OPERATOR CLASS gist__int_ops USING gist;
-
-DROP FUNCTION g_int_same(_int4, _int4, internal);
-
-DROP FUNCTION g_int_union(internal, internal);
-
-DROP FUNCTION g_int_picksplit(internal, internal);
-
-DROP FUNCTION g_int_penalty(internal,internal,internal);
-
-DROP FUNCTION g_int_decompress(internal);
-
-DROP FUNCTION g_int_compress(internal);
-
-DROP FUNCTION g_int_consistent(internal,_int4,int,oid,internal);
-
-DROP OPERATOR & (_int4, _int4);
-
-DROP OPERATOR - (_int4, _int4);
-
-DROP FUNCTION intset_subtract(_int4, _int4);
-
-DROP OPERATOR | (_int4, _int4);
-
-DROP OPERATOR | (_int4, int4);
-
-DROP FUNCTION intset_union_elem(_int4, int4);
-
-DROP OPERATOR - (_int4, int4);
-
-DROP FUNCTION intarray_del_elem(_int4, int4);
-
-DROP OPERATOR + (_int4, _int4);
-
-DROP FUNCTION intarray_push_array(_int4, _int4);
-
-DROP OPERATOR + (_int4, int4);
-
-DROP FUNCTION intarray_push_elem(_int4, int4);
-
-DROP FUNCTION subarray(_int4, int4);
-
-DROP FUNCTION subarray(_int4, int4, int4);
-
-DROP OPERATOR # (_int4, int4);
-
-DROP FUNCTION idx(_int4, int4);
-
-DROP FUNCTION uniq(_int4);
-
-DROP FUNCTION sort_desc(_int4);
-
-DROP FUNCTION sort_asc(_int4);
-
-DROP FUNCTION sort(_int4);
-
-DROP FUNCTION sort(_int4, text);
-
-DROP OPERATOR # (NONE, _int4);
-
-DROP FUNCTION icount(_int4);
-
-DROP FUNCTION intset(int4);
-
-DROP OPERATOR <@ (_int4, _int4);
-
-DROP OPERATOR @> (_int4, _int4);
-
-DROP OPERATOR ~ (_int4, _int4);
-
-DROP OPERATOR @ (_int4, _int4);
-
-DROP OPERATOR && (_int4, _int4);
-
-DROP FUNCTION _int_inter(_int4, _int4);
-
-DROP FUNCTION _int_union(_int4, _int4);
-
-DROP FUNCTION _int_different(_int4, _int4);
-
-DROP FUNCTION _int_same(_int4, _int4);
-
-DROP FUNCTION _int_overlap(_int4, _int4);
-
-DROP FUNCTION _int_contained(_int4, _int4);
-
-DROP FUNCTION _int_contains(_int4, _int4);
-
-DROP OPERATOR ~~ (query_int, _int4);
-
-DROP OPERATOR @@ (_int4, query_int);
-
-DROP FUNCTION rboolop(query_int, _int4);
-
-DROP FUNCTION boolop(_int4, query_int);
-
-DROP FUNCTION querytree(query_int);
-
-DROP TYPE query_int CASCADE;
diff --git a/contrib/isn/.gitignore b/contrib/isn/.gitignore
deleted file mode 100644
index 1df12e3b7534738470bd30e430c4f610f9732728..0000000000000000000000000000000000000000
--- a/contrib/isn/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/isn.sql
diff --git a/contrib/isn/Makefile b/contrib/isn/Makefile
index ae33b758fbcc62ebdf850d0ed11b370b4c50e92b..bd8f193e9383f973f6a38af13bea05233f5797a6 100644
--- a/contrib/isn/Makefile
+++ b/contrib/isn/Makefile
@@ -1,8 +1,9 @@
 # contrib/isn/Makefile
 
 MODULES = isn
-DATA_built = isn.sql
-DATA = uninstall_isn.sql
+
+EXTENSION = isn
+DATA = isn--1.0.sql isn--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/isn/isn.sql.in b/contrib/isn/isn--1.0.sql
similarity index 99%
rename from contrib/isn/isn.sql.in
rename to contrib/isn/isn--1.0.sql
index 8f73c5c497ca64cd0823cd76cc9245b0be7b4a83..a6499f267a5dde0ea920a27f44219a69c95fdb2c 100644
--- a/contrib/isn/isn.sql.in
+++ b/contrib/isn/isn--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/isn/isn.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/isn/isn--1.0.sql */
 
 -- Example:
 --   create table test ( id isbn );
diff --git a/contrib/isn/isn--unpackaged--1.0.sql b/contrib/isn/isn--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..6130a43e5157f6bd264b4135562a24719c9252e6
--- /dev/null
+++ b/contrib/isn/isn--unpackaged--1.0.sql
@@ -0,0 +1,461 @@
+/* contrib/isn/isn--unpackaged--1.0.sql */
+
+ALTER EXTENSION isn ADD type ean13;
+ALTER EXTENSION isn ADD function ean13_in(cstring);
+ALTER EXTENSION isn ADD function ean13_out(ean13);
+ALTER EXTENSION isn ADD type isbn13;
+ALTER EXTENSION isn ADD function isbn13_in(cstring);
+ALTER EXTENSION isn ADD function ean13_out(isbn13);
+ALTER EXTENSION isn ADD type ismn13;
+ALTER EXTENSION isn ADD function ismn13_in(cstring);
+ALTER EXTENSION isn ADD function ean13_out(ismn13);
+ALTER EXTENSION isn ADD type issn13;
+ALTER EXTENSION isn ADD function issn13_in(cstring);
+ALTER EXTENSION isn ADD function ean13_out(issn13);
+ALTER EXTENSION isn ADD type isbn;
+ALTER EXTENSION isn ADD function isbn_in(cstring);
+ALTER EXTENSION isn ADD function isn_out(isbn);
+ALTER EXTENSION isn ADD type ismn;
+ALTER EXTENSION isn ADD function ismn_in(cstring);
+ALTER EXTENSION isn ADD function isn_out(ismn);
+ALTER EXTENSION isn ADD type issn;
+ALTER EXTENSION isn ADD function issn_in(cstring);
+ALTER EXTENSION isn ADD function isn_out(issn);
+ALTER EXTENSION isn ADD type upc;
+ALTER EXTENSION isn ADD function upc_in(cstring);
+ALTER EXTENSION isn ADD function isn_out(upc);
+ALTER EXTENSION isn ADD function isnlt(ean13,ean13);
+ALTER EXTENSION isn ADD function isnle(ean13,ean13);
+ALTER EXTENSION isn ADD function isneq(ean13,ean13);
+ALTER EXTENSION isn ADD function isnge(ean13,ean13);
+ALTER EXTENSION isn ADD function isngt(ean13,ean13);
+ALTER EXTENSION isn ADD function isnne(ean13,ean13);
+ALTER EXTENSION isn ADD function isnlt(ean13,isbn13);
+ALTER EXTENSION isn ADD function isnle(ean13,isbn13);
+ALTER EXTENSION isn ADD function isneq(ean13,isbn13);
+ALTER EXTENSION isn ADD function isnge(ean13,isbn13);
+ALTER EXTENSION isn ADD function isngt(ean13,isbn13);
+ALTER EXTENSION isn ADD function isnne(ean13,isbn13);
+ALTER EXTENSION isn ADD function isnlt(ean13,ismn13);
+ALTER EXTENSION isn ADD function isnle(ean13,ismn13);
+ALTER EXTENSION isn ADD function isneq(ean13,ismn13);
+ALTER EXTENSION isn ADD function isnge(ean13,ismn13);
+ALTER EXTENSION isn ADD function isngt(ean13,ismn13);
+ALTER EXTENSION isn ADD function isnne(ean13,ismn13);
+ALTER EXTENSION isn ADD function isnlt(ean13,issn13);
+ALTER EXTENSION isn ADD function isnle(ean13,issn13);
+ALTER EXTENSION isn ADD function isneq(ean13,issn13);
+ALTER EXTENSION isn ADD function isnge(ean13,issn13);
+ALTER EXTENSION isn ADD function isngt(ean13,issn13);
+ALTER EXTENSION isn ADD function isnne(ean13,issn13);
+ALTER EXTENSION isn ADD function isnlt(ean13,isbn);
+ALTER EXTENSION isn ADD function isnle(ean13,isbn);
+ALTER EXTENSION isn ADD function isneq(ean13,isbn);
+ALTER EXTENSION isn ADD function isnge(ean13,isbn);
+ALTER EXTENSION isn ADD function isngt(ean13,isbn);
+ALTER EXTENSION isn ADD function isnne(ean13,isbn);
+ALTER EXTENSION isn ADD function isnlt(ean13,ismn);
+ALTER EXTENSION isn ADD function isnle(ean13,ismn);
+ALTER EXTENSION isn ADD function isneq(ean13,ismn);
+ALTER EXTENSION isn ADD function isnge(ean13,ismn);
+ALTER EXTENSION isn ADD function isngt(ean13,ismn);
+ALTER EXTENSION isn ADD function isnne(ean13,ismn);
+ALTER EXTENSION isn ADD function isnlt(ean13,issn);
+ALTER EXTENSION isn ADD function isnle(ean13,issn);
+ALTER EXTENSION isn ADD function isneq(ean13,issn);
+ALTER EXTENSION isn ADD function isnge(ean13,issn);
+ALTER EXTENSION isn ADD function isngt(ean13,issn);
+ALTER EXTENSION isn ADD function isnne(ean13,issn);
+ALTER EXTENSION isn ADD function isnlt(ean13,upc);
+ALTER EXTENSION isn ADD function isnle(ean13,upc);
+ALTER EXTENSION isn ADD function isneq(ean13,upc);
+ALTER EXTENSION isn ADD function isnge(ean13,upc);
+ALTER EXTENSION isn ADD function isngt(ean13,upc);
+ALTER EXTENSION isn ADD function isnne(ean13,upc);
+ALTER EXTENSION isn ADD function isnlt(isbn13,isbn13);
+ALTER EXTENSION isn ADD function isnle(isbn13,isbn13);
+ALTER EXTENSION isn ADD function isneq(isbn13,isbn13);
+ALTER EXTENSION isn ADD function isnge(isbn13,isbn13);
+ALTER EXTENSION isn ADD function isngt(isbn13,isbn13);
+ALTER EXTENSION isn ADD function isnne(isbn13,isbn13);
+ALTER EXTENSION isn ADD function isnlt(isbn13,isbn);
+ALTER EXTENSION isn ADD function isnle(isbn13,isbn);
+ALTER EXTENSION isn ADD function isneq(isbn13,isbn);
+ALTER EXTENSION isn ADD function isnge(isbn13,isbn);
+ALTER EXTENSION isn ADD function isngt(isbn13,isbn);
+ALTER EXTENSION isn ADD function isnne(isbn13,isbn);
+ALTER EXTENSION isn ADD function isnlt(isbn13,ean13);
+ALTER EXTENSION isn ADD function isnle(isbn13,ean13);
+ALTER EXTENSION isn ADD function isneq(isbn13,ean13);
+ALTER EXTENSION isn ADD function isnge(isbn13,ean13);
+ALTER EXTENSION isn ADD function isngt(isbn13,ean13);
+ALTER EXTENSION isn ADD function isnne(isbn13,ean13);
+ALTER EXTENSION isn ADD function isnlt(isbn,isbn);
+ALTER EXTENSION isn ADD function isnle(isbn,isbn);
+ALTER EXTENSION isn ADD function isneq(isbn,isbn);
+ALTER EXTENSION isn ADD function isnge(isbn,isbn);
+ALTER EXTENSION isn ADD function isngt(isbn,isbn);
+ALTER EXTENSION isn ADD function isnne(isbn,isbn);
+ALTER EXTENSION isn ADD function isnlt(isbn,isbn13);
+ALTER EXTENSION isn ADD function isnle(isbn,isbn13);
+ALTER EXTENSION isn ADD function isneq(isbn,isbn13);
+ALTER EXTENSION isn ADD function isnge(isbn,isbn13);
+ALTER EXTENSION isn ADD function isngt(isbn,isbn13);
+ALTER EXTENSION isn ADD function isnne(isbn,isbn13);
+ALTER EXTENSION isn ADD function isnlt(isbn,ean13);
+ALTER EXTENSION isn ADD function isnle(isbn,ean13);
+ALTER EXTENSION isn ADD function isneq(isbn,ean13);
+ALTER EXTENSION isn ADD function isnge(isbn,ean13);
+ALTER EXTENSION isn ADD function isngt(isbn,ean13);
+ALTER EXTENSION isn ADD function isnne(isbn,ean13);
+ALTER EXTENSION isn ADD function isnlt(ismn13,ismn13);
+ALTER EXTENSION isn ADD function isnle(ismn13,ismn13);
+ALTER EXTENSION isn ADD function isneq(ismn13,ismn13);
+ALTER EXTENSION isn ADD function isnge(ismn13,ismn13);
+ALTER EXTENSION isn ADD function isngt(ismn13,ismn13);
+ALTER EXTENSION isn ADD function isnne(ismn13,ismn13);
+ALTER EXTENSION isn ADD function isnlt(ismn13,ismn);
+ALTER EXTENSION isn ADD function isnle(ismn13,ismn);
+ALTER EXTENSION isn ADD function isneq(ismn13,ismn);
+ALTER EXTENSION isn ADD function isnge(ismn13,ismn);
+ALTER EXTENSION isn ADD function isngt(ismn13,ismn);
+ALTER EXTENSION isn ADD function isnne(ismn13,ismn);
+ALTER EXTENSION isn ADD function isnlt(ismn13,ean13);
+ALTER EXTENSION isn ADD function isnle(ismn13,ean13);
+ALTER EXTENSION isn ADD function isneq(ismn13,ean13);
+ALTER EXTENSION isn ADD function isnge(ismn13,ean13);
+ALTER EXTENSION isn ADD function isngt(ismn13,ean13);
+ALTER EXTENSION isn ADD function isnne(ismn13,ean13);
+ALTER EXTENSION isn ADD function isnlt(ismn,ismn);
+ALTER EXTENSION isn ADD function isnle(ismn,ismn);
+ALTER EXTENSION isn ADD function isneq(ismn,ismn);
+ALTER EXTENSION isn ADD function isnge(ismn,ismn);
+ALTER EXTENSION isn ADD function isngt(ismn,ismn);
+ALTER EXTENSION isn ADD function isnne(ismn,ismn);
+ALTER EXTENSION isn ADD function isnlt(ismn,ismn13);
+ALTER EXTENSION isn ADD function isnle(ismn,ismn13);
+ALTER EXTENSION isn ADD function isneq(ismn,ismn13);
+ALTER EXTENSION isn ADD function isnge(ismn,ismn13);
+ALTER EXTENSION isn ADD function isngt(ismn,ismn13);
+ALTER EXTENSION isn ADD function isnne(ismn,ismn13);
+ALTER EXTENSION isn ADD function isnlt(ismn,ean13);
+ALTER EXTENSION isn ADD function isnle(ismn,ean13);
+ALTER EXTENSION isn ADD function isneq(ismn,ean13);
+ALTER EXTENSION isn ADD function isnge(ismn,ean13);
+ALTER EXTENSION isn ADD function isngt(ismn,ean13);
+ALTER EXTENSION isn ADD function isnne(ismn,ean13);
+ALTER EXTENSION isn ADD function isnlt(issn13,issn13);
+ALTER EXTENSION isn ADD function isnle(issn13,issn13);
+ALTER EXTENSION isn ADD function isneq(issn13,issn13);
+ALTER EXTENSION isn ADD function isnge(issn13,issn13);
+ALTER EXTENSION isn ADD function isngt(issn13,issn13);
+ALTER EXTENSION isn ADD function isnne(issn13,issn13);
+ALTER EXTENSION isn ADD function isnlt(issn13,issn);
+ALTER EXTENSION isn ADD function isnle(issn13,issn);
+ALTER EXTENSION isn ADD function isneq(issn13,issn);
+ALTER EXTENSION isn ADD function isnge(issn13,issn);
+ALTER EXTENSION isn ADD function isngt(issn13,issn);
+ALTER EXTENSION isn ADD function isnne(issn13,issn);
+ALTER EXTENSION isn ADD function isnlt(issn13,ean13);
+ALTER EXTENSION isn ADD function isnle(issn13,ean13);
+ALTER EXTENSION isn ADD function isneq(issn13,ean13);
+ALTER EXTENSION isn ADD function isnge(issn13,ean13);
+ALTER EXTENSION isn ADD function isngt(issn13,ean13);
+ALTER EXTENSION isn ADD function isnne(issn13,ean13);
+ALTER EXTENSION isn ADD function isnlt(issn,issn);
+ALTER EXTENSION isn ADD function isnle(issn,issn);
+ALTER EXTENSION isn ADD function isneq(issn,issn);
+ALTER EXTENSION isn ADD function isnge(issn,issn);
+ALTER EXTENSION isn ADD function isngt(issn,issn);
+ALTER EXTENSION isn ADD function isnne(issn,issn);
+ALTER EXTENSION isn ADD function isnlt(issn,issn13);
+ALTER EXTENSION isn ADD function isnle(issn,issn13);
+ALTER EXTENSION isn ADD function isneq(issn,issn13);
+ALTER EXTENSION isn ADD function isnge(issn,issn13);
+ALTER EXTENSION isn ADD function isngt(issn,issn13);
+ALTER EXTENSION isn ADD function isnne(issn,issn13);
+ALTER EXTENSION isn ADD function isnlt(issn,ean13);
+ALTER EXTENSION isn ADD function isnle(issn,ean13);
+ALTER EXTENSION isn ADD function isneq(issn,ean13);
+ALTER EXTENSION isn ADD function isnge(issn,ean13);
+ALTER EXTENSION isn ADD function isngt(issn,ean13);
+ALTER EXTENSION isn ADD function isnne(issn,ean13);
+ALTER EXTENSION isn ADD function isnlt(upc,upc);
+ALTER EXTENSION isn ADD function isnle(upc,upc);
+ALTER EXTENSION isn ADD function isneq(upc,upc);
+ALTER EXTENSION isn ADD function isnge(upc,upc);
+ALTER EXTENSION isn ADD function isngt(upc,upc);
+ALTER EXTENSION isn ADD function isnne(upc,upc);
+ALTER EXTENSION isn ADD function isnlt(upc,ean13);
+ALTER EXTENSION isn ADD function isnle(upc,ean13);
+ALTER EXTENSION isn ADD function isneq(upc,ean13);
+ALTER EXTENSION isn ADD function isnge(upc,ean13);
+ALTER EXTENSION isn ADD function isngt(upc,ean13);
+ALTER EXTENSION isn ADD function isnne(upc,ean13);
+ALTER EXTENSION isn ADD operator >(ean13,ean13);
+ALTER EXTENSION isn ADD operator >=(ean13,ean13);
+ALTER EXTENSION isn ADD operator <(ean13,ean13);
+ALTER EXTENSION isn ADD operator <=(ean13,ean13);
+ALTER EXTENSION isn ADD operator <>(ean13,ean13);
+ALTER EXTENSION isn ADD operator =(ean13,ean13);
+ALTER EXTENSION isn ADD operator >(isbn13,ean13);
+ALTER EXTENSION isn ADD operator >=(ean13,isbn13);
+ALTER EXTENSION isn ADD operator <(ean13,isbn13);
+ALTER EXTENSION isn ADD operator >=(isbn13,ean13);
+ALTER EXTENSION isn ADD operator >(ean13,isbn13);
+ALTER EXTENSION isn ADD operator <=(ean13,isbn13);
+ALTER EXTENSION isn ADD operator =(isbn13,ean13);
+ALTER EXTENSION isn ADD operator <>(ean13,isbn13);
+ALTER EXTENSION isn ADD operator =(ean13,isbn13);
+ALTER EXTENSION isn ADD operator <=(isbn13,ean13);
+ALTER EXTENSION isn ADD operator <(isbn13,ean13);
+ALTER EXTENSION isn ADD operator <>(isbn13,ean13);
+ALTER EXTENSION isn ADD operator >(ismn13,ean13);
+ALTER EXTENSION isn ADD operator >=(ean13,ismn13);
+ALTER EXTENSION isn ADD operator <(ean13,ismn13);
+ALTER EXTENSION isn ADD operator >=(ismn13,ean13);
+ALTER EXTENSION isn ADD operator >(ean13,ismn13);
+ALTER EXTENSION isn ADD operator <=(ean13,ismn13);
+ALTER EXTENSION isn ADD operator =(ismn13,ean13);
+ALTER EXTENSION isn ADD operator <>(ean13,ismn13);
+ALTER EXTENSION isn ADD operator =(ean13,ismn13);
+ALTER EXTENSION isn ADD operator <=(ismn13,ean13);
+ALTER EXTENSION isn ADD operator <(ismn13,ean13);
+ALTER EXTENSION isn ADD operator <>(ismn13,ean13);
+ALTER EXTENSION isn ADD operator >(issn13,ean13);
+ALTER EXTENSION isn ADD operator >=(ean13,issn13);
+ALTER EXTENSION isn ADD operator <(ean13,issn13);
+ALTER EXTENSION isn ADD operator >=(issn13,ean13);
+ALTER EXTENSION isn ADD operator >(ean13,issn13);
+ALTER EXTENSION isn ADD operator <=(ean13,issn13);
+ALTER EXTENSION isn ADD operator =(issn13,ean13);
+ALTER EXTENSION isn ADD operator <>(ean13,issn13);
+ALTER EXTENSION isn ADD operator =(ean13,issn13);
+ALTER EXTENSION isn ADD operator <=(issn13,ean13);
+ALTER EXTENSION isn ADD operator <(issn13,ean13);
+ALTER EXTENSION isn ADD operator <>(issn13,ean13);
+ALTER EXTENSION isn ADD operator >(isbn,ean13);
+ALTER EXTENSION isn ADD operator >=(ean13,isbn);
+ALTER EXTENSION isn ADD operator <(ean13,isbn);
+ALTER EXTENSION isn ADD operator >=(isbn,ean13);
+ALTER EXTENSION isn ADD operator >(ean13,isbn);
+ALTER EXTENSION isn ADD operator <=(ean13,isbn);
+ALTER EXTENSION isn ADD operator =(isbn,ean13);
+ALTER EXTENSION isn ADD operator <>(ean13,isbn);
+ALTER EXTENSION isn ADD operator =(ean13,isbn);
+ALTER EXTENSION isn ADD operator <=(isbn,ean13);
+ALTER EXTENSION isn ADD operator <(isbn,ean13);
+ALTER EXTENSION isn ADD operator <>(isbn,ean13);
+ALTER EXTENSION isn ADD operator >(ismn,ean13);
+ALTER EXTENSION isn ADD operator >=(ean13,ismn);
+ALTER EXTENSION isn ADD operator <(ean13,ismn);
+ALTER EXTENSION isn ADD operator >=(ismn,ean13);
+ALTER EXTENSION isn ADD operator >(ean13,ismn);
+ALTER EXTENSION isn ADD operator <=(ean13,ismn);
+ALTER EXTENSION isn ADD operator =(ismn,ean13);
+ALTER EXTENSION isn ADD operator <>(ean13,ismn);
+ALTER EXTENSION isn ADD operator =(ean13,ismn);
+ALTER EXTENSION isn ADD operator <=(ismn,ean13);
+ALTER EXTENSION isn ADD operator <(ismn,ean13);
+ALTER EXTENSION isn ADD operator <>(ismn,ean13);
+ALTER EXTENSION isn ADD operator >(issn,ean13);
+ALTER EXTENSION isn ADD operator >=(ean13,issn);
+ALTER EXTENSION isn ADD operator <(ean13,issn);
+ALTER EXTENSION isn ADD operator >=(issn,ean13);
+ALTER EXTENSION isn ADD operator >(ean13,issn);
+ALTER EXTENSION isn ADD operator <=(ean13,issn);
+ALTER EXTENSION isn ADD operator =(issn,ean13);
+ALTER EXTENSION isn ADD operator <>(ean13,issn);
+ALTER EXTENSION isn ADD operator =(ean13,issn);
+ALTER EXTENSION isn ADD operator <=(issn,ean13);
+ALTER EXTENSION isn ADD operator <(issn,ean13);
+ALTER EXTENSION isn ADD operator <>(issn,ean13);
+ALTER EXTENSION isn ADD operator >(upc,ean13);
+ALTER EXTENSION isn ADD operator >=(ean13,upc);
+ALTER EXTENSION isn ADD operator <(ean13,upc);
+ALTER EXTENSION isn ADD operator >=(upc,ean13);
+ALTER EXTENSION isn ADD operator >(ean13,upc);
+ALTER EXTENSION isn ADD operator <=(ean13,upc);
+ALTER EXTENSION isn ADD operator =(upc,ean13);
+ALTER EXTENSION isn ADD operator <>(ean13,upc);
+ALTER EXTENSION isn ADD operator =(ean13,upc);
+ALTER EXTENSION isn ADD operator <=(upc,ean13);
+ALTER EXTENSION isn ADD operator <(upc,ean13);
+ALTER EXTENSION isn ADD operator <>(upc,ean13);
+ALTER EXTENSION isn ADD operator >(isbn13,isbn13);
+ALTER EXTENSION isn ADD operator >=(isbn13,isbn13);
+ALTER EXTENSION isn ADD operator <(isbn13,isbn13);
+ALTER EXTENSION isn ADD operator <=(isbn13,isbn13);
+ALTER EXTENSION isn ADD operator <>(isbn13,isbn13);
+ALTER EXTENSION isn ADD operator =(isbn13,isbn13);
+ALTER EXTENSION isn ADD operator >(isbn,isbn13);
+ALTER EXTENSION isn ADD operator >=(isbn13,isbn);
+ALTER EXTENSION isn ADD operator <(isbn13,isbn);
+ALTER EXTENSION isn ADD operator >=(isbn,isbn13);
+ALTER EXTENSION isn ADD operator >(isbn13,isbn);
+ALTER EXTENSION isn ADD operator <=(isbn13,isbn);
+ALTER EXTENSION isn ADD operator =(isbn,isbn13);
+ALTER EXTENSION isn ADD operator <>(isbn13,isbn);
+ALTER EXTENSION isn ADD operator =(isbn13,isbn);
+ALTER EXTENSION isn ADD operator <=(isbn,isbn13);
+ALTER EXTENSION isn ADD operator <(isbn,isbn13);
+ALTER EXTENSION isn ADD operator <>(isbn,isbn13);
+ALTER EXTENSION isn ADD operator >(isbn,isbn);
+ALTER EXTENSION isn ADD operator >=(isbn,isbn);
+ALTER EXTENSION isn ADD operator <(isbn,isbn);
+ALTER EXTENSION isn ADD operator <=(isbn,isbn);
+ALTER EXTENSION isn ADD operator <>(isbn,isbn);
+ALTER EXTENSION isn ADD operator =(isbn,isbn);
+ALTER EXTENSION isn ADD operator >(ismn13,ismn13);
+ALTER EXTENSION isn ADD operator >=(ismn13,ismn13);
+ALTER EXTENSION isn ADD operator <(ismn13,ismn13);
+ALTER EXTENSION isn ADD operator <=(ismn13,ismn13);
+ALTER EXTENSION isn ADD operator <>(ismn13,ismn13);
+ALTER EXTENSION isn ADD operator =(ismn13,ismn13);
+ALTER EXTENSION isn ADD operator >(ismn,ismn13);
+ALTER EXTENSION isn ADD operator >=(ismn13,ismn);
+ALTER EXTENSION isn ADD operator <(ismn13,ismn);
+ALTER EXTENSION isn ADD operator >=(ismn,ismn13);
+ALTER EXTENSION isn ADD operator >(ismn13,ismn);
+ALTER EXTENSION isn ADD operator <=(ismn13,ismn);
+ALTER EXTENSION isn ADD operator =(ismn,ismn13);
+ALTER EXTENSION isn ADD operator <>(ismn13,ismn);
+ALTER EXTENSION isn ADD operator =(ismn13,ismn);
+ALTER EXTENSION isn ADD operator <=(ismn,ismn13);
+ALTER EXTENSION isn ADD operator <(ismn,ismn13);
+ALTER EXTENSION isn ADD operator <>(ismn,ismn13);
+ALTER EXTENSION isn ADD operator >(ismn,ismn);
+ALTER EXTENSION isn ADD operator >=(ismn,ismn);
+ALTER EXTENSION isn ADD operator <(ismn,ismn);
+ALTER EXTENSION isn ADD operator <=(ismn,ismn);
+ALTER EXTENSION isn ADD operator <>(ismn,ismn);
+ALTER EXTENSION isn ADD operator =(ismn,ismn);
+ALTER EXTENSION isn ADD operator >(issn13,issn13);
+ALTER EXTENSION isn ADD operator >=(issn13,issn13);
+ALTER EXTENSION isn ADD operator <(issn13,issn13);
+ALTER EXTENSION isn ADD operator <=(issn13,issn13);
+ALTER EXTENSION isn ADD operator <>(issn13,issn13);
+ALTER EXTENSION isn ADD operator =(issn13,issn13);
+ALTER EXTENSION isn ADD operator >(issn,issn13);
+ALTER EXTENSION isn ADD operator >=(issn13,issn);
+ALTER EXTENSION isn ADD operator <(issn13,issn);
+ALTER EXTENSION isn ADD operator >=(issn,issn13);
+ALTER EXTENSION isn ADD operator >(issn13,issn);
+ALTER EXTENSION isn ADD operator <=(issn13,issn);
+ALTER EXTENSION isn ADD operator =(issn,issn13);
+ALTER EXTENSION isn ADD operator <>(issn13,issn);
+ALTER EXTENSION isn ADD operator =(issn13,issn);
+ALTER EXTENSION isn ADD operator <=(issn,issn13);
+ALTER EXTENSION isn ADD operator <(issn,issn13);
+ALTER EXTENSION isn ADD operator <>(issn,issn13);
+ALTER EXTENSION isn ADD operator >(issn,issn);
+ALTER EXTENSION isn ADD operator >=(issn,issn);
+ALTER EXTENSION isn ADD operator <(issn,issn);
+ALTER EXTENSION isn ADD operator <=(issn,issn);
+ALTER EXTENSION isn ADD operator <>(issn,issn);
+ALTER EXTENSION isn ADD operator =(issn,issn);
+ALTER EXTENSION isn ADD operator >(upc,upc);
+ALTER EXTENSION isn ADD operator >=(upc,upc);
+ALTER EXTENSION isn ADD operator <(upc,upc);
+ALTER EXTENSION isn ADD operator <=(upc,upc);
+ALTER EXTENSION isn ADD operator <>(upc,upc);
+ALTER EXTENSION isn ADD operator =(upc,upc);
+ALTER EXTENSION isn ADD operator family isn_ops using btree;
+ALTER EXTENSION isn ADD operator family isn_ops using hash;
+ALTER EXTENSION isn ADD function btean13cmp(ean13,ean13);
+ALTER EXTENSION isn ADD operator class ean13_ops using btree;
+ALTER EXTENSION isn ADD function hashean13(ean13);
+ALTER EXTENSION isn ADD operator class ean13_ops using hash;
+ALTER EXTENSION isn ADD function btean13cmp(ean13,isbn13);
+ALTER EXTENSION isn ADD function btean13cmp(ean13,ismn13);
+ALTER EXTENSION isn ADD function btean13cmp(ean13,issn13);
+ALTER EXTENSION isn ADD function btean13cmp(ean13,isbn);
+ALTER EXTENSION isn ADD function btean13cmp(ean13,ismn);
+ALTER EXTENSION isn ADD function btean13cmp(ean13,issn);
+ALTER EXTENSION isn ADD function btean13cmp(ean13,upc);
+ALTER EXTENSION isn ADD function btisbn13cmp(isbn13,isbn13);
+ALTER EXTENSION isn ADD operator class isbn13_ops using btree;
+ALTER EXTENSION isn ADD function hashisbn13(isbn13);
+ALTER EXTENSION isn ADD operator class isbn13_ops using hash;
+ALTER EXTENSION isn ADD function btisbn13cmp(isbn13,ean13);
+ALTER EXTENSION isn ADD function btisbn13cmp(isbn13,isbn);
+ALTER EXTENSION isn ADD function btisbncmp(isbn,isbn);
+ALTER EXTENSION isn ADD operator class isbn_ops using btree;
+ALTER EXTENSION isn ADD function hashisbn(isbn);
+ALTER EXTENSION isn ADD operator class isbn_ops using hash;
+ALTER EXTENSION isn ADD function btisbncmp(isbn,ean13);
+ALTER EXTENSION isn ADD function btisbncmp(isbn,isbn13);
+ALTER EXTENSION isn ADD function btismn13cmp(ismn13,ismn13);
+ALTER EXTENSION isn ADD operator class ismn13_ops using btree;
+ALTER EXTENSION isn ADD function hashismn13(ismn13);
+ALTER EXTENSION isn ADD operator class ismn13_ops using hash;
+ALTER EXTENSION isn ADD function btismn13cmp(ismn13,ean13);
+ALTER EXTENSION isn ADD function btismn13cmp(ismn13,ismn);
+ALTER EXTENSION isn ADD function btismncmp(ismn,ismn);
+ALTER EXTENSION isn ADD operator class ismn_ops using btree;
+ALTER EXTENSION isn ADD function hashismn(ismn);
+ALTER EXTENSION isn ADD operator class ismn_ops using hash;
+ALTER EXTENSION isn ADD function btismncmp(ismn,ean13);
+ALTER EXTENSION isn ADD function btismncmp(ismn,ismn13);
+ALTER EXTENSION isn ADD function btissn13cmp(issn13,issn13);
+ALTER EXTENSION isn ADD operator class issn13_ops using btree;
+ALTER EXTENSION isn ADD function hashissn13(issn13);
+ALTER EXTENSION isn ADD operator class issn13_ops using hash;
+ALTER EXTENSION isn ADD function btissn13cmp(issn13,ean13);
+ALTER EXTENSION isn ADD function btissn13cmp(issn13,issn);
+ALTER EXTENSION isn ADD function btissncmp(issn,issn);
+ALTER EXTENSION isn ADD operator class issn_ops using btree;
+ALTER EXTENSION isn ADD function hashissn(issn);
+ALTER EXTENSION isn ADD operator class issn_ops using hash;
+ALTER EXTENSION isn ADD function btissncmp(issn,ean13);
+ALTER EXTENSION isn ADD function btissncmp(issn,issn13);
+ALTER EXTENSION isn ADD function btupccmp(upc,upc);
+ALTER EXTENSION isn ADD operator class upc_ops using btree;
+ALTER EXTENSION isn ADD function hashupc(upc);
+ALTER EXTENSION isn ADD operator class upc_ops using hash;
+ALTER EXTENSION isn ADD function btupccmp(upc,ean13);
+ALTER EXTENSION isn ADD function isbn13(ean13);
+ALTER EXTENSION isn ADD function ismn13(ean13);
+ALTER EXTENSION isn ADD function issn13(ean13);
+ALTER EXTENSION isn ADD function isbn(ean13);
+ALTER EXTENSION isn ADD function ismn(ean13);
+ALTER EXTENSION isn ADD function issn(ean13);
+ALTER EXTENSION isn ADD function upc(ean13);
+ALTER EXTENSION isn ADD cast (ean13 as isbn13);
+ALTER EXTENSION isn ADD cast (ean13 as isbn);
+ALTER EXTENSION isn ADD cast (ean13 as ismn13);
+ALTER EXTENSION isn ADD cast (ean13 as ismn);
+ALTER EXTENSION isn ADD cast (ean13 as issn13);
+ALTER EXTENSION isn ADD cast (ean13 as issn);
+ALTER EXTENSION isn ADD cast (ean13 as upc);
+ALTER EXTENSION isn ADD cast (isbn13 as ean13);
+ALTER EXTENSION isn ADD cast (isbn as ean13);
+ALTER EXTENSION isn ADD cast (ismn13 as ean13);
+ALTER EXTENSION isn ADD cast (ismn as ean13);
+ALTER EXTENSION isn ADD cast (issn13 as ean13);
+ALTER EXTENSION isn ADD cast (issn as ean13);
+ALTER EXTENSION isn ADD cast (upc as ean13);
+ALTER EXTENSION isn ADD cast (isbn as isbn13);
+ALTER EXTENSION isn ADD cast (isbn13 as isbn);
+ALTER EXTENSION isn ADD cast (ismn as ismn13);
+ALTER EXTENSION isn ADD cast (ismn13 as ismn);
+ALTER EXTENSION isn ADD cast (issn as issn13);
+ALTER EXTENSION isn ADD cast (issn13 as issn);
+ALTER EXTENSION isn ADD function make_valid(ean13);
+ALTER EXTENSION isn ADD function make_valid(isbn13);
+ALTER EXTENSION isn ADD function make_valid(ismn13);
+ALTER EXTENSION isn ADD function make_valid(issn13);
+ALTER EXTENSION isn ADD function make_valid(isbn);
+ALTER EXTENSION isn ADD function make_valid(ismn);
+ALTER EXTENSION isn ADD function make_valid(issn);
+ALTER EXTENSION isn ADD function make_valid(upc);
+ALTER EXTENSION isn ADD function is_valid(ean13);
+ALTER EXTENSION isn ADD function is_valid(isbn13);
+ALTER EXTENSION isn ADD function is_valid(ismn13);
+ALTER EXTENSION isn ADD function is_valid(issn13);
+ALTER EXTENSION isn ADD function is_valid(isbn);
+ALTER EXTENSION isn ADD function is_valid(ismn);
+ALTER EXTENSION isn ADD function is_valid(issn);
+ALTER EXTENSION isn ADD function is_valid(upc);
+ALTER EXTENSION isn ADD function isn_weak(boolean);
+ALTER EXTENSION isn ADD function isn_weak();
diff --git a/contrib/isn/isn.control b/contrib/isn/isn.control
new file mode 100644
index 0000000000000000000000000000000000000000..cf0b2ebe3831f87c93678689846a1a100cce2570
--- /dev/null
+++ b/contrib/isn/isn.control
@@ -0,0 +1,5 @@
+# isn extension
+comment = 'data types for international product numbering standards'
+default_version = '1.0'
+module_pathname = '$libdir/isn'
+relocatable = true
diff --git a/contrib/isn/uninstall_isn.sql b/contrib/isn/uninstall_isn.sql
deleted file mode 100644
index bf866b47485b65a04f5de5e76f7a42dd92461c68..0000000000000000000000000000000000000000
--- a/contrib/isn/uninstall_isn.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* contrib/isn/uninstall_isn.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
--- Drop the operator families (which don't depend on the types)
-DROP OPERATOR FAMILY isn_ops USING btree CASCADE;
-DROP OPERATOR FAMILY isn_ops USING hash CASCADE;
-
---
---	Drop the actual types (in cascade):
---
-DROP TYPE ean13 CASCADE;
-DROP TYPE isbn13 CASCADE;
-DROP TYPE ismn13 CASCADE;
-DROP TYPE issn13 CASCADE;
-DROP TYPE isbn CASCADE;
-DROP TYPE ismn CASCADE;
-DROP TYPE issn CASCADE;
-DROP TYPE upc CASCADE;
-
--- and clean up a couple miscellaneous functions
-DROP FUNCTION isn_weak();
-DROP FUNCTION isn_weak(boolean);
diff --git a/contrib/lo/.gitignore b/contrib/lo/.gitignore
deleted file mode 100644
index 979347bd008b7a05d65e910b1144f1311517b38b..0000000000000000000000000000000000000000
--- a/contrib/lo/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/lo.sql
diff --git a/contrib/lo/Makefile b/contrib/lo/Makefile
index 43c01f57c0a839e6fe436643599728fa16182ba1..66b337c17a6c1f3f986893c2b55dda727f0a8102 100644
--- a/contrib/lo/Makefile
+++ b/contrib/lo/Makefile
@@ -1,8 +1,9 @@
 # contrib/lo/Makefile
 
 MODULES = lo
-DATA_built = lo.sql
-DATA = uninstall_lo.sql
+
+EXTENSION = lo
+DATA = lo--1.0.sql lo--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/lo/lo.sql.in b/contrib/lo/lo--1.0.sql
similarity index 82%
rename from contrib/lo/lo.sql.in
rename to contrib/lo/lo--1.0.sql
index 8c7afbe5e30861836cdfe2d63cdad51d9d469a87..6ecb370a2276c0a2d926f85c904e971ace4c37aa 100644
--- a/contrib/lo/lo.sql.in
+++ b/contrib/lo/lo--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/lo/lo.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/lo/lo--1.0.sql */
 
 --
 --	Create the data type ... now just a domain over OID
diff --git a/contrib/lo/lo--unpackaged--1.0.sql b/contrib/lo/lo--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..54de61686eae9e8a8fa6980b9fc8505561c465ef
--- /dev/null
+++ b/contrib/lo/lo--unpackaged--1.0.sql
@@ -0,0 +1,5 @@
+/* contrib/lo/lo--unpackaged--1.0.sql */
+
+ALTER EXTENSION lo ADD domain lo;
+ALTER EXTENSION lo ADD function lo_oid(lo);
+ALTER EXTENSION lo ADD function lo_manage();
diff --git a/contrib/lo/lo.control b/contrib/lo/lo.control
new file mode 100644
index 0000000000000000000000000000000000000000..849dfb5803983dde7385ac31e675d8887d974c8c
--- /dev/null
+++ b/contrib/lo/lo.control
@@ -0,0 +1,5 @@
+# lo extension
+comment = 'Large Object maintenance'
+default_version = '1.0'
+module_pathname = '$libdir/lo'
+relocatable = true
diff --git a/contrib/lo/uninstall_lo.sql b/contrib/lo/uninstall_lo.sql
deleted file mode 100644
index 77deb1d550dbad08e336f19f2555cbbdd247d19e..0000000000000000000000000000000000000000
--- a/contrib/lo/uninstall_lo.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* contrib/lo/uninstall_lo.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
---
--- This removes the LO type
--- It's used just for development
---
-
--- drop the type and associated functions
-DROP TYPE lo CASCADE;
-
--- the trigger function has no dependency on the type, so drop separately
-DROP FUNCTION lo_manage();
-
--- the lo stuff is now removed from the system
diff --git a/contrib/ltree/.gitignore b/contrib/ltree/.gitignore
index 49883e82a3ac20b49c748339f62d44f511e5e55b..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/ltree/.gitignore
+++ b/contrib/ltree/.gitignore
@@ -1,3 +1,2 @@
-/ltree.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/ltree/Makefile b/contrib/ltree/Makefile
index bad3cbfe85c68e30214840671b7ad2fee71ded4a..65d42f875f0dc3086b40549fb3a61fa207f71d5a 100644
--- a/contrib/ltree/Makefile
+++ b/contrib/ltree/Makefile
@@ -1,11 +1,13 @@
 # contrib/ltree/Makefile
 
-PG_CPPFLAGS = -DLOWER_NODE
 MODULE_big = ltree
 OBJS = 	ltree_io.o ltree_op.o lquery_op.o _ltree_op.o crc32.o \
 	ltxtquery_io.o ltxtquery_op.o ltree_gist.o _ltree_gist.o
-DATA_built = ltree.sql
-DATA = uninstall_ltree.sql
+PG_CPPFLAGS = -DLOWER_NODE
+
+EXTENSION = ltree
+DATA = ltree--1.0.sql ltree--unpackaged--1.0.sql
+
 REGRESS = ltree
 
 ifdef USE_PGXS
diff --git a/contrib/ltree/expected/ltree.out b/contrib/ltree/expected/ltree.out
index 7f61e569cf99329c0754bf822a30ebd0fe4c2498..da6e39a785f18a3b5504f6ad60e2937240eb33ac 100644
--- a/contrib/ltree/expected/ltree.out
+++ b/contrib/ltree/expected/ltree.out
@@ -1,10 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of ltree.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION ltree;
 SELECT ''::ltree;
  ltree 
 -------
diff --git a/contrib/ltree/ltree.sql.in b/contrib/ltree/ltree--1.0.sql
similarity index 99%
rename from contrib/ltree/ltree.sql.in
rename to contrib/ltree/ltree--1.0.sql
index 1b985a7a9952976fd2bff96f4f9aa7230b06ea07..d9b5ead53acc67d2654ae7c84b8443d0b34cc0d5 100644
--- a/contrib/ltree/ltree.sql.in
+++ b/contrib/ltree/ltree--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/ltree/ltree.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/ltree/ltree--1.0.sql */
 
 CREATE OR REPLACE FUNCTION ltree_in(cstring)
 RETURNS ltree
diff --git a/contrib/ltree/ltree--unpackaged--1.0.sql b/contrib/ltree/ltree--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..f483725b4afd59a945e3bf9f7d66226be39beaa3
--- /dev/null
+++ b/contrib/ltree/ltree--unpackaged--1.0.sql
@@ -0,0 +1,131 @@
+/* contrib/ltree/ltree--unpackaged--1.0.sql */
+
+ALTER EXTENSION ltree ADD type ltree;
+ALTER EXTENSION ltree ADD function ltree_in(cstring);
+ALTER EXTENSION ltree ADD function ltree_out(ltree);
+ALTER EXTENSION ltree ADD function ltree_cmp(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_lt(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_le(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_eq(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_ge(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_gt(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_ne(ltree,ltree);
+ALTER EXTENSION ltree ADD operator >(ltree,ltree);
+ALTER EXTENSION ltree ADD operator >=(ltree,ltree);
+ALTER EXTENSION ltree ADD operator <(ltree,ltree);
+ALTER EXTENSION ltree ADD operator <=(ltree,ltree);
+ALTER EXTENSION ltree ADD operator <>(ltree,ltree);
+ALTER EXTENSION ltree ADD operator =(ltree,ltree);
+ALTER EXTENSION ltree ADD function subltree(ltree,integer,integer);
+ALTER EXTENSION ltree ADD function subpath(ltree,integer,integer);
+ALTER EXTENSION ltree ADD function subpath(ltree,integer);
+ALTER EXTENSION ltree ADD function index(ltree,ltree);
+ALTER EXTENSION ltree ADD function index(ltree,ltree,integer);
+ALTER EXTENSION ltree ADD function nlevel(ltree);
+ALTER EXTENSION ltree ADD function ltree2text(ltree);
+ALTER EXTENSION ltree ADD function text2ltree(text);
+ALTER EXTENSION ltree ADD function lca(ltree[]);
+ALTER EXTENSION ltree ADD function lca(ltree,ltree);
+ALTER EXTENSION ltree ADD function lca(ltree,ltree,ltree);
+ALTER EXTENSION ltree ADD function lca(ltree,ltree,ltree,ltree);
+ALTER EXTENSION ltree ADD function lca(ltree,ltree,ltree,ltree,ltree);
+ALTER EXTENSION ltree ADD function lca(ltree,ltree,ltree,ltree,ltree,ltree);
+ALTER EXTENSION ltree ADD function lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree);
+ALTER EXTENSION ltree ADD function lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_isparent(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_risparent(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_addltree(ltree,ltree);
+ALTER EXTENSION ltree ADD function ltree_addtext(ltree,text);
+ALTER EXTENSION ltree ADD function ltree_textadd(text,ltree);
+ALTER EXTENSION ltree ADD function ltreeparentsel(internal,oid,internal,integer);
+ALTER EXTENSION ltree ADD operator <@(ltree,ltree);
+ALTER EXTENSION ltree ADD operator @>(ltree,ltree);
+ALTER EXTENSION ltree ADD operator ^<@(ltree,ltree);
+ALTER EXTENSION ltree ADD operator ^@>(ltree,ltree);
+ALTER EXTENSION ltree ADD operator ||(ltree,ltree);
+ALTER EXTENSION ltree ADD operator ||(ltree,text);
+ALTER EXTENSION ltree ADD operator ||(text,ltree);
+ALTER EXTENSION ltree ADD operator family ltree_ops using btree;
+ALTER EXTENSION ltree ADD operator class ltree_ops using btree;
+ALTER EXTENSION ltree ADD type lquery;
+ALTER EXTENSION ltree ADD function lquery_in(cstring);
+ALTER EXTENSION ltree ADD function lquery_out(lquery);
+ALTER EXTENSION ltree ADD function ltq_regex(ltree,lquery);
+ALTER EXTENSION ltree ADD function ltq_rregex(lquery,ltree);
+ALTER EXTENSION ltree ADD operator ~(lquery,ltree);
+ALTER EXTENSION ltree ADD operator ~(ltree,lquery);
+ALTER EXTENSION ltree ADD operator ^~(lquery,ltree);
+ALTER EXTENSION ltree ADD operator ^~(ltree,lquery);
+ALTER EXTENSION ltree ADD function lt_q_regex(ltree,lquery[]);
+ALTER EXTENSION ltree ADD function lt_q_rregex(lquery[],ltree);
+ALTER EXTENSION ltree ADD operator ?(lquery[],ltree);
+ALTER EXTENSION ltree ADD operator ?(ltree,lquery[]);
+ALTER EXTENSION ltree ADD operator ^?(lquery[],ltree);
+ALTER EXTENSION ltree ADD operator ^?(ltree,lquery[]);
+ALTER EXTENSION ltree ADD type ltxtquery;
+ALTER EXTENSION ltree ADD function ltxtq_in(cstring);
+ALTER EXTENSION ltree ADD function ltxtq_out(ltxtquery);
+ALTER EXTENSION ltree ADD function ltxtq_exec(ltree,ltxtquery);
+ALTER EXTENSION ltree ADD function ltxtq_rexec(ltxtquery,ltree);
+ALTER EXTENSION ltree ADD operator @(ltxtquery,ltree);
+ALTER EXTENSION ltree ADD operator @(ltree,ltxtquery);
+ALTER EXTENSION ltree ADD operator ^@(ltxtquery,ltree);
+ALTER EXTENSION ltree ADD operator ^@(ltree,ltxtquery);
+ALTER EXTENSION ltree ADD type ltree_gist;
+ALTER EXTENSION ltree ADD function ltree_gist_in(cstring);
+ALTER EXTENSION ltree ADD function ltree_gist_out(ltree_gist);
+ALTER EXTENSION ltree ADD function ltree_consistent(internal,internal,smallint,oid,internal);
+ALTER EXTENSION ltree ADD function ltree_compress(internal);
+ALTER EXTENSION ltree ADD function ltree_decompress(internal);
+ALTER EXTENSION ltree ADD function ltree_penalty(internal,internal,internal);
+ALTER EXTENSION ltree ADD function ltree_picksplit(internal,internal);
+ALTER EXTENSION ltree ADD function ltree_union(internal,internal);
+ALTER EXTENSION ltree ADD function ltree_same(internal,internal,internal);
+ALTER EXTENSION ltree ADD operator family gist_ltree_ops using gist;
+ALTER EXTENSION ltree ADD operator class gist_ltree_ops using gist;
+ALTER EXTENSION ltree ADD function _ltree_isparent(ltree[],ltree);
+ALTER EXTENSION ltree ADD function _ltree_r_isparent(ltree,ltree[]);
+ALTER EXTENSION ltree ADD function _ltree_risparent(ltree[],ltree);
+ALTER EXTENSION ltree ADD function _ltree_r_risparent(ltree,ltree[]);
+ALTER EXTENSION ltree ADD function _ltq_regex(ltree[],lquery);
+ALTER EXTENSION ltree ADD function _ltq_rregex(lquery,ltree[]);
+ALTER EXTENSION ltree ADD function _lt_q_regex(ltree[],lquery[]);
+ALTER EXTENSION ltree ADD function _lt_q_rregex(lquery[],ltree[]);
+ALTER EXTENSION ltree ADD function _ltxtq_exec(ltree[],ltxtquery);
+ALTER EXTENSION ltree ADD function _ltxtq_rexec(ltxtquery,ltree[]);
+ALTER EXTENSION ltree ADD operator <@(ltree,ltree[]);
+ALTER EXTENSION ltree ADD operator @>(ltree[],ltree);
+ALTER EXTENSION ltree ADD operator @>(ltree,ltree[]);
+ALTER EXTENSION ltree ADD operator <@(ltree[],ltree);
+ALTER EXTENSION ltree ADD operator ~(lquery,ltree[]);
+ALTER EXTENSION ltree ADD operator ~(ltree[],lquery);
+ALTER EXTENSION ltree ADD operator ?(lquery[],ltree[]);
+ALTER EXTENSION ltree ADD operator ?(ltree[],lquery[]);
+ALTER EXTENSION ltree ADD operator @(ltxtquery,ltree[]);
+ALTER EXTENSION ltree ADD operator @(ltree[],ltxtquery);
+ALTER EXTENSION ltree ADD operator ^<@(ltree,ltree[]);
+ALTER EXTENSION ltree ADD operator ^@>(ltree[],ltree);
+ALTER EXTENSION ltree ADD operator ^@>(ltree,ltree[]);
+ALTER EXTENSION ltree ADD operator ^<@(ltree[],ltree);
+ALTER EXTENSION ltree ADD operator ^~(lquery,ltree[]);
+ALTER EXTENSION ltree ADD operator ^~(ltree[],lquery);
+ALTER EXTENSION ltree ADD operator ^?(lquery[],ltree[]);
+ALTER EXTENSION ltree ADD operator ^?(ltree[],lquery[]);
+ALTER EXTENSION ltree ADD operator ^@(ltxtquery,ltree[]);
+ALTER EXTENSION ltree ADD operator ^@(ltree[],ltxtquery);
+ALTER EXTENSION ltree ADD function _ltree_extract_isparent(ltree[],ltree);
+ALTER EXTENSION ltree ADD operator ?@>(ltree[],ltree);
+ALTER EXTENSION ltree ADD function _ltree_extract_risparent(ltree[],ltree);
+ALTER EXTENSION ltree ADD operator ?<@(ltree[],ltree);
+ALTER EXTENSION ltree ADD function _ltq_extract_regex(ltree[],lquery);
+ALTER EXTENSION ltree ADD operator ?~(ltree[],lquery);
+ALTER EXTENSION ltree ADD function _ltxtq_extract_exec(ltree[],ltxtquery);
+ALTER EXTENSION ltree ADD operator ?@(ltree[],ltxtquery);
+ALTER EXTENSION ltree ADD function _ltree_consistent(internal,internal,smallint,oid,internal);
+ALTER EXTENSION ltree ADD function _ltree_compress(internal);
+ALTER EXTENSION ltree ADD function _ltree_penalty(internal,internal,internal);
+ALTER EXTENSION ltree ADD function _ltree_picksplit(internal,internal);
+ALTER EXTENSION ltree ADD function _ltree_union(internal,internal);
+ALTER EXTENSION ltree ADD function _ltree_same(internal,internal,internal);
+ALTER EXTENSION ltree ADD operator family gist__ltree_ops using gist;
+ALTER EXTENSION ltree ADD operator class gist__ltree_ops using gist;
diff --git a/contrib/ltree/ltree.control b/contrib/ltree/ltree.control
new file mode 100644
index 0000000000000000000000000000000000000000..d879fd618c132025751d95eb2861636d9af0efe1
--- /dev/null
+++ b/contrib/ltree/ltree.control
@@ -0,0 +1,5 @@
+# ltree extension
+comment = 'data type for hierarchical tree-like structures'
+default_version = '1.0'
+module_pathname = '$libdir/ltree'
+relocatable = true
diff --git a/contrib/ltree/sql/ltree.sql b/contrib/ltree/sql/ltree.sql
index 50aad78d3ccdf8309e888627433ed979effac928..46cfa41a4195596ae8f3a151f94960473e042ba0 100644
--- a/contrib/ltree/sql/ltree.sql
+++ b/contrib/ltree/sql/ltree.sql
@@ -1,12 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of ltree.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i ltree.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION ltree;
 
 SELECT ''::ltree;
 SELECT '1'::ltree;
diff --git a/contrib/ltree/uninstall_ltree.sql b/contrib/ltree/uninstall_ltree.sql
deleted file mode 100644
index 2e10b10e97e7e30738475ad9b7187778bca384bb..0000000000000000000000000000000000000000
--- a/contrib/ltree/uninstall_ltree.sql
+++ /dev/null
@@ -1,240 +0,0 @@
-/* contrib/ltree/uninstall_ltree.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR CLASS gist__ltree_ops USING gist;
-
-DROP FUNCTION _ltree_same(internal, internal, internal);
-
-DROP FUNCTION _ltree_union(internal, internal);
-
-DROP FUNCTION _ltree_picksplit(internal, internal);
-
-DROP FUNCTION _ltree_penalty(internal,internal,internal);
-
-DROP FUNCTION _ltree_compress(internal);
-
-DROP FUNCTION _ltree_consistent(internal,internal,int2,oid,internal);
-
-DROP OPERATOR ?@ (_ltree, ltxtquery);
-
-DROP FUNCTION _ltxtq_extract_exec(_ltree,ltxtquery);
-
-DROP OPERATOR ?~ (_ltree, lquery);
-
-DROP FUNCTION _ltq_extract_regex(_ltree,lquery);
-
-DROP OPERATOR ?<@ (_ltree, ltree);
-
-DROP FUNCTION _ltree_extract_risparent(_ltree,ltree);
-
-DROP OPERATOR ?@> (_ltree, ltree);
-
-DROP FUNCTION _ltree_extract_isparent(_ltree,ltree);
-
-DROP OPERATOR ^@ (ltxtquery, _ltree);
-
-DROP OPERATOR ^@ (_ltree, ltxtquery);
-
-DROP OPERATOR ^? (_lquery, _ltree);
-
-DROP OPERATOR ^? (_ltree, _lquery);
-
-DROP OPERATOR ^~ (lquery, _ltree);
-
-DROP OPERATOR ^~ (_ltree, lquery);
-
-DROP OPERATOR ^@> (ltree, _ltree);
-
-DROP OPERATOR ^<@ (_ltree, ltree);
-
-DROP OPERATOR ^<@ (ltree, _ltree);
-
-DROP OPERATOR ^@> (_ltree, ltree);
-
-DROP OPERATOR @ (ltxtquery, _ltree);
-
-DROP OPERATOR @ (_ltree, ltxtquery);
-
-DROP OPERATOR ? (_lquery, _ltree);
-
-DROP OPERATOR ? (_ltree, _lquery);
-
-DROP OPERATOR ~ (lquery, _ltree);
-
-DROP OPERATOR ~ (_ltree, lquery);
-
-DROP OPERATOR @> (ltree, _ltree);
-
-DROP OPERATOR <@ (_ltree, ltree);
-
-DROP OPERATOR <@ (ltree, _ltree);
-
-DROP OPERATOR @> (_ltree, ltree);
-
-DROP FUNCTION _ltxtq_rexec(ltxtquery, _ltree);
-
-DROP FUNCTION _ltxtq_exec(_ltree, ltxtquery);
-
-DROP FUNCTION _lt_q_rregex(_lquery,_ltree);
-
-DROP FUNCTION _lt_q_regex(_ltree,_lquery);
-
-DROP FUNCTION _ltq_rregex(lquery,_ltree);
-
-DROP FUNCTION _ltq_regex(_ltree,lquery);
-
-DROP FUNCTION _ltree_r_risparent(ltree,_ltree);
-
-DROP FUNCTION _ltree_risparent(_ltree,ltree);
-
-DROP FUNCTION _ltree_r_isparent(ltree,_ltree);
-
-DROP FUNCTION _ltree_isparent(_ltree,ltree);
-
-DROP OPERATOR CLASS gist_ltree_ops USING gist;
-
-DROP FUNCTION ltree_same(internal, internal, internal);
-
-DROP FUNCTION ltree_union(internal, internal);
-
-DROP FUNCTION ltree_picksplit(internal, internal);
-
-DROP FUNCTION ltree_penalty(internal,internal,internal);
-
-DROP FUNCTION ltree_decompress(internal);
-
-DROP FUNCTION ltree_compress(internal);
-
-DROP FUNCTION ltree_consistent(internal,internal,int2,oid,internal);
-
-DROP TYPE ltree_gist CASCADE;
-
-DROP OPERATOR ^@ (ltxtquery, ltree);
-
-DROP OPERATOR ^@ (ltree, ltxtquery);
-
-DROP OPERATOR @ (ltxtquery, ltree);
-
-DROP OPERATOR @ (ltree, ltxtquery);
-
-DROP FUNCTION ltxtq_rexec(ltxtquery, ltree);
-
-DROP FUNCTION ltxtq_exec(ltree, ltxtquery);
-
-DROP TYPE ltxtquery CASCADE;
-
-DROP OPERATOR ^? (_lquery, ltree);
-
-DROP OPERATOR ^? (ltree, _lquery);
-
-DROP OPERATOR ? (_lquery, ltree);
-
-DROP OPERATOR ? (ltree, _lquery);
-
-DROP FUNCTION lt_q_rregex(_lquery,ltree);
-
-DROP FUNCTION lt_q_regex(ltree,_lquery);
-
-DROP OPERATOR ^~ (lquery, ltree);
-
-DROP OPERATOR ^~ (ltree, lquery);
-
-DROP OPERATOR ~ (lquery, ltree);
-
-DROP OPERATOR ~ (ltree, lquery);
-
-DROP FUNCTION ltq_rregex(lquery,ltree);
-
-DROP FUNCTION ltq_regex(ltree,lquery);
-
-DROP TYPE lquery CASCADE;
-
-DROP OPERATOR CLASS ltree_ops USING btree;
-
-DROP OPERATOR || (text, ltree);
-
-DROP OPERATOR || (ltree, text);
-
-DROP OPERATOR || (ltree, ltree);
-
-DROP OPERATOR ^<@ (ltree, ltree);
-
-DROP OPERATOR <@ (ltree, ltree);
-
-DROP OPERATOR ^@> (ltree, ltree);
-
-DROP OPERATOR @> (ltree, ltree);
-
-DROP FUNCTION ltreeparentsel(internal, oid, internal, integer);
-
-DROP FUNCTION ltree_textadd(text,ltree);
-
-DROP FUNCTION ltree_addtext(ltree,text);
-
-DROP FUNCTION ltree_addltree(ltree,ltree);
-
-DROP FUNCTION ltree_risparent(ltree,ltree);
-
-DROP FUNCTION ltree_isparent(ltree,ltree);
-
-DROP FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree,ltree);
-
-DROP FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree);
-
-DROP FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree);
-
-DROP FUNCTION lca(ltree,ltree,ltree,ltree,ltree);
-
-DROP FUNCTION lca(ltree,ltree,ltree,ltree);
-
-DROP FUNCTION lca(ltree,ltree,ltree);
-
-DROP FUNCTION lca(ltree,ltree);
-
-DROP FUNCTION lca(_ltree);
-
-DROP FUNCTION text2ltree(text);
-
-DROP FUNCTION ltree2text(ltree);
-
-DROP FUNCTION nlevel(ltree);
-
-DROP FUNCTION index(ltree,ltree,int4);
-
-DROP FUNCTION index(ltree,ltree);
-
-DROP FUNCTION subpath(ltree,int4);
-
-DROP FUNCTION subpath(ltree,int4,int4);
-
-DROP FUNCTION subltree(ltree,int4,int4);
-
-DROP OPERATOR <> (ltree, ltree);
-
-DROP OPERATOR = (ltree, ltree);
-
-DROP OPERATOR > (ltree, ltree);
-
-DROP OPERATOR >= (ltree, ltree);
-
-DROP OPERATOR <= (ltree, ltree);
-
-DROP OPERATOR < (ltree, ltree);
-
-DROP FUNCTION ltree_ne(ltree,ltree);
-
-DROP FUNCTION ltree_gt(ltree,ltree);
-
-DROP FUNCTION ltree_ge(ltree,ltree);
-
-DROP FUNCTION ltree_eq(ltree,ltree);
-
-DROP FUNCTION ltree_le(ltree,ltree);
-
-DROP FUNCTION ltree_lt(ltree,ltree);
-
-DROP FUNCTION ltree_cmp(ltree,ltree);
-
-DROP TYPE ltree CASCADE;
diff --git a/contrib/pageinspect/.gitignore b/contrib/pageinspect/.gitignore
deleted file mode 100644
index fad166aaee8747d8c4fa2dd17555b14851a0b98c..0000000000000000000000000000000000000000
--- a/contrib/pageinspect/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/pageinspect.sql
diff --git a/contrib/pageinspect/Makefile b/contrib/pageinspect/Makefile
index a8ae51dfd1ebfd64d98334306a0e111d8507c09b..13ba6d391113d26b9bd1d3d1185dd6ba896d61ea 100644
--- a/contrib/pageinspect/Makefile
+++ b/contrib/pageinspect/Makefile
@@ -1,15 +1,10 @@
-#-------------------------------------------------------------------------
-#
-# pageinspect Makefile
-#
 # contrib/pageinspect/Makefile
-#
-#-------------------------------------------------------------------------
 
 MODULE_big	= pageinspect
 OBJS		= rawpage.o heapfuncs.o btreefuncs.o fsmfuncs.o
-DATA_built	= pageinspect.sql
-DATA      	= uninstall_pageinspect.sql
+
+EXTENSION = pageinspect
+DATA = pageinspect--1.0.sql pageinspect--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/pageinspect/pageinspect.sql.in b/contrib/pageinspect/pageinspect--1.0.sql
similarity index 94%
rename from contrib/pageinspect/pageinspect.sql.in
rename to contrib/pageinspect/pageinspect--1.0.sql
index d6058d409f3ad8f393ca19e498b21cfe388aafb0..b6e46063ba295e39956a02d83a2cc310b2f3c5a5 100644
--- a/contrib/pageinspect/pageinspect.sql.in
+++ b/contrib/pageinspect/pageinspect--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/pageinspect/pageinspect.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/pageinspect/pageinspect--1.0.sql */
 
 --
 -- get_raw_page()
diff --git a/contrib/pageinspect/pageinspect--unpackaged--1.0.sql b/contrib/pageinspect/pageinspect--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..a9d1b52a4268cf14793f07dd0cdf0b7fe1698793
--- /dev/null
+++ b/contrib/pageinspect/pageinspect--unpackaged--1.0.sql
@@ -0,0 +1,10 @@
+/* contrib/pageinspect/pageinspect--unpackaged--1.0.sql */
+
+ALTER EXTENSION pageinspect ADD function get_raw_page(text,integer);
+ALTER EXTENSION pageinspect ADD function get_raw_page(text,text,integer);
+ALTER EXTENSION pageinspect ADD function page_header(bytea);
+ALTER EXTENSION pageinspect ADD function heap_page_items(bytea);
+ALTER EXTENSION pageinspect ADD function bt_metap(text);
+ALTER EXTENSION pageinspect ADD function bt_page_stats(text,integer);
+ALTER EXTENSION pageinspect ADD function bt_page_items(text,integer);
+ALTER EXTENSION pageinspect ADD function fsm_page_contents(bytea);
diff --git a/contrib/pageinspect/pageinspect.control b/contrib/pageinspect/pageinspect.control
new file mode 100644
index 0000000000000000000000000000000000000000..f9da0e86edc840820235a086956f6ba1ac9ccc18
--- /dev/null
+++ b/contrib/pageinspect/pageinspect.control
@@ -0,0 +1,5 @@
+# pageinspect extension
+comment = 'inspect the contents of database pages at a low level'
+default_version = '1.0'
+module_pathname = '$libdir/pageinspect'
+relocatable = true
diff --git a/contrib/pageinspect/uninstall_pageinspect.sql b/contrib/pageinspect/uninstall_pageinspect.sql
deleted file mode 100644
index a980fd7d01e01e3513456fc3989975e258b8e444..0000000000000000000000000000000000000000
--- a/contrib/pageinspect/uninstall_pageinspect.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-/* contrib/pageinspect/uninstall_pageinspect.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION get_raw_page(text, int4);
-DROP FUNCTION get_raw_page(text, text, int4);
-DROP FUNCTION page_header(bytea);
-DROP FUNCTION heap_page_items(bytea);
-DROP FUNCTION bt_metap(text);
-DROP FUNCTION bt_page_stats(text, int4);
-DROP FUNCTION bt_page_items(text, int4);
-DROP FUNCTION fsm_page_contents(bytea);
diff --git a/contrib/pg_buffercache/.gitignore b/contrib/pg_buffercache/.gitignore
deleted file mode 100644
index fea8b0b3d40b27e0eec2392d2f347a3609ca6348..0000000000000000000000000000000000000000
--- a/contrib/pg_buffercache/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/pg_buffercache.sql
diff --git a/contrib/pg_buffercache/Makefile b/contrib/pg_buffercache/Makefile
index ffcf0c3b928d73ba271116d94b9b0658b9a19bee..323c0ac8ed18d17cbb3f5afa95e02c6d82c9947a 100644
--- a/contrib/pg_buffercache/Makefile
+++ b/contrib/pg_buffercache/Makefile
@@ -3,8 +3,8 @@
 MODULE_big = pg_buffercache
 OBJS = pg_buffercache_pages.o
 
-DATA_built = pg_buffercache.sql
-DATA = uninstall_pg_buffercache.sql
+EXTENSION = pg_buffercache
+DATA = pg_buffercache--1.0.sql pg_buffercache--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/pg_buffercache/pg_buffercache.sql.in b/contrib/pg_buffercache/pg_buffercache--1.0.sql
similarity index 73%
rename from contrib/pg_buffercache/pg_buffercache.sql.in
rename to contrib/pg_buffercache/pg_buffercache--1.0.sql
index 88b5e643acd50de1c190bb04e10d863e2739422c..a49d171e04a0d9364a075812b660192e5f410984 100644
--- a/contrib/pg_buffercache/pg_buffercache.sql.in
+++ b/contrib/pg_buffercache/pg_buffercache--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/pg_buffercache/pg_buffercache.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/pg_buffercache/pg_buffercache--1.0.sql */
 
 -- Register the function.
 CREATE OR REPLACE FUNCTION pg_buffercache_pages()
@@ -15,6 +12,6 @@ CREATE VIEW pg_buffercache AS
 	(bufferid integer, relfilenode oid, reltablespace oid, reldatabase oid,
 	 relforknumber int2, relblocknumber int8, isdirty bool, usagecount int2);
 
--- Don't want these to be available at public.
+-- Don't want these to be available to public.
 REVOKE ALL ON FUNCTION pg_buffercache_pages() FROM PUBLIC;
 REVOKE ALL ON pg_buffercache FROM PUBLIC;
diff --git a/contrib/pg_buffercache/pg_buffercache--unpackaged--1.0.sql b/contrib/pg_buffercache/pg_buffercache--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..f00a954d86e89ced9ef1c3f6c76b2ed6e01a7f27
--- /dev/null
+++ b/contrib/pg_buffercache/pg_buffercache--unpackaged--1.0.sql
@@ -0,0 +1,4 @@
+/* contrib/pg_buffercache/pg_buffercache--unpackaged--1.0.sql */
+
+ALTER EXTENSION pg_buffercache ADD function pg_buffercache_pages();
+ALTER EXTENSION pg_buffercache ADD view pg_buffercache;
diff --git a/contrib/pg_buffercache/pg_buffercache.control b/contrib/pg_buffercache/pg_buffercache.control
new file mode 100644
index 0000000000000000000000000000000000000000..709513c334ed4d04c4047358e9b23dffd6c5bd5f
--- /dev/null
+++ b/contrib/pg_buffercache/pg_buffercache.control
@@ -0,0 +1,5 @@
+# pg_buffercache extension
+comment = 'examine the shared buffer cache'
+default_version = '1.0'
+module_pathname = '$libdir/pg_buffercache'
+relocatable = true
diff --git a/contrib/pg_buffercache/uninstall_pg_buffercache.sql b/contrib/pg_buffercache/uninstall_pg_buffercache.sql
deleted file mode 100644
index 62617cd20d98b07959e0a90cfc6290ef70f6bfbd..0000000000000000000000000000000000000000
--- a/contrib/pg_buffercache/uninstall_pg_buffercache.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-/* contrib/pg_buffercache/uninstall_pg_buffercache.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP VIEW pg_buffercache;
-
-DROP FUNCTION pg_buffercache_pages();
diff --git a/contrib/pg_freespacemap/.gitignore b/contrib/pg_freespacemap/.gitignore
deleted file mode 100644
index 645433a39fa29c7760820062f2e88b7300e885e1..0000000000000000000000000000000000000000
--- a/contrib/pg_freespacemap/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/pg_freespacemap.sql
diff --git a/contrib/pg_freespacemap/Makefile b/contrib/pg_freespacemap/Makefile
index 65539d5d716a12539f266c9d7b316071afbc1aa2..b2e3ba3aa3575a1b457806949480440e3e6aad3d 100644
--- a/contrib/pg_freespacemap/Makefile
+++ b/contrib/pg_freespacemap/Makefile
@@ -3,8 +3,8 @@
 MODULE_big = pg_freespacemap
 OBJS = pg_freespacemap.o
 
-DATA_built = pg_freespacemap.sql
-DATA = uninstall_pg_freespacemap.sql
+EXTENSION = pg_freespacemap
+DATA = pg_freespacemap--1.0.sql pg_freespacemap--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/pg_freespacemap/pg_freespacemap.sql.in b/contrib/pg_freespacemap/pg_freespacemap--1.0.sql
similarity index 82%
rename from contrib/pg_freespacemap/pg_freespacemap.sql.in
rename to contrib/pg_freespacemap/pg_freespacemap--1.0.sql
index 5ef8ba46ad0be5e56d0b1df896dc50132b46594d..19f099ee37604a9e8d01eb78afe01d25564b7eaf 100644
--- a/contrib/pg_freespacemap/pg_freespacemap.sql.in
+++ b/contrib/pg_freespacemap/pg_freespacemap--1.0.sql
@@ -1,8 +1,4 @@
-/* contrib/pg_freespacemap/pg_freespacemap.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
+/* contrib/pg_freespacemap/pg_freespacemap--1.0.sql */
 
 -- Register the C function.
 CREATE OR REPLACE FUNCTION pg_freespace(regclass, bigint)
diff --git a/contrib/pg_freespacemap/pg_freespacemap--unpackaged--1.0.sql b/contrib/pg_freespacemap/pg_freespacemap--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..4c7487fa4e78da9a6daae7f97d47b5fff9382a61
--- /dev/null
+++ b/contrib/pg_freespacemap/pg_freespacemap--unpackaged--1.0.sql
@@ -0,0 +1,4 @@
+/* contrib/pg_freespacemap/pg_freespacemap--unpackaged--1.0.sql */
+
+ALTER EXTENSION pg_freespacemap ADD function pg_freespace(regclass,bigint);
+ALTER EXTENSION pg_freespacemap ADD function pg_freespace(regclass);
diff --git a/contrib/pg_freespacemap/pg_freespacemap.control b/contrib/pg_freespacemap/pg_freespacemap.control
new file mode 100644
index 0000000000000000000000000000000000000000..34b695ff75a6b444f97687d687f693a091c52649
--- /dev/null
+++ b/contrib/pg_freespacemap/pg_freespacemap.control
@@ -0,0 +1,5 @@
+# pg_freespacemap extension
+comment = 'examine the free space map (FSM)'
+default_version = '1.0'
+module_pathname = '$libdir/pg_freespacemap'
+relocatable = true
diff --git a/contrib/pg_freespacemap/uninstall_pg_freespacemap.sql b/contrib/pg_freespacemap/uninstall_pg_freespacemap.sql
deleted file mode 100644
index 168506708a780da57fb162062ec14cc5bc28dfaf..0000000000000000000000000000000000000000
--- a/contrib/pg_freespacemap/uninstall_pg_freespacemap.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-/* contrib/pg_freespacemap/uninstall_pg_freespacemap.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION pg_freespace(regclass, bigint);
-DROP FUNCTION pg_freespace(regclass);
diff --git a/contrib/pg_stat_statements/.gitignore b/contrib/pg_stat_statements/.gitignore
deleted file mode 100644
index 2ca3f068d0c284ec231b58bf98743cb00ee58924..0000000000000000000000000000000000000000
--- a/contrib/pg_stat_statements/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/pg_stat_statements.sql
diff --git a/contrib/pg_stat_statements/Makefile b/contrib/pg_stat_statements/Makefile
index efb26a90f6f8702e725dafc5ef681083778bbd54..e086fd8a827dd22dff806a0009637fb68b505a69 100644
--- a/contrib/pg_stat_statements/Makefile
+++ b/contrib/pg_stat_statements/Makefile
@@ -1,10 +1,11 @@
 # contrib/pg_stat_statements/Makefile
 
 MODULE_big = pg_stat_statements
-DATA_built = pg_stat_statements.sql
-DATA = uninstall_pg_stat_statements.sql
 OBJS = pg_stat_statements.o
 
+EXTENSION = pg_stat_statements
+DATA = pg_stat_statements--1.0.sql pg_stat_statements--unpackaged--1.0.sql
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/pg_stat_statements/pg_stat_statements.sql.in b/contrib/pg_stat_statements/pg_stat_statements--1.0.sql
similarity index 85%
rename from contrib/pg_stat_statements/pg_stat_statements.sql.in
rename to contrib/pg_stat_statements/pg_stat_statements--1.0.sql
index 56d5fd591a2642516e88db34d1f97df5cc0f0211..e17b82c616a86666da33a906ceb0708ef6915d83 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.sql.in
+++ b/contrib/pg_stat_statements/pg_stat_statements--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/pg_stat_statements/pg_stat_statements.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/pg_stat_statements/pg_stat_statements--1.0.sql */
 
 -- Register functions.
 CREATE FUNCTION pg_stat_statements_reset()
diff --git a/contrib/pg_stat_statements/pg_stat_statements--unpackaged--1.0.sql b/contrib/pg_stat_statements/pg_stat_statements--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..9dda85cbdfc384014571b707ba60ad2dacafac4c
--- /dev/null
+++ b/contrib/pg_stat_statements/pg_stat_statements--unpackaged--1.0.sql
@@ -0,0 +1,5 @@
+/* contrib/pg_stat_statements/pg_stat_statements--unpackaged--1.0.sql */
+
+ALTER EXTENSION pg_stat_statements ADD function pg_stat_statements_reset();
+ALTER EXTENSION pg_stat_statements ADD function pg_stat_statements();
+ALTER EXTENSION pg_stat_statements ADD view pg_stat_statements;
diff --git a/contrib/pg_stat_statements/pg_stat_statements.control b/contrib/pg_stat_statements/pg_stat_statements.control
new file mode 100644
index 0000000000000000000000000000000000000000..6f9a9471228df72dd9669dff346bb0ed636bc2b2
--- /dev/null
+++ b/contrib/pg_stat_statements/pg_stat_statements.control
@@ -0,0 +1,5 @@
+# pg_stat_statements extension
+comment = 'track execution statistics of all SQL statements executed'
+default_version = '1.0'
+module_pathname = '$libdir/pg_stat_statements'
+relocatable = true
diff --git a/contrib/pg_stat_statements/uninstall_pg_stat_statements.sql b/contrib/pg_stat_statements/uninstall_pg_stat_statements.sql
deleted file mode 100644
index d2832a2986a1c660b1d6e6f1973bda138ed5d26e..0000000000000000000000000000000000000000
--- a/contrib/pg_stat_statements/uninstall_pg_stat_statements.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-/* contrib/pg_stat_statements/uninstall_pg_stat_statements.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP VIEW pg_stat_statements;
-DROP FUNCTION pg_stat_statements();
-DROP FUNCTION pg_stat_statements_reset();
diff --git a/contrib/pg_test_fsync/Makefile b/contrib/pg_test_fsync/Makefile
index a9365667b39e8d8ce090385cf7a48e811ecad058..b456429098865e0a1cbd5a122dad6787186f08c1 100644
--- a/contrib/pg_test_fsync/Makefile
+++ b/contrib/pg_test_fsync/Makefile
@@ -1,6 +1,3 @@
-#
-# Makefile for pg_test_fsync
-#
 # contrib/pg_test_fsync/Makefile
 
 PGFILEDESC = "pg_test_fsync - test various disk sync methods"
diff --git a/contrib/pg_trgm/.gitignore b/contrib/pg_trgm/.gitignore
index 9cda826ca43f8a0cd26207c066fbb8ec6f0c5ffd..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/pg_trgm/.gitignore
+++ b/contrib/pg_trgm/.gitignore
@@ -1,3 +1,2 @@
-/pg_trgm.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/pg_trgm/Makefile b/contrib/pg_trgm/Makefile
index cf2dec795c672cfba8d6fe4c25bf10d84def303b..64fd69f2cbbe330d6b1d4f4a5ac5b46611f22ff3 100644
--- a/contrib/pg_trgm/Makefile
+++ b/contrib/pg_trgm/Makefile
@@ -3,8 +3,9 @@
 MODULE_big = pg_trgm
 OBJS = trgm_op.o trgm_gist.o trgm_gin.o
 
-DATA_built = pg_trgm.sql
-DATA = uninstall_pg_trgm.sql
+EXTENSION = pg_trgm
+DATA = pg_trgm--1.0.sql pg_trgm--unpackaged--1.0.sql
+
 REGRESS = pg_trgm
 
 ifdef USE_PGXS
diff --git a/contrib/pg_trgm/expected/pg_trgm.out b/contrib/pg_trgm/expected/pg_trgm.out
index 6e73af2a32f2fc086f687aab8c8cf52e775ea14b..e7af7d48902e0c88f7720d5d4dd211cf454288af 100644
--- a/contrib/pg_trgm/expected/pg_trgm.out
+++ b/contrib/pg_trgm/expected/pg_trgm.out
@@ -1,10 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of pg_tgrm.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION pg_trgm;
 select show_trgm('');
  show_trgm 
 -----------
diff --git a/contrib/pg_trgm/pg_trgm.sql.in b/contrib/pg_trgm/pg_trgm--1.0.sql
similarity index 97%
rename from contrib/pg_trgm/pg_trgm.sql.in
rename to contrib/pg_trgm/pg_trgm--1.0.sql
index 12a8c21071b5377293dace8c09a8b3a3630b1248..fc31728dcc187538f3443d1f39d965f6e470b465 100644
--- a/contrib/pg_trgm/pg_trgm.sql.in
+++ b/contrib/pg_trgm/pg_trgm--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/pg_trgm/pg_trgm.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/pg_trgm/pg_trgm--1.0.sql */
 
 CREATE OR REPLACE FUNCTION set_limit(float4)
 RETURNS float4
diff --git a/contrib/pg_trgm/pg_trgm--unpackaged--1.0.sql b/contrib/pg_trgm/pg_trgm--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..ffcb8c1e098943051efbda1ba23b03290a56a2a2
--- /dev/null
+++ b/contrib/pg_trgm/pg_trgm--unpackaged--1.0.sql
@@ -0,0 +1,28 @@
+/* contrib/pg_trgm/pg_trgm--unpackaged--1.0.sql */
+
+ALTER EXTENSION pg_trgm ADD function set_limit(real);
+ALTER EXTENSION pg_trgm ADD function show_limit();
+ALTER EXTENSION pg_trgm ADD function show_trgm(text);
+ALTER EXTENSION pg_trgm ADD function similarity(text,text);
+ALTER EXTENSION pg_trgm ADD function similarity_op(text,text);
+ALTER EXTENSION pg_trgm ADD operator %(text,text);
+ALTER EXTENSION pg_trgm ADD function similarity_dist(text,text);
+ALTER EXTENSION pg_trgm ADD operator <->(text,text);
+ALTER EXTENSION pg_trgm ADD type gtrgm;
+ALTER EXTENSION pg_trgm ADD function gtrgm_in(cstring);
+ALTER EXTENSION pg_trgm ADD function gtrgm_out(gtrgm);
+ALTER EXTENSION pg_trgm ADD function gtrgm_consistent(internal,text,integer,oid,internal);
+ALTER EXTENSION pg_trgm ADD function gtrgm_distance(internal,text,integer,oid);
+ALTER EXTENSION pg_trgm ADD function gtrgm_compress(internal);
+ALTER EXTENSION pg_trgm ADD function gtrgm_decompress(internal);
+ALTER EXTENSION pg_trgm ADD function gtrgm_penalty(internal,internal,internal);
+ALTER EXTENSION pg_trgm ADD function gtrgm_picksplit(internal,internal);
+ALTER EXTENSION pg_trgm ADD function gtrgm_union(bytea,internal);
+ALTER EXTENSION pg_trgm ADD function gtrgm_same(gtrgm,gtrgm,internal);
+ALTER EXTENSION pg_trgm ADD operator family gist_trgm_ops using gist;
+ALTER EXTENSION pg_trgm ADD operator class gist_trgm_ops using gist;
+ALTER EXTENSION pg_trgm ADD function gin_extract_value_trgm(text,internal);
+ALTER EXTENSION pg_trgm ADD function gin_extract_query_trgm(text,internal,smallint,internal,internal,internal,internal);
+ALTER EXTENSION pg_trgm ADD function gin_trgm_consistent(internal,smallint,text,integer,internal,internal,internal,internal);
+ALTER EXTENSION pg_trgm ADD operator family gin_trgm_ops using gin;
+ALTER EXTENSION pg_trgm ADD operator class gin_trgm_ops using gin;
diff --git a/contrib/pg_trgm/pg_trgm.control b/contrib/pg_trgm/pg_trgm.control
new file mode 100644
index 0000000000000000000000000000000000000000..70404d881d49665b742546fed377512bf754deaa
--- /dev/null
+++ b/contrib/pg_trgm/pg_trgm.control
@@ -0,0 +1,5 @@
+# pg_trgm extension
+comment = 'text similarity measurement and index searching based on trigrams'
+default_version = '1.0'
+module_pathname = '$libdir/pg_trgm'
+relocatable = true
diff --git a/contrib/pg_trgm/sql/pg_trgm.sql b/contrib/pg_trgm/sql/pg_trgm.sql
index b8209344c3f0ed5e50e3ae27095e2023b33f3148..ea902f602f9271bb54803ba1a382b5f916560bc5 100644
--- a/contrib/pg_trgm/sql/pg_trgm.sql
+++ b/contrib/pg_trgm/sql/pg_trgm.sql
@@ -1,12 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of pg_tgrm.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i pg_trgm.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION pg_trgm;
 
 select show_trgm('');
 select show_trgm('(*&^$@%@');
diff --git a/contrib/pg_trgm/uninstall_pg_trgm.sql b/contrib/pg_trgm/uninstall_pg_trgm.sql
deleted file mode 100644
index 961e40ca4875a4317d68a4503449fba09c74c937..0000000000000000000000000000000000000000
--- a/contrib/pg_trgm/uninstall_pg_trgm.sql
+++ /dev/null
@@ -1,48 +0,0 @@
-/* contrib/pg_trgm/uninstall_pg_trgm.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR CLASS gist_trgm_ops USING gist;
-
-DROP FUNCTION gtrgm_same(gtrgm, gtrgm, internal);
-
-DROP FUNCTION gtrgm_union(bytea, internal);
-
-DROP FUNCTION gtrgm_picksplit(internal, internal);
-
-DROP FUNCTION gtrgm_penalty(internal,internal,internal);
-
-DROP FUNCTION gtrgm_decompress(internal);
-
-DROP FUNCTION gtrgm_compress(internal);
-
-DROP FUNCTION gtrgm_consistent(internal,text,int,oid,internal);
-
-DROP FUNCTION gtrgm_distance(internal,text,int,oid);
-
-DROP TYPE gtrgm CASCADE;
-
-DROP OPERATOR CLASS gin_trgm_ops USING gin;
-
-DROP FUNCTION gin_extract_value_trgm(text, internal);
-
-DROP FUNCTION gin_extract_query_trgm(text, internal, int2, internal, internal, internal, internal);
-
-DROP FUNCTION gin_trgm_consistent(internal, int2, text, int4, internal, internal, internal, internal);
-
-DROP OPERATOR % (text, text);
-
-DROP FUNCTION similarity_op(text,text);
-
-DROP OPERATOR <-> (text, text);
-
-DROP FUNCTION similarity_dist(text,text);
-
-DROP FUNCTION similarity(text,text);
-
-DROP FUNCTION show_trgm(text);
-
-DROP FUNCTION show_limit();
-
-DROP FUNCTION set_limit(float4);
diff --git a/contrib/pg_upgrade/Makefile b/contrib/pg_upgrade/Makefile
index 79ac234b5ee4bf5ab9e3a0764b5ef0ab70685488..8f3fd7c9bbf29ca227ae77280130ebc46db30d58 100644
--- a/contrib/pg_upgrade/Makefile
+++ b/contrib/pg_upgrade/Makefile
@@ -1,6 +1,3 @@
-#
-# Makefile for pg_upgrade
-#
 # contrib/pg_upgrade/Makefile
 
 PGFILEDESC = "pg_upgrade - an in-place binary upgrade utility"
diff --git a/contrib/pg_upgrade_support/Makefile b/contrib/pg_upgrade_support/Makefile
index e23c9bebcbcec11cfa3e700086b7b88610c97d3e..f7def160c3992c2cabafb501165cf17078a5df57 100644
--- a/contrib/pg_upgrade_support/Makefile
+++ b/contrib/pg_upgrade_support/Makefile
@@ -1,6 +1,3 @@
-#
-# Makefile for pg_upgrade_support
-#
 # contrib/pg_upgrade_support/Makefile
 
 PGFILEDESC = "pg_upgrade_support - server-side functions for pg_upgrade"
diff --git a/contrib/pgcrypto/.gitignore b/contrib/pgcrypto/.gitignore
index 07b24d98f0343cfcf562ad22202f17f8726f94d3..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/pgcrypto/.gitignore
+++ b/contrib/pgcrypto/.gitignore
@@ -1,3 +1,2 @@
-/pgcrypto.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/pgcrypto/Makefile b/contrib/pgcrypto/Makefile
index f429fab4edd324ceed5916f2758ed89be53aa78a..dadec953c2aa03006de621405ddd3d27b9d5e04a 100644
--- a/contrib/pgcrypto/Makefile
+++ b/contrib/pgcrypto/Makefile
@@ -1,6 +1,4 @@
-#
 # contrib/pgcrypto/Makefile
-#
 
 INT_SRCS = md5.c sha1.c sha2.c internal.c internal-sha2.c blf.c rijndael.c \
 		fortuna.c random.c pgp-mpi-internal.c imath.c
@@ -26,9 +24,9 @@ SRCS		= pgcrypto.c px.c px-hmac.c px-crypt.c \
 
 MODULE_big	= pgcrypto
 OBJS		= $(SRCS:.c=.o)
-DATA_built	= pgcrypto.sql
-DATA		= uninstall_pgcrypto.sql
-EXTRA_CLEAN	= gen-rtab
+
+EXTENSION = pgcrypto
+DATA = pgcrypto--1.0.sql pgcrypto--unpackaged--1.0.sql
 
 REGRESS = init md5 sha1 hmac-md5 hmac-sha1 blowfish rijndael \
 	$(CF_TESTS) \
@@ -36,6 +34,7 @@ REGRESS = init md5 sha1 hmac-md5 hmac-sha1 blowfish rijndael \
 	pgp-armor pgp-decrypt pgp-encrypt $(CF_PGP_TESTS) \
 	pgp-pubkey-decrypt pgp-pubkey-encrypt pgp-info
 
+EXTRA_CLEAN = gen-rtab
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/pgcrypto/expected/init.out b/contrib/pgcrypto/expected/init.out
index 4cb108199752f50559631b148bdc40638983ecad..bd8f8e13809c79e8060215606e124bd326b8a2e0 100644
--- a/contrib/pgcrypto/expected/init.out
+++ b/contrib/pgcrypto/expected/init.out
@@ -1,13 +1,7 @@
 --
 -- init pgcrypto
 --
---
--- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of pgcrypto.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION pgcrypto;
 -- ensure consistent test output regardless of the default bytea format
 SET bytea_output TO escape;
 -- check for encoding fn's
diff --git a/contrib/pgcrypto/pgcrypto.sql.in b/contrib/pgcrypto/pgcrypto--1.0.sql
similarity index 97%
rename from contrib/pgcrypto/pgcrypto.sql.in
rename to contrib/pgcrypto/pgcrypto--1.0.sql
index 37ae1004122b9a6253b63dc2a1fe87cd7f1ee01a..29b489fbe5114c24f0ebe9a687f9a30dda7a7549 100644
--- a/contrib/pgcrypto/pgcrypto.sql.in
+++ b/contrib/pgcrypto/pgcrypto--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/pgcrypto/pgcrypto.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/pgcrypto/pgcrypto--1.0.sql */
 
 CREATE OR REPLACE FUNCTION digest(text, text)
 RETURNS bytea
diff --git a/contrib/pgcrypto/pgcrypto--unpackaged--1.0.sql b/contrib/pgcrypto/pgcrypto--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..64f0cdf23ac41af213c1aa99a8340d771b887313
--- /dev/null
+++ b/contrib/pgcrypto/pgcrypto--unpackaged--1.0.sql
@@ -0,0 +1,35 @@
+/* contrib/pgcrypto/pgcrypto--unpackaged--1.0.sql */
+
+ALTER EXTENSION pgcrypto ADD function digest(text,text);
+ALTER EXTENSION pgcrypto ADD function digest(bytea,text);
+ALTER EXTENSION pgcrypto ADD function hmac(text,text,text);
+ALTER EXTENSION pgcrypto ADD function hmac(bytea,bytea,text);
+ALTER EXTENSION pgcrypto ADD function crypt(text,text);
+ALTER EXTENSION pgcrypto ADD function gen_salt(text);
+ALTER EXTENSION pgcrypto ADD function gen_salt(text,integer);
+ALTER EXTENSION pgcrypto ADD function encrypt(bytea,bytea,text);
+ALTER EXTENSION pgcrypto ADD function decrypt(bytea,bytea,text);
+ALTER EXTENSION pgcrypto ADD function encrypt_iv(bytea,bytea,bytea,text);
+ALTER EXTENSION pgcrypto ADD function decrypt_iv(bytea,bytea,bytea,text);
+ALTER EXTENSION pgcrypto ADD function gen_random_bytes(integer);
+ALTER EXTENSION pgcrypto ADD function pgp_sym_encrypt(text,text);
+ALTER EXTENSION pgcrypto ADD function pgp_sym_encrypt_bytea(bytea,text);
+ALTER EXTENSION pgcrypto ADD function pgp_sym_encrypt(text,text,text);
+ALTER EXTENSION pgcrypto ADD function pgp_sym_encrypt_bytea(bytea,text,text);
+ALTER EXTENSION pgcrypto ADD function pgp_sym_decrypt(bytea,text);
+ALTER EXTENSION pgcrypto ADD function pgp_sym_decrypt_bytea(bytea,text);
+ALTER EXTENSION pgcrypto ADD function pgp_sym_decrypt(bytea,text,text);
+ALTER EXTENSION pgcrypto ADD function pgp_sym_decrypt_bytea(bytea,text,text);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_encrypt(text,bytea);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_encrypt_bytea(bytea,bytea);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_encrypt(text,bytea,text);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_encrypt_bytea(bytea,bytea,text);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_decrypt(bytea,bytea);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_decrypt_bytea(bytea,bytea);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_decrypt(bytea,bytea,text);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_decrypt_bytea(bytea,bytea,text);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_decrypt(bytea,bytea,text,text);
+ALTER EXTENSION pgcrypto ADD function pgp_pub_decrypt_bytea(bytea,bytea,text,text);
+ALTER EXTENSION pgcrypto ADD function pgp_key_id(bytea);
+ALTER EXTENSION pgcrypto ADD function armor(bytea);
+ALTER EXTENSION pgcrypto ADD function dearmor(text);
diff --git a/contrib/pgcrypto/pgcrypto.control b/contrib/pgcrypto/pgcrypto.control
new file mode 100644
index 0000000000000000000000000000000000000000..8375cf9e7bb71da981dbe12b359238169b5e23a1
--- /dev/null
+++ b/contrib/pgcrypto/pgcrypto.control
@@ -0,0 +1,5 @@
+# pgcrypto extension
+comment = 'cryptographic functions'
+default_version = '1.0'
+module_pathname = '$libdir/pgcrypto'
+relocatable = true
diff --git a/contrib/pgcrypto/sql/init.sql b/contrib/pgcrypto/sql/init.sql
index 8c1d2192a683edcd655b94aca598bfe871fe1631..5c3d100576b723b766302e62c46b6f8d73537ae9 100644
--- a/contrib/pgcrypto/sql/init.sql
+++ b/contrib/pgcrypto/sql/init.sql
@@ -2,15 +2,7 @@
 -- init pgcrypto
 --
 
---
--- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of pgcrypto.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i pgcrypto.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION pgcrypto;
 
 -- ensure consistent test output regardless of the default bytea format
 SET bytea_output TO escape;
diff --git a/contrib/pgcrypto/uninstall_pgcrypto.sql b/contrib/pgcrypto/uninstall_pgcrypto.sql
deleted file mode 100644
index 3005c50333afa04dccf60d62224f0f261f713578..0000000000000000000000000000000000000000
--- a/contrib/pgcrypto/uninstall_pgcrypto.sql
+++ /dev/null
@@ -1,45 +0,0 @@
-/* contrib/pgcrypto/uninstall_pgcrypto.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION digest(text, text);
-DROP FUNCTION digest(bytea, text);
-
-DROP FUNCTION hmac(text, text, text);
-DROP FUNCTION hmac(bytea, bytea, text);
-
-DROP FUNCTION crypt(text, text);
-DROP FUNCTION gen_salt(text);
-DROP FUNCTION gen_salt(text, int4);
-
-DROP FUNCTION encrypt(bytea, bytea, text);
-DROP FUNCTION decrypt(bytea, bytea, text);
-DROP FUNCTION encrypt_iv(bytea, bytea, bytea, text);
-DROP FUNCTION decrypt_iv(bytea, bytea, bytea, text);
-
-DROP FUNCTION gen_random_bytes(int4);
-
-DROP FUNCTION pgp_sym_encrypt(text, text);
-DROP FUNCTION pgp_sym_encrypt_bytea(bytea, text);
-DROP FUNCTION pgp_sym_encrypt(text, text, text);
-DROP FUNCTION pgp_sym_encrypt_bytea(bytea, text, text);
-DROP FUNCTION pgp_sym_decrypt(bytea, text);
-DROP FUNCTION pgp_sym_decrypt_bytea(bytea, text);
-DROP FUNCTION pgp_sym_decrypt(bytea, text, text);
-DROP FUNCTION pgp_sym_decrypt_bytea(bytea, text, text);
-
-DROP FUNCTION pgp_pub_encrypt(text, bytea);
-DROP FUNCTION pgp_pub_encrypt_bytea(bytea, bytea);
-DROP FUNCTION pgp_pub_encrypt(text, bytea, text);
-DROP FUNCTION pgp_pub_encrypt_bytea(bytea, bytea, text);
-DROP FUNCTION pgp_pub_decrypt(bytea, bytea);
-DROP FUNCTION pgp_pub_decrypt_bytea(bytea, bytea);
-DROP FUNCTION pgp_pub_decrypt(bytea, bytea, text);
-DROP FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text);
-DROP FUNCTION pgp_pub_decrypt(bytea, bytea, text, text);
-DROP FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text, text);
-
-DROP FUNCTION pgp_key_id(bytea);
-DROP FUNCTION armor(bytea);
-DROP FUNCTION dearmor(text);
diff --git a/contrib/pgrowlocks/.gitignore b/contrib/pgrowlocks/.gitignore
deleted file mode 100644
index b2729282bf058fdac2ae734690cc81855454a57e..0000000000000000000000000000000000000000
--- a/contrib/pgrowlocks/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/pgrowlocks.sql
diff --git a/contrib/pgrowlocks/Makefile b/contrib/pgrowlocks/Makefile
index fd338d75d7622fc4a094a357c095a845842691d6..f56389b0e21c3e5612c361c8ffdf5a8110c14eea 100644
--- a/contrib/pgrowlocks/Makefile
+++ b/contrib/pgrowlocks/Makefile
@@ -1,15 +1,10 @@
-#-------------------------------------------------------------------------
-#
-# pgrowlocks Makefile
-#
 # contrib/pgrowlocks/Makefile
-#
-#-------------------------------------------------------------------------
 
 MODULE_big	= pgrowlocks
 OBJS		= pgrowlocks.o
-DATA_built	= pgrowlocks.sql
-DATA		= uninstall_pgrowlocks.sql
+
+EXTENSION = pgrowlocks
+DATA = pgrowlocks--1.0.sql pgrowlocks--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/pgrowlocks/pgrowlocks.sql.in b/contrib/pgrowlocks/pgrowlocks--1.0.sql
similarity index 72%
rename from contrib/pgrowlocks/pgrowlocks.sql.in
rename to contrib/pgrowlocks/pgrowlocks--1.0.sql
index 3bcb3ee7ea163ab5f8cbe511dbad3871761a0f5b..8b5fc9a1c822811e89e5b063016b834152ab7c5f 100644
--- a/contrib/pgrowlocks/pgrowlocks.sql.in
+++ b/contrib/pgrowlocks/pgrowlocks--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/pgrowlocks/pgrowlocks.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/pgrowlocks/pgrowlocks--1.0.sql */
 
 CREATE OR REPLACE FUNCTION pgrowlocks(IN relname text,
     OUT locked_row TID,		-- row TID
diff --git a/contrib/pgrowlocks/pgrowlocks--unpackaged--1.0.sql b/contrib/pgrowlocks/pgrowlocks--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..2d9d1eed41a98054bc39c74aab50eed6024bd489
--- /dev/null
+++ b/contrib/pgrowlocks/pgrowlocks--unpackaged--1.0.sql
@@ -0,0 +1,3 @@
+/* contrib/pgrowlocks/pgrowlocks--unpackaged--1.0.sql */
+
+ALTER EXTENSION pgrowlocks ADD function pgrowlocks(text);
diff --git a/contrib/pgrowlocks/pgrowlocks.control b/contrib/pgrowlocks/pgrowlocks.control
new file mode 100644
index 0000000000000000000000000000000000000000..a6ba16451573e12fc67915bb4a23aa68e0179884
--- /dev/null
+++ b/contrib/pgrowlocks/pgrowlocks.control
@@ -0,0 +1,5 @@
+# pgrowlocks extension
+comment = 'show row-level locking information'
+default_version = '1.0'
+module_pathname = '$libdir/pgrowlocks'
+relocatable = true
diff --git a/contrib/pgrowlocks/uninstall_pgrowlocks.sql b/contrib/pgrowlocks/uninstall_pgrowlocks.sql
deleted file mode 100644
index 004e97c0e9faacbb8397edc14ae42e3a6011e23a..0000000000000000000000000000000000000000
--- a/contrib/pgrowlocks/uninstall_pgrowlocks.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-/* contrib/pgrowlocks/uninstall_pgrowlocks.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION pgrowlocks(text);
diff --git a/contrib/pgstattuple/.gitignore b/contrib/pgstattuple/.gitignore
deleted file mode 100644
index 69b22b64cd92e80aed3c334d9ccc807e192e06f9..0000000000000000000000000000000000000000
--- a/contrib/pgstattuple/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/pgstattuple.sql
diff --git a/contrib/pgstattuple/Makefile b/contrib/pgstattuple/Makefile
index 33386cdf170a12b4324e655e77a5544a5c8a924d..13b87090eec946e8156eb80a443959813bee30fe 100644
--- a/contrib/pgstattuple/Makefile
+++ b/contrib/pgstattuple/Makefile
@@ -1,15 +1,10 @@
-#-------------------------------------------------------------------------
-#
-# pgstattuple Makefile
-#
 # contrib/pgstattuple/Makefile
-#
-#-------------------------------------------------------------------------
 
 MODULE_big	= pgstattuple
 OBJS		= pgstattuple.o pgstatindex.o
-DATA_built	= pgstattuple.sql
-DATA      	= uninstall_pgstattuple.sql
+
+EXTENSION = pgstattuple
+DATA = pgstattuple--1.0.sql pgstattuple--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/pgstattuple/pgstattuple.sql.in b/contrib/pgstattuple/pgstattuple--1.0.sql
similarity index 92%
rename from contrib/pgstattuple/pgstattuple.sql.in
rename to contrib/pgstattuple/pgstattuple--1.0.sql
index 6a0913659688b81c86fb94af26a6cf08868ab768..84b91dda0ac49f5a5055edce47a319eeda9d828d 100644
--- a/contrib/pgstattuple/pgstattuple.sql.in
+++ b/contrib/pgstattuple/pgstattuple--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/pgstattuple/pgstattuple.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/pgstattuple/pgstattuple--1.0.sql */
 
 CREATE OR REPLACE FUNCTION pgstattuple(IN relname text,
     OUT table_len BIGINT,		-- physical table length in bytes
diff --git a/contrib/pgstattuple/pgstattuple--unpackaged--1.0.sql b/contrib/pgstattuple/pgstattuple--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..3cfb8db53475002511628062c25b3757948d8dab
--- /dev/null
+++ b/contrib/pgstattuple/pgstattuple--unpackaged--1.0.sql
@@ -0,0 +1,6 @@
+/* contrib/pgstattuple/pgstattuple--unpackaged--1.0.sql */
+
+ALTER EXTENSION pgstattuple ADD function pgstattuple(text);
+ALTER EXTENSION pgstattuple ADD function pgstattuple(oid);
+ALTER EXTENSION pgstattuple ADD function pgstatindex(text);
+ALTER EXTENSION pgstattuple ADD function pg_relpages(text);
diff --git a/contrib/pgstattuple/pgstattuple.control b/contrib/pgstattuple/pgstattuple.control
new file mode 100644
index 0000000000000000000000000000000000000000..7b5129b2f215665f04742e9d36e9bf243474fef0
--- /dev/null
+++ b/contrib/pgstattuple/pgstattuple.control
@@ -0,0 +1,5 @@
+# pgstattuple extension
+comment = 'show tuple-level statistics'
+default_version = '1.0'
+module_pathname = '$libdir/pgstattuple'
+relocatable = true
diff --git a/contrib/pgstattuple/uninstall_pgstattuple.sql b/contrib/pgstattuple/uninstall_pgstattuple.sql
deleted file mode 100644
index 29eac40f297992ca4e7901ae97583e3d7caebee6..0000000000000000000000000000000000000000
--- a/contrib/pgstattuple/uninstall_pgstattuple.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-/* contrib/pgstattuple/uninstall_pgstattuple.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION pgstattuple(text);
-DROP FUNCTION pgstattuple(oid);
-DROP FUNCTION pgstatindex(text);
-DROP FUNCTION pg_relpages(text);
diff --git a/contrib/seg/.gitignore b/contrib/seg/.gitignore
index a8973ff696c3356d33610e9154b1c79472d3e5d6..102f8b3246da9bedee88199f52d88fc9d7004295 100644
--- a/contrib/seg/.gitignore
+++ b/contrib/seg/.gitignore
@@ -1,5 +1,4 @@
 /segparse.c
 /segscan.c
-/seg.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile
index e8c7a44845063ef0dc65035838d34eb27cb47f72..d84934c67fb7dbfc7bbb467b24976b9f1d59b7c0 100644
--- a/contrib/seg/Makefile
+++ b/contrib/seg/Makefile
@@ -2,8 +2,10 @@
 
 MODULE_big = seg
 OBJS = seg.o segparse.o
-DATA_built = seg.sql
-DATA = uninstall_seg.sql
+
+EXTENSION = seg
+DATA = seg--1.0.sql seg--unpackaged--1.0.sql
+
 REGRESS = seg
 
 EXTRA_CLEAN = y.tab.c y.tab.h
diff --git a/contrib/seg/expected/seg.out b/contrib/seg/expected/seg.out
index 17c803e50e4195e8fdd011536c0fbffbd43a1bbd..1f82a4abb86337a8b3501e96948323980d1fb6aa 100644
--- a/contrib/seg/expected/seg.out
+++ b/contrib/seg/expected/seg.out
@@ -1,13 +1,7 @@
 --
 --  Test seg datatype
 --
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION seg;
 --
 -- testing the input and output functions
 --
diff --git a/contrib/seg/expected/seg_1.out b/contrib/seg/expected/seg_1.out
index a4cca8b3917c62e8f3b853a4932099294b4afbf7..563c744b2d6584ede0a7e60b13a380c5078e8eca 100644
--- a/contrib/seg/expected/seg_1.out
+++ b/contrib/seg/expected/seg_1.out
@@ -1,13 +1,7 @@
 --
 --  Test seg datatype
 --
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION seg;
 --
 -- testing the input and output functions
 --
diff --git a/contrib/seg/seg.sql.in b/contrib/seg/seg--1.0.sql
similarity index 98%
rename from contrib/seg/seg.sql.in
rename to contrib/seg/seg--1.0.sql
index 9bd747656c8d67aebded7793f9ffc636f6ee1bf5..02d8ffadb0a03e1531bd11cc57bf9759315d8e3b 100644
--- a/contrib/seg/seg.sql.in
+++ b/contrib/seg/seg--1.0.sql
@@ -1,10 +1,6 @@
-/* contrib/seg/seg.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/seg/seg--1.0.sql */
 
 -- Create the user-defined type for 1-D floating point intervals (seg)
---
 
 CREATE OR REPLACE FUNCTION seg_in(cstring)
 RETURNS seg
diff --git a/contrib/seg/seg--unpackaged--1.0.sql b/contrib/seg/seg--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..9fefbfc9aa4efd4134d511c71e465a7b5859a67d
--- /dev/null
+++ b/contrib/seg/seg--unpackaged--1.0.sql
@@ -0,0 +1,51 @@
+/* contrib/seg/seg--unpackaged--1.0.sql */
+
+ALTER EXTENSION seg ADD type seg;
+ALTER EXTENSION seg ADD function seg_in(cstring);
+ALTER EXTENSION seg ADD function seg_out(seg);
+ALTER EXTENSION seg ADD function seg_over_left(seg,seg);
+ALTER EXTENSION seg ADD function seg_over_right(seg,seg);
+ALTER EXTENSION seg ADD function seg_left(seg,seg);
+ALTER EXTENSION seg ADD function seg_right(seg,seg);
+ALTER EXTENSION seg ADD function seg_lt(seg,seg);
+ALTER EXTENSION seg ADD function seg_le(seg,seg);
+ALTER EXTENSION seg ADD function seg_gt(seg,seg);
+ALTER EXTENSION seg ADD function seg_ge(seg,seg);
+ALTER EXTENSION seg ADD function seg_contains(seg,seg);
+ALTER EXTENSION seg ADD function seg_contained(seg,seg);
+ALTER EXTENSION seg ADD function seg_overlap(seg,seg);
+ALTER EXTENSION seg ADD function seg_same(seg,seg);
+ALTER EXTENSION seg ADD function seg_different(seg,seg);
+ALTER EXTENSION seg ADD function seg_cmp(seg,seg);
+ALTER EXTENSION seg ADD function seg_union(seg,seg);
+ALTER EXTENSION seg ADD function seg_inter(seg,seg);
+ALTER EXTENSION seg ADD function seg_size(seg);
+ALTER EXTENSION seg ADD function seg_center(seg);
+ALTER EXTENSION seg ADD function seg_upper(seg);
+ALTER EXTENSION seg ADD function seg_lower(seg);
+ALTER EXTENSION seg ADD operator >(seg,seg);
+ALTER EXTENSION seg ADD operator >=(seg,seg);
+ALTER EXTENSION seg ADD operator <(seg,seg);
+ALTER EXTENSION seg ADD operator <=(seg,seg);
+ALTER EXTENSION seg ADD operator >>(seg,seg);
+ALTER EXTENSION seg ADD operator <<(seg,seg);
+ALTER EXTENSION seg ADD operator &<(seg,seg);
+ALTER EXTENSION seg ADD operator &&(seg,seg);
+ALTER EXTENSION seg ADD operator &>(seg,seg);
+ALTER EXTENSION seg ADD operator <>(seg,seg);
+ALTER EXTENSION seg ADD operator =(seg,seg);
+ALTER EXTENSION seg ADD operator <@(seg,seg);
+ALTER EXTENSION seg ADD operator @>(seg,seg);
+ALTER EXTENSION seg ADD operator ~(seg,seg);
+ALTER EXTENSION seg ADD operator @(seg,seg);
+ALTER EXTENSION seg ADD function gseg_consistent(internal,seg,integer,oid,internal);
+ALTER EXTENSION seg ADD function gseg_compress(internal);
+ALTER EXTENSION seg ADD function gseg_decompress(internal);
+ALTER EXTENSION seg ADD function gseg_penalty(internal,internal,internal);
+ALTER EXTENSION seg ADD function gseg_picksplit(internal,internal);
+ALTER EXTENSION seg ADD function gseg_union(internal,internal);
+ALTER EXTENSION seg ADD function gseg_same(seg,seg,internal);
+ALTER EXTENSION seg ADD operator family seg_ops using btree;
+ALTER EXTENSION seg ADD operator class seg_ops using btree;
+ALTER EXTENSION seg ADD operator family gist_seg_ops using gist;
+ALTER EXTENSION seg ADD operator class gist_seg_ops using gist;
diff --git a/contrib/seg/seg.control b/contrib/seg/seg.control
new file mode 100644
index 0000000000000000000000000000000000000000..a1286962eed13afcf9e60c982f236b26e393e1a7
--- /dev/null
+++ b/contrib/seg/seg.control
@@ -0,0 +1,5 @@
+# seg extension
+comment = 'data type for representing line segments or floating-point intervals'
+default_version = '1.0'
+module_pathname = '$libdir/seg'
+relocatable = true
diff --git a/contrib/seg/sql/seg.sql b/contrib/seg/sql/seg.sql
index b8a29d659a5425095be8503c0a23aa44c72c638d..7b7f138dbf68cf8009594953f58e2f34f180304d 100644
--- a/contrib/seg/sql/seg.sql
+++ b/contrib/seg/sql/seg.sql
@@ -2,15 +2,7 @@
 --  Test seg datatype
 --
 
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i seg.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION seg;
 
 --
 -- testing the input and output functions
diff --git a/contrib/seg/uninstall_seg.sql b/contrib/seg/uninstall_seg.sql
deleted file mode 100644
index 27e8ba901a78f407d85fd3ee1fc9426046b1880c..0000000000000000000000000000000000000000
--- a/contrib/seg/uninstall_seg.sql
+++ /dev/null
@@ -1,94 +0,0 @@
-/* contrib/seg/uninstall_seg.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP OPERATOR CLASS gist_seg_ops USING gist;
-
-DROP OPERATOR CLASS seg_ops USING btree;
-
-DROP FUNCTION gseg_same(seg, seg, internal);
-
-DROP FUNCTION gseg_union(internal, internal);
-
-DROP FUNCTION gseg_picksplit(internal, internal);
-
-DROP FUNCTION gseg_penalty(internal,internal,internal);
-
-DROP FUNCTION gseg_decompress(internal);
-
-DROP FUNCTION gseg_compress(internal);
-
-DROP FUNCTION gseg_consistent(internal,seg,int,oid,internal);
-
-DROP OPERATOR <@ (seg, seg);
-
-DROP OPERATOR @> (seg, seg);
-
-DROP OPERATOR ~ (seg, seg);
-
-DROP OPERATOR @ (seg, seg);
-
-DROP OPERATOR <> (seg, seg);
-
-DROP OPERATOR = (seg, seg);
-
-DROP OPERATOR >> (seg, seg);
-
-DROP OPERATOR &> (seg, seg);
-
-DROP OPERATOR && (seg, seg);
-
-DROP OPERATOR &< (seg, seg);
-
-DROP OPERATOR << (seg, seg);
-
-DROP OPERATOR >= (seg, seg);
-
-DROP OPERATOR > (seg, seg);
-
-DROP OPERATOR <= (seg, seg);
-
-DROP OPERATOR < (seg, seg);
-
-DROP FUNCTION seg_center(seg);
-
-DROP FUNCTION seg_lower(seg);
-
-DROP FUNCTION seg_upper(seg);
-
-DROP FUNCTION seg_size(seg);
-
-DROP FUNCTION seg_inter(seg, seg);
-
-DROP FUNCTION seg_union(seg, seg);
-
-DROP FUNCTION seg_cmp(seg, seg);
-
-DROP FUNCTION seg_different(seg, seg);
-
-DROP FUNCTION seg_same(seg, seg);
-
-DROP FUNCTION seg_overlap(seg, seg);
-
-DROP FUNCTION seg_contained(seg, seg);
-
-DROP FUNCTION seg_contains(seg, seg);
-
-DROP FUNCTION seg_ge(seg, seg);
-
-DROP FUNCTION seg_gt(seg, seg);
-
-DROP FUNCTION seg_le(seg, seg);
-
-DROP FUNCTION seg_lt(seg, seg);
-
-DROP FUNCTION seg_right(seg, seg);
-
-DROP FUNCTION seg_left(seg, seg);
-
-DROP FUNCTION seg_over_right(seg, seg);
-
-DROP FUNCTION seg_over_left(seg, seg);
-
-DROP TYPE seg CASCADE;
diff --git a/contrib/spi/.gitignore b/contrib/spi/.gitignore
deleted file mode 100644
index 6c07a33b11426c253e8eb0a0ba33ebf981822907..0000000000000000000000000000000000000000
--- a/contrib/spi/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/autoinc.sql
-/insert_username.sql
-/moddatetime.sql
-/refint.sql
-/timetravel.sql
diff --git a/contrib/spi/Makefile b/contrib/spi/Makefile
index 531d40660520bd49ea6c44b5eddb344d461f8cf3..0c11bfcbbd47b0c3ed002874bfefd9e2022cf5ac 100644
--- a/contrib/spi/Makefile
+++ b/contrib/spi/Makefile
@@ -1,7 +1,15 @@
 # contrib/spi/Makefile
 
 MODULES = autoinc insert_username moddatetime refint timetravel
-DATA_built = $(addsuffix .sql, $(MODULES))
+
+EXTENSION = autoinc insert_username moddatetime refint timetravel
+
+DATA = autoinc--1.0.sql autoinc--unpackaged--1.0.sql \
+       insert_username--1.0.sql insert_username--unpackaged--1.0.sql \
+       moddatetime--1.0.sql moddatetime--unpackaged--1.0.sql \
+       refint--1.0.sql refint--unpackaged--1.0.sql \
+       timetravel--1.0.sql timetravel--unpackaged--1.0.sql
+
 DOCS = $(addsuffix .example, $(MODULES))
 
 # this is needed for the regression tests;
diff --git a/contrib/spi/autoinc--1.0.sql b/contrib/spi/autoinc--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..bf5ecab08b5e50e6353b7988ed1005ed6268a0e3
--- /dev/null
+++ b/contrib/spi/autoinc--1.0.sql
@@ -0,0 +1,6 @@
+/* contrib/spi/autoinc--1.0.sql */
+
+CREATE OR REPLACE FUNCTION autoinc()
+RETURNS trigger
+AS 'MODULE_PATHNAME'
+LANGUAGE C;
diff --git a/contrib/spi/autoinc--unpackaged--1.0.sql b/contrib/spi/autoinc--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..232e9170fc61e8703afc5af6790dcd4f498aa7db
--- /dev/null
+++ b/contrib/spi/autoinc--unpackaged--1.0.sql
@@ -0,0 +1,3 @@
+/* contrib/spi/autoinc--unpackaged--1.0.sql */
+
+ALTER EXTENSION autoinc ADD function autoinc();
diff --git a/contrib/spi/autoinc.control b/contrib/spi/autoinc.control
new file mode 100644
index 0000000000000000000000000000000000000000..1d7a8e53d44f0486a750a1cc5a256b4dcfe604b4
--- /dev/null
+++ b/contrib/spi/autoinc.control
@@ -0,0 +1,5 @@
+# autoinc extension
+comment = 'functions for autoincrementing fields'
+default_version = '1.0'
+module_pathname = '$libdir/autoinc'
+relocatable = true
diff --git a/contrib/spi/autoinc.sql.in b/contrib/spi/autoinc.sql.in
deleted file mode 100644
index 1fa322f9c7712a90297d31e6af2b42e3f3e6e818..0000000000000000000000000000000000000000
--- a/contrib/spi/autoinc.sql.in
+++ /dev/null
@@ -1,9 +0,0 @@
-/* contrib/spi/autoinc.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
-CREATE OR REPLACE FUNCTION autoinc()
-RETURNS trigger
-AS 'MODULE_PATHNAME'
-LANGUAGE C;
diff --git a/contrib/spi/insert_username--1.0.sql b/contrib/spi/insert_username--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..3867c57a2cc680a3c9f2d755618460cc1de05fc3
--- /dev/null
+++ b/contrib/spi/insert_username--1.0.sql
@@ -0,0 +1,6 @@
+/* contrib/spi/insert_username--1.0.sql */
+
+CREATE OR REPLACE FUNCTION insert_username()
+RETURNS trigger
+AS 'MODULE_PATHNAME'
+LANGUAGE C;
diff --git a/contrib/spi/insert_username--unpackaged--1.0.sql b/contrib/spi/insert_username--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..f53cb690f12a55159069e34d65cbece3581a2789
--- /dev/null
+++ b/contrib/spi/insert_username--unpackaged--1.0.sql
@@ -0,0 +1,3 @@
+/* contrib/spi/insert_username--unpackaged--1.0.sql */
+
+ALTER EXTENSION insert_username ADD function insert_username();
diff --git a/contrib/spi/insert_username.control b/contrib/spi/insert_username.control
new file mode 100644
index 0000000000000000000000000000000000000000..9d110643ee8864e3d395172454bbcac348ff862b
--- /dev/null
+++ b/contrib/spi/insert_username.control
@@ -0,0 +1,5 @@
+# insert_username extension
+comment = 'functions for tracking who changed a table'
+default_version = '1.0'
+module_pathname = '$libdir/insert_username'
+relocatable = true
diff --git a/contrib/spi/insert_username.sql.in b/contrib/spi/insert_username.sql.in
deleted file mode 100644
index bdc2deb340b6936d4fe1b84069f363936d6b2067..0000000000000000000000000000000000000000
--- a/contrib/spi/insert_username.sql.in
+++ /dev/null
@@ -1,9 +0,0 @@
-/* contrib/spi/insert_username.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
-CREATE OR REPLACE FUNCTION insert_username()
-RETURNS trigger
-AS 'MODULE_PATHNAME'
-LANGUAGE C;
diff --git a/contrib/spi/moddatetime--1.0.sql b/contrib/spi/moddatetime--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..00971c9fe1e275a274d37e14e225e0477ccf40f3
--- /dev/null
+++ b/contrib/spi/moddatetime--1.0.sql
@@ -0,0 +1,6 @@
+/* contrib/spi/moddatetime--1.0.sql */
+
+CREATE OR REPLACE FUNCTION moddatetime()
+RETURNS trigger
+AS 'MODULE_PATHNAME'
+LANGUAGE C;
diff --git a/contrib/spi/moddatetime--unpackaged--1.0.sql b/contrib/spi/moddatetime--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..f3a0a968371fa5071dd03f6645f9c011a5e5ae5e
--- /dev/null
+++ b/contrib/spi/moddatetime--unpackaged--1.0.sql
@@ -0,0 +1,3 @@
+/* contrib/spi/moddatetime--unpackaged--1.0.sql */
+
+ALTER EXTENSION moddatetime ADD function moddatetime();
diff --git a/contrib/spi/moddatetime.control b/contrib/spi/moddatetime.control
new file mode 100644
index 0000000000000000000000000000000000000000..93dfac589a34bbe4e08688567ea04e49402e4ffb
--- /dev/null
+++ b/contrib/spi/moddatetime.control
@@ -0,0 +1,5 @@
+# moddatetime extension
+comment = 'functions for tracking last modification time'
+default_version = '1.0'
+module_pathname = '$libdir/moddatetime'
+relocatable = true
diff --git a/contrib/spi/moddatetime.sql.in b/contrib/spi/moddatetime.sql.in
deleted file mode 100644
index e4ca6a66536a4eb8368f22b55c8a0c6a7754e596..0000000000000000000000000000000000000000
--- a/contrib/spi/moddatetime.sql.in
+++ /dev/null
@@ -1,9 +0,0 @@
-/* contrib/spi/moddatetime.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
-
-CREATE OR REPLACE FUNCTION moddatetime()
-RETURNS trigger
-AS 'MODULE_PATHNAME'
-LANGUAGE C;
diff --git a/contrib/spi/refint.sql.in b/contrib/spi/refint--1.0.sql
similarity index 61%
rename from contrib/spi/refint.sql.in
rename to contrib/spi/refint--1.0.sql
index 2525b70006e92a97ff894c96d40adbefabd80b88..5a50226c436eddad5ad42e570cbf4dd203dd52f5 100644
--- a/contrib/spi/refint.sql.in
+++ b/contrib/spi/refint--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/spi/refint.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/spi/refint--1.0.sql */
 
 CREATE OR REPLACE FUNCTION check_primary_key()
 RETURNS trigger
diff --git a/contrib/spi/refint--unpackaged--1.0.sql b/contrib/spi/refint--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..54fece055a306e9cf4f8e40bef05ac32337efd2f
--- /dev/null
+++ b/contrib/spi/refint--unpackaged--1.0.sql
@@ -0,0 +1,4 @@
+/* contrib/spi/refint--unpackaged--1.0.sql */
+
+ALTER EXTENSION refint ADD function check_primary_key();
+ALTER EXTENSION refint ADD function check_foreign_key();
diff --git a/contrib/spi/refint.control b/contrib/spi/refint.control
new file mode 100644
index 0000000000000000000000000000000000000000..cbede45784cfac2024ac6142493edf3a8000f633
--- /dev/null
+++ b/contrib/spi/refint.control
@@ -0,0 +1,5 @@
+# refint extension
+comment = 'functions for implementing referential integrity (obsolete)'
+default_version = '1.0'
+module_pathname = '$libdir/refint'
+relocatable = true
diff --git a/contrib/spi/timetravel.sql.in b/contrib/spi/timetravel--1.0.sql
similarity index 72%
rename from contrib/spi/timetravel.sql.in
rename to contrib/spi/timetravel--1.0.sql
index 83dc958a88b26155c8920a3d6f8f75d57cdb7dae..c9f786218f2cd19b1f456ed3b91dad98afe5d012 100644
--- a/contrib/spi/timetravel.sql.in
+++ b/contrib/spi/timetravel--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/spi/timetravel.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/spi/timetravel--1.0.sql */
 
 CREATE OR REPLACE FUNCTION timetravel()
 RETURNS trigger
diff --git a/contrib/spi/timetravel--unpackaged--1.0.sql b/contrib/spi/timetravel--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..e3716afe95acd7fd7d94c2124031261ef30c7189
--- /dev/null
+++ b/contrib/spi/timetravel--unpackaged--1.0.sql
@@ -0,0 +1,5 @@
+/* contrib/spi/timetravel--unpackaged--1.0.sql */
+
+ALTER EXTENSION timetravel ADD function timetravel();
+ALTER EXTENSION timetravel ADD function set_timetravel(name,integer);
+ALTER EXTENSION timetravel ADD function get_timetravel(name);
diff --git a/contrib/spi/timetravel.control b/contrib/spi/timetravel.control
new file mode 100644
index 0000000000000000000000000000000000000000..9b4bb6ba04614e130806f1d4fc7329c868dfa900
--- /dev/null
+++ b/contrib/spi/timetravel.control
@@ -0,0 +1,5 @@
+# timetravel extension
+comment = 'functions for implementing time travel'
+default_version = '1.0'
+module_pathname = '$libdir/timetravel'
+relocatable = true
diff --git a/contrib/sslinfo/.gitignore b/contrib/sslinfo/.gitignore
deleted file mode 100644
index 6ed45c8ce5a1ea0b1e60147d81b3f83d9c23bd85..0000000000000000000000000000000000000000
--- a/contrib/sslinfo/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/sslinfo.sql
diff --git a/contrib/sslinfo/Makefile b/contrib/sslinfo/Makefile
index a4c3d84297808e898b535375743091dd1c62c3fc..0dee6ed2f76524793a0f901aaf9fbbc8174ff4db 100644
--- a/contrib/sslinfo/Makefile
+++ b/contrib/sslinfo/Makefile
@@ -2,8 +2,9 @@
 
 MODULE_big = sslinfo
 OBJS = sslinfo.o
-DATA_built = sslinfo.sql
-DATA = uninstall_sslinfo.sql
+
+EXTENSION = sslinfo
+DATA = sslinfo--1.0.sql sslinfo--unpackaged--1.0.sql
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/sslinfo/sslinfo.sql.in b/contrib/sslinfo/sslinfo--1.0.sql
similarity index 89%
rename from contrib/sslinfo/sslinfo.sql.in
rename to contrib/sslinfo/sslinfo--1.0.sql
index 66cbe3ea664311a122ab18464c297fb3b44d7d0d..37007e59f7ce801193f5ec774dd4ebafbc7c7f0d 100644
--- a/contrib/sslinfo/sslinfo.sql.in
+++ b/contrib/sslinfo/sslinfo--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/sslinfo/sslinfo.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/sslinfo/sslinfo--1.0.sql */
 
 CREATE OR REPLACE FUNCTION ssl_client_serial() RETURNS numeric
 AS 'MODULE_PATHNAME', 'ssl_client_serial'
diff --git a/contrib/sslinfo/sslinfo--unpackaged--1.0.sql b/contrib/sslinfo/sslinfo--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..c07793905adb06c06469efcef77cbc5c9ce87f53
--- /dev/null
+++ b/contrib/sslinfo/sslinfo--unpackaged--1.0.sql
@@ -0,0 +1,11 @@
+/* contrib/sslinfo/sslinfo--unpackaged--1.0.sql */
+
+ALTER EXTENSION sslinfo ADD function ssl_client_serial();
+ALTER EXTENSION sslinfo ADD function ssl_is_used();
+ALTER EXTENSION sslinfo ADD function ssl_version();
+ALTER EXTENSION sslinfo ADD function ssl_cipher();
+ALTER EXTENSION sslinfo ADD function ssl_client_cert_present();
+ALTER EXTENSION sslinfo ADD function ssl_client_dn_field(text);
+ALTER EXTENSION sslinfo ADD function ssl_issuer_field(text);
+ALTER EXTENSION sslinfo ADD function ssl_client_dn();
+ALTER EXTENSION sslinfo ADD function ssl_issuer_dn();
diff --git a/contrib/sslinfo/sslinfo.control b/contrib/sslinfo/sslinfo.control
new file mode 100644
index 0000000000000000000000000000000000000000..1d2f058f6e245811557466ef70b0ca223ab07517
--- /dev/null
+++ b/contrib/sslinfo/sslinfo.control
@@ -0,0 +1,5 @@
+# sslinfo extension
+comment = 'information about SSL certificates'
+default_version = '1.0'
+module_pathname = '$libdir/sslinfo'
+relocatable = true
diff --git a/contrib/sslinfo/uninstall_sslinfo.sql b/contrib/sslinfo/uninstall_sslinfo.sql
deleted file mode 100644
index 9ac572c8f9f2753cd4b2709437396784618496fc..0000000000000000000000000000000000000000
--- a/contrib/sslinfo/uninstall_sslinfo.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-/* contrib/sslinfo/uninstall_sslinfo.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION ssl_client_serial();
-DROP FUNCTION ssl_is_used();
-DROP FUNCTION ssl_cipher();
-DROP FUNCTION ssl_version();
-DROP FUNCTION ssl_client_cert_present();
-DROP FUNCTION ssl_client_dn_field(text);
-DROP FUNCTION ssl_issuer_field(text);
-DROP FUNCTION ssl_client_dn();
-DROP FUNCTION ssl_issuer_dn();
diff --git a/contrib/tablefunc/.gitignore b/contrib/tablefunc/.gitignore
index b28639637bcf350646c2b611e2e9d3bf1eeac4f7..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/tablefunc/.gitignore
+++ b/contrib/tablefunc/.gitignore
@@ -1,3 +1,2 @@
-/tablefunc.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/tablefunc/Makefile b/contrib/tablefunc/Makefile
index a5c2882866150bee5ba58eb03d9ad150c7ecd33a..eb108931ec49a8a8473708ea94a0ecda6a6c8407 100644
--- a/contrib/tablefunc/Makefile
+++ b/contrib/tablefunc/Makefile
@@ -1,8 +1,10 @@
 # contrib/tablefunc/Makefile
 
 MODULES = tablefunc
-DATA_built = tablefunc.sql
-DATA = uninstall_tablefunc.sql
+
+EXTENSION = tablefunc
+DATA = tablefunc--1.0.sql tablefunc--unpackaged--1.0.sql
+
 REGRESS = tablefunc
 
 LDFLAGS_SL += $(filter -lm, $(LIBS))
diff --git a/contrib/tablefunc/expected/tablefunc.out b/contrib/tablefunc/expected/tablefunc.out
index 15ef758ed71b631973ca053b922544dbafc7e58b..7ad4336ada407a41548ea72852ab1201301290c3 100644
--- a/contrib/tablefunc/expected/tablefunc.out
+++ b/contrib/tablefunc/expected/tablefunc.out
@@ -1,10 +1,4 @@
---
--- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of tablefunc.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION tablefunc;
 --
 -- normal_rand()
 -- no easy way to do this for regression testing
diff --git a/contrib/tablefunc/sql/tablefunc.sql b/contrib/tablefunc/sql/tablefunc.sql
index 8846a4218ef4a8f5880515b43b5625ce9391a5eb..bf874f26ad88d89200e304b9270ee6e04f1739d6 100644
--- a/contrib/tablefunc/sql/tablefunc.sql
+++ b/contrib/tablefunc/sql/tablefunc.sql
@@ -1,12 +1,4 @@
---
--- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of tablefunc.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i tablefunc.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION tablefunc;
 
 --
 -- normal_rand()
diff --git a/contrib/tablefunc/tablefunc.sql.in b/contrib/tablefunc/tablefunc--1.0.sql
similarity index 94%
rename from contrib/tablefunc/tablefunc.sql.in
rename to contrib/tablefunc/tablefunc--1.0.sql
index 54cba5ed3e1a3e99bacd69872a780bc90bf8ae35..63dd8c4634cb59b774397b7d093a9b80f767b428 100644
--- a/contrib/tablefunc/tablefunc.sql.in
+++ b/contrib/tablefunc/tablefunc--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/tablefunc/tablefunc.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/tablefunc/tablefunc--1.0.sql */
 
 CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8)
 RETURNS setof float8
diff --git a/contrib/tablefunc/tablefunc--unpackaged--1.0.sql b/contrib/tablefunc/tablefunc--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..20e09816e9dd1de65b8dd771c0de77c5eed79173
--- /dev/null
+++ b/contrib/tablefunc/tablefunc--unpackaged--1.0.sql
@@ -0,0 +1,16 @@
+/* contrib/tablefunc/tablefunc--unpackaged--1.0.sql */
+
+ALTER EXTENSION tablefunc ADD function normal_rand(integer,double precision,double precision);
+ALTER EXTENSION tablefunc ADD function crosstab(text);
+ALTER EXTENSION tablefunc ADD type tablefunc_crosstab_2;
+ALTER EXTENSION tablefunc ADD type tablefunc_crosstab_3;
+ALTER EXTENSION tablefunc ADD type tablefunc_crosstab_4;
+ALTER EXTENSION tablefunc ADD function crosstab2(text);
+ALTER EXTENSION tablefunc ADD function crosstab3(text);
+ALTER EXTENSION tablefunc ADD function crosstab4(text);
+ALTER EXTENSION tablefunc ADD function crosstab(text,integer);
+ALTER EXTENSION tablefunc ADD function crosstab(text,text);
+ALTER EXTENSION tablefunc ADD function connectby(text,text,text,text,integer,text);
+ALTER EXTENSION tablefunc ADD function connectby(text,text,text,text,integer);
+ALTER EXTENSION tablefunc ADD function connectby(text,text,text,text,text,integer,text);
+ALTER EXTENSION tablefunc ADD function connectby(text,text,text,text,text,integer);
diff --git a/contrib/tablefunc/tablefunc.control b/contrib/tablefunc/tablefunc.control
new file mode 100644
index 0000000000000000000000000000000000000000..248b0a77a2dfdc2cdadef05c75dd1942ca16869c
--- /dev/null
+++ b/contrib/tablefunc/tablefunc.control
@@ -0,0 +1,5 @@
+# tablefunc extension
+comment = 'functions that manipulate whole tables, including crosstab'
+default_version = '1.0'
+module_pathname = '$libdir/tablefunc'
+relocatable = true
diff --git a/contrib/tablefunc/uninstall_tablefunc.sql b/contrib/tablefunc/uninstall_tablefunc.sql
deleted file mode 100644
index b1ec9164478b23ca4357e081ec5b87e01519779e..0000000000000000000000000000000000000000
--- a/contrib/tablefunc/uninstall_tablefunc.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-/* contrib/tablefunc/uninstall_tablefunc.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION connectby(text,text,text,text,text,int);
-
-DROP FUNCTION connectby(text,text,text,text,text,int,text);
-
-DROP FUNCTION connectby(text,text,text,text,int);
-
-DROP FUNCTION connectby(text,text,text,text,int,text);
-
-DROP FUNCTION crosstab(text,text);
-
-DROP FUNCTION crosstab(text,int);
-
-DROP FUNCTION crosstab4(text);
-
-DROP FUNCTION crosstab3(text);
-
-DROP FUNCTION crosstab2(text);
-
-DROP TYPE tablefunc_crosstab_4;
-
-DROP TYPE tablefunc_crosstab_3;
-
-DROP TYPE tablefunc_crosstab_2;
-
-DROP FUNCTION crosstab(text);
-
-DROP FUNCTION normal_rand(int4, float8, float8);
diff --git a/contrib/test_parser/.gitignore b/contrib/test_parser/.gitignore
index c07f518855cc8544ed2450fd5e9b0c99d5b13850..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/test_parser/.gitignore
+++ b/contrib/test_parser/.gitignore
@@ -1,3 +1,2 @@
-/test_parser.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/test_parser/Makefile b/contrib/test_parser/Makefile
index ad4e0ec9b8edfc8156577c8b3548892b88cc5fc0..b9766cb0234dc1692031e7b81786b75d6919f780 100644
--- a/contrib/test_parser/Makefile
+++ b/contrib/test_parser/Makefile
@@ -2,8 +2,10 @@
 
 MODULE_big = test_parser
 OBJS = test_parser.o
-DATA_built = test_parser.sql
-DATA = uninstall_test_parser.sql
+
+EXTENSION = test_parser
+DATA = test_parser--1.0.sql test_parser--unpackaged--1.0.sql
+
 REGRESS = test_parser
 
 ifdef USE_PGXS
diff --git a/contrib/test_parser/expected/test_parser.out b/contrib/test_parser/expected/test_parser.out
index 3d0fd4210f7750ac296383d82a3807d994f3444a..8a49bc01e329f7f81bd75bcd6a16245e88d6ac8b 100644
--- a/contrib/test_parser/expected/test_parser.out
+++ b/contrib/test_parser/expected/test_parser.out
@@ -1,10 +1,4 @@
---
--- first, define the parser.  Turn off echoing so that expected file
--- does not depend on contents of this file.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION test_parser;
 -- make test configuration using parser
 CREATE TEXT SEARCH CONFIGURATION testcfg (PARSER = testparser);
 ALTER TEXT SEARCH CONFIGURATION testcfg ADD MAPPING FOR word WITH simple;
diff --git a/contrib/test_parser/sql/test_parser.sql b/contrib/test_parser/sql/test_parser.sql
index 97c2cb5a5d3eeba3b588ce92a4df2614998b287e..1f21504602b375f521aec9e7b1e0f03ac9c1b461 100644
--- a/contrib/test_parser/sql/test_parser.sql
+++ b/contrib/test_parser/sql/test_parser.sql
@@ -1,12 +1,4 @@
---
--- first, define the parser.  Turn off echoing so that expected file
--- does not depend on contents of this file.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i test_parser.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION test_parser;
 
 -- make test configuration using parser
 
diff --git a/contrib/test_parser/test_parser.sql.in b/contrib/test_parser/test_parser--1.0.sql
similarity index 83%
rename from contrib/test_parser/test_parser.sql.in
rename to contrib/test_parser/test_parser--1.0.sql
index bab97a29870b1f3593e00318f6c0dc8a052cf756..fb785a1c4a06817e2055164f21e90d4a6a47f7ab 100644
--- a/contrib/test_parser/test_parser.sql.in
+++ b/contrib/test_parser/test_parser--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/test_parser/test_parser.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/test_parser/test_parser--1.0.sql */
 
 CREATE OR REPLACE FUNCTION testprs_start(internal, int4)
 RETURNS internal
diff --git a/contrib/test_parser/test_parser--unpackaged--1.0.sql b/contrib/test_parser/test_parser--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..e240ab2b5bb076db66c4dbdbdb0b74efa1cc6487
--- /dev/null
+++ b/contrib/test_parser/test_parser--unpackaged--1.0.sql
@@ -0,0 +1,7 @@
+/* contrib/test_parser/test_parser--unpackaged--1.0.sql */
+
+ALTER EXTENSION test_parser ADD function testprs_start(internal,integer);
+ALTER EXTENSION test_parser ADD function testprs_getlexeme(internal,internal,internal);
+ALTER EXTENSION test_parser ADD function testprs_end(internal);
+ALTER EXTENSION test_parser ADD function testprs_lextype(internal);
+ALTER EXTENSION test_parser ADD text search parser testparser;
diff --git a/contrib/test_parser/test_parser.control b/contrib/test_parser/test_parser.control
new file mode 100644
index 0000000000000000000000000000000000000000..36b26b2087ca2f0fc3a4a3652154de456676022e
--- /dev/null
+++ b/contrib/test_parser/test_parser.control
@@ -0,0 +1,5 @@
+# test_parser extension
+comment = 'example of a custom parser for full-text search'
+default_version = '1.0'
+module_pathname = '$libdir/test_parser'
+relocatable = true
diff --git a/contrib/test_parser/uninstall_test_parser.sql b/contrib/test_parser/uninstall_test_parser.sql
deleted file mode 100644
index 042f46b251729ac21729c30210995e050652303f..0000000000000000000000000000000000000000
--- a/contrib/test_parser/uninstall_test_parser.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-/* contrib/test_parser/uninstall_test_parser.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP TEXT SEARCH PARSER testparser;
-
-DROP FUNCTION testprs_start(internal, int4);
-
-DROP FUNCTION testprs_getlexeme(internal, internal, internal);
-
-DROP FUNCTION testprs_end(internal);
-
-DROP FUNCTION testprs_lextype(internal);
diff --git a/contrib/tsearch2/.gitignore b/contrib/tsearch2/.gitignore
index 1d34309d00899acc2a18a9d38b62e5b9a0b93e7e..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/tsearch2/.gitignore
+++ b/contrib/tsearch2/.gitignore
@@ -1,3 +1,2 @@
-/tsearch2.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/tsearch2/Makefile b/contrib/tsearch2/Makefile
index 8748d30b195626684588bf75b8eb8693b9f5e4e2..d260fd00309d62da2b90dc6ee9daaea7f2ad8095 100644
--- a/contrib/tsearch2/Makefile
+++ b/contrib/tsearch2/Makefile
@@ -1,8 +1,10 @@
 # contrib/tsearch2/Makefile
 
 MODULES = tsearch2
-DATA_built = tsearch2.sql
-DATA = uninstall_tsearch2.sql
+
+EXTENSION = tsearch2
+DATA = tsearch2--1.0.sql tsearch2--unpackaged--1.0.sql
+
 REGRESS = tsearch2
 
 ifdef USE_PGXS
diff --git a/contrib/tsearch2/expected/tsearch2.out b/contrib/tsearch2/expected/tsearch2.out
index 18b591e0aaa71a857043f67fbc82e6265bab7682..972f764c14abf7a8e0b8518ae45822827c71f666 100644
--- a/contrib/tsearch2/expected/tsearch2.out
+++ b/contrib/tsearch2/expected/tsearch2.out
@@ -1,10 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of tsearch2.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION tsearch2;
 --tsvector
 SELECT '1'::tsvector;
  tsvector 
diff --git a/contrib/tsearch2/expected/tsearch2_1.out b/contrib/tsearch2/expected/tsearch2_1.out
index f7cb0963b86af5559a5006821fc36f0c72f9b0c3..349733b6fd3687fb8540d2ffc6bd4d97f23b3c04 100644
--- a/contrib/tsearch2/expected/tsearch2_1.out
+++ b/contrib/tsearch2/expected/tsearch2_1.out
@@ -1,10 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of tsearch2.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION tsearch2;
 --tsvector
 SELECT '1'::tsvector;
  tsvector 
diff --git a/contrib/tsearch2/sql/tsearch2.sql b/contrib/tsearch2/sql/tsearch2.sql
index 99d808a1b39111a3fd9ee37402445a9e569e56c6..665882ff885751c8e17b3cc065ffd8e146b68b00 100644
--- a/contrib/tsearch2/sql/tsearch2.sql
+++ b/contrib/tsearch2/sql/tsearch2.sql
@@ -1,12 +1,4 @@
---
--- first, define the datatype.  Turn off echoing so that expected file
--- does not depend on contents of tsearch2.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i tsearch2.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION tsearch2;
 
 --tsvector
 SELECT '1'::tsvector;
diff --git a/contrib/tsearch2/tsearch2.sql.in b/contrib/tsearch2/tsearch2--1.0.sql
similarity index 99%
rename from contrib/tsearch2/tsearch2.sql.in
rename to contrib/tsearch2/tsearch2--1.0.sql
index f7f7dfdec871acdcfccedcfc9fa9e53fe46a4d38..40386a4c2a61ecd7c29bed8fb9a9e134a96d7fc2 100644
--- a/contrib/tsearch2/tsearch2.sql.in
+++ b/contrib/tsearch2/tsearch2--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/tsearch2/tsearch2.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/tsearch2/tsearch2--1.0.sql */
 
 -- These domains are just to catch schema-qualified references to the
 -- old data types.
diff --git a/contrib/tsearch2/tsearch2--unpackaged--1.0.sql b/contrib/tsearch2/tsearch2--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..a3fcc8572ab060b75a90f679516727f5dad9a8b6
--- /dev/null
+++ b/contrib/tsearch2/tsearch2--unpackaged--1.0.sql
@@ -0,0 +1,100 @@
+/* contrib/tsearch2/tsearch2--unpackaged--1.0.sql */
+
+ALTER EXTENSION tsearch2 ADD type @extschema@.tsvector;
+ALTER EXTENSION tsearch2 ADD type @extschema@.tsquery;
+ALTER EXTENSION tsearch2 ADD type @extschema@.gtsvector;
+ALTER EXTENSION tsearch2 ADD type gtsq;
+ALTER EXTENSION tsearch2 ADD function lexize(oid,text);
+ALTER EXTENSION tsearch2 ADD function lexize(text,text);
+ALTER EXTENSION tsearch2 ADD function lexize(text);
+ALTER EXTENSION tsearch2 ADD function set_curdict(integer);
+ALTER EXTENSION tsearch2 ADD function set_curdict(text);
+ALTER EXTENSION tsearch2 ADD function dex_init(internal);
+ALTER EXTENSION tsearch2 ADD function dex_lexize(internal,internal,integer);
+ALTER EXTENSION tsearch2 ADD function snb_en_init(internal);
+ALTER EXTENSION tsearch2 ADD function snb_lexize(internal,internal,integer);
+ALTER EXTENSION tsearch2 ADD function snb_ru_init_koi8(internal);
+ALTER EXTENSION tsearch2 ADD function snb_ru_init_utf8(internal);
+ALTER EXTENSION tsearch2 ADD function snb_ru_init(internal);
+ALTER EXTENSION tsearch2 ADD function spell_init(internal);
+ALTER EXTENSION tsearch2 ADD function spell_lexize(internal,internal,integer);
+ALTER EXTENSION tsearch2 ADD function syn_init(internal);
+ALTER EXTENSION tsearch2 ADD function syn_lexize(internal,internal,integer);
+ALTER EXTENSION tsearch2 ADD function @extschema@.thesaurus_init(internal);
+ALTER EXTENSION tsearch2 ADD function thesaurus_lexize(internal,internal,integer,internal);
+ALTER EXTENSION tsearch2 ADD type tokentype;
+ALTER EXTENSION tsearch2 ADD function token_type(integer);
+ALTER EXTENSION tsearch2 ADD function token_type(text);
+ALTER EXTENSION tsearch2 ADD function token_type();
+ALTER EXTENSION tsearch2 ADD function set_curprs(integer);
+ALTER EXTENSION tsearch2 ADD function set_curprs(text);
+ALTER EXTENSION tsearch2 ADD type tokenout;
+ALTER EXTENSION tsearch2 ADD function parse(oid,text);
+ALTER EXTENSION tsearch2 ADD function parse(text,text);
+ALTER EXTENSION tsearch2 ADD function parse(text);
+ALTER EXTENSION tsearch2 ADD function @extschema@.prsd_start(internal,integer);
+ALTER EXTENSION tsearch2 ADD function prsd_getlexeme(internal,internal,internal);
+ALTER EXTENSION tsearch2 ADD function @extschema@.prsd_end(internal);
+ALTER EXTENSION tsearch2 ADD function @extschema@.prsd_lextype(internal);
+ALTER EXTENSION tsearch2 ADD function prsd_headline(internal,internal,internal);
+ALTER EXTENSION tsearch2 ADD function set_curcfg(integer);
+ALTER EXTENSION tsearch2 ADD function set_curcfg(text);
+ALTER EXTENSION tsearch2 ADD function show_curcfg();
+ALTER EXTENSION tsearch2 ADD function @extschema@.length(tsvector);
+ALTER EXTENSION tsearch2 ADD function to_tsvector(oid,text);
+ALTER EXTENSION tsearch2 ADD function to_tsvector(text,text);
+ALTER EXTENSION tsearch2 ADD function @extschema@.to_tsvector(text);
+ALTER EXTENSION tsearch2 ADD function @extschema@.strip(tsvector);
+ALTER EXTENSION tsearch2 ADD function @extschema@.setweight(tsvector,"char");
+ALTER EXTENSION tsearch2 ADD function concat(tsvector,tsvector);
+ALTER EXTENSION tsearch2 ADD function @extschema@.querytree(tsquery);
+ALTER EXTENSION tsearch2 ADD function to_tsquery(oid,text);
+ALTER EXTENSION tsearch2 ADD function to_tsquery(text,text);
+ALTER EXTENSION tsearch2 ADD function @extschema@.to_tsquery(text);
+ALTER EXTENSION tsearch2 ADD function plainto_tsquery(oid,text);
+ALTER EXTENSION tsearch2 ADD function plainto_tsquery(text,text);
+ALTER EXTENSION tsearch2 ADD function @extschema@.plainto_tsquery(text);
+ALTER EXTENSION tsearch2 ADD function tsearch2();
+ALTER EXTENSION tsearch2 ADD function rank(real[],tsvector,tsquery);
+ALTER EXTENSION tsearch2 ADD function rank(real[],tsvector,tsquery,integer);
+ALTER EXTENSION tsearch2 ADD function rank(tsvector,tsquery);
+ALTER EXTENSION tsearch2 ADD function rank(tsvector,tsquery,integer);
+ALTER EXTENSION tsearch2 ADD function rank_cd(real[],tsvector,tsquery);
+ALTER EXTENSION tsearch2 ADD function rank_cd(real[],tsvector,tsquery,integer);
+ALTER EXTENSION tsearch2 ADD function rank_cd(tsvector,tsquery);
+ALTER EXTENSION tsearch2 ADD function rank_cd(tsvector,tsquery,integer);
+ALTER EXTENSION tsearch2 ADD function headline(oid,text,tsquery,text);
+ALTER EXTENSION tsearch2 ADD function headline(oid,text,tsquery);
+ALTER EXTENSION tsearch2 ADD function headline(text,text,tsquery,text);
+ALTER EXTENSION tsearch2 ADD function headline(text,text,tsquery);
+ALTER EXTENSION tsearch2 ADD function headline(text,tsquery,text);
+ALTER EXTENSION tsearch2 ADD function headline(text,tsquery);
+ALTER EXTENSION tsearch2 ADD operator family gist_tsvector_ops using gist;
+ALTER EXTENSION tsearch2 ADD operator class gist_tsvector_ops using gist;
+ALTER EXTENSION tsearch2 ADD type statinfo;
+ALTER EXTENSION tsearch2 ADD function stat(text);
+ALTER EXTENSION tsearch2 ADD function stat(text,text);
+ALTER EXTENSION tsearch2 ADD function reset_tsearch();
+ALTER EXTENSION tsearch2 ADD function get_covers(tsvector,tsquery);
+ALTER EXTENSION tsearch2 ADD type tsdebug;
+ALTER EXTENSION tsearch2 ADD function _get_parser_from_curcfg();
+ALTER EXTENSION tsearch2 ADD function @extschema@.ts_debug(text);
+ALTER EXTENSION tsearch2 ADD function @extschema@.numnode(tsquery);
+ALTER EXTENSION tsearch2 ADD function @extschema@.tsquery_and(tsquery,tsquery);
+ALTER EXTENSION tsearch2 ADD function @extschema@.tsquery_or(tsquery,tsquery);
+ALTER EXTENSION tsearch2 ADD function @extschema@.tsquery_not(tsquery);
+ALTER EXTENSION tsearch2 ADD function rewrite(tsquery,text);
+ALTER EXTENSION tsearch2 ADD function rewrite(tsquery,tsquery,tsquery);
+ALTER EXTENSION tsearch2 ADD function rewrite_accum(tsquery,tsquery[]);
+ALTER EXTENSION tsearch2 ADD function rewrite_finish(tsquery);
+ALTER EXTENSION tsearch2 ADD function rewrite(tsquery[]);
+ALTER EXTENSION tsearch2 ADD function @extschema@.tsq_mcontains(tsquery,tsquery);
+ALTER EXTENSION tsearch2 ADD function @extschema@.tsq_mcontained(tsquery,tsquery);
+ALTER EXTENSION tsearch2 ADD operator family gist_tp_tsquery_ops using gist;
+ALTER EXTENSION tsearch2 ADD operator class gist_tp_tsquery_ops using gist;
+ALTER EXTENSION tsearch2 ADD operator family gin_tsvector_ops using gin;
+ALTER EXTENSION tsearch2 ADD operator class gin_tsvector_ops using gin;
+ALTER EXTENSION tsearch2 ADD operator family @extschema@.tsvector_ops using btree;
+ALTER EXTENSION tsearch2 ADD operator class @extschema@.tsvector_ops using btree;
+ALTER EXTENSION tsearch2 ADD operator family @extschema@.tsquery_ops using btree;
+ALTER EXTENSION tsearch2 ADD operator class @extschema@.tsquery_ops using btree;
diff --git a/contrib/tsearch2/tsearch2.control b/contrib/tsearch2/tsearch2.control
new file mode 100644
index 0000000000000000000000000000000000000000..474fedeada71be5c513a1ebe960f8667c6064495
--- /dev/null
+++ b/contrib/tsearch2/tsearch2.control
@@ -0,0 +1,5 @@
+# tsearch2 extension
+comment = 'compatibility package for pre-8.3 text search functions'
+default_version = '1.0'
+module_pathname = '$libdir/tsearch2'
+relocatable = true
diff --git a/contrib/tsearch2/uninstall_tsearch2.sql b/contrib/tsearch2/uninstall_tsearch2.sql
deleted file mode 100644
index f444a218e63ab44b60679b3a52c6253e8340bbf2..0000000000000000000000000000000000000000
--- a/contrib/tsearch2/uninstall_tsearch2.sql
+++ /dev/null
@@ -1,96 +0,0 @@
-/* contrib/tsearch2/uninstall_tsearch2.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public, pg_catalog;
-
-DROP DOMAIN tsvector CASCADE;
-DROP DOMAIN tsquery CASCADE;
-DROP DOMAIN gtsvector CASCADE;
-DROP DOMAIN gtsq CASCADE;
-
-DROP TYPE tokentype CASCADE;
-DROP TYPE tokenout CASCADE;
-DROP TYPE statinfo CASCADE;
-DROP TYPE tsdebug CASCADE;
-
-DROP OPERATOR CLASS tsquery_ops USING btree CASCADE;
-
-DROP OPERATOR CLASS tsvector_ops USING btree CASCADE;
-
-DROP OPERATOR CLASS gin_tsvector_ops USING gin CASCADE;
-
-DROP OPERATOR CLASS gist_tp_tsquery_ops USING gist CASCADE;
-
-DROP OPERATOR CLASS gist_tsvector_ops USING gist CASCADE;
-
-DROP FUNCTION lexize(oid, text) ;
-DROP FUNCTION lexize(text, text);
-DROP FUNCTION lexize(text);
-DROP FUNCTION set_curdict(int);
-DROP FUNCTION set_curdict(text);
-DROP FUNCTION dex_init(internal);
-DROP FUNCTION dex_lexize(internal,internal,int4);
-DROP FUNCTION snb_en_init(internal);
-DROP FUNCTION snb_lexize(internal,internal,int4);
-DROP FUNCTION snb_ru_init_koi8(internal);
-DROP FUNCTION snb_ru_init_utf8(internal);
-DROP FUNCTION snb_ru_init(internal);
-DROP FUNCTION spell_init(internal);
-DROP FUNCTION spell_lexize(internal,internal,int4);
-DROP FUNCTION syn_init(internal);
-DROP FUNCTION syn_lexize(internal,internal,int4);
-DROP FUNCTION thesaurus_init(internal);
-DROP FUNCTION thesaurus_lexize(internal,internal,int4,internal);
-DROP FUNCTION set_curprs(int);
-DROP FUNCTION set_curprs(text);
-DROP FUNCTION prsd_start(internal,int4);
-DROP FUNCTION prsd_getlexeme(internal,internal,internal);
-DROP FUNCTION prsd_end(internal);
-DROP FUNCTION prsd_lextype(internal);
-DROP FUNCTION prsd_headline(internal,internal,internal);
-DROP FUNCTION set_curcfg(int);
-DROP FUNCTION set_curcfg(text);
-DROP FUNCTION show_curcfg();
-DROP FUNCTION length(tsvector);
-DROP FUNCTION to_tsvector(oid, text);
-DROP FUNCTION to_tsvector(text, text);
-DROP FUNCTION to_tsvector(text);
-DROP FUNCTION strip(tsvector);
-DROP FUNCTION setweight(tsvector,"char");
-DROP FUNCTION concat(tsvector,tsvector);
-DROP FUNCTION querytree(tsquery);
-DROP FUNCTION to_tsquery(oid, text);
-DROP FUNCTION to_tsquery(text, text);
-DROP FUNCTION to_tsquery(text);
-DROP FUNCTION plainto_tsquery(oid, text);
-DROP FUNCTION plainto_tsquery(text, text);
-DROP FUNCTION plainto_tsquery(text);
-DROP FUNCTION tsearch2() CASCADE;
-DROP FUNCTION rank(float4[], tsvector, tsquery);
-DROP FUNCTION rank(float4[], tsvector, tsquery, int4);
-DROP FUNCTION rank(tsvector, tsquery);
-DROP FUNCTION rank(tsvector, tsquery, int4);
-DROP FUNCTION rank_cd(float4[], tsvector, tsquery);
-DROP FUNCTION rank_cd(float4[], tsvector, tsquery, int4);
-DROP FUNCTION rank_cd(tsvector, tsquery);
-DROP FUNCTION rank_cd(tsvector, tsquery, int4);
-DROP FUNCTION headline(oid, text, tsquery, text);
-DROP FUNCTION headline(oid, text, tsquery);
-DROP FUNCTION headline(text, text, tsquery, text);
-DROP FUNCTION headline(text, text, tsquery);
-DROP FUNCTION headline(text, tsquery, text);
-DROP FUNCTION headline(text, tsquery);
-DROP FUNCTION get_covers(tsvector,tsquery);
-DROP FUNCTION _get_parser_from_curcfg();
-DROP FUNCTION numnode(tsquery);
-DROP FUNCTION tsquery_and(tsquery,tsquery);
-DROP FUNCTION tsquery_or(tsquery,tsquery);
-DROP FUNCTION tsquery_not(tsquery);
-DROP FUNCTION rewrite(tsquery, text);
-DROP FUNCTION rewrite(tsquery, tsquery, tsquery);
-DROP AGGREGATE rewrite (tsquery[]);
-DROP FUNCTION rewrite_accum(tsquery,tsquery[]);
-DROP FUNCTION rewrite_finish(tsquery);
-DROP FUNCTION tsq_mcontains(tsquery, tsquery);
-DROP FUNCTION tsq_mcontained(tsquery, tsquery);
-DROP FUNCTION reset_tsearch();
diff --git a/contrib/unaccent/.gitignore b/contrib/unaccent/.gitignore
index 6d74a7617fd803b8bd6d5fd73a35b1f98fce26e8..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/unaccent/.gitignore
+++ b/contrib/unaccent/.gitignore
@@ -1,3 +1,2 @@
-/unaccent.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/unaccent/Makefile b/contrib/unaccent/Makefile
index 254155dcca4e3ab92cfe38b07428f458b12338fc..13cd8538d3941be2d5494840559af94f404969b8 100644
--- a/contrib/unaccent/Makefile
+++ b/contrib/unaccent/Makefile
@@ -3,9 +3,10 @@
 MODULE_big = unaccent
 OBJS = unaccent.o
 
-DATA_built = unaccent.sql
-DATA = uninstall_unaccent.sql
+EXTENSION = unaccent
+DATA = unaccent--1.0.sql unaccent--unpackaged--1.0.sql
 DATA_TSEARCH = unaccent.rules
+
 REGRESS = unaccent
 
 # Adjust REGRESS_OPTS because we need a UTF8 database
diff --git a/contrib/unaccent/expected/unaccent.out b/contrib/unaccent/expected/unaccent.out
index a09e00fe5b1394eeea1ea5a875968b86aabaee8b..b93105e9c7c59bc27c2182609e61206c909e4731 100644
--- a/contrib/unaccent/expected/unaccent.out
+++ b/contrib/unaccent/expected/unaccent.out
@@ -1,6 +1,4 @@
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION unaccent;
 -- must have a UTF8 database
 SELECT getdatabaseencoding();
  getdatabaseencoding 
diff --git a/contrib/unaccent/sql/unaccent.sql b/contrib/unaccent/sql/unaccent.sql
index ede938d4795bddec457b21c56c105748ba766adf..310213994f377946288e8967fa52722f8477738e 100644
--- a/contrib/unaccent/sql/unaccent.sql
+++ b/contrib/unaccent/sql/unaccent.sql
@@ -1,8 +1,4 @@
-SET client_min_messages = warning;
-\set ECHO none
-\i unaccent.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION unaccent;
 
 -- must have a UTF8 database
 SELECT getdatabaseencoding();
diff --git a/contrib/unaccent/unaccent.sql.in b/contrib/unaccent/unaccent--1.0.sql
similarity index 84%
rename from contrib/unaccent/unaccent.sql.in
rename to contrib/unaccent/unaccent--1.0.sql
index 6d712e7bb8f605824412f14d54143c82897016e5..4dc9c3d9c66efa81e56dfc3456a2fcb4298ac85e 100644
--- a/contrib/unaccent/unaccent.sql.in
+++ b/contrib/unaccent/unaccent--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/unaccent/unaccent.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/unaccent/unaccent--1.0.sql */
 
 CREATE OR REPLACE FUNCTION unaccent(regdictionary, text)
 	RETURNS text
diff --git a/contrib/unaccent/unaccent--unpackaged--1.0.sql b/contrib/unaccent/unaccent--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..7b36d29512f62ae8f5aba8a075dcad5ae3e3d1ae
--- /dev/null
+++ b/contrib/unaccent/unaccent--unpackaged--1.0.sql
@@ -0,0 +1,8 @@
+/* contrib/unaccent/unaccent--unpackaged--1.0.sql */
+
+ALTER EXTENSION unaccent ADD function unaccent(regdictionary,text);
+ALTER EXTENSION unaccent ADD function unaccent(text);
+ALTER EXTENSION unaccent ADD function unaccent_init(internal);
+ALTER EXTENSION unaccent ADD function unaccent_lexize(internal,internal,internal,internal);
+ALTER EXTENSION unaccent ADD text search template unaccent;
+ALTER EXTENSION unaccent ADD text search dictionary unaccent;
diff --git a/contrib/unaccent/unaccent.control b/contrib/unaccent/unaccent.control
new file mode 100644
index 0000000000000000000000000000000000000000..200d2ae7bb413178bc579dde859d51c1d9646f04
--- /dev/null
+++ b/contrib/unaccent/unaccent.control
@@ -0,0 +1,5 @@
+# unaccent extension
+comment = 'text search dictionary that removes accents'
+default_version = '1.0'
+module_pathname = '$libdir/unaccent'
+relocatable = true
diff --git a/contrib/unaccent/uninstall_unaccent.sql b/contrib/unaccent/uninstall_unaccent.sql
deleted file mode 100644
index 6879d4f74c6f1c2e1780f8f5ab0a20634213e02d..0000000000000000000000000000000000000000
--- a/contrib/unaccent/uninstall_unaccent.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-/* contrib/unaccent/uninstall_unaccent.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION unaccent(regdictionary, text);
-DROP FUNCTION unaccent(text);
-DROP TEXT SEARCH DICTIONARY unaccent;
-DROP TEXT SEARCH TEMPLATE unaccent;
-DROP FUNCTION unaccent_init(internal);
-DROP FUNCTION unaccent_lexize(internal,internal,internal,internal);
diff --git a/contrib/uuid-ossp/.gitignore b/contrib/uuid-ossp/.gitignore
deleted file mode 100644
index ece095ad7bb2e77b3acf7ddb23842768de436072..0000000000000000000000000000000000000000
--- a/contrib/uuid-ossp/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/uuid-ossp.sql
diff --git a/contrib/uuid-ossp/Makefile b/contrib/uuid-ossp/Makefile
index 77ea87409f1691f6212f61514648b2945219d0ee..9b2d2e3ff93c3d50053aa95bf2bac7913ea36537 100644
--- a/contrib/uuid-ossp/Makefile
+++ b/contrib/uuid-ossp/Makefile
@@ -2,8 +2,9 @@
 
 MODULE_big = uuid-ossp
 OBJS = uuid-ossp.o
-DATA_built = uuid-ossp.sql
-DATA = uninstall_uuid-ossp.sql
+
+EXTENSION = uuid-ossp
+DATA = uuid-ossp--1.0.sql uuid-ossp--unpackaged--1.0.sql
 
 SHLIB_LINK += $(OSSP_UUID_LIBS)
 
diff --git a/contrib/uuid-ossp/uninstall_uuid-ossp.sql b/contrib/uuid-ossp/uninstall_uuid-ossp.sql
deleted file mode 100644
index 0fafb2721fcd2fa1f88235b824f16c9ccbbe58a5..0000000000000000000000000000000000000000
--- a/contrib/uuid-ossp/uninstall_uuid-ossp.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* contrib/uuid-ossp/uninstall_uuid-ossp.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION uuid_nil();
-DROP FUNCTION uuid_ns_dns();
-DROP FUNCTION uuid_ns_url();
-DROP FUNCTION uuid_ns_oid();
-DROP FUNCTION uuid_ns_x500();
-
-DROP FUNCTION uuid_generate_v1();
-DROP FUNCTION uuid_generate_v1mc();
-DROP FUNCTION uuid_generate_v3(namespace uuid, name text);
-DROP FUNCTION uuid_generate_v4();
-DROP FUNCTION uuid_generate_v5(namespace uuid, name text);
diff --git a/contrib/uuid-ossp/uuid-ossp.sql.in b/contrib/uuid-ossp/uuid-ossp--1.0.sql
similarity index 90%
rename from contrib/uuid-ossp/uuid-ossp.sql.in
rename to contrib/uuid-ossp/uuid-ossp--1.0.sql
index 71212cde4802c5dededaed2f4dc6af11ee035938..34b32de77e0bd22467d5bcb5adb5f69eca3797f8 100644
--- a/contrib/uuid-ossp/uuid-ossp.sql.in
+++ b/contrib/uuid-ossp/uuid-ossp--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/uuid-ossp/uuid-ossp.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/uuid-ossp/uuid-ossp--1.0.sql */
 
 CREATE OR REPLACE FUNCTION uuid_nil()
 RETURNS uuid
diff --git a/contrib/uuid-ossp/uuid-ossp--unpackaged--1.0.sql b/contrib/uuid-ossp/uuid-ossp--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..bc984dd8c09d58898335a64f2cdae87ff9ca5843
--- /dev/null
+++ b/contrib/uuid-ossp/uuid-ossp--unpackaged--1.0.sql
@@ -0,0 +1,12 @@
+/* contrib/uuid-ossp/uuid-ossp--unpackaged--1.0.sql */
+
+ALTER EXTENSION "uuid-ossp" ADD function uuid_nil();
+ALTER EXTENSION "uuid-ossp" ADD function uuid_ns_dns();
+ALTER EXTENSION "uuid-ossp" ADD function uuid_ns_url();
+ALTER EXTENSION "uuid-ossp" ADD function uuid_ns_oid();
+ALTER EXTENSION "uuid-ossp" ADD function uuid_ns_x500();
+ALTER EXTENSION "uuid-ossp" ADD function uuid_generate_v1();
+ALTER EXTENSION "uuid-ossp" ADD function uuid_generate_v1mc();
+ALTER EXTENSION "uuid-ossp" ADD function uuid_generate_v3(namespace uuid, name text);
+ALTER EXTENSION "uuid-ossp" ADD function uuid_generate_v4();
+ALTER EXTENSION "uuid-ossp" ADD function uuid_generate_v5(namespace uuid, name text);
diff --git a/contrib/uuid-ossp/uuid-ossp.control b/contrib/uuid-ossp/uuid-ossp.control
new file mode 100644
index 0000000000000000000000000000000000000000..f52ae99d41be11c70066259618732faf8b976638
--- /dev/null
+++ b/contrib/uuid-ossp/uuid-ossp.control
@@ -0,0 +1,5 @@
+# uuid-ossp extension
+comment = 'generate universally unique identifiers (UUIDs)'
+default_version = '1.0'
+module_pathname = '$libdir/uuid-ossp'
+relocatable = true
diff --git a/contrib/xml2/.gitignore b/contrib/xml2/.gitignore
index 5ef9dbf4d4b74726e0e4f7f09023b4bcc289acfd..19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a 100644
--- a/contrib/xml2/.gitignore
+++ b/contrib/xml2/.gitignore
@@ -1,3 +1,2 @@
-/pgxml.sql
 # Generated subdirectories
 /results/
diff --git a/contrib/xml2/Makefile b/contrib/xml2/Makefile
index 57b4cbfac5df11e56733d8d274bcf0850fec11be..ad325723c9917235edd7a629da1a2901c06be331 100644
--- a/contrib/xml2/Makefile
+++ b/contrib/xml2/Makefile
@@ -1,15 +1,15 @@
 # contrib/xml2/Makefile
 
 MODULE_big = pgxml
-
 OBJS = xpath.o xslt_proc.o
 
-SHLIB_LINK += $(filter -lxslt, $(LIBS)) $(filter -lxml2, $(LIBS))
+EXTENSION = xml2
+DATA = xml2--1.0.sql xml2--unpackaged--1.0.sql
 
-DATA_built = pgxml.sql
-DATA = uninstall_pgxml.sql
 REGRESS = xml2
 
+SHLIB_LINK += $(filter -lxslt, $(LIBS)) $(filter -lxml2, $(LIBS))
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/xml2/expected/xml2.out b/contrib/xml2/expected/xml2.out
index 8ce04d0b848642e2a4c931f919cf0f759bcb144e..3bf676fb400717c12f8f550108f048568feb28f7 100644
--- a/contrib/xml2/expected/xml2.out
+++ b/contrib/xml2/expected/xml2.out
@@ -1,10 +1,4 @@
---
--- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of pgxml.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION xml2;
 select query_to_xml('select 1 as x',true,false,'');
                          query_to_xml                          
 ---------------------------------------------------------------
diff --git a/contrib/xml2/expected/xml2_1.out b/contrib/xml2/expected/xml2_1.out
index d2d243ada7d95c85cc62024709f4d3bc8e1d3d5a..fda626e08c7f62040a0a106e964bb486bce10250 100644
--- a/contrib/xml2/expected/xml2_1.out
+++ b/contrib/xml2/expected/xml2_1.out
@@ -1,10 +1,4 @@
---
--- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of pgxml.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-RESET client_min_messages;
+CREATE EXTENSION xml2;
 select query_to_xml('select 1 as x',true,false,'');
                          query_to_xml                          
 ---------------------------------------------------------------
diff --git a/contrib/xml2/sql/xml2.sql b/contrib/xml2/sql/xml2.sql
index 5b3cc997f50e25bc3b7f64d3d709546bd8f79002..4a996af71678b58027486859b208ccf9fce48d3f 100644
--- a/contrib/xml2/sql/xml2.sql
+++ b/contrib/xml2/sql/xml2.sql
@@ -1,12 +1,4 @@
---
--- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of pgxml.sql.
---
-SET client_min_messages = warning;
-\set ECHO none
-\i pgxml.sql
-\set ECHO all
-RESET client_min_messages;
+CREATE EXTENSION xml2;
 
 select query_to_xml('select 1 as x',true,false,'');
 
diff --git a/contrib/xml2/uninstall_pgxml.sql b/contrib/xml2/uninstall_pgxml.sql
deleted file mode 100644
index 1696390f80d4608663cf083a6d05557bbabc649b..0000000000000000000000000000000000000000
--- a/contrib/xml2/uninstall_pgxml.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-/* contrib/xml2/uninstall_pgxml.sql */
-
--- Adjust this setting to control where the objects get dropped.
-SET search_path = public;
-
-DROP FUNCTION xslt_process(text,text);
-
-DROP FUNCTION xslt_process(text,text,text);
-
-DROP FUNCTION xpath_table(text,text,text,text,text);
-
-DROP FUNCTION xpath_nodeset(text,text,text);
-
-DROP FUNCTION xpath_nodeset(text,text);
-
-DROP FUNCTION xpath_list(text,text);
-
-DROP FUNCTION xpath_list(text,text,text);
-
-DROP FUNCTION xpath_bool(text,text);
-
-DROP FUNCTION xpath_number(text,text);
-
-DROP FUNCTION xpath_nodeset(text,text,text,text);
-
-DROP FUNCTION xpath_string(text,text);
-
-DROP FUNCTION xml_encode_special_chars(text);
-
--- deprecated old name for xml_is_well_formed
-DROP FUNCTION xml_valid(text);
diff --git a/contrib/xml2/pgxml.sql.in b/contrib/xml2/xml2--1.0.sql
similarity index 93%
rename from contrib/xml2/pgxml.sql.in
rename to contrib/xml2/xml2--1.0.sql
index 8c3d420afd3158097471ef7690ccdc836d5f3d65..100f57291fafe4a472ca56116f8d8970fdc86514 100644
--- a/contrib/xml2/pgxml.sql.in
+++ b/contrib/xml2/xml2--1.0.sql
@@ -1,7 +1,4 @@
-/* contrib/xml2/pgxml.sql.in */
-
--- Adjust this setting to control where the objects get created.
-SET search_path = public;
+/* contrib/xml2/xml2--1.0.sql */
 
 --SQL for XML parser
 
diff --git a/contrib/xml2/xml2--unpackaged--1.0.sql b/contrib/xml2/xml2--unpackaged--1.0.sql
new file mode 100644
index 0000000000000000000000000000000000000000..a4716cf9168cb33330e05bc323d825955248b5fc
--- /dev/null
+++ b/contrib/xml2/xml2--unpackaged--1.0.sql
@@ -0,0 +1,16 @@
+/* contrib/xml2/xml2--unpackaged--1.0.sql */
+
+ALTER EXTENSION xml2 ADD function xslt_process(text,text);
+ALTER EXTENSION xml2 ADD function xslt_process(text,text,text);
+ALTER EXTENSION xml2 ADD function xpath_table(text,text,text,text,text);
+ALTER EXTENSION xml2 ADD function xpath_nodeset(text,text,text);
+ALTER EXTENSION xml2 ADD function xpath_nodeset(text,text);
+ALTER EXTENSION xml2 ADD function xpath_list(text,text);
+ALTER EXTENSION xml2 ADD function xpath_list(text,text,text);
+ALTER EXTENSION xml2 ADD function xpath_bool(text,text);
+ALTER EXTENSION xml2 ADD function xpath_number(text,text);
+ALTER EXTENSION xml2 ADD function xpath_nodeset(text,text,text,text);
+ALTER EXTENSION xml2 ADD function xpath_string(text,text);
+ALTER EXTENSION xml2 ADD function xml_encode_special_chars(text);
+ALTER EXTENSION xml2 ADD function xml_valid(text);
+ALTER EXTENSION xml2 ADD function xml_is_well_formed(text);
diff --git a/contrib/xml2/xml2.control b/contrib/xml2/xml2.control
new file mode 100644
index 0000000000000000000000000000000000000000..004649d652032d258acd138318a868c8ee36dc67
--- /dev/null
+++ b/contrib/xml2/xml2.control
@@ -0,0 +1,5 @@
+# xml2 extension
+comment = 'XPath querying and XSLT'
+default_version = '1.0'
+module_pathname = '$libdir/pgxml'
+relocatable = true