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

Case sensitive names? #59

Open
mitar opened this issue Aug 18, 2019 · 2 comments
Open

Case sensitive names? #59

mitar opened this issue Aug 18, 2019 · 2 comments
Labels

Comments

@mitar
Copy link

mitar commented Aug 18, 2019

I am trying to make a tool which would automatically quote all identifiers to make them case sensitive. I thought of parsing end deparsing (using this node module) but I am realizing that all identifiers in the parsed tree are already lowercased. Is there some way to not do that? So to get parse tree with original string values?

@lfittl
Copy link
Member

lfittl commented Oct 24, 2019

Unfortunately thats not really feasible, since we depend on the Postgres parser logic - which will normalize identifiers if they are not escaped.

@mitar
Copy link
Author

mitar commented Oct 25, 2019

But you already patch it a bit, no? A simple change like this seems to work:

diff --git a/examples/simple.c b/examples/simple.c
index 1c513b1..5a27658 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -10,7 +10,7 @@
 size_t testCount = 7;
 const char* tests[] = {
   "SELECT 1",
-  "SELECT * FROM x WHERE z = 2",
+  "SELECT * FROM X WHERE Z = 2",
   "SELECT 5.41414",
   "SELECT $1",
   "SELECT ?",
diff --git a/src/postgres/src_backend_parser_scansup.c b/src/postgres/src_backend_parser_scansup.c
index 3925612..7bfc46a 100644
--- a/src/postgres/src_backend_parser_scansup.c
+++ b/src/postgres/src_backend_parser_scansup.c
@@ -88,11 +88,6 @@ downcase_identifier(const char *ident, int len, bool warn, bool truncate)
        for (i = 0; i < len; i++)
        {
                unsigned char ch = (unsigned char) ident[i];
-
-               if (ch >= 'A' && ch <= 'Z')
-                       ch += 'a' - 'A';
-               else if (enc_is_single_byte && IS_HIGHBIT_SET(ch) && isupper(ch))
-                       ch = tolower(ch);
                result[i] = (char) ch;
        }
        result[i] = '\0';

So exposing this somehow as a switch or something would be possible, or not?

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