Re: RfD: more powerful "any" types - Mailing list pgsql-hackers

From daveg
Subject Re: RfD: more powerful "any" types
Date
Msg-id 20090912224522.GB25379@sonic.net
Whole thread Raw
In response to Re: RfD: more powerful "any" types  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-hackers
On Fri, Sep 11, 2009 at 11:43:32AM -0400, Merlin Moncure wrote:
> 
> If you are going to use printf format codes, which is good and useful
> being something of a standard, I'd call routine printf (not format)
> and actually wrap vsnprintf.  The format codes in printf have a very
> specific meaning: converting native C types to arrays of characters.
> I think that a postgresql implementation should do exactly that:
> attempt to convert the passed in datum to the c type in question if
> possible (erroring if no cast exists) and then pass it down.  The idea
> is we are not adding new formatting routines but using a very high
> quality existing one...why reinvent the wheel?
> 
> so if you did: select printf('%s %3.1f', foo::box, bar::circle);
> the box to char* cast would work (using the text cast) but the second
> cast would fail unless the user added a cast to float.  The code in
> question is easy to imagine...parse the format string, and loop the
> varargs using the appropriate looked up cast one by one...

+1

-dg 

-- 
David Gould       daveg@sonic.net      510 536 1443    510 282 0869
If simplicity worked, the world would be overrun with insects.


pgsql-hackers by date:

Previous
From: decibel
Date:
Subject: Re: RfD: more powerful "any" types
Next
From: Andrew Dunstan
Date:
Subject: Re: RfD: more powerful "any" types