Skip site navigation (1) Skip section navigation (2)

SPI_psprintf and SPI_pstrdup

From: Jacob Rief <jacob(dot)rief(at)gmx(dot)at>
To: pgsql-patches(at)postgresql(dot)org
Subject: SPI_psprintf and SPI_pstrdup
Date: 2007-04-24 20:51:04
Message-ID: 1177447864.4530.21.camel@ruben (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
The Apache runtime library, which is using a similar concept for
allocating heap-based memory out of a pool, has some since utility
functions, named apr_psprintf and apr_pstrdup.
These functions allocate a memory-block out of a pool and print a
formatted string into that block, or duplicate a string respectively.

Since such useful functions are missing in PostgreSQL's Server
Programming Interface, I created two similar functions:

char *SPI_psprintf(const char *fmt, ...);
allocates a block of memory out of the memory pool and prints a
formatted string into it

SPI_pstrdup(const char *src);
allocates a block of memory out of the memory pool and copies an
existing string into it.

I includes a patch containing these functions to be applied onto version
8.2.3 and 8.2.4. I would appreciate seeing it in one of the next

Jacob Rief

Attachment: postgresql-8.2.4-SPI_extras.patch
Description: text/x-patch (1.7 KB)


pgsql-patches by date

Next:From: Peter EisentrautDate: 2007-04-24 21:08:57
Subject: Re: SPI_psprintf and SPI_pstrdup
Previous:From: Tom LaneDate: 2007-04-24 20:25:40
Subject: Re: BUG #3245: PANIC: failed to re-find shared loc k o b j ect

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group