Skip to content

Commit ef1ded8

Browse files
Move schema elements specific for Oracle Database 21 and higher to a
separate script for ease of maintenance.
1 parent 30ec927 commit ef1ded8

File tree

3 files changed

+50
-34
lines changed

3 files changed

+50
-34
lines changed

tests/create_schema.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2023, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -47,6 +47,9 @@
4747
main_password=test_env.get_main_password(),
4848
proxy_user=test_env.get_proxy_user(),
4949
proxy_password=test_env.get_proxy_password())
50+
if test_env.get_server_version() >= (21, 0):
51+
test_env.run_sql_script(conn, "create_schema_21",
52+
main_user=test_env.get_main_user())
5053
if test_env.is_on_oracle_cloud(conn):
5154
test_env.run_sql_script(conn, "create_schema_cloud",
5255
main_user=test_env.get_main_user())

tests/sql/create_schema.sql

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -313,35 +313,9 @@ create table &main_user..PlsqlSessionCallbacks (
313313
)
314314
/
315315

316-
declare
317-
t_Version number;
318-
begin
319-
320-
select to_number(substr(version, 1, instr(version, '.') - 1))
321-
into t_Version
322-
from product_component_version
323-
where product like 'Oracle Database%';
324-
325-
if t_Version >= 21 then
326-
execute immediate 'create table &main_user..TestJson (' ||
327-
' IntCol number(9) not null,' ||
328-
' JsonCol json not null' ||
329-
')';
330-
end if;
331-
332-
end;
333-
/
334-
335316
-- create queue table and queues for testing advanced queuing
336-
declare
337-
t_Version number;
338317
begin
339318

340-
select to_number(substr(version, 1, instr(version, '.') - 1))
341-
into t_Version
342-
from product_component_version
343-
where product like 'Oracle Database%';
344-
345319
dbms_aqadm.create_queue_table('&main_user..BOOK_QUEUE_TAB',
346320
'&main_user..UDT_BOOK');
347321
dbms_aqadm.create_queue('&main_user..TEST_BOOK_QUEUE',
@@ -361,13 +335,6 @@ begin
361335
dbms_aqadm.add_subscriber('&main_user..BOOK_QUEUE_MULTI',
362336
sys.aq$_agent('Sub1', null, null));
363337

364-
if t_Version >= 21 then
365-
dbms_aqadm.create_queue_table('&main_user..JSON_QUEUE_TAB', 'JSON');
366-
dbms_aqadm.create_queue('&main_user..TEST_JSON_QUEUE',
367-
'&main_user..JSON_QUEUE_TAB');
368-
dbms_aqadm.start_queue('&main_user..TEST_JSON_QUEUE');
369-
end if;
370-
371338
end;
372339
/
373340

tests/sql/create_schema_21.sql

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*-----------------------------------------------------------------------------
2+
* Copyright (c) 2023, Oracle and/or its affiliates.
3+
*
4+
* This software is dual-licensed to you under the Universal Permissive License
5+
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
6+
* 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
7+
* either license.*
8+
*
9+
* If you elect to accept the software under the Apache License, Version 2.0,
10+
* the following applies:
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* https://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*---------------------------------------------------------------------------*/
24+
25+
/*-----------------------------------------------------------------------------
26+
* create_schema_21.sql
27+
*
28+
* Performs the actual work of creating and populating the schemas with the
29+
* database objects used by the python-oracledb test suite that require Oracle
30+
* Database 21c or higher. It is executed by the Python script
31+
* create_schema.py.
32+
*---------------------------------------------------------------------------*/
33+
34+
create table &main_user..TestJson (
35+
IntCol number(9) not null,
36+
JsonCol json not null
37+
)
38+
/
39+
40+
begin
41+
dbms_aqadm.create_queue_table('&main_user..JSON_QUEUE_TAB', 'JSON');
42+
dbms_aqadm.create_queue('&main_user..TEST_JSON_QUEUE',
43+
'&main_user..JSON_QUEUE_TAB');
44+
dbms_aqadm.start_queue('&main_user..TEST_JSON_QUEUE');
45+
end;
46+
/

0 commit comments

Comments
 (0)