I execute a user define function and get two different results. Both the two results appear randomly, the result2 is expected.
results2:
postgres=# select trap_foreign_key(2);
NOTICE: caught foreign_key_violation
trap_foreign_key
------------------
0
(1 row)
CREATE FUNCTION trap_foreign_key(int) RETURNS INT AS $$
BEGIN
begin -- start transaction
insert into slave values($1);
exception
when foreign_key_violation then
raise notice 'caught foreign_key_violation';
return 0;
end;
return 1;
end$$ language plpgsql;
select trap_foreign_key(2); – detects FK violation
I add a elog in handle_reponse() of coordinator:
msg_type = get_message(conn, &msg_len, &msg);
elog(WARNING, "Received message type: %c", msg_type);
The debug output is in the attachment.
As the debug output shows, the result1 misses the N, Z messages from datanode.
The reason is when the coordinator in justifing message buffer,
the datanode has not yet send the messages.The coordinator thinks
there is no message now, and return, the later messages from datanode is missed.
The coordinator code:
if (!HAS_MESSAGE_BUFFERED(conn))
return RESPONSE_EOF;
The N,Z messages comes later than the check above.
Sorry, exception is not supported in XC at present. This needs
SAVEPOINT feature inside SPI. Also, for the same reason, you cannot
issue more than one DML in a function.
Regards;
Koichi Suzuki
2014-09-22 18:41 GMT+09:00 peace zone peacezone@users.sf.net:
Related
Bugs: #490
Thanks for your response!
1. I found this condition during doing the make check.
2. Do we have a plan to adding this feature?
Sorry, I was wrong.
If you found it within the make check, the cause is not here.
In make check, test script sometimes cancels statement execution
intentionally. This cancellation is done in asynchronous manner and
when the cancellation takes time, typically in slower environment,
following script has to run while the cancellation is not complete.
Unfortunately, it is not simple to perform this cancellation in
synchronous manner. Instead, we inserted some wait before the next
script is ready to run. We understand this is not complete and we
still have a good chance to have such error occasionally.
You can ignore this. If you write an application where you cancel
statement execution intentionally, then you should be careful to see
if the cancellation is complete.
Thank you very much for pointing out.
Please also understand the limitation I mentioned is collect.
Regards;
Koichi Suzuki
2014-09-26 11:29 GMT+09:00 peace zone peacezone@users.sf.net:
Related
Bugs: #490
Thanks for your explanation, I will do as you say