/* This file is part of VoltDB.
 * Copyright (C) 2008-2015 VoltDB Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with VoltDB.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.voltdb.planner;

import java.util.LinkedHashMap;
import java.util.List;

import org.hsqldb_voltpatches.VoltXMLElement;
import org.voltdb.catalog.Column;
import org.voltdb.catalog.Database;
import org.voltdb.catalog.Table;
import org.voltdb.expressions.AbstractExpression;

/**
 *
 *
 */
public class ParsedUpdateStmt extends AbstractParsedStmt {
    // maintaining column ordering is important for deterministic
    // schema generation: see ENG-1660.
    LinkedHashMap<Column, AbstractExpression> columns =
        new LinkedHashMap<Column, AbstractExpression>();

    /**
    * Class constructor
    * @param paramValues
    * @param db
    */
    public ParsedUpdateStmt(String[] paramValues, Database db) {
        super(paramValues, db);
    }

    @Override
    void parse(VoltXMLElement stmtNode) {
        assert(m_tableList.size() == 1);
        Table table = m_tableList.get(0);
        // Need to add the table to the cache. It may be required to resolve the
        // correlated TVE in case of WHERE clause contains IN subquery
        addTableToStmtCache(table, table.getTypeName());

        for (VoltXMLElement child : stmtNode.children) {
            if (child.name.equalsIgnoreCase("columns")) {
                parseTargetColumns(child, table, columns);
            }
        }
    }

    @Override
    public String toString() {
        String retval = super.toString() + "\n";

        retval += "COLUMNS:\n";
        for (Column col : columns.keySet()) {
            retval += "\tColumn: " + col.getTypeName() + ": ";
            retval += columns.get(col).toString() + "\n";
        }

        retval = retval.trim();

        return retval;
    }

    @Override
    public List<AbstractExpression> findAllSubexpressionsOfClass(Class< ? extends AbstractExpression> aeClass) {
        List<AbstractExpression> exprs = super.findAllSubexpressionsOfClass(aeClass);

        for (AbstractExpression expr : columns.values()) {
            exprs.addAll(expr.findAllSubexpressionsOfClass(aeClass));
        }

        return exprs;
    }
}

@@ -2686,24 +2686,60 @@
 values()) %7B%0A
+            if (expr != null) %7B%0A    
             
@@ -2796,16 +2796,30 @@
 lass));%0A
+            %7D%0A
         

Add null check looking for exprs in UPDATE statements