Hi hackers,

I note that if you pass NULL to quote_literal(), you get NULL.

This isn't surprising, but I was thinking that the stated purpose of
quote_literal is preparing the argument for entry into a dynamic SQL
statement.  In this context, it fails for NULL input.

Wouldn't it be more useful if quote_literal(NULL) yielded the text value 'NULL'?

With the current behaviour, if you want quote_literal to be "null
safe" you have to replace any such calls with
coalesce(quote_literal(foo), 'NULL')).  Since the use case for
quote_literal is concatenating the result with some other text, a NULL
return seems guaranteed to be unhelpful.

Meanwhile, the string 'NULL' is the only way of representing a NULL in
SQL, so it makes sense (to me) that this is what quote_literal should



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not

Reply via email to