Skip to content

Commit 458857c

Browse files
committed
Throw a useful error message if an extension script file is fed to psql.
We have seen one too many reports of people trying to use 9.1 extension files in the old-fashioned way of sourcing them in psql. Not only does that usually not work (due to failure to substitute for MODULE_PATHNAME and/or @extschema@), but if it did work they'd get a collection of loose objects not an extension. To prevent this, insert an \echo ... \quit line that prints a suitable error message into each extension script file, and teach commands/extension.c to ignore lines starting with \echo. That should not only prevent any adverse consequences of loading a script file the wrong way, but make it crystal clear to users that they need to do it differently now. Tom Lane, following an idea of Andrew Dunstan's. Back-patch into 9.1 ... there is not going to be much value in this if we wait till 9.2.
1 parent e0d2735 commit 458857c

File tree

78 files changed

+274
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+274
-17
lines changed

contrib/adminpack/adminpack--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/adminpack/adminpack--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION adminpack" to load this file. \quit
5+
36
/* ***********************************************
47
* Administrative functions for PostgreSQL
58
* *********************************************** */

contrib/btree_gin/btree_gin--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/btree_gin/btree_gin--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION btree_gin" to load this file. \quit
5+
36
CREATE FUNCTION gin_btree_consistent(internal, int2, anyelement, int4, internal, internal)
47
RETURNS bool
58
AS 'MODULE_PATHNAME'

contrib/btree_gin/btree_gin--unpackaged--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/btree_gin/btree_gin--unpackaged--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION btree_gin" to load this file. \quit
5+
36
ALTER EXTENSION btree_gin ADD function gin_btree_consistent(internal,smallint,anyelement,integer,internal,internal);
47
ALTER EXTENSION btree_gin ADD function gin_extract_value_int2(smallint,internal);
58
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_int2(smallint,smallint,smallint,internal);

contrib/btree_gist/btree_gist--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/btree_gist/btree_gist--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION btree_gist" to load this file. \quit
5+
36
CREATE FUNCTION gbtreekey4_in(cstring)
47
RETURNS gbtreekey4
58
AS 'MODULE_PATHNAME', 'gbtreekey_in'

contrib/btree_gist/btree_gist--unpackaged--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/btree_gist/btree_gist--unpackaged--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION btree_gist" to load this file. \quit
5+
36
ALTER EXTENSION btree_gist ADD type gbtreekey4;
47
ALTER EXTENSION btree_gist ADD function gbtreekey4_in(cstring);
58
ALTER EXTENSION btree_gist ADD function gbtreekey4_out(gbtreekey4);

contrib/chkpass/chkpass--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/chkpass/chkpass--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION chkpass" to load this file. \quit
5+
36
--
47
-- Input and output functions and the type itself:
58
--

contrib/chkpass/chkpass--unpackaged--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/chkpass/chkpass--unpackaged--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION chkpass" to load this file. \quit
5+
36
ALTER EXTENSION chkpass ADD type chkpass;
47
ALTER EXTENSION chkpass ADD function chkpass_in(cstring);
58
ALTER EXTENSION chkpass ADD function chkpass_out(chkpass);

contrib/citext/citext--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/citext/citext--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION citext" to load this file. \quit
5+
36
--
47
-- PostgreSQL code for CITEXT.
58
--

contrib/citext/citext--unpackaged--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/citext/citext--unpackaged--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION citext" to load this file. \quit
5+
36
ALTER EXTENSION citext ADD type citext;
47
ALTER EXTENSION citext ADD function citextin(cstring);
58
ALTER EXTENSION citext ADD function citextout(citext);

contrib/cube/cube--1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* contrib/cube/cube--1.0.sql */
22

3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION cube" to load this file. \quit
5+
36
-- Create the user-defined type for N-dimensional boxes
47

58
CREATE FUNCTION cube_in(cstring)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy