From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Create libpgcommon, and move pg_malloc et al to it |
Date: | 2013-02-12 14:55:16 |
Message-ID: | E1U5HGO-0000Ou-77@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/8396447cdbdff0b62914748de2fec04281dc9114
Modified Files
--------------
contrib/oid2name/oid2name.c | 50 -------------
contrib/pg_upgrade/check.c | 2 +-
contrib/pg_upgrade/controldata.c | 2 +-
contrib/pg_upgrade/dump.c | 2 +-
contrib/pg_upgrade/exec.c | 2 +-
contrib/pg_upgrade/file.c | 2 +-
contrib/pg_upgrade/function.c | 2 +-
contrib/pg_upgrade/info.c | 2 +-
contrib/pg_upgrade/option.c | 2 +-
contrib/pg_upgrade/page.c | 2 +-
contrib/pg_upgrade/parallel.c | 2 +-
contrib/pg_upgrade/pg_upgrade.c | 2 +-
contrib/pg_upgrade/pg_upgrade.h | 4 -
contrib/pg_upgrade/relfilenode.c | 2 +-
contrib/pg_upgrade/server.c | 2 +-
contrib/pg_upgrade/tablespace.c | 2 +-
contrib/pg_upgrade/util.c | 51 +-------------
contrib/pg_upgrade/version.c | 2 +-
contrib/pg_upgrade/version_old_8_3.c | 2 +-
contrib/pgbench/pgbench.c | 53 --------------
src/Makefile | 1 +
src/Makefile.global.in | 25 ++++---
src/backend/storage/file/copydir.c | 11 ---
src/backend/utils/mmgr/mcxt.c | 78 +++++++++++---------
src/bin/initdb/initdb.c | 39 ----------
src/bin/pg_basebackup/streamutil.c | 37 ----------
src/bin/pg_basebackup/streamutil.h | 4 -
src/bin/pg_ctl/pg_ctl.c | 38 ----------
src/bin/pg_dump/Makefile | 6 +-
src/bin/pg_dump/common.c | 2 -
src/bin/pg_dump/compress_io.c | 1 -
src/bin/pg_dump/dumpmem.c | 76 -------------------
src/bin/pg_dump/dumpmem.h | 22 ------
src/bin/pg_dump/dumputils.c | 1 -
src/bin/pg_dump/nls.mk | 2 +-
src/bin/pg_dump/pg_backup_archiver.c | 1 -
src/bin/pg_dump/pg_backup_custom.c | 1 -
src/bin/pg_dump/pg_backup_db.c | 1 -
src/bin/pg_dump/pg_backup_directory.c | 1 -
src/bin/pg_dump/pg_backup_null.c | 1 -
src/bin/pg_dump/pg_backup_tar.c | 1 -
src/bin/pg_dump/pg_dump.c | 1 -
src/bin/pg_dump/pg_dump_sort.c | 1 -
src/bin/pg_dump/pg_dumpall.c | 1 -
src/bin/pg_dump/pg_restore.c | 1 -
src/bin/pg_resetxlog/pg_resetxlog.c | 5 +-
src/bin/psql/common.c | 50 -------------
src/bin/psql/common.h | 9 ---
src/bin/scripts/common.c | 49 -------------
src/bin/scripts/common.h | 4 -
src/common/Makefile | 64 ++++++++++++++++
src/common/fe_memutils.c | 128 +++++++++++++++++++++++++++++++++
src/include/common/fe_memutils.h | 20 +++++
src/include/postgres_fe.h | 2 +
src/include/utils/palloc.h | 30 ++------
src/port/dirmod.c | 74 -------------------
src/tools/msvc/Install.pm | 1 +
src/tools/msvc/Mkvcbuild.pm | 35 +++++++--
src/tools/msvc/Project.pm | 2 +-
59 files changed, 332 insertions(+), 684 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2013-02-12 15:23:04 | pgsql: Don't build libpgcommon_srv.a just yet |
Previous Message | Andres Freund | 2013-02-12 12:19:01 | Re: pgsql: Add noreturn attributes to some error reporting functions |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2013-02-12 15:08:14 | Re: palloc unification |
Previous Message | Amit Kapila | 2013-02-12 14:49:43 | Re: Re: Proposal for Allow postgresql.conf values to be changed via SQL [review] |