From 384179b406612c962f34f069ffd40cbd006a9ab6 Mon Sep 17 00:00:00 2001 From: zhanglihui Date: Sat, 7 Oct 2023 02:57:12 -0700 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmysql=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=EF=BC=8C=E5=A4=A7=E5=B0=8F=E5=86=99?= =?UTF-8?q?=E6=95=8F=E6=84=9F=E6=97=B6=EF=BC=8C\d+=20=E5=A4=A7=E5=86=99?= =?UTF-8?q?=E8=A1=A8=E6=98=8E=E6=8A=A5=E8=A1=A8=E6=98=8E=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/pg_dump/dumputils.cpp | 8 +++++++- src/bin/psql/describe.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_dump/dumputils.cpp b/src/bin/pg_dump/dumputils.cpp index cb0c030fa..976ee456f 100644 --- a/src/bin/pg_dump/dumputils.cpp +++ b/src/bin/pg_dump/dumputils.cpp @@ -42,6 +42,8 @@ const char *gdatcompatibility = NULL; char* binary_upgrade_oldowner = NULL; char* binary_upgrade_newowner = NULL; +int dolphin_lower_case_table_names = -1; + #define MAX_ON_EXIT_NICELY 20 static struct { @@ -1177,7 +1179,11 @@ bool processSQLNamePattern(PGconn* conn, PQExpBuffer buf, const char* pattern, b } cp++; } else if (!inquotes && isupper((unsigned char)ch)) { - appendPQExpBufferChar(&namebuf, pg_tolower((unsigned char)ch)); + if (dolphin_lower_case_table_names == 0){ + appendPQExpBufferChar(&namebuf, ch); + } else { + appendPQExpBufferChar(&namebuf, pg_tolower((unsigned char)ch)); + } cp++; } else if (!inquotes && ch == '*') { appendPQExpBufferStr(&namebuf, ".*"); diff --git a/src/bin/psql/describe.cpp b/src/bin/psql/describe.cpp index 91618c52d..f3c384f54 100644 --- a/src/bin/psql/describe.cpp +++ b/src/bin/psql/describe.cpp @@ -74,6 +74,8 @@ static bool* generateTranslateColumns(int n, int truesz, int* trues); const char* ORIENTATION_TIMESERIES = "timeseries"; const char* TS_PSEUDO_DIST_COLUMN = "ts_pseudo_distcol"; +extern int dolphin_lower_case_table_names; + /* ---------------- * Handlers for various slash commands displaying some sort of list * of things in the database. @@ -1134,6 +1136,15 @@ bool describeTableDetails(const char* pattern, bool verbose, bool showSystem) PGresult* res = NULL; int i; + PGresult* res_lower_case_table_names = NULL; + res_lower_case_table_names = PSQLexec("select setting from pg_settings where name = 'dolphin.lower_case_table_names';", false); + if (PQntuples(res_lower_case_table_names) == 1){ + dolphin_lower_case_table_names = atoi(PQgetvalue(res_lower_case_table_names, 0, 0)); + } else { + dolphin_lower_case_table_names = -1; + } + PQclear(res_lower_case_table_names); + initPQExpBuffer(&buf); printfPQExpBuffer(&buf,