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] Import schema for auto-generated column fails after Ora2Pg commit #355

Closed
shubham-yb opened this issue Sep 27, 2022 · 4 comments · Fixed by #506
Closed

[MYSQL] Import schema for auto-generated column fails after Ora2Pg commit #355

shubham-yb opened this issue Sep 27, 2022 · 4 comments · Fixed by #506
Assignees

Comments

@shubham-yb
Copy link
Contributor

This is the original ticket
#315

So an issue was put up on Ora2Pg and they implemented migration of auto-generated columns using triggers.
Commit

But now the import-schema fails with error.

Original schema:

CREATE TABLE auto_price (
	id INT,
	first_name VARCHAR(50),
	gender VARCHAR(50),
	price_dollar DECIMAL(7,2),
    price_pound DECIMAL(7,2) GENERATED ALWAYS AS (price_dollar * 0.22) STORED
);

Previously exported schema:

CREATE TABLE auto_price (
	id bigint,
	first_name varchar(50),
	gender varchar(50),
	price_dollar decimal(7,2),
	price_pound decimal(7,2)
) ;

Exported schema after commit:

CREATE TABLE auto_price (
	id bigint,
	first_name varchar(50),
	gender varchar(50),
	price_dollar decimal(7,2),
	price_pound decimal(7,2)
) ;
DROP TRIGGER IF EXISTS virt_col_auto_price_trigger ON auto_price CASCADE;

CREATE OR REPLACE FUNCTION fct_virt_col_auto_price_trigger() RETURNS trigger AS $BODY$
BEGIN
	NEW.price_pound = (NEW.price_dollar * 0.22);

RETURN NEW;
end
$BODY$
 LANGUAGE 'plpgsql' SECURITY DEFINER;

CREATE TRIGGER virt_col_auto_price_trigger
        BEFORE INSERT OR UPDATE ON auto_price FOR EACH ROW
        EXECUTE PROCEDURE fct_virt_col_auto_price_trigger();


Error while importing:

importing      TABLE      
    ERROR: unterminated dollar-quoted string at or near "$BODY$ BEGIN 	NEW.price_pound = (NEW.price_dollar * 0.22); " (SQLSTATE 42601)
    STATEMENT: CREATE OR REPLACE FUNCTION fct_virt_col_auto_price_trigger() RETURNS trigger AS $BODY$
BEGIN
	NEW.price_pound = (NEW.price_dollar * 0.22);
ERROR: unterminated dollar-quoted string at or near "$BODY$ BEGIN 	NEW.price_pound = (NEW.price_dollar * 0.22); " (SQLSTATE 42601)
@github-actions github-actions bot added the triage Needs to be triaged label Sep 27, 2022
@kneeraj kneeraj added GA1.0 and removed triage Needs to be triaged labels Sep 30, 2022
@amit-yb
Copy link
Contributor

amit-yb commented Oct 17, 2022

@shubham-yb Looks like @sanyamsinghal fixed this issue as part of #399 . Please, verify and close this issue.

@amit-yb amit-yb assigned shubham-yb and unassigned amit-yb Oct 17, 2022
@shubham-yb
Copy link
Contributor Author

@amit-yb @sanyamsinghal I'm still getting the issue.

Image

@amit-yb amit-yb removed the GA1.0 label Oct 17, 2022
@amit-yb amit-yb removed their assignment Oct 17, 2022
@sanyamsinghal
Copy link
Collaborator

Fix: change the parsing logic to lookahead parsing instead of based on kind of sql file

@sanyamsinghal
Copy link
Collaborator

@shubham-yb can you please verify this bug with main branch now. Changes merged in #506

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants