Re: pl/python quoting functions

Lists: pgsql-hackers
From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pl/python quoting functions
Date: 2011-01-10 21:48:56
Message-ID: 4D2B7EC8.4020500@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Here's a patch that adds a few PL/Python functions for quoting strings.
It's an incremental patch on top of the plpython-refactor patch sent in
http://archives.postgresql.org/message-id/4D135170.3080705@wulczer.org.

Git branch for this patch:
https://github.com/wulczer/postgres/tree/functions

The new functions are plpy.quote_literal, plpy.quote_nullable and
plpy.quote_ident, and work just like their sql or plperl equivalents.

Cheers,
Jan

Attachment Content-Type Size
plpython-functions.diff text/x-patch 8.4 KB

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Jan Urbański <wulczer(at)wulczer(dot)org>
Cc: Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pl/python quoting functions
Date: 2011-02-04 17:10:21
Message-ID: AANLkTi=8LX2-=8jD3wpbMTD_=Q-U-0nG3B9Hj8_L2awC@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2011/1/11 Jan Urbański <wulczer(at)wulczer(dot)org>:
> Here's a patch that adds a few PL/Python functions for quoting strings.
> It's an incremental patch on top of the plpython-refactor patch sent in
> http://archives.postgresql.org/message-id/4D135170.3080705@wulczer.org.
>
> Git branch for this patch:
> https://github.com/wulczer/postgres/tree/functions
>
> The new functions are plpy.quote_literal, plpy.quote_nullable and
> plpy.quote_ident, and work just like their sql or plperl equivalents.
>

I reviewed this.

The patch applies and compiles cleanly and all the tests are passed.
The patch adds 3 functions which works as the corresponding SQL
functions. The test is enough, without any additional docs. No
feature/performance issues found.

I mark this "Reader for Committer".

Regards,

--
Hitoshi Harada


From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
Cc: Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pl/python quoting functions
Date: 2011-02-06 09:54:19
Message-ID: 4D4E6FCB.3030304@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 04/02/11 18:10, Hitoshi Harada wrote:
> 2011/1/11 Jan Urbański <wulczer(at)wulczer(dot)org>:
>> Here's a patch that adds a few PL/Python functions for quoting strings.
>> It's an incremental patch on top of the plpython-refactor patch sent in
>> http://archives.postgresql.org/message-id/4D135170.3080705@wulczer.org.
>>
>> Git branch for this patch:
>> https://github.com/wulczer/postgres/tree/functions
>>
>> The new functions are plpy.quote_literal, plpy.quote_nullable and
>> plpy.quote_ident, and work just like their sql or plperl equivalents.
>>
>
> I reviewed this.
>
> The patch applies and compiles cleanly and all the tests are passed.
> The patch adds 3 functions which works as the corresponding SQL
> functions. The test is enough, without any additional docs. No
> feature/performance issues found.
>
> I mark this "Reader for Committer".

Thanks!

I guess a short paragraph in the Utility Functions section of the
PL/Python docs would be in order, I'll try to add it today.

Jan


From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
Cc: Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pl/python quoting functions
Date: 2011-02-06 19:11:08
Message-ID: 4D4EF24C.4010209@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 06/02/11 10:54, Jan Urbański wrote:
> On 04/02/11 18:10, Hitoshi Harada wrote:
>> 2011/1/11 Jan Urbański <wulczer(at)wulczer(dot)org>:
>>> Here's a patch that adds a few PL/Python functions for quoting strings.
>>> It's an incremental patch on top of the plpython-refactor patch sent in
>>> http://archives.postgresql.org/message-id/4D135170.3080705@wulczer.org.
>>>
>>> Git branch for this patch:
>>> https://github.com/wulczer/postgres/tree/functions
>>>
>>> The new functions are plpy.quote_literal, plpy.quote_nullable and
>>> plpy.quote_ident, and work just like their sql or plperl equivalents.
>>>
>>
>> I reviewed this.
>>
>> The patch applies and compiles cleanly and all the tests are passed.
>> The patch adds 3 functions which works as the corresponding SQL
>> functions. The test is enough, without any additional docs. No
>> feature/performance issues found.
>>
>> I mark this "Reader for Committer".
>
> Thanks!
>
> I guess a short paragraph in the Utility Functions section of the
> PL/Python docs would be in order, I'll try to add it today.

Added docs and merged with master.

Attachment Content-Type Size
plpython-functions.diff text/x-patch 9.6 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Jan Urbański <wulczer(at)wulczer(dot)org>
Cc: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>, Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pl/python quoting functions
Date: 2011-02-22 21:48:19
Message-ID: 1298411300.334.6.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Committed this, with two changes: Changed some things around with the
way const char * is propagated. Just casting it away is not nice. Also
dropped the error tests in the _quote.sql regression test. This
generates three different wordings of error messages from Python with
2.6, 3.1, and 3.2, which I don't care to maintain. Maybe one day we'll
have a better solution for this.


From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>, Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pl/python quoting functions
Date: 2011-02-23 10:26:50
Message-ID: 4D64E0EA.5080604@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 22/02/11 22:48, Peter Eisentraut wrote:
> Committed this, with two changes: Changed some things around with the
> way const char * is propagated. Just casting it away is not nice. Also
> dropped the error tests in the _quote.sql regression test. This
> generates three different wordings of error messages from Python with
> 2.6, 3.1, and 3.2, which I don't care to maintain. Maybe one day we'll
> have a better solution for this.

Thanks.

One thing: you removed the conditional pfree from PLy_quote_ident, which
makes this function leak memory if the actual quoting took place, no? Is
that leak too small to worry about?

Cheers,
Jan


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Jan Urbański <wulczer(at)wulczer(dot)org>
Cc: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>, Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pl/python quoting functions
Date: 2011-02-23 15:44:01
Message-ID: 1298475841.27343.1.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On ons, 2011-02-23 at 11:26 +0100, Jan Urbański wrote:
> One thing: you removed the conditional pfree from PLy_quote_ident,
> which makes this function leak memory if the actual quoting took
> place, no? Is that leak too small to worry about?

Many functions in PostgreSQL leak memory in this way. It's not worth
worrying about, and certainly not worth violating a called function's
API for it.