File: | plpython.c |
Function: | PLy_spi_execute_query |
Error: | returning (PyObject*)NULL without setting an exception |
3661 static PyObject *
3662 PLy_spi_execute_query(char *query, long limit)
3663 {
3664 int rv;
3665 volatile MemoryContext oldcontext;
3666 volatile ResourceOwner oldowner;
3667 PyObject *ret;
3668
3669 oldcontext = CurrentMemoryContext;
3670 oldowner = CurrentResourceOwner;
3671
3672 BeginInternalSubTransaction(NULL);
3673 /* Want to run inside function's memory context */
3674 MemoryContextSwitchTo(oldcontext);
3675
3676 PG_TRY();
when considering range: -0x80000000 <= value <= -1
taking False path
3677 {
3678 pg_verifymbstr(query, strlen(query), false);
3679 rv = SPI_execute(query, PLy_curr_procedure->fn_readonly, limit);
3680 ret = PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv);
3681
3682 /* Commit the inner transaction, return to outer xact context */
3683 ReleaseCurrentSubTransaction();
3684 MemoryContextSwitchTo(oldcontext);
3685 CurrentResourceOwner = oldowner;
3686
3687 /*
3688 * AtEOSubXact_SPI() should not have popped any SPI context, but just
3689 * in case it did, make sure we remain connected.
3690 */
3691 SPI_restore_connection();
3692 }
3693 PG_CATCH();
3694 {
3695 ErrorData *edata;
3696 PLyExceptionEntry *entry;
3697 PyObject *exc;
3698
3699 /* Save error info */
3700 MemoryContextSwitchTo(oldcontext);
3701 edata = CopyErrorData();
3702 FlushErrorState();
3703
3704 /* Abort the inner transaction */
3705 RollbackAndReleaseCurrentSubTransaction();
3706 MemoryContextSwitchTo(oldcontext);
3707 CurrentResourceOwner = oldowner;
3708
3709 /*
3710 * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will
3711 * have left us in a disconnected state. We need this hack to return
3712 * to connected state.
3713 */
3714 SPI_restore_connection();
3715
3716 /* Look up the correct exception */
3717 entry = hash_search(PLy_spi_exceptions, &edata->sqlerrcode,
when treating unknown struct ErrorData * from plpython.c:3701 as non-NULL
3718 HASH_FIND, NULL);
3719 /* We really should find it, but just in case have a fallback */
3720 Assert(entry != NULL);
3721 exc = entry ? entry->exc : PLy_exc_spi_error;
when treating unknown void * from plpython.c:3717 as non-NULL
taking True path
3722 /* Make Python raise the exception */
3723 PLy_spi_exception_set(exc, edata);
3724 return NULL;
3725 }
3726 PG_END_TRY();
3727
3728 if (rv < 0)
3729 {
3730 PLy_exception_set(PLy_exc_spi_error,
3731 "SPI_execute failed: %s",
3732 SPI_result_code_string(rv));
3733 return NULL;
3734 }
3735
3736 return ret;
3737 }
returning (PyObject*)NULL without setting an exception
found 4 similar trace(s) to this
File: | plpython.c |
Function: | PLy_spi_execute_query |
Error: | ob_refcnt of '*ret' is 1 too high |
3661 static PyObject *
3662 PLy_spi_execute_query(char *query, long limit)
3663 {
3664 int rv;
3665 volatile MemoryContext oldcontext;
3666 volatile ResourceOwner oldowner;
3667 PyObject *ret;
3668
3669 oldcontext = CurrentMemoryContext;
3670 oldowner = CurrentResourceOwner;
3671
3672 BeginInternalSubTransaction(NULL);
3673 /* Want to run inside function's memory context */
3674 MemoryContextSwitchTo(oldcontext);
3675
3676 PG_TRY();
when considering value == (int)0 from plpython.c:3676
taking True path
3677 {
3678 pg_verifymbstr(query, strlen(query), false);
3679 rv = SPI_execute(query, PLy_curr_procedure->fn_readonly, limit);
when treating unknown struct PLyProcedure * from plpython.c:421 as non-NULL
3680 ret = PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv);
when PLy_spi_execute_fetch_result() succeeds
new ref from (unknown) PLy_spi_execute_fetch_result allocated at: ret = PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv);
ob_refcnt is now refs: 1 + N where N >= 0
3681
3682 /* Commit the inner transaction, return to outer xact context */
3683 ReleaseCurrentSubTransaction();
3684 MemoryContextSwitchTo(oldcontext);
3685 CurrentResourceOwner = oldowner;
3686
3687 /*
3688 * AtEOSubXact_SPI() should not have popped any SPI context, but just
3689 * in case it did, make sure we remain connected.
3690 */
3691 SPI_restore_connection();
3692 }
3693 PG_CATCH();
3694 {
3695 ErrorData *edata;
3696 PLyExceptionEntry *entry;
3697 PyObject *exc;
3698
3699 /* Save error info */
3700 MemoryContextSwitchTo(oldcontext);
3701 edata = CopyErrorData();
3702 FlushErrorState();
3703
3704 /* Abort the inner transaction */
3705 RollbackAndReleaseCurrentSubTransaction();
3706 MemoryContextSwitchTo(oldcontext);
3707 CurrentResourceOwner = oldowner;
3708
3709 /*
3710 * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will
3711 * have left us in a disconnected state. We need this hack to return
3712 * to connected state.
3713 */
3714 SPI_restore_connection();
3715
3716 /* Look up the correct exception */
3717 entry = hash_search(PLy_spi_exceptions, &edata->sqlerrcode,
3718 HASH_FIND, NULL);
3719 /* We really should find it, but just in case have a fallback */
3720 Assert(entry != NULL);
3721 exc = entry ? entry->exc : PLy_exc_spi_error;
3722 /* Make Python raise the exception */
3723 PLy_spi_exception_set(exc, edata);
3724 return NULL;
3725 }
3726 PG_END_TRY();
3727
3728 if (rv < 0)
when considering range: -0x80000000 <= value <= -1
taking True path
3729 {
3730 PLy_exception_set(PLy_exc_spi_error,
3731 "SPI_execute failed: %s",
3732 SPI_result_code_string(rv));
3733 return NULL;
3734 }
3735
3736 return ret;
3737 }
ob_refcnt of '*ret' is 1 too high
was expecting final ob_refcnt to be N + 0 (for some unknown N)
but final ob_refcnt is N + 1