Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved `t/handler/Makefile` to the root and updated it to support `make installecheck` and an installer script. Other relevant changes. * Moved the test from `t/test/sql` to `t/sql/test.sql` and added a symlink from `sql` to `t/sql`. This is because `pg_regress` is hard-coded to look for test scripts in `sql`. * Added `expected/test.out`. This is for `pg_regress` to compare test results. * Added `test` target using `pg_prove`. You need to install pgTAP to get pg_prove. I'll look at embedding it here soon. Either way, you'll need a recent Test::Harness to use it. It's best to use it for development, though. * Replace `HOWTO` with `README.plparrot`. It's copied from the first 100 lines or so of pgTAP's `README.pgtap`, and contains build instructions with and without pgxs, as well as testing instructions. * Added `plparrot.sql.in`. This is the script that can be used to install PL/Parrot. Inserting into `pg_pltemplate` does not appear to be the supported way to add a non-core PL.
- Loading branch information
Showing
8 changed files
with
149 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,40 @@ | ||
NAME = plparrot | ||
MODULE_big = src/handler/plparrot | ||
OBJS= src/handler/plparrot.o | ||
DATA_built = plparrot.sql | ||
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plpgsql | ||
TESTS = $(wildcard t/sql/*.sql) | ||
REGRESS = $(patsubst t/sql/%.sql,%,$(TESTS)) | ||
|
||
all: | ||
cd src/handler; make | ||
EXTRA_CLEAN = | ||
|
||
test: all | ||
psql test --no-psqlrc --no-align --quiet --pset pager= --pset tuples_only=true \ | ||
--set ON_ERROR_ROLLBACK=1 --set ON_ERROR_STOP=1 -f t/test.sql | ||
ifndef NO_PGXS | ||
PGXS := $(shell pg_config --pgxs) | ||
include $(PGXS) | ||
else | ||
subdir = contrib/plparrot | ||
top_builddir = ../.. | ||
include $(top_builddir)/src/Makefile.global | ||
include $(top_srcdir)/contrib/contrib-global.mk | ||
endif | ||
|
||
clean: | ||
cd src/handler; make clean | ||
PARROTINCLUDEDIR = $(shell parrot_config includedir) | ||
PARROTVERSION = $(shell parrot_config versiondir) | ||
PARROTINC = "$(PARROTINCLUDEDIR)$(PARROTVERSION)" | ||
PARROTLDFLAGS = $(shell parrot_config ldflags) | ||
PARROTLINKFLAGS = $(shell parrot_config inst_libparrot_linkflags) | ||
|
||
redo: clean all | ||
# We need to do various things with various versions of PostgreSQL. | ||
# VERSION = $(shell $(PG_CONFIG) --version | awk '{print $$2}') | ||
# PGVER_MAJOR = $(shell echo $(VERSION) | awk -F. '{ print ($$1 + 0) }') | ||
# PGVER_MINOR = $(shell echo $(VERSION) | awk -F. '{ print ($$2 + 0) }') | ||
# PGVER_PATCH = $(shell echo $(VERSION) | awk -F. '{ print ($$3 + 0) }') | ||
|
||
redotest: clean test | ||
# this is not quite working yet | ||
#PARROT_CCFLAGS=$(shell ~/svn/parrot/parrot_config ccflags) | ||
#PARROT_CCFLAGS2=$(shell ~/svn/parrot/parrot_config ccflags_provisional) | ||
override CPPFLAGS := -I$(PARROTINC) -I$(srcdir) $(CPPFLAGS) | ||
override CFLAGS := $(PARROTLDFLAGS) $(PARROTLINKFLAGS) $(CFLAGS) | ||
|
||
install: all | ||
cd src/handler; make install | ||
test: | ||
pg_prove --pset tuples_only=1 $(TESTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
PL/Parrot 0.01 | ||
============== | ||
|
||
PL/Parrot is a PostgreSQL procedural language for the Parrot virtual machine. | ||
|
||
Installation | ||
============ | ||
|
||
For the impatient, to install PL/Parrot into a PostgreSQL database, just do this: | ||
|
||
make | ||
make install | ||
make installcheck | ||
|
||
If you encounter an error such as: | ||
|
||
"Makefile", line 8: Need an operator | ||
|
||
You need to use GNU make, which may well be installed on your system as | ||
'gmake': | ||
|
||
gmake | ||
gmake install | ||
gmake installcheck | ||
|
||
If you encounter an error such as: | ||
|
||
make: pg_config: Command not found | ||
|
||
Be sure that you have `pg_config` installed and in your path. If you used a | ||
package management system such as RPM to install PostgreSQL, be sure that the | ||
`-devel` package is also installed. If necessary, add the path to `pg_config` | ||
to your `$PATH` environment variable: | ||
|
||
env PATH=$PATH:/path/to/pgsql/bin \ | ||
make && make install && make installcheck | ||
|
||
And finally, if all that fails, copy the entire distribution directory to the | ||
`contrib/` subdirectory of the PostgreSQL source tree and try it there without | ||
the `$USE_PGXS` variable: | ||
|
||
make NO_PGXS=1 | ||
make install NO_PGXS=1 | ||
make installcheck NO_PGXS=1 | ||
|
||
If you encounter an error such as: | ||
|
||
ERROR: must be owner of database regression | ||
|
||
You need to run the test suite using a super user, such as the default | ||
"postgres" super user: | ||
|
||
make installcheck PGUSER=postgres | ||
|
||
Testing PL/Parrot with PL/Parrot | ||
------------------------ | ||
|
||
In addition to the PostgreSQL-standard `installcheck` target, the `test` | ||
target uses the `pg_prove` Perl program to do its testing, which requires | ||
TAP::Harness, included in | ||
[Test::Harness](http://search.cpan.org/dist/Test-Harness/ "Test::Harness on | ||
CPAN") 3.x. You'll need to make sure that you use a database with PL/pgSQL | ||
loaded, or else the tests won't work. `pg_prove` supports a number of | ||
environment variables that you might need to use, including all the usual | ||
PostgreSQL client environment variables: | ||
|
||
* `$PGDATABASE` | ||
* `$PGHOST` | ||
* `$PGPORT` | ||
* `$PGUSER` | ||
|
||
You can use it to run the test suite as a database super user like so: | ||
|
||
make test PGUSER=postgres | ||
|
||
Of course, if you're running the tests from the `contrib/` directory, you | ||
should add the `NO_PGXS` variable. | ||
|
||
Adding PL/Parrot to a Database | ||
-------------------------- | ||
|
||
Once PL/Parrot has been built and tested, you can install it into a | ||
PL/pgSQL-enabled database: | ||
|
||
psql -d dbname -f plparrot.sql | ||
|
||
If you want PL/Parrot to be available to all new databases, install it into the | ||
"template1" database: | ||
|
||
psql -d template1 -f plparrot.sql | ||
|
||
The `plparrot.sql script will also be installed in the `contrib` directory | ||
under the directory output by `pg_config --sharedir`. So you can always do | ||
this: | ||
|
||
psql -d template1 -f `pg_config --sharedir`/contrib/plparrot.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
\unset ECHO | ||
1..5 | ||
ok 1 - We can return void | ||
ok 2 - We can return an int | ||
ok 3 - We can return an int that was passed as an arg | ||
ok 4 - We can return a float | ||
ok 5 - We can return a varchar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- handler function | ||
CREATE FUNCTION plparrot_call_handler () | ||
RETURNS language_handler AS 'MODULE_PATHNAME' LANGUAGE C; | ||
|
||
-- language | ||
CREATE LANGUAGE plparrot HANDLER plparrot_call_handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
t/sql/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters