Skip to content

pq: unterminated dollar-quoted string at or near "$BODY$ #590

@REASY

Description

@REASY

Seems like x-multi-statement=true is causing migrate to fail with error: migration failed: unterminated dollar-quoted string at or near "$BODY$

Steps to Reproduce

  1. My migrations look like
CREATE OR REPLACE FUNCTION add_column(target REGCLASS)
  RETURNS VOID AS $BODY$
DECLARE
table_name TEXT := QUOTE_IDENT(target :: TEXT);
BEGIN
EXECUTE 'ALTER TABLE ' || table_name ||
        ' ADD COLUMN IF NOT EXISTS col_id INT4 NOT NULL';
END;
$BODY$
LANGUAGE plpgsql;
  1. I ran migrate with the following options, please note x-multi-statement=true:
docker run -v /tmp/migrations:/migrations --network host -i 9df23b0b252d -path /migrations/ -database 'postgres://postgres:@localhost:5433/test?sslmode=disable&x-multi-statement=true' up

9df23b0b252d is an image id built at commit 3dfb0ff

  1. See error error: migration failed: unterminated dollar-quoted string at or near "$BODY$
    image

Migrate Version
4.14.1-43-g3dfb0ff, running it as docker container built at commit 3dfb0ff

Loaded Source Drivers
godoc-vfs, gcs, file, s3, github, github-ee, gitlab, go-bindata, bitbucket

Loaded Database Drivers
postgres, clickhouse, cockroachdb, firebird, mongodb, mongodb+srv, sqlserver, postgresql, stub, crdb-postgres, mysql, neo4j, pgx, redshift, spanner, cassandra, cockroach, firebirdsql

In case if I run the migration without x-multi-statement=true it works fine:
image

Also I can create that function via psql without any issue:
image

Attachments:
migrations.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdatabaseUpdates database drivershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions