From: | Juan Pablo Espino <jp(dot)espino(at)gmail(dot)com> |
---|---|
To: | "pgsql-es-ayuda(at)postgresql(dot)org" <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Funcion que retorna el numero de atributos de una relacion |
Date: | 2005-05-04 21:11:36 |
Message-ID: | 3e7daec10505041411683f35a3@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hola a todos,
Escribi una funcion en C que retorna el numero de atributos de una
relacion, pero me aparece un warning que no se de donde ni por que, a
pesar de eso todo parece funcionar bien.
Aqui pongo la funcion
#include "postgres.h"
#include "fmgr.h"
#include "executor/spi.h"
#include "commands/trigger.h"
/*esta es para convertir de text a char*/
char
*text_2_char(text *t)
{
int32 new_size = VARSIZE(t) - VARHDRSZ;
char *new = (char *) palloc(new_size + 1);
if (t->vl_dat == NULL)
{
elog(ERROR, "No es una cadena valida");
return NULL;
}
memcpy(new, t->vl_dat, new_size);
*(new + new_size) = '\0';
return new;
}
/*esta es la funcion en cuestion*/
PG_FUNCTION_INFO_V1(num_att);
Datum
num_att(PG_FUNCTION_ARGS)
{
text *t = PG_GETARG_TEXT_P(0);
char *new;
int32 n;
TupleDesc tupdesc;
new = text_2_char(t);
tupdesc = RelationNameGetTupleDesc(new);
n = (int32) tupdesc->natts;
PG_RETURN_INT32(n);
}
El warning:
numero.c:35: warning: asignacin makes pointer from integer without a cast
La linea 35 es: tupdesc = RelationNameGetTupleDesc(new);
Les agradezco cualquier ayuda, sugerencia o comentario, saludos
Juan P. Espino
From | Date | Subject | |
---|---|---|---|
Next Message | Gunnar Wolf | 2005-05-04 22:18:23 | Re: Tabla temporal |
Previous Message | Mario Soto Cordones | 2005-05-04 20:43:03 | Re: Vistas vacias por ODBC pero en psql bien |