Alguém já conseguiu criar tipos definidos pelo usuário com essa combinação?
Estou usando um arquivo simples, extraído da documentação, apenas para
testar:
########################### complex.c
#include <stdio.h>
#include <postgres.h>
#include <fmgr.h>
PG_MODULE_MAGIC;
typedef struct Complex {
double x;
double y;
} Complex;
PG_FUNCTION_INFO_V1(complex_in);
Datum
complex_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
double x,
y;
Complex *result;
if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for complex: \"%s\"",
str)));
result = (Complex *) palloc(sizeof(Complex));
result->x = x;
result->y = y;
PG_RETURN_POINTER(result);
}
PG_FUNCTION_INFO_V1(complex_out);
Datum
complex_out(PG_FUNCTION_ARGS)
{
Complex *complex = (Complex *) PG_GETARG_POINTER(0);
char *result;
result = (char *) palloc(100);
snprintf(result, 100, "(%g,%g)", complex->x, complex->y);
PG_RETURN_CSTRING(result);
}
###########################
Gero a DLL com o MinGW, executo as funções para criar os tipos etc, crio uma
tabela com o tipo recém definido, mas toda vez que tenho uma operação de
INSERT recebo a seguinte mensagem:
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.
Olhei o log do servidor e encontrei o seguinte:
2008-05-03 00:19:26 BRT LOG: server process (PID 760) was terminated by
exception 0xC0000005
2008-05-03 00:19:26 BRT HINT: See C include file "ntstatus.h" for a
description of the hexadecimal value.
2008-05-03 00:19:26 BRT LOG: terminating any other active server processes
2008-05-03 00:19:27 BRT LOG: all server processes terminated;
reinitializing
2008-05-03 00:19:28 BRT FATAL: pre-existing shared memory block is still in
use
2008-05-03 00:19:28 BRT HINT: Check if there are any old server processes
still running, and terminate them.
E dentro do ntstatus.h:
#define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L).
Alguém tem alguma idéia?
Leonel Freire
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral