From: | "Jasbinder Bali" <jsbali(at)gmail(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org |
Subject: | Dynamic loading (datatype mismatch) |
Date: | 2006-08-24 16:08:58 |
Message-ID: | a47902760608240908q6abf70d9u90d57f1ecdb25747@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice |
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(at)simon-cozens(dot)org Tue Apr 15 20:24:47 2003
X-MultiHeader: one
X-MultiHeader: two
X-MultiHeader: three
From: Simon Cozens <simon(at)simon-cozens(dot)org>
To: test
Bcc: simon(at)twingle(dot)net
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(at)cozens(dot)net address is deprecated due to being broken.
simon(at)brecon(dot)co(dot)uk 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
From | Date | Subject | |
---|---|---|---|
Next Message | Bob Pawley | 2006-08-24 16:20:11 | Inserting Data |
Previous Message | Joe Kramer | 2006-08-24 16:05:53 | Large database design advice |
From | Date | Subject | |
---|---|---|---|
Next Message | Srinivas Iyyer | 2006-08-24 17:27:16 | matching empty column |
Previous Message | Michael Fuhr | 2006-08-24 12:19:07 | Re: [GENERAL] Shared Objects (Dynamic loading) |