Dennis Bjorklund <[EMAIL PROTECTED]> 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);

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to