Commit ecc99eee authored by Marco Pivetta's avatar Marco Pivetta

Merge pull request #628 from rehfeldchris/db2v10columnbugfix

bug fix for db2 v10 new column def of syscat.columns.default
parents 51074ffd f6e24cf6
...@@ -234,7 +234,7 @@ class DB2Platform extends AbstractPlatform ...@@ -234,7 +234,7 @@ class DB2Platform extends AbstractPlatform
} }
/** /**
* This code fragment is originally from the Zend_Db_Adapter_Db2 class. * This code fragment is originally from the Zend_Db_Adapter_Db2 class, but has been edited.
* *
* @license New BSD License * @license New BSD License
* *
...@@ -245,22 +245,47 @@ class DB2Platform extends AbstractPlatform ...@@ -245,22 +245,47 @@ class DB2Platform extends AbstractPlatform
*/ */
public function getListTableColumnsSQL($table, $database = null) public function getListTableColumnsSQL($table, $database = null)
{ {
return "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno, // We do the funky subquery and join syscat.columns.default this crazy way because
c.typename, c.default, c.nulls, c.length, c.scale, // as of db2 v10, the column is CLOB(64k) and the distinct operator won't allow a CLOB,
c.identity, tc.type AS tabconsttype, k.colseq, // it wants shorter stuff like a varchar.
CASE return "
WHEN c.generated = 'D' THEN 1 SELECT
ELSE 0 cols.default,
END AS autoincrement subq.*
FROM syscat.columns c FROM (
LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc SELECT DISTINCT
ON (k.tabschema = tc.tabschema c.tabschema,
AND k.tabname = tc.tabname c.tabname,
AND tc.type = 'P')) c.colname,
ON (c.tabschema = k.tabschema c.colno,
AND c.tabname = k.tabname c.typename,
AND c.colname = k.colname) c.nulls,
WHERE UPPER(c.tabname) = UPPER('" . $table . "') ORDER BY c.colno"; c.length,
c.scale,
c.identity,
tc.type AS tabconsttype,
k.colseq,
CASE
WHEN c.generated = 'D' THEN 1
ELSE 0
END AS autoincrement
FROM syscat.columns c
LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
ON (k.tabschema = tc.tabschema
AND k.tabname = tc.tabname
AND tc.type = 'P'))
ON (c.tabschema = k.tabschema
AND c.tabname = k.tabname
AND c.colname = k.colname)
WHERE UPPER(c.tabname) = UPPER('" . $table . "')
ORDER BY c.colno
) subq
JOIN syscat.columns cols
ON subq.tabschema = cols.tabschema
AND subq.tabname = cols.tabname
AND subq.colno = cols.colno
ORDER BY subq.colno
";
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment