IBM Db2 LUW 9.1: table DDL generation fails
Description
DB2/NT v9.1 (SQL09010): table DDL generation fails; CLP tests isolate -x and -xd as rejected DB2LK_GENERATE_DDL arguments
Summary
When table DDL is requested in DBeaver 26.2.0, the reporter observes this error in the DBeaver UI:
Error running DDL generation
SQL Error [38553]: Routine "SYSPROC.DB2LK_GENERATE_DDL"
(specific name "DB2LK_GENERATE_DDL") has returned an error SQLSTATE
with diagnostic text "Invalid input".
The attached DBeaver debug logs do not contain that UI error text. They do show the command string DBeaver passes to DB2LK_GENERATE_DDL and show that the same option pattern is used with both tested JDBC drivers:
-noview -e -x -xd -td <line break> -t <schema>.<table>
Direct DB2 CLP tests attached to this report isolate the relevant options on the same tested database:
- tested argument sets without
-x/-xdsucceed; -xalone returnsSQLSTATE=38553/Invalid input;-xdalone returnsSQLSTATE=38553/Invalid input;- adding
-xor-xdto otherwise successful tested argument sets returnsSQLSTATE=38553; - a separate malformed argument sequence also returns
SQLSTATE=38553, so that SQLSTATE alone is not specific to-x/-xd.
These observations describe the attached test results for this database only. They do not establish a DB2 version or fix-pack boundary at which DB2LK_GENERATE_DDL behavior changes.
Environment facts from the attached DBeaver logs
The following values are quoted from both attached DBeaver debug logs:
- DBeaver:
26.2.0.202608301738 - DBeaver log OS string:
Windows 10 10.0 (amd64) - Java:
25.0.3by Microsoft, 64-bit - Database product name:
DB2/NT - Database product version:
SQL09010 - DBeaver also logs the connected database as
version v9.1
Tested JDBC drivers, as reported by the attached logs:
IBM DB2 JDBC Universal Driver Architecture, version3.8.88IBM Data Server Driver for JDBC and SQLJ, version4.34.30
No Windows marketing edition is inferred from the DBeaver OS string. No server fix-pack level is inferred from SQL09010 or from any client installation information.
DBeaver 26.2.0 source-code evidence
The DBeaver 26.2.0 source code itself shows how the command is built.
In plugins/org.jkiss.dbeaver.ext.db2/src/org/jkiss/dbeaver/ext/db2/DB2Utils.java, generateDDLforTable(...) contains:
String command = String.format(
(includeViews ? "" : "-noview ") + "-e -x -xd -td %s -t %s",
statementDelimiter,
db2Table.getFullyQualifiedName(DBPEvaluationContext.DDL));
The same source file comments that DBeaver uses the SYSPROC.DB2LK_GENERATE_DDL stored procedure as an undocumented mechanism.
Source at tag 26.2.0:
In plugins/org.jkiss.dbeaver.ext.db2/src/org/jkiss/dbeaver/ext/db2/model/DB2Table.java, DBeaver defines:
private static final String LINE_SEPARATOR = GeneralUtils.getDefaultLineSeparator();
and passes that value to generateDDLforTable(...):
return DB2Utils.generateDDLforTable(monitor, LINE_SEPARATOR, getDataSource(), this, includeViews);
Source at tag 26.2.0:
This source-code evidence is consistent with the attached debug logs: the logged command contains -x -xd, and the value logged after -td contains a line break.
DBeaver debug-log evidence
JCC 3.8.88
dbeaver-logs/jcc-3.8.88/dbeaver-debug.log records:
DBeaver 26.2.0.202608301738 is starting
OS: Windows 10 10.0 (amd64)
Java version: 25.0.3 by Microsoft (64bit)
It records the connected database and driver as:
DATABASE1 is version v9.1
...
databaseProductName='DB2/NT'
databaseProductVersion='SQL09010'
driverName='IBM DB2 JDBC Universal Driver Architecture'
driverVersion='3.8.88'
For DDL generation it records:
Generate DDL for MYSCHEMA1.FDUBL2
Calling DB2LK_GENERATE_DDL with command : -noview -e -x -xd -td
-t MYSCHEMA1.FDUBL2
JCC 4.34.30
dbeaver-logs/jcc-4.34.30/dbeaver-debug.log records the same DBeaver version, OS string, Java version, database product and database version, with:
driverName='IBM Data Server Driver for JDBC and SQLJ'
driverVersion='4.34.30'
For DDL generation it records:
Generate DDL for MYSCHEMA.FDUBL2
Calling DB2LK_GENERATE_DDL with command : -noview -e -x -xd -td
-t MYSCHEMA.FDUBL2
The schema names in the two captures are different; they are reproduced above exactly as logged.
The debug logs do not themselves contain the SQLSTATE=38553 result of the DDL call. That error was observed by the reporter in the DBeaver UI. The attached CLP tests independently demonstrate the server response to isolated argument sets.
Direct DB2 CLP tests
The test cases below are summaries of the attached raw clp-tests/*.cmd and clp-tests/*.log files. The raw files are authoritative and are included without content edits.
1. Baseline succeeds
Command in 1.cmd:
db2 CALL "SYSPROC.DB2LK_GENERATE_DDL('-e -t MYSCHEMA.FDUBL2', ?)"
Observed in 1.log:
OP_TOKENvalue:18- localized CLP return-status value:
0
2. -td ; form succeeds
Command in 1.cmd:
db2 CALL "SYSPROC.DB2LK_GENERATE_DDL('-e -td ; -t MYSCHEMA.FDUBL2', ?)"
Observed in 1.log:
OP_TOKENvalue:19- localized CLP return-status value:
0
3. Adding -x fails
Command in 1.cmd:
db2 CALL "SYSPROC.DB2LK_GENERATE_DDL('-e -x -td ; -t MYSCHEMA.FDUBL2', ?)"
Observed in 1.log:
SQL0443N ... "Invalid input". SQLSTATE=38553
4. -x alone fails
Command in 5.cmd:
db2 CALL "SYSPROC.DB2LK_GENERATE_DDL('-x -t MYSCHEMA.FDUBL2', ?)"
Observed in 5.log:
SQL0443N ... "Invalid input". SQLSTATE=38553
5. -xd alone fails
Command in 5.cmd:
db2 CALL "SYSPROC.DB2LK_GENERATE_DDL('-xd -t MYSCHEMA.FDUBL2', ?)"
Observed in 5.log:
SQL0443N ... "Invalid input". SQLSTATE=38553
6. Adding -xd to the tested successful -e -td ; -t ... form fails
Command appears in both 2.cmd and 5.cmd:
db2 CALL "SYSPROC.DB2LK_GENERATE_DDL('-e -xd -td ; -t MYSCHEMA.FDUBL2', ?)"
Both corresponding logs report:
SQL0443N ... "Invalid input". SQLSTATE=38553
7. -noview is accepted in the tested form without -x / -xd
Command appears in 2.cmd and 6.cmd:
db2 CALL "SYSPROC.DB2LK_GENERATE_DDL('-noview -e -td ; -t MYSCHEMA.FDUBL2', ?)"
Observed results:
2.log:OP_TOKENvalue20, localized CLP return-status value06.log:OP_TOKENvalue21, localized CLP return-status value0
8. A value built with SYSFUN.CHR(13) || SYSFUN.CHR(10) in the -td position is accepted in the tested form without -x / -xd
7.cmd executes:
db2 "CALL SYSPROC.DB2LK_GENERATE_DDL('-noview -e -td ' || SYSFUN.CHR(13) || SYSFUN.CHR(10) || ' -t MYSCHEMA.FDUBL2', ?)"
Observed in 7.log:
OP_TOKENvalue:22- localized CLP return-status value:
0
This test establishes only that this SQL expression produces an argument accepted by the procedure in this tested form. The generated DDL was not inspected in this test to determine how the procedure semantically interprets those characters as a -td value.
9. A separate malformed argument sequence also returns 38553
Command in 3.cmd:
db2 CALL "SYSPROC.DB2LK_GENERATE_DDL('-noview -e -td -t MYSCHEMA.FDUBL2', ?)"
Observed in 3.log:
SQL0443N ... "Invalid input". SQLSTATE=38553
This control shows that SQLSTATE=38553 is not specific to -x or -xd. No assumption is made here about how the undocumented procedure tokenizes or interprets -td -t internally.
Evidence-based conclusion
For this connected database, the attached evidence establishes all of the following:
- DBeaver 26.2.0 source code unconditionally includes
-x -xdin theDB2LK_GENERATE_DDLcommand built bygenerateDDLforTable(...). - Both attached DBeaver debug logs show
-x -xdin the command logged for table DDL generation. - In direct CLP tests against the tested database,
-xalone returnsSQLSTATE=38553. - In direct CLP tests against the tested database,
-xdalone returnsSQLSTATE=38553. - Tested argument sets without
-x/-xdsucceed when using the other argument forms shown above. - Switching between the two tested JDBC drivers does not change the DBeaver DDL option pattern shown in the debug logs.
- The CLP tests reproduce
SQLSTATE=38553without DBeaver or JDBC being involved in the call path used for those CLP tests.
No claim is made about other DB2 versions, other DB2 9.1 fix-pack levels, or the exact release/fix-pack at which DB2LK_GENERATE_DDL may accept these options.
Expected behavior
DBeaver should be able to generate table DDL for this connected DB2 v9.1 database without passing an argument set that the server-side DB2LK_GENERATE_DDL procedure rejects.
Requested investigation
Please investigate whether DBeaver should conditionally omit or otherwise handle -x and -xd when DB2LK_GENERATE_DDL on the connected database does not accept those options.
The evidence in this report does not establish a DB2 version/fix-pack cutoff, so no version boundary is proposed.
The report also does not propose retrying solely on SQLSTATE=38553, because 3.cmd / 3.log show the same SQLSTATE for a different malformed argument sequence.
A tested form that succeeds on this database is:
-noview -e -td ; -t <schema>.<table>
The separate 7.cmd test also succeeds when the value after -td is constructed using SYSFUN.CHR(13) || SYSFUN.CHR(10), but this report does not claim how that value is represented in generated DDL because the generated DDL was not inspected for that test.
Scope and limitations
- The reporter-observed DBeaver UI error is not present in the attached DBeaver debug logs; the debug logs document the command DBeaver constructs.
- The CLP tests isolate
-xand-xdindividually and in several combinations. - The attached CLP tests do not replay the exact full DBeaver command with both
-x -xdandSYSFUN.CHR(13) || SYSFUN.CHR(10)in the same call. This is not claimed as tested. - The attached files do not establish a server fix-pack level.
- The full DBeaver debug logs contain additional messages/errors concerning metadata/statistics and, with JCC 3.8.88,
setClientInfo. Those messages are not analyzed as part of this DDL-generation report.
DBeaver documentation context
DBeaver's current IBM Db2 driver documentation states that the regular Db2 for LUW driver is used for DB2 versions newer than 8.x:
https://github.com/dbeaver/dbeaver/wiki/Database-driver-IBM-Db2
This report does not infer any IBM support lifecycle status from that DBeaver documentation statement.
Attached evidence
Raw CLP tests
clp-tests/1.cmd/clp-tests/1.logclp-tests/2.cmd/clp-tests/2.logclp-tests/3.cmd/clp-tests/3.logclp-tests/5.cmd/clp-tests/5.logclp-tests/6.cmd/clp-tests/6.logclp-tests/7.cmd/clp-tests/7.log
Raw DBeaver debug logs
dbeaver-logs/jcc-3.8.88/dbeaver-debug.logdbeaver-logs/jcc-4.34.30/dbeaver-debug.log
Password for archive: 1 dbeaver-db2-9.1-ddl-bug2.zip
DBeaver Version
Community edition 26.2.0
Operating System
Windows 10 (client), Windows 2016 (server)
Database and driver
Database: DB2 9.1 LUW Express-C for Windows Drivers: JDBC version 3.8.88, 4.34.30
Steps to reproduce
See archive
Additional context
No response
Source: dbeaver/dbeaver