Search Postgresql Archives

Re: server-side extension in c++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tom Lane wrote:
> Bruce Momjian <bruce@xxxxxxxxxx> writes:
> > That is great new information.  I have created a new documentation
> > section called "Using C++ for Extensibility", and listed you as the
> > author in the CVS commit;  patch attached.  Thanks. 
> 
> Too bad two out of the four pieces of advice are wrong (how many pieces
> of memory managed by the backend are allocated directly with malloc?).
> The other two are not wrong as far as they go, but they're certainly
> woefully inadequate, because no interesting backend extension is going
> to be able to get along without calling back into the core code.

Good point.  I assumed others would chime in to improve this.

> Personally I would reduce this section to
> 
> 	<para>
> 	 Don't.
> 	</para>
> 
> I don't think it is worth our time to try to support people who run into
> the inevitable memory management and error handling incompatibilities.
> Nor are they likely to be happy at the end of the experience, if we
> blithely tell them up front that it'll work.

Well, I would have avoided this mine-trap except we have this 9.0
release note item:

       Allow use of <productname>C++</> functions in backend code (Kurt
       Harriman, Peter Eisentraut)

I figure if we don't provide some guidance, things will be even worse.

I have updated the docs to mention palloc/pfree instead;  applied patch
attached.

-- 
  Bruce Momjian  <bruce@xxxxxxxxxx>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + None of us is going to be here forever. +
Index: doc/src/sgml/extend.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v
retrieving revision 1.40
diff -c -c -r1.40 extend.sgml
*** doc/src/sgml/extend.sgml	1 Jun 2010 02:35:37 -0000	1.40
--- doc/src/sgml/extend.sgml	1 Jun 2010 02:53:30 -0000
***************
*** 296,309 ****
       </listitem>
       <listitem>
        <para>
!        Use <function>malloc()</> to allocate any memory that might be
         freed by the backend C code (don't pass <function>new()</>-allocated
         memory).
        </para>
       </listitem>
       <listitem>
        <para>
!        Use <function>free()</> to free memory allocated by the backend
         C code (do not use <function>delete()</> for such cases).
        </para>
       </listitem>
--- 296,309 ----
       </listitem>
       <listitem>
        <para>
!        Use <function>palloc()</> to allocate any memory that might be
         freed by the backend C code (don't pass <function>new()</>-allocated
         memory).
        </para>
       </listitem>
       <listitem>
        <para>
!        Use <function>pfree()</> to free memory allocated by the backend
         C code (do not use <function>delete()</> for such cases).
        </para>
       </listitem>
-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux