[Please CC any replies, thanks]

I added a field to each of Var, Const, FuncExpr and OpExpr which is set
during parse_expr. But somewhere between the parsing and execution the
values of these fields get reset back to NULL. But only for FuncExpr
and OpExpr, for Var and Const it all works as expected.

I've traced with the debugger and confirmed that the field is set but
that it's copied somewhere before execution and that copy didn't copy
this field. The copyFuncExpr worked, it's just that another place did a
copy some other way.

grep reveals several places where new nodes are created but rather than
just changing them all, is there a particular phase where these changes
are made that I should be looking at?

Thanks in advance,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.

Search Discussions

  • Alvaro Herrera at Sep 6, 2005 at 5:02 pm

    On Tue, Sep 06, 2005 at 06:06:49PM +0200, Martijn van Oosterhout wrote:
    [Please CC any replies, thanks]

    I added a field to each of Var, Const, FuncExpr and OpExpr which is set
    during parse_expr. But somewhere between the parsing and execution the
    values of these fields get reset back to NULL. But only for FuncExpr
    and OpExpr, for Var and Const it all works as expected.
    Did you change the functions in src/backend/nodes/*funcs.c ? Nodes are
    copied using those. Any time you change the definition of the node, you
    need to change its equalfunc, copyfunc, outfunc, and readfunc, where
    applicable.

    --
    Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com
    "Pensar que el espectro que vemos es ilusorio no lo despoja de espanto,
    sólo le suma el nuevo terror de la locura" (Perelandra, CSLewis)
  • Tom Lane at Sep 6, 2005 at 5:51 pm

    Martijn van Oosterhout writes:
    grep reveals several places where new nodes are created but rather than
    just changing them all, is there a particular phase where these changes
    are made that I should be looking at?
    Grepping for "makeNode(OpExpr)" might help you. Offhand I'd finger
    eval_const_expressions as the likely culprit. clauses.c has some other
    code you'd better look at too.

    Personally, when I want to add a field to a node, I grep for every
    reference to one or two of the existing fields to make sure I've found
    all the places I need to touch.

    regards, tom lane
  • Martijn van Oosterhout at Sep 6, 2005 at 6:31 pm

    On Tue, Sep 06, 2005 at 01:51:25PM -0400, Tom Lane wrote:
    Grepping for "makeNode(OpExpr)" might help you. Offhand I'd finger
    eval_const_expressions as the likely culprit. clauses.c has some other
    code you'd better look at too.
    Yeah, eval_const_expressions was the culprit in this case, though I
    think operators might have some more.
    Personally, when I want to add a field to a node, I grep for every
    reference to one or two of the existing fields to make sure I've found
    all the places I need to touch.
    So there's no shortcut, I'll remember that :)

    Thanks for the help,
    --
    Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
    Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
    tool for doing 5% of the work and then sitting around waiting for someone
    else to do the other 95% so you can sue them.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedSep 6, '05 at 4:07p
activeSep 6, '05 at 6:31p
posts4
users3
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase