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

Dollar-quoted PostgreSQL function definitions are parsed incorrectly in some situations #1238

Closed
arlampin opened this issue Mar 11, 2016 · 1 comment

Comments

@arlampin
Copy link

@arlampin arlampin commented Mar 11, 2016

What version of Flyway are you using?

4.0

What database are you using (type & version)?

PostgreSQL 9.5 and 9.4

What operating system are you using?

Linux

What did you do?

Using the following SQL

CREATE TABLE sometable1 (
  id        SERIAL PRIMARY KEY,
  somefield TEXT CHECK (somefield ~ E'.')
);

CREATE OR REPLACE FUNCTION testfun1()
  RETURNS TEXT AS $$
BEGIN
  RETURN E'foo';
END;
$$ LANGUAGE 'plpgsql';

fails with

  Migration V1__Test.sql failed
  -----------------------------
  SQL State  : 42601
  Error Code : 0
  Message    : ERROR: unterminated dollar-quoted string at or near "$$
  BEGIN
    RETURN E'foo'"
    Position: 59
  Location   : src/main/resources/migrations/V1__Test.sql 
  Line       : 1

but

CREATE TABLE sometable1 (
  id        SERIAL PRIMARY KEY,
  somefield TEXT CHECK (somefield ~ E'.')
);

CREATE TABLE sometable2 (
  id        SERIAL PRIMARY KEY,
  somefield TEXT CHECK (somefield ~ E'.')
);

CREATE OR REPLACE FUNCTION testfun1()
  RETURNS TEXT AS $$
BEGIN
  RETURN E'foo';
END;
$$ LANGUAGE 'plpgsql';

doesn't, and neither does a version without escaped (E'') strings or a version with just the function definition alone.

Applying the migration directly with psql works.

@axelfontaine axelfontaine added this to the Flyway 4.0.1 milestone Mar 11, 2016
axelfontaine added a commit to flyway/flywaydb.org that referenced this issue May 5, 2016
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented May 5, 2016

Thanks! Fixed.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.