Hello

attached patch allows raising exception from _PG_init function as was
discussed before.

regards
Pavel Stehule
*** ./src/backend/utils/fmgr/dfmgr.c.orig	2009-03-31 20:32:21.000000000 +0200
--- ./src/backend/utils/fmgr/dfmgr.c	2009-03-31 21:59:36.000000000 +0200
***************
*** 281,287 ****
  		 */
  		PG_init = (PG_init_t) pg_dlsym(file_scanner->handle, "_PG_init");
  		if (PG_init)
! 			(*PG_init) ();
  
  		/* OK to link it into list */
  		if (file_list == NULL)
--- 281,313 ----
  		 */
  		PG_init = (PG_init_t) pg_dlsym(file_scanner->handle, "_PG_init");
  		if (PG_init)
! 		{
! 			MemoryContext	oldcontext = CurrentMemoryContext;
! 		
! 			PG_TRY();
! 			{
! 				/* try to init library */
! 				(*PG_init) ();
! 			}
! 			PG_CATCH();
! 			{
! 				ErrorData *edata;
! 				
! 				MemoryContextSwitchTo(oldcontext);
! 				edata = CopyErrorData();
! 				FlushErrorState();
! 			
! 				/* we can't to use PG_RE_THROWN after close the originator file */
! 				clear_external_function_hash(file_scanner->handle);
! 				pg_dlclose(file_scanner->handle);
! 				free((char *) file_scanner);
! 				
! 				ereport(ERROR, 
! 						(errmsg("cannot initialise library \"%s\"", libname),
! 						 errhint("Function _PG_init throws exception \"%s\".", edata->message)));
! 			}
! 			PG_END_TRY();
! 		}
  
  		/* OK to link it into list */
  		if (file_list == NULL)
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to