GithubHelp home page GithubHelp logo

pl-php's Introduction

PL/php is a procedural language add-on for PostgreSQL.

It allows you to create PHP functions that are stored inside a PostgreSQL
database server.  They can then be used as stored procedures.  They have
many of the functionalities of a standard PostgreSQL function, and you
can use them to write triggers, set-returning functions, and plain functions
that would just be too complex or cumbersome to write in PL/pgSQL.

pl-php's People

Contributors

alvherre avatar jdatcmd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pl-php's Issues

Can't compile with php-5.4.38

I installed php-5.4.38 from source:
./configure --enable-embed --prefix=/usr/local && make install

and then try to compie PL-PHP:
./configure -with-php=/usr/local/
[here everything is OK]

$ make

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -
pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DLINUX_OOM_ADJ=0 -fpic -I/usr/local/include/php -I/usr/local
/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I. -I./ -I/usr/pgsql-9.4/include/server -I/usr/pgsql-9.4
/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o plphp.o plphp.c
plphp.c:361:2: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
php_error, /* sapi_error(int, const char _, ...) */
^
In file included from /usr/local/include/php/main/fopen_wrappers.h:25:0,
from /usr/local/include/php/main/php.h:398,
from plphp.c:83:
plphp.c: In function ‘plphp_call_handler’:
/usr/local/include/php/main/php_globals.h:32:29: error: ‘struct _php_core_globals’ has no member named ‘safe_mode’

define PG(v) (core_globals.v)

                         ^

plphp.c:569:5: note: in expansion of macro ‘PG’
PG(safe_mode) = desc->trusted;
^
/usr/local/include/php/main/php_globals.h:32:29: error: ‘struct _php_core_globals’ has no member named ‘safe_mode’

define PG(v) (core_globals.v)

                         ^

plphp.c:578:5: note: in expansion of macro ‘PG’
PG(safe_mode) = desc->trusted;
^
plphp.c: In function ‘plphp_validator’:
plphp.c:648:3: warning: implicit declaration of function ‘GETSTRUCT’ [-Wimplicit-function-declaration]
procForm = (Form_pg_proc) GETSTRUCT(procTup);
^
plphp.c:648:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
procForm = (Form_pg_proc) GETSTRUCT(procTup);
^
plphp.c: In function ‘plphp_func_handler’:
plphp.c:1006:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
retTypeStruct = (Form_pg_type) GETSTRUCT(retTypeTup);
^
plphp.c: In function ‘plphp_compile_function’:
plphp.c:1195:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
procStruct = (Form_pg_proc) GETSTRUCT(procTup);
^
plphp.c:1223:4: warning: implicit declaration of function ‘HeapTupleHeaderGetXmin’ [-Wimplicit-function-declaration](prodesc->fn_xmin == HeapTupleHeaderGetXmin%28procTup->t_data%29 &&
^
plphp.c:1224:5: warning: implicit declaration of function ‘HeapTupleHeaderGetRawCommandId’ [-Wimplicit-function-declaration]
prodesc->fn_cmin == HeapTupleHeaderGetRawCommandId%28procTup->t_data%29);
^
plphp.c:1312:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
langStruct = (Form_pg_language) GETSTRUCT(langTup);
^
plphp.c: In function ‘plphp_func_build_args’:
plphp.c:1634:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
^
plphp.c:1657:5: warning: implicit declaration of function ‘HeapTupleHeaderGetDatumLength’ [-Wimplicit-function-declaration]
tmptup.t_len = HeapTupleHeaderGetDatumLength(td);
^
plphp.c:1661:5: warning: implicit declaration of function ‘HeapTupleHeaderGetTypeId’ [-Wimplicit-function-declaration]
tupType = HeapTupleHeaderGetTypeId(tmptup.t_data);
^
plphp.c:1662:5: warning: implicit declaration of function ‘HeapTupleHeaderGetTypMod’ [-Wimplicit-function-declaration]
tupTypmod = HeapTupleHeaderGetTypMod(tmptup.t_data);
^
make: *_* [plphp.o] Error 1

Can't compile

I'm running under Ubuntu 14.04 64 with Postgresql 9.3.4

I've downloaded the last version of php 5.5.14

Compiled:

sudo ./configure --prefix=/usr/local/plphp --enable-embed
sudo make
sudo make install

Downloaded plphp 1.4 from https://public.commandprompt.com/projects/plphp/wiki/Downloads

$ sudo ./configure --with-php=/usr/local/plphp
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gawk... gawk
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for strcasecmp... yes
checking for strdup... yes
checking whether to build with debug information... no
checking for pg_config... /usr/bin/pg_config
checking for /usr/lib/postgresql/9.3/lib/pgxs/src/makefiles/pgxs.mk... yes
checking for PostgreSQL version... 9.3.4
checking for php-config... /usr/local/plphp/bin/php-config
checking whether ZTS is declared... no
checking whether PHP is compiled with the Embed SAPI... yes
checking for php_module_startup in -lphp5... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged

But when I try to run make:

$ sudo make
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -fpic -I/usr/local/plphp/include/php -I/usr/local/plphp/include/php/main -I/usr/local/plphp/include/php/TSRM -I/usr/local/plphp/include/php/Zend -I/usr/local/plphp/include/php/ext -I/usr/local/plphp/include/php/ext/date/lib -I/usr/local/plphp/include/php -I/usr/local/plphp/include/php/main -I/usr/local/plphp/include/php/TSRM -I/usr/local/plphp/include/php/Zend -I/usr/local/plphp/include/php/ext -I/usr/local/plphp/include/php/ext/date/lib  -I. -I./ -I/usr/include/postgresql/9.3/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/tcl8.6  -c -o plphp.o plphp.c
plphp.c:342:2: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  php_error,     /* sapi_error(int, const char *, ...) */
  ^
In file included from /usr/local/plphp/include/php/main/fopen_wrappers.h:25:0,
                 from /usr/local/plphp/include/php/main/php.h:397,
                 from plphp.c:82:
plphp.c: In function ‘plphp_call_handler’:
/usr/local/plphp/include/php/main/php_globals.h:32:29: error: ‘struct _php_core_globals’ has no member named ‘safe_mode’
 # define PG(v) (core_globals.v)
                             ^
plphp.c:549:5: note: in expansion of macro ‘PG’
     PG(safe_mode) = desc->trusted;
     ^
/usr/local/plphp/include/php/main/php_globals.h:32:29: error: ‘struct _php_core_globals’ has no member named ‘safe_mode’
 # define PG(v) (core_globals.v)
                             ^
plphp.c:558:5: note: in expansion of macro ‘PG’
     PG(safe_mode) = desc->trusted;
     ^
plphp.c: In function ‘plphp_validator’:
plphp.c:627:3: warning: implicit declaration of function ‘GETSTRUCT’ [-Wimplicit-function-declaration]
   procForm = (Form_pg_proc) GETSTRUCT(procTup);
   ^
plphp.c:627:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   procForm = (Form_pg_proc) GETSTRUCT(procTup);
              ^
plphp.c: In function ‘plphp_trig_build_args’:
plphp.c:749:30: error: dereferencing pointer to incomplete type
  tupdesc = tdata->tg_relation->rd_att;
                              ^
In file included from /usr/local/plphp/include/php/main/php.h:38:0,
                 from plphp.c:82:
plphp.c:753:55: error: dereferencing pointer to incomplete type
     add_assoc_long(retval, "relid", tdata->tg_relation->rd_id);
                                                       ^
/usr/local/plphp/include/php/Zend/zend_API.h:385:92: note: in definition of macro ‘add_assoc_long’
 #define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key)+1, __n)
                                                                                            ^
plphp.c: In function ‘plphp_func_handler’:
plphp.c:988:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   retTypeStruct = (Form_pg_type) GETSTRUCT(retTypeTup);
                   ^
plphp.c: In function ‘plphp_compile_function’:
plphp.c:1177:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  procStruct = (Form_pg_proc) GETSTRUCT(procTup);
               ^
plphp.c:1205:4: warning: implicit declaration of function ‘HeapTupleHeaderGetXmin’ [-Wimplicit-function-declaration]
    (prodesc->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
    ^
plphp.c:1206:5: warning: implicit declaration of function ‘HeapTupleHeaderGetRawCommandId’ [-Wimplicit-function-declaration]
     prodesc->fn_cmin == HeapTupleHeaderGetRawCommandId(procTup->t_data));
     ^
plphp.c:1288:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   langStruct = (Form_pg_language) GETSTRUCT(langTup);
                ^
plphp.c:1308:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
                 ^
plphp.c:1383:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
                  ^
plphp.c: In function ‘plphp_func_build_args’:
plphp.c:1536:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
                 ^
plphp.c:1559:5: warning: implicit declaration of function ‘HeapTupleHeaderGetDatumLength’ [-Wimplicit-function-declaration]
     tmptup.t_len = HeapTupleHeaderGetDatumLength(td);
     ^
plphp.c:1563:5: warning: implicit declaration of function ‘HeapTupleHeaderGetTypeId’ [-Wimplicit-function-declaration]
     tupType = HeapTupleHeaderGetTypeId(tmptup.t_data);
     ^
plphp.c:1564:5: warning: implicit declaration of function ‘HeapTupleHeaderGetTypMod’ [-Wimplicit-function-declaration]
     tupTypmod = HeapTupleHeaderGetTypMod(tmptup.t_data);
     ^
make: *** [plphp.o] Error 1

What I'm doing wrong? I've tested running "$ sudo autoconf", after "$ sudo ./configure" and "$ make" but I got the same error...

Patch - can`t create language

create language plphp;
ERROR: could not load library "/usr/lib/postgresql/plphp.so": /usr/lib/postgresql/plphp.so: undefined symbol: HeapTupleHeaderGetTypeId

and

create language plphp;
ERROR: could not load library "/usr/lib/postgresql/plphp.so": /usr/lib/postgresql/plphp.so: undefined symbol: GETSTRUCT

=== patch ===
diff --git a/plphp.c b/plphp.c
index 72d5dbd..a9514b7 100644
--- a/plphp.c
+++ b/plphp.c
@@ -49,6 +49,7 @@
#include "postgres.h"
#include "access/heapam.h"
#include "access/transam.h"
+#include "access/htup_details.h"

#include "catalog/catversion.h"
#include "catalog/pg_language.h"
diff --git a/plphp_io.h b/plphp_io.h
index 8292797..ebda6ab 100644
--- a/plphp_io.h
+++ b/plphp_io.h
@@ -8,6 +8,7 @@
/* PostgreSQL stuff */
#include "postgres.h"
#include "access/heapam.h"
+#include "access/htup_details.h"
#include "commands/trigger.h"
#include "funcapi.h"

PHP 7

Please update for PHP 7.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.