Skip to content

v_generate_tbl_ddl: Apostrophes not escaped in table comments #726

@outcomes-dale-sedivec

Description

@outcomes-dale-sedivec

I have a multi-line table comment, such as

COMMENT ON TABLE foo IS '
    Roses are red
    Violets are blue
    Redshift doesn''t mind long comments
    And so shouldn''t you
';

When this is exported via v_generate_tbl_ddl, it comes out as:

COMMENT ON table foo IS '
    Roses are red
    Violets are blue
    Redshift doesn't mind long comments
    And so shouldn't you
';

Notice that both contractions are no longer correctly doubling up '', which results in a syntax error when I try to run the generated DDL. I expected the generated DDL to correctly escape these quotes in a comment.

I haven't had time to look into this, including:

  • Whether it matters that there are exactly a balanced pair of apostrophes, or whether this would work with just one apostrophe, or if you just need more than one apostrophe
  • Whether it matters that it's multi-line
  • Whether it could affect e.g. column comments

Thanks for giving us a way to get DDL out of Redshift!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions