Fix for TRAFODION-3112 Internal error: get ... for user/role Heading incorrect for libraries Parser error: get procedures/table_mapping functions/functions for user/role
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/3d013bc2 Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/3d013bc2 Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/3d013bc2 Branch: refs/heads/master Commit: 3d013bc2adb46d139ee027a6c878e8ec2c4d5f5a Parents: ce62bc5 Author: Roberta Marton <[email protected]> Authored: Mon Jul 30 22:51:13 2018 +0000 Committer: Roberta Marton <[email protected]> Committed: Mon Jul 30 22:51:13 2018 +0000 ---------------------------------------------------------------------- core/sql/bin/SqlciErrors.txt | 2 +- core/sql/comexe/ComTdbExeUtil.h | 110 +-- core/sql/executor/ExExeUtilGet.cpp | 1024 ++++++++++-------------- core/sql/generator/GenRelExeUtil.cpp | 31 +- core/sql/parser/ParKeyWords.cpp | 2 +- core/sql/parser/sqlparser.y | 51 +- core/sql/parser/ulexer.cpp | 18 + core/sql/regress/compGeneral/EXPECTEDTOK | 5 +- core/sql/regress/compGeneral/EXPECTEDTOK2 | 5 +- core/sql/regress/privs1/EXPECTED125 | 325 +++++++- core/sql/regress/privs1/TEST125 | 9 + core/sql/sqlcomp/CmpDDLCatErrorCodes.h | 1 + 12 files changed, 863 insertions(+), 720 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/bin/SqlciErrors.txt ---------------------------------------------------------------------- diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt index 3437cef..75abfab 100644 --- a/core/sql/bin/SqlciErrors.txt +++ b/core/sql/bin/SqlciErrors.txt @@ -85,7 +85,7 @@ 1083 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Validation for constraint $0~ConstraintName failed; incompatible data exists in table. 1084 ZZZZZ 99999 BEGINNER MINOR DBADMIN An invalid default value was specified for column $0~ColumnName. 1085 ZZZZZ 99999 BEGINNER MAJOR DBADMIN --- unused --- -1086 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU --- unused --- +1086 ZZZZZ 99999 BEGINNER MAJOR DBADMIN $0~string0 is not a $1~string1. 1087 ZZZZZ 99999 BEGINNER MAJOR DBADMIN --- unused --- 1088 ZZZZZ 99999 BEGINNER MINOR DBADMIN --- unused --- 1089 ZZZZZ 99999 BEGINNER MINOR DBADMIN The system generated column SYSKEY must be specified last or not specified at all in the index column list. http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/comexe/ComTdbExeUtil.h ---------------------------------------------------------------------- diff --git a/core/sql/comexe/ComTdbExeUtil.h b/core/sql/comexe/ComTdbExeUtil.h index 39cd249..afb29fb 100644 --- a/core/sql/comexe/ComTdbExeUtil.h +++ b/core/sql/comexe/ComTdbExeUtil.h @@ -2381,90 +2381,106 @@ public: HIVE_EXT_TABLES_IN_CATALOG_, HBASE_REG_TABLES_IN_CATALOG_, - TABLES_IN_SCHEMA_, + FUNCTIONS_IN_SCHEMA_, INDEXES_IN_SCHEMA_, - VIEWS_IN_SCHEMA_, + INVALID_VIEWS_IN_SCHEMA_, LIBRARIES_IN_SCHEMA_, - MVS_IN_SCHEMA_, - MVGROUPS_IN_SCHEMA_, - PRIVILEGES_ON_SCHEMA_, + OBJECTS_IN_SCHEMA_, PROCEDURES_IN_SCHEMA_, SEQUENCES_IN_SCHEMA_, - SYNONYMS_IN_SCHEMA_, - FUNCTIONS_IN_SCHEMA_, TABLE_FUNCTIONS_IN_SCHEMA_, - - OBJECTS_IN_SCHEMA_, - INVALID_VIEWS_IN_SCHEMA_, + TABLES_IN_SCHEMA_, + VIEWS_IN_SCHEMA_, INDEXES_ON_TABLE_, - INDEXES_ON_MV_, + OBJECTS_ON_TABLE_, VIEWS_ON_TABLE_, VIEWS_ON_VIEW_, - MVS_ON_TABLE_, - MVS_ON_VIEW_, - MVS_ON_MV_, - MVGROUPS_ON_TABLE_, - PRIVILEGES_ON_TABLE_, - PRIVILEGES_ON_MV_, - PRIVILEGES_ON_VIEW_, - PRIVILEGES_ON_SEQUENCE_, - SYNONYMS_ON_TABLE_, - OBJECTS_ON_TABLE_, - PARTITIONS_FOR_TABLE_, + FUNCTIONS_FOR_LIBRARY_, PARTITIONS_FOR_INDEX_, + PARTITIONS_FOR_TABLE_, + PROCEDURES_FOR_LIBRARY_, + TABLE_FUNCTIONS_FOR_LIBRARY_, + OBJECTS_IN_VIEW_, TABLES_IN_VIEW_, VIEWS_IN_VIEW_, - OBJECTS_IN_VIEW_, - TABLES_IN_MV_, - MVS_IN_MV_, - OBJECTS_IN_MV_, ROLES_, - ROLES_FOR_ROLE_, + ROLES_FOR_USER_, + USERS_, USERS_FOR_ROLE_, - PRIVILEGES_FOR_ROLE_, - USERS_, + FUNCTIONS_FOR_ROLE_, + INDEXES_FOR_ROLE_, + LIBRARIES_FOR_ROLE_, + PRIVILEGES_FOR_ROLE_, + PROCEDURES_FOR_ROLE_, + SCHEMAS_FOR_ROLE_, + TABLES_FOR_ROLE_, + TABLE_FUNCTIONS_FOR_ROLE_, + VIEWS_FOR_ROLE_, + FUNCTIONS_FOR_USER_, INDEXES_FOR_USER_, LIBRARIES_FOR_USER_, - MVGROUPS_FOR_USER_, - MVS_FOR_USER_, PRIVILEGES_FOR_USER_, PROCEDURES_FOR_USER_, - ROLES_FOR_USER_, SCHEMAS_FOR_USER_, - SYNONYMS_FOR_USER_, TABLES_FOR_USER_, - TRIGGERS_FOR_USER_, + TABLE_FUNCTIONS_FOR_USER_, VIEWS_FOR_USER_, - - PROCEDURES_FOR_LIBRARY_, - FUNCTIONS_FOR_LIBRARY_, - TABLE_FUNCTIONS_FOR_LIBRARY_, + PRIVILEGES_ON_LIBRARY_, PRIVILEGES_ON_PROCEDURE_, PRIVILEGES_ON_ROUTINE_, + PRIVILEGES_ON_TABLE_, + PRIVILEGES_ON_SCHEMA_, + PRIVILEGES_ON_SEQUENCE_, + PRIVILEGES_ON_VIEW_, COMPONENTS_, COMPONENT_OPERATIONS_, COMPONENT_PRIVILEGES_, - IUDLOG_TABLES_IN_SCHEMA_, - RANGELOG_TABLES_IN_SCHEMA_, - TRIGTEMP_TABLES_IN_SCHEMA_, - IUDLOG_TABLE_ON_TABLE_, - RANGELOG_TABLE_ON_TABLE_, - TRIGTEMP_TABLE_ON_TABLE_, - IUDLOG_TABLE_ON_MV_, - RANGELOG_TABLE_ON_MV_, - TRIGTEMP_TABLE_ON_MV_, HBASE_OBJECTS_ + // Not supported at this time + // Kept around because we may support synonyms, triggers, or MV sometime + + //MVGROUPS_FOR_USER_, + //MVS_FOR_USER_, + //SYNONYMS_FOR_USER_, + //TRIGGERS_FOR_USER_, + //MVS_IN_MV_, + + //OBJECTS_IN_MV_, + //TABLES_IN_MV_, + + //IUDLOG_TABLES_IN_SCHEMA_, + //MVS_IN_SCHEMA_, + //MVGROUPS_IN_SCHEMA_, + //RANGELOG_TABLES_IN_SCHEMA_, + //SYNONYMS_IN_SCHEMA_, + //TRIGTEMP_TABLES_IN_SCHEMA_, + + //INDEXES_ON_MV_, + //IUDLOG_TABLE_ON_MV_, + //MVS_ON_MV_, + //PRIVILEGES_ON_MV_, + //RANGELOG_TABLE_ON_MV_, + //TRIGTEMP_TABLE_ON_MV_, + + //IUDLOG_TABLE_ON_TABLE_, + //MVS_ON_TABLE_, + //MVGROUPS_ON_TABLE_, + //RANGELOG_TABLE_ON_TABLE_, + //SYNONYMS_ON_TABLE_, + //TRIGTEMP_TABLE_ON_TABLE_, + + //MVS_ON_VIEW_, }; ComTdbExeUtilGetMetadataInfo() http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/executor/ExExeUtilGet.cpp ---------------------------------------------------------------------- diff --git a/core/sql/executor/ExExeUtilGet.cpp b/core/sql/executor/ExExeUtilGet.cpp index e66ef01..b54674e 100644 --- a/core/sql/executor/ExExeUtilGet.cpp +++ b/core/sql/executor/ExExeUtilGet.cpp @@ -103,9 +103,9 @@ ex_tcb * ExExeUtilGetMetadataInfoTdb::build(ex_globals * glob) (queryType() == ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_SCHEMA_)) exe_util_tcb = new(glob->getSpace()) ExExeUtilGetMetadataInfoComplexTcb(*this, glob); - else if (getVersion()) - exe_util_tcb = - new(glob->getSpace()) ExExeUtilGetMetadataInfoVersionTcb(*this, glob); + //else if (getVersion()) + // exe_util_tcb = + // new(glob->getSpace()) ExExeUtilGetMetadataInfoVersionTcb(*this, glob); else if (queryType() == ComTdbExeUtilGetMetadataInfo::HBASE_OBJECTS_) exe_util_tcb = new(glob->getSpace()) ExExeUtilGetHbaseObjectsTcb(*this, glob); @@ -394,6 +394,18 @@ static const QueryString getTrafLibrariesForUser[] = {" ; "} }; +static const QueryString getTrafRoutinesForAuthQuery[] = +{ + {" select distinct object_name from "}, + {" %s.\"%s\".%s T, %s.\"%s\".%s R "}, + {" where T.catalog_name = '%s' and "}, + {" T.object_type = 'UR' and "}, + {" T.object_uid = R.udr_uid and "}, + {" R.udr_type = '%s' %s "}, + {" order by 1 "}, + {" ; "} +}; + static const QueryString getTrafFunctionsInSchemaQuery[] = { {" select object_name from "}, @@ -844,12 +856,12 @@ Lng32 ExExeUtilGetMetadataInfoTcb::getUsedObjects(Queue * infoList, strcpy(objectStr, "views"); else if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_VIEW_) strcpy(objectStr, "objects"); - else if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_) - strcpy(objectStr, "tables"); - else if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_) - strcpy(objectStr, "mvs"); - else if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_MV_) - strcpy(objectStr, "objects"); + //else if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_) + // strcpy(objectStr, "tables"); + //else if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_) + // strcpy(objectStr, "mvs"); + //else if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_MV_) + // strcpy(objectStr, "objects"); char inStr[10]; if (isShorthandView) @@ -1089,13 +1101,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::MVS_IN_SCHEMA_: - { - str_sprintf(headingBuf_, "MVs in Schema %s.%s", - getMItdb().getCat(), getMItdb().getSch()); - } - break; - case ComTdbExeUtilGetMetadataInfo::PROCEDURES_IN_SCHEMA_: { str_sprintf(headingBuf_, "Procedures in Schema %s.%s", @@ -1117,13 +1122,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::SYNONYMS_IN_SCHEMA_: - { - str_sprintf(headingBuf_, "Synonyms in Schema %s.%s", - getMItdb().getCat(), getMItdb().getSch()); - } - break; - case ComTdbExeUtilGetMetadataInfo::INDEXES_ON_TABLE_: { str_sprintf(headingBuf_, "Indexes on Table %s.%s", @@ -1131,13 +1129,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::INDEXES_ON_MV_: - { - str_sprintf(headingBuf_, "Indexes on MV %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::PRIVILEGES_ON_SCHEMA_: { str_sprintf(headingBuf_, "Privileges on Schema %s.%s", @@ -1152,13 +1143,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::PRIVILEGES_ON_MV_: - { - str_sprintf(headingBuf_, "Privileges on MV %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::PRIVILEGES_ON_VIEW_: { str_sprintf(headingBuf_, "Privileges on View %s.%s", @@ -1175,7 +1159,7 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() case ComTdbExeUtilGetMetadataInfo::PRIVILEGES_ON_LIBRARY_: { - str_sprintf(headingBuf_, "Privileges on Sequence %s.%s", + str_sprintf(headingBuf_, "Privileges on Library %s.%s", getMItdb().getSch(), getMItdb().getObj()); } break; @@ -1187,13 +1171,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::SYNONYMS_ON_TABLE_: - { - str_sprintf(headingBuf_, "Synonyms on Table %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::VIEWS_ON_TABLE_: case ComTdbExeUtilGetMetadataInfo::VIEWS_ON_VIEW_: { @@ -1204,16 +1181,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::MVS_ON_TABLE_: - case ComTdbExeUtilGetMetadataInfo::MVS_ON_MV_: - { - str_sprintf(headingBuf_, - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_ON_TABLE_ - ? "MVs on Table %s.%s" : "MVs ON MV %s.%s"), - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::PARTITIONS_FOR_TABLE_: { str_sprintf(headingBuf_, "Partitions for Table %s.%s", @@ -1221,42 +1188,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::IUDLOG_TABLE_ON_TABLE_: - { - str_sprintf(headingBuf_, "Iudlog tables for Table %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::RANGELOG_TABLE_ON_TABLE_: - { - str_sprintf(headingBuf_, "Rangelog table for Table %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::TRIGTEMP_TABLE_ON_TABLE_: - { - str_sprintf(headingBuf_, "Trigger temp table for Table %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::IUDLOG_TABLE_ON_MV_: - { - str_sprintf(headingBuf_, "Iudlog table for MV %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::RANGELOG_TABLE_ON_MV_: - { - str_sprintf(headingBuf_, "Rangelog table for MV %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::TRIGTEMP_TABLE_ON_MV_: - { - str_sprintf(headingBuf_, "Trigger temp table for MV %s.%s", - getMItdb().getSch(), getMItdb().getObj()); - } - break; case ComTdbExeUtilGetMetadataInfo::PARTITIONS_FOR_INDEX_: { str_sprintf(headingBuf_, "Partitions for Index %s.%s", @@ -1271,26 +1202,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::IUDLOG_TABLES_IN_SCHEMA_: - { - str_sprintf(headingBuf_, "Iud log tables in schema %s.%s", - getMItdb().getCat(), getMItdb().getSch()); - } - break; - case ComTdbExeUtilGetMetadataInfo::RANGELOG_TABLES_IN_SCHEMA_: - { - str_sprintf(headingBuf_, "Range log tables in schema %s.%s", - getMItdb().getCat(), getMItdb().getSch()); - } - break; - - case ComTdbExeUtilGetMetadataInfo::TRIGTEMP_TABLES_IN_SCHEMA_: - { - str_sprintf(headingBuf_, "Trigger temp tables in schema %s.%s", - getMItdb().getCat(), getMItdb().getSch()); - } - break; - case ComTdbExeUtilGetMetadataInfo::SEQUENCES_IN_SCHEMA_: { str_sprintf(headingBuf_, "Sequences in schema %s.%s", @@ -1319,20 +1230,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; - case ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_: - case ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_: - case ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_MV_: - { - str_sprintf(headingBuf_, - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_ ? - "Tables in MV %s.%s" : - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_ ? - "MVs in MV %s.%s" : - "Objects in MV %s.%s")), - getMItdb().getSch(), getMItdb().getObj()); - } - break; - case ComTdbExeUtilGetMetadataInfo::ROLES_: str_sprintf(headingBuf_,"Roles"); break; @@ -1354,14 +1251,30 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() } break; + case ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_USER_: + str_sprintf(headingBuf_,"Functions for User %s",getMItdb().getParam1()); + break; + + case ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_ROLE_: + str_sprintf(headingBuf_,"Functions for Role %s",getMItdb().getParam1()); + break; + case ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_USER_: str_sprintf(headingBuf_,"Indexes for User %s",getMItdb().getParam1()); break; + case ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_ROLE_: + str_sprintf(headingBuf_,"Indexes for Role %s",getMItdb().getParam1()); + break; + case ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_USER_: str_sprintf(headingBuf_,"Libraries for User %s", getMItdb().getParam1()); break; + case ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_ROLE_: + str_sprintf(headingBuf_,"Libraries for User %s", getMItdb().getParam1()); + break; + case ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_LIBRARY_: str_sprintf(headingBuf_,"Procedures for Library %s.%s",getMItdb().getSch(), getMItdb().getObj()); break; @@ -1374,14 +1287,6 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() str_sprintf(headingBuf_,"Table_mapping Functions for Library %s.%s",getMItdb().getSch(), getMItdb().getObj()); break; - case ComTdbExeUtilGetMetadataInfo::MVS_FOR_USER_: - str_sprintf(headingBuf_,"Materialized Views for User %s",getMItdb().getParam1()); - break; - - case ComTdbExeUtilGetMetadataInfo::MVGROUPS_FOR_USER_: - str_sprintf(headingBuf_,"Materialized View Groups for User %s",getMItdb().getParam1()); - break; - case ComTdbExeUtilGetMetadataInfo::PRIVILEGES_FOR_USER_: str_sprintf(headingBuf_,"Privileges for User %s",getMItdb().getParam1()); break; @@ -1394,6 +1299,10 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() str_sprintf(headingBuf_,"Procedures for User %s",getMItdb().getParam1()); break; + case ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_ROLE_: + str_sprintf(headingBuf_,"Procedures for Role %s",getMItdb().getParam1()); + break; + case ComTdbExeUtilGetMetadataInfo::ROLES_FOR_USER_: str_sprintf(headingBuf_,"Roles for User %s",getMItdb().getParam1()); break; @@ -1402,22 +1311,30 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() str_sprintf(headingBuf_,"Schemas for User %s",getMItdb().getParam1()); break; - case ComTdbExeUtilGetMetadataInfo::SYNONYMS_FOR_USER_: - str_sprintf(headingBuf_,"Synonyms for User %s",getMItdb().getParam1()); + case ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_USER_: + str_sprintf(headingBuf_,"Table mapping functions for User %s",getMItdb().getParam1()); + break; + + case ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_ROLE_: + str_sprintf(headingBuf_,"Table mapping functions for Role %s",getMItdb().getParam1()); break; case ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_: str_sprintf(headingBuf_,"Tables for User %s",getMItdb().getParam1()); break; - case ComTdbExeUtilGetMetadataInfo::TRIGGERS_FOR_USER_: - str_sprintf(headingBuf_,"Triggers for User %s",getMItdb().getParam1()); + case ComTdbExeUtilGetMetadataInfo::TABLES_FOR_ROLE_: + str_sprintf(headingBuf_,"Tables for Role %s",getMItdb().getParam1()); break; case ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_USER_: str_sprintf(headingBuf_,"Views for User %s",getMItdb().getParam1()); break; + case ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_ROLE_: + str_sprintf(headingBuf_,"Views for Role %s",getMItdb().getParam1()); + break; + case ComTdbExeUtilGetMetadataInfo::COMPONENTS_: str_sprintf(headingBuf_, "Components"); break; @@ -1434,44 +1351,178 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading() break; } - default: - str_sprintf(headingBuf_, "Add to ExExeUtilGetMetadataInfoTcb::displayHeading"); - break; - } - - moveRowToUpQueue(headingBuf_); - str_pad(outputBuf_, strlen(headingBuf_), '='); - outputBuf_[strlen(headingBuf_)] = 0; - moveRowToUpQueue(outputBuf_); - - moveRowToUpQueue(" "); +// Not supported at this time +#if 0 + case ComTdbExeUtilGetMetadataInfo::TRIGGERS_FOR_USER_: + str_sprintf(headingBuf_,"Triggers for User %s",getMItdb().getParam1()); + break; - return 0; -} // ExExeUtilGetMetadataInfoTcb::displayHeading + case ComTdbExeUtilGetMetadataInfo::INDEXES_ON_MV_: + { + str_sprintf(headingBuf_, "Indexes on MV %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; -// ---------------------------------------------------------------------------- -// getAuthID -// -// Reads the "_MD_".auths table to get the auth_id from the passed in authName. -// If relationship not found for any reason, return 0, otherwise return -// the authID. -// ---------------------------------------------------------------------------- -Int32 ExExeUtilGetMetadataInfoTcb::getAuthID( - const char *authName, - const char *catName, - const char *schName, - const char *objName) -{ - if (strcmp(authName, PUBLIC_AUTH_NAME) == 0) - return PUBLIC_USER; + case ComTdbExeUtilGetMetadataInfo::PRIVILEGES_ON_MV_: + { + str_sprintf(headingBuf_, "Privileges on MV %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; - short rc = 0; - Lng32 cliRC = 0; + case ComTdbExeUtilGetMetadataInfo::IUDLOG_TABLE_ON_TABLE_: + { + str_sprintf(headingBuf_, "Iudlog tables for Table %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; + case ComTdbExeUtilGetMetadataInfo::RANGELOG_TABLE_ON_TABLE_: + { + str_sprintf(headingBuf_, "Rangelog table for Table %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; + case ComTdbExeUtilGetMetadataInfo::TRIGTEMP_TABLE_ON_TABLE_: + { + str_sprintf(headingBuf_, "Trigger temp table for Table %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; + case ComTdbExeUtilGetMetadataInfo::IUDLOG_TABLE_ON_MV_: + { + str_sprintf(headingBuf_, "Iudlog table for MV %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; + case ComTdbExeUtilGetMetadataInfo::RANGELOG_TABLE_ON_MV_: + { + str_sprintf(headingBuf_, "Rangelog table for MV %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; + case ComTdbExeUtilGetMetadataInfo::TRIGTEMP_TABLE_ON_MV_: + { + str_sprintf(headingBuf_, "Trigger temp table for MV %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; + case ComTdbExeUtilGetMetadataInfo::IUDLOG_TABLES_IN_SCHEMA_: + { + str_sprintf(headingBuf_, "Iud log tables in schema %s.%s", + getMItdb().getCat(), getMItdb().getSch()); + } + break; + case ComTdbExeUtilGetMetadataInfo::RANGELOG_TABLES_IN_SCHEMA_: + { + str_sprintf(headingBuf_, "Range log tables in schema %s.%s", + getMItdb().getCat(), getMItdb().getSch()); + } + break; - sprintf(queryBuf_, "select auth_id from %s.\"%s\".%s where auth_db_name = '%s' ", - catName, schName, objName, authName); + case ComTdbExeUtilGetMetadataInfo::TRIGTEMP_TABLES_IN_SCHEMA_: + { + str_sprintf(headingBuf_, "Trigger temp tables in schema %s.%s", + getMItdb().getCat(), getMItdb().getSch()); + } + break; - if (initializeInfoList(infoList_)) return NA_UserIdDefault; + case ComTdbExeUtilGetMetadataInfo::SYNONYMS_IN_SCHEMA_: + { + str_sprintf(headingBuf_, "Synonyms in Schema %s.%s", + getMItdb().getCat(), getMItdb().getSch()); + } + break; + case ComTdbExeUtilGetMetadataInfo::SYNONYMS_FOR_USER_: + str_sprintf(headingBuf_,"Synonyms for User %s",getMItdb().getParam1()); + break; + + case ComTdbExeUtilGetMetadataInfo::SYNONYMS_ON_TABLE_: + { + str_sprintf(headingBuf_, "Synonyms on Table %s.%s", + getMItdb().getSch(), getMItdb().getObj()); + } + break; + + + case ComTdbExeUtilGetMetadataInfo::MVS_IN_SCHEMA_: + { + str_sprintf(headingBuf_, "MVs in Schema %s.%s", + getMItdb().getCat(), getMItdb().getSch()); + } + break; + + case ComTdbExeUtilGetMetadataInfo::MVS_ON_TABLE_: + case ComTdbExeUtilGetMetadataInfo::MVS_ON_MV_: + { + str_sprintf(headingBuf_, + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_ON_TABLE_ + ? "MVs on Table %s.%s" : "MVs ON MV %s.%s"), + getMItdb().getSch(), getMItdb().getObj()); + } + break; + case ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_: + case ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_: + case ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_MV_: + { + str_sprintf(headingBuf_, + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_ ? + "Tables in MV %s.%s" : + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_ ? + "MVs in MV %s.%s" : + "Objects in MV %s.%s")), + getMItdb().getSch(), getMItdb().getObj()); + } + break; + + case ComTdbExeUtilGetMetadataInfo::MVS_FOR_USER_: + str_sprintf(headingBuf_,"Materialized Views for User %s",getMItdb().getParam1()); + break; + + case ComTdbExeUtilGetMetadataInfo::MVGROUPS_FOR_USER_: + str_sprintf(headingBuf_,"Materialized View Groups for User %s",getMItdb().getParam1()); + break; + +#endif + + default: + str_sprintf(headingBuf_, "Add to ExExeUtilGetMetadataInfoTcb::displayHeading"); + break; + } + + moveRowToUpQueue(headingBuf_); + str_pad(outputBuf_, strlen(headingBuf_), '='); + outputBuf_[strlen(headingBuf_)] = 0; + moveRowToUpQueue(outputBuf_); + + moveRowToUpQueue(" "); + + return 0; +} // ExExeUtilGetMetadataInfoTcb::displayHeading + +// ---------------------------------------------------------------------------- +// getAuthID +// +// Reads the "_MD_".auths table to get the auth_id from the passed in authName. +// If relationship not found for any reason, return 0, otherwise return +// the authID. +// ---------------------------------------------------------------------------- +Int32 ExExeUtilGetMetadataInfoTcb::getAuthID( + const char *authName, + const char *catName, + const char *schName, + const char *objName) +{ + if (strcmp(authName, PUBLIC_AUTH_NAME) == 0) + return PUBLIC_USER; + + short rc = 0; + Lng32 cliRC = 0; + + sprintf(queryBuf_, "select auth_id from %s.\"%s\".%s where auth_db_name = '%s' ", + catName, schName, objName, authName); + + if (initializeInfoList(infoList_)) return NA_UserIdDefault; numOutputEntries_ = 1; cliRC = fetchAllRows(infoList_, queryBuf_, numOutputEntries_, FALSE, rc); @@ -1978,8 +2029,22 @@ short ExExeUtilGetMetadataInfoTcb::work() if(getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::COMPONENTS_ ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::COMPONENT_OPERATIONS_ ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::COMPONENT_PRIVILEGES_ - ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::USERS_FOR_ROLE_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_USER_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_ROLE_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_USER_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_ROLE_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_USER_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_ROLE_ ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::ROLES_FOR_USER_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_USER_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_ROLE_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_USER_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_ROLE_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_FOR_ROLE_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_USER_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_ROLE_ + ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::USERS_FOR_ROLE_ ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::PRIVILEGES_FOR_ROLE_ ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::PRIVILEGES_FOR_USER_ ||getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::PRIVILEGES_ON_TABLE_ @@ -2382,6 +2447,95 @@ short ExExeUtilGetMetadataInfoTcb::work() param_[8] = (char *) privWhereClause.data(); } break ; + + case ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_USER_: + case ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_ROLE_: + case ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_USER_: + case ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_ROLE_: + case ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_USER_: + case ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_ROLE_: + { + NABoolean isUser = + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_USER_ || + getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_USER_ || + getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_USER_); + + // Get the authID associated with the specified user + Int32 authID = *currContext->getDatabaseUserID(); + if (!(strcmp(getMItdb().getParam1(), currContext->getDatabaseUserName()) == 0)) + authID = getAuthID(getMItdb().getParam1(), cat, sch, auths); + + // Verify that the user is a user, or the role is a role + if (isUser && !CmpSeabaseDDLauth::isUserID(authID) || + !isUser && !CmpSeabaseDDLauth::isRoleID(authID)) + { + NAString type = (isUser ? "user" : "role"); + ExRaiseSqlError(getHeap(), &diagsArea_, -CAT_IS_NOT_CORRECT_AUTHID, + NULL, NULL, NULL, + getMItdb().getParam1(), + type.data()); + step_ = HANDLE_ERROR_; + break; + } + + qs = getTrafRoutinesForAuthQuery; + sizeOfqs = sizeof(getTrafRoutinesForAuthQuery); + + NAString routineType; + if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_USER_) || + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_ROLE_)) + routineType = COM_PROCEDURE_TYPE_LIT; + else if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_USER_) || + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_ROLE_)) + routineType = COM_SCALAR_UDF_TYPE_LIT; + else + routineType = COM_TABLE_UDF_TYPE_LIT; + + // Getting objects for the current user + if (strcmp(getMItdb().getParam1(), currContext->getDatabaseUserName()) == 0) + privWhereClause = getGrantedPrivCmd(authList, cat, NAString ("T.object_uid")); + + // Getting objects for a user other than the current user + else + { + if (doPrivCheck) + { + // User cannot view privileges for another user + ExRaiseSqlError(getHeap(), &diagsArea_, -1017); + step_ = HANDLE_ERROR_; + break; + } + else + { + // get the list of roles for this other user. + char *userRoleList = getRoleList(authID, cat, pmsch, role_usage); + if (userRoleList) + { + privWhereClause = getGrantedPrivCmd(userRoleList, cat, NAString ("T.object_uid")); + NADELETEBASIC(userRoleList, getHeap()); + } + else + { + // Unable to read metadata + ExRaiseSqlError(getHeap(), &diagsArea_, -8001); + step_ = HANDLE_ERROR_; + break; + } + } + } + + param_[0] = cat; + param_[1] = sch; + param_[2] = tab; + param_[3] = cat; + param_[4] = sch; + param_[5] = routine; + param_[6] = getMItdb().cat_; + param_[7] = (char *)routineType.data(); + param_[8] = (char *) privWhereClause.data(); + } + break ; + case ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_LIBRARY_: case ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_LIBRARY_: case ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_LIBRARY_: @@ -2682,6 +2836,7 @@ short ExExeUtilGetMetadataInfoTcb::work() } case ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_USER_: + case ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_ROLE_: { qs = getTrafIndexesForUser; sizeOfqs = sizeof(getTrafIndexesForUser); @@ -2736,18 +2891,46 @@ short ExExeUtilGetMetadataInfoTcb::work() break; case ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_: + case ComTdbExeUtilGetMetadataInfo::TABLES_FOR_ROLE_: case ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_USER_: + case ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_ROLE_: { + NABoolean isUser = + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_ || + getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_USER_); + + // Get the authID associated with the specified user + Int32 authID = *currContext->getDatabaseUserID(); + if (!(strcmp(getMItdb().getParam1(), currContext->getDatabaseUserName()) == 0)) + authID = getAuthID(getMItdb().getParam1(), cat, sch, auths); + + // Verify that the user is a user, or the role is a role + NABoolean validAuth = FALSE; + if (isUser && CmpSeabaseDDLauth::isUserID(authID)) + validAuth = TRUE; + if (!isUser && CmpSeabaseDDLauth::isRoleID(authID)) + validAuth = TRUE; + + if (!validAuth) + { + NAString authName = (isUser) ? "user" : "role"; + ExRaiseSqlError(getHeap(), &diagsArea_, -CAT_IS_NOT_CORRECT_AUTHID, + NULL, NULL, NULL, + getMItdb().getParam1(), + authName.data()); + step_ = HANDLE_ERROR_; + break; + } + qs = getTrafObjectsForUser; sizeOfqs = sizeof(getTrafObjectsForUser); NAString objType; - if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_) + if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_) || + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_FOR_ROLE_)) objType = COM_BASE_TABLE_OBJECT_LIT; - else if (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_USER_) + else objType = COM_VIEW_OBJECT_LIT; - else - objType = COM_INDEX_OBJECT_LIT; // Getting objects for the current user if (strcmp(getMItdb().getParam1(), currContext->getDatabaseUserName()) == 0) @@ -2765,9 +2948,6 @@ short ExExeUtilGetMetadataInfoTcb::work() } else { - // Get the authID associated with the requested user - Int32 authID = getAuthID(getMItdb().getParam1(), cat, sch, auths); - // get the list of roles for this other user. char *userRoleList = getRoleList(authID, cat, pmsch, role_usage); if (userRoleList) @@ -2795,7 +2975,34 @@ short ExExeUtilGetMetadataInfoTcb::work() break; case ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_USER_: + case ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_ROLE_: { + NABoolean isUser = + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_USER_); + + // Get the authID associated with the specified user + Int32 authID = *currContext->getDatabaseUserID(); + if (!(strcmp(getMItdb().getParam1(), currContext->getDatabaseUserName()) == 0)) + authID = getAuthID(getMItdb().getParam1(), cat, sch, auths); + + // Verify that the user is a user, or the role is a role + NABoolean validAuth = FALSE; + if (isUser && CmpSeabaseDDLauth::isUserID(authID)) + validAuth = TRUE; + if (!isUser && CmpSeabaseDDLauth::isRoleID(authID)) + validAuth = TRUE; + + if (!validAuth) + { + NAString authName = (isUser) ? "user" : "role"; + ExRaiseSqlError(getHeap(), &diagsArea_, -CAT_IS_NOT_CORRECT_AUTHID, + NULL, NULL, NULL, + getMItdb().getParam1(), + authName.data()); + step_ = HANDLE_ERROR_; + break; + } + qs = getTrafLibrariesForUser; sizeOfqs = sizeof(getTrafLibrariesForUser); @@ -2815,9 +3022,6 @@ short ExExeUtilGetMetadataInfoTcb::work() } else { - // Get the authID associated with the requested user - Int32 authID = getAuthID(getMItdb().getParam1(), cat, sch, auths); - // Get the list of roles for this other user. char *userRoleList = getRoleList(authID, cat, pmsch, role_usage); if (userRoleList) @@ -2922,7 +3126,7 @@ short ExExeUtilGetMetadataInfoTcb::work() if (CmpSeabaseDDLauth::isUserID(authID) && getMItdb().cascade()) { char buf[300 + MAX_AUTHNAME_LEN + 200]; - str_sprintf(buf, "or p.grantee_id = (select role_id from " + str_sprintf(buf, "or p.grantee_id in (select role_id from " "%s.\"%s\".%s where grantee_name = '%s') " "or p.grantee_id = -1", cat, pmsch, role_usage, getMItdb().getParam1()); @@ -3087,6 +3291,9 @@ short ExExeUtilGetMetadataInfoTcb::work() ptr = outputCharStr; len = outputStr.length(); } + +// Not supported at this time +#if 0 if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TRIGTEMP_TABLE_ON_TABLE_ ) || (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TRIGTEMP_TABLE_ON_MV_ )) { @@ -3114,16 +3321,19 @@ short ExExeUtilGetMetadataInfoTcb::work() } - if (((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_VIEW_) || - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_)) && +#endif + + if (((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_VIEW_) + //|| (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_) + ) && (vi->get(1) && (strcmp(vi->get(1), "BT") != 0))) exprRetCode = ex_expr::EXPR_FALSE; else if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_IN_VIEW_) && (vi->get(1) && (strcmp(vi->get(1), "VI") != 0))) exprRetCode = ex_expr::EXPR_FALSE; - else if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_) && - (vi->get(1) && (strcmp(vi->get(1), "MV") != 0))) - exprRetCode = ex_expr::EXPR_FALSE; + //else if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_) && + // (vi->get(1) && (strcmp(vi->get(1), "MV") != 0))) + // exprRetCode = ex_expr::EXPR_FALSE; if (exprRetCode == ex_expr::EXPR_TRUE) exprRetCode = evalScanExpr(ptr, len, TRUE); @@ -3217,17 +3427,17 @@ short ExExeUtilGetMetadataInfoTcb::work() } if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_ON_TABLE_) || - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_ON_VIEW_) || - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_ON_TABLE_) || - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_ON_VIEW_)) + //(getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_ON_TABLE_) || + //(getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_ON_VIEW_) || + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_ON_VIEW_)) step_ = GET_USING_VIEWS_; else if ((getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_VIEW_) || (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::VIEWS_IN_VIEW_) || - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_VIEW_) || - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_) || - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_) || - (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_MV_)) + //(getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::TABLES_IN_MV_) || + //(getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::MVS_IN_MV_) || + //(getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_MV_) || + (getMItdb().queryType_ == ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_VIEW_)) step_ = GET_USED_OBJECTS_; else step_ = DONE_; @@ -3462,41 +3672,55 @@ short ExExeUtilGetMetadataInfoComplexTcb::work() } break; - case ComTdbExeUtilGetMetadataInfo::MVS_ON_TABLE_: + case ComTdbExeUtilGetMetadataInfo::TABLES_IN_VIEW_: { - str_sprintf(queryBuf_, "select * from (get all mvs on table \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", + str_sprintf(queryBuf_, "select * from (get all tables in view \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", getMItdb().getCat(), getMItdb().getSch(), getMItdb().getObj(), patternStr_); } break; - case ComTdbExeUtilGetMetadataInfo::MVS_ON_MV_: + case ComTdbExeUtilGetMetadataInfo::VIEWS_IN_VIEW_: { - str_sprintf(queryBuf_, "select * from (get all mvs on mv \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", + str_sprintf(queryBuf_, "select * from (get all views in view \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", getMItdb().getCat(), getMItdb().getSch(), getMItdb().getObj(), patternStr_); } break; - case ComTdbExeUtilGetMetadataInfo::TABLES_IN_VIEW_: + case ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_VIEW_: { - str_sprintf(queryBuf_, "select * from (get all tables in view \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", + str_sprintf(queryBuf_, "select * from (get all objects in view \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", getMItdb().getCat(), getMItdb().getSch(), getMItdb().getObj(), patternStr_); } break; - case ComTdbExeUtilGetMetadataInfo::VIEWS_IN_VIEW_: + case ComTdbExeUtilGetMetadataInfo::OBJECTS_ON_TABLE_: { - str_sprintf(queryBuf_, "select * from (get all views in view \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", + step_ = FETCH_ALL_ROWS_FOR_OBJECTS_; + } + break; + + case ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_SCHEMA_: + { + step_ = FETCH_ALL_ROWS_IN_SCHEMA_; + } + break; + +// not supported at this time +#if 0 + case ComTdbExeUtilGetMetadataInfo::MVS_ON_TABLE_: + { + str_sprintf(queryBuf_, "select * from (get all mvs on table \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", getMItdb().getCat(), getMItdb().getSch(), getMItdb().getObj(), patternStr_); } break; - case ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_VIEW_: + case ComTdbExeUtilGetMetadataInfo::MVS_ON_MV_: { - str_sprintf(queryBuf_, "select * from (get all objects in view \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", + str_sprintf(queryBuf_, "select * from (get all mvs on mv \"%s\".\"%s\".\"%s\", no header %s) xxx(aaa) group by aaa order by 1", getMItdb().getCat(), getMItdb().getSch(), getMItdb().getObj(), patternStr_); } @@ -3526,18 +3750,7 @@ short ExExeUtilGetMetadataInfoComplexTcb::work() } break; - case ComTdbExeUtilGetMetadataInfo::OBJECTS_ON_TABLE_: - { - step_ = FETCH_ALL_ROWS_FOR_OBJECTS_; - } - break; - - case ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_SCHEMA_: - { - step_ = FETCH_ALL_ROWS_IN_SCHEMA_; - } - break; - +#endif default: { ExRaiseSqlError(getHeap(), &diagsArea_, -4298, @@ -4192,385 +4405,6 @@ short ExExeUtilGetHbaseObjectsTcb::work() return WORK_OK; } -//////////////////////////////////////////////////////////////// -// Constructor for class ExExeUtilGetMetadataInfoVersionTcb -/////////////////////////////////////////////////////////////// -ExExeUtilGetMetadataInfoVersionTcb::ExExeUtilGetMetadataInfoVersionTcb( - const ComTdbExeUtilGetMetadataInfo & exe_util_tdb, - ex_globals * glob) - : ExExeUtilGetMetadataInfoTcb( exe_util_tdb, glob) -{ -} - -static const QueryString getVersionForSchemasInCatalogQuery[] = -{ - {" select translate(trim(S.schema_name) using ucs2toutf8), "}, - {" cast(S.schema_version as char(4)) "}, - {" from "}, - {" HP_SYSTEM_CATALOG.system_schema.catsys C, "}, - {" HP_SYSTEM_CATALOG.system_schema.schemata S "}, - {" where "}, - {" C.cat_name = '%s' and "}, - {" C.cat_uid = S.cat_uid "}, - {" %s "}, - {" order by 1 "}, - {" ; "} -}; - -static const QueryString getVersionForObjectsInSchemaQuery[] = -{ - {" select translate(trim(O.object_name) using ucs2toutf8), "}, - {" cast(S.schema_version as char(4)), cast(O.object_feature_version as char(4)), "}, - {" cast(O.rcb_version as char(4)) "}, - {" from "}, - {" HP_SYSTEM_CATALOG.system_schema.catsys C, "}, - {" HP_SYSTEM_CATALOG.system_schema.schemata S, "}, - {" \"%s\".HP_DEFINITION_SCHEMA.objects O "}, - {" where "}, - {" C.cat_name = '%s' and "}, - {" S.schema_name = '%s' and "}, - {" C.cat_uid = S.cat_uid and "}, - {" S.schema_uid = O.schema_uid "}, - {" %s "}, - {" order by 1 "}, - {" ; "} -}; - -////////////////////////////////////////////////////// -// work() for ExExeUtilGetMetadataInfoVersionTcb -////////////////////////////////////////////////////// -short ExExeUtilGetMetadataInfoVersionTcb::work() -{ - short retcode = 0; - Lng32 cliRC = 0; - ex_expr::exp_return_type exprRetCode = ex_expr::EXPR_OK; - - // if no parent request, return - if (qparent_.down->isEmpty()) - return WORK_OK; - - // if no room in up queue, won't be able to return data/status. - // Come back later. - if (qparent_.up->isFull()) - return WORK_OK; - - ex_queue_entry * pentry_down = qparent_.down->getHeadEntry(); - ExExeUtilPrivateState & pstate = - *((ExExeUtilPrivateState*) pentry_down->pstate); - - // Get the globals stucture of the master executor. - ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals(); - ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals(); - ContextCli * currContext = masterGlob->getStatement()->getContext(); - - while (1) - { - switch (step_) - { - case INITIAL_: - { - step_ = DISABLE_CQS_; - } - break; - - case DISABLE_CQS_: - { - if (disableCQS()) - { - step_ = HANDLE_ERROR_; - break; - } - - step_ = SETUP_QUERY_; - } - break; - - case SETUP_QUERY_: - { - const QueryString * qs; - Int32 sizeOfqs = 0; - - char predStr[2000]; - predStr[0] = '\0'; - patternStr_[0] = '\0'; - if (getMItdb().getPattern()) - { - str_sprintf(patternStr_, ", match '%s' ", - getMItdb().getPattern()); - } - - if (getMItdb().queryType() == ComTdbExeUtilGetMetadataInfo::SCHEMAS_IN_CATALOG_) - { - qs = getVersionForSchemasInCatalogQuery; - sizeOfqs = sizeof(getVersionForSchemasInCatalogQuery); - - param_[0] = getMItdb().cat_; - param_[1] = predStr; - - if (getMItdb().userObjs()) - { - str_sprintf(predStr, " and (S.schema_name <> 'HP_DEFINITION_SCHEMA' and S.schema_name <> 'MXCS_SCHEMA' and S.schema_name <> 'SYSTEM_DEFAULTS_SCHEMA' and S.schema_name <> 'SYSTEM_SCHEMA' and S.schema_name <> 'PUBLIC_ACCESS_SCHEMA' and S.schema_name <> 'HP_ROUTINES' and S.schema_name <> 'HP_SECURITY_SCHEMA' and S.schema_name <> 'MANAGEABILITY' and left(S.schema_name, 1) <> '@' and S.current_operation <> 'VS' ) "); - } - else if (getMItdb().systemObjs()) - { - str_sprintf(predStr, " and (S.schema_name = 'HP_DEFINITION_SCHEMA' or S.schema_name = 'MXCS_SCHEMA' or S.schema_name = 'SYSTEM_DEFAULTS_SCHEMA' or S.schema_name = 'SYSTEM_SCHEMA' or S.schema_name = 'PUBLIC_ACCESS_SCHEMA' or S.schema_name = 'HP_ROUTINES' or S.schema_name = 'HP_SECURITY_SCHEMA' or S.schema_name = 'MANAGEABILITY' or left(S.schema_name, 1) = '@' or S.current_operation = 'VS') "); - } - - numOutputEntries_ = 2; - } - else - { - qs = getVersionForObjectsInSchemaQuery; - sizeOfqs = sizeof(getVersionForObjectsInSchemaQuery); - - param_[0] = getMItdb().cat_; - param_[1] = getMItdb().cat_; - param_[2] = getMItdb().sch_; - param_[3] = predStr; - - switch (getMItdb().queryType_) - { - case ComTdbExeUtilGetMetadataInfo::TABLES_IN_SCHEMA_: - { - strcat(predStr, " and O.object_name_space = 'TA' and O.object_type = 'BT' "); - - if (getMItdb().userObjs()) - { - strcat(predStr, " and O.object_security_class = 'UT' "); - } - else if (getMItdb().systemObjs()) - { - strcat(predStr, " and O.object_security_class <> 'UT' "); - } - - } - break; - - case ComTdbExeUtilGetMetadataInfo::INDEXES_IN_SCHEMA_: - { - strcat(predStr, " and O.object_name_space = 'IX' and O.object_type = 'IX' "); - } - break; - - case ComTdbExeUtilGetMetadataInfo::VIEWS_IN_SCHEMA_: - { - strcat(predStr, " and O.object_name_space = 'TA' and O.object_type = 'VI' "); - } - break; - - case ComTdbExeUtilGetMetadataInfo::LIBRARIES_IN_SCHEMA_: - { - strcat(predStr, " and O.object_name_space = 'LB' and O.object_type = 'LB' "); //ACH VErfiy this is stored correctly - SMDIO? - } - break; - - case ComTdbExeUtilGetMetadataInfo::MVS_IN_SCHEMA_: - { - strcat(predStr, " and O.object_name_space = 'TA' and O.object_type = 'MV' "); - } - break; - - case ComTdbExeUtilGetMetadataInfo::PROCEDURES_IN_SCHEMA_: - { - strcat(predStr, " and O.object_name_space = 'TA' and O.object_type = 'UR' "); - } - break; - - case ComTdbExeUtilGetMetadataInfo::SYNONYMS_IN_SCHEMA_: - { - strcat(predStr, " and O.object_name_space = 'TA' and O.object_type = 'SY' "); - } - break; - - case ComTdbExeUtilGetMetadataInfo::OBJECTS_IN_SCHEMA_: - { - } - break; - - default: - { - ExRaiseSqlError(getHeap(), &diagsArea_, -4218, - NULL, NULL, NULL, "GET"); - step_ = HANDLE_ERROR_; - } - break; - - } // switch - - numOutputEntries_ = 4; - } - - Int32 qryArraySize = sizeOfqs / sizeof(QueryString); - char * gluedQuery; - Lng32 gluedQuerySize; - glueQueryFragments(qryArraySize, qs, - gluedQuery, gluedQuerySize); - - str_sprintf(queryBuf_, gluedQuery, - param_[0], param_[1], param_[2], param_[3], - param_[4], param_[5], param_[6], param_[7], - param_[8], param_[9], param_[10], param_[11], - param_[12], param_[13], param_[14]); - - NADELETEBASIC(gluedQuery, getMyHeap()); - step_ = FETCH_ALL_ROWS_; - } - break; - - case FETCH_ALL_ROWS_: - { - if (initializeInfoList(infoList_)) - { - step_ = HANDLE_ERROR_; - break; - } - - if (fetchAllRows(infoList_, queryBuf_, numOutputEntries_, - FALSE, retcode) < 0) - { - step_ = HANDLE_ERROR_; - - break; - } - - infoList_->position(); - - // find out the max length of the object name entry. - // This will help in formatting of output. - infoList_->position(); - maxObjLen_ = 0; - while (NOT infoList_->atEnd()) - { - OutputInfo * oi = (OutputInfo*)infoList_->getCurr(); - if (strlen(oi->get(0)) > maxObjLen_) - maxObjLen_ = strlen(oi->get(0)); - - infoList_->advance(); - } - - infoList_->position(); - - step_ = DISPLAY_HEADING_; - } - break; - - case DISPLAY_HEADING_: - { - if (infoList_->atEnd()) - { - step_ = DONE_; - break; - } - - // make sure there is enough space to move header - if (isUpQueueFull(5)) - { - return WORK_CALL_AGAIN; // come back later - } - - if (numOutputEntries_ == 2) - { - maxObjLen_ = MAXOF(strlen("Schema"), maxObjLen_); - str_sprintf(formatStr_, "%%%ds %%4s", maxObjLen_); - - str_sprintf(headingBuf_, formatStr_, - "Schema", "OSV"); - } - else - { - maxObjLen_ = MAXOF(strlen("Object"), maxObjLen_); - str_sprintf(formatStr_, "%%%ds %%4s %%4s %%4s", maxObjLen_); - - str_sprintf(headingBuf_, formatStr_, - "Object", "OSV", "OFV", "RCBV"); - } - - Lng32 len = strlen(headingBuf_); - moveRowToUpQueue(headingBuf_); - str_pad(headingBuf_, len, '='); - headingBuf_[len] = 0; - moveRowToUpQueue(headingBuf_); - - moveRowToUpQueue(" "); - - step_ = RETURN_ROW_; - } - break; - - case RETURN_ROW_: - { - if (infoList_->atEnd()) - { - step_ = ENABLE_CQS_; - break; - } - - if (qparent_.up->isFull()) - return WORK_OK; - - OutputInfo * vi = (OutputInfo*)infoList_->getCurr(); - - if (numOutputEntries_ == 2) - { - str_sprintf(outputBuf_, formatStr_, - vi->get(0), vi->get(1)); - } - else - { - str_sprintf(outputBuf_, formatStr_, - vi->get(0), vi->get(1), vi->get(2), - vi->get(3)); - } - - short rc = 0; - moveRowToUpQueue(outputBuf_, 0, &rc); - - infoList_->advance(); - } - break; - - case ENABLE_CQS_: - { - if (restoreCQS()) - { - step_ = HANDLE_ERROR_; - break; - } - - step_ = DONE_; - } - break; - - case HANDLE_ERROR_: - { - restoreCQS(); - - retcode = handleError(); - if (retcode == 1) - return WORK_OK; - - step_ = DONE_; - } - break; - - case DONE_: - { - retcode = handleDone(); - if (retcode == 1) - return WORK_OK; - - step_ = INITIAL_; - - return WORK_OK; - } - break; - - } - } - - return 0; -} - /////////////////////////////////////////////////////////////////// ex_tcb * ExExeUtilGetHiveMetadataInfoTdb::build(ex_globals * glob) { http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/generator/GenRelExeUtil.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenRelExeUtil.cpp b/core/sql/generator/GenRelExeUtil.cpp index 109312a..1e5509b 100644 --- a/core/sql/generator/GenRelExeUtil.cpp +++ b/core/sql/generator/GenRelExeUtil.cpp @@ -1721,15 +1721,20 @@ short ExeUtilGetMetadataInfo::codeGen(Generator * generator) { "ALL", "TABLE_FUNCTIONS","FOR","LIBRARY", 0, 3, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_LIBRARY_ }, { "ALL", "INDEXES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_USER_ }, + { "ALL", "INDEXES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_ROLE_ }, { "ALL", "LIBRARIES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_USER_ }, + { "ALL", "LIBRARIES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_ROLE_ }, { "ALL", "PRIVILEGES","FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PRIVILEGES_FOR_USER_ }, { "ALL", "PRIVILEGES","FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PRIVILEGES_FOR_ROLE_ }, { "ALL", "PROCEDURES","FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_USER_ }, + { "ALL", "PROCEDURES","FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_ROLE_ }, { "ALL", "ROLES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::ROLES_FOR_USER_ }, { "ALL", "SCHEMAS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_USER_ }, - { "ALL", "SCHEMAS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_USER_ }, + { "ALL", "SCHEMAS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_ROLE_ }, { "ALL", "TABLES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_ }, + { "ALL", "TABLES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLES_FOR_ROLE_ }, { "ALL", "VIEWS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_USER_ }, + { "ALL", "VIEWS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_ROLE_ }, // { "ALL", "MVS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::MVS_FOR_USER_ }, // { "ALL", "MVGROUPS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::MVGROUPS_FOR_USER_ }, // { "ALL", "SYNONYMS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SYNONYMS_FOR_USER_ }, @@ -1737,28 +1742,40 @@ short ExeUtilGetMetadataInfo::codeGen(Generator * generator) { "SYSTEM", "ROLES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::ROLES_FOR_USER_ }, { "SYSTEM", "SCHEMAS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_USER_ }, - { "SYSTEM", "SCHEMAS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_USER_ }, + { "SYSTEM", "SCHEMAS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_ROLE_ }, { "SYSTEM", "TABLES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_ }, -// { "SYSTEM", "INDEXES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_USER_ }, -// { "SYSTEM", "LIBRARIES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_USER_ }, + { "SYSTEM", "TABLES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLES_FOR_ROLE_ }, + { "SYSTEM", "INDEXES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_USER_ }, + { "SYSTEM", "INDEXES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_ROLE_ }, + { "SYSTEM", "LIBRARIES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_USER_ }, + { "SYSTEM", "LIBRARIES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_ROLE_ }, + { "SYSTEM", "PROCEDURES","FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_USER_ }, + { "SYSTEM", "PROCEDURES","FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_ROLE_ }, // { "SYSTEM", "MVS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::MVS_FOR_USER_ }, // { "SYSTEM", "MVGROUPS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::MVGROUPS_FOR_USER_ }, -// { "SYSTEM", "PRIVILEGES","FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PRIVILEGES_FOR_USER_ }, -// { "SYSTEM", "PROCEDURES","FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_USER_ }, // { "SYSTEM", "SYNONYMS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SYNONYMS_FOR_USER_ }, // { "SYSTEM", "TRIGGERS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TRIGGERS_FOR_USER_ }, // { "SYSTEM", "VIEWS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_USER_ }, + { "USER", "FUNCTIONS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_USER_ }, + { "USER", "FUNCTIONS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::FUNCTIONS_FOR_ROLE_ }, { "USER", "INDEXES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_USER_ }, + { "USER", "INDEXES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::INDEXES_FOR_ROLE_ }, { "USER", "LIBRARIES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_USER_ }, + { "USER", "LIBRARIES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::LIBRARIES_FOR_ROLE_ }, { "USER", "PRIVILEGES","FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PRIVILEGES_FOR_USER_ }, { "USER", "PRIVILEGES","FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PRIVILEGES_FOR_ROLE_ }, { "USER", "PROCEDURES","FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_USER_ }, + { "USER", "PROCEDURES","FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::PROCEDURES_FOR_ROLE_ }, { "USER", "ROLES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::ROLES_FOR_USER_ }, { "USER", "SCHEMAS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_USER_ }, - { "USER", "SCHEMAS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_USER_ }, + { "USER", "SCHEMAS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SCHEMAS_FOR_ROLE_ }, { "USER", "TABLES", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLES_FOR_USER_ }, + { "USER", "TABLES", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLES_FOR_ROLE_ }, + { "USER", "TABLE_FUNCTIONS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_USER_ }, + { "USER", "TABLE_FUNCTIONS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::TABLE_FUNCTIONS_FOR_ROLE_ }, { "USER", "VIEWS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_USER_ }, + { "USER", "VIEWS", "FOR", "ROLE", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::VIEWS_FOR_ROLE_ }, // { "USER", "MVS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::MVS_FOR_USER_ }, // { "USER", "MVGROUPS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::MVGROUPS_FOR_USER_ }, // { "USER", "SYNONYMS", "FOR", "USER", 0, 0, 0, 0, ComTdbExeUtilGetMetadataInfo::SYNONYMS_FOR_USER_ }, http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/parser/ParKeyWords.cpp ---------------------------------------------------------------------- diff --git a/core/sql/parser/ParKeyWords.cpp b/core/sql/parser/ParKeyWords.cpp index 85b97e7..bdceb61 100644 --- a/core/sql/parser/ParKeyWords.cpp +++ b/core/sql/parser/ParKeyWords.cpp @@ -1211,7 +1211,7 @@ ParKeyWord ParKeyWords::keyWords_[] = { ParKeyWord("USA", TOK_USA, NONRESTOKEN_), ParKeyWord("USAGE", TOK_USAGE, ANS_|RESWORD_), ParKeyWord("USE", TOK_USE, FLAGSNONE_), - ParKeyWord("USER", TOK_USER, ANS_|RESWORD_), + ParKeyWord("USER", TOK_USER, ANS_|RESWORD_|SECOND_), ParKeyWord("USERNAME_INT_TO_EXT",TOK_USERNAMEINTTOEXT, NONRESTOKEN_), ParKeyWord("USERS", TOK_USERS, NONRESTOKEN_), ParKeyWord("USING", TOK_USING, ANS_|RESWORD_), http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/parser/sqlparser.y ---------------------------------------------------------------------- diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y index b053fb6..4793f41 100755 --- a/core/sql/parser/sqlparser.y +++ b/core/sql/parser/sqlparser.y @@ -688,6 +688,9 @@ static void enableMakeQuotedStringISO88591Mechanism() %token <tokval> TOK_FOR_REPEATABLE /* FOR REPEATABLE */ %token <tokval> TOK_FOR_SERIALIZABLE /* FOR SERIALIZABLE */ %token <tokval> TOK_FOR_STABLE /* FOR STABLE */ +%token <tokval> TOK_FOR_USER /* FOR GET .. FOR USER */ +%token <tokval> TOK_FOR_ROLE /* FOR GET ... FOR ROLE */ +%token <tokval> TOK_FOR_LIBRARY /* FOR GET ... FOR LIBRARY */ %token <tokval> TOK_FOUND %token <tokval> TOK_FRACTION /* Tandem extension non-reserved word */ %token <tokval> TOK_FROM @@ -1057,6 +1060,7 @@ static void enableMakeQuotedStringISO88591Mechanism() %token <tokval> TOK_SHOWDDL_COMPONENT %token <tokval> TOK_SHOWDDL_LIBRARY %token <tokval> TOK_SHOWDDL_SEQUENCE +%token <tokval> TOK_SHOWDDL_USER %token <tokval> TOK_SHOWDDL /* Tandem extension non-reserved word */ %token <tokval> TOK_SYSDATE %token <tokval> TOK_SYSTIMESTAMP @@ -2275,7 +2279,7 @@ static void enableMakeQuotedStringISO88591Mechanism() %type <pElemDDL> optional_schema_clause %type <stringval> optional_as_auth_clause %type <stringval> external_user_identifier -%type <tokval> user_or_role +%type <tokval> for_user_or_role %type <tokval> procedure_or_function %type <pStmtDDL> sql_schema_statement %type <pStmtDDL> sql_schema_definition_statement @@ -15439,13 +15443,15 @@ exe_util_get_metadata_info : $$ = gmi; } - | TOK_GET get_info_aus_clause procedure_or_function TOK_FOR TOK_LIBRARY table_name + | TOK_GET get_info_aus_clause procedure_or_function TOK_FOR_LIBRARY table_name + optional_no_header_and_match_pattern_clause { NAString aus("ALL"); NAString infoType; NAString iof("FOR"); NAString objType("LIBRARY"); CorrName cn(""); + // we want an empty get_info_aus_clause; it is just there to make the // production symetric with other GET statements and please the parser if (*$2 != "NONE") @@ -15457,24 +15463,34 @@ exe_util_get_metadata_info : else infoType = "TABLE_FUNCTIONS" ; + PtrPlaceHolder * pph = $6; + NAString * noHeader = (NAString *)pph->ptr1_; + NAString * pattern = (NAString *)pph->ptr2_; + NAString * fullyQualNames = (NAString *)pph->ptr3_; + ExeUtilGetMetadataInfo * gmi = new (PARSERHEAP ()) ExeUtilGetMetadataInfo( aus, // NAString & infoType, // NAString & iof, // NAString & objType, // NAString & objectType - *($6), // CorrName & + *($5), // CorrName & NULL, // NAString * pattern TRUE, // return fully qualified names FALSE, // getVersion NULL, // param1 -- the library name PARSERHEAP ()); // ColHeap * oHeap - //gmi->setNoHeader(TRUE); + if (noHeader) + gmi->setNoHeader(TRUE); + else if (NOT ((CmpCommon::getDefault(IS_SQLCI) == DF_ON) || + (CmpCommon::getDefault(NVCI_PROCESS) == DF_ON))) + gmi->setNoHeader(TRUE); + $$ = gmi; } | TOK_GET get_info_aus_clause obj_priv_identifier - TOK_FOR user_or_role authorization_identifier + for_user_or_role authorization_identifier optional_no_header_and_match_pattern_clause { NAString aus(*$2); @@ -15482,22 +15498,15 @@ exe_util_get_metadata_info : if (aus == "NONE") aus = "USER"; - if ((*$3 != "SEQUENCES" ) && (*$3 != "INDEXES" ) && - (*$3 != "PRIVILEGES") && (*$3 != "PROCEDURES") && - (*$3 != "FUNCTIONS" ) && (*$3 != "TABLE_MAPPING FUNCTIONS") && - (*$3 != "SCHEMAS" ) && (*$3 != "TABLES" ) && - (*$3 != "VIEWS" ) && (*$3 != "USERS" ) && - (*$3 != "ROLES" ) && (*$3 != "LIBRARIES" )) YYERROR; - NAString infoType(*$3); NAString iof("FOR"); NAString objType("USER"); - if ($5 == TOK_ROLE) + if ($4 == TOK_FOR_ROLE) objType = "ROLE"; - - PtrPlaceHolder * pph = $7; + + PtrPlaceHolder * pph = $6; NAString * noHeader = (NAString *)pph->ptr1_; NAString * pattern = (NAString *)pph->ptr2_; NABoolean fullyQualNames = (pph->ptr3_) ? TRUE : FALSE; @@ -15508,7 +15517,7 @@ exe_util_get_metadata_info : ExeUtilGetMetadataInfo * gmi = new (PARSERHEAP ()) ExeUtilGetMetadataInfo (aus, infoType, iof, objType, cnm, pattern, fullyQualNames, - getVersion, $6, PARSERHEAP ()); + getVersion, $5, PARSERHEAP ()); if (noHeader || (NOT ((CmpCommon::getDefault(IS_SQLCI) == DF_ON) || @@ -15793,16 +15802,16 @@ exe_util_get_metadata_info : $$ = gmi; } -user_or_role : TOK_USER | TOK_ROLE +for_user_or_role : TOK_FOR_USER | TOK_FOR_ROLE optional_for_user_clause : empty { $$ = NULL; } | TOK_FOR authorization_identifier { $$ = new(PARSERHEAP()) NAString(*$2); } - | TOK_FOR TOK_USER authorization_identifier + | TOK_FOR_USER authorization_identifier { - $$ = new(PARSERHEAP()) NAString(*$3); + $$ = new(PARSERHEAP()) NAString(*$2); } optional_authid_clause : empty { $$ = NULL; } @@ -22819,11 +22828,11 @@ show_statement: new (PARSERHEAP()) ColReference(new (PARSERHEAP()) ColRefName(TRUE, PARSERHEAP()))); } - | TOK_SHOWDDL TOK_USER authorization_identifier + | TOK_SHOWDDL_USER authorization_identifier { $$ = new (PARSERHEAP()) RelRoot(new (PARSERHEAP()) - Describe(SQLTEXT(), COM_USER_CLASS, *$3, Describe::SHOWDDL_), + Describe(SQLTEXT(), COM_USER_CLASS, *$2, Describe::SHOWDDL_), REL_ROOT, new (PARSERHEAP()) ColReference(new (PARSERHEAP()) ColRefName(TRUE, PARSERHEAP()))); http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/parser/ulexer.cpp ---------------------------------------------------------------------- diff --git a/core/sql/parser/ulexer.cpp b/core/sql/parser/ulexer.cpp index 26b1afb..3021814 100644 --- a/core/sql/parser/ulexer.cpp +++ b/core/sql/parser/ulexer.cpp @@ -2934,6 +2934,18 @@ Int32 yyULexer::yylex(YYSTYPE *lvalp) // retract to end of kwd1. retractToMark(end1); return anSQLMXKeyword(keyWordEntry1->getTokenCode(), lvalp); + case TOK_LIBRARY: + *end1 = holdChar1; + doBeforeAction(); + return aCompoundKeyword(TOK_FOR_LIBRARY, lvalp); + case TOK_ROLE: + *end1 = holdChar1; + doBeforeAction(); + return aCompoundKeyword(TOK_FOR_ROLE, lvalp); + case TOK_USER: + *end1 = holdChar1; + doBeforeAction(); + return aCompoundKeyword(TOK_FOR_USER, lvalp); case TOK_MAXRUNTIME: case TOK_REPEATABLE: case TOK_SERIALIZABLE: @@ -3108,6 +3120,12 @@ Int32 yyULexer::yylex(YYSTYPE *lvalp) TOK_SHOWDDL_SEQUENCE, keyWordEntry1->getTokenCode(), end1, holdChar1, lvalp); + else if (keyWordEntry2->getTokenCode() == TOK_USER) + return eitherCompoundOrSimpleKeyword + ( keyWordEntry2->getTokenCode() == TOK_USER, + TOK_SHOWDDL_USER, + keyWordEntry1->getTokenCode(), + end1, holdChar1, lvalp); break; case TOK_SERIALIZABLE: return eitherCompoundOrSimpleKeyword http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/regress/compGeneral/EXPECTEDTOK ---------------------------------------------------------------------- diff --git a/core/sql/regress/compGeneral/EXPECTEDTOK b/core/sql/regress/compGeneral/EXPECTEDTOK index e2bd723..2d2eabf 100644 --- a/core/sql/regress/compGeneral/EXPECTEDTOK +++ b/core/sql/regress/compGeneral/EXPECTEDTOK @@ -1,5 +1,5 @@ sqlparser.y: warning: 61 shift/reduce conflicts [-Wconflicts-sr] -sqlparser.y: warning: 12 reduce/reduce conflicts [-Wconflicts-rr] +sqlparser.y: warning: 9 reduce/reduce conflicts [-Wconflicts-rr] nnnn conflicts: 1 shift/reduce nnnn olap_sequence_function: set_function_specification . TOK_OVER '(' opt_olap_part_clause opt_olap_order_clause ')' nnnn conflicts: 1 shift/reduce nnnn value_expression: value_expression_sans_collate . collation_option @@ -17,10 +17,7 @@ nnnn conflicts: 2 shift/reduce nnnn value_expression_list_comma: value_expressio nnnn conflicts: 1 shift/reduce nnnn value_expression_list_comma: value_expression . ',' value_expression nnnn conflicts: 1 shift/reduce nnnn primary: row_subquery . nnnn conflicts: 1 shift/reduce nnnn control_statement: TOK_CONTROL TOK_QUERY TOK_SHAPE . query_shape_options query_shape_control -nnnn conflicts: 1 reduce/reduce nnnn procedure_or_function: TOK_PROCEDURES . -nnnn conflicts: 1 reduce/reduce nnnn procedure_or_function: TOK_FUNCTIONS . nnnn conflicts: 1 shift/reduce nnnn drop_catalog_statement: TOK_DROP TOK_CATALOG . catalog_name extension_drop_behavior -nnnn conflicts: 1 reduce/reduce nnnn procedure_or_function: TOK_TABLE_MAPPING TOK_FUNCTIONS . nnnn conflicts: 8 shift/reduce nnnn query_spec_body: query_select_list table_expression . access_type optional_lock_mode nnnn conflicts: 1 reduce/reduce nnnn primary: row_subquery . nnnn conflicts: 1 reduce/reduce nnnn primary: row_subquery . http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d013bc2/core/sql/regress/compGeneral/EXPECTEDTOK2 ---------------------------------------------------------------------- diff --git a/core/sql/regress/compGeneral/EXPECTEDTOK2 b/core/sql/regress/compGeneral/EXPECTEDTOK2 index e2bd723..2d2eabf 100644 --- a/core/sql/regress/compGeneral/EXPECTEDTOK2 +++ b/core/sql/regress/compGeneral/EXPECTEDTOK2 @@ -1,5 +1,5 @@ sqlparser.y: warning: 61 shift/reduce conflicts [-Wconflicts-sr] -sqlparser.y: warning: 12 reduce/reduce conflicts [-Wconflicts-rr] +sqlparser.y: warning: 9 reduce/reduce conflicts [-Wconflicts-rr] nnnn conflicts: 1 shift/reduce nnnn olap_sequence_function: set_function_specification . TOK_OVER '(' opt_olap_part_clause opt_olap_order_clause ')' nnnn conflicts: 1 shift/reduce nnnn value_expression: value_expression_sans_collate . collation_option @@ -17,10 +17,7 @@ nnnn conflicts: 2 shift/reduce nnnn value_expression_list_comma: value_expressio nnnn conflicts: 1 shift/reduce nnnn value_expression_list_comma: value_expression . ',' value_expression nnnn conflicts: 1 shift/reduce nnnn primary: row_subquery . nnnn conflicts: 1 shift/reduce nnnn control_statement: TOK_CONTROL TOK_QUERY TOK_SHAPE . query_shape_options query_shape_control -nnnn conflicts: 1 reduce/reduce nnnn procedure_or_function: TOK_PROCEDURES . -nnnn conflicts: 1 reduce/reduce nnnn procedure_or_function: TOK_FUNCTIONS . nnnn conflicts: 1 shift/reduce nnnn drop_catalog_statement: TOK_DROP TOK_CATALOG . catalog_name extension_drop_behavior -nnnn conflicts: 1 reduce/reduce nnnn procedure_or_function: TOK_TABLE_MAPPING TOK_FUNCTIONS . nnnn conflicts: 8 shift/reduce nnnn query_spec_body: query_select_list table_expression . access_type optional_lock_mode nnnn conflicts: 1 reduce/reduce nnnn primary: row_subquery . nnnn conflicts: 1 reduce/reduce nnnn primary: row_subquery .
