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

New notation to identify ansi char to make better clean code psql #7311

Closed
gladiston opened this issue Sep 21, 2022 · 3 comments
Closed

New notation to identify ansi char to make better clean code psql #7311

gladiston opened this issue Sep 21, 2022 · 3 comments

Comments

@gladiston
Copy link

A new predicative or notation to identify ansi string like:
old: while (position(ASCII_CHAR(13), str)>0) do...
new:while (position(#13, str)>0) do...
or new:while (position('\n', str)>0) do...

Just to make better clean code psql.

@mrotteveel
Copy link
Member

You can use x'0D', or if you really want it as ASCII, _ascii x'0D'. Although there might be a good use for a general escape mechanism, that would be better served by implementing SQL standard Unicode string literals.

@mrotteveel
Copy link
Member

mrotteveel commented Sep 21, 2022

Your second example cannot be implemented in that way, as that would change how literals work (a '\n' is two characters, a \ and a n, not a single character), and thus would break existing applications. As an aside, generally, the character escape \n is character 10/x0A, not character 13/x0D, which is generally escaped with \r.

@gladiston
Copy link
Author

gladiston commented Sep 21, 2022

You can use x'0D', or if you really want it as ASCII, _ascii x'0D'. Although there might be a good use for a general escape mechanism, that would be better served by implementing SQL standard Unicode string literals.

For a better world, less quotes in psql, I think ;-)
I know about hexa notation, but my intention is maximize clean code in psql.
The second way, I know that is hard and complex. I put only becase escape codes are much common in very languages. I don't expect implement it because its too complex.

@asfernandes asfernandes closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2022
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

No branches or pull requests

3 participants