引用标识符大小写兼容
UDB-TX Oracle兼容版本新增三种引用标识符的大小写转换模式。通过guc参数“identifier_case_switch”选择转换模式,支持Oracle的引用标识符大小写兼容,
功能
大小写转换的三种模式(默认为interchange)
如果 guc参数identifier_case_switch值为normal
保持双引号所引用的标识符中的字母大小写不变。
如果 guc参数identifier_case_switch值为interchange:
如果双引号所引用的标识符中的字母全部为大写,则将大写转换为小写。
如果双引号所引用的标识符中的字母全部为小写,则将小写转换为大写。
如果用双引号引起来的标识符中的字母是大小写混合的,则保持标识符不变。
如果 guc参数identifier_case_switch值为lowercase
如果双引号所引用的标识符中的字母全部为大写,则将大写转换为小写。
如果用双引号引起来的标识符中的字母是大小写混合的,则保持标识符不变。
初始化数据库集簇时
在initdb程序中加入 -C选项设置大小写转换模式,-C对应的值为:
“normal” (”0”同义)
“interchange” ( “1”同义)
“lowercase” (”2”同义)
在初始化数据库集簇的过程中,将大小写转换模式保存到data目录的global/pg_control文件中。
用例
normal
unvdb=# SET unvdb_compatible_mode to oracle;
SET
unvdb=# SET unvdb_oracle.identifier_case_switch TO normal;
SET
unvdb=# CREATE TABLE "NORMAL_1"(c1 int, c2 int);
CREATE TABLE
unvdb=# CREATE TABLE "Normal_2"(c1 int, c2 int);
CREATE TABLE
unvdb=# CREATE TABLE "normal_3"(c1 int, c2 int);
CREATE TABLE
unvdb=# select * from "NORMAL_1";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "Normal_1";
ERROR: relation "Normal_1" does not exist
LINE 1: select * from "Normal_1";
unvdb=# select * from "normal_1";
ERROR: relation "normal" does not exist
LINE 1: select * from "normal";
unvdb=# select * from NORMAL_1;
ERROR: relation "normal_1" does not exist
LINE 1: select * from NORMAL_1;
unvdb=# select * from "Normal_2";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "NORMAL_2";
ERROR: relation "NORMAL_2" does not exist
LINE 1: select * from "NORMAL_2";
unvdb=# select * from "normal_2";
ERROR: relation "normal_2" does not exist
LINE 1: select * from "normal_2";
unvdb=# select * from Normal_2;
ERROR: relation "normal_2" does not exist
LINE 1: select * from Normal_2;
unvdb=# select * from "normal_3";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "NORMAL_3";
ERROR: relation "NORMAL_3" does not exist
LINE 1: select * from "NORMAL_3";
unvdb=# select * from "Normal_3";
ERROR: relation "Normal_3" does not exist
LINE 1: select * from "Normal_3";
unvdb=# drop table "NORMAL_1";
DROP TABLE
unvdb=# drop table "Normal_2";
DROP TABLE
unvdb=# drop table "normal_3";
DROP TABLE
interchange
unvdb=# SET unvdb_compatible_mode to oracle;
SET
unvdb=# SET unvdb_oracle.identifier_case_switch TO interchange;
SET
unvdb=# CREATE TABLE "INTER_CHANGE_1"(c1 int, c2 int);
CREATE TABLE
unvdb=# CREATE TABLE "Inter_Change_2"(c1 int, c2 int);
CREATE TABLE
unvdb=# CREATE TABLE "inter_change_3"(c1 int, c2 int);
CREATE TABLE
unvdb=# select * from "INTER_CHANGE_1";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "Inter_Change_1";
ERROR: relation "Inter_Change_1" does not exist
LINE 1: select * from "Inter_Change_1";
unvdb=# select * from "inter_change_1";
ERROR: relation "INTER_CHANGE_1" does not exist
LINE 1: select * from "inter_change_1";
unvdb=# select * from INTER_CHANGE_1;
c1 | c2
----+----
(0 rows)
unvdb=# select * from "Inter_Change_2";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "INTER_CHANGE_2";
ERROR: relation "inter_change_2" does not exist
LINE 1: select * from "INTER_CHANGE_2";
unvdb=# select * from "inter_change_2";
ERROR: relation "INTER_CHANGE_2" does not exist
LINE 1: select * from "inter_change_2";
unvdb=# select * from Inter_Change_2;
ERROR: relation "inter_change_2" does not exist
LINE 1: select * from Inter_Change_2;
unvdb=# select * from "inter_change_3";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "INTER_CHANGE_3";
ERROR: relation "inter_change_3" does not exist
LINE 1: select * from "INTER_CHANGE_3";
unvdb=# select * from "Inter_Change_3";
ERROR: relation "Inter_Change_3" does not exist
LINE 1: select * from "Inter_Change_3";
unvdb=# select * from inter_change_3;
ERROR: relation "inter_change_3" does not exist
LINE 1: select * from "INTER_CHANGE_3";
unvdb=# drop table "INTER_CHANGE_1";
DROP TABLE
unvdb=# drop table "Inter_Change_2";
DROP TABLE
unvdb=# drop table "inter_change_3";
DROP TABLE
lowercase
unvdb=# SET unvdb_compatible_mode to oracle;
SET
unvdb=# SET UDB-TX.enable_case_switch TO true;
SET
unvdb=# SET unvdb_oracle.identifier_case_switch TO lowercase;
SET
unvdb=# CREATE TABLE "LOWER_CASE_1"(c1 int, c2 int);
CREATE TABLE
unvdb=# CREATE TABLE "Lower_Case_2"(c1 int, c2 int);
CREATE TABLE
unvdb=# CREATE TABLE "lower_case_3"(c1 int, c2 int);
CREATE TABLE
unvdb=# select * from "LOWER_CASE_1";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "Lower_Case_1";
ERROR: relation "Lower_Case_1" does not exist
LINE 1: select * from "Lower_Case_1";
unvdb=# select * from "lower_case_1";
c1 | c2
----+----
(0 rows)
unvdb=# select * from LOWER_CASE_1;
c1 | c2
----+----
(0 rows)
unvdb=# select * from "Lower_Case_2";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "LOWER_CASE_2";
ERROR: relation "lower_case_2" does not exist
LINE 1: select * from "LOWER_CASE_2";
unvdb=# select * from "lower_case_2";
ERROR: relation "lower_case_2" does not exist
LINE 1: select * from "lower_case_2";
unvdb=# select * from Lower_Case_2;
ERROR: relation "lower_case_2" does not exist
LINE 1: select * from Lower_Case_2;
unvdb=# select * from "lower_case_3";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "LOWER_CASE_3";
c1 | c2
----+----
(0 rows)
unvdb=# select * from "Lower_Case_3";
ERROR: relation "Lower_Case_3" does not exist
LINE 1: select * from "Lower_Case_3";
unvdb=# select * from LOWER_CASE_3;
c1 | c2
----+----
(0 rows)
unvdb=# drop table "LOWER_CASE_1";
DROP TABLE
unvdb=# ddrop table "Lower_Case_2";
DROP TABLE
unvdb=# drop table "lower_case_3";
DROP TABLE