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 quoting ($$) and single quoting (') errors when populating PostgreSQL dumps #2185

Closed
YasserHassan opened this issue Jul 18, 2015 · 3 comments
Labels

Comments

@YasserHassan
Copy link
Contributor

The error Syntax error: 7 ERROR: unterminated dollar-quoted string at or near "$$ (reported in #1128) that was fixed in #1450 seems did not account for all cases. It works when the dollar quoting is at the beginning of the line like this:

...
    AS
$$
    BEGIN
...

but produces the mentioned error when the same code above is written like below, which is generated by pg_dump and is a valid syntax as shown in the examples at CREATE FUNCTION:

...
    AS $$
    BEGIN
...

Also it does not work at all with the following quoting variations:

  • Dollar quoting with a tag such as $BODY$.
  • Single quoting instead of dollar quoting as produced by the '--disable-dollar-quoting' pg_dump option.

I tested that on version 2.0.16 but by looking into the code of version 2.1.1, it seems it's valid there too.

@DavertMik
Copy link
Member

Thanks. Looks like you deeply discovered this issue. Could you send PR for it?
Please send it to 2.1.x branch (or to 2.0 if you still use it)

@DavertMik DavertMik added the Db label Jul 19, 2015
YasserHassan added a commit to YasserHassan/Codeception that referenced this issue Jul 20, 2015
Fix Codeception#2185
The old code handled dollar-quoted blocks only if the $$ is at the beginning of a new line. This enhancement detects it anywhere and also detects if the $$ is part of a SQL standard string and ignores it.
@YasserHassan
Copy link
Contributor Author

@DavertMik, done for branch 2.0 for the case when $$ is not at the beginning of the line. Please notice that the tagged dollar quoting (e.g. $function$) and single quoting mentioned above are still unhandled. This fix at least can help when the development database is automatically dumped using `pg_dump' then populated to the testing database before testing.

I suggest adding these two points as known issues and limitations until if/when they are implemented.

@YasserHassan
Copy link
Contributor Author

@DavertMik could you please review this commit? The testing errors seem irrelevant.

Naktibalda added a commit that referenced this issue Jul 27, 2015
Fix #2185 when $$ not at line start ONLY
Naktibalda pushed a commit to Codeception/module-db that referenced this issue Sep 15, 2019
Fix Codeception/Codeception#2185
The old code handled dollar-quoted blocks only if the $$ is at the beginning of a new line. This enhancement detects it anywhere and also detects if the $$ is part of a SQL standard string and ignores it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants