diff --git a/migtests/tests/analyze-schema/dummy-export-dir/schema/functions/function.sql b/migtests/tests/analyze-schema/dummy-export-dir/schema/functions/function.sql index f85ea54d71..fc5c894f6d 100644 --- a/migtests/tests/analyze-schema/dummy-export-dir/schema/functions/function.sql +++ b/migtests/tests/analyze-schema/dummy-export-dir/schema/functions/function.sql @@ -87,4 +87,90 @@ BEGIN SELECT * FROM employees e WHERE e.xmax = (SELECT MAX(xmax) FROM employees WHERE department = e.department); END; -$$; \ No newline at end of file +$$; + +CREATE FUNCTION public.get_employeee_salary(emp_id integer) RETURNS numeric + LANGUAGE plpgsql + AS $$ +DECLARE + emp_salary employees.salary%TYPE; -- Declare a variable with the same type as employees.salary +BEGIN + SELECT salary INTO emp_salary + FROM employees + WHERE employee_id = emp_id; + RETURN emp_salary; +END; +$$; + +CREATE OR REPLACE FUNCTION calculate_tax(salary_amount NUMERIC) RETURNS NUMERIC AS $$ +DECLARE + tax_rate employees.tax_rate%TYPE; -- Inherits type from employees.tax_rate column + tax_amount NUMERIC; +BEGIN + -- Assign a value to the variable + SELECT tax_rate INTO tax_rate FROM employees WHERE id = 1; + + -- Use the variable in a calculation + tax_amount := salary_amount * tax_rate; + RETURN tax_amount; +END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION log_salary_change() RETURNS TRIGGER AS $$ +DECLARE + old_salary employees.salary%TYPE; -- Matches the type of the salary column + new_salary employees.salary%TYPE; +BEGIN + old_salary := OLD.salary; + new_salary := NEW.salary; + + IF new_salary <> old_salary THEN + INSERT INTO salary_log(employee_id, old_salary, new_salary, changed_at) + VALUES (NEW.id, old_salary, new_salary, now()); + END IF; + + RETURN NEW; +END; +$$ LANGUAGE plpgsql; + +CREATE TRIGGER salary_update_trigger +AFTER UPDATE OF salary ON employees +FOR EACH ROW EXECUTE FUNCTION log_salary_change(); + +CREATE OR REPLACE FUNCTION get_employee_details(emp_id employees.id%Type) +RETURNS public.employees.name%Type AS $$ +DECLARE + employee_name employees.name%TYPE; +BEGIN + SELECT name INTO employee_name FROM employees WHERE id = emp_id; + RETURN employee_name; +END; +$$ LANGUAGE plpgsql; + + +CREATE OR REPLACE FUNCTION list_high_earners(threshold NUMERIC) RETURNS VOID AS $$ +DECLARE + emp_name employees.name%TYPE; + emp_salary employees.salary%TYPE; +BEGIN + FOR emp_name, emp_salary IN + SELECT name, salary FROM employees WHERE salary > threshold + LOOP + RAISE NOTICE 'Employee: %, Salary: %', emp_name, emp_salary; + END LOOP; +END; +$$ LANGUAGE plpgsql; + + +CREATE OR REPLACE FUNCTION copy_high_earners(threshold NUMERIC) RETURNS VOID AS $$ +DECLARE + temp_salary employees.salary%TYPE; +BEGIN + CREATE TEMP TABLE temp_high_earners AS + SELECT * FROM employees WHERE salary > threshold; + + FOR temp_salary IN SELECT salary FROM temp_high_earners LOOP + RAISE NOTICE 'High earner salary: %', temp_salary; + END LOOP; +END; +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/migtests/tests/analyze-schema/dummy-export-dir/schema/procedures/procedure.sql b/migtests/tests/analyze-schema/dummy-export-dir/schema/procedures/procedure.sql index 4879281eb3..cdb2bdcff6 100644 --- a/migtests/tests/analyze-schema/dummy-export-dir/schema/procedures/procedure.sql +++ b/migtests/tests/analyze-schema/dummy-export-dir/schema/procedures/procedure.sql @@ -149,3 +149,27 @@ BEGIN RAISE NOTICE 'Employee % of age % added successfully.', emp_name, emp_age; END; $$; + +CREATE OR REPLACE PROCEDURE update_salary(emp_id INT, increment NUMERIC) AS $$ +DECLARE + current_salary employees.salary%TYPE; -- Matches the type of the salary column +BEGIN + SELECT salary INTO current_salary FROM employees WHERE id = emp_id; + + IF current_salary IS NULL THEN + RAISE NOTICE 'Employee ID % does not exist.', emp_id; + ELSE + UPDATE employees SET salary = current_salary + increment WHERE id = emp_id; + END IF; +END; +$$ LANGUAGE plpgsql; + + +CREATE OR REPLACE PROCEDURE get_employee_details_proc(emp_id employees.id%Type, salary employees.salary%TYPE, tax_rate numeric) AS $$ +DECLARE + employee_name employees.name%TYPE; +BEGIN + SELECT name INTO employee_name FROM employees e WHERE e.id = emp_id and e.salary = salary and e.tax_rate = tax_rate; + +END; +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/migtests/tests/analyze-schema/expected_issues.json b/migtests/tests/analyze-schema/expected_issues.json index 0c1dc18255..431ab83cf4 100644 --- a/migtests/tests/analyze-schema/expected_issues.json +++ b/migtests/tests/analyze-schema/expected_issues.json @@ -1584,5 +1584,145 @@ "Suggestion": "", "GH": "", "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#system-columns-is-not-yet-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "public.get_employeee_salary", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.salary%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "calculate_tax", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.tax_rate%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "log_salary_change", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.salary%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "log_salary_change", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.salary%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "get_employee_details", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.name%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "get_employee_details", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.id%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "list_high_earners", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.name%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "list_high_earners", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.salary%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "copy_high_earners", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.salary%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "PROCEDURE", + "ObjectName": "update_salary", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.salary%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "PROCEDURE", + "ObjectName": "get_employee_details_proc", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.name%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "PROCEDURE", + "ObjectName": "get_employee_details_proc", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.id%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "PROCEDURE", + "ObjectName": "get_employee_details_proc", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "employees.salary%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "get_employee_details", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "public.employees.name%TYPE", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" } ] diff --git a/migtests/tests/analyze-schema/summary.json b/migtests/tests/analyze-schema/summary.json index 8b633466df..09b4ec3f28 100644 --- a/migtests/tests/analyze-schema/summary.json +++ b/migtests/tests/analyze-schema/summary.json @@ -36,15 +36,15 @@ }, { "ObjectType": "FUNCTION", - "TotalCount": 1, - "InvalidCount": 1, - "ObjectNames": "create_and_populate_tables" + "TotalCount": 7, + "InvalidCount": 7, + "ObjectNames": "create_and_populate_tables, public.get_employeee_salary, get_employee_details, calculate_tax, log_salary_change, list_high_earners, copy_high_earners" }, { "ObjectType": "PROCEDURE", - "TotalCount": 6, - "InvalidCount": 4, - "ObjectNames": "foo, foo1, sp_createnachabatch, test, test1, add_employee" + "TotalCount": 8, + "InvalidCount": 6, + "ObjectNames": "foo, foo1, sp_createnachabatch, test, get_employee_details_proc, test1, add_employee, update_salary" }, { "ObjectType": "VIEW", diff --git a/migtests/tests/pg/assessment-report-test/expectedAssessmentReport.json b/migtests/tests/pg/assessment-report-test/expectedAssessmentReport.json index e3aa333e28..e87e9cb5e2 100644 --- a/migtests/tests/pg/assessment-report-test/expectedAssessmentReport.json +++ b/migtests/tests/pg/assessment-report-test/expectedAssessmentReport.json @@ -55,10 +55,9 @@ }, { "ObjectType": "FUNCTION", - "TotalCount": 9, - "InvalidCount": 2, - "ObjectNames": "public.process_order, schema2.process_order, public.auditlogfunc, public.check_sales_region, public.prevent_update_shipped_without_date, public.total, schema2.auditlogfunc, schema2.prevent_update_shipped_without_date, schema2.total" - }, + "TotalCount": 10, + "InvalidCount": 3, + "ObjectNames": "public.auditlogfunc, public.check_sales_region, public.prevent_update_shipped_without_date, public.process_combined_tbl, public.process_order, public.total, schema2.auditlogfunc, schema2.prevent_update_shipped_without_date, schema2.process_order, schema2.total" }, { "ObjectType": "AGGREGATE", "TotalCount": 2, @@ -67,9 +66,9 @@ }, { "ObjectType": "PROCEDURE", - "TotalCount": 2, - "InvalidCount": 0, - "ObjectNames": "public.tt_insert_data, schema2.tt_insert_data" + "TotalCount": 3, + "InvalidCount": 1, + "ObjectNames": "public.tt_insert_data, public.update_combined_tbl_data, schema2.tt_insert_data" }, { "ObjectType": "VIEW", @@ -2131,6 +2130,22 @@ } ], "UnsupportedPlPgSqlObjects": [ + { + "FeatureName": "Referenced type declaration of variables", + "Objects": [ + { + "ObjectType": "FUNCTION", + "ObjectName": "public.process_combined_tbl", + "SqlStatement": "public.combined_tbl.maddr%TYPE" + }, + { + "ObjectType": "PROCEDURE", + "ObjectName": "public.update_combined_tbl_data", + "SqlStatement": "public.combined_tbl.maddr%TYPE" + } + ], + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, { "FeatureName": "Advisory Locks", "Objects": [ diff --git a/migtests/tests/pg/assessment-report-test/pg_assessment_report.sql b/migtests/tests/pg/assessment-report-test/pg_assessment_report.sql index c826c33aaf..e3ef11bb0c 100644 --- a/migtests/tests/pg/assessment-report-test/pg_assessment_report.sql +++ b/migtests/tests/pg/assessment-report-test/pg_assessment_report.sql @@ -294,3 +294,56 @@ END; $$ LANGUAGE plpgsql; select process_order(1); + +-- In PG migration from pg_dump the function parameters and return will never have the %TYPE syntax, instead they have the actual type in the DDLs +-- e.g. for the below function this will be the export one `CREATE FUNCTION public.process_combined_tbl(p_id integer, p_c cidr, p_bitt bit, p_inds3 interval) RETURNS macaddr` +CREATE OR REPLACE FUNCTION public.process_combined_tbl( + p_id public.combined_tbl.id%TYPE, + p_c public.combined_tbl.c%TYPE, + p_bitt public.combined_tbl.bitt%TYPE, + p_inds3 public.combined_tbl.inds3%TYPE +) +RETURNS public.combined_tbl.maddr%TYPE AS +$$ +DECLARE + v_maddr public.combined_tbl.maddr%TYPE; +BEGIN + -- Example logic: Assigning local variable using passed-in parameter + v_maddr := p_c::text; -- Example conversion (cidr to macaddr), just for illustration + + -- Processing the passed parameters + RAISE NOTICE 'Processing: ID = %, CIDR = %, BIT = %, Interval = %, MAC = %', + p_id, p_c, p_bitt, p_inds3, v_maddr; + + -- Returning a value of the macaddr type (this could be more meaningful logic) + RETURN v_maddr; -- Returning a macaddr value +END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE PROCEDURE public.update_combined_tbl_data( + p_id public.combined_tbl.id%TYPE, + p_c public.combined_tbl.c%TYPE, + p_bitt public.combined_tbl.bitt%TYPE, + p_d public.combined_tbl.d%TYPE +) +AS +$$ +DECLARE + v_new_mac public.combined_tbl.maddr%TYPE; +BEGIN + -- Example: Using a local variable to store a macaddr value (for illustration) + v_new_mac := '00:14:22:01:23:45'::macaddr; + + -- Updating the table with provided parameters + UPDATE public.combined_tbl + SET + c = p_c, -- Updating cidr type column + bitt = p_bitt, -- Updating bit column + d = p_d, -- Updating daterange column + maddr = v_new_mac -- Using the local macaddr variable in update + WHERE id = p_id; + + RAISE NOTICE 'Updated record with ID: %, CIDR: %, BIT: %, Date range: %', + p_id, p_c, p_bitt, p_d; +END; +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/migtests/tests/pg/mgi/expected_files/expectedAssessmentReport.json b/migtests/tests/pg/mgi/expected_files/expectedAssessmentReport.json index e977afb880..ae0b93f687 100644 --- a/migtests/tests/pg/mgi/expected_files/expectedAssessmentReport.json +++ b/migtests/tests/pg/mgi/expected_files/expectedAssessmentReport.json @@ -36,7 +36,7 @@ { "ObjectType": "FUNCTION", "TotalCount": 139, - "InvalidCount": 0, + "InvalidCount": 16, "ObjectNames": "mgd.acc_accession_delete, mgd.acc_assignj, mgd.acc_assignmgi, mgd.acc_delete_byacckey, mgd.acc_insert, mgd.acc_setmax, mgd.acc_split, mgd.acc_update, mgd.accref_insert, mgd.accref_process, mgd.all_allele_delete, mgd.all_allele_insert, mgd.all_allele_update, mgd.all_cellline_delete, mgd.all_cellline_update1, mgd.all_cellline_update2, mgd.all_convertallele, mgd.all_createwildtype, mgd.all_insertallele, mgd.all_mergeallele, mgd.all_mergewildtypes, mgd.all_reloadlabel, mgd.all_variant_delete, mgd.bib_keepwfrelevance, mgd.bib_refs_delete, mgd.bib_refs_insert, mgd.bib_reloadcache, mgd.bib_updatewfstatusap, mgd.bib_updatewfstatusgo, mgd.bib_updatewfstatusgxd, mgd.bib_updatewfstatusqtl, mgd.gxd_addcelltypeset, mgd.gxd_addemapaset, mgd.gxd_addgenotypeset, mgd.gxd_allelepair_insert, mgd.gxd_antibody_delete, mgd.gxd_antibody_insert, mgd.gxd_antigen_delete, mgd.gxd_antigen_insert, mgd.gxd_assay_delete, mgd.gxd_assay_insert, mgd.gxd_checkduplicategenotype, mgd.gxd_gelrow_insert, mgd.gxd_genotype_delete, mgd.gxd_genotype_insert, mgd.gxd_getgenotypesdatasets, mgd.gxd_getgenotypesdatasetscount, mgd.gxd_htexperiment_delete, mgd.gxd_htrawsample_delete, mgd.gxd_htsample_ageminmax, mgd.gxd_index_insert, mgd.gxd_index_insert_before, mgd.gxd_index_update, mgd.gxd_orderallelepairs, mgd.gxd_ordergenotypes, mgd.gxd_ordergenotypesall, mgd.gxd_ordergenotypesmissing, mgd.gxd_removebadgelband, mgd.gxd_replacegenotype, mgd.img_image_delete, mgd.img_image_insert, mgd.img_setpdo, mgd.mgi_addsetmember, mgd.mgi_checkemapaclipboard, mgd.mgi_cleannote, mgd.mgi_deleteemapaclipboarddups, mgd.mgi_insertreferenceassoc, mgd.mgi_insertsynonym, mgd.mgi_mergerelationship, mgd.mgi_organism_delete, mgd.mgi_organism_insert, mgd.mgi_processnote, mgd.mgi_reference_assoc_delete, mgd.mgi_reference_assoc_insert, mgd.mgi_relationship_delete, mgd.mgi_resetageminmax, mgd.mgi_resetsequencenum, mgd.mgi_setmember_emapa_insert, mgd.mgi_setmember_emapa_update, mgd.mgi_statistic_delete, mgd.mgi_updatereferenceassoc, mgd.mgi_updatesetmember, mgd.mld_expt_marker_update, mgd.mld_expts_delete, mgd.mld_expts_insert, mgd.mrk_allelewithdrawal, mgd.mrk_cluster_delete, mgd.mrk_copyhistory, mgd.mrk_deletewithdrawal, mgd.mrk_inserthistory, mgd.mrk_marker_delete, mgd.mrk_marker_insert, mgd.mrk_marker_update, mgd.mrk_mergewithdrawal, mgd.mrk_reloadlocation, mgd.mrk_reloadreference, mgd.mrk_simplewithdrawal, mgd.mrk_strainmarker_delete, mgd.mrk_updatekeys, mgd.prb_ageminmax, mgd.prb_getstrainbyreference, mgd.prb_getstraindatasets, mgd.prb_getstrainreferences, mgd.prb_insertreference, mgd.prb_marker_insert, mgd.prb_marker_update, mgd.prb_mergestrain, mgd.prb_probe_delete, mgd.prb_probe_insert, mgd.prb_processanonymoussource, mgd.prb_processprobesource, mgd.prb_processseqloadersource, mgd.prb_processsequencesource, mgd.prb_reference_delete, mgd.prb_reference_update, mgd.prb_setstrainreview, mgd.prb_source_delete, mgd.prb_strain_delete, mgd.prb_strain_insert, mgd.seq_deletebycreatedby, mgd.seq_deletedummy, mgd.seq_deleteobsoletedummy, mgd.seq_merge, mgd.seq_sequence_delete, mgd.seq_split, mgd.voc_annot_insert, mgd.voc_copyannotevidencenotes, mgd.voc_evidence_delete, mgd.voc_evidence_insert, mgd.voc_evidence_property_delete, mgd.voc_evidence_update, mgd.voc_mergeannotations, mgd.voc_mergedupannotations, mgd.voc_mergeterms, mgd.voc_processannotheader, mgd.voc_processannotheaderall, mgd.voc_processannotheadermissing, mgd.voc_resetterms, mgd.voc_term_delete" }, { @@ -13513,5 +13513,232 @@ } ], "UnsupportedQueryConstructs": null, - "UnsupportedPlPgSqlObjects": null + "UnsupportedPlPgSqlObjects": [ + { + "FeatureName": "Referenced type declaration of variables", + "Objects": [ + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_assignmgi", + "SqlStatement": "acc_accession.accid%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_assignmgi", + "SqlStatement": "acc_accession.accid%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_insert", + "SqlStatement": "acc_accession.prefixPart%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_update", + "SqlStatement": "acc_accession.prefixPart%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_update", + "SqlStatement": "acc_accession.prefixPart%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_createwildtype", + "SqlStatement": "all_allele.symbol%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_insertallele", + "SqlStatement": "all_allele.isextinct%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_insertallele", + "SqlStatement": "all_allele.ismixed%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_reloadlabel", + "SqlStatement": "all_label.label%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_reloadlabel", + "SqlStatement": "all_label.labelType%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_reloadlabel", + "SqlStatement": "all_label.labelTypeName%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.img_setpdo", + "SqlStatement": "acc_accession.accID%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_allelewithdrawal", + "SqlStatement": "mrk_marker.symbol%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_allelewithdrawal", + "SqlStatement": "mrk_marker.name%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_allelewithdrawal", + "SqlStatement": "mrk_marker.symbol%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_copyhistory", + "SqlStatement": "mrk_history.name%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_copyhistory", + "SqlStatement": "mrk_history.event_date%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_deletewithdrawal", + "SqlStatement": "mrk_marker.name%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "SqlStatement": "mrk_marker.symbol%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "SqlStatement": "mrk_marker.name%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "SqlStatement": "mrk_marker.symbol%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "SqlStatement": "mrk_marker.chromosome%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "SqlStatement": "mrk_marker.name%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "SqlStatement": "mrk_marker.cytogeneticOffset%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "SqlStatement": "mrk_marker.cmOffset%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "SqlStatement": "all_allele.symbol%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "mrk_marker.chromosome%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "mrk_marker.cytogeneticOffset%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "mrk_marker.cmoffset%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "seq_coord_cache.startCoordinate%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "seq_coord_cache.endCoordinate%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "seq_coord_cache.strand%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "voc_term.term%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "map_coord_collection.abbreviation%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "seq_coord_cache.version%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "SqlStatement": "seq_coord_cache.chromosome%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_simplewithdrawal", + "SqlStatement": "mrk_marker.name%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_simplewithdrawal", + "SqlStatement": "mrk_marker.symbol%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.prb_ageminmax", + "SqlStatement": "prb_source.age%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.prb_ageminmax", + "SqlStatement": "prb_source.age%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.prb_mergestrain", + "SqlStatement": "acc_accession.accID%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.prb_mergestrain", + "SqlStatement": "acc_accession.accID%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.seq_split", + "SqlStatement": "acc_accession.accID%TYPE" + }, + { + "ObjectType": "FUNCTION", + "ObjectName": "mgd.seq_split", + "SqlStatement": "acc_accession.accID%TYPE" + } + ], + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + } + ] } diff --git a/migtests/tests/pg/mgi/expected_files/expected_schema_analysis_report.json b/migtests/tests/pg/mgi/expected_files/expected_schema_analysis_report.json index ccadb13896..e6cc902c91 100644 --- a/migtests/tests/pg/mgi/expected_files/expected_schema_analysis_report.json +++ b/migtests/tests/pg/mgi/expected_files/expected_schema_analysis_report.json @@ -36,7 +36,7 @@ { "ObjectType": "FUNCTION", "TotalCount": 139, - "InvalidCount": 0, + "InvalidCount": 16, "ObjectNames": "mgd.acc_accession_delete, mgd.acc_assignj, mgd.acc_assignmgi, mgd.acc_delete_byacckey, mgd.acc_insert, mgd.acc_setmax, mgd.acc_split, mgd.acc_update, mgd.accref_insert, mgd.accref_process, mgd.all_allele_delete, mgd.all_allele_insert, mgd.all_allele_update, mgd.all_cellline_delete, mgd.all_cellline_update1, mgd.all_cellline_update2, mgd.all_convertallele, mgd.all_createwildtype, mgd.all_insertallele, mgd.all_mergeallele, mgd.all_mergewildtypes, mgd.all_reloadlabel, mgd.all_variant_delete, mgd.bib_keepwfrelevance, mgd.bib_refs_delete, mgd.bib_refs_insert, mgd.bib_reloadcache, mgd.bib_updatewfstatusap, mgd.bib_updatewfstatusgo, mgd.bib_updatewfstatusgxd, mgd.bib_updatewfstatusqtl, mgd.gxd_addcelltypeset, mgd.gxd_addemapaset, mgd.gxd_addgenotypeset, mgd.gxd_allelepair_insert, mgd.gxd_antibody_delete, mgd.gxd_antibody_insert, mgd.gxd_antigen_delete, mgd.gxd_antigen_insert, mgd.gxd_assay_delete, mgd.gxd_assay_insert, mgd.gxd_checkduplicategenotype, mgd.gxd_gelrow_insert, mgd.gxd_genotype_delete, mgd.gxd_genotype_insert, mgd.gxd_getgenotypesdatasets, mgd.gxd_getgenotypesdatasetscount, mgd.gxd_htexperiment_delete, mgd.gxd_htrawsample_delete, mgd.gxd_htsample_ageminmax, mgd.gxd_index_insert, mgd.gxd_index_insert_before, mgd.gxd_index_update, mgd.gxd_orderallelepairs, mgd.gxd_ordergenotypes, mgd.gxd_ordergenotypesall, mgd.gxd_ordergenotypesmissing, mgd.gxd_removebadgelband, mgd.gxd_replacegenotype, mgd.img_image_delete, mgd.img_image_insert, mgd.img_setpdo, mgd.mgi_addsetmember, mgd.mgi_checkemapaclipboard, mgd.mgi_cleannote, mgd.mgi_deleteemapaclipboarddups, mgd.mgi_insertreferenceassoc, mgd.mgi_insertsynonym, mgd.mgi_mergerelationship, mgd.mgi_organism_delete, mgd.mgi_organism_insert, mgd.mgi_processnote, mgd.mgi_reference_assoc_delete, mgd.mgi_reference_assoc_insert, mgd.mgi_relationship_delete, mgd.mgi_resetageminmax, mgd.mgi_resetsequencenum, mgd.mgi_setmember_emapa_insert, mgd.mgi_setmember_emapa_update, mgd.mgi_statistic_delete, mgd.mgi_updatereferenceassoc, mgd.mgi_updatesetmember, mgd.mld_expt_marker_update, mgd.mld_expts_delete, mgd.mld_expts_insert, mgd.mrk_allelewithdrawal, mgd.mrk_cluster_delete, mgd.mrk_copyhistory, mgd.mrk_deletewithdrawal, mgd.mrk_inserthistory, mgd.mrk_marker_delete, mgd.mrk_marker_insert, mgd.mrk_marker_update, mgd.mrk_mergewithdrawal, mgd.mrk_reloadlocation, mgd.mrk_reloadreference, mgd.mrk_simplewithdrawal, mgd.mrk_strainmarker_delete, mgd.mrk_updatekeys, mgd.prb_ageminmax, mgd.prb_getstrainbyreference, mgd.prb_getstraindatasets, mgd.prb_getstrainreferences, mgd.prb_insertreference, mgd.prb_marker_insert, mgd.prb_marker_update, mgd.prb_mergestrain, mgd.prb_probe_delete, mgd.prb_probe_insert, mgd.prb_processanonymoussource, mgd.prb_processprobesource, mgd.prb_processseqloadersource, mgd.prb_processsequencesource, mgd.prb_reference_delete, mgd.prb_reference_update, mgd.prb_setstrainreview, mgd.prb_source_delete, mgd.prb_strain_delete, mgd.prb_strain_insert, mgd.seq_deletebycreatedby, mgd.seq_deletedummy, mgd.seq_deleteobsoletedummy, mgd.seq_merge, mgd.seq_sequence_delete, mgd.seq_split, mgd.voc_annot_insert, mgd.voc_copyannotevidencenotes, mgd.voc_evidence_delete, mgd.voc_evidence_insert, mgd.voc_evidence_property_delete, mgd.voc_evidence_update, mgd.voc_mergeannotations, mgd.voc_mergedupannotations, mgd.voc_mergeterms, mgd.voc_processannotheader, mgd.voc_processannotheaderall, mgd.voc_processannotheadermissing, mgd.voc_resetterms, mgd.voc_term_delete" }, { @@ -735,6 +735,490 @@ "Suggestion": "Remove it from the exported schema.", "GH": "https://github.com/YugaByte/yugabyte-db/issues/1124", "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#unsupported-alter-table-ddl-variants-in-source-schema" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_assignmgi", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.accid%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_assignmgi", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.accid%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_insert", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.prefixPart%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_update", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.prefixPart%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.acc_update", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.prefixPart%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_createwildtype", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "all_allele.symbol%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_insertallele", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "all_allele.isextinct%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_insertallele", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "all_allele.ismixed%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_reloadlabel", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "all_label.label%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_reloadlabel", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "all_label.labelType%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.all_reloadlabel", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "all_label.labelTypeName%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.img_setpdo", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.accID%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_allelewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.symbol%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_allelewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.name%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_allelewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.symbol%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_copyhistory", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_history.name%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_copyhistory", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_history.event_date%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_deletewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.name%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.symbol%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.name%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.symbol%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.chromosome%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.name%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.cytogeneticOffset%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.cmOffset%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_mergewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "all_allele.symbol%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.chromosome%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.cytogeneticOffset%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.cmoffset%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "seq_coord_cache.startCoordinate%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "seq_coord_cache.endCoordinate%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "seq_coord_cache.strand%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "voc_term.term%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "map_coord_collection.abbreviation%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "seq_coord_cache.version%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_reloadlocation", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "seq_coord_cache.chromosome%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_simplewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.name%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.mrk_simplewithdrawal", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "mrk_marker.symbol%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.prb_ageminmax", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "prb_source.age%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.prb_ageminmax", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "prb_source.age%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.prb_mergestrain", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.accID%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.prb_mergestrain", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.accID%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.seq_split", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.accID%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" + }, + { + "IssueType": "unsupported_plpgsql_objects", + "ObjectType": "FUNCTION", + "ObjectName": "mgd.seq_split", + "Reason": "Referenced type declaration of variables", + "SqlStatement": "acc_accession.accID%TYPE", + "FilePath": "/Users/priyanshigupta/Documents/voyager/yb-voyager/migtests/tests/pg/mgi/export-dir/schema/functions/function.sql", + "Suggestion": "Fix the syntax to include the actual type name instead of referencing the type of a column", + "GH": "https://github.com/yugabyte/yugabyte-db/issues/23619", + "DocsLink": "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported" } ] } diff --git a/yb-voyager/cmd/analyzeSchema.go b/yb-voyager/cmd/analyzeSchema.go index 976e905ba3..9b71172dcd 100644 --- a/yb-voyager/cmd/analyzeSchema.go +++ b/yb-voyager/cmd/analyzeSchema.go @@ -1724,6 +1724,8 @@ func convertIssueInstanceToAnalyzeIssue(issueInstance issue.IssueInstance, fileN DocsLink: issueInstance.DocsLink, FilePath: fileName, IssueType: UNSUPPORTED_PLPGSQL_OBEJCTS, + Suggestion: issueInstance.Suggestion, + GH: issueInstance.GH, } } diff --git a/yb-voyager/src/issue/constants.go b/yb-voyager/src/issue/constants.go index fdd94c0ea2..f792d32fea 100644 --- a/yb-voyager/src/issue/constants.go +++ b/yb-voyager/src/issue/constants.go @@ -18,9 +18,10 @@ package issue // Types const ( - ADVISORY_LOCKS = "ADVISORY_LOCKS" - SYSTEM_COLUMNS = "SYSTEM_COLUMNS" - XML_FUNCTIONS = "XML_FUNCTIONS" + ADVISORY_LOCKS = "ADVISORY_LOCKS" + SYSTEM_COLUMNS = "SYSTEM_COLUMNS" + XML_FUNCTIONS = "XML_FUNCTIONS" + REFERENCED_TYPE_DECLARATION = "REFERENCED_TYPE_DECLARATION" ) // Object types diff --git a/yb-voyager/src/issue/ddl.go b/yb-voyager/src/issue/ddl.go new file mode 100644 index 0000000000..390ee1b76c --- /dev/null +++ b/yb-voyager/src/issue/ddl.go @@ -0,0 +1,31 @@ +/* +Copyright (c) YugabyteDB, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package issue + +var percentTypeSyntax = Issue{ + Type: REFERENCED_TYPE_DECLARATION, + TypeName: "Referenced type declaration of variables", + TypeDescription: "", + Suggestion: "Fix the syntax to include the actual type name instead of referencing the type of a column", + GH: "https://github.com/yugabyte/yugabyte-db/issues/23619", + DocsLink: "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#type-syntax-is-not-supported", +} + +func NewPercentTypeSyntaxIssue(objectType string, objectName string, sqlStatement string) IssueInstance { + return newIssueInstance(percentTypeSyntax, objectType, objectName, sqlStatement, map[string]interface{}{}) +} + diff --git a/yb-voyager/src/queryissue/queryissue.go b/yb-voyager/src/queryissue/queryissue.go index 9772e3a160..691a407ec6 100644 --- a/yb-voyager/src/queryissue/queryissue.go +++ b/yb-voyager/src/queryissue/queryissue.go @@ -18,6 +18,7 @@ package queryissue import ( "fmt" + "strings" "github.com/samber/lo" log "github.com/sirupsen/logrus" @@ -83,6 +84,12 @@ func (p *ParserIssueDetector) getAllIssues(query string) ([]issue.IssueInstance, issues = append(issues, issuesInQuery...) } + percentTypeSyntaxIssues, err := p.GetPercentTypeSyntaxIssues(query) + if err != nil { + return nil, fmt.Errorf("error getting reference TYPE syntax issues: %v", err) + } + issues = append(issues, percentTypeSyntaxIssues...) + return lo.Map(issues, func(i issue.IssueInstance, _ int) issue.IssueInstance { //Replacing the objectType and objectName to the original ObjectType and ObjectName of the PLPGSQL object //e.g. replacing the DML_QUERY and "" to FUNCTION and @@ -110,7 +117,6 @@ func (p *ParserIssueDetector) getAllIssues(query string) ([]issue.IssueInstance, i.ObjectName = objName return i }), nil - } issues, err := p.getDMLIssues(query) @@ -120,6 +126,36 @@ func (p *ParserIssueDetector) getAllIssues(query string) ([]issue.IssueInstance, return issues, nil } +func (p *ParserIssueDetector) GetPercentTypeSyntaxIssues(query string) ([]issue.IssueInstance, error) { + parseTree, err := queryparser.Parse(query) + if err != nil { + return nil, fmt.Errorf("error parsing the query-%s: %v", query, err) + } + + objType, objName := queryparser.GetObjectTypeAndObjectName(parseTree) + typeNames, err := queryparser.GetAllTypeNamesInPlpgSQLStmt(query) + if err != nil { + return nil, fmt.Errorf("error getting type names in PLPGSQL: %v", err) + } + + /* + Caveats of GetAllTypeNamesInPlpgSQLStmt(): + 1. Not returning typename for variables in function parameter from this function (in correct in json as UNKNOWN), for that using the GetTypeNamesFromFuncParameters() + 2. Not returning the return type from this function (not available in json), for that using the GetReturnTypeOfFunc() + */ + if queryparser.IsFunctionObject(parseTree) { + typeNames = append(typeNames, queryparser.GetReturnTypeOfFunc(parseTree)) + } + typeNames = append(typeNames, queryparser.GetFuncParametersTypeNames(parseTree)...) + var issues []issue.IssueInstance + for _, typeName := range typeNames { + if strings.HasSuffix(typeName, "%TYPE") { + issues = append(issues, issue.NewPercentTypeSyntaxIssue(objType, objName, typeName)) // TODO: confirm + } + } + return issues, nil +} + func (p *ParserIssueDetector) GetDMLIssues(query string, targetDbVersion *ybversion.YBVersion) ([]issue.IssueInstance, error) { issues, err := p.getDMLIssues(query) if err != nil { diff --git a/yb-voyager/src/queryparser/query_parser.go b/yb-voyager/src/queryparser/query_parser.go index 247a30c597..2a4737cd7a 100644 --- a/yb-voyager/src/queryparser/query_parser.go +++ b/yb-voyager/src/queryparser/query_parser.go @@ -17,6 +17,7 @@ package queryparser import ( "fmt" + "strings" pg_query "github.com/pganalyze/pg_query_go/v5" "github.com/samber/lo" @@ -65,7 +66,6 @@ func GetProtoMessageFromParseTree(parseTree *pg_query.ParseResult) protoreflect. return parseTree.Stmts[0].Stmt.ProtoReflect() } - func IsPLPGSQLObject(parseTree *pg_query.ParseResult) bool { // CREATE FUNCTION is same parser NODE for FUNCTION/PROCEDURE _, isPlPgSQLObject := getCreateFuncStmtNode(parseTree) @@ -163,4 +163,77 @@ func getCreateViewNode(parseTree *pg_query.ParseResult) (*pg_query.Node_ViewStmt func getCreateFuncStmtNode(parseTree *pg_query.ParseResult) (*pg_query.Node_CreateFunctionStmt, bool) { node, ok := parseTree.Stmts[0].Stmt.Node.(*pg_query.Node_CreateFunctionStmt) return node, ok -} \ No newline at end of file +} + +func IsFunctionObject(parseTree *pg_query.ParseResult) bool { + funcNode, ok := getCreateFuncStmtNode(parseTree) + if !ok { + return false + } + return !funcNode.CreateFunctionStmt.IsProcedure +} + +/* +return type ex- +CREATE OR REPLACE FUNCTION public.process_combined_tbl( + + ... + +) +RETURNS public.combined_tbl.maddr%TYPE AS +return_type:{names:{string:{sval:"public"}} names:{string:{sval:"combined_tbl"}} names:{string:{sval:"maddr"}} +pct_type:true typemod:-1 location:226} +*/ +func GetReturnTypeOfFunc(parseTree *pg_query.ParseResult) string { + funcNode, _ := getCreateFuncStmtNode(parseTree) + returnType := funcNode.CreateFunctionStmt.GetReturnType() + return convertParserTypeNameToString(returnType) +} + +func getQualifiedTypeName(typeNames []*pg_query.Node) string { + var typeNameStrings []string + for _, n := range typeNames { + typeNameStrings = append(typeNameStrings, n.GetString_().Sval) + } + return strings.Join(typeNameStrings, ".") +} + +func convertParserTypeNameToString(typeVar *pg_query.TypeName) string { + typeNames := typeVar.GetNames() + finalTypeName := getQualifiedTypeName(typeNames) // type name can qualified table_name.column in case of %TYPE + if typeVar.PctType { // %TYPE declaration, so adding %TYPE for using it further + return finalTypeName + "%TYPE" + } + return finalTypeName +} + +/* +function ex - +CREATE OR REPLACE FUNCTION public.process_combined_tbl( + + p_id int, + p_c public.combined_tbl.c%TYPE, + p_bitt public.combined_tbl.bitt%TYPE, + .. + +) +parseTree- +parameters:{function_parameter:{name:"p_id" arg_type:{names:{string:{sval:"pg_catalog"}} names:{string:{sval:"int4"}} typemod:-1 location:66} +mode:FUNC_PARAM_DEFAULT}} parameters:{function_parameter:{name:"p_c" arg_type:{names:{string:{sval:"public"}} names:{string:{sval:"combined_tbl"}} +names:{string:{sval:"c"}} pct_type:true typemod:-1 location:87} mode:FUNC_PARAM_DEFAULT}} parameters:{function_parameter:{name:"p_bitt" +arg_type:{names:{string:{sval:"public"}} names:{string:{sval:"combined_tbl"}} names:{string:{sval:"bitt"}} pct_type:true typemod:-1 +location:136} mode:FUNC_PARAM_DEFAULT}} +*/ +func GetFuncParametersTypeNames(parseTree *pg_query.ParseResult) []string { + funcNode, _ := getCreateFuncStmtNode(parseTree) + parameters := funcNode.CreateFunctionStmt.GetParameters() + var paramTypeNames []string + for _, param := range parameters { + funcParam, ok := param.Node.(*pg_query.Node_FunctionParameter) + if ok { + paramType := funcParam.FunctionParameter.ArgType + paramTypeNames = append(paramTypeNames, convertParserTypeNameToString(paramType)) + } + } + return paramTypeNames +} diff --git a/yb-voyager/src/queryparser/traversal_plpgsql.go b/yb-voyager/src/queryparser/traversal_plpgsql.go index 2fa757930c..bc6a3c419e 100644 --- a/yb-voyager/src/queryparser/traversal_plpgsql.go +++ b/yb-voyager/src/queryparser/traversal_plpgsql.go @@ -28,6 +28,11 @@ const ( QUERY = "query" ACTION = "action" + DATUMS = "datums" + PLPGSQL_VAR = "PLpgSQL_var" + DATATYPE = "datatype" + TYPENAME = "typname" + PLPGSQL_TYPE = "PLpgSQL_type" PLPGSQL_FUNCTION = "PLpgSQL_function" ) @@ -49,32 +54,15 @@ These issues are majorly expressions, conditions, assignments, loop variables, r * */ func GetAllPLPGSQLStatements(query string) ([]string, error) { - parsedJson, err := ParsePLPGSQLToJson(query) + parsedJson, parsedJsonMap, err := getParsedJsonMap(query) if err != nil { - log.Infof("error in parsing the stmt-%s to json: %v", query, err) return []string{}, err } - if parsedJson == "" { - return []string{}, nil - } - var parsedJsonMapList []map[string]interface{} - //Refer to the queryparser.traversal_plpgsql.go for example and sample parsed json - log.Debugf("parsing the json string-%s of stmt-%s", parsedJson, query) - err = json.Unmarshal([]byte(parsedJson), &parsedJsonMapList) - if err != nil { - return []string{}, fmt.Errorf("error parsing the json string of stmt-%s: %v", query, err) - } - - if len(parsedJsonMapList) == 0 { - return []string{}, nil - } - - parsedJsonMap := parsedJsonMapList[0] function := parsedJsonMap[PLPGSQL_FUNCTION] parsedFunctionMap, ok := function.(map[string]interface{}) if !ok { - return []string{}, fmt.Errorf("error getting the PlPgSQL_Function field in parsed json-%s", parsedJson) + return []string{}, fmt.Errorf("the PlPgSQL_Function field is not a map in parsed json-%s", parsedJson) } actions := parsedFunctionMap[ACTION] @@ -228,3 +216,194 @@ func formatExprQuery(q string) string { } return q } + +func getParsedJsonMap(query string) (string, map[string]interface{}, error) { + parsedJson, err := ParsePLPGSQLToJson(query) + if err != nil { + log.Infof("error in parsing the stmt-%s to json: %v", query, err) + return parsedJson, nil, err + } + if parsedJson == "" { + return "", nil, nil + } + var parsedJsonMapList []map[string]interface{} + //Refer to the queryparser.traversal_plpgsql.go for example and sample parsed json + log.Debugf("parsing the json string-%s of stmt-%s", parsedJson, query) + err = json.Unmarshal([]byte(parsedJson), &parsedJsonMapList) + if err != nil { + return parsedJson, nil, fmt.Errorf("error parsing the json string of stmt-%s: %v", query, err) + } + + if len(parsedJsonMapList) == 0 { + return parsedJson, nil, nil + } + + return parsedJson, parsedJsonMapList[0], nil +} + +/* +example - +CREATE FUNCTION public.get_employeee_salary(emp_id employees.employee_id%TYPE) RETURNS employees.salary%Type + + LANGUAGE plpgsql + AS $$ + +DECLARE + + emp_salary employees.salary%TYPE; + +BEGIN + + SELECT salary INTO emp_salary + FROM employees + WHERE employee_id = emp_id; + RETURN emp_salary; + +END; +$$; +[ + + { + "PLpgSQL_function": { + "datums": [ + { + "PLpgSQL_var": { + "refname": "emp_id", + "datatype": { + "PLpgSQL_type": { + "typname": "UNKNOWN" + } + } + } + }, + { + "PLpgSQL_var": { + "refname": "found", + "datatype": { + "PLpgSQL_type": { + "typname": "UNKNOWN" + } + } + } + }, + { + "PLpgSQL_var": { + "refname": "emp_salary", + "lineno": 3, + "datatype": { + "PLpgSQL_type": { + "typname": "employees.salary%TYPE" + } + } + } + }, + { + "PLpgSQL_row": { + "refname": "(unnamed row)", + "lineno": 5, + "fields": [ + { + "name": "emp_salary", + "varno": 2 + } + ] + } + } + ],"action": { + .... + } + } + }, + + Caveats: + 1. Not returning typename for variables in function parameter from this function (in correct in json as UNKNOWN), for that using the GetTypeNamesFromFuncParameters() + 2. Not returning the return type from this function (not available in json), for that using the GetReturnTypeOfFunc() +*/ +func GetAllTypeNamesInPlpgSQLStmt(query string) ([]string, error) { + parsedJson, parsedJsonMap, err := getParsedJsonMap(query) + if err != nil { + return []string{}, nil + } + function := parsedJsonMap[PLPGSQL_FUNCTION] + parsedFunctionMap, ok := function.(map[string]interface{}) + if !ok { + return []string{}, fmt.Errorf("the PlPgSQL_Function field is not a map in parsed json-%s", parsedJson) + } + + datums := parsedFunctionMap[DATUMS] + datumList, isList := datums.([]interface{}) + if !isList { + return []string{}, fmt.Errorf("type names datums field is not list in parsed json-%s", parsedJson) + } + + var typeNames []string + for _, datum := range datumList { + datumMap, ok := datum.(map[string]interface{}) + if !ok { + log.Errorf("datum is not a map-%v", datum) + continue + } + for key, val := range datumMap { + switch key { + case PLPGSQL_VAR: + typeName, err := getTypeNameFromPlpgSQLVar(val) + if err != nil { + log.Errorf("not able to get typename from PLPGSQL_VAR(%v): %v", val, err) + continue + } + typeNames = append(typeNames, typeName) + } + } + } + return typeNames, nil +} + +/* +example of PLPGSQL_VAR - + + "PLpgSQL_var": { + "refname": "tax_rate", + "lineno": 3, + "datatype": { + "PLpgSQL_type": { + "typname": "employees.tax_rate%TYPE" + } + } + } +*/ +func getTypeNameFromPlpgSQLVar(plpgsqlVar interface{}) (string, error) { + //getting the map of of PLpgSQL_Var json + valueMap, ok := plpgsqlVar.(map[string]interface{}) + if !ok { + return "", fmt.Errorf("PLPGSQL_VAR is not a map-%v", plpgsqlVar) + } + + //getting the "datatype" field of PLpgSQL_Var json + datatype, ok := valueMap[DATATYPE] + if !ok { + return "", fmt.Errorf("datatype is not in the PLPGSQL_VAR map-%v", valueMap) + } + + datatypeValueMap, ok := datatype.(map[string]interface{}) + if !ok { + return "", fmt.Errorf("datatype is not a map-%v", datatype) + } + + plpgsqlType, ok := datatypeValueMap[PLPGSQL_TYPE] + if !ok { + return "", fmt.Errorf("PLPGSQL_Type is not in the datatype map-%v", datatypeValueMap) + } + + typeValueMap, ok := plpgsqlType.(map[string]interface{}) + if !ok { + return "", fmt.Errorf("PLPGSQL_Type is not a map-%v", plpgsqlType) + } + + typeName, ok := typeValueMap[TYPENAME] + if !ok { + return "", fmt.Errorf("typname is not in the PLPGSQL_Type map-%v", typeValueMap) + } + + return typeName.(string), nil + +}