Skip to content

Commit 83050ec

Browse files
committed
refactor case conversion feature
1 parent c53c1c4 commit 83050ec

File tree

11 files changed

+26
-27
lines changed

11 files changed

+26
-27
lines changed

src/backend/access/transam/xlog.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5226,8 +5226,6 @@ BootStrapXLOG(uint32 data_checksum_version)
52265226
/* save database compatible level value */
52275227
ControlFile->dbmode = bootstrap_database_mode;
52285228
ControlFile->casemode = identifier_case_switch;
5229-
5230-
52315229

52325230
/* some additional ControlFile fields are set in WriteControlFile() */
52335231
WriteControlFile();
@@ -5425,7 +5423,7 @@ CleanupAfterArchiveRecovery(TimeLineID EndOfLogTLI, XLogRecPtr EndOfLog,
54255423
}
54265424
}
54275425

5428-
/* IvorySQL: BEGIN - case sensitive indentify
5426+
/* IvorySQL: BEGIN - case-sensitive indentifier support
54295427
* Read database compatibility mode from pg_control file
54305428
*
54315429
*/
@@ -5519,7 +5517,7 @@ void SetCaseGucOption(char* path)
55195517

55205518
dbstyle = GetDatabaseStyleFromControl(path);
55215519

5522-
//the pg mode does not need to set
5520+
/* PG mode leaves identifier_case_switch unchanged. */
55235521
if (DB_ORACLE == dbstyle)
55245522
{
55255523
int casemode;
@@ -5545,6 +5543,7 @@ void SetCaseGucOption(char* path)
55455543
(errmsg("Incorrect case conversion mode value \"%d\"", casemode)));
55465544
}
55475545
}
5546+
/* IvorySQL: END - case-sensitive identifier support */
55485547

55495548
/*
55505549
* Check to see if required parameters are set high enough on this server

src/backend/catalog/namespace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,7 +4420,8 @@ preprocessNamespacePath(const char *searchPath, Oid roleid,
44204420
char *curname = (char *) lfirst(l);
44214421
Oid namespaceId;
44224422

4423-
if ((compatible_db == ORA_PARSER && enable_case_switch && identifier_case_switch != NORMAL) ? /* IvorySQL: case sensitive indentify */
4423+
if ((compatible_db == ORA_PARSER && enable_case_switch &&
4424+
identifier_case_switch != NORMAL) ? /* IvorySQL: case-sensitive indentifier support */
44244425
pg_strcasecmp(curname, "$user") == 0 : strcmp(curname, "$user") == 0)
44254426
{
44264427
/* $user --- substitute namespace matching user name, if any */
@@ -5433,4 +5434,3 @@ get_nodefvalargposition(HeapTuple proctup, int pronargs)
54335434
}
54345435
return nodefvalargposition;
54355436
}
5436-

src/backend/parser/scansup.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ downcase_identifier(const char *ident, int len, bool warn, bool truncate)
5656
/*
5757
* SQL99 specifies Unicode-aware case normalization, which we don't yet
5858
* have the infrastructure for. Instead we use tolower() to provide a
59-
* locale-aware translation. However, there are some locales where this
60-
* is not right either (eg, Turkish may do strange things with 'i' and
61-
* 'I'). Our current compromise is to use tolower() for characters with
62-
* the high bit set, as long as they aren't part of a multi-byte
63-
* character, and use an ASCII-only downcasing for 7-bit characters.
59+
* locale-aware translation. However, in some locales (for example,
60+
* Turkish with 'i' and 'I') this still is not correct. Our compromise is
61+
* to use toupper() for characters with the high bit set, as long as they
62+
* aren't part of a multi-byte character, and use an ASCII-only approach
63+
* for 7-bit characters.
6464
*/
6565
for (i = 0; i < len; i++)
6666
{

src/backend/tcop/backend_startup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
797797

798798
if (strcmp(nameptr, "database") == 0)
799799
{
800-
/* Oracle compatibility tranfor upper to lower */
800+
/* Oracle compatibility: transform uppercase identifiers to lowercase. */
801801
char *database_name = pstrdup(valptr);
802802

803803
if (ORA_PARSER == compatible_db && database_name != NULL)
@@ -850,7 +850,7 @@ ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
850850
}
851851
else if (strcmp(nameptr, "user") == 0)
852852
{
853-
/* Oracle compatibility tranfor upper to lower */
853+
/* Oracle compatibility: transform uppercase identifiers to lowercase. */
854854
char *user_name = pstrdup(valptr);
855855

856856
if (ORA_PARSER == compatible_db && user_name != NULL)

src/backend/utils/misc/ivy_guc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static struct config_bool Ivy_ConfigureNamesBool[] =
116116
{
117117
/* Not for general use --- used by pg_dump */
118118
{"ivorysql.identifier_case_from_pg_dump", PGC_USERSET, UNGROUPED,
119-
gettext_noop("Shows whether the identifer with quote is from pg dump."),
119+
gettext_noop("Shows whether the identifier with quotes is from pg dump."),
120120
NULL,
121121
GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
122122
},

src/bin/initdb/initdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,7 +3320,7 @@ initialize_data_directory(void)
33203320
make_template0(cmdfd);
33213321

33223322
make_postgres(cmdfd);
3323-
3323+
33243324
make_ivorysql(cmdfd);
33253325

33263326
PG_CMD_CLOSE();
@@ -3691,7 +3691,7 @@ main(int argc, char *argv[])
36913691
if (strncmp(username, "pg_", 3) == 0)
36923692
pg_fatal("superuser name \"%s\" is disallowed; role names cannot begin with \"pg_\"", username);
36933693

3694-
/* Oracle compatibility username transfor upper to lower */
3694+
/* Oracle compatibility: transform uppercase usernames to lowercase. */
36953695
if (database_mode == DB_ORACLE && username != NULL
36963696
&& is_all_upper(username, strlen(username)))
36973697
{

src/oracle_test/regress/expected/case_conversion.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- 1). If the alphas in the identifier quoted by double quotes are all the upper case, convert the upper case to the lower case.
44
-- 2). If the alphas in the identifier quoted by double quotes are all the lower case, convert the lower case to the upper case.
55
-- 3). If the alphas in the identifier quoted by double quotes are case-mixed, leave the identifier unchanged.
6-
-- 2. if guc parameter "identifier_case_switch" value is "lowcase", convert all identifiers to the lower case.
6+
-- 2. if guc parameter "identifier_case_switch" value is "lowercase", convert all identifiers to the lowercase.
77
-- 3. if guc parameter "identifier_case_switch" value is "normal", The rules for converting identifiers are the same as for native PG.
88
----1. "identifier_case_switch" value is "interchange"
99
SET ivorysql.enable_case_switch = true;

src/oracle_test/regress/expected/case_conversion_1.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- 1). If the alphas in the identifier quoted by double quotes are all the upper case, convert the upper case to the lower case.
44
-- 2). If the alphas in the identifier quoted by double quotes are all the lower case, convert the lower case to the upper case.
55
-- 3). If the alphas in the identifier quoted by double quotes are case-mixed, leave the identifier unchanged.
6-
-- 2. if guc parameter "identifier_case_switch" value is "lowcase", convert all identifiers to the lower case.
6+
-- 2. if guc parameter "identifier_case_switch" value is "lowercase", convert all identifiers to the lowercase.
77
-- 3. if guc parameter "identifier_case_switch" value is "normal", The rules for converting identifiers are the same as for native PG.
88
----1. "identifier_case_switch" value is "interchange"
99
SET ivorysql.enable_case_switch = true;

src/oracle_test/regress/expected/case_conversion_2.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- 1). If the alphas in the identifier quoted by double quotes are all the upper case, convert the upper case to the lower case.
44
-- 2). If the alphas in the identifier quoted by double quotes are all the lower case, convert the lower case to the upper case.
55
-- 3). If the alphas in the identifier quoted by double quotes are case-mixed, leave the identifier unchanged.
6-
-- 2. if guc parameter "identifier_case_switch" value is "lowcase", convert all identifiers to the lower case.
6+
-- 2. if guc parameter "identifier_case_switch" value is "lowercase", convert all identifiers to the lowercase.
77
-- 3. if guc parameter "identifier_case_switch" value is "normal", The rules for converting identifiers are the same as for native PG.
88
----1. "identifier_case_switch" value is "interchange"
99
SET ivorysql.enable_case_switch = true;

src/oracle_test/regress/sql/case_conversion.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- 1). If the alphas in the identifier quoted by double quotes are all the upper case, convert the upper case to the lower case.
44
-- 2). If the alphas in the identifier quoted by double quotes are all the lower case, convert the lower case to the upper case.
55
-- 3). If the alphas in the identifier quoted by double quotes are case-mixed, leave the identifier unchanged.
6-
-- 2. if guc parameter "identifier_case_switch" value is "lowcase", convert all identifiers to the lower case.
6+
-- 2. if guc parameter "identifier_case_switch" value is "lowercase", convert all identifiers to the lowercase.
77
-- 3. if guc parameter "identifier_case_switch" value is "normal", The rules for converting identifiers are the same as for native PG.
88

99
----1. "identifier_case_switch" value is "interchange"

0 commit comments

Comments
 (0)