fmgr changes not yet ported to AIX

Started by Zeugswetter Andreas SBover 25 years ago4 messages
#1Zeugswetter Andreas SB
ZeugswetterA@wien.spardat.at

Just wanted to give a short message, that current snapshot does not
compile on AIX due to the fmgr changes.
I have some patches that unfortunately affect other ports but not a complete
fix.
Why are the pg_dlopen ... declared extern in include/utils/dynamic_loader.h
?

aside: Why is sys/fcntl.h included in c.h and not in config.h ?
AIX has fcntl.h, but that seems not to be compatible with dlfcn.h.
It does not seem to be missing if commented out.

Andreas

PS: Am I the only looser who now looking at the new fmgr interface has his
doubts
about the changes ?

What exactly does it gain except masking badly written code
(casts to wrong datatype like ints to longs) that goof the optimizers and
64bit ports
and solving the null value problem ?

My ideas would be:
- multi row returns
- multi column returns (not opaque)
- portability to other implementations
(Informix is similar to our old fmgr interface,
Oracle's interface I think is not open to the public)

It would e.g. have been possible to add the NULL indicator array as last
argument
to the existing scheme. Informix reserves one value of each pass by value
datatype
to represent NULLs which imho is a bad idea (e.g. INT_MIN for int's).

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Zeugswetter Andreas SB (#1)
Re: fmgr changes not yet ported to AIX

Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:

Just wanted to give a short message, that current snapshot does not
compile on AIX due to the fmgr changes.

Without more details, that's completely unhelpful.

What exactly does it gain except masking badly written code
(casts to wrong datatype like ints to longs) that goof the optimizers and
64bit ports
and solving the null value problem ?

My ideas would be:
- multi row returns
- multi column returns (not opaque)

I've said before and I'll say it again: all I'm doing in this round is
fixing our portability and NULL-value problems. Better handling of sets
and tuples is a higher-level problem. If you want to start working on
that, be my guest...

regards, tom lane

#3Zeugswetter Andreas SB
ZeugswetterA@wien.spardat.at
In reply to: Tom Lane (#2)
1 attachment(s)
AW: fmgr changes not yet ported to AIX

Just wanted to give a short message, that current snapshot does not
compile on AIX due to the fmgr changes.

Without more details, that's completely unhelpful.

Yes sorry, I just wanted to know if somebody already knows,
or is working on it, before going into detail.

xlc -I../../../include -I/usr/local/include -qmaxmem=16384 -qhalt=w -qsrcmsg
-qlanglvl=ext
ended -qlonglong -I/usr/local/include -c -o dfmgr.o dfmgr.c
"../../../include/utils/dynamic_loader.h", line 26.14: 1506-276 (S) Syntax
error: possible
missing identifier?
"../../../include/utils/dynamic_loader.h", line 26.14: 1506-282 (S) The type
of the parame
ters must be specified in a prototype.
"../../../include/utils/dynamic_loader.h", line 27.19: 1506-343 (S)
Redeclaration of dlsym
differs from previous declaration on line 36 of
"../../../include/dynloader.h".
"../../../include/utils/dynamic_loader.h", line 27.19: 1506-050 (I) Return
type "unsigned
long(*)(struct FunctionCallInfoData*)" in redeclaration is not compatible
with the previou
s return type "void*".
"../../../include/utils/dynamic_loader.h", line 28.13: 1506-343 (S)
Redeclaration of dlclo
se differs from previous declaration on line 38 of
"../../../include/dynloader.h".
"../../../include/utils/dynamic_loader.h", line 28.13: 1506-050 (I) Return
type "void" in
redeclaration is not compatible with the previous return type "int".
"../../../include/utils/dynamic_loader.h", line 29.25: 1506-215 (E) Too many
arguments spe
cified for macro pg_dlerror.
gmake[4]: *** [dfmgr.o] Error 1

Why do you declare dlopen, dlsym, ... in dynamic_loader.h ?
They are defined in the port specific dynloader.h .
Why do you use "void pg_dlclose" when dlclose is "int dlclose" ?
This makes a wrapper function necessary.

Same with "PGFunction pg_dlsym" when dlsym is "void *dlsym"

What I tried is in the attachment, but I guess at least the cast in dfmgr.c
is unwanted.

Andreas

Attachments:

aix_patchapplication/octet-stream; name=aix_patchDownload
*** ./src/backend/port/dynloader/aix.h.orig	Tue Sep  1 06:30:51 1998
--- ./src/backend/port/dynloader/aix.h	Wed Jul 12 17:11:39 2000
***************
*** 48,56 ****
  
  #endif
  
! #define  pg_dlopen(f)	dlopen(filename, RTLD_LAZY)
! #define  pg_dlsym(h,f)	dlsym(h, f)
! #define  pg_dlclose(h)	dlclose(h)
! #define  pg_dlerror()	dlerror()
  
  #endif	 /* __dlfcn_h__ */
--- 48,56 ----
  
  #endif
  
! #define  pg_dlopen(f)	dlopen(f, RTLD_LAZY)
! #define  pg_dlsym	dlsym
! #define  pg_dlclose	dlclose
! #define  pg_dlerror	dlerror
  
  #endif	 /* __dlfcn_h__ */
*** ./src/backend/utils/fmgr/dfmgr.c.orig	Thu Jul  6 09:00:35 2000
--- ./src/backend/utils/fmgr/dfmgr.c	Wed Jul 12 17:17:46 2000
***************
*** 160,166 ****
  	if (funcname == (char *) NULL)
  		return (PGFunction) NULL;
  
! 	retval = pg_dlsym(file_scanner->handle, funcname);
  
  	if (retval == (PGFunction) NULL)
  		elog(ERROR, "Can't find function %s in file %s", funcname, filename);
--- 160,166 ----
  	if (funcname == (char *) NULL)
  		return (PGFunction) NULL;
  
! 	retval = (PGFunction) pg_dlsym(file_scanner->handle, funcname);
  
  	if (retval == (PGFunction) NULL)
  		elog(ERROR, "Can't find function %s in file %s", funcname, filename);
*** ./src/include/utils/dynamic_loader.h.orig	Mon May 29 09:00:21 2000
--- ./src/include/utils/dynamic_loader.h	Wed Jul 12 17:13:11 2000
***************
*** 22,31 ****
  /* and this one for typedef PGFunction */
  #include "fmgr.h"
  
  
  extern void *pg_dlopen(char *filename);
  extern PGFunction pg_dlsym(void *handle, char *funcname);
! extern void pg_dlclose(void *handle);
  extern char *pg_dlerror(void);
  
  #endif	 /* DYNAMIC_LOADER_H */
--- 22,34 ----
  /* and this one for typedef PGFunction */
  #include "fmgr.h"
  
+ #include "dynloader.h"
  
+ /*
  extern void *pg_dlopen(char *filename);
  extern PGFunction pg_dlsym(void *handle, char *funcname);
! extern int pg_dlclose(void *handle);
  extern char *pg_dlerror(void);
+ */
  
  #endif	 /* DYNAMIC_LOADER_H */
*** ./src/include/c.h.orig	Sat Jul  8 09:00:23 2000
--- ./src/include/c.h	Wed Jul 12 16:45:54 2000
***************
*** 50,56 ****
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
! #include <sys/fcntl.h>
  #ifdef STDC_HEADERS
  #include <stddef.h>
  #include <stdarg.h>
--- 50,56 ----
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
! /* #include <sys/fcntl.h> */
  #ifdef STDC_HEADERS
  #include <stddef.h>
  #include <stdarg.h>
No differences encountered
#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Zeugswetter Andreas SB (#3)
Re: AW: fmgr changes not yet ported to AIX

Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:

Why do you declare dlopen, dlsym, ... in dynamic_loader.h ?
They are defined in the port specific dynloader.h .
Why do you use "void pg_dlclose" when dlclose is "int dlclose" ?
This makes a wrapper function necessary.

It seems to me that the real problem here is that someone tried to
take shortcuts in the AIX dynloader code. Instead of implementing
the same interface that the rest of the ports support, the AIX files
try to force their own definition of the pg_dlXXX functions --- and
for what? To save a wrapper function? These are hardly performance-
critical routines, so I don't see the point.

I propose the following changes instead. I don't have any way to
test them however --- would you check them?

regards, tom lane

*** aix.h~	Mon Jul 17 00:40:12 2000
--- aix.h	Mon Jul 17 00:41:34 2000
***************
*** 45,56 ****

#ifdef __cplusplus
}
-
#endif
-
- #define pg_dlopen(f) dlopen(filename, RTLD_LAZY)
- #define pg_dlsym(h,f) dlsym(h, f)
- #define pg_dlclose(h) dlclose(h)
- #define pg_dlerror() dlerror()

  #endif	 /* __dlfcn_h__ */
--- 45,50 ----
*** aix.c~	Mon Jul 17 00:40:19 2000
--- aix.c	Mon Jul 17 00:45:34 2000
***************
*** 601,603 ****
--- 601,631 ----
  	free(buf);
  	return ret;
  }
+ 
+ /*
+  * PostgreSQL interface to the above functions
+  */
+ 
+ void *
+ pg_dlopen(char *filename)
+ {
+ 	return dlopen(filename, RTLD_LAZY);
+ }
+ 
+ PGFunction
+ pg_dlsym(void *handle, char *funcname)
+ {
+ 	return (PGFunction) dlsym(handle, funcname);
+ }
+ 
+ void
+ pg_dlclose(void *handle)
+ {
+ 	dlclose(h);
+ }
+ 
+ char *
+ pg_dlerror()
+ {
+ 	return dlerror();
+ }