Re: Problema ejecutando funcion en C

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Edwin Quijada <listas_quijada(at)hotmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Problema ejecutando funcion en C
Date: 2009-08-26 01:08:43
Message-ID: 20090826010843.GP12604@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Edwin Quijada escribió:
>
> Hola!
> Estoy tratando de hacer un par de funciones en C. Las compile bien e incluso las cargue pero al momento de ejecutarlas Postgres me saca del server y me da un error extrano

No se puede leer muy bien, pero el error significa que Postgres se cae
porque tu programa tiene algún error. Si miras en el log probablemente
veas que se muere por una señal 11 o algo parecido.

¿No sería más sencillo usar PL/php para invocar tus programas PHP?

> Este es mi codigo en c y el error que me da al tratar de ejecutar las funciones. Solo son dos
>
> #include "postgres.h"#include <string.h>#include "fmgr.h"#include <stdio.h>#include <stdlib.h> #ifdef PG_MODULE_MAGICPG_MODULE_MAGIC;#endif PG_FUNCTION_INFO_V1(pg_val_licenses_movil); /* Ejecuta la funcion que determina si la licencia movil es valida para poder usarla */Datumpg_val_licenses_movil(PG_FUNCTION_ARGS) { int32 arg = PG_GETARG_INT32(0); char *cmd = "php getm.php"; char buf[BUFSIZ]; FILE *ptr; if ((ptr = popen(cmd, "r")) != NULL) while (fgets(buf, BUFSIZ, ptr) != NULL) (void) pclose(ptr); PG_RETURN_BOOL(buf[0]!= '0'); } PG_FUNCTION_INFO_V1(pg_val_licenses_desk); /* Ejecuta la funcion que determina si la licencia movil es valida para poder usarla */ Datumpg_val_licenses_desk(PG_FUNCTION_ARGS) { int32 arg = PG_GETARG_INT32(0); char *cmd = "php getd.php"; char buf[BUFSIZ]; FILE *ptr; if ((ptr = popen(cmd, "
> r")) != NULL) while (fgets(buf, BUFSIZ, ptr) != NULL) (void) pclose(ptr); PG_RETURN_BOOL(buf[0]!= '0'); } This the error to running db_source#select pg_val_licenses_movil(0);server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.The connection to the server was lost. Attempting reset: Failed.

--
Alvaro Herrera http://www.flickr.com/photos/alvherre/
"Executive Executive Summary: The [Windows] Vista Content Protection
specification could very well constitute the longest suicide note in history."
Peter Guttman, http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Edwin Quijada 2009-08-26 01:13:05 RE: Problema ejecutando funcion en C
Previous Message Edwin Quijada 2009-08-26 00:01:51 FW: Problema ejecutando funcion en C