| From: | Edwin Quijada <listas_quijada(at)hotmail(dot)com> | 
|---|---|
| To: | <pgsql-es-ayuda(at)postgresql(dot)org> | 
| Subject: | Ayuda con funcion en C | 
| Date: | 2009-08-28 16:16:15 | 
| Message-ID: | BLU137-W253E851DE19E06C8AFA306E3F50@phx.gbl | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-es-ayuda | 
Tengo la sigte funcion y estoy tratando de que me devuelva un texto hacia postgres
#define LENMAX 40
Compila bien pero al tratar de correr la funcion obtengo este error:
db_lotonet=# select  pg_serverid(4);
ERROR:  invalid memory alloc request size 4294967293
PG_FUNCTION_INFO_V1(pg_serverid);
Datum
pg_serverid(PG_FUNCTION_ARGS)
{
  int32 arg = PG_GETARG_INT32(0);
  char *cmd = "php /proc/lotod/movil/serverkey.php";
  char *arch = "/proc/lotod/movil/serverkey.php";
  char buf[BUFSIZ];
  FILE *fp,*ptr;
text *new_t = (text *) palloc(LENMAX);
if ((fp = fopen(arch,"r"))==NULL) {PG_RETURN_BOOL(false);}
  if ((ptr = popen(cmd, "r")) != NULL)
                     while (fgets(buf, BUFSIZ, ptr) != NULL);
                           (void) pclose(ptr);
  memcpy(VARDATA(new_t),buf,strlen(buf)); // <==esta es lo que copia a la variable
  PG_RETURN_TEXT_P(new_t);
}
*-------------------------------------------------------* 
*-Edwin Quijada 
*-Developer DataBase 
*-JQ Microsistemas 
*-Soporte PostgreSQL
*-www.jqmicrosistemas.com
*-809-849-8087
*-------------------------------------------------------*
_________________________________________________________________
| From | Date | Subject | |
|---|---|---|---|
| Next Message | kernel | 2009-08-28 16:20:21 | Re: rendimiento 8.2 VS 8.3 | 
| Previous Message | Alvaro Herrera | 2009-08-28 15:12:48 | Re: El indice no mejora me mejora el rendimiento de mis consultas. |