1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18
/*********************************************************************
19
Name: NdbSchemaCon.cpp
22
Author: UABMNST Mona Natterkvist UAB/B/SD
23
EMIKRON Mikael Ronstrom
26
Description: Old Interface between application and NDB
28
Adjust: 980126 UABMNST First version.
29
020826 EMIKRON New version adapted to new DICT version
30
040524 Magnus Svensson - Adapted to not be included in public NdbApi
31
unless the user wants to use it.
33
NOTE: This file is only used as a compatibility layer for old test programs,
34
New programs should use NdbDictionary.hpp
35
*********************************************************************/
37
#include <ndb_global.h>
39
#include <NdbSchemaCon.hpp>
40
#include <NdbSchemaOp.hpp>
43
/*********************************************************************
44
NdbSchemaCon(Ndb* aNdb);
46
Parameters: aNdb: Pointers to the Ndb object
47
Remark: Creates a schemacon object.
48
************************************************************************************************/
49
NdbSchemaCon::NdbSchemaCon( Ndb* aNdb ) :
51
theFirstSchemaOpInList(NULL),
52
theMagicNumber(0x75318642)
55
}//NdbSchemaCon::NdbSchemaCon()
57
/*********************************************************************
60
Remark: Deletes the connection object.
61
************************************************************************************************/
62
NdbSchemaCon::~NdbSchemaCon()
64
}//NdbSchemaCon::~NdbSchemaCon()
66
/*********************************************************************
67
NdbSchemaOp* getNdbSchemaOp();
69
Return Value Return a pointer to a NdbSchemaOp object if getNdbSchemaOp was sussesful.
70
Return NULL: In all other case.
71
Parameters: tableId : Id of the database table beeing deleted.
72
************************************************************************************************/
74
NdbSchemaCon::getNdbSchemaOp()
76
NdbSchemaOp* tSchemaOp;
77
if (theFirstSchemaOpInList != NULL) {
78
theError.code = 4401; // Only support one add table per transaction
81
tSchemaOp = new NdbSchemaOp(theNdb);
82
if ( tSchemaOp == NULL ) {
83
theError.code = 4000; // Could not allocate schema operation
86
theFirstSchemaOpInList = tSchemaOp;
87
int retValue = tSchemaOp->init(this);
90
theError.code = 4000; // Could not allocate buffer in schema operation
94
}//NdbSchemaCon::getNdbSchemaOp()
96
/*********************************************************************
99
Return Value: Return 0 : execute was successful.
100
Return -1: In all other case.
101
Parameters : aTypeOfExec: Type of execute.
102
Remark: Initialise connection object for new transaction.
103
************************************************************************************************/
105
NdbSchemaCon::execute()
107
if(theError.code != 0) {
111
NdbSchemaOp* tSchemaOp;
113
tSchemaOp = theFirstSchemaOpInList;
114
if (tSchemaOp == NULL) {
115
theError.code = 4402;
119
if ((tSchemaOp->sendRec() == -1) || (theError.code != 0)) {
120
// Error Code already set in other place
125
}//NdbSchemaCon::execute()
127
/*********************************************************************
130
Remark: Release all schemaop.
131
************************************************************************************************/
133
NdbSchemaCon::release()
135
NdbSchemaOp* tSchemaOp;
136
tSchemaOp = theFirstSchemaOpInList;
137
if (tSchemaOp != NULL) {
138
tSchemaOp->release();
141
theFirstSchemaOpInList = NULL;
143
}//NdbSchemaCon::release()
145
#include <NdbError.hpp>
148
update(const NdbError & _err){
149
NdbError & error = (NdbError &) _err;
150
ndberror_struct ndberror = (ndberror_struct)error;
151
ndberror_update(&ndberror);
152
error = NdbError(ndberror);
157
NdbSchemaCon::getNdbError() const {