Sandor Molnar created KNOX-3436:
-----------------------------------

             Summary:  Move JDBC table provisioning to a pure SQL layer; drop 
the Java-side DDL parsing
                 Key: KNOX-3436
                 URL: https://issues.apache.org/jira/browse/KNOX-3436
             Project: Apache Knox
          Issue Type: Improvement
          Components: Server
    Affects Versions: 3.0.0
            Reporter: Sandor Molnar
             Fix For: 3.1.0


h4. Context

{{KnoxDatabase}} currently strips the license header, splits DDL on {{;}}, and 
runs a per-table {{tableExists}} guard. This Java-side splitting exists only 
for the two engines that can't self-handle idempotent creation: {{Derby}} (no 
IF NOT EXISTS, no multi-statement execute()) and {{Oracle}} (no IF NOT EXISTS). 
PostgreSQL/MySQL/MariaDB/HSQL already use CREATE TABLE IF NOT EXISTS.

Once Derby is dropped after KNOX-3401, the parsing can go away.

h4. Change

Make every engine's DDL self-idempotent and execute scripts directly:
- PG/MySQL/MariaDB/HSQL: keep CREATE TABLE IF NOT EXISTS (Postgres keeps its 
pg_advisory_lock wrapper).
- Oracle: wrap each CREATE TABLE in a PL/SQL block that swallows ORA-00955.
- Derby: gone.
- Derby alternative: to be defined

Then delete from {{KnoxDatabase/JDBCUtils}}: {{parseCreateTableStatements}}, 
{{removeLicenseHeader}}, {{extractTableName}}, 
{{createTableIfNotExists}}/{{createTablesIfNotExist}}, {{tableExists}}, 
{{normalizeIdentifier}}, and {{RemoteConfigDatabase's}} private duplicate.

This also lets us merge each service's DDL into one file per DB type: kept 
per-service so enabling core JDBC token-state never creates KnoxIDF tables.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to