You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2017/05/01 14:21:07 UTC
[1/2] incubator-trafodion git commit: [TRAFODION-2294] Fix
permissions hole in Explain
Repository: incubator-trafodion
Updated Branches:
refs/heads/master b36003cf8 -> b791f8831
[TRAFODION-2294] Fix permissions hole in Explain
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9e37f06d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9e37f06d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9e37f06d
Branch: refs/heads/master
Commit: 9e37f06dcf033b6d95309ff4c401fa73abaf3314
Parents: b5eb1cf
Author: Dave Birdsall <db...@apache.org>
Authored: Thu Apr 27 16:43:05 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Thu Apr 27 16:43:05 2017 +0000
----------------------------------------------------------------------
core/sql/arkcmp/CmpStatement.cpp | 23 ++++--
core/sql/cli/Statement.cpp | 3 +
core/sql/cli/sqlcli.h | 5 +-
core/sql/comexe/CmpMessage.h | 10 ++-
core/sql/executor/ExExeUtilCli.cpp | 25 +++---
core/sql/executor/ExExeUtilCli.h | 3 +-
core/sql/executor/ExExeUtilExplain.cpp | 20 ++++-
core/sql/parser/SqlParserGlobalsCmn.h | 84 +-------------------
core/sql/parser/SqlParserGlobalsEnum.h | 119 ++++++++++++++++++++++++++++
core/sql/regress/privs1/EXPECTED120 | 16 ++++
core/sql/regress/privs1/TEST120 | 3 +
core/sql/sqlcomp/CmpMain.cpp | 10 ++-
core/sql/sqlcomp/CmpMain.h | 3 +-
13 files changed, 214 insertions(+), 110 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/arkcmp/CmpStatement.cpp
----------------------------------------------------------------------
diff --git a/core/sql/arkcmp/CmpStatement.cpp b/core/sql/arkcmp/CmpStatement.cpp
index 4c3cd24..ac8bc9a 100644
--- a/core/sql/arkcmp/CmpStatement.cpp
+++ b/core/sql/arkcmp/CmpStatement.cpp
@@ -329,7 +329,8 @@ static NABoolean processRecvdCmpCompileInfo(CmpStatement *cmpStmt,
NABoolean &odbcProcess,
NABoolean &noTextCache,
NABoolean &aqrPrepare,
- NABoolean &standaloneQuery)
+ NABoolean &standaloneQuery,
+ NABoolean &doNotCachePlan)
{
char * catSchStr = NULL;
cmpInfo->getUnpackedFields(sqlStr, catSchStr, recompControlInfo);
@@ -341,6 +342,7 @@ static NABoolean processRecvdCmpCompileInfo(CmpStatement *cmpStmt,
noTextCache = FALSE;
aqrPrepare = FALSE;
standaloneQuery = FALSE;
+ doNotCachePlan = FALSE;
if (!sqlStr)
{
@@ -360,6 +362,7 @@ static NABoolean processRecvdCmpCompileInfo(CmpStatement *cmpStmt,
noTextCache = cmpInfo->noTextCache();
aqrPrepare = cmpInfo->aqrPrepare();
standaloneQuery = cmpInfo->standaloneQuery();
+ doNotCachePlan = cmpInfo->doNotCachePlan();
if (recompControlInfo)
{
@@ -425,6 +428,7 @@ CmpStatement::process (const CmpMessageSQLText& sqltext)
NABoolean noTextCache;
NABoolean aqrPrepare;
NABoolean standaloneQuery;
+ NABoolean doNotCachePlan;
if (processRecvdCmpCompileInfo(this,
sqltext,
sqltext.getCmpCompileInfo(),
@@ -439,7 +443,8 @@ CmpStatement::process (const CmpMessageSQLText& sqltext)
odbcProcess,
noTextCache,
aqrPrepare,
- standaloneQuery))
+ standaloneQuery,
+ doNotCachePlan))
return CmpStatement_ERROR;
reply_ = new(outHeap_) CmpMessageReplyCode( outHeap_, sqltext.id(), 0, 0, outHeap_);
@@ -499,7 +504,7 @@ CmpStatement::process (const CmpMessageSQLText& sqltext)
cmpmain.sqlcomp(qText, 0,
&(reply_->data()), &(reply_->size()),
reply_->outHeap(), CmpMain::END,
- &fragmentDir, typ);
+ &fragmentDir, typ, !doNotCachePlan);
}
catch (...)
{
@@ -623,6 +628,7 @@ CmpStatement::process (const CmpMessageCompileStmt& compilestmt)
NABoolean noTextCache;
NABoolean aqrPrepare;
NABoolean standaloneQuery;
+ NABoolean doNotCachePlan;
if (processRecvdCmpCompileInfo(this,
compilestmt,
compilestmt.getCmpCompileInfo(),
@@ -637,7 +643,8 @@ CmpStatement::process (const CmpMessageCompileStmt& compilestmt)
odbcProcess,
noTextCache,
aqrPrepare,
- standaloneQuery))
+ standaloneQuery,
+ doNotCachePlan))
return CmpStatement_ERROR;
reply_ =
@@ -758,6 +765,7 @@ CmpStatement::process (const CmpMessageDDL& statement)
NABoolean noTextCache;
NABoolean aqrPrepare;
NABoolean standaloneQuery;
+ NABoolean doNotCachePlan;
isDDL_ = TRUE;
if (processRecvdCmpCompileInfo(this,
@@ -774,7 +782,8 @@ CmpStatement::process (const CmpMessageDDL& statement)
odbcProcess,
noTextCache,
aqrPrepare,
- standaloneQuery))
+ standaloneQuery,
+ doNotCachePlan))
return CmpStatement_ERROR;
CmpCommon::context()->sqlSession()->setParentQid(
@@ -1056,6 +1065,7 @@ CmpStatement::process(const CmpMessageDDLwithStatus &statement)
NABoolean noTextCache;
NABoolean aqrPrepare;
NABoolean standaloneQuery;
+ NABoolean doNotCachePlan;
isDDL_ = TRUE;
if (processRecvdCmpCompileInfo(NULL,
@@ -1072,7 +1082,8 @@ CmpStatement::process(const CmpMessageDDLwithStatus &statement)
odbcProcess,
noTextCache,
aqrPrepare,
- standaloneQuery))
+ standaloneQuery,
+ doNotCachePlan))
return CmpStatement_ERROR;
CmpCommon::context()->sqlSession()->setParentQid(statement.getParentQid());
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/cli/Statement.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Statement.cpp b/core/sql/cli/Statement.cpp
index ce213c1..a6aead5 100644
--- a/core/sql/cli/Statement.cpp
+++ b/core/sql/cli/Statement.cpp
@@ -1437,6 +1437,7 @@ RETCODE Statement::prepare2(char *source, ComDiagsArea &diagsArea,
NABoolean deCache = (cliFlags & PREPARE_WITH_DECACHE) != 0;
NABoolean noTextCache = (cliFlags & PREPARE_NO_TEXT_CACHE) != 0;
NABoolean standaloneQuery = (cliFlags & PREPARE_STANDALONE_QUERY) != 0;
+ NABoolean doNotCache = (cliFlags & PREPARE_DONT_CACHE) != 0;
this->setStandaloneQ(standaloneQuery);
NABoolean wmsMonitoringNeeded = (cliFlags & PREPARE_MONITOR_THIS_QUERY) !=0;
@@ -1651,6 +1652,7 @@ RETCODE Statement::prepare2(char *source, ComDiagsArea &diagsArea,
c.setAqrPrepare(aqRetry);
else if (noTextCache)
c.setNoTextCache(noTextCache);
+ c.setDoNotCachePlan(doNotCache);
if (standaloneQuery)
c.setStandaloneQuery(standaloneQuery);
@@ -1704,6 +1706,7 @@ RETCODE Statement::prepare2(char *source, ComDiagsArea &diagsArea,
c.setAqrPrepare(aqRetry);
else if (noTextCache)
c.setNoTextCache(noTextCache);
+ c.setDoNotCachePlan(doNotCache);
if (standaloneQuery)
c.setStandaloneQuery(standaloneQuery);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/cli/sqlcli.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/sqlcli.h b/core/sql/cli/sqlcli.h
index 98149de..dfe04a3 100644
--- a/core/sql/cli/sqlcli.h
+++ b/core/sql/cli/sqlcli.h
@@ -1275,7 +1275,10 @@ enum PREPARE_FLAGS
PREPARE_MONITOR_THIS_QUERY = 0x0040,
/* set when embedded compiler needs to be called */
- PREPARE_USE_EMBEDDED_ARKCMP = 0x0080
+ PREPARE_USE_EMBEDDED_ARKCMP = 0x0080,
+
+ /* set when we don't want the plan to go in the query cache */
+ PREPARE_DONT_CACHE = 0x0100
};
/* used to put and get DDL redefinition invalidation keys */
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/comexe/CmpMessage.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/CmpMessage.h b/core/sql/comexe/CmpMessage.h
index 7822fce..fde5f53 100644
--- a/core/sql/comexe/CmpMessage.h
+++ b/core/sql/comexe/CmpMessage.h
@@ -377,6 +377,11 @@ public:
void setHbaseDDL(NABoolean v)
{ (v ? flags_ |= HBASE_DDL : flags_ &= ~HBASE_DDL); }
+ NABoolean doNotCachePlan()
+ { return (flags_ & DO_NOT_CACHE_PLAN) != 0; }
+ void setDoNotCachePlan(NABoolean v)
+ { (v ? flags_ |= DO_NOT_CACHE_PLAN : flags_ &= ~DO_NOT_CACHE_PLAN); }
+
enum { FILLERSIZE = 56 /* used to be 60 - took 4 bytes for sqlTextCharSet_ */ } ; // of original 72
protected:
@@ -410,7 +415,10 @@ protected:
// this is a request to perform a SQL ddl operation that will be converted
// to an hbase object
- HBASE_DDL = 0x0800
+ HBASE_DDL = 0x0800,
+
+ // do not cache the resulting query plan
+ DO_NOT_CACHE_PLAN = 0x1000
};
char * sqltext_; // 00-07
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/executor/ExExeUtilCli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilCli.cpp b/core/sql/executor/ExExeUtilCli.cpp
index e29938a..fdfef44 100644
--- a/core/sql/executor/ExExeUtilCli.cpp
+++ b/core/sql/executor/ExExeUtilCli.cpp
@@ -278,20 +278,21 @@ Lng32 ExeCliInterface::allocStuff(SQLMODULE_ID * &module,
}
Lng32 ExeCliInterface::prepare(const char * stmtStr,
- SQLMODULE_ID * module,
- SQLSTMT_ID * stmt,
- SQLDESC_ID * sql_src,
- SQLDESC_ID * input_desc,
- SQLDESC_ID * output_desc,
- char ** outputBuf,
+ SQLMODULE_ID * module,
+ SQLSTMT_ID * stmt,
+ SQLDESC_ID * sql_src,
+ SQLDESC_ID * input_desc,
+ SQLDESC_ID * output_desc,
+ char ** outputBuf,
Queue * outputVarPtrList,
- char ** inputBuf,
+ char ** inputBuf,
Queue * inputVarPtrList,
char *uniqueStmtId,
Lng32 *uniqueStmtIdLen,
SQL_QUERY_COST_INFO *query_cost_info,
- SQL_QUERY_COMPILER_STATS_INFO *comp_stats_info,
- NABoolean monitorThis)
+ SQL_QUERY_COMPILER_STATS_INFO *comp_stats_info,
+ NABoolean monitorThis,
+ NABoolean doNotCachePlan)
{
Lng32 retcode = 0;
ULng32 prepFlags = 0;
@@ -307,6 +308,12 @@ Lng32 ExeCliInterface::prepare(const char * stmtStr,
prepFlags |= PREPARE_USE_EMBEDDED_ARKCMP;
}
+ if (doNotCachePlan)
+ {
+ prepFlags |= PREPARE_NO_TEXT_CACHE;
+ prepFlags |= PREPARE_DONT_CACHE;
+ }
+
retcode = SQL_EXEC_SetDescItem(sql_src, 1, SQLDESC_LENGTH,
strlen(stmtStr) + 1, 0);
if (retcode != SUCCESS)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/executor/ExExeUtilCli.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilCli.h b/core/sql/executor/ExExeUtilCli.h
index 7f47762..9068602 100644
--- a/core/sql/executor/ExExeUtilCli.h
+++ b/core/sql/executor/ExExeUtilCli.h
@@ -116,7 +116,8 @@ private:
Lng32 *uniqueStmtIdLen = NULL,
SQL_QUERY_COST_INFO *query_cost_info = NULL,
SQL_QUERY_COMPILER_STATS_INFO *comp_stats_info = NULL,
- NABoolean monitorThis = FALSE);
+ NABoolean monitorThis = FALSE,
+ NABoolean doNotCachePlan = FALSE);
Lng32 setupExplainData(SQLMODULE_ID * module,
SQLSTMT_ID * stmt);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/executor/ExExeUtilExplain.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilExplain.cpp b/core/sql/executor/ExExeUtilExplain.cpp
index dc79d44..3e44e3e 100644
--- a/core/sql/executor/ExExeUtilExplain.cpp
+++ b/core/sql/executor/ExExeUtilExplain.cpp
@@ -52,6 +52,8 @@
#include "ComRtUtils.h"
#include "ExStats.h"
+#include "SqlParserGlobalsEnum.h"
+
//////////////////////////////////////////////////////////
// classes defined in this file:
//
@@ -254,13 +256,23 @@ short ExExeUtilDisplayExplainTcb::work()
pstate.step_ = HANDLE_ERROR_;
break;
}
-
+
char * stmtStr = exeUtilTdb().getQuery();
retcode = cliInterface()->prepare(stmtStr,
module_,
stmt_, sql_src_,
input_desc_, output_desc_,
- NULL);
+ NULL /* outputBuf */,
+ NULL /* outputVarPtrList */,
+ NULL /* inputBuf */,
+ NULL /* inputVarPtrList */,
+ NULL /* uniqueStmtId */,
+ NULL /* uniqueStmtIdLen */,
+ NULL /* query_cost_info */,
+ NULL /* comp_stats_info */,
+ FALSE /* monitorThis */,
+ TRUE /* doNotCachePlan */);
+
if (retcode < 0)
{
cliInterface()->retrieveSQLDiagnostics(getDiagsArea());
@@ -277,7 +289,7 @@ short ExExeUtilDisplayExplainTcb::work()
{
// set sqlparserflags to disable stats for explain query
// DISABLE_RUNTIME_STATS 0x80000
- masterGlob->getStatement()->getContext()->setSqlParserFlags(0x80000);
+ masterGlob->getStatement()->getContext()->setSqlParserFlags(DISABLE_RUNTIME_STATS);
/*set the flag here, use it later*/
if (exeUtilTdb().isOptionF() > 0)
@@ -619,7 +631,7 @@ short ExExeUtilDisplayExplainTcb::work()
// reset sqlparserflags that disabled stats for Explain query
// DISABLE_RUNTIME_STATS = 0x80000
- masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x80000);
+ masterGlob->getStatement()->getContext()->resetSqlParserFlags(DISABLE_RUNTIME_STATS);
//reset variables used for options E_ and N_
cntLines_ = 0;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/parser/SqlParserGlobalsCmn.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/SqlParserGlobalsCmn.h b/core/sql/parser/SqlParserGlobalsCmn.h
index d72b6c3..63e6474 100644
--- a/core/sql/parser/SqlParserGlobalsCmn.h
+++ b/core/sql/parser/SqlParserGlobalsCmn.h
@@ -47,89 +47,7 @@
#if defined(SQLPARSERGLOBALS_FLAGS) || defined(SQLPARSERGLOBALSCMN__INITIALIZE)
#include "BaseTypes.h"
-
- // Changes to these values must be reflected in regression test
- // settings of env var "SQLPARSER_FLAGS", used by parser.cpp.
-enum SqlParser_Flags_Enum {
-
- // IPC-copiable flags
-
- // ## We could define bits here to help implement a SQL Flagger
- // ## (Ansi 4.34 and 23.3/23.4), e.g.
- // DISALLOW_FULL_LEVEL_SQL, DISALLOW_INTERMEDIATE_LEVEL_SQL
-
- ALLOW_SPECIALTABLETYPE = 0x1, // used by SqlParser.y
- ALLOW_FUNNY_IDENTIFIER = 0x2, // used by NAString.C
- ALLOW_FUNNY_TABLE_CREATE = 0x4, // CatExecCreateTable.C
- ALLOW_ADD_CONSTRAINT_NOT_DROPPABLE = 0x8, // BindStmtDDL.C
-
- // QSTUFF
- // this allows old and new values to be specified for
- // update with return values
- ALLOW_OLD_AND_NEW_KEYWORD = 0x10,
- // QSTUFF
-
- // Allows users to be registered even when they don't exist
- DISABLE_EXTERNAL_USERNAME_CHECK = 0x40,
-
- // set in sqlcomp/parser.cpp Parser::parseSQL and used in
- // parser/SqlParserAux.cpp literalOfNumericPassingScale to
- // allow generator & binder to specify arbitrary precision
- // for exact numeric literals
- ALLOW_ARB_PRECISION_LITERALS = 0x100,
- ALLOW_UNKNOWN_CHARSET = 0x200, // used by SqlParser.y for charsets
-
-
- // Indicate that an error should not be returned
- // if volatile schema name has been explicitely specified
- // as part of the table name.
- // Used when internal queries prepared since they may
- // already be fullyqualified.
- ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME = 0x8000,
-
- // set if volatile schema usage is to be disabled.
- // For example, when operations (alter, create view)
- // are not supported on volatile objects and name lookup
- // should not look for them in the volatile schema
- DISABLE_VOLATILE_SCHEMA = 0x10000,
-
- // set, if a query is internally issued from master executor as
- // part of an ExeUtil operator.
- INTERNAL_QUERY_FROM_EXEUTIL = 0x20000,
-
-
- DISABLE_RUNTIME_STATS = 0x80000,
-
-
- // allows cqds that are set in ndcs DSN to be processed. These
- // are also called setOnce cqds (see sqlcomp/nadefaults.cpp).
- // These cqds cannot be set by users during a regular session.
- // If this flag is not set, these cqds cannot be set.
- // (exception is when defaults are internally sent during mxcmp
- // recreation after an abend, or to the secondary mxcmp).
- ALLOW_SET_ONCE_DEFAULTS = 0x400000,
-
-
- // causes errors to be given for any constructs not allowed in the context
- // of the Where clause of an incremental update stats (IUS) statement.
- PARSING_IUS_WHERE_CLAUSE = 0x1000000,
-
- // special mode_special_4 mode. Used to enable specialized and non-ansi
- // functionality.
- // See cqd mode_special_4.
- IN_MODE_SPECIAL_4 = 0x2000000,
-
- // The bits of the flag word are divided into copiable and uncopiable portions.
- // See the comments for function receiveAndSetUp() in arkcmp/cmpconnection.cpp.
- // Enum values above are copiable, those below are uncopiable.
- IPC_COPIABLE_MASK = 0x0FFFFFFF, // 28 lowest flag bits
- IPC_UNCOPIABLE_MASK = 0xF0000000, // 4 highest flag bits
-
- // IPC-uncopiable flags
- DELAYED_RESET = 0x10000000 // used by cmpmain.cpp
-
-
-};
+ #include "SqlParserGlobalsEnum.h" // to get SqlParser_Flags_Enum
GLOB_ THREAD_P ULng32 SqlParser_Flags INIT_(0);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/parser/SqlParserGlobalsEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/SqlParserGlobalsEnum.h b/core/sql/parser/SqlParserGlobalsEnum.h
new file mode 100644
index 0000000..137b725
--- /dev/null
+++ b/core/sql/parser/SqlParserGlobalsEnum.h
@@ -0,0 +1,119 @@
+/**********************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**********************************************************************/
+
+#ifndef SQLPARSERGLOBALSENUM_H
+#define SQLPARSERGLOBALSENUM_H
+/* -*-C++-*-
+ *****************************************************************************
+ *
+ * File: SqlParserGlobalsEnum.h
+ *
+ * Description: Contains the enum SqlParser_Flags_Enum
+ *
+ *****************************************************************************
+ */
+
+
+ // Changes to these values must be reflected in regression test
+ // settings of env var "SQLPARSER_FLAGS", used by parser.cpp.
+enum SqlParser_Flags_Enum {
+
+ // IPC-copiable flags
+
+ // ## We could define bits here to help implement a SQL Flagger
+ // ## (Ansi 4.34 and 23.3/23.4), e.g.
+ // DISALLOW_FULL_LEVEL_SQL, DISALLOW_INTERMEDIATE_LEVEL_SQL
+
+ ALLOW_SPECIALTABLETYPE = 0x1, // used by SqlParser.y
+ ALLOW_FUNNY_IDENTIFIER = 0x2, // used by NAString.C
+ ALLOW_FUNNY_TABLE_CREATE = 0x4, // CatExecCreateTable.C
+ ALLOW_ADD_CONSTRAINT_NOT_DROPPABLE = 0x8, // BindStmtDDL.C
+
+ // QSTUFF
+ // this allows old and new values to be specified for
+ // update with return values
+ ALLOW_OLD_AND_NEW_KEYWORD = 0x10,
+ // QSTUFF
+
+ // Allows users to be registered even when they don't exist
+ DISABLE_EXTERNAL_USERNAME_CHECK = 0x40,
+
+ // set in sqlcomp/parser.cpp Parser::parseSQL and used in
+ // parser/SqlParserAux.cpp literalOfNumericPassingScale to
+ // allow generator & binder to specify arbitrary precision
+ // for exact numeric literals
+ ALLOW_ARB_PRECISION_LITERALS = 0x100,
+ ALLOW_UNKNOWN_CHARSET = 0x200, // used by SqlParser.y for charsets
+
+
+ // Indicate that an error should not be returned
+ // if volatile schema name has been explicitely specified
+ // as part of the table name.
+ // Used when internal queries prepared since they may
+ // already be fullyqualified.
+ ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME = 0x8000,
+
+ // set if volatile schema usage is to be disabled.
+ // For example, when operations (alter, create view)
+ // are not supported on volatile objects and name lookup
+ // should not look for them in the volatile schema
+ DISABLE_VOLATILE_SCHEMA = 0x10000,
+
+ // set, if a query is internally issued from master executor as
+ // part of an ExeUtil operator.
+ INTERNAL_QUERY_FROM_EXEUTIL = 0x20000,
+
+ DISABLE_RUNTIME_STATS = 0x80000,
+
+
+ // allows cqds that are set in ndcs DSN to be processed. These
+ // are also called setOnce cqds (see sqlcomp/nadefaults.cpp).
+ // These cqds cannot be set by users during a regular session.
+ // If this flag is not set, these cqds cannot be set.
+ // (exception is when defaults are internally sent during mxcmp
+ // recreation after an abend, or to the secondary mxcmp).
+ ALLOW_SET_ONCE_DEFAULTS = 0x400000,
+
+
+ // causes errors to be given for any constructs not allowed in the context
+ // of the Where clause of an incremental update stats (IUS) statement.
+ PARSING_IUS_WHERE_CLAUSE = 0x1000000,
+
+ // special mode_special_4 mode. Used to enable specialized and non-ansi
+ // functionality.
+ // See cqd mode_special_4.
+ IN_MODE_SPECIAL_4 = 0x2000000,
+
+ // The bits of the flag word are divided into copiable and uncopiable portions.
+ // See the comments for function receiveAndSetUp() in arkcmp/cmpconnection.cpp.
+ // Enum values above are copiable, those below are uncopiable.
+ IPC_COPIABLE_MASK = 0x0FFFFFFF, // 28 lowest flag bits
+ IPC_UNCOPIABLE_MASK = 0xF0000000, // 4 highest flag bits
+
+ // IPC-uncopiable flags
+ DELAYED_RESET = 0x10000000 // used by cmpmain.cpp
+
+
+};
+
+#endif // SQLPARSERGLOBALSENUM_H
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/regress/privs1/EXPECTED120
----------------------------------------------------------------------
diff --git a/core/sql/regress/privs1/EXPECTED120 b/core/sql/regress/privs1/EXPECTED120
index fc84cbc..113b2d8 100644
--- a/core/sql/regress/privs1/EXPECTED120
+++ b/core/sql/regress/privs1/EXPECTED120
@@ -297,6 +297,22 @@ SQL_USER6
*** ERROR[8822] The statement was not prepared.
+>>-- the next two lines insure that explain isn't a back door (JIRA TRAFODION-2294)
+>>explain options 'f' select * from games;
+
+LC RC OP OPERATOR OPT DESCRIPTION CARD
+---- ---- ---- -------------------- -------- -------------------- ---------
+
+1 . 2 root 1.00E+002
+. . 1 trafodion_scan GAMES 1.00E+002
+
+--- SQL operation complete.
+>>select * from games;
+
+*** ERROR[4481] The user does not have SELECT privilege on table or view TRAFODION.T120SCH.GAMES.
+
+*** ERROR[8822] The statement was not prepared.
+
>>
>>-- sql_user9 also has no privileges
>>sh sqlci -i "TEST120(select_queries)" -u sql_user9;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/regress/privs1/TEST120
----------------------------------------------------------------------
diff --git a/core/sql/regress/privs1/TEST120 b/core/sql/regress/privs1/TEST120
index 9f771a8..7dca9ea 100755
--- a/core/sql/regress/privs1/TEST120
+++ b/core/sql/regress/privs1/TEST120
@@ -197,6 +197,9 @@ prepare update_teams from
prepare select_players from select count(*) from players;
prepare select_standings from select team_number, seqnum(team_seq) from standings;
prepare select_stats from select team_number, num_players from stats;
+-- the next two lines insure that explain isn't a back door (JIRA TRAFODION-2294)
+explain options 'f' select * from games;
+select * from games;
-- sql_user9 also has no privileges
sh sqlci -i "TEST120(select_queries)" -u sql_user9;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/sqlcomp/CmpMain.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpMain.cpp b/core/sql/sqlcomp/CmpMain.cpp
index 0b884dc..ce75d82 100644
--- a/core/sql/sqlcomp/CmpMain.cpp
+++ b/core/sql/sqlcomp/CmpMain.cpp
@@ -636,8 +636,9 @@ CmpMain::ReturnStatus CmpMain::sqlcomp(QueryText& input, //IN
ULng32 *gen_code_len, //OUT
CollHeap *heap, //IN
CompilerPhase phase, //IN
- FragmentDir **fragmentDir, //OUT
- IpcMessageObjType op) //IN
+ FragmentDir **fragmentDir, //OUT
+ IpcMessageObjType op, //IN
+ NABoolean useQueryCache) //IN
{
TimeVal begTime;
GETTIMEOFDAY(&begTime, 0);
@@ -693,9 +694,10 @@ CmpMain::ReturnStatus CmpMain::sqlcomp(QueryText& input, //IN
sqlcompCleanup("", queryExpr, FALSE);
return PARSERERROR;
}
- // make at most 2 tries to compile a query: 1st with caching on, and
+ // make at most 2 tries to compile a query: 1st with caching on
+ // (assuming our caller wants it on), and
// on any error, retry it with caching off if query was cacheable
- NABoolean useQueryCache=TRUE, cacheable=FALSE, useTextCache=TRUE;
+ NABoolean cacheable=FALSE, useTextCache=TRUE;
// if running in OSIM capture mode or simulation, don't use the cache
if (OSIM_runningInCaptureMode()||OSIM_runningSimulation())
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37f06d/core/sql/sqlcomp/CmpMain.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpMain.h b/core/sql/sqlcomp/CmpMain.h
index 771d080..32659e0 100644
--- a/core/sql/sqlcomp/CmpMain.h
+++ b/core/sql/sqlcomp/CmpMain.h
@@ -172,7 +172,8 @@ public:
NAMemory *h = NULL,
CompilerPhase = END,
FragmentDir **framentDir = NULL,
- IpcMessageObjType op=CmpMessageObj::SQLTEXT_COMPILE);
+ IpcMessageObjType op=CmpMessageObj::SQLTEXT_COMPILE,
+ NABoolean useQueryCache=TRUE);
// sqlcomp will compile a RelExpr into code from generator
ReturnStatus sqlcomp (const char *input_str, Lng32 charset,
[2/2] incubator-trafodion git commit: Merge [TRAFODION-2294] PR 1074
Fix permissions hole in Explain
Posted by db...@apache.org.
Merge [TRAFODION-2294] PR 1074 Fix permissions hole in Explain
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/b791f883
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/b791f883
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/b791f883
Branch: refs/heads/master
Commit: b791f883141b524fd7bc19564511796b5352afa5
Parents: b36003c 9e37f06
Author: Dave Birdsall <db...@apache.org>
Authored: Mon May 1 14:19:53 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon May 1 14:19:53 2017 +0000
----------------------------------------------------------------------
core/sql/arkcmp/CmpStatement.cpp | 23 ++++--
core/sql/cli/Statement.cpp | 3 +
core/sql/cli/sqlcli.h | 5 +-
core/sql/comexe/CmpMessage.h | 10 ++-
core/sql/executor/ExExeUtilCli.cpp | 25 +++---
core/sql/executor/ExExeUtilCli.h | 3 +-
core/sql/executor/ExExeUtilExplain.cpp | 20 ++++-
core/sql/parser/SqlParserGlobalsCmn.h | 84 +-------------------
core/sql/parser/SqlParserGlobalsEnum.h | 119 ++++++++++++++++++++++++++++
core/sql/regress/privs1/EXPECTED120 | 16 ++++
core/sql/regress/privs1/TEST120 | 3 +
core/sql/sqlcomp/CmpMain.cpp | 10 ++-
core/sql/sqlcomp/CmpMain.h | 3 +-
13 files changed, 214 insertions(+), 110 deletions(-)
----------------------------------------------------------------------