I have been trying to execute a shell command from within postgresql
You ought to be using Version 1 calling conventions -- see: http://www.postgresql.org/docs/current/static/xfunc-c.html#AEN29226
The following works fine for me on RH9:
#define GET_STR(textp) \ DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp))) extern Datum shell_exec(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(shell_exec);
Datum
shell_exec(PG_FUNCTION_ARGS)
{
char *cmd = GET_STR(PG_GETARG_TEXT_P(0));
int32 result;
result = system(cmd);
PG_RETURN_INT32(result);
}
CREATE OR REPLACE FUNCTION xp_shellexec(text) RETURNS int AS '$libdir/shell_exec','shell_exec' LANGUAGE 'C' VOLATILE STRICT;
SELECT xp_shellexec('mkdir /tmp/testing123');
[EMAIL PROTECTED] tmp]# ls -ld /tmp/test* drwx------ 2 postgres postgres 4096 Nov 28 19:31 /tmp/testing123
HTH,
Joe
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
