pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Move pg_lzcompress.c to src/common.
8+ messages / 5 participants
[nested] [flat]

* pgsql: Move pg_lzcompress.c to src/common.
@ 2014-12-25 11:47  Fujii Masao <fujii@postgresql.org>
  0 siblings, 1 reply; 8+ messages in thread

From: Fujii Masao @ 2014-12-25 11:47 UTC (permalink / raw)
  To: pgsql-committers

Move pg_lzcompress.c to src/common.

Exposing compression and decompression APIs of pglz makes possible its
use by extensions and contrib modules. pglz_decompress contained a call
to elog to emit an error message in case of corrupted data. This function
is changed to return a status code to let its callers return an error instead.

This commit is required for upcoming WAL compression feature so that
the WAL reader facility can decompress the WAL data by using pglz_decompress.

Michael Paquier

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/60838df922345b26a616e49ac9fab808a35d1f85

Modified Files
--------------
src/backend/access/heap/tuptoaster.c  |   11 +-
src/backend/utils/adt/Makefile        |    4 +-
src/backend/utils/adt/pg_lzcompress.c |  779 --------------------------------
src/common/Makefile                   |    3 +-
src/common/pg_lzcompress.c            |  786 +++++++++++++++++++++++++++++++++
src/include/common/pg_lzcompress.h    |  112 +++++
src/include/utils/pg_lzcompress.h     |  112 -----
src/tools/msvc/Mkvcbuild.pm           |    3 +-
8 files changed, 911 insertions(+), 899 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Move pg_lzcompress.c to src/common.
@ 2014-12-25 13:39  Fujii Masao <masao.fujii@gmail.com>
  parent: Fujii Masao <fujii@postgresql.org>
  0 siblings, 1 reply; 8+ messages in thread

From: Fujii Masao @ 2014-12-25 13:39 UTC (permalink / raw)
  To: Fujii Masao <fujii@postgresql.org>; +Cc: pgsql-committers

On Thu, Dec 25, 2014 at 8:47 PM, Fujii Masao <fujii@postgresql.org> wrote:
> Move pg_lzcompress.c to src/common.
>
> Exposing compression and decompression APIs of pglz makes possible its
> use by extensions and contrib modules. pglz_decompress contained a call
> to elog to emit an error message in case of corrupted data. This function
> is changed to return a status code to let its callers return an error instead.
>
> This commit is required for upcoming WAL compression feature so that
> the WAL reader facility can decompress the WAL data by using pglz_decompress.

Hmm... the buildfarm member prairiedog doesn't like this change. Because
pg_lzcompress.c uses the macros (like VARSIZE) for varlena datatypes which
are defined in postgres.h which client-side should not include. ISTM that
pg_lzcompress.c should be changed to be "varlena-free", in order to push it
in src/common.

Regards,

-- 
Fujii Masao


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Move pg_lzcompress.c to src/common.
@ 2014-12-25 13:43  Andres Freund <andres@2ndquadrant.com>
  parent: Fujii Masao <masao.fujii@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Andres Freund @ 2014-12-25 13:43 UTC (permalink / raw)
  To: Fujii Masao <masao.fujii@gmail.com>; +Cc: Fujii Masao <fujii@postgresql.org>; pgsql-committers

On 2014-12-25 22:39:58 +0900, Fujii Masao wrote:
> On Thu, Dec 25, 2014 at 8:47 PM, Fujii Masao <fujii@postgresql.org> wrote:
> > Move pg_lzcompress.c to src/common.
> >
> > Exposing compression and decompression APIs of pglz makes possible its
> > use by extensions and contrib modules. pglz_decompress contained a call
> > to elog to emit an error message in case of corrupted data. This function
> > is changed to return a status code to let its callers return an error instead.
> >
> > This commit is required for upcoming WAL compression feature so that
> > the WAL reader facility can decompress the WAL data by using pglz_decompress.
> 
> Hmm... the buildfarm member prairiedog doesn't like this change. Because
> pg_lzcompress.c uses the macros (like VARSIZE) for varlena datatypes which
> are defined in postgres.h which client-side should not include. ISTM that
> pg_lzcompress.c should be changed to be "varlena-free", in order to push it
> in src/common.

Temporarily this can be solved by including postgres.h the way
e.g. pg_resetxlog does:

/*
 * We have to use postgres.h not postgres_fe.h here, because there's so much
 * backend-only stuff in the XLOG include files we need.  But we need a
 * frontend-ish environment otherwise.  Hence this ugly hack.
 */
#define FRONTEND 1

#include "postgres.h"

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Move pg_lzcompress.c to src/common.
@ 2014-12-25 14:46  Michael Paquier <michael.paquier@gmail.com>
  parent: Andres Freund <andres@2ndquadrant.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Michael Paquier @ 2014-12-25 14:46 UTC (permalink / raw)
  To: Andres Freund <andres@2ndquadrant.com>; +Cc: Fujii Masao <masao.fujii@gmail.com>; Fujii Masao <fujii@postgresql.org>; pgsql-committers

On Thu, Dec 25, 2014 at 10:43 PM, Andres Freund <andres@2ndquadrant.com> wrote:
> On 2014-12-25 22:39:58 +0900, Fujii Masao wrote:
>> On Thu, Dec 25, 2014 at 8:47 PM, Fujii Masao <fujii@postgresql.org> wrote:
>> > Move pg_lzcompress.c to src/common.
>> >
>> > Exposing compression and decompression APIs of pglz makes possible its
>> > use by extensions and contrib modules. pglz_decompress contained a call
>> > to elog to emit an error message in case of corrupted data. This function
>> > is changed to return a status code to let its callers return an error instead.
>> >
>> > This commit is required for upcoming WAL compression feature so that
>> > the WAL reader facility can decompress the WAL data by using pglz_decompress.
>>
>> Hmm... the buildfarm member prairiedog doesn't like this change. Because
>> pg_lzcompress.c uses the macros (like VARSIZE) for varlena datatypes which
>> are defined in postgres.h which client-side should not include. ISTM that
>> pg_lzcompress.c should be changed to be "varlena-free", in order to push it
>> in src/common.
>
> Temporarily this can be solved by including postgres.h the way
> e.g. pg_resetxlog does:
>
> /*
>  * We have to use postgres.h not postgres_fe.h here, because there's so much
>  * backend-only stuff in the XLOG include files we need.  But we need a
>  * frontend-ish environment otherwise.  Hence this ugly hack.
>  */
> #define FRONTEND 1
>
> #include "postgres.h"
Urgh.. Would that mean keeping a local copy of SET_VARSIZE_4B_C and
VARSIZE_4B if this hack is not used? Looking at the git history, I am
seeing similar things in 2008 where pg_crc stuff was moved to src/port
(5c9c08d).
-- 
Michael


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Move pg_lzcompress.c to src/common.
@ 2014-12-25 16:05  Andres Freund <andres@2ndquadrant.com>
  parent: Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Andres Freund @ 2014-12-25 16:05 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Fujii Masao <masao.fujii@gmail.com>; Fujii Masao <fujii@postgresql.org>; pgsql-committers

On 2014-12-25 23:46:52 +0900, Michael Paquier wrote:
> On Thu, Dec 25, 2014 at 10:43 PM, Andres Freund <andres@2ndquadrant.com> wrote:
> > /*
> >  * We have to use postgres.h not postgres_fe.h here, because there's so much
> >  * backend-only stuff in the XLOG include files we need.  But we need a
> >  * frontend-ish environment otherwise.  Hence this ugly hack.
> >  */
> > #define FRONTEND 1
> >
> > #include "postgres.h"
> Urgh.. Would that mean keeping a local copy of SET_VARSIZE_4B_C and
> VARSIZE_4B if this hack is not used? Looking at the git history, I am
> seeing similar things in 2008 where pg_crc stuff was moved to src/port
> (5c9c08d).

Surely not. It seems like a much better idea to not have lzcompress deal
with varlena at all but pass that responsibility one layer upwards. That
shouldn't be very hard.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Move pg_lzcompress.c to src/common.
@ 2014-12-25 18:31  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Andres Freund <andres@2ndquadrant.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2014-12-25 18:31 UTC (permalink / raw)
  To: Andres Freund <andres@2ndquadrant.com>; +Cc: Michael Paquier <michael.paquier@gmail.com>; Fujii Masao <masao.fujii@gmail.com>; Fujii Masao <fujii@postgresql.org>; pgsql-committers

Andres Freund <andres@2ndquadrant.com> writes:
> On 2014-12-25 23:46:52 +0900, Michael Paquier wrote:
>> Urgh.. Would that mean keeping a local copy of SET_VARSIZE_4B_C and
>> VARSIZE_4B if this hack is not used? Looking at the git history, I am
>> seeing similar things in 2008 where pg_crc stuff was moved to src/port
>> (5c9c08d).

> Surely not. It seems like a much better idea to not have lzcompress deal
> with varlena at all but pass that responsibility one layer upwards. That
> shouldn't be very hard.

All files in src/common should be using the coding pattern

#ifndef FRONTEND
#include "postgres.h"
#else
#include "postgres_fe.h"
#endif

and as noted, it's going to take additional refactoring to make it
possible to do that in pg_lzcompress.  In view of all the potentially
unportable stuff Andres committed today, we need the buildfarm to be
at full strength; so I've reverted this commit until it can be worked
out a bit better.

			regards, tom lane


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Move pg_lzcompress.c to src/common.
@ 2014-12-25 23:40  Michael Paquier <michael.paquier@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Paquier @ 2014-12-25 23:40 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andres Freund <andres@2ndquadrant.com>; Fujii Masao <masao.fujii@gmail.com>; Fujii Masao <fujii@postgresql.org>; pgsql-committers

On Fri, Dec 26, 2014 at 3:31 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
>> Surely not. It seems like a much better idea to not have lzcompress deal
>> with varlena at all but pass that responsibility one layer upwards. That
>> shouldn't be very hard.
I'll figure out something.

> and as noted, it's going to take additional refactoring to make it
> possible to do that in pg_lzcompress.  In view of all the potentially
> unportable stuff Andres committed today, we need the buildfarm to be
> at full strength; so I've reverted this commit until it can be worked
> out a bit better.
Makes sense.
-- 
Michael


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Move pg_lzcompress.c to src/common.
@ 2015-02-09 06:16  Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 8+ messages in thread

From: Fujii Masao @ 2015-02-09 06:16 UTC (permalink / raw)
  To: pgsql-committers

Move pg_lzcompress.c to src/common.

The meta data of PGLZ symbolized by PGLZ_Header is removed, to make
the compression and decompression code independent on the backend-only
varlena facility. PGLZ_Header is being used to store some meta data
related to the data being compressed like the raw length of the uncompressed
record or some varlena-related data, making it unpluggable once PGLZ is
stored in src/common as it contains some backend-only code paths with
the management of varlena structures. The APIs of PGLZ are reworked
at the same time to do only compression and decompression of buffers
without the meta-data layer, simplifying its use for a more general usage.

On-disk format is preserved as well, so there is no incompatibility with
previous major versions of PostgreSQL for TOAST entries.

Exposing compression and decompression APIs of pglz makes possible its
use by extensions and contrib modules. Especially this commit is required
for upcoming WAL compression feature so that the WAL reader facility can
decompress the WAL data by using pglz_decompress.

Michael Paquier, reviewed by me.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/40bede5477bb5bce98ce9548841cb414634c26f7

Modified Files
--------------
src/backend/access/heap/tuptoaster.c  |   87 +++-
src/backend/utils/adt/Makefile        |    4 +-
src/backend/utils/adt/pg_lzcompress.c |  779 ---------------------------------
src/common/Makefile                   |    3 +-
src/common/pg_lzcompress.c            |  778 ++++++++++++++++++++++++++++++++
src/include/common/pg_lzcompress.h    |   91 ++++
src/include/utils/pg_lzcompress.h     |  112 -----
src/tools/msvc/Mkvcbuild.pm           |    3 +-
src/tools/pgindent/typedefs.list      |    1 -
9 files changed, 940 insertions(+), 918 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2015-02-09 06:16 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-12-25 11:47 pgsql: Move pg_lzcompress.c to src/common. Fujii Masao <fujii@postgresql.org>
2014-12-25 13:39 ` Fujii Masao <masao.fujii@gmail.com>
2014-12-25 13:43   ` Andres Freund <andres@2ndquadrant.com>
2014-12-25 14:46     ` Michael Paquier <michael.paquier@gmail.com>
2014-12-25 16:05       ` Andres Freund <andres@2ndquadrant.com>
2014-12-25 18:31         ` Tom Lane <tgl@sss.pgh.pa.us>
2014-12-25 23:40           ` Michael Paquier <michael.paquier@gmail.com>
2015-02-09 06:16 pgsql: Move pg_lzcompress.c to src/common. Fujii Masao <fujii@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox