Skip site navigation (1) Skip section navigation (2)

Re: LOAD broken?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: LOAD broken?
Date: 2003-09-07 02:22:03
Message-ID: 5768.1062901323@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org> 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);

In response to

pgsql-bugs by date

Next:From: Gaetano MendolaDate: 2003-09-07 17:19:08
Subject: Re: pl/pgsql problem with search_path
Previous:From: Bruce MomjianDate: 2003-09-07 01:40:27
Subject: Re: pl/pgsql problem with search_path

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group