pgxn_utils 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +9 -0
- data/META.json +32 -10
- data/Makefile +1 -1
- data/README.md +179 -39
- data/Rakefile +77 -14
- data/bin/pgxn-bundle +22 -0
- data/bin/pgxn-change +22 -0
- data/bin/pgxn-release +22 -0
- data/bin/pgxn-skeleton +22 -0
- data/bin/pgxn-utils +15 -3
- data/lib/pgxn_utils/cli.rb +34 -19
- data/lib/pgxn_utils/no_tasks.rb +63 -0
- data/lib/pgxn_utils/templates/c/%extension_name%.control.tt +5 -0
- data/lib/pgxn_utils/templates/c/.gitignore.tt +8 -0
- data/lib/pgxn_utils/templates/c/.template +1 -0
- data/lib/pgxn_utils/templates/c/META.json.tt +37 -0
- data/lib/pgxn_utils/templates/c/Makefile.tt +24 -0
- data/lib/pgxn_utils/templates/c/README.md.tt +80 -0
- data/lib/pgxn_utils/templates/c/doc/%extension_name%.md.tt +33 -0
- data/lib/pgxn_utils/templates/c/sql/%extension_name%.sql.tt +17 -0
- data/lib/pgxn_utils/templates/c/sql/uninstall_%extension_name%.sql.tt +1 -0
- data/lib/pgxn_utils/templates/c/src/%extension_name%.c.tt +26 -0
- data/lib/pgxn_utils/templates/c/test/expected/base.out.tt +9 -0
- data/lib/pgxn_utils/templates/c/test/sql/base.sql.tt +10 -0
- data/lib/pgxn_utils/templates/fdw/%extension_name%.control.tt +5 -0
- data/lib/pgxn_utils/templates/fdw/.gitignore.tt +8 -0
- data/lib/pgxn_utils/templates/fdw/.template +1 -0
- data/lib/pgxn_utils/templates/fdw/META.json.tt +37 -0
- data/lib/pgxn_utils/templates/fdw/Makefile.tt +24 -0
- data/lib/pgxn_utils/templates/fdw/README.md.tt +80 -0
- data/lib/pgxn_utils/templates/fdw/doc/%extension_name%.md.tt +33 -0
- data/lib/pgxn_utils/templates/fdw/sql/%extension_name%.sql.tt +31 -0
- data/lib/pgxn_utils/templates/fdw/sql/uninstall_%extension_name%.sql.tt +14 -0
- data/lib/pgxn_utils/templates/fdw/src/%extension_name%_fdw.c.tt +323 -0
- data/lib/pgxn_utils/templates/fdw/test/expected/base.out.tt +4 -0
- data/lib/pgxn_utils/templates/fdw/test/sql/base.sql.tt +8 -0
- data/lib/pgxn_utils/templates/root/.gitignore.tt +8 -0
- data/lib/pgxn_utils/templates/root/META.json.tt +21 -21
- data/lib/pgxn_utils/templates/sql/%extension_name%.control.tt +4 -0
- data/lib/pgxn_utils/templates/sql/.gitignore.tt +8 -0
- data/lib/pgxn_utils/templates/sql/.template +1 -0
- data/lib/pgxn_utils/templates/sql/META.json.tt +27 -0
- data/lib/pgxn_utils/templates/sql/Makefile.tt +28 -0
- data/lib/pgxn_utils/templates/sql/README.md.tt +80 -0
- data/lib/pgxn_utils/templates/sql/doc/%extension_name%.md.tt +33 -0
- data/lib/pgxn_utils/templates/sql/sql/%extension_name%.sql.tt +31 -0
- data/lib/pgxn_utils/templates/sql/sql/uninstall_%extension_name%.sql.tt +21 -0
- data/lib/pgxn_utils/templates/sql/test/expected/base.out.tt +49 -0
- data/lib/pgxn_utils/templates/sql/test/sql/base.sql.tt +25 -0
- data/lib/pgxn_utils/version.rb +1 -1
- data/lib/pgxn_utils.rb +1 -1
- data/pgxn_utils.gemspec +21 -30
- data/spec/cli_spec.rb +73 -8
- data/spec/no_tasks_spec.rb +2 -0
- data/spec/spec_helper.rb +21 -4
- metadata +87 -30
data/lib/pgxn_utils/cli.rb
CHANGED
@@ -23,20 +23,24 @@ module PgxnUtils
|
|
23
23
|
method_option :generated_by, :aliases => "-b", :type => :string, :desc => "Name of extension's generator"
|
24
24
|
method_option :tags, :aliases => "-t", :type => :array, :desc => "Defines extension's tags"
|
25
25
|
method_option :release_status, :aliases => "-r", :type => :string, :desc => "Initial extension's release status"
|
26
|
+
method_option :git, :type => :boolean, :default => false, :desc => "Initialize a git repository after create the extension"
|
27
|
+
method_option :template, :type => :string, :default => "sql", :desc => "The template that will be used to create the extension. Expected values are: sql, c, fdw"
|
26
28
|
|
27
29
|
def skeleton(extension_name,target=nil)
|
28
30
|
self.target = options[:target] || target || "."
|
29
31
|
|
30
32
|
if is_extension?("#{self.target}/#{extension_name}")
|
31
33
|
say "'#{extension_name}' already exists. Please, use 'change' instead 'skeleton'.", :red
|
32
|
-
elsif is_extension?(
|
34
|
+
elsif is_extension?(self.target)
|
33
35
|
say "You are inside a extension directory, already. Consider use 'change' instead.", :red
|
34
36
|
elsif is_dir?("#{self.target}/#{extension_name}")
|
35
37
|
say "Can't create an extension overwriting an existing directory.", :red
|
36
38
|
else
|
37
39
|
self.set_accessors extension_name
|
38
40
|
|
39
|
-
directory
|
41
|
+
directory selected_template, extension_name
|
42
|
+
|
43
|
+
init_repository("#{self.target}/#{extension_name}") if options[:git]
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
@@ -59,14 +63,16 @@ module PgxnUtils
|
|
59
63
|
def change(extension_name=".")
|
60
64
|
extension_path, extension_name = resolve_extension_path_and_name(extension_name)
|
61
65
|
|
66
|
+
template_type = File.read("#{extension_path}/.template").chomp
|
67
|
+
|
62
68
|
self.target = extension_path
|
63
69
|
self.extension_name = extension_name
|
64
70
|
|
65
71
|
set_accessors(extension_name)
|
66
72
|
|
67
73
|
if is_extension?(extension_path)
|
68
|
-
template "
|
69
|
-
template "
|
74
|
+
template "#{template_type}/META.json.tt", "#{extension_path}/META.json"
|
75
|
+
template "#{template_type}/%extension_name%.control.tt", "#{extension_path}/%extension_name%.control"
|
70
76
|
else
|
71
77
|
say "'#{extension_name}' doesn't appears to be an extension. Please, supply the extension's name", :red
|
72
78
|
end
|
@@ -83,21 +89,30 @@ module PgxnUtils
|
|
83
89
|
|
84
90
|
self.target = path
|
85
91
|
archive_name = "#{path}-#{config_options['version']}"
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
92
|
+
prefix_name = "#{extension_name}-#{config_options['version']}/"
|
93
|
+
|
94
|
+
archive = "#{archive_name}.zip"
|
95
|
+
archived = false
|
96
|
+
|
97
|
+
if has_scm?(path)
|
98
|
+
if is_dirty?(path)
|
99
|
+
say "Your repository is dirty! You should commit or stash before continue.", :red
|
100
|
+
else
|
101
|
+
if can_zip?(archive)
|
102
|
+
scm_archive(path, archive, prefix_name)
|
103
|
+
archived = true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
else
|
107
|
+
if can_zip?(archive)
|
108
|
+
make_dist_clean(path)
|
109
|
+
zip_archive(path, archive, prefix_name)
|
110
|
+
archived = true
|
111
|
+
end
|
112
|
+
end
|
113
|
+
say_status(:create, archive, :green) if archived
|
114
|
+
end
|
115
|
+
end
|
101
116
|
|
102
117
|
desc "release filename", "Release an extension to PGXN"
|
103
118
|
|
data/lib/pgxn_utils/no_tasks.rb
CHANGED
@@ -2,6 +2,47 @@ module PgxnUtils
|
|
2
2
|
module NoTasks
|
3
3
|
|
4
4
|
include PgxnUtils::Constants
|
5
|
+
include Grit
|
6
|
+
|
7
|
+
def selected_template
|
8
|
+
template = options[:template]
|
9
|
+
|
10
|
+
unless [ 'sql', 'c', 'fdw' ].include?(template)
|
11
|
+
if Dir["#{template}/*"].include?("#{template}/META.json") or
|
12
|
+
Dir["#{template}/*"].include?("#{template}/META.json.tt")
|
13
|
+
template = File.expand_path(options[:template])
|
14
|
+
else
|
15
|
+
raise "invalid template: #{template}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
template
|
19
|
+
end
|
20
|
+
|
21
|
+
def init_repository(extension_dir)
|
22
|
+
repo = Repo.init(extension_dir)
|
23
|
+
original_dir = File.expand_path "."
|
24
|
+
|
25
|
+
if repo
|
26
|
+
say_status :init, "#{extension_dir}", :green
|
27
|
+
|
28
|
+
FileUtils.chdir extension_dir
|
29
|
+
repo.add "."
|
30
|
+
if repo.commit_index("initial commit")
|
31
|
+
say_status :commit, "initial commit", :green
|
32
|
+
else
|
33
|
+
say_status :failed, "initial commit", :red
|
34
|
+
end
|
35
|
+
else
|
36
|
+
say_status :error, " initializing #{extension_dir}", :red
|
37
|
+
end
|
38
|
+
|
39
|
+
FileUtils.chdir original_dir
|
40
|
+
end
|
41
|
+
|
42
|
+
def is_dirty?(extension_dir)
|
43
|
+
repo = Repo.init(extension_dir)
|
44
|
+
repo.status.map(&:type).uniq != [nil]
|
45
|
+
end
|
5
46
|
|
6
47
|
def make_dist_clean(path)
|
7
48
|
inside path do
|
@@ -77,12 +118,34 @@ module PgxnUtils
|
|
77
118
|
[ extension_path, extension_name ]
|
78
119
|
end
|
79
120
|
|
121
|
+
def has_scm?(path)
|
122
|
+
begin
|
123
|
+
Repo.new(path)
|
124
|
+
rescue Grit::InvalidGitRepositoryError
|
125
|
+
false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def scm_archive(path, archive, prefix, treeish='master')
|
130
|
+
git = Git.new(Repo.new(path).path)
|
131
|
+
git.archive({:format => "zip", :prefix => prefix, :output => archive}, treeish)
|
132
|
+
end
|
133
|
+
|
134
|
+
def zip_archive(path, archive, prefix)
|
135
|
+
Zip::ZipFile.open(archive, Zip::ZipFile::CREATE) do |zip|
|
136
|
+
Dir["#{path}/**/**"].each do |file|
|
137
|
+
zip.add("#{prefix}#{file.sub(path+'/','')}", file) unless File.directory?(file)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
80
142
|
def can_zip?(archive)
|
81
143
|
can_zip = false
|
82
144
|
|
83
145
|
if File.exists?(archive)
|
84
146
|
say_status :conflict, archive, :red
|
85
147
|
if yes? "Overwrite #{archive}? [yN]"
|
148
|
+
FileUtils.rm_f archive
|
86
149
|
can_zip = true
|
87
150
|
else
|
88
151
|
can_zip = false
|
@@ -0,0 +1 @@
|
|
1
|
+
c
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"name": "<%= extension_name %>",
|
3
|
+
"abstract": "<%= abstract %>",
|
4
|
+
"description": "<%= description %>",
|
5
|
+
"version": "<%= version %>",
|
6
|
+
"maintainer": "<%= maintainer %>",
|
7
|
+
"license": "<%= license %>",
|
8
|
+
"provides": {
|
9
|
+
"<%= extension_name %>": {
|
10
|
+
"abstract": "<%= abstract %>",
|
11
|
+
"file": "sql/<%= extension_name %>.sql",
|
12
|
+
"docfile": "doc/<%= extension_name %>.md",
|
13
|
+
"version": "<%= version %>"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"release_status": "<%= release_status %>",
|
17
|
+
"resources": {
|
18
|
+
"bugtracker": {
|
19
|
+
"web": "http://change.me"
|
20
|
+
},
|
21
|
+
"repository": {
|
22
|
+
"url": "git://change.me/<%= extension_name %>.git",
|
23
|
+
"web": "http://change.me",
|
24
|
+
"type": "git"
|
25
|
+
}
|
26
|
+
},
|
27
|
+
<% if generated_by %>
|
28
|
+
"generated_by": "<%= generated_by %>",
|
29
|
+
<% end %>
|
30
|
+
<% if tags %>
|
31
|
+
"tags": [ <%= tags.collect { |t| %Q|"#{t}"| }.join(",") %> ],
|
32
|
+
<% end %>
|
33
|
+
"meta-spec": {
|
34
|
+
"version": "1.0.0",
|
35
|
+
"url": "http://pgxn.org/meta/spec.txt"
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
EXTENSION = <%= extension_name %>
|
2
|
+
EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
|
3
|
+
|
4
|
+
DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
|
5
|
+
DOCS = $(wildcard doc/*.md)
|
6
|
+
TESTS = $(wildcard test/sql/*.sql)
|
7
|
+
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
|
8
|
+
REGRESS_OPTS = --inputdir=test --load-language=plpgsql
|
9
|
+
MODULES = $(patsubst %.c,%,$(wildcard src/*.c))
|
10
|
+
PG_CONFIG = pg_config
|
11
|
+
PG91 = $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0" && echo no || echo yes)
|
12
|
+
|
13
|
+
ifeq ($(PG91),yes)
|
14
|
+
all: sql/$(EXTENSION)--$(EXTVERSION).sql
|
15
|
+
|
16
|
+
sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
|
17
|
+
cp $< $@
|
18
|
+
|
19
|
+
DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
|
20
|
+
EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql
|
21
|
+
endif
|
22
|
+
|
23
|
+
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
24
|
+
include $(PGXS)
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<%= extension_name %>
|
2
|
+
<%= extension_name.gsub(/./,"=") %>
|
3
|
+
|
4
|
+
<%= description %>
|
5
|
+
|
6
|
+
To build it, just do this:
|
7
|
+
|
8
|
+
make
|
9
|
+
make installcheck
|
10
|
+
make install
|
11
|
+
|
12
|
+
If you encounter an error such as:
|
13
|
+
|
14
|
+
"Makefile", line 8: Need an operator
|
15
|
+
|
16
|
+
You need to use GNU make, which may well be installed on your system as
|
17
|
+
`gmake`:
|
18
|
+
|
19
|
+
gmake
|
20
|
+
gmake install
|
21
|
+
gmake installcheck
|
22
|
+
|
23
|
+
If you encounter an error such as:
|
24
|
+
|
25
|
+
make: pg_config: Command not found
|
26
|
+
|
27
|
+
Be sure that you have `pg_config` installed and in your path. If you used a
|
28
|
+
package management system such as RPM to install PostgreSQL, be sure that the
|
29
|
+
`-devel` package is also installed. If necessary tell the build process where
|
30
|
+
to find it:
|
31
|
+
|
32
|
+
env PG_CONFIG=/path/to/pg_config make && make installcheck && make install
|
33
|
+
|
34
|
+
And finally, if all that fails (and if you're on PostgreSQL 8.1 or lower, it
|
35
|
+
likely will), copy the entire distribution directory to the `contrib/`
|
36
|
+
subdirectory of the PostgreSQL source tree and try it there without
|
37
|
+
`pg_config`:
|
38
|
+
|
39
|
+
env NO_PGXS=1 make && make installcheck && make install
|
40
|
+
|
41
|
+
If you encounter an error such as:
|
42
|
+
|
43
|
+
ERROR: must be owner of database regression
|
44
|
+
|
45
|
+
You need to run the test suite using a super user, such as the default
|
46
|
+
"postgres" super user:
|
47
|
+
|
48
|
+
make installcheck PGUSER=postgres
|
49
|
+
|
50
|
+
Once <%= extension_name %> is installed, you can add it to a database. If you're running
|
51
|
+
PostgreSQL 9.1.0 or greater, it's a simple as connecting to a database as a
|
52
|
+
super user and running:
|
53
|
+
|
54
|
+
CREATE EXTENSION <%= extension_name %>;
|
55
|
+
|
56
|
+
If you've upgraded your cluster to PostgreSQL 9.1 and already had <%= extension_name %>
|
57
|
+
installed, you can upgrade it to a properly packaged extension with:
|
58
|
+
|
59
|
+
CREATE EXTENSION <%= extension_name %> FROM unpackaged;
|
60
|
+
|
61
|
+
For versions of PostgreSQL less than 9.1.0, you'll need to run the
|
62
|
+
installation script:
|
63
|
+
|
64
|
+
psql -d mydb -f /path/to/pgsql/share/contrib/<%= extension_name %>.sql
|
65
|
+
|
66
|
+
If you want to install <%= extension_name %> and all of its supporting objects into a specific
|
67
|
+
schema, use the `PGOPTIONS` environment variable to specify the schema, like
|
68
|
+
so:
|
69
|
+
|
70
|
+
PGOPTIONS=--search_path=extensions psql -d mydb -f <%= extension_name %>.sql
|
71
|
+
|
72
|
+
Dependencies
|
73
|
+
------------
|
74
|
+
The `<%= extension_name %>` data type has no dependencies other than PostgreSQL.
|
75
|
+
|
76
|
+
Copyright and License
|
77
|
+
---------------------
|
78
|
+
|
79
|
+
Copyright (c) <%= Time.now.strftime("%Y") %> <%= maintainer %>.
|
80
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= extension_name %>
|
2
|
+
<%= extension_name.gsub(/./,"=") %>
|
3
|
+
|
4
|
+
Synopsis
|
5
|
+
--------
|
6
|
+
|
7
|
+
Show a brief synopsis of the extension.
|
8
|
+
|
9
|
+
Description
|
10
|
+
-----------
|
11
|
+
|
12
|
+
<%= description %>
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
|
17
|
+
Show usage.
|
18
|
+
|
19
|
+
Support
|
20
|
+
-------
|
21
|
+
|
22
|
+
There is issues tracker? Github? Put this information here.
|
23
|
+
|
24
|
+
Author
|
25
|
+
------
|
26
|
+
|
27
|
+
[<%= maintainer %>]
|
28
|
+
|
29
|
+
Copyright and License
|
30
|
+
---------------------
|
31
|
+
|
32
|
+
Copyright (c) <%= Time.now.strftime("%Y") %> <%= maintainer %>.
|
33
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/*
|
2
|
+
* Author: <%= maintainer %>
|
3
|
+
* Created at: <%= Time.now %>
|
4
|
+
*
|
5
|
+
*/
|
6
|
+
|
7
|
+
--
|
8
|
+
-- This is a example code genereted automaticaly
|
9
|
+
-- by pgxn-utils.
|
10
|
+
|
11
|
+
-- This is how you define a C function in PostgreSQL.
|
12
|
+
CREATE OR REPLACE FUNCTION <%= extension_name %>(text)
|
13
|
+
RETURNS text
|
14
|
+
AS '<%= extension_name %>'
|
15
|
+
LANGUAGE C IMMUTABLE STRICT;
|
16
|
+
|
17
|
+
-- See more: http://www.postgresql.org/docs/current/static/xfunc-c.html
|
@@ -0,0 +1 @@
|
|
1
|
+
DROP FUNCTION <%= extension_name %>(text);
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#include "postgres.h"
|
2
|
+
#include "fmgr.h"
|
3
|
+
/*
|
4
|
+
* You can include more files here if needed.
|
5
|
+
* To use some types, you must include the
|
6
|
+
* correct file here based on:
|
7
|
+
* http://www.postgresql.org/docs/current/static/xfunc-c.html#XFUNC-C-TYPE-TABLE
|
8
|
+
*/
|
9
|
+
|
10
|
+
PG_MODULE_MAGIC;
|
11
|
+
|
12
|
+
PG_FUNCTION_INFO_V1(<%= extension_name %>);
|
13
|
+
Datum <%= extension_name %>(PG_FUNCTION_ARGS);
|
14
|
+
|
15
|
+
Datum
|
16
|
+
<%= extension_name %>(PG_FUNCTION_ARGS)
|
17
|
+
{
|
18
|
+
/*
|
19
|
+
* This is an empty body and will return NULL
|
20
|
+
*
|
21
|
+
* You should remove this comment and type
|
22
|
+
* cool code here!
|
23
|
+
*/
|
24
|
+
|
25
|
+
PG_RETURN_NULL();
|
26
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
fdw
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"name": "<%= extension_name %>",
|
3
|
+
"abstract": "<%= abstract %>",
|
4
|
+
"description": "<%= description %>",
|
5
|
+
"version": "<%= version %>",
|
6
|
+
"maintainer": "<%= maintainer %>",
|
7
|
+
"license": "<%= license %>",
|
8
|
+
"provides": {
|
9
|
+
"<%= extension_name %>": {
|
10
|
+
"abstract": "<%= abstract %>",
|
11
|
+
"file": "sql/<%= extension_name %>.sql",
|
12
|
+
"docfile": "doc/<%= extension_name %>.md",
|
13
|
+
"version": "<%= version %>"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"release_status": "<%= release_status %>",
|
17
|
+
"resources": {
|
18
|
+
"bugtracker": {
|
19
|
+
"web": "http://change.me"
|
20
|
+
},
|
21
|
+
"repository": {
|
22
|
+
"url": "git://change.me/<%= extension_name %>.git",
|
23
|
+
"web": "http://change.me",
|
24
|
+
"type": "git"
|
25
|
+
}
|
26
|
+
},
|
27
|
+
<% if generated_by %>
|
28
|
+
"generated_by": "<%= generated_by %>",
|
29
|
+
<% end %>
|
30
|
+
<% if tags %>
|
31
|
+
"tags": [ <%= tags.collect { |t| %Q|"#{t}"| }.join(",") %> ],
|
32
|
+
<% end %>
|
33
|
+
"meta-spec": {
|
34
|
+
"version": "1.0.0",
|
35
|
+
"url": "http://pgxn.org/meta/spec.txt"
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
EXTENSION = <%= extension_name %>
|
2
|
+
EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
|
3
|
+
|
4
|
+
DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
|
5
|
+
DOCS = $(wildcard doc/*.md)
|
6
|
+
TESTS = $(wildcard test/sql/*.sql)
|
7
|
+
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
|
8
|
+
REGRESS_OPTS = --inputdir=test --load-language=plpgsql
|
9
|
+
MODULES = $(patsubst %.c,%,$(wildcard src/*.c))
|
10
|
+
PG_CONFIG = pg_config
|
11
|
+
PG91 = $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0" && echo no || echo yes)
|
12
|
+
|
13
|
+
ifeq ($(PG91),yes)
|
14
|
+
all: sql/$(EXTENSION)--$(EXTVERSION).sql
|
15
|
+
|
16
|
+
sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
|
17
|
+
cp $< $@
|
18
|
+
|
19
|
+
DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
|
20
|
+
EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql
|
21
|
+
endif
|
22
|
+
|
23
|
+
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
24
|
+
include $(PGXS)
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<%= extension_name %>
|
2
|
+
<%= extension_name.gsub(/./,"=") %>
|
3
|
+
|
4
|
+
<%= description %>
|
5
|
+
|
6
|
+
To build it, just do this:
|
7
|
+
|
8
|
+
make
|
9
|
+
make installcheck
|
10
|
+
make install
|
11
|
+
|
12
|
+
If you encounter an error such as:
|
13
|
+
|
14
|
+
"Makefile", line 8: Need an operator
|
15
|
+
|
16
|
+
You need to use GNU make, which may well be installed on your system as
|
17
|
+
`gmake`:
|
18
|
+
|
19
|
+
gmake
|
20
|
+
gmake install
|
21
|
+
gmake installcheck
|
22
|
+
|
23
|
+
If you encounter an error such as:
|
24
|
+
|
25
|
+
make: pg_config: Command not found
|
26
|
+
|
27
|
+
Be sure that you have `pg_config` installed and in your path. If you used a
|
28
|
+
package management system such as RPM to install PostgreSQL, be sure that the
|
29
|
+
`-devel` package is also installed. If necessary tell the build process where
|
30
|
+
to find it:
|
31
|
+
|
32
|
+
env PG_CONFIG=/path/to/pg_config make && make installcheck && make install
|
33
|
+
|
34
|
+
And finally, if all that fails (and if you're on PostgreSQL 8.1 or lower, it
|
35
|
+
likely will), copy the entire distribution directory to the `contrib/`
|
36
|
+
subdirectory of the PostgreSQL source tree and try it there without
|
37
|
+
`pg_config`:
|
38
|
+
|
39
|
+
env NO_PGXS=1 make && make installcheck && make install
|
40
|
+
|
41
|
+
If you encounter an error such as:
|
42
|
+
|
43
|
+
ERROR: must be owner of database regression
|
44
|
+
|
45
|
+
You need to run the test suite using a super user, such as the default
|
46
|
+
"postgres" super user:
|
47
|
+
|
48
|
+
make installcheck PGUSER=postgres
|
49
|
+
|
50
|
+
Once <%= extension_name %> is installed, you can add it to a database. If you're running
|
51
|
+
PostgreSQL 9.1.0 or greater, it's a simple as connecting to a database as a
|
52
|
+
super user and running:
|
53
|
+
|
54
|
+
CREATE EXTENSION <%= extension_name %>;
|
55
|
+
|
56
|
+
If you've upgraded your cluster to PostgreSQL 9.1 and already had <%= extension_name %>
|
57
|
+
installed, you can upgrade it to a properly packaged extension with:
|
58
|
+
|
59
|
+
CREATE EXTENSION <%= extension_name %> FROM unpackaged;
|
60
|
+
|
61
|
+
For versions of PostgreSQL less than 9.1.0, you'll need to run the
|
62
|
+
installation script:
|
63
|
+
|
64
|
+
psql -d mydb -f /path/to/pgsql/share/contrib/<%= extension_name %>.sql
|
65
|
+
|
66
|
+
If you want to install <%= extension_name %> and all of its supporting objects into a specific
|
67
|
+
schema, use the `PGOPTIONS` environment variable to specify the schema, like
|
68
|
+
so:
|
69
|
+
|
70
|
+
PGOPTIONS=--search_path=extensions psql -d mydb -f <%= extension_name %>.sql
|
71
|
+
|
72
|
+
Dependencies
|
73
|
+
------------
|
74
|
+
The `<%= extension_name %>` data type has no dependencies other than PostgreSQL.
|
75
|
+
|
76
|
+
Copyright and License
|
77
|
+
---------------------
|
78
|
+
|
79
|
+
Copyright (c) <%= Time.now.strftime("%Y") %> <%= maintainer %>.
|
80
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= extension_name %>
|
2
|
+
<%= extension_name.gsub(/./,"=") %>
|
3
|
+
|
4
|
+
Synopsis
|
5
|
+
--------
|
6
|
+
|
7
|
+
Show a brief synopsis of the extension.
|
8
|
+
|
9
|
+
Description
|
10
|
+
-----------
|
11
|
+
|
12
|
+
<%= description %>
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
|
17
|
+
Show usage.
|
18
|
+
|
19
|
+
Support
|
20
|
+
-------
|
21
|
+
|
22
|
+
There is issues tracker? Github? Put this information here.
|
23
|
+
|
24
|
+
Author
|
25
|
+
------
|
26
|
+
|
27
|
+
[<%= maintainer %>]
|
28
|
+
|
29
|
+
Copyright and License
|
30
|
+
---------------------
|
31
|
+
|
32
|
+
Copyright (c) <%= Time.now.strftime("%Y") %> <%= maintainer %>.
|
33
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
/*
|
2
|
+
* Author: <%= maintainer %>
|
3
|
+
* Created at: <%= Time.now %>
|
4
|
+
*
|
5
|
+
*/
|
6
|
+
|
7
|
+
--
|
8
|
+
-- This is a example code genereted automaticaly
|
9
|
+
-- by pgxn-utils.
|
10
|
+
|
11
|
+
CREATE OR REPLACE FUNCTION <%= extension_name %>_fdw_validator (text[], oid)
|
12
|
+
RETURNS bool
|
13
|
+
AS 'MODULE_PATHNAME'
|
14
|
+
LANGUAGE C STRICT;
|
15
|
+
|
16
|
+
CREATE OR REPLACE FUNCTION <%= extension_name %>_fdw_handler ()
|
17
|
+
RETURNS fdw_handler
|
18
|
+
AS 'MODULE_PATHNAME'
|
19
|
+
LANGUAGE C STRICT;
|
20
|
+
|
21
|
+
CREATE FOREIGN DATA WRAPPER <%= extension_name %>_fdw
|
22
|
+
VALIDATOR <%= extension_name %>_fdw_validator HANDLER <%= extension_name %>_fdw_handler;
|
23
|
+
|
24
|
+
CREATE SERVER <%= extension_name %>_local_service
|
25
|
+
FOREIGN DATA WRAPPER <%= extension_name %>_fdw
|
26
|
+
OPTIONS ( server_address 'localhost', server_port '389');
|
27
|
+
|
28
|
+
-- See more:
|
29
|
+
-- http://www.postgresql.org/docs/current/static/sql-createserver.html
|
30
|
+
-- http://www.postgresql.org/docs/current/static/sql-createusermapping.html
|
31
|
+
-- http://www.postgresql.org/docs/current/static/sql-createforeigndatawrapper.html
|