Re: [Dovecot] Oracle SQL driver
The transaction handling doesn't look correct to me. The sql_update()s just add the change to a linked list and commit() is then supposed to run them in one transaction and either everything should succeed or fail. Your commit appears to ignore errors and just commit everything that goes through? Also since nothing is actually sent before commit(), your rollback() shouldn't need to send ROLLBACK.
You right. I've corrected the transaction handling mechanism. The only thing I couldn't understand: why rollback() shouldn't need to make real ROLLBACK? In case when whole transaction was failed succeded statements will remain uncommited. Then they will be commited later on next successful transaction. May be ROLLBACK is still needed?
The "VARCHAR sqltext[2048]" seems like an unnecessary restriction on the query length. Wasn't there a way to do this without the limit? Or in
AFAIK there is no possibility to use C types in PREPARE statement. Also Oracle cannot handle unsized VARCHARs. I've increased VARCHAR size to 65535.
test_connection() seems unnecessary.
Right you are.
Couldn't driver_oracle_generate_name() be simply: static unsigned int counter = 0; return i_strdup_printf("ORACONN_%x", ++counter);
=) Right.
driver_oracle_escape_string() really should be escaping the string.
I made this function to replace single quote in string with two single quotes. IMHO this should be enough. How do you think?
Kind of annoying that each query needs a cursor, even though nearly all queries are expected to return only a single row, but I guess that can't be helped with the current API..
Yes. There are no other ways to work with untyped statements in OCI. But Oracle claims that all these statements shouldn't produce significant performance impact.
The new version attached.
On 6.1.2010, at 14.09, Alexander Bukharov wrote:
The transaction handling doesn't look correct to me. The sql_update()s just add the change to a linked list and commit() is then supposed to run them in one transaction and either everything should succeed or fail. Your commit appears to ignore errors and just commit everything that goes through? Also since nothing is actually sent before commit(), your rollback() shouldn't need to send ROLLBACK.
You right. I've corrected the transaction handling mechanism. The only thing I couldn't understand: why rollback() shouldn't need to make real ROLLBACK? In case when whole transaction was failed succeded statements will remain uncommited. Then they will be commited later on next successful transaction. May be ROLLBACK is still needed?
There wouldn't be any uncommitted statements. The only such statements are sent inside commit(), the others are SELECTs and such that don't modify anything.
The "VARCHAR sqltext[2048]" seems like an unnecessary restriction on the query length. Wasn't there a way to do this without the limit? Or in
AFAIK there is no possibility to use C types in PREPARE statement. Also Oracle cannot handle unsized VARCHARs. I've increased VARCHAR size to 65535.
Well, that also wastes memory :) I thought I remembered using VARCHAR pointers about 10 years ago. I think I still have that code around, but I currently don't have a computer where I could put that hard drive. Maybe in a few days.
driver_oracle_escape_string() really should be escaping the string.
I made this function to replace single quote in string with two single quotes. IMHO this should be enough. How do you think?
Does Oracle handle \ specially? I don't have Oracle installed currently or access to any installations.
I'll check the updated patch later.
On Wed, 2010-01-06 at 15:09 +0300, Alexander Bukharov wrote:
AFAIK there is no possibility to use C types in PREPARE statement.
What about elsewhere? Looking at my old code I see for example:
int main(int argc, char *argv[]) .. EXEC SQL CONNECT :*argv;
So it looks like in at least some places copying to VARCHAR isn't necessary.
Ok. I'll fix in couple of days.
Alexander Bukharov
Timo Sirainen tss@iki.fi От: dovecot-bounces+bukharov=bpc.ru@dovecot.org 19.01.2010 16:27 Срок ответа для: Dovecot Mailing List dovecot@dovecot.org
Кому Alexander Bukharov bukharov@bpc.ru Копия Dovecot Mailing List dovecot@dovecot.org Тема Re: [Dovecot] Oracle SQL driver
On Wed, 2010-01-06 at 15:09 +0300, Alexander Bukharov wrote:
AFAIK there is no possibility to use C types in PREPARE statement.
What about elsewhere? Looking at my old code I see for example:
int main(int argc, char *argv[]) .. EXEC SQL CONNECT :*argv;
So it looks like in at least some places copying to VARCHAR isn't necessary.
participants (2)
-
Alexander Bukharov
-
Timo Sirainen