~sgdg/stado/stado25

« back to all changes in this revision

Viewing changes to src/org/postgresql/stado/engine/XDBSessionContext.java

  • Committer: Jim Mlodgenski
  • Date: 2011-08-30 22:39:37 UTC
  • mfrom: (1.1.3 stado)
  • Revision ID: jim@cirrusql.com-20110830223937-25q231a31x0e08b4
Merge from Spatial branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Copyright (C) 2008 EnterpriseDB Corporation.
3
3
 * Copyright (C) 2011 Stado Global Development Group.
4
4
 *
5
 
 * This program is free software; you can redistribute it and/or modify it
6
 
 * under the terms of the GNU General Public License version 2 as published by
7
 
 * the Free Software Foundation.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful, but WITHOUT
10
 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12
 
 * more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License along
15
 
 * with this program; if not, see http://www.gnu.org/licenses or write to the
16
 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
 
 * 02110-1301 USA.
 
5
 * This file is part of Stado.
 
6
 *
 
7
 * Stado is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation, either version 3 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * Stado is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with Stado.  If not, see <http://www.gnu.org/licenses/>.
18
19
 *
19
20
 * You can find Stado at http://www.stado.us
20
21
 *
21
22
 ****************************************************************************/
22
 
/*
23
 
 * XDBSessionContext.java
 
23
/**
24
24
 *
25
 
 *  
26
25
 */
27
 
 
28
26
package org.postgresql.stado.engine;
29
27
 
30
28
import java.io.IOException;
59
57
import org.postgresql.stado.metadata.scheduler.ILockCost;
60
58
import org.postgresql.stado.metadata.scheduler.ITransaction;
61
59
import org.postgresql.stado.metadata.scheduler.Scheduler;
 
60
import org.postgresql.stado.optimizer.QueryTree;
62
61
import org.postgresql.stado.parser.Parser;
63
62
import org.postgresql.stado.parser.SqlModifyTable;
64
63
 
65
 
 
66
64
/**
67
65
 * An XDBSessionContext maintains state information for client sessions.
68
66
 * XDBSessionContext's lifetime, use cases, etc. 1. Client contacts the server,
382
380
    }
383
381
 
384
382
    public ExecutionResult login(SysLogin login) throws XDBSecurityException,
 
383
    XDBServerException {
 
384
        return login(login, false);
 
385
    }
 
386
    
 
387
    public ExecutionResult login(SysLogin login, boolean isSpatial) throws XDBSecurityException,
385
388
            XDBServerException {
386
389
        if (CONNECTION_MODE_CREATE == mode) {
387
390
            logSession.debug("This is createdb request");
388
391
            if (dbName == null) {
389
392
                throw new XDBServerException("Database name is not specified");
390
393
            }
391
 
            database = MetaData.getMetaData().createDatabase(dbName, login);
 
394
            database = MetaData.getMetaData().createDatabase(dbName, login, isSpatial);
392
395
            logSession.debug("Temp database and user have been created");
393
396
        }
394
397
        if (database == null) {
880
883
    private Map<String, ServerStatement> statements = new HashMap<String, ServerStatement>();
881
884
 
882
885
    private Map<String, ServerStatement> cursors = new HashMap<String, ServerStatement>();
 
886
    
 
887
    private Map<String, DeclaredCursor> userCursors = new HashMap<String, DeclaredCursor>();
 
888
    
 
889
    public void createCursor(String cursorName, QueryTree cursorTree, boolean isScrollable, boolean isHoldable) {
 
890
        userCursors.put(cursorName, new DeclaredCursor(cursorName, cursorTree, isScrollable, isHoldable));
 
891
    }
883
892
 
 
893
    public DeclaredCursor getCursor(String cursorName) {
 
894
        return userCursors.get(cursorName);
 
895
    }
 
896
    
884
897
    public void createStatement(String statementID, ExecutableRequest request) {
885
898
        closeStatement(statementID);
886
899
        statements.put(statementID, new ServerStatement(statementID, request, this));
908
921
        statement.bind(cursorID, paramValues);
909
922
        statement.setBindStepComplete(true);
910
923
    }
 
924
    
 
925
    public void clearAllCursors() {
 
926
        cursors.clear();
 
927
    }
911
928
 
912
929
    public ResponseMessage describeStatement(String statementID, String cursorID) {
913
930
        ServerStatement statement = null;
1205
1222
     */
1206
1223
    public ExecutionResult persistDatabase() throws XDBSecurityException {
1207
1224
        checkPrivileged();
1208
 
        MetaData.getMetaData().makeDbPersistent(database);
 
1225
        int dbid = MetaData.getMetaData().makeDbPersistent(database);
1209
1226
        CoordinatorPools.initPool(database.getDbname(), database.getCoordinatorNodeID());
1210
1227
        CoordinatorAgent.getInstance().connectToDatabase(database);
1211
1228
        return ExecutionResult
1212
 
                .createSuccessResult(ExecutionResult.COMMAND_PERSIST_DATABASE);
 
1229
                .createGeneratorRangeResult(ExecutionResult.COMMAND_PERSIST_DATABASE, dbid);
1213
1230
    }
1214
1231
 
1215
1232
    /**