Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a6Ll2-0005hj-7S for pgadmin-hackers@arkaria.postgresql.org; Tue, 08 Dec 2015 17:08:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a6Ll1-0007S9-GE for pgadmin-hackers@arkaria.postgresql.org; Tue, 08 Dec 2015 17:08:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a6KAo-0000F5-Fi for pgadmin-hackers@postgresql.org; Tue, 08 Dec 2015 15:27:26 +0000 Received: from imp-m.ru ([93.174.79.86]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1a6KAk-0007cx-MK for pgadmin-hackers@postgresql.org; Tue, 08 Dec 2015 15:27:24 +0000 Received: by imp-m.ru (Postfix, from userid 80) id CCC6473F489A; Tue, 8 Dec 2015 18:27:21 +0300 (MSK) To: pgadmin-hackers@postgresql.org Subject: Re: patch: fix to use =?UTF-8?Q?=60=60pg=5Fget=5Ffunctiondef=28?= =?UTF-8?Q?=29=60=60?= X-PHP-Originating-Script: 0:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 08 Dec 2015 18:27:21 +0300 From: Andrej Antonov In-Reply-To: <8214ef66e4cf3dc04bd99a0af601e5ab@imp-m.ru> References: <8214ef66e4cf3dc04bd99a0af601e5ab@imp-m.ru> Message-ID: <4c8aebe7570a546854c71de8ed0e6ba0@imp-m.ru> X-Sender: antonov@imp-m.ru User-Agent: Roundcube Webmail/1.0.3 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org |||||||||||||||||||| COMMENT-1 ON GITHUB [BEGIN] |||||||||||||||||||| <<< Dmitriy olshevskiy87@bk.ru >>> BTW > pg_get_functiondef() -- less wrong what's wrong with this function? :) |||||||||||||||||||| COMMENT-2 ON GITHUB [BEGIN] |||||||||||||||||||| ok. a few examples: example "A" =========== write function: CREATE FUNCTION test123() RETURNS TABLE(my_col text) LANGUAGE plpgsql AS $xxx$ BEGIN my_col := 'abc'; RETURN NEXT; my_col := 'def'; RETURN NEXT; END; $xxx$; --SELECT * FROM test123(); pgAdmin3 transforming it to function: -- Function: test123() -- DROP FUNCTION test123(); CREATE OR REPLACE FUNCTION test123() RETURNS SETOF text AS $BODY$ BEGIN my_col := 'abc'; RETURN NEXT; my_col := 'def'; RETURN NEXT; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100 ROWS 1000; ALTER FUNCTION test123() OWNER TO postgres; and of course with error: ERROR: "my_col" is not a known variable LINE 10: my_col := 'abc'; ^ ********** Error ********** ERROR: "my_col" is not a known variable SQL state: 42601 Character: 129 example "B" =========== CREATE FUNCTION test234(arr text[] DEFAULT ARRAY['sss', 'ddd']) RETURNS SETOF text LANGUAGE plpgsql AS $xxx$ DECLARE r record; BEGIN FOR r IN SELECT UNNEST(arr) LOOP RETURN NEXT r.unnest; END LOOP; END; $xxx$; --SELECT * FROM test234(); pgAdmin3 transforming it to function: -- Function: test234(text[]) -- DROP FUNCTION test234(text[]); CREATE OR REPLACE FUNCTION test234(arr text[] DEFAULT ARRAY['sss'::text) RETURNS SETOF text AS $BODY$ DECLARE r record; BEGIN FOR r IN SELECT UNNEST(arr) LOOP RETURN NEXT r.unnest; END LOOP; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100 ROWS 1000; ALTER FUNCTION test234(text[]) OWNER TO postgres; ...with error: ERROR: syntax error at or near ")" LINE 5: ...PLACE FUNCTION test234(arr text[] DEFAULT ARRAY['sss'::text) ^ ********** Error ********** ERROR: syntax error at or near ")" SQL state: 42601 Character: 137 other minor discomfort ====================== words -- ``VOLATILE``, ``COST 100``, ``ROWS 1000`` -- are extra (unnecessary, redundant). |||||||||||||||||||| COMMENT-3 ON GITHUB [BEGIN] |||||||||||||||||||| but this sql code was generated by pgadmin, isn't it? I thought you are talking about native postgres function pg_get_functiondef() ) |||||||||||||||||||| COMMENT-4 ON GITHUB [BEGIN] |||||||||||||||||||| > but this sql code was generated by pgadmin, isn't it? > I thought you are talking about native postgres function > pg_get_functiondef() sorry for my ambiguity message.. yes. my examples -- about pgadmin-generation (without ``pg_get_functiondef()`` ) I wanted to say: I do not know about bad sides of ``pg_get_functiondef()`` , but if they exists -- I think them less then bad sides of original-pgadmin-generation . |||||||||||||||||||| END OF COMMENTS ON GITHUB |||||||||||||||||||| Andrej Antonov писал 2015-12-08 11:50: > patch: fix to use ``pg_get_functiondef()`` [see attachment file] > > it is copy of pull-request https://github.com/postgres/pgadmin3/pull/12 > > thank you! -- Андрей Антонов, инженер-программист отдела информационных технологий и программирования, компания «Импульс М» -- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers