2
2
* Copyright (C) 2008 EnterpriseDB Corporation.
3
3
* Copyright (C) 2011 Stado Global Development Group.
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.
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
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
5
* This file is part of Stado.
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.
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.
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/>.
19
20
* You can find Stado at http://www.stado.us
21
22
****************************************************************************/
23
* XDBSessionContext.java
28
26
package org.postgresql.stado.engine;
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;
67
65
* An XDBSessionContext maintains state information for client sessions.
68
66
* XDBSessionContext's lifetime, use cases, etc. 1. Client contacts the server,
384
382
public ExecutionResult login(SysLogin login) throws XDBSecurityException,
384
return login(login, false);
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");
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");
394
397
if (database == null) {
880
883
private Map<String, ServerStatement> statements = new HashMap<String, ServerStatement>();
882
885
private Map<String, ServerStatement> cursors = new HashMap<String, ServerStatement>();
887
private Map<String, DeclaredCursor> userCursors = new HashMap<String, DeclaredCursor>();
889
public void createCursor(String cursorName, QueryTree cursorTree, boolean isScrollable, boolean isHoldable) {
890
userCursors.put(cursorName, new DeclaredCursor(cursorName, cursorTree, isScrollable, isHoldable));
893
public DeclaredCursor getCursor(String cursorName) {
894
return userCursors.get(cursorName);
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);
925
public void clearAllCursors() {
912
929
public ResponseMessage describeStatement(String statementID, String cursorID) {
913
930
ServerStatement statement = null;
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);