Обсуждение: patch: fix to use ``pg_get_functiondef()``
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! -- Андрей Антонов, инженер-программист отдела информационных технологий и программирования, компания «Импульс М»
Вложения
|||||||||||||||||||| 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! -- Андрей Антонов, инженер-программист отдела информационных технологий и программирования, компания «Импульс М»
Hi, Andrej!
Here is small fix of your patch - can you check it please?
I think there must be wxwidgets function IsEmpty() instead of double negation,
because type of the variable is wxstring. Also I added the Trim() function before
check if function definition is empty or not.
Here is small fix of your patch - can you check it please?
I think there must be wxwidgets function IsEmpty() instead of double negation,
because type of the variable is wxstring. Also I added the Trim() function before
check if function definition is empty or not.
On 08.12.2015 11:50, Andrej Antonov wrote:
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!
-- Dmitriy Olshevskiy
Вложения
thank you, Dmitriy. I agree -- this-fix should works better. I applyed this-fix to my local-git-branches ("REL-1_20_0-impulsm" and "fix-to-use-pg_get_functiondef"). works good. Dmitriy Olshevskiy писал 2015-12-13 18:04: > Hi, Andrej! > Here is small fix of your patch - can you check it please? > I think there must be wxwidgets function IsEmpty() instead of double > negation, > because type of the variable is wxstring. Also I added the Trim() > function before > check if function definition is empty or not. > > On 08.12.2015 11:50, Andrej Antonov wrote: > >> patch: fix to use ``pg_get_functiondef()`` [see attachment file] >> >> it is copy of pull-request >> https://github.com/postgres/pgadmin3/pull/12 [1] >> >> thank you! > > -- > Dmitriy Olshevskiy > > > Links: > ------ > [1] https://github.com/postgres/pgadmin3/pull/12 -- Андрей Антонов, инженер-программист отдела информационных технологий и программирования, компания «Импульс М»
small fix ( diff see here: https://github.com/postgres-impulsm/pgadmin3/commit/72f381aa1964d5630f3ada44768bc562911102e9 ) if we using ``pg_get_functiondef(func_oid)`` -- in this case -- no need to write additional ``ALTER FUNCTION ... = ... ;``. Andrej Antonov писал 2015-12-14 10:51: > thank you, Dmitriy. I agree -- this-fix should works better. > > I applyed this-fix to my local-git-branches ("REL-1_20_0-impulsm" and > "fix-to-use-pg_get_functiondef"). works good. > > Dmitriy Olshevskiy писал 2015-12-13 18:04: >> Hi, Andrej! >> Here is small fix of your patch - can you check it please? >> I think there must be wxwidgets function IsEmpty() instead of double >> negation, >> because type of the variable is wxstring. Also I added the Trim() >> function before >> check if function definition is empty or not. >> >> On 08.12.2015 11:50, Andrej Antonov wrote: >> >>> patch: fix to use ``pg_get_functiondef()`` [see attachment file] >>> >>> it is copy of pull-request >>> https://github.com/postgres/pgadmin3/pull/12 [1] >>> >>> thank you! >> >> -- >> Dmitriy Olshevskiy >> >> >> Links: >> ------ >> [1] https://github.com/postgres/pgadmin3/pull/12 -- Андрей Антонов, инженер-программист отдела информационных технологий и программирования, компания «Импульс М»
Вложения
Hello, dear colleagues) Could you please review this patch (see the previous letter)? As I remember, there are several similar, but unclosed issues in pgadmin mailing list yet. Really, there is a problem with function's definition and this patch probably could solve it (at least for postgresql 8.4 and higher). What do you think? Thank you. On 18.12.2015 13:22, Andrej Antonov wrote: > small fix ( diff see here: > https://github.com/postgres-impulsm/pgadmin3/commit/72f381aa1964d5630f3ada44768bc562911102e9 > ) > > > if we using ``pg_get_functiondef(func_oid)`` -- > in this case -- no need to write additional > ``ALTER FUNCTION ... = ... ;``. > > > Andrej Antonov писал 2015-12-14 10:51: >> thank you, Dmitriy. I agree -- this-fix should >> works better. >> >> I applyed this-fix to my local-git-branches >> ("REL-1_20_0-impulsm" and >> "fix-to-use-pg_get_functiondef"). works good. >> >> Dmitriy Olshevskiy писал 2015-12-13 18:04: >>> Hi, Andrej! >>> Here is small fix of your patch - can you >>> check it please? >>> I think there must be wxwidgets function >>> IsEmpty() instead of double >>> negation, >>> because type of the variable is wxstring. >>> Also I added the Trim() >>> function before >>> check if function definition is empty or not. >>> >>> On 08.12.2015 11:50, Andrej Antonov wrote: >>> >>>> patch: fix to use ``pg_get_functiondef()`` >>>> [see attachment file] >>>> >>>> it is copy of pull-request >>>> https://github.com/postgres/pgadmin3/pull/12 [1] >>>> >>>> thank you! >>> >>> -- >>> Dmitriy Olshevskiy >>> >>> >>> Links: >>> ------ >>> [1] https://github.com/postgres/pgadmin3/pull/12 > -- Dmitriy Olshevskiy