From 0e66a82238ad0aacbf646d0016193a064a4b7ecb Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Sun, 14 Dec 2014 14:33:42 +0000 Subject: [PATCH 1/4] Build improvements - Allow direct path to headers directory to be specified - Add apt-get install location to default search path --- config9.m4 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 From e1b86433bd546df30808d89489707de7c50794b7 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Sun, 14 Dec 2014 14:37:03 +0000 Subject: [PATCH 2/4] Ensure server will report notices when test expects them --- tests/trans001.phpt | 1 + 1 file changed, 1 insertion(+) 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"; }); From 7f158e111eb753a090eac95e55b586d58c97d3ca Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Sun, 14 Dec 2014 14:37:43 +0000 Subject: [PATCH 3/4] Add travis config --- .travis.yml | 17 +++++++++++++++++ travis/compile-ext.sh | 10 ++++++++++ travis/compile-php.sh | 14 ++++++++++++++ travis/compile-raphf.sh | 13 +++++++++++++ travis/configure-postgres.sh | 4 ++++ 5 files changed, 58 insertions(+) create mode 100644 .travis.yml create mode 100755 travis/compile-ext.sh create mode 100755 travis/compile-php.sh create mode 100755 travis/compile-raphf.sh create mode 100755 travis/configure-postgres.sh 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/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 From 3c7eea4bb454d4b40b3e59351bf8ef96808c9605 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Sun, 14 Dec 2014 15:24:11 +0000 Subject: [PATCH 4/4] Add README.md for github --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 README.md 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).