Clone Tools
Constraints: committers
Constraints: files
Constraints: dates
TRAFODION-3121 Enhance 'initialize trafodion' to return progress status

-- init traf will now return status during various steps.

'Started' indication will be returned when that step starts.

'Completed' will be returned when it completes successfully.

'Failed' will be returned if that step fails.

Elapsed time for each step will be shown in {ET hh:mm:ss} format.

-- method CmpSeabaseDDL::initSeabaseMD is rewritten and moved from

file CmpSeabaseDDLcommon.cpp to new file CmpSeabaseDDLinitraf.cpp.

-- priv mgr tables are now always created during init traf.

-- a 'no return status' option has been added if status is not to be

returned during init traf. This is used when init traf is called

internally, for ex, during upgrade.

It is not an externalized option.

-- Output of init traf is shown below.

Note: output is not a printf/cout to stdout.

It is returned as selected rows to the caller.

Apache Trafodion Conversational Interface 2.3.0

Copyright (c) 2015-2017 Apache Software Foundation

>>initialize trafodion;

Initialize Trafodion: Started

Verify User: Started

Verify User: Completed {ET: 00:00:00}

Version Check: Started

Version Check: Completed {ET: 00:00:00}

Create Metadata Tables: Started

Create Metadata Tables: Completed {ET: 00:00:49}

Update Metadata Tables: Started

Update Metadata Tables: Completed {ET: 00:00:06}

Create Schema Objects: Started

Create Schema Objects: Completed {ET: 00:00:20}

Create Metadata Views: Started

Create Metadata Views: Completed {ET: 00:00:05}

Create Repository Tables: Started

Create Repository Tables: Completed {ET: 00:00:16}

Create PrivMgr Tables: Started

Create PrivMgr Tables: Completed {ET: 00:00:29}

Create Library Manager: Started

Create Library Manager: Completed {ET: 00:00:51}

Initialize Trafodion: Completed {ET: 00:03:09}

--- SQL operation complete.

  1. … 36 more files in changeset.
TRAFODION-3086 Further enhancements to 'DDL on Hive objects'

-- Hive CTAS enhancements

-- CTAS will do create through Hive and in Traf

-- a cqd can be set if CTAS need to be passed in completely to Hive

-- CTAS 'no load' option can be used to create a Hive

table LIKE a traf table.

Older 'create hive like traf' is removed.

-- explain for CTAS to show ddl,, upd...stats stmts

-- Truncate enhancements.

-- traf: purgedata, truncate, truncate table

-- Hive: truncate, truncate table

-- 'if exists' option has been added

-- Hive truncate is through new exeutil operator

-- older operator uses LOB interface to clear data.

Maintained as Legacy operator, will be removed.

-- new operator uses Hive to truncate tables

-- explain for truncate to show trunc query that will be sent

-- removed obsolete parallel label op

-- removed obsolete purgedata (fast delete) op

  1. … 30 more files in changeset.
[TRAFODION-2727] Memory leak in the compiler part of the code in Trafodion

It was found that CmpMessageReplyCode was not getting deleted at all times.

But, the handling of CmpMessageDescribe messages in the compiler code has some

mysterious issue that corrupts the memory causing unpredictable behavior when

CmpMessageReplyCode is deleted. To circumvent this problem, the CmpStatement heap

is used for embedded compiler to allocate CmpMessageReplyCode and the Context heap

is used in case of standalone compiler. The handling of CmpMessageDescribe will

continue to leak memory in standalone compiler.

  1. … 3 more files in changeset.
Merge PR 1389 [TRAFOFION-2731] CodeCleanup: Removed the obsolete code in NAMemory and CliGlobals classes

  1. … 1 more file in changeset.
Merge [TRAFODION-2879] Core dump four more fixes, see below PR-1384

  1. … 2 more files in changeset.
[TRAFOFION-2731] CodeCleanup: Removed the obsolete code in NAMemory and CliGlobals classes

  1. … 8 more files in changeset.
[TRAFODION-2879] Core dump due to reference to deallocated memory for EstLogProp object

In the optimizer, we often use a define to refer to an "empty input

logical properties" object. The problem was that this object was

allocated on the statement heap but it was owned by the CmpContext

object, which lives longer than the statement heap. During debugging,

we have seen cases where this led to references of deleted memory.

The fix is to move the empty logical properties to the CmpStatement


  1. … 5 more files in changeset.
[TRAFODION-2888] Streamline setjmp/longjmp concepts in Trafodion

First set of changes to streamline setjmp/longjmp.

a) Removed the setjmp in heap management within Trafodion.

b) Removed obsolete code related to No-wait operation concepts in SQL

  1. … 30 more files in changeset.
TRAFODION-2731 CodeCleanup: Phase 4. Remove legacy/obsolete pragmas

  1. … 392 more files in changeset.
TRAFODION-2731 CodeCleanup: Remove obsolete, legacy and unused code

This phase handles the following:

-- removal of code that dealt with:

-- mpalias, NSK, MP, mploc, resource fork, rfork

-- ARLIB, DISK, VOLUME, PFS, compiler version info

-- interpretasrow/IAR, AuditImage, ExtractColumns functions

-- ARKCMP_SINGLE_PROCESS and oneProcess()

-- recompControl, remoteDefaults, rtdu, module

-- latebind thru nsk defines, guardian names, nametype nsk

-- SHADOW implementation


-- older sqlcat ReadTableDef


-- internal cli methods no longer used by any caller

Code within the following defines is removed if it is obsolete

or the define itself is removed if that feature is always on:

-- removed NA_EIDPROC

-- removed SQLEXP_LIB_FUNC

-- removed NA_CMPDLL


-- removed SQ_NEW_PHANDLE

-- removed __EID

-- removed ARKFS_OPEN

-- removed STAND_ALONE

-- removed __TANDEM

-- removed NA_C89

-- removed NA_NSK


-- removed SQLCLI_LIB_FUNC

-- removed CLI_PRIV_SRL

-- removed PRIV_SRL

-- removed NA_LINUX

-- removed NA_HSC_LINUX

-- removed NA_UNIX

-- removed NA_WINNT

-- removed HAVE_MMAP

-- removed NA_NO_C_RUNTIME

-- removed NA_DEBUG_C_RUNTIME(replaced with _DEBUG)

-- removed NA_64BIT usage except in sqlcli.h

-- removed dg64

-- removed SQLEXPORT_LIB

-- removed NA_ARKFS

-- removed NA_IEEE_FLOAT

-- removed NA_GUARDIAN_MSG

-- removed NA_HSC


-- removed ERROR

-- removed ERROR_STATE


Contents of these files have been removed.

Next checkin fill remove the files itself from git:


executor/ExMeas.h, ExMeas.cpp

executor/tempfile.h, .cpp


executor/stubs.cpp, stubs2.cpp


cli/rtdu.h, rtdu2.h, rtdu.cpp, rtdu.cpp












sqlcat/ReadTableDef.h, cpp

sqlcat/readRealArk.h, cpp

  1. … 460 more files in changeset.
TRAFODION-2722 Change purgedata to use HBase truncate api

Traf now uses HBase truncate api to delete all rows from

a table and indexes, instead of dropping/recreating underlying HBase


A second change has also been added to fix a bug where compiler cache

was being cleared whenever a DDL statement was issued.

This change was added a while back before Query Invalidation(QI) feature

was available and was not removed when QI was added.

It has now been removed.

  1. … 4 more files in changeset.
[TRAFODION-2605] Rework of fix for TRAFODION-2294

  1. … 4 more files in changeset.
[TRAFODION-2294] Fix permissions hole in Explain

  1. … 12 more files in changeset.
[TRAFODION-2315] Heuristic decision for common subexpressions

This includes various fixes in addition to the heuristic decision,

mainly an improvement on how to navigate between parent and child

common subexpressions.

  1. … 29 more files in changeset.
[TRAFODION-2317] Infrastructure for common subexpressions

This is a first set of changes to allow us to make use of CTEs

(Common Table Expressions) declared in WITH clauses and to create

a temp table for them that is then read multiple times in the query.

This also includes a fix for

[TRAFODION-2280] Need to remove salt columns from uniqueness constraints

Summary of changes:

- Adding a unique statement number in CmpContext

- Moving the execHiveSQL method from the OSIM code to CmpContext

- Adding a list of common subexpressions and their references

to CmpStatement

- Adding the ability to the Hive Truncate operator to drop the

table when the TCB gets deallocated

- Adding the ability to the HDFS scan to compute scan ranges at

runtime. Those are usually determined in the compiler. This is

only supported for simple, non-partitioned, delimited tables.

We need this because we populate the temp table and read from

in in the same statement, without the option of compiling

after we inserted into the temp table.

- Special handling in the MapValueIds node of common subexpressions.

See the comment in MapValueId::preCodeGen().

- Moved the binder code to create a FastExtract node into a new

method FastExtract::makeFastExtractTree(), to be able to call

it from another place.

- MapValueIds no longer looks at the "used by MVQR flag" to determine

the method for VEGRewrite. Instead it checks whether a list of

values has been provided to do this.

- Adding a new method, RelExpr::prepareMeForCSESharing, that is

kind of an "unnormalizer", undoing some of the normalizer


- Implementing the steps for common subexpression materializations

described below.

- Adding the ability to suppress the Hive timestamp modification

check when truncating a Hive table

- Adding an optimizer rule to eliminate CommonSubExprRef nodes.

These nodes should not normally survive past the SQO phase, but

if the SQO phase gets interrupted by an exception, that could

happen, since we then fall back to a copy of the tree before

SQO. In the future, we can consider cost-based decision on

what to do with common subexpressions.

- Adding CommonSubExprRef nodes in the parser whenever we expand

a CTE reference.

- Adding cleanup code to the "cleanup obsolete volatile tables"

command that removes obsolete Hive tables used for common


Other changes contained in this change set:

- Optimization for empty scans, like select * from t where 1=0

This now generates a cardinality constraint with 0 rows, which

can be used later to eliminate parts of a tree.

(file OptLogRelExpr.cpp)

- [TRAFODION-2280] Need to remove salt columns from uniqueness

constraints generated on salted tables.

(file OptLogRelExpr.cpp)

- Got rid of the now meaningless "seamonster" display in EXPLAIN.

(file GenExplain.cpp and misc. expected files)

- Suppress display of "zombies" in the cstat command. Otherwise,

these zombies (marked as <defunct>) prevent Trafodion from

starting, because they are incorrectly considered "orphan"

processes. This could require a reboot when no reboot is necessary.

(file core/sqf/sql/scripts/pstat)

Incomplete list of things left to be done:

- TRAFODION-2316: Hive temp tables are not secure. Use volatile

tables instead.

- TRAFODION-2315: Add heuristics to decide when to use the temp table


- TRAFODION-2320: Make subquery unnesting work with common subexpressions.

Generated Plans


The resulting query plan for a query Q with n common

subexpressions CSE1 ... CSEn looks like this:






/ \

Union Q

/ \

... CTn



/ \


Each of the CTi variables looks like the following, an



/ \

Truncate FastExtract TEMPi



The original query Q has the common subexpressions replaced

with the following:



scan TEMPi

Here is a simple query and its explain:

prepare s from

with cse1 as (select d_date_sk, d_date, d_year, d_dow, d_moy from date_dim)

select x.d_year, y.d_date

from cse1 x join cse1 y on x.d_date_sk = y.d_date_sk

where x.d_moy = 3;

>>explain options 'f' s;


---- ---- ---- -------------------- -------- -------------------- ---------

11 . 12 root 1.46E+005

5 10 11 blocked_union 1.46E+005

7 9 10 merge_join 7.30E+004

8 . 9 sort 1.00E+002

. . 8 hive_scan CSE_TEMP_CSE1_MXID11 1.00E+002

6 . 7 sort 5.00E+001

. . 6 hive_scan CSE_TEMP_CSE1_MXID11 5.00E+001

1 4 5 blocked_union 7.30E+004

2 . 4 hive_insert CSE_TEMP_CSE1_MXID11 7.30E+004

. . 2 hive_scan DATE_DIM 7.30E+004

. . 1 hive_truncate 1.00E+000

--- SQL operation complete.


CQDs to control common subexpressions


CSE_FOR_WITH is the master switch.

CQD Value Default Behavior

--------------------- --------- ------- ---------------------------------------


ON Insert a CommonSubExprRef node in the

tree whenever we reference a CTE

(table defined in a WITH clause)

CSE_USE_TEMP OFF Y Disable creation of temp tables

for common subexpressions

SYSTEM Same as OFF for now

ON Always create a temp table for

common subexpressions where possible


ON Emit diagnostic warnings that show why

we didn't create temp tables for

common subexpressions


ON Cleanup Hive tables used for CSEs with

the "cleanup obsolete volatile tables"


CommonSubExprRef relational operators


This is a new RelExpr class that is introduced. It marks the common

subexpressions in a RelExpr tree. This operator remembers the name of

a common subexpression (e.g. the name used in the WITH clause).

Multiple such operators can reference to the same name. Each of

these references has a copy of the tree.

Right now, these operators are created in the parser when we expand a

CTE (Common Table Expression), declared in a WITH clause. If the CTE

is referenced only once, then the CommonSubExprRef operator is removed

in the binder - it also doesn't live up to its name in this case.

The remaining CommonSubExprRef operators keep track of various changes

to their child trees, during the binder and normalizer phases. In

particular, it tracks which predicates are pushed down into the child

tree and which outputs are eliminated.

The CmpStatement object keeps a global list of all the

CommonSubExprRef operators in a statement, so the individual operators

have a way to communicate with their siblings:

- A statement can have zero or more named common subexpressions.

- Each reference to a common subexpression is marked in the RelExpr

tree with a CommonSubExprRef node.

- In the binder and normalizer, common subexpressions are expanded,

meaning that multiple copies of them exist, one copy per


- Common subexpressions can reference other common subexpressions,

so they, together with the main query, for a DAG (directed

acyclic graph) of dependencies.

- Note that CTEs declared in a WITH clause but not referenced are

ignored and are not part of the query tree.

In the semantic query optimization phase (SQO), the current code makes

a heuristic decision what to do with common subexpressions - to

evaluate them multiple times (expand) or to create a temporary table

once and read that table multiple times.

If we decide to expand, the action is simple: Remove the

CommonSubExprRef operator from the tree and replace it with its child.

If we decide to create a temp table, things become much more difficult.

We need to do several steps:

- Pick one of the child trees of the CommonSubExprRefs as the one to


- Undo any normalization steps that aren't compatible with the other

CommonSubExprRefs. That means pulling out predicates that are not

common among the references and adding back outputs that are

required by other references. If that process fails, we fall back

and expand the expressions.

- Create a temp table tmp.

- Prepare an INSERT OVERWRITE TABLE tmp SELECT * FROM cse tree

that materializes the common subexpression in a table.

- Replace the CommonSubExprRef nodes with scans of the temp table.

- Hook up the insert query tree with the main query, such that it

is executed before the main query starts.

Temporary tables


At this time, temporary tables are created as Hive tables, with a

fabricated, unique name, including the session id, a unique statement

number within the session, and a unique identifier of the common

subexpression within the statement. The temporary table is created at

compile time. The query plan contains an operator to truncate the

table before populating it. The "temporary" Hive table is dropped when

the executor TCB is deallocated.

Several issues are remaining with this approach:

- If the process exits before executing and deallocating the statement,

the Hive table is not cleaned up.

Solution (TBD): Clean up these tables like we clean up left-over

volatile tables. Both are identified by the session id.

- If the executor runs into memory pressure and deallocates the TCB,

then allocates it again at a later time, the temp table is no longer


Solution (TBD): Use AQR to recompile the query and create a new table.

- Query cache: If we cache a query, multiple queries may end up with

the same temporary table. This works ok as long as these queries are

executed serially, but it fails if both queries are executed at the

same time (e.g. open two cursors and fetch from both, alternating).

Solution (TBD): Add a CQD that disables caching queries with temp tables

for common subexpressions.

In the future we also want to support volatile tables. However, those also

have issues:

- Volatile tables aren't cleaned up until the session ends. If we run

many statements with common subexpressions, that is undesirable. So,

we have a similar cleanup problem as with Hive tables.

- Volatile tables take a relatively long time to create.

- Insert and scan rates on volatile Trafodion tables are slower than

those on Hive tables.

To-do items are marked with "Todo: CSE: " in the code.

  1. … 78 more files in changeset.
Merge remote branch 'origin/master' into memleak1

  1. … 8 more files in changeset.
Create NACollection objects on NAHeap. Avoid use of system heap as far as possible

  1. … 50 more files in changeset.
similarity check changes, commit #1

  1. … 44 more files in changeset.
TRAFODION [2025] Initialize authorization cannot be run in a DDL transaction

As part of DDL transaction work, there is a goal to run all DDL and DDL like

operations in a single DDL transaction. This delivery changes initialize

trafodion and initialize authorization to make this happen.

Prior to DDL transactions, initialize authorization would either add or drop

authorization support. Part of this required that all compiler processes

associated with the master process be killed to clear out information stored

in memory. When DDL transactions were added, killing the compiler processes

caused the DDL transaction to abort. This means that initialize authorization

could not be run in DDL transation. Initialize trafodion calls initialize

authorization when security is enabled, so initialize trafodion was not able

to run in DDL transactions.

A change was made to send a CmpMessageDatabaseUser request to the child arkcmp

processes after authorization was initialized or dropped. This request is

reponsible for setting appropriate memory attributes so we no longer require

arkcmps to be terminated. Changes were piggy backed on current support that

sends usernames and IDs to child arkcmps.

A new method called ContextCli::updateMxcmpSession is called during initialize

and drop requests. This calls send a message to associated arkcmp process to

update session attributes for user information. It then propagates the message

to other child arkcmp processes.

To make this work, the following code was changed to generate and recognize the

new message format:

CmpStatement.cpp (process - CmpMessageDatabaseUser)

Context.cpp (createMxcmpSession & updateMxcmpSession)

ExSqlComp.cpp (resendControls)

The following was changed to support DDL transactions:

CmpSeabaseDDLcommon.cpp (initSeabaseAuthorization & dropSeabaseAuthorization)

GenPreCode.cpp (allow DDL transaction for initialize trafodion)

SqlciErrors.txt (allow initialize authorization to succeed with warnings)

This also includes a change on how Trafodion processes alter user operations

that allow predefined users to be modified by someone with the correct


  1. … 10 more files in changeset.
TRAFODION-1910 mxosrvr crashes on Hive query after reconnect (take 2)

NATableDB is caching a pointer to a HiveClient_JNI object

(HiveMetaData::client_), but that object gets deallocated when a JDBC

client disconnects. Fixing this by keeping the HiveClient_JNI around

across sessions.

Selva and Suresh commented on the first fix and suggested to treat both

HBaseClient_JNI and HiveClient_JNI the same and to remove the CLI

interface that's used to delete these objects.

Therefore, the new fix is to remove this CLI call. It gets called from

two places, one is when an ODBC/JDBC connection closes and the other

is from "initialize trafodion, drop". We believe that neither of them

is needed. Note that we have only one object of each type per CLI

context, and that we delete both objects when we delete the context

(ContextCli::deleteMe()), so there are no leaks.

  1. … 3 more files in changeset.
JIRA TRAFODION-1798 (ddl xns) and few other fixes, details below.

-- support for sql part of ddl xns. Section 1 of JIRA TRAFODION-1798

-- cqd ddl_transactions to enable or disable ddl xns.

Default is currently off. Once it is tested, it will be turned on.

Dev regressions are run with cqd set to ON

-- get stmts run with read committed to get changes in current xns

-- support for where preds with get stmts

-- scan to pass in transid even if running with read uncommitted access.

This enables rows modified in current xn to be returned.

-- cleanup no longer return multiple duplicate error messages if

objects id is not found.

-- cleanup no longer includes internallay created schemas (_HV_ , _HB_)

during cleanup operations.

-- Correct error msg was not getting returned if an invalid index

existed in table and the same index was created again.

-- init traf, drop md views was giving an error if views didnt exist.

That has been fixed.

-- regressions with -diff option now show original file timestamps

instead of the timestamp when the diff command was run.

  1. … 72 more files in changeset.
Part 2 of changes to update license text in Trafodion source

This check-in updates license text in all source files in the

core/sql directory. Remaining directories will be done in

later check-ins.

  1. … 3147 more files in changeset.
Move core into subdir to combine repos

    • -0
    • +1669
  1. … 10768 more files in changeset.
Move core into subdir to combine repos

    • -0
    • +1678
  1. … 10622 more files in changeset.
Move core into subdir to combine repos

Use: git log --follow -- <file>

to view file history thru renames.

    • -0
    • +1641
  1. … 10837 more files in changeset.