Mysterious Bus Error with get_fn_expr_argtype()
От | David E. Wheeler |
---|---|
Тема | Mysterious Bus Error with get_fn_expr_argtype() |
Дата | |
Msg-id | 02D8BD30-688E-4A1D-A39C-92A15EFD1BFC@kineticode.com обсуждение исходный текст |
Ответы |
Re: Mysterious Bus Error with get_fn_expr_argtype()
|
Список | pgsql-hackers |
Howdy, I'm trying to write a simple function that will return a string with the type name of a value. Unfortunately, it keeps dying on me. I don't even get any useful debugging information with --enable-cassert, just this: LOG: server process (PID 96946) was terminated by signal 10: Bus error LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing I stuck in a few calls to elog(), and it looks like this is the line that's choking: typeoid = get_fn_expr_argtype(fcinfo->flinfo, 0); But that's copied directly from enum.c. So I'm pretty mystified. Any help would be greatly appreciated. Here's the complete code: #include "postgres.h" #include "fmgr.h" #include "utils/builtins.h" #ifdef PG_MODULE_MAGIC PG_MODULE_MAGIC; #endif extern Datum type_of (PG_FUNCTION_ARGS); Datum type_of(PG_FUNCTION_ARGS) { Oid typeoid; Datum result; char *typename; typeoid = get_fn_expr_argtype(fcinfo->flinfo, 0); if (typeoid == InvalidOid) { ereport( ERROR, ( errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("could not determine data type of argumentto type_of()") ) ); } typename = format_type_be(typeoid); result = DirectFunctionCall1(textin, CStringGetDatum(typename));PG_RETURN_DATUM(result); } And I load the function like so: CREATE OR REPLACE FUNCTION type_of(anyelement) RETURNS text AS '$libdir/type_of' LANGUAGE C STRICT IMMUTABLE; Thanks, DAvid
В списке pgsql-hackers по дате отправления: