mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Code review for magic-block patch. Remove separate header file pgmagic.h,
as this seems only likely to create headaches for module developers. Put the macro in the pre-existing fmgr.h file instead. Avoid being too cute about how many fields we can cram into a word, and avoid trying to fetch from a library we've already unlinked. Along the way, it occurred to me that the magic block really ought to be 'const' so it can be stored in the program text area. Do the same for the existing data blocks for PG_FUNCTION_INFO_V1 functions.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.113 2006/05/30 14:09:32 momjian Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.114 2006/05/30 21:21:29 tgl Exp $ -->
|
||||
|
||||
<sect1 id="xfunc">
|
||||
<title>User-Defined Functions</title>
|
||||
@ -1148,13 +1148,6 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision
|
||||
that fails as well, the load will fail.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
After the module has been found, PostgreSQL looks for its magic block.
|
||||
This block contains information about the environment a module was
|
||||
compiled in. The server uses this to verify the module was compiled
|
||||
under the same assumptions and environment as the backend.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The user ID the <productname>PostgreSQL</productname> server runs
|
||||
as must be able to traverse the path to the file you intend to
|
||||
@ -1958,26 +1951,6 @@ concat_text(PG_FUNCTION_ARGS)
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
To ensure your module is not loaded into an incompatible backend, it
|
||||
is recommended to include a magic block. To do this you must include
|
||||
the header <filename>pgmagic.h</filename> and declare the block as
|
||||
follows:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
#include "pgmagic.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If the module consists of multiple source files, this only needs to
|
||||
be done in one of them.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Symbol names defined within object files must not conflict
|
||||
@ -1988,6 +1961,31 @@ PG_MODULE_MAGIC;
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
To ensure your module is not loaded into an incompatible server, it
|
||||
is recommended to include a <quote>magic block</>. This allows
|
||||
the server to detect obvious incompatibilities, such as a module
|
||||
compiled for a different major version of
|
||||
<productname>PostgreSQL</productname>. It is likely that magic
|
||||
blocks will be required in future releases. To include a magic
|
||||
block, write this in one (and only one) of your module source files,
|
||||
after having included the header <filename>fmgr.h</>:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
#ifdef PG_MODULE_MAGIC
|
||||
PG_MODULE_MAGIC;
|
||||
#endif
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
The <literal>#ifdef</> test can be omitted if your code doesn't
|
||||
need to compile against pre-8.2 <productname>PostgreSQL</productname>
|
||||
releases.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Compiling and linking your code so that it can be dynamically
|
||||
|
Reference in New Issue
Block a user