Re: Problem reloading regression database

From: Brent Verner <brent(at)rcfile(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Problem reloading regression database
Date: 2002-01-15 02:30:38
Message-ID: 20020115023038.GA9619@rcfile.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

[2002-01-14 00:41] Tom Lane said:
| Brent Verner <brent(at)rcfile(dot)org> writes:
| > | You'll need to make sure that the code isn't expecting to palloc
| > | anything first-time-through and re-use it on later loops, but I
| > | think that will be okay. (The attribute_buf is the most obvious
| > | risk, but that's all right, see stringinfo.c.)
|
| > So I /can't/ palloc some things /before/ switching context to
| > per-tuple-context?
|
| Oh, sure you can. That's the point of having a per-query context.
| What I was wondering was whether there were any pallocs executed
| *after* entering the loop that the code expected to live across
| loop cycles. I don't think so, I'm just mentioning the risk as
| part of your education ;-)

gotcha. No, I don't think anything inside that loop expects to
persist across iterations. The attribute_buf is static to the
file, and initialized in DoCopy.

What I ended up doing is switching to per-tuple-context prior to
the input loop, then switching back to the (saved) query-context
after exiting the loop. I followed ResetTupleExprContext back, and
it doesn't seem to do anything that would require a switch per loop.
Are there any problems this might cause that I'm not seeing with
my test case?

Memory use is now under control, and things look good (stable around
2.8M).

sleepy:/usr/local/pg-7.2/bin
brent$ ./psql -c '\d yyy'
Table "yyy"
Column | Type | Modifiers
--------+---------+------------------------------------------------
id | integer | not null default nextval('"yyy_id_seq"'::text)
a | integer | not null default 1
b | text | not null default 'test'
c | integer |
Unique keys: yyy_id_key

sleepy:/usr/local/pg-7.2/bin
brent$ wc -l mmm
3200386 mmm
sleepy:/usr/local/pg-7.2/bin
brent$ head -10 mmm
\N
\N
\N
20
10
20
20
40
50
20
sleepy:/usr/local/pg-7.2/bin
brent$ ./psql -c 'copy yyy(c) from stdin' < mmm
sleepy:/usr/local/pg-7.2/bin

thanks.
brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing." -- Duane Allman

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lincoln Yeoh 2002-01-15 02:44:04 Re: bug in permission handling?
Previous Message Hiroshi Inoue 2002-01-15 02:23:44 Re: Theory about XLogFlush startup failures