Maxim Boguk maxim.boguk at gmail.com
Tue Jan 19 01:26:06 PST 2010
I using Slony 1.2.17 + Postgresql 8.4.1
All running fine until i try to add new function via execute script:
and i getting function body all time garbled with errors:

Looks like some bug in parsing file with statements.

Here is details:


slonik script look like:
==========
include <cluster_config.slonik>;

EXECUTE SCRIPT (SET ID=@main, FILENAME = '../sql/update.sql', EVENT
NODE=@master);
==========

update.sql look like:
==========
CREATE OR REPLACE FUNCTION percent_int(bigint, bigint) RETURNS numeric AS
$body$
        DECLARE
                percent numeric(10,2);
        BEGIN
                if $2 = 0 then
                        percent := 0.00;
                else
                        percent := ($1::numeric(10,2) * 100 /
$2)::numeric(10,2);
                end if;
                RETURN
                        percent;
        END;
$body$
LANGUAGE 'plpgsql';
=========

When i trying run this with slonik i got error:
postgres at shalyapin:~/dba/plus1/slonik_scripts$ slonik ./execute_script.slonik
DDL script consisting of 3 SQL statements
DDL Statement 0: (0,1026) [CREATE OR REPLACE FUNCTION
percent_int(bigint, bigint) RETURNS numeric AS$body$ OR REPLACE
FUNCTION percent_int(bigint, bigint) RETURNS numeric AS
DECLARECE FUNCTION percent_int(bigint, bigint) RETURNS numeric AS
          percent numeric(10,2);(bigint, bigint) RETURNS numeric AS
    BEGIN   percent numeric(10,2);(bigint, bigint) RETURNS numeric AS
              if $2 = 0 thenc(10,2);(bigint, bigint) RETURNS numeric
AS                        percent := 0.00;igint, bigint) RETURNS
numeric AS                else    percent := 0.00;igint, bigint)
RETURNS numeric AS                        percent :=
($1::numeric(10,2) * 100 / $2)::numeric(10,2);T6
                end if; percent := ($1::numeric(10,2) * 100 /
$2)::numeric(10,2);T6
                RETURN; percent := ($1::numeric(10,2) * 100 /
$2)::numeric(10,2);T6
                        percent;:= ($1::numeric(10,2) * 100 /
$2)::numeric(10,2);T6
        END;            percent;:= ($1::numeric(10,2) * 100 /
$2)::numeric(10,2);T6
$body$  END;]
DDL Statement failed - PGRES_FATAL_ERROR

And in postgresql log i see:
2010-01-19 11:47:02 MSK 10236 slony at plus1 [vxid:52/24956042
txid:554963435] [idle in transaction] ERROR:  syntax error at or near
"cent" at character 969
2010-01-19 11:47:02 MSK 10236 slony at plus1 [vxid:52/24956042
txid:554963435] [idle in transaction] STATEMENT:  CREATE OR REPLACE
FUNCTION percent_int(bigint, bigint) RETURNS numeric AS $body$ OR
REPLACE FUNCTION percent_int(bigint, bigint) RETURNS numeric AS
DECLARER REPLACE FUNCTION percent_int(bigint, bigint) RETURNS numeric
AS                percent numeric(10,2);ON percent_int(bigint, bigint)
RETURNS numeric AS
        BEGINent numeric(10,2);ON percent_int(bigint, bigint) RETURNS
numeric AS                if $2 = 0 thenc(10,2);ON percent_int(bigint,
bigint) RETURNS numeric AS                         percent :=
0.00;0,2);ON percent_int(bigint, bigint) RETURNS numeric AS
elsecent := 0.00;0,2);ON percent_int(bigint, bigint) RETURNS numeric
AS                         percent := ($1::numeric(10,2) * 100 /
$2)::numeric(10,2);NS numeric AS          end if;t :=
($1::numeric(10,2) * 100 / $2)::numeric(10,2);NS numeric AS
     RETURN t := ($1::numeric(10,2) * 100 / $2)::numeric(10,2);NS
numeric AS                         percent;:= ($1::numeric(10,2) * 100
/ $2)::numeric(10,2);NS numeric AS  END;rcent;:= ($1::numeric(10,2) *
100 / $2)::numeric(10,2);NS numeric AS $body$cent;


-- 
=======================================================
Я в контакте: http://vkontakte.ru/id16323414
Сила солому ломит, но не все в нашей жизни - солома, да и сила далеко не все.


More information about the Slony1-general mailing list