pgsql-server/src/interfaces/libpq fe-exec.c - Mailing list pgsql-committers

From momjian@svr1.postgresql.org (Bruce Momjian)
Subject pgsql-server/src/interfaces/libpq fe-exec.c
Date
Msg-id 20030612011719.6796730DC44@svr1.postgresql.org
Whole thread Raw
List pgsql-committers
CVSROOT:    /cvsroot
Module name:    pgsql-server
Changes by:    momjian@svr1.postgresql.org    03/06/11 22:17:19

Modified files:
    src/interfaces/libpq: fe-exec.c

Log message:
    I found the libpq function PGunescapeBytea a little slow. It was taking a
    minute and a half to decode a 500Kb on a fairly fast machine. I think the
    culprit is sscanf.

    I attach a patch that replaces the function with one used to perform the same
    task in pyPgSQL (a Python interface to PostgreSQL). This code was written by
    Billy Allie, author of pyPgSQL. I've changed a few variable names to match
    those in the original code and removed a bit of Pythonness.

    Billy has kindly looked at the code and points out that it is slightly
    stricter than the original implementation and if it encounters an invalid
    bytea such as '\12C' it drops the unescape '\' and outputs '12C'.

    The code is licensed by the author under a BSD license.

    I've performed limited testing of the function by putting JPEGs into
    PostgreSQL, extracting them using them using the new function and diffing
    against the original files.

    The new function is significantly faster on my machine with the JPEGs being
    decoded in less than a second. I attach a modified libpq example program that
    I used for my testing.

    Ben Lamb.


pgsql-committers by date:

Previous
From: momjian@svr1.postgresql.org (Bruce Momjian)
Date:
Subject: pgsql-server/src backend/access/transam/Makefi ...
Next
From: momjian@svr1.postgresql.org (Bruce Momjian)
Date:
Subject: pgsql-server/contrib/pg_autovacuum README.pg_a ...