Exemplo n.º 1
0
static Datum internalCallHandler(bool trusted, PG_FUNCTION_ARGS)
{
	Invocation ctx;
	Datum retval = 0;

	if ( IS_COMPLETE != initstage )
	{
		/*
		 * Just in case it could be helpful in offering diagnostics later, hang
		 * on to an Oid that is known to refer to PL/Java (because it got here).
		 * It's cheap, and can be followed back to the right language and
		 * handler function entries later if needed.
		 */
		*(trusted ? &pljavaTrustedOid : &pljavaUntrustedOid)
			= fcinfo->flinfo->fn_oid;
		initsequencer( initstage, false);

		/* Force initial setting
 		 */
		s_currentTrust = !trusted;
	}

	Invocation_pushInvocation(&ctx, trusted);
	PG_TRY();
	{
		Function function = Function_getFunction(fcinfo);
		if(CALLED_AS_TRIGGER(fcinfo))
		{
			/* Called as a trigger procedure
			 */
			retval = Function_invokeTrigger(function, fcinfo);
		}
		else
		{
			/* Called as a function
			 */
			retval = Function_invoke(function, fcinfo);
		}
		Invocation_popInvocation(false);
	}
	PG_CATCH();
	{
		Invocation_popInvocation(true);
		PG_RE_THROW();
	}
	PG_END_TRY();
	return retval;
}
Exemplo n.º 2
0
static Datum internalCallHandler(bool trusted, PG_FUNCTION_ARGS)
{
	Invocation ctx;
	Datum retval = 0;

#ifdef USE_PLJAVA_SIGHANDLERS
	/*
	 * Substitute SIGUSR1 handler CatchupInterruptHandler with new local
	 * handler PLCatchupInterruptHandler, which will strictly let main
	 * thread of GPDB to process the signal rather than any other threads.
	 *
	 * Resolving possible lwlock releasing crash caused by SIGUSR1.
	 * MPP-23735
	 */
	if(!s_handlerSubstituted)
	{
		s_mainThreadIdForHandler = pthread_self();
		s_oldHandlerFunc = pqsignal(SIGUSR1, PLCatchupInterruptHandler);
		s_handlerSubstituted = true;
	}
#endif

	/*
	 * Just in case it could be helpful in offering diagnostics later, hang
	 * on to an Oid that is known to refer to PL/Java (because it got here).
	 * It's cheap, and can be followed back to the right language and
	 * handler function entries later if needed.
	 */
	*(trusted ? &pljavaTrustedOid : &pljavaUntrustedOid)
		= fcinfo->flinfo->fn_oid;
	if ( IS_COMPLETE != initstage )
	{
		initsequencer( initstage, false);

		/* Force initial setting
 		 */
		s_currentTrust = !trusted;
	}

	Invocation_pushInvocation(&ctx, trusted);
	PG_TRY();
	{
		Function function = Function_getFunction(fcinfo);
		if(CALLED_AS_TRIGGER(fcinfo))
		{
			/* Called as a trigger procedure
			 */
			retval = Function_invokeTrigger(function, fcinfo);
		}
		else
		{
			/* Called as a function
			 */
			retval = Function_invoke(function, fcinfo);
		}
		Invocation_popInvocation(false);
	}
	PG_CATCH();
	{
		Invocation_popInvocation(true);
		PG_RE_THROW();
	}
	PG_END_TRY();
	return retval;
}