!4248 修复mysql兼容模式下,大小写敏感时,\d+ 大写表名报表名不存在的问题

Merge pull request !4248 from zlh21343/zhanglh
This commit is contained in:
opengauss_bot
2023-10-16 11:22:52 +00:00
committed by Gitee
2 changed files with 18 additions and 1 deletions

View File

@ -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, ".*");

View File

@ -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,