Ident nodetype considered harmful - Mailing list pgsql-hackers

From Tom Lane
Subject Ident nodetype considered harmful
Date
Msg-id 16423.1029720422@sss.pgh.pa.us
Whole thread Raw
List pgsql-hackers
I've just noticed that a bunch of places use strVal() to access the name
field of an Ident node.  (Try changing strVal() to

#define strVal(v)        (AssertMacro(IsA(v, String)), ((Value *)(v))->val.str)

and watch the fur fly...)

This works, at the moment, because Ident and Value nodes have a similar
layout.  But it sure looks like trouble waiting to happen.

As far as I can tell, there's no really good reason to keep Ident around
at all.  The only thing it's still used for is lists of column names in
a couple of statement types --- which is something that we do elsewhere
with lists of String nodes.  Indeed I imagine that the buggy places got
that way because someone copied-and-pasted code that was legitimately
dealing with a list of column names in String form.

Also, strVal() and makeString() provide handy notational infrastructure
that we don't have for Ident.

Considering these points, I'd rather rip out Ident and replace its uses
with String nodes than try to clean up the misuses of strVal().  Any
objections out there?
        regards, tom lane


pgsql-hackers by date:

Previous
From: ngpg@grymmjack.com
Date:
Subject: Re: Open 7.3 items
Next
From: "Christopher Kings-Lynne"
Date:
Subject: Re: About to update the PostgreSQL Functions in the official PHP Manual