Github user arvind-narain commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/243#discussion_r51490240
--- Diff: core/conn/jdbc_type2/native/SrvrCommon.cpp ---
@@ -1634,6 +1635,53 @@ short do_ExecSMD(
tableParam[0], inputParam[0], inputParam[1],
inputParam[2], inputParam[3]);
break;
+ case SQL_API_SQLSTATISTICS:
+ if ((!checkIfWildCard(catalogNm, catalogNmNoEsc) ||
!checkIfWildCard(schemaNm, schemaNmNoEsc)
+ || !checkIfWildCard(tableNm, tableNmNoEsc)) &&
!metadataId)
+ {
+ executeException->exception_nr =
odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_;
+ executeException->u.ParamError.ParamDesc =
SQLSVC_EXCEPTION_WILDCARD_NOT_SUPPORTED;
+
FUNCTION_RETURN_NUMERIC(EXECUTE_EXCEPTION,("EXECUTE_EXCEPTION"));
+ }
+
+ if (strcmp(catalogNm,"") == 0)
+ strcpy(tableName1,SEABASE_MD_CATALOG);
+ else
+ strcpy(tableName1, catalogNm);
+ tableParam[0] = tableName1;
+ convertWildcard(metadataId, TRUE, schemaNm, expSchemaNm);
+ convertWildcardNoEsc(metadataId, TRUE, schemaNm,
schemaNmNoEsc);
+ convertWildcard(metadataId, TRUE, tableNm, expTableNm);
+ convertWildcardNoEsc(metadataId, TRUE, tableNm,
tableNmNoEsc);
+ if( inputParam[5] != NULL )
+ {
+ sprintf(cunique, " and index.IS_UNIQUE=1");
+ }
+ inputParam[0] = schemaNmNoEsc;
+ inputParam[1] = expSchemaNm;
+ inputParam[2] = tableNmNoEsc;
+ inputParam[3] = expTableNm;
+ inputParam[4] = NULL;
+ snprintf((char *)sqlString->dataValue._buffer, totalSize,
+ "select "
+ "obj.CATALOG_NAME TABLE_CAT, obj.SCHEMA_NAME TABLE_SCHEM,
obj.OBJECT_NAME TABLE_NAME,"
+ "cast((case when index.IS_UNIQUE=0 then 1 else 0 end) as
smallint) NON_UNIQUE, "
+ "cast(NULL as varchar(32)) INDEX_QUALIFIER,
idxobj.OBJECT_NAME INDEX_NAME, "
+ "cast(-2 as smallint) TYPE, cols.COLUMN_NUMBER
ORDINAL_POSITION, "
+ "substr(cols.COLUMN_NAME,0,CHAR_LENGTH(cols.COLUMN_NAME))
COLUMN_NAME, "
+ "cast((case when keys.ORDERING=0 then 'A' else 'D' end) as
varchar(4)) ASC_OR_DESC,"
+ "cast(-2 as int) CARDINALITY, cast(-2 as int) PAGES,
cast(NULL as varchar(10)) FILTER_CONDITION "
--- End diff --
1. Sorry for the confusion and the delay Kevin. I was referring to the
output when all tables (%) under a schema are specified. In my testing the
query in the code returned some rows with empty index name and in some cases
temporary table names etc. This can be fixed in a separate JIRA if needed.
<Row id="39">
<TABLE_CAT>TRAFODION</TABLE_CAT>
<TABLE_SCHEM>MTD</TABLE_SCHEM>
<TABLE_NAME>MTD0</TABLE_NAME>
<NON_UNIQUE>0</NON_UNIQUE>
<INDEX_QUALIFIER>NULL</INDEX_QUALIFIER>
<INDEX_NAME>NULL</INDEX_NAME>
<TYPE>-2</TYPE>
<ORDINAL_POSITION>NULL</ORDINAL_POSITION>
<COLUMN_NAME>NULL</COLUMN_NAME>
<ASC_OR_DESC>D</ASC_OR_DESC>
<CARDINALITY>-2</CARDINALITY>
<PAGES>-2</PAGES>
<FILTER_CONDITION>NULL</FILTER_CONDITION>
</Row>
<Row id="40">
<TABLE_CAT>TRAFODION</TABLE_CAT>
<TABLE_SCHEM>MTD</TABLE_SCHEM>
<TABLE_NAME>__SCHEMA__</TABLE_NAME>
<NON_UNIQUE>0</NON_UNIQUE>
<INDEX_QUALIFIER>NULL</INDEX_QUALIFIER>
<INDEX_NAME>NULL</INDEX_NAME>
<TYPE>-2</TYPE>
<ORDINAL_POSITION>NULL</ORDINAL_POSITION>
<COLUMN_NAME>NULL</COLUMN_NAME>
<ASC_OR_DESC>D</ASC_OR_DESC>
<CARDINALITY>-2</CARDINALITY>
<PAGES>-2</PAGES>
<FILTER_CONDITION>NULL</FILTER_CONDITION>
</Row>
2. I did look at the corresponding ODBC API. Ordinal position should start
from 1, so please fix this one and I'll check this in. The following should be
changed -
cols.COLUMN_NUMBER ORDINAL_POSITION
to
keys.KEYSEQ_NUMBER ORDINAL_POSITION
or with a cast if needed.
3. Also could you please create a separate enhancement JIRA - I think for
column_class 'S' - "DIVISION BY" column_name (_DIVISION_n) and SALT we should
have an optional column at the end - maybe "REMARKS" or some appropriate
heading which should give the text from text.text - null for non-system columns
(column_class <> 'S')
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---