Alvaro Herrera <alvherre@commandprompt.com> writes:
> Is this really all that hard? I'm thinking it could be implemented by
> using the real C sprintf underneath, passing one % specifier and its
> corresponding parameter at a time, coerced to whatever the conversion
> specifier specifies.
The only disadvantage I can see of that is that it would lose precision
for NUMERIC. I'd really like to be able to write "%300.100f" and have it
Do The Right Thing with a 300-digit numeric input.
> The only thing that breaks this idea is the $n positional specifiers, I
> think.
Yeah, that's a bit of a pain too. But we have the logic for that in
src/port/. It wouldn't be that much work to repurpose it. Actually,
since a SQL implementation wouldn't be constrained to read the actual
arguments left-to-right, you could probably simplify it a great deal.
regards, tom lane