Hi,
I am dynamically loading a shared object in a function.
CREATE OR REPLACE FUNCTION sp_trigger_raw_email(int4, char)
RETURNS bool AS
'/usr/local/pgsql/jsbali/parser', 'test'
LANGUAGE 'c' VOLATILE STRICT;
ALTER FUNCTION sp_trigger_raw_email(int4, text) OWNER TO postgres;
signature of test is
test (int, char*)
Also, function sp_trigger_raw_email gets invoked as a result of trigger action
The function that invokes sp_trigger_raw_email is as follows
CREATE OR REPLACE FUNCTION func_trigger_raw_email()
RETURNS "trigger" AS
$BODY$
BEGIN
PERFORM sp_trigger_raw_email(NEW.id, NEW.raw_email);
RETURN NEW;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION func_trigger_raw_email() OWNER TO postgres;
----------------------------------------------------------------------------------------------------------------------------------------
My problems are as follows:
1. After i execute the function sp_raw_email_trigger, the second argument automatically gets changed
from char to bpchar. Don't know if this is dangerous.
2. function test(int, char*) has char* as its second parameter and i declare the arguments of the function that calls it as (int4, char).
Is this a mismatch??
3. Test stores the values supplied to it in a table.
test(int caseno, char *rawemail)
{
EXEC SQL CONNECT TO dbxyz;
EXEC SQL BEGIN DECLARE SECTION;
int id = caseno;
char *email = rawemail;
EXEC SQL END DECLARE SECTION;
EXEC SQL INSERT INTO headers (id, header_content) VALUES (:id, :email);
EXEC SQL COMMIT;
}
Now the value of rawemail argument the actually is supplied to it from the trigger using
NEW.raw_email is as follows:
-----------------------------------------------
'From simon@xxxxxxxxxxxxxxxx Tue Apr 15 20:24:47 2003
X-MultiHeader: one
X-MultiHeader: two
X-MultiHeader: three
From: Simon Cozens <simon@xxxxxxxxxxxxxxxx>
To: test
Bcc: simon@xxxxxxxxxxx
Subject: foo
Mime-Version:
1.0
Content-Type: image/gif
Content-Disposition: attachment; filename="1.gif"
Content-Transfer-Encoding: base64
X-Operating-System: Linux deep-dark-truthful-mirror 2.4.9
X-POM: The Moon is Waxing Gibbous (98% of Full)
X-Addresses: The simon@xxxxxxxxxx address is deprecated due to being broken. simon@xxxxxxxxxxxx still works, but
simon-cozens.org or netthink.co.uk are preferred.
X-Mutt-Fcc: =outbox-200304
Status: RO
Content-Length: 1205
Lines: 17
R0lGODlhDAAMAPcAAAAAAAgICBAQEBgYGCkpKTExMTk5OUpKSoyMjJSUlJycnKWlpbW1tc7O
zufn5+/v7/f39///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/////////////////////////////////ywAAAAADAAMAAAIXwAjRICQwIAAAQYUQBAYwUEB
AAACEIBYwMHAhxARNIAIoAAEBBAPOICwkSMCjBAXlKQYgCMABSsjtuQI02UAlC9jFgBJMyYC
CCgRMODoseFElx0tCvxYIEAAAwkWRggIADs=
'
----------------------------------------------
But what gets stored in header table is
just a 'T' with some junk characters.
Don't know if its because of a datatype mismatch or wrong copy command
used in the DECLARE SECTION i.e. char *email = rawemail;
I'm being too verbose here to include each phase of the problem.
Thanks and regards,
Jas