PQgetvalue alternative in SQL code? In in the PostgreSQL source code there is a function called PQgetvalue that returns a valid text representation of the value that can be used as a constant expression in SQL code. 

It essentially creates a literal for any value supported by PostgreSQL.

Is there any such function that is accessible from within the PostgreSQL DBMS itself? 

This is an example of what I want:

select PQgetvalue(1); -- 1

select PQgetvalue('cats' || ' dogs'); -- 'cats dogs'

select PQgetvalue('1990-01-01'); -- '1990-01-01'
PQgetvalue() is a client-side function that does not create anything, it just returns the value of a field inside a resultset.

The server-side equivalent, say select SomethingLikePQgetvalue('cats' || ' dogs')
would simply be select 'cats' || ' dogs'. Or if it isn't, please give an example showing when it would differ.

If the goal is to reinject the value as a literal into another SQL statement, then the SQL function quote_literal can be used.