Search Postgresql Archives

PG_TRY(), PG_CATCH()....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Guys,


I've got a C-implemented function which performs number
of SPI_exec()'s in a loop, where each of them may fail,
thus I wrapped them into the PG_TRY()/PG_CATCH() inside
the loop. Something like this :

for(i = 0; i < query_count; i++) {

  PG_TRY();
  {

    SPI_exec(query[i], 1);

  }

  PG_CATCH();
  {

    FlushErrorState();

  }
  PG_END_TRY();

}

Which works fine with successful queries, but for each
unsuccessful query it complains about reference leaks
and not properly closed relations.
 Later on I've solved that with use of subtransactions, which
provide some proper cleanup mechanisms, but I was wondering
if it is possible to bypass that layer, and make the code
above work fine just by doing some cleanup within the catch
block.

Thanks!


Best regards,
Alex Vinogradovs

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux