Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MySQL] Multiple declaration of variables in functions #708

Open
shubham-yb opened this issue Dec 23, 2022 · 0 comments
Open

[MySQL] Multiple declaration of variables in functions #708

shubham-yb opened this issue Dec 23, 2022 · 0 comments
Assignees
Labels
dep-issue Issues with dependencies

Comments

@shubham-yb
Copy link
Contributor

If we have a re-initialization of a variable in a function in MySQL using the set statement, the variable gets declared twice with different datatypes in the exported schema. This is due to the uncommenting of data-type mappings in our underlying tool's config file.

Sample source function:

drop function if exists xyz;

delimiter //
create function xyz()
returns varchar(10)
reads sql data
begin
    declare max_date date;
    set max_date=(SELECT CURRENT_DATE()
    );
    set @max_date=max_date;
    return max_date;
    end //
delimiter ;

select xyz();

Exported schema:

CREATE OR REPLACE FUNCTION xyz () RETURNS varchar AS $body$
DECLARE

max_date timestamp;max_date date;

BEGIN

    max_date = (SELECT CURRENT_DATE
    );
    max_date:=max_date;
    return max_date;
    end;
$body$
LANGUAGE PLPGSQL
SECURITY DEFINER
;

Workaround:

Remove the extra variable declaration from the exported files

@shubham-yb shubham-yb added documentation Improvements or additions to documentation dep-issue Issues with dependencies labels Dec 23, 2022
@github-actions github-actions bot added the triage Needs to be triaged label Dec 23, 2022
@shubham-yb shubham-yb removed the triage Needs to be triaged label Dec 23, 2022
@shubham-yb shubham-yb removed the documentation Improvements or additions to documentation label Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dep-issue Issues with dependencies
Projects
None yet
Development

No branches or pull requests

1 participant