mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-08 08:57:36 +08:00
When the elog functions (plpy.info etc.) get a single argument, just print
that argument instead of printing the single-member tuple like ('foo',).
38 lines
858 B
PL/PgSQL
38 lines
858 B
PL/PgSQL
-- first some tests of basic functionality
|
|
|
|
-- really stupid function just to get the module loaded
|
|
CREATE FUNCTION stupid() RETURNS text AS 'return "zarkon"' LANGUAGE plpythonu;
|
|
|
|
select stupid();
|
|
|
|
|
|
-- test multiple arguments
|
|
CREATE FUNCTION argument_test_one(u users, a1 text, a2 text) RETURNS text
|
|
AS
|
|
'keys = list(u.keys())
|
|
keys.sort()
|
|
out = []
|
|
for key in keys:
|
|
out.append("%s: %s" % (key, u[key]))
|
|
words = a1 + " " + a2 + " => {" + ", ".join(out) + "}"
|
|
return words'
|
|
LANGUAGE plpythonu;
|
|
|
|
select argument_test_one(users, fname, lname) from users where lname = 'doe' order by 1;
|
|
|
|
|
|
CREATE FUNCTION elog_test() RETURNS void
|
|
AS $$
|
|
plpy.debug('debug')
|
|
plpy.log('log')
|
|
plpy.info('info')
|
|
plpy.info(37)
|
|
plpy.info()
|
|
plpy.info('info', 37, [1, 2, 3])
|
|
plpy.notice('notice')
|
|
plpy.warning('warning')
|
|
plpy.error('error')
|
|
$$ LANGUAGE plpythonu;
|
|
|
|
SELECT elog_test();
|