| From: | Manuel Sugawara <masm(at)fciencias(dot)unam(dot)mx> |
|---|---|
| To: | Juan Pablo Espino <jp(dot)espino(at)gmail(dot)com> |
| Cc: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, "pgsql-es-ayuda(at)postgresql(dot)org" <pgsql-es-ayuda(at)postgresql(dot)org> |
| Subject: | Re: Problemas al imprimir cadenas de caracteres |
| Date: | 2005-04-18 22:44:58 |
| Message-ID: | m34qe3puvp.fsf@conexa.fciencias.unam.mx |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
Intenta con:
Datum
ej2(PG_FUNCTION_ARGS)
{
int32 x = PG_GETARG_INT32(0);
text *t = PG_GETARG_TEXT_P(1);
int32 z;
int32 new_size = VARSIZE(t) - VARHDRSZ;
char *new = (char *) palloc(new_size + 1);
memcpy(new, VARDATA(t), new_size);
*(new + new_size) = '\0';
z = x*8;
elog(INFO, "Cadena: %s", new);
PG_RETURN_INT32(z);
}
También podrías usar algo como:
char *new = DatumGetCString(DirectFunctionCall1(textout,PointerGetDatum(t)));
y evitar toda la danza de copiar, etc.
Saludos,
Manuel.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2005-04-18 22:45:22 | Re: Problemas al imprimir cadenas de caracteres |
| Previous Message | Juan Pablo Espino | 2005-04-18 22:43:48 | Re: Problemas al imprimir cadenas de caracteres |