X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A292B329F85 for ; Wed, 13 Oct 2004 16:07:18 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20090-03 for ; Wed, 13 Oct 2004 15:07:12 +0000 (GMT) Received: from poweredge.attiksystem.ch (adsl-soholight-4-c59-p029.vtx.ch [212.147.59.29]) by svr1.postgresql.org (Postfix) with ESMTP id ABFA2329F0C for ; Wed, 13 Oct 2004 16:07:07 +0100 (BST) Subject: Plperlu function & backticks return value -> truncated? MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Wed, 13 Oct 2004 17:07:05 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Message-ID: <6C0CF58A187DA5479245E0830AF84F42142C54@poweredge.attiksystem.ch> content-class: urn:content-classes:message X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Plperlu function & backticks return value -> truncated? Thread-Index: AcSxNkzrWb3cXSFBRaaiNHKWXamJRg== From: "Philippe Lang" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/90 X-Sequence-Number: 19193 Hello, I'm using the following show_users() function in order to retreive in postgresql the output from the unix "ps" command. When run directly from a shell, this code: $ps =3D `ps -afux | grep postgres`; @fields =3D split /\n/, $ps; return "{" . join(",", @fields) . "}"; ... runs fine. But when run inside a plperlu function, lines are being truncated after a certain width. Is that a known limitation of plperlu? Or maybe something else? Philippe ------------------------------------------------------------ -- TYPE: line_type ------------------------------------------------------------ CREATE TYPE public.line_type AS ( line text ); ------------------------------------------------------------ -- UTILITY FUNCTION: ps ------------------------------------------------------------ CREATE FUNCTION public.ps() RETURNS text[] AS ' $ps =3D `ps -afux | grep postgres`; @fields =3D split /\n/, $ps; return "{" . join(",", @fields) . "}"; ' LANGUAGE 'plperlu' VOLATILE; ------------------------------------------------------------ -- UTILITY FUNCTION: show_users ------------------------------------------------------------ CREATE FUNCTION public.show_users() RETURNS SETOF user_type AS ' DECLARE users text[]; user_rec line_type%ROWTYPE; i int2; BEGIN users =3D ps(); FOR i IN 1 .. array_upper(users, 1) LOOP user_rec.line =3D users[i]; RETURN NEXT user_rec; END LOOP; RETURN; END ' LANGUAGE 'plpgsql' VOLATILE; ------------------------------------------------------------ -- MAIN ------------------------------------------------------------ select * from show_users();