Package com.foundationdb.sql.pg

Source Code of com.foundationdb.sql.pg.PostgresLoadableOperator

/**
* Copyright (C) 2009-2013 FoundationDB, LLC
*
* 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 this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.foundationdb.sql.pg;

import com.foundationdb.sql.server.ServerCallContextStack;
import com.foundationdb.sql.server.ServerCallInvocation;

import com.foundationdb.ais.model.Column;
import com.foundationdb.qp.loadableplan.LoadableOperator;
import com.foundationdb.qp.operator.QueryBindings;
import com.foundationdb.util.tap.InOutTap;
import com.foundationdb.util.tap.Tap;

import java.io.IOException;
import java.util.List;

public class PostgresLoadableOperator extends PostgresOperatorStatement
{
    private static final InOutTap EXECUTE_TAP = Tap.createTimer("PostgresLoadableOperator: execute shared");

    private ServerCallInvocation invocation;

    protected PostgresLoadableOperator(LoadableOperator loadableOperator,
                                       ServerCallInvocation invocation,
                                       List<String> columnNames, List<PostgresType> columnTypes, List<Column> aisColumns,
                                       PostgresType[] parameterTypes)
    {
        super(null);
        super.init(loadableOperator.plan(), null, columnNames, columnTypes, aisColumns, parameterTypes, null);
        setSchema(loadableOperator.schema());
        this.invocation = invocation;
    }
   
    @Override
    protected InOutTap executeTap()
    {
        return EXECUTE_TAP;
    }

    @Override
    public int execute(PostgresQueryContext context, QueryBindings bindings, int maxrows) throws IOException {
        bindings = PostgresLoadablePlan.setParameters(bindings, invocation);
        ServerCallContextStack stack = ServerCallContextStack.get();
        boolean success = false;
        stack.push(context, invocation);
        try {
            context.initStore(getSchema());
            int result = super.execute(context, bindings, maxrows);
            success = true;
            return result;
        }
        finally {
            stack.pop(context, invocation, success);
        }
    }

}
TOP

Related Classes of com.foundationdb.sql.pg.PostgresLoadableOperator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.