Thread: postgresql-7.2b3-betterquote.patch

postgresql-7.2b3-betterquote.patch

From
Elliot Lee
Date:
This patch to the python bindings adds C versions of the often-used query
args quoting routines, as well as support for quoting lists e.g.
dbc.execute("SELECT * FROM foo WHERE blah IN %s", ([1,2,3],))

Please consider incorporating this patch into postgresql 7.2,
-- Elliot

Attachment

Re: postgresql-7.2b3-betterquote.patch

From
Tom Lane
Date:
Elliot Lee <sopwith@redhat.com> writes:
> This patch to the python bindings adds C versions of the often-used query
> args quoting routines, as well as support for quoting lists e.g.
> dbc.execute("SELECT * FROM foo WHERE blah IN %s", ([1,2,3],))

> Please consider incorporating this patch into postgresql 7.2,

Sorry, it's far too late for feature additions to 7.2.  We can hold
onto this for 7.3, though.

Documentation additions to go with the code additions would be a useful
thing to work on in the meantime ;-)

            regards, tom lane

Re: postgresql-7.2b3-betterquote.patch

From
Bruce Momjian
Date:
Saved for 7.3:

    http://candle.pha.pa.us/cgi-bin/pgpatches2


---------------------------------------------------------------------------

Elliot Lee wrote:
> This patch to the python bindings adds C versions of the often-used query
> args quoting routines, as well as support for quoting lists e.g.
> dbc.execute("SELECT * FROM foo WHERE blah IN %s", ([1,2,3],))
>
> Please consider incorporating this patch into postgresql 7.2,
> -- Elliot

Content-Description:

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: postgresql-7.2b3-betterquote.patch

From
Elliot Lee
Date:
On Thu, 17 Jan 2002, Tom Lane wrote:

> Elliot Lee <sopwith@redhat.com> writes:
> > This patch to the python bindings adds C versions of the often-used query
> > args quoting routines, as well as support for quoting lists e.g.
> > dbc.execute("SELECT * FROM foo WHERE blah IN %s", ([1,2,3],))
>
> > Please consider incorporating this patch into postgresql 7.2,
>
> Sorry, it's far too late for feature additions to 7.2.  We can hold
> onto this for 7.3, though.
>
> Documentation additions to go with the code additions would be a useful
> thing to work on in the meantime ;-)

It's not a new feature, so there's no documentation to give - it's all
making the existing API behave as expected...

The C versions are more likely to contain bugs, but even they are not new
features (go look at the profile on any DB-intensive app and then tell me
that _quote being slow is not a bug :)

-- Elliot




Re: postgresql-7.2b3-betterquote.patch

From
Bruce Momjian
Date:
Patch applied.  Thanks.

---------------------------------------------------------------------------


Elliot Lee wrote:
> This patch to the python bindings adds C versions of the often-used query
> args quoting routines, as well as support for quoting lists e.g.
> dbc.execute("SELECT * FROM foo WHERE blah IN %s", ([1,2,3],))
>
> Please consider incorporating this patch into postgresql 7.2,
> -- Elliot

Content-Description:

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: postgresql-7.2b3-betterquote.patch

From
Bruce Momjian
Date:
I am getting a Python compile error with this patch attached on the
function call PySequence_Size():

    gcc -O2 -pipe -m486 -Wall -Wmissing-prototypes -Wmissing-declarations -O0 -Wall -Wmissing-prototypes
-Wmissing-declarations-Wpointer-arith -Wcast-align -fpic -I../../../src/interfaces/libpq -I../../../src/include
-I/usr/local/include/readline-I/usr/contrib/include -I/usr/contrib/include/python1.5  -c -o pgmodule.o pgmodule.c 
    pgmodule.c: In function `pgpy_quote_fast':
    pgmodule.c:3166: warning: implicit declaration of function `PySequence_Size'
    pgmodule.c:3191: warning: passing arg 2 of `PyTuple_SetItem' makes integer from pointer without a cast
    pgmodule.c:3191: too few arguments to function `PyTuple_SetItem'
    pgmodule.c:3194: warning: implicit declaration of function `_PyString_Join'
    pgmodule.c:3194: warning: assignment makes pointer from integer without a cast
    pgmodule.c:3197: warning: implicit declaration of function `PyString_FromFormat'
    pgmodule.c:3197: warning: assignment makes pointer from integer without a cast
    pgmodule.c: In function `pgpy_quoteparams_fast':
    pgmodule.c:3224: warning: passing arg 1 of `PyArg_ParseTuple' from incompatible pointer type
    pgmodule.c:3224: warning: passing arg 2 of `PyArg_ParseTuple' from incompatible pointer type
    gmake: *** [pgmodule.o] Error 1

I am backing out this patch.  Please resubmit with this corrected.  Thanks.

I am running Python 1.5.

---------------------------------------------------------------------------

pgman wrote:
>
> Patch applied.  Thanks.
>
> ---------------------------------------------------------------------------
>
>
> Elliot Lee wrote:
> > This patch to the python bindings adds C versions of the often-used query
> > args quoting routines, as well as support for quoting lists e.g.
> > dbc.execute("SELECT * FROM foo WHERE blah IN %s", ([1,2,3],))
> >
> > Please consider incorporating this patch into postgresql 7.2,
> > -- Elliot
>
> Content-Description:
>
> [ Attachment, skipping... ]
>
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: postgresql-7.2b3-betterquote.patch

From
Elliot Lee
Date:
On Mon, 4 Mar 2002, Bruce Momjian wrote:

> I am backing out this patch.  Please resubmit with this corrected.  Thanks.
>
> I am running Python 1.5.

Therein lies the problem... :)

Since it appears you have the requirement of supporting old python
versions, attached is just the pgdb.py part of the patch (with a fix for
DateTime handling). It has the same functionality but certainly won't be
quite as fast. Given the absence of _PyString_Join in python1.5, it's a
pain to get the C variants working for all versions. The pgdb.py patch
does leaves the hooks in, should someone wish to do the optimization at a
later point.

Hope this helps,
-- Elliot
Ever stop to think, and forget to start again?

Attachment

Re: postgresql-7.2b3-betterquote.patch

From
Bruce Momjian
Date:
Seems we still need to support Python 1.5.

Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Elliot Lee wrote:
> On Mon, 4 Mar 2002, Bruce Momjian wrote:
>
> > I am backing out this patch.  Please resubmit with this corrected.  Thanks.
> >
> > I am running Python 1.5.
>
> Therein lies the problem... :)
>
> Since it appears you have the requirement of supporting old python
> versions, attached is just the pgdb.py part of the patch (with a fix for
> DateTime handling). It has the same functionality but certainly won't be
> quite as fast. Given the absence of _PyString_Join in python1.5, it's a
> pain to get the C variants working for all versions. The pgdb.py patch
> does leaves the hooks in, should someone wish to do the optimization at a
> later point.
>
> Hope this helps,
> -- Elliot
> Ever stop to think, and forget to start again?

Content-Description:

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: postgresql-7.2b3-betterquote.patch

From
Bruce Momjian
Date:
Patch applied.  Thanks.

---------------------------------------------------------------------------


Elliot Lee wrote:
> On Mon, 4 Mar 2002, Bruce Momjian wrote:
>
> > I am backing out this patch.  Please resubmit with this corrected.  Thanks.
> >
> > I am running Python 1.5.
>
> Therein lies the problem... :)
>
> Since it appears you have the requirement of supporting old python
> versions, attached is just the pgdb.py part of the patch (with a fix for
> DateTime handling). It has the same functionality but certainly won't be
> quite as fast. Given the absence of _PyString_Join in python1.5, it's a
> pain to get the C variants working for all versions. The pgdb.py patch
> does leaves the hooks in, should someone wish to do the optimization at a
> later point.
>
> Hope this helps,
> -- Elliot
> Ever stop to think, and forget to start again?

Content-Description:

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026