From: | Marc Tardif <admin(at)wtbwts(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | pglib and long queries |
Date: | 2000-01-22 13:17:26 |
Message-ID: | Pine.BSF.4.10.10001221305580.22701-100000@server.b0x.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I am using a c program to insert the contents of mail messages into
postgresql. First, I copy the message from stdin into a char pointer which
I malloc at every line, then I use the following code to insert into a
table:
char query[1024];
PGresult *res;
...
sprint(query, "insert into mail_msg values ('%s'), message);
res = PQexec(conn, query);
...
There is obviously more than one problem here, the most important being
I'm inserting a message of undetermined length into a char array of 1024
bytes. Second, I'm not parsing the message for apostrophes or other
characters which would mess-up my query.
I'd appreciate if someone could suggest a solution to either problem, or
point me towards sample source code I could learn from. Please do not
suggest using Perl, I enjoy c even though I am still not very proficient
at it and this is a good opportunity to practice.
Thanks again,
Marc
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Meskes | 2000-01-22 13:52:55 | Re: [HACKERS] off topic |
Previous Message | Oliver Elphick | 2000-01-22 10:56:19 | Re: [HACKERS] Types |