Database Reference
In-Depth Information
name, or function name. It surrounds the name with double quotes and takes care of
properly escaping anything inside the string which would break the quoting:
hannu=# DO LANGUAGE plpythonu $$
plpy.notice(plpy.quote_ident(r'5" \"')) $$;
NOTICE: "5"" \"""
CONTEXT: PL/Python anonymous code block
DO
And yes, 5" \" is a legal table or field name in PostgreSQL; you just have to always
quote it if you use it in any statement.
Note
The DO syntax creates an anonymous block inside your database session. It is a
very handy way to run some procedural language code without needing to create
a function.
The other two functions are for quoting literal values. The function,
plpy.quote_literal(litvalue) , is for quoting strings and
plpy.quote_nullable(value_or_none) is for quoting a value, which may be
None . Both of these functions quote strings in a similar way, by enclosing them in
single quotes ( str becomes 'str' ) and doubling any single quotes or backslashes:
hannu=# DO LANGUAGE plpythonu $$
plpy.notice(plpy.quote_literal(r" \' "))
$$;
NOTICE: E' \\'' '
CONTEXT: PL/Python anonymous code block
DO
The only difference between these two is that plpy.quote_nullable() can also
take a value None , which will rendered as string NULL without any surrounding
quotes. The argument to both of these has to be a string or a unicode string. If you
Search WWH ::




Custom Search