diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..296407f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: c + +addons: + postgresql: "9.3" + +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq libpq-dev + +before_script: + - sudo ./travis/compile-php.sh + - sudo ./travis/compile-raphf.sh + - sudo ./travis/compile-ext.sh + - sudo ./travis/configure-postgres.sh + +script: + - REPORT_EXIT_STATUS=1 $HOME/bin/php ./run-tests.php -p $HOME/bin/php --show-diff diff --git a/README.md b/README.md new file mode 100644 index 0000000..e251e37 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +pecl/pq +======= + +[![Build Status](https://travis-ci.org/php/pecl-database-pq.svg?branch=master)](https://travis-ci.org/php/pecl-database-pq) + +About +----- + +This is a modern binding to the mature [libpq](http://www.postgresql.org/docs/current/static/libpq.html), the official PostgreSQL C-client library. + +Highlights: + +- Nearly 100% support for asynchronous usage. +- Extended type support by pg_type. +- Fetching simple multi-dimensional array maps. +- Working [Gateway implementation](https://github.com/m6w6/pq-gateway). + +Installation +------------ + +This extension is hosted at [PECL](http://pecl.php.net/) and can be installed with [PEAR](http://pear.php.net/)'s `pecl` command: + + # pecl install pq + +Dependencies +------------ + +This extension unconditionally depends on the pre-loaded presence of the following PHP extensions: + +- [raphf](http://pecl.php.net/package/raphf) +- [spl](http://php.net/spl) + +Documentation +------------- + +Documentation is available [here](http://devel-m6w6.rhcloud.com/mdref/pq). diff --git a/config9.m4 b/config9.m4 index ed2e3a3..b63f2ad 100644 --- a/config9.m4 +++ b/config9.m4 @@ -2,14 +2,22 @@ PHP_ARG_WITH(pq, [whether to enable libpq (PostgreSQL) support], [ --with-pq[=DIR] Include libpq support]) if test "$PHP_PQ" != "no"; then - SEARCH_PATH="/usr/local /usr /opt" + SEARCH_PATH="/usr/local /usr /usr/include/postgresql /opt" if test "$PHP_PQ" != "yes"; then SEARCH_PATH="$PHP_PQ $SEARCH_PATH" fi for i in $SEARCH_PATH; do + AC_MSG_CHECKING(for $i/libpq-events.h) + if test -f "$i/libpq-events.h"; then + PQ_DIR=$i + AC_MSG_RESULT(yep) + break + fi + AC_MSG_RESULT(nope) + AC_MSG_CHECKING(for $i/include/libpq-events.h) if test -f "$i/include/libpq-events.h"; then - PQ_DIR=$i + PQ_DIR=$i/include AC_MSG_RESULT(yep) break fi @@ -19,7 +27,7 @@ if test "$PHP_PQ" != "no"; then if test -z "$PQ_DIR"; then AC_MSG_ERROR(could not find include/libpq-events.h) fi - PHP_ADD_INCLUDE($PQ_DIR/include) + PHP_ADD_INCLUDE($PQ_DIR) ifdef([AC_PROG_EGREP], [ AC_PROG_EGREP @@ -32,7 +40,7 @@ if test "$PHP_PQ" != "no"; then dnl AC_DEFUN([PQ_CHECK_CONST], [ AC_MSG_CHECKING(for $1) - if $EGREP -q $1 $PQ_DIR/include/libpq-fe.h; then + if $EGREP -q $1 $PQ_DIR/libpq-fe.h; then AC_DEFINE(HAVE_$1, 1, [Have $1]) AC_MSG_RESULT(yep) else diff --git a/tests/trans001.phpt b/tests/trans001.phpt index fc00a38..1dc97ba 100644 --- a/tests/trans001.phpt +++ b/tests/trans001.phpt @@ -10,6 +10,7 @@ include "_setup.inc"; $c = new pq\Connection(PQ_DSN); $c->exec("DROP TABLE IF EXISTS test CASCADE"); +$c->exec("SET client_min_messages TO NOTICE"); $c->on(pq\Connection::EVENT_NOTICE, function($c, $notice) { echo "Got notice: $notice\n"; }); diff --git a/travis/compile-ext.sh b/travis/compile-ext.sh new file mode 100755 index 0000000..17b6be8 --- /dev/null +++ b/travis/compile-ext.sh @@ -0,0 +1,10 @@ +#!/bin/sh -x + +set -e + +$HOME/bin/phpize +./configure --with-php-config=$HOME/bin/php-config --with-pq + +make -j2 --quiet install + +echo 'extension=pq.so' > $HOME/php.d/20-pq.ini diff --git a/travis/compile-php.sh b/travis/compile-php.sh new file mode 100755 index 0000000..63c8142 --- /dev/null +++ b/travis/compile-php.sh @@ -0,0 +1,14 @@ +#!/bin/sh -x + +set -e +TARGET_PHP_REF="PHP-5.6" + +mkdir -p $HOME/php +mkdir -p $HOME/php.d +git clone --depth=1 --branch=$TARGET_PHP_REF https://github.com/php/php-src $HOME/php/src + +cd $HOME/php/src +./buildconf --force +./configure --prefix=$HOME --with-config-file-scan-dir=$HOME/php.d --disable-all --enable-maintainer-zts --enable-json --with-mhash + +make -j2 --quiet install diff --git a/travis/compile-raphf.sh b/travis/compile-raphf.sh new file mode 100755 index 0000000..99aa4b0 --- /dev/null +++ b/travis/compile-raphf.sh @@ -0,0 +1,13 @@ +#!/bin/sh -x + +set -e + +git clone --depth 1 https://github.com/php/pecl-php-raphf $HOME/raphf +cd $HOME/raphf + +$HOME/bin/phpize +./configure --with-php-config=$HOME/bin/php-config --with-pq + +make -j2 --quiet install + +echo 'extension=raphf.so' > $HOME/php.d/10-raphf.ini diff --git a/travis/configure-postgres.sh b/travis/configure-postgres.sh new file mode 100755 index 0000000..de5355c --- /dev/null +++ b/travis/configure-postgres.sh @@ -0,0 +1,4 @@ +#!/bin/sh -x + +psql -c 'create database pq_test;' -U postgres +echo ' ./tests/_setup.inc