Skip to content

Commit 1d078e8

Browse files
zhrt123my-ship-it
authored andcommitted
Update orafce to 4.9.2
Update orafce to the latest version for further work: to support raw type in GPDB. (raw is one of the types in Oracle, which is the same as bytea.) - cherry-pick the previous modification for orafce to fit GPDB. - remove decode() supported by orafce, since they have already been implemented in GPDB. - enable set `protransform` in `pg_proc` (this behavior is disabled in 3.13), since the bug for setting GUC is fixed. - enable set `typstorage` in `pg_type` with `set allow_system_table_mods=true`. Changes with version 3.13: - changes the storage type from `plain` to `extended` for varchar2 and nvarchar2. `plain` specifies that data of the type will always be stored in-line and not compressed. `extended` specifies that the system will first try to compress a long data value, and will move the value out of the main table row if it's still too long. - move objects from pg_catalog/public to Oracle schema to avoid polluting these namespaces. Refer [commit](orafce/orafce@86a1b51) - varchar2 substr: - use oracle_substrb3 instead of bytea_substr - use oracle_substrb2 instead of bytea_substr_no_len - add dbms_sql schema, which provides interfaces to use dynamic SQL to parse any DML or DDL statement using PL/SQL. - add regexp function - add greatest function - add least function - add oracle.unistr - add oracle.translate_oracle_modifiers - add oracle.sys_guid - add oracle.to_char - add oracle.mod - add oracle.remainder - add dbms_utility.get_time - guarantee function parallel safe (useless for gp) User behavior changes: - user needs to set search_path to oracle to use functions in orafce: `set search_path = public, oracle;`. Upgrade from 3.13: - Users could still use 3.13 orafce in the latest GP7 or upgrade to 4.9 by `alter extension orafce update to '4.9'`. - After the upgrade from 3.13, the function/type in public/pg_catalog namespace will be moved to oracle namespace. Users who want to use these functions/types without code change could set search_path like `set search_path = public, oracle`.
1 parent 09d27ed commit 1d078e8

26 files changed

Lines changed: 4189 additions & 309 deletions

gpcontrib/orafce/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ REGRESS = orafce\
8484
nlssort\
8585
dbms_random\
8686
regexp_func\
87+
gp_partition_by\
88+
gp_distributed_by\
8789
dbms_sql
8890

8991
#REGRESS_OPTS = --load-language=plpgsql --schedule=parallel_schedule --encoding=utf8
9092
REGRESS_OPTS = --schedule=parallel_schedule --encoding=utf8
93+
REGRESS_OPTS += --init-file=init_file
9194

9295
# override CFLAGS += -Wextra -Wimplicit-fallthrough=0
9396

gpcontrib/orafce/README.gp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# How to update repo by subtree
2+
3+
1. Add the repo URL as a git remote.
4+
```
5+
git remote add -f orafce_remote https://github.com/orafce/orafce.git
6+
```
7+
8+
2. Clone the repo to a directory as a subtree.
9+
```
10+
git subtree add --prefix gpcontrib/orafce orafce_remote master --squash
11+
```
12+
13+
3. To update the subtree later:
14+
```
15+
git fetch orafce_remote master
16+
git subtree pull --prefix gpcontrib/orafce orafce_remote master --squash
17+
```
18+
19+
4. Update subtree to a specific commit.
20+
```
21+
git subtree merge --prefix gpcontrib/orafce --squash commit_id
22+
```

gpcontrib/orafce/expected/files.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ NOTICE: [11] >>[1=1, 2=2, 3=3, 4=4, 5=5]<<
172172
NOTICE: >>1234<<
173173
NOTICE: >>5678<<
174174
NOTICE: >>90<<
175-
NOTICE: finish no data found
175+
NOTICE: finish no data found
176176
NOTICE: is_open = t
177177
NOTICE: is_open = f
178178
read_file
@@ -237,7 +237,7 @@ NOTICE: [11] >>[1=1, 2=2, 3=3, 4=4, 5=5]<<
237237
NOTICE: >>1234<<
238238
NOTICE: >>5678<<
239239
NOTICE: >>90<<
240-
NOTICE: finish no data found
240+
NOTICE: finish no data found
241241
NOTICE: is_open = t
242242
NOTICE: is_open = f
243243
read_file

gpcontrib/orafce/expected/files_1.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ NOTICE: [11] >>[1=1, 2=2, 3=3, 4=4, 5=5]<<
172172
NOTICE: >>1234<<
173173
NOTICE: >>5678<<
174174
NOTICE: >>90<<
175-
NOTICE: finish no data found
175+
NOTICE: finish no data found
176176
NOTICE: is_open = t
177177
NOTICE: is_open = f
178178
read_file
@@ -237,7 +237,7 @@ NOTICE: [11] >>[1=1, 2=2, 3=3, 4=4, 5=5]<<
237237
NOTICE: >>1234<<
238238
NOTICE: >>5678<<
239239
NOTICE: >>90<<
240-
NOTICE: finish no data found
240+
NOTICE: finish no data found
241241
NOTICE: is_open = t
242242
NOTICE: is_open = f
243243
read_file
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- test distributed by
2+
CREATE TABLE t1 (str oracle.varchar2(30)) DISTRIBUTED BY (str);
3+
INSERT INTO t1 VALUES ('abc');
4+
SELECT * FROM t1;
5+
str
6+
-----
7+
abc
8+
(1 row)
9+
10+
CREATE TABLE t2 (str oracle.nvarchar2(30)) DISTRIBUTED BY (str);
11+
INSERT INTO t2 VALUES ('abc');
12+
SELECT * FROM t2;
13+
str
14+
-----
15+
abc
16+
(1 row)
17+
18+
DROP TABLE t1;
19+
DROP TABLE t2;
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
-- test partition by list
2+
CREATE TABLE t3 (
3+
str oracle.varchar2(30)
4+
) PARTITION BY LIST (str)
5+
(
6+
PARTITION t3_1 VALUES ('a', 'b'),
7+
PARTITION t3_2 VALUES ('c')
8+
);
9+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'str' as the Greenplum Database data distribution key for this table.
10+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
11+
INSERT INTO t3 VALUES ('a'), ('b'), ('c');
12+
SELECT * FROM t3 ORDER BY str;
13+
str
14+
-----
15+
a
16+
b
17+
c
18+
(3 rows)
19+
20+
\d+ t3
21+
Partitioned table "public.t3"
22+
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
23+
--------+---------------------+-----------+----------+---------+----------+--------------+-------------
24+
str | oracle.varchar2(30) | | | | extended | |
25+
Partition key: LIST (str)
26+
Partitions: t3_1_prt_t3_1 FOR VALUES IN ('a', 'b'),
27+
t3_1_prt_t3_2 FOR VALUES IN ('c')
28+
Distributed by: (str)
29+
30+
CREATE TABLE t4 (
31+
str oracle.nvarchar2(30)
32+
) PARTITION BY LIST (str)
33+
(
34+
PARTITION t4_1 VALUES ('a', 'b'),
35+
PARTITION t4_2 VALUES ('c')
36+
);
37+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'str' as the Greenplum Database data distribution key for this table.
38+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
39+
INSERT INTO t4 VALUES ('a'), ('b'), ('c');
40+
SELECT * FROM t4 ORDER BY str;
41+
str
42+
-----
43+
a
44+
b
45+
c
46+
(3 rows)
47+
48+
\d+ t4
49+
Partitioned table "public.t4"
50+
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
51+
--------+----------------------+-----------+----------+---------+----------+--------------+-------------
52+
str | oracle.nvarchar2(30) | | | | extended | |
53+
Partition key: LIST (str)
54+
Partitions: t4_1_prt_t4_1 FOR VALUES IN ('a', 'b'),
55+
t4_1_prt_t4_2 FOR VALUES IN ('c')
56+
Distributed by: (str)
57+
58+
-- test partition by hash
59+
CREATE TABLE t5 (
60+
str oracle.varchar2(30)
61+
) PARTITION BY HASH (str);
62+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'str' as the Greenplum Database data distribution key for this table.
63+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
64+
CREATE TABLE t5_1 PARTITION OF t5 FOR VALUES WITH (MODULUS 3, REMAINDER 0);
65+
NOTICE: table has parent, setting distribution columns to match parent table
66+
CREATE TABLE t5_2 PARTITION OF t5 FOR VALUES WITH (MODULUS 3, REMAINDER 1);
67+
NOTICE: table has parent, setting distribution columns to match parent table
68+
CREATE TABLE t5_3 PARTITION OF t5 FOR VALUES WITH (MODULUS 3, REMAINDER 2);
69+
NOTICE: table has parent, setting distribution columns to match parent table
70+
INSERT INTO t5 VALUES ('a'), ('b'), ('c');
71+
SELECT * FROM t5_1 ORDER BY str;
72+
str
73+
-----
74+
b
75+
(1 row)
76+
77+
SELECT * FROM t5_2 ORDER BY str;
78+
str
79+
-----
80+
(0 rows)
81+
82+
SELECT * FROM t5_3 ORDER BY str;
83+
str
84+
-----
85+
a
86+
c
87+
(2 rows)
88+
89+
\d+ t5
90+
Partitioned table "public.t5"
91+
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
92+
--------+---------------------+-----------+----------+---------+----------+--------------+-------------
93+
str | oracle.varchar2(30) | | | | extended | |
94+
Partition key: HASH (str)
95+
Partitions: t5_1 FOR VALUES WITH (modulus 3, remainder 0),
96+
t5_2 FOR VALUES WITH (modulus 3, remainder 1),
97+
t5_3 FOR VALUES WITH (modulus 3, remainder 2)
98+
Distributed by: (str)
99+
100+
CREATE TABLE t6 (
101+
str oracle.nvarchar2(30)
102+
) PARTITION BY HASH (str);
103+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'str' as the Greenplum Database data distribution key for this table.
104+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
105+
CREATE TABLE t6_1 PARTITION OF t6 FOR VALUES WITH (MODULUS 3, REMAINDER 0);
106+
NOTICE: table has parent, setting distribution columns to match parent table
107+
CREATE TABLE t6_2 PARTITION OF t6 FOR VALUES WITH (MODULUS 3, REMAINDER 1);
108+
NOTICE: table has parent, setting distribution columns to match parent table
109+
CREATE TABLE t6_3 PARTITION OF t6 FOR VALUES WITH (MODULUS 3, REMAINDER 2);
110+
NOTICE: table has parent, setting distribution columns to match parent table
111+
INSERT INTO t6 VALUES ('a'), ('b'), ('c');
112+
SELECT * FROM t6_1 ORDER BY str;
113+
str
114+
-----
115+
b
116+
(1 row)
117+
118+
SELECT * FROM t6_2 ORDER BY str;
119+
str
120+
-----
121+
(0 rows)
122+
123+
SELECT * FROM t6_3 ORDER BY str;
124+
str
125+
-----
126+
a
127+
c
128+
(2 rows)
129+
130+
\d+ t6
131+
Partitioned table "public.t6"
132+
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
133+
--------+----------------------+-----------+----------+---------+----------+--------------+-------------
134+
str | oracle.nvarchar2(30) | | | | extended | |
135+
Partition key: HASH (str)
136+
Partitions: t6_1 FOR VALUES WITH (modulus 3, remainder 0),
137+
t6_2 FOR VALUES WITH (modulus 3, remainder 1),
138+
t6_3 FOR VALUES WITH (modulus 3, remainder 2)
139+
Distributed by: (str)
140+
141+
DROP TABLE t3;
142+
DROP TABLE t4;
143+
DROP TABLE t5;
144+
DROP TABLE t6;

gpcontrib/orafce/expected/nlssort.out

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ SELECT getdatabaseencoding() <> 'UTF8' OR
88
\quit
99
\endif
1010
\set ECHO none
11+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'name' as the Greenplum Database data distribution key for this table.
12+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
1113
name
1214
--------
1315
brown
@@ -29,8 +31,14 @@ SELECT getdatabaseencoding() <> 'UTF8' OR
2931

3032
(1 row)
3133

32-
ERROR: failed to set the requested LC_COLLATE value [invalid]
33-
CONTEXT: SQL function "nlssort" statement 1
34+
name
35+
--------
36+
Purple
37+
brown
38+
red
39+
yellow
40+
(4 rows)
41+
3442
set_nls_sort
3543
--------------
3644

@@ -51,16 +59,16 @@ CONTEXT: SQL function "nlssort" statement 1
5159

5260
name
5361
--------
54-
brown
5562
Purple
63+
brown
5664
red
5765
yellow
5866
(4 rows)
5967

6068
name
6169
--------
62-
brown
6370
Purple
71+
brown
6472
red
6573
yellow
6674

0 commit comments

Comments
 (0)