LOAD broken?

Поиск
Список
Период
Сортировка
Искать

LOAD broken?

От:
Dennis Bjorklund <db@zigo.dhs.org>
Дата:
I've got a C function in a .so that I use in postgres. While developing it 
I want to reload the dynamic library. The docs says that LOAD should do 
the trick but nothing happens when I use it.

Have LOAD stoped working and is it now a NOP?

I've tried LOAD both when the function exists in pg, and when I first drop
the function, do the load and then create the function again. But it makes
no difference.

I run redhat 9, maybe load works in other dists/operating systems?

-- 
/Dennis

Re: LOAD broken?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Dennis Bjorklund  writes:
> I've got a C function in a .so that I use in postgres. While developing it 
> I want to reload the dynamic library. The docs says that LOAD should do 
> the trick but nothing happens when I use it.

You're right, this seems not to work on Linux.  I've applied the
attached patch to CVS tip.

			regards, tom lane

*** src/backend/utils/fmgr/dfmgr.c.orig	Sun Aug  3 23:01:07 2003
--- src/backend/utils/fmgr/dfmgr.c	Sat Sep  6 22:13:25 2003
***************
*** 177,183 ****
  load_file(char *filename)
  {
  	DynamicFileList *file_scanner,
! 			   *p;
  	struct stat stat_buf;
  	char	   *fullname;
  
--- 178,185 ----
  load_file(char *filename)
  {
  	DynamicFileList *file_scanner,
! 			   *prv,
! 			   *nxt;
  	struct stat stat_buf;
  	char	   *fullname;
  
***************
*** 196,226 ****
  				(errcode_for_file_access(),
  				 errmsg("could not access file \"%s\": %m", fullname)));
  
! 	if (file_list != (DynamicFileList *) NULL)
  	{
! 		if (SAME_INODE(stat_buf, *file_list))
  		{
! 			p = file_list;
! 			file_list = p->next;
! 			pg_dlclose(p->handle);
! 			free((char *) p);
  		}
  		else
! 		{
! 			for (file_scanner = file_list;
! 				 file_scanner->next != (DynamicFileList *) NULL;
! 				 file_scanner = file_scanner->next)
! 			{
! 				if (SAME_INODE(stat_buf, *(file_scanner->next)))
! 				{
! 					p = file_scanner->next;
! 					file_scanner->next = p->next;
! 					pg_dlclose(p->handle);
! 					free((char *) p);
! 					break;
! 				}
! 			}
! 		}
  	}
  
  	load_external_function(fullname, (char *) NULL, false, (void *) NULL);
--- 198,224 ----
  				(errcode_for_file_access(),
  				 errmsg("could not access file \"%s\": %m", fullname)));
  
! 	/*
! 	 * We have to zap all entries in the list that match on either filename
! 	 * or inode, else load_external_function() won't do anything.
! 	 */
! 	prv = NULL;
! 	for (file_scanner = file_list; file_scanner != NULL; file_scanner = nxt)
  	{
! 		nxt = file_scanner->next;
! 		if (strcmp(fullname, file_scanner->filename) == 0 ||
! 			SAME_INODE(stat_buf, *file_scanner))
  		{
! 			if (prv)
! 				prv->next = nxt;
! 			else
! 				file_list = nxt;
! 			pg_dlclose(file_scanner->handle);
! 			free((char *) file_scanner);
! 			/* prv does not change */
  		}
  		else
! 			prv = file_scanner;
  	}
  
  	load_external_function(fullname, (char *) NULL, false, (void *) NULL);
FAQ