Thread: BUG #5302: WIN1252 encoding causes server memory leak

BUG #5302: WIN1252 encoding causes server memory leak

From
"Florian Nigsch"
Date:
The following bug has been logged online:

Bug reference:      5302
Logged by:          Florian Nigsch
Email address:      contact@flo.nigsch.com
PostgreSQL version: 8.4.2
Operating system:   x86_64 GNU/Linux 2.6.18-92.el5
Description:        WIN1252 encoding causes server memory leak
Details:

The following rapidly consumes server memory:

-- Causes leak:
SET client_encoding TO 'WIN1252';

BEGIN;
CREATE TEMP TABLE t1(pk INT PRIMARY KEY);

-- Repeat 1000 times
DECLARE mycur CURSOR WITH HOLD FOR SELECT * FROM t1;
FETCH 100 IN mycur;
SAVEPOINT mysp;
CLOSE mycur;
RELEASE mysp;
-- End repeat

COMMIT:


Tested on 8.4.0 and 8.4.2.   The above code is analogous to that produced by
the PSQLODBC driver.

The leak does not occur without the WIN1252 encoding setting.

http://pgfoundry.org/tracker/index.php?func=detail&aid=1010758&group_id=1000
125&atid=538

Re: BUG #5302: WIN1252 encoding causes server memory leak

From
Tom Lane
Date:
"Florian Nigsch" <contact@flo.nigsch.com> writes:
> Description:        WIN1252 encoding causes server memory leak

Hmm, what server-side encoding and locale are you using?

            regards, tom lane

Re: BUG #5302: WIN1252 encoding causes server memory leak

From
Florian Nigsch
Date:
Output of 'psql -l':

The 8.4.0 server:

                                   List of databases
    Name    |  Owner   | Encoding |  Collation  |    Ctype    |
Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
  ********  | ******** | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
  postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
  template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                              :
postgres=CTc/postgres
  template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                              :
postgres=CTc/postgres

psql client used on the 8.4.0 server:
~$ psql --version
psql (PostgreSQL) 8.4.0

And the 8.4.2 server:

                                 List of databases
    Name    |  Owner   | Encoding | Collation |   Ctype    |   Access
privileges
-----------+----------+----------+-----------+------------+-----------------------
  ********  | ******** | UTF8     | C         | en_US.utf8 |
  postgres  | postgres | UTF8     | C         | en_US.utf8 |
  template0 | postgres | UTF8     | C         | en_US.utf8 | =c/postgres
                                                           :
postgres=CTc/postgres
  template1 | postgres | UTF8     | C         | en_US.utf8 |
postgres=CTc/postgres
                                                           : =c/postgres

psql client used on the 8.4.2 server:
~$ psql --version
psql (PostgreSQL) 8.4.2


Cheers,

Flo

Quoting Tom Lane <tgl@sss.pgh.pa.us>:

> "Florian Nigsch" <contact@flo.nigsch.com> writes:
>> Description:        WIN1252 encoding causes server memory leak
>
> Hmm, what server-side encoding and locale are you using?
>
>             regards, tom lane
>

Re: BUG #5302: WIN1252 encoding causes server memory leak

From
Tom Lane
Date:
"Florian Nigsch" <contact@flo.nigsch.com> writes:
> The following rapidly consumes server memory:

> -- Causes leak:
> SET client_encoding TO 'WIN1252';

> BEGIN;
> CREATE TEMP TABLE t1(pk INT PRIMARY KEY);

> -- Repeat 1000 times
> DECLARE mycur CURSOR WITH HOLD FOR SELECT * FROM t1;
> FETCH 100 IN mycur;
> SAVEPOINT mysp;
> CLOSE mycur;
> RELEASE mysp;
> -- End repeat

I've applied a patch for this, but I have to say that using a SAVEPOINT
around a CLOSE is an awfully expensive use of a savepoint.  You might
want to nag the psqlodbc people to see if they can't avoid that.

            regards, tom lane