pgadmin4 icon indicating copy to clipboard operation
pgadmin4 copied to clipboard

Schema Diff: Issue when trigger names are same but trigger function body is different

Open kblum007 opened this issue 2 years ago • 2 comments

When comparing two tables that:

  • Have exactly the same DLL (see files source_dll.txt and target_dll.txt)
  • Have identical trigger DLL (see trigger_definition.txt), calling the same trigger function
  • The body of the trigger function is different in this case by comments only (see source_trigger_dll.txt and target_trigger_dll.txt)
  • (In my case) the trigger function is in a different schema

Schema Diff reports the two tables are different, and the script generator simply recreates the trigger (see generated_script_ddl.txt) with no reference or action to the trigger function.

I understand from the documentation that Schema Diff does not resolve dependencies. However, the behavior, in this case, is inconsistent. Schema Diff seems to understand that the trigger functions are different, but -- The DDL comparison for the source and target are identical -- The difference/generated script doesn't address the actual solution

source_ddl.txt target_ddl.txt trigger_definition.txt source_trigger_dll.txt target_trigger_dll.txt generated_script_ddl.txt

kblum007 avatar Jan 19 '23 17:01 kblum007

@kblum007

You seem to compare two schemas in your case, which is 'cmdb', which contains both tables and triggers. Your trigger function is in a different schema that is not included in the comparison, so this behavior is expected, but we will investigate.

Schema diff resolves dependencies between schemas. Create a trigger_function in 'cmdb', and it will be selected automatically when the table object is selected.

Meanwhile, you can compare the whole database, schema diff will show the trigeer_function that you can select and generate the scripts.

akshay-joshi avatar Jan 20 '23 13:01 akshay-joshi

I understand the different schemas. It’s that if Schema Diff is only looking at the current schema’s objects then why is it presenting the objects as “different” when the only thing that is different about them is the trigger function in another schema? It’s inconsistent with the expected behavior.

From: Akshay Joshi @.> Sent: Friday, January 20, 2023 7:25 AM To: pgadmin-org/pgadmin4 @.> Cc: Blum, Kimber @.>; Mention @.> Subject: Re: [pgadmin-org/pgadmin4] Schema Diff: Issue when trigger names are same but trigger function body is different (Issue #5762)

@kblum007https://urldefense.com/v3/__https:/github.com/kblum007__;!!DZ3fjg!9nkWKG3hOQGipV-qg_lh3O7YnH1MOAk7Mu1z7As2PYPbisevhikU3wqfWxtLKLLaf_yQjb3SPX0eEmnm_WGiuzWjbjU$

You seem to compare two schemas in your case, which is 'cmdb', which contains both tables and triggers. Your trigger function is in a different schema that is not included in the comparison, so this behavior is expected, but we will investigate.

Schema diff resolves dependencies between schemas. Create a trigger_function in 'cmdb', and it will be selected automatically when the table object is selected.

Meanwhile, you can compare the whole database, schema diff will show the trigeer_function that you can select and generate the scripts.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/pgadmin-org/pgadmin4/issues/5762*issuecomment-1398381666__;Iw!!DZ3fjg!9nkWKG3hOQGipV-qg_lh3O7YnH1MOAk7Mu1z7As2PYPbisevhikU3wqfWxtLKLLaf_yQjb3SPX0eEmnm_WGimZNSusQ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AIRACZ4VCAVFQESB6II22HTWTKG3XANCNFSM6AAAAAAUASPFWA__;!!DZ3fjg!9nkWKG3hOQGipV-qg_lh3O7YnH1MOAk7Mu1z7As2PYPbisevhikU3wqfWxtLKLLaf_yQjb3SPX0eEmnm_WGi0XfnJb4$. You are receiving this because you were mentioned.Message ID: @.@.>>

kblum007 avatar Jan 20 '23 14:01 kblum007

Issue fixed. Verified on snapshot build.

Env: OS - macOS Sonoma 14.4.1 Mode - Desktop

pravesh-sharma avatar May 27 '24 10:05 pravesh-sharma