Open ad-pro opened 5 years ago
Can you provide the script or a example to help with the tests?
Script could be difficult, I have to send you whole source code of the DB ...
What I have found:
ALTER TABLE deal_cost_attr
ADD CONSTRAINT deal_cost_attr_pkey PRIMARY KEY (id);
ALTER TABLE deal_cost_statuses
ADD CONSTRAINT deal_cost_statuses_pkey PRIMARY KEY (id);
ALTER TABLE deal_costs
ADD CONSTRAINT deal_costs_pkey PRIMARY KEY (id);
ALTER TABLE deal_cost_attr
ADD CONSTRAINT deal_cost_attr_sname_key UNIQUE (sname
last line number was 1930.
in the original file this was after:
--
-- Name: deal_cost_attr deal_cost_attr_pkey; Type: CONSTRAINT; Schema: cntr; Owner: mig_admin
--
ALTER TABLE ONLY cntr.deal_cost_attr
ADD CONSTRAINT deal_cost_attr_pkey PRIMARY KEY (id);
--
-- Name: deal_cost_attr deal_cost_attr_sname_key; Type: CONSTRAINT; Schema: cntr; Owner: mig_admin
--
ALTER TABLE ONLY cntr.deal_cost_attr
ADD CONSTRAINT deal_cost_attr_sname_key UNIQUE (sname);
last line: 36172.
when I run it without --ignore-function-whitespace parameter it generate diff file till:
CREATE OR REPLACE FUNCTION update_contract(p_id core.t_id, p_sname core.t_s
this is line 2556
and in original file this is
ALTER FUNCTION cntr.tmp_migrate_contract_container() OWNER TO mig_admin;
--
-- Name: update_contract(core.t_id, core.t_s_name, core.t_l_name, core.t_s_name, core.t_s_name, core.t_s_name, core.t_s_name, core.t_s_name, core.t_s_name, core.t_tsz, core.t_tsz, core.t_qty, core.t_qty, core.t_s_name, core.t_s_name, core.t_s_name); Type: FUNCTION; Schema: cntr; Owner: postgres
--
CREATE FUNCTION cntr.update_contract(p_id core.t_id, p_sname core.t_s_name, p_name core.t_l_name, p_cp_from_sname core.t_s_name, p_cp_to_sname core.t_s_name, p_place_from core.t_s_name, p_place_to core.t_s_name, p_material core.t_s_name, p_custom_status core.t_s_name, p_tsz_bgn core.t_tsz, p_tsz_end core.t_tsz, p_total_qty_min core.t_qty, p_total_qty_max core.t_qty, p_qty_unit_sname core.t_s_name, p_price_index_func core.t_s_name, p_cmnt core.t_s_name) RETURNS core.t_id
LANGUAGE plpgsql
line 18129
Hope this will help you a little bit.
I kind of fixed it in my fork
The same thing happen also parsing triggers. I think problem is because of using '' in comment.
version 2.4 gives this error
cz.startnet.utils.pgdiff.parsers.ParserException: Cannot parse string: COMMENT ON COLUMN audit.logged_actions.event_id IS 'Unique identifier for each auditable event';
and this from version 2.6.0
Exception in thread "main" java.lang.NullPointerException
at cz.startnet.utils.pgdiff.parsers.CommentParser.parseTrigger(CommentParser.java:202)
at cz.startnet.utils.pgdiff.parsers.CommentParser.parse(CommentParser.java:48)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:260)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:311)
at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:35)
at cz.startnet.utils.pgdiff.Main.main(Main.java:39)
I found the problem. Let assume that we have the below statement
COMMENT ON TRIGGER ex_trig ON schem1.table1 IS 'some comment';
As you can see the above example our trigger name is ex_trig
and it belongs to schem1
schema. When code parses trigger name and gets schema name function returns default
schema name because of there is no schema information with trigger name. In my case, default schema is public
but public
schema has not trigger with name ex_trig
so that programs give NullPointerException
I found the problem. Let assume that we have the below statement
COMMENT ON TRIGGER ex_trig ON schem1.table1 IS 'some comment';
As you can see the above example our trigger name is
ex_trig
and it belongs toschem1
schema. When code parses trigger name and gets schema name function returnsdefault
schema name because of there is no schema information with trigger name. In my case, default schema ispublic
butpublic
schema has not trigger with nameex_trig
so that programs giveNullPointerException
i fixed it in my fork
@d1maxa I checked your solution. I did also the same thing also. But i am not sure this is the correct way or not
@d1maxa I checked your solution. I did also the same thing also. But i am not sure this is the correct way or not
i'm sure
I have tested @d1maxa solutions with some databases scripts and the problem was solved, at lest for me.
I tried to generate difference between schemas and got following error:
Exception in thread "main" java.lang.NullPointerException at cz.startnet.utils.pgdiff.PgDiffTriggers.getEnablerOrDisableTriggers(PgDiffTriggers.java:222) at cz.startnet.utils.pgdiff.PgDiffTriggers.disableOrEnableTriggers(PgDiffTriggers.java:256) at cz.startnet.utils.pgdiff.PgDiff.updateSchemas(PgDiff.java:321) at cz.startnet.utils.pgdiff.PgDiff.diffDatabaseSchemas(PgDiff.java:144) at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:46) at cz.startnet.utils.pgdiff.Main.main(Main.java:39)
My java version is: penjdk version "1.8.0_212" OpenJDK Runtime Environment (build 1.8.0_212-8u212-b01-1~deb9u1-b01) OpenJDK 64-Bit Server VM (build 25.212-b01, mixed mode)