Re: Problem reloading regression database - Mailing list pgsql-hackers

From Brent Verner
Subject Re: Problem reloading regression database
Date
Msg-id 20020114023923.GA2972@rcfile.org
Whole thread Raw
In response to Re: Problem reloading regression database  (Brent Verner <brent@rcfile.org>)
Responses Re: Problem reloading regression database  (Brent Verner <brent@rcfile.org>)
List pgsql-hackers
[2002-01-13 16:42] Brent Verner said:
| [2002-01-13 15:17] Tom Lane said:
| | Brent Verner <brent@rcfile.org> writes:
| | > I fixed this by making an int* mapping from specified collist
| | > position to actual rd_att->attrs position.
| |
| | Sounds better.
| |
| | > I'm still a bit^W^W lost as hell on how the column default magic
| | > happens.
| |
| | I'd say use build_column_default() in src/backend/optimizer/prep/preptlist.c
| | to set up a default expression (possibly just NULL) for every column
| | that's not supplied by the input.  That routine's not exported now, but
| | it could be, or perhaps it should be moved somewhere else.  (Suggestions
| | anyone?  Someplace in src/backend/catalog might be a more appropriate
| | place for it.)
|
| gotcha.
|
| | Then in the per-tuple loop you use ExecEvalExpr, or more likely
| | ExecEvalExprSwitchContext, to execute the default expressions.
| | The econtext wanted by ExecEvalExpr can be had from the estate
| | that CopyFrom already creates; use GetPerTupleExprContext(estate).
|
| many, many thanks!
|
| | You'll need to verify that you have got the memory context business
| | right, ie, no memory leak across rows.  I think the above sketch is
| | sufficient, but check it with a memory-eating default expression
| | evaluated for a few million input rows ...
|
| Yes, the above info should get me through.

round two...

  1) I (kludgily) exported build_column_default() from its current
     location.
  2) defaults expressions are now tried if a column is not in the
     COPY attlist specification.

There are still some kinks... (probably more than I've thought of)
  1) a column in attlist that is not in the table will cause a segv
     in the backend.
  2) duplicate names in attlist are still not treated as an error.

I believe the memory context issues are handled correctly, but I've
not run the few million copy tests yet, and I probably won't be able
to until late(r) tomorrow.  No strangeness running compiled with
--enable-cassert.  Regression tests still pass.

Sanity checks much appreciated.

cheers.
  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

Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Release time
Next
From: Tom Lane
Date:
Subject: Re: Release time