Обсуждение: Ident nodetype considered harmful

Поиск
Список
Период
Сортировка

Ident nodetype considered harmful

От
Tom Lane
Дата:
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