postgresql.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. Remove lorder(1) and tsort(1) stuff, because it is not needed on modern
  2. systems and makes problems under some platforms (e.g. older Linux).
  3. --- src/Makefile.global.in.orig Thu Sep 5 00:54:18 2002
  4. +++ src/Makefile.global.in Tue Jul 1 17:17:25 2003
  5. @@ -193,7 +193,7 @@
  6. LDREL = -r
  7. LDOUT = -o
  8. RANLIB = @RANLIB@
  9. -LORDER = @LORDER@
  10. +MK_NO_LORDER= true
  11. X = @EXEEXT@
  12. # Perl
  13. --- src/makefiles/Makefile.freebsd.orig Wed Aug 29 21:14:40 2001
  14. +++ src/makefiles/Makefile.freebsd Tue Jul 1 17:23:00 2003
  15. @@ -16,7 +16,7 @@
  16. $(LD) $(LDREL) $(LDOUT) $<.obj -x $<
  17. @echo building shared object $@
  18. @rm -f $@.pic
  19. - @${AR} cq $@.pic `lorder $<.obj | tsort`
  20. + @${AR} cq $@.pic
  21. ${RANLIB} $@.pic
  22. @rm -f $@
  23. $(LD) -x -Bshareable -Bforcearchive -o $@ $@.pic
  24. --- src/makefiles/Makefile.openbsd.orig Wed Aug 29 21:14:40 2001
  25. +++ src/makefiles/Makefile.openbsd Tue Jul 1 17:23:12 2003
  26. @@ -16,7 +16,7 @@
  27. $(LD) $(LDREL) $(LDOUT) $<.obj -x $<
  28. @echo building shared object $@
  29. @rm -f $@.pic
  30. - @${AR} cq $@.pic `lorder $<.obj | tsort`
  31. + @${AR} cq $@.pic
  32. ${RANLIB} $@.pic
  33. @rm -f $@
  34. $(LD) -x -Bshareable -Bforcearchive \
  35. --- src/makefiles/Makefile.netbsd.orig Wed Aug 29 21:14:40 2001
  36. +++ src/makefiles/Makefile.netbsd Tue Jul 1 17:23:39 2003
  37. @@ -18,7 +18,7 @@
  38. $(LD) $(LDREL) $(LDOUT) $<.obj -x $<
  39. @echo building shared object $@
  40. @rm -f $@.pic
  41. - @${AR} cq $@.pic `lorder $<.obj | tsort`
  42. + @${AR} cq $@.pic
  43. ${RANLIB} $@.pic
  44. @rm -f $@
  45. $(LD) -x -Bshareable -Bforcearchive \
  46. Index: src/template/freebsd
  47. --- src/template/freebsd.orig 2004-12-02 19:11:40.000000000 +0100
  48. +++ src/template/freebsd 2005-02-16 17:09:09.617038264 +0100
  49. @@ -1,3 +1,3 @@
  50. case $host_cpu in
  51. - alpha*) CFLAGS="-O";; # alpha has problems with -O2
  52. + alpha*) CFLAGS=`echo "x$CFLAGS" | sed -e 's;^x;;' -e 's;-O2;-O;'`;; # alpha has problems with -O2
  53. esac
  54. Index: src/template/linux
  55. --- src/template/linux.orig 2004-12-02 19:11:40.000000000 +0100
  56. +++ src/template/linux 2005-02-16 17:08:13.160599508 +0100
  57. @@ -1,2 +1,2 @@
  58. # Force _GNU_SOURCE on; plperl is broken with Perl 5.8.0 otherwise
  59. -CPPFLAGS="-D_GNU_SOURCE"
  60. +CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
  61. -----------------------------------------------------------------------------
  62. A small patch to allow DSO-based PostgreSQL extensions to be more
  63. flexible by providing initialization and finishing hooks. This patch was
  64. contributed by Ralf S. Engelschall to the upstream vendor in August 2006
  65. and taken over by the upstream vendor for inclusion into the next major
  66. PostgreSQL release.
  67. http://groups.google.com/group/pgsql.hackers/browse_frm/thread/ce7858f865a6fecd/19a3f052656f3a69?tvc=1&q=PG_init#19a3f052656f3a69
  68. Index: src/backend/utils/fmgr/dfmgr.c
  69. --- src/backend/utils/fmgr/dfmgr.c.orig 2005-10-15 04:49:32 +0200
  70. +++ src/backend/utils/fmgr/dfmgr.c 2006-10-07 11:53:58 +0200
  71. @@ -60,6 +60,10 @@
  72. static char *expand_dynamic_library_name(const char *name);
  73. static char *substitute_libpath_macro(const char *name);
  74. +/* types for PostgreSQL-specific DSO init/fini functions */
  75. +typedef void (*PG_init_t)(void);
  76. +typedef void (*PG_fini_t)(void);
  77. +
  78. /*
  79. * Load the specified dynamic-link library file, and look for a function
  80. * named funcname in it. (funcname can be NULL to just load the file.)
  81. @@ -77,6 +81,7 @@
  82. load_external_function(char *filename, char *funcname,
  83. bool signalNotFound, void **filehandle)
  84. {
  85. + PG_init_t *PG_init;
  86. DynamicFileList *file_scanner;
  87. PGFunction retval;
  88. char *load_error;
  89. @@ -146,6 +151,13 @@
  90. fullname, load_error)));
  91. }
  92. + /* optionally give the DSO a chance to initialize by calling a
  93. + PostgreSQL-specific (and this way portable) "_PG_init" function
  94. + similar to what dlopen(3) implicitly does with "_init" on some
  95. + Unix platforms. */
  96. + if ((PG_init = (PG_init_t *)pg_dlsym(file_scanner->handle, "_PG_init")) != NULL)
  97. + (*PG_init)();
  98. +
  99. /* OK to link it into list */
  100. if (file_list == NULL)
  101. file_list = file_scanner;
  102. @@ -187,6 +199,7 @@
  103. void
  104. load_file(char *filename)
  105. {
  106. + PG_fini_t *PG_fini;
  107. DynamicFileList *file_scanner,
  108. *prv,
  109. *nxt;
  110. @@ -223,6 +236,14 @@
  111. prv->next = nxt;
  112. else
  113. file_list = nxt;
  114. +
  115. + /* optionally give the DSO a chance to finish by calling
  116. + a PostgreSQL-specific (and this way portable) "_PG_fini"
  117. + function similar to what dlopen(3) implicitly does with
  118. + "_fini" on some Unix platforms. */
  119. + if ((PG_fini = (PG_fini_t *)pg_dlsym(file_scanner->handle, "_PG_fini")) != NULL)
  120. + (*PG_fini)();
  121. +
  122. clear_external_function_hash(file_scanner->handle);
  123. pg_dlclose(file_scanner->handle);
  124. free((char *) file_scanner);