42 {
"street_name",
DBA_CHAR, PCN_SIZE_OF(
Address, StreetName ), PCN_FALSE},
43 {
"street_no",
DBA_INT, PCN_SIZE_OF(
Address, StreetNo ), PCN_FALSE},
65 static const int Rows = 6;
69 { 1242,
"Joe",
"Dalton" },
70 { 123,
"Lucky",
"Luke" },
71 { 456,
"Averell",
"Dalton" },
72 { 8976,
"Gaston",
"Lagaffe" },
73 { 1122,
"Jolly",
"Jumper" },
74 { 3211,
"Leffe",
"Pagrotsky" }
89 { 1242,
"Lonesome Street", 12,
"Crime Town" },
90 { 123,
"Pistol Road", 13,
"Fort Mount" },
91 { 456,
"Banking Blv.", 43,
"Las Vegas" },
92 { 8976,
"ChancylleZee", 54,
"Paris" },
93 { 1122,
"Lucky", 111,
"Wild West" },
94 { 3211,
"Parlament St.", 11,
"Stockholm" }
107 static const char EMP_TABLE[] =
"employees";
108 static const char ADD_TABLE[] =
"addresses";
110 static const int EmpNbCol = 3;
111 static const int AddNbCol = 4;
117 ndbout <<
"Opening database" << endl;
120 ndbout <<
"Creating tables" << endl;
124 ndbout <<
"Checking for table existance" << endl;
131 CreateBindings(
void){
132 ndbout <<
"Creating bindings" << endl;
157 ndbout <<
"Testing basic array operations" << endl;
161 NdbSleep_SecSleep(1);
163 NdbSleep_SecSleep(1);
164 CompareRows(EMP_TABLE_DATA, Rows-2, EMP_TABLE_DATA_READ);
167 AlterRows(EMP_TABLE_DATA, Rows-2);
169 NdbSleep_SecSleep(1);
171 NdbSleep_SecSleep(1);
172 CompareRows(EMP_TABLE_DATA, Rows-2, EMP_TABLE_DATA_READ);
175 AlterRows(EMP_TABLE_DATA, Rows);
177 NdbSleep_SecSleep(1);
179 NdbSleep_SecSleep(1);
180 CompareRows(EMP_TABLE_DATA, Rows, EMP_TABLE_DATA_READ);
184 NdbSleep_SecSleep(1);
189 ndbout <<
"Testing multi operations" << endl;
191 const int R2 = Rows + Rows;
195 void * DATA_READ[R2];
196 for(
int i = 0;
i<Rows;
i++){
197 Bindings[2*
i] = EmpB;
198 Bindings[2*
i+1] = AddB;
200 DATA[2*
i] = &EMP_TABLE_DATA[
i];
201 DATA[2*
i+1] = &ADD_TABLE_DATA[
i];
203 DATA_READ[2*
i] = &EMP_TABLE_DATA_READ[
i];
204 DATA_READ[2*
i+1] = &ADD_TABLE_DATA_READ[
i];
209 NdbSleep_SecSleep(1);
211 NdbSleep_SecSleep(1);
213 CompareRows(EMP_TABLE_DATA, Rows-2, EMP_TABLE_DATA_READ);
214 CompareRows(ADD_TABLE_DATA, Rows-2, ADD_TABLE_DATA_READ);
217 AlterRows(EMP_TABLE_DATA, Rows-2);
218 AlterRows(ADD_TABLE_DATA, Rows-2);
220 NdbSleep_SecSleep(1);
222 NdbSleep_SecSleep(1);
223 CompareRows(EMP_TABLE_DATA, Rows-2, EMP_TABLE_DATA_READ);
224 CompareRows(ADD_TABLE_DATA, Rows-2, ADD_TABLE_DATA_READ);
227 AlterRows(EMP_TABLE_DATA, Rows);
228 AlterRows(ADD_TABLE_DATA, Rows);
230 NdbSleep_SecSleep(1);
232 NdbSleep_SecSleep(1);
233 CompareRows(EMP_TABLE_DATA, Rows, EMP_TABLE_DATA_READ);
234 CompareRows(ADD_TABLE_DATA, Rows, ADD_TABLE_DATA_READ);
238 NdbSleep_SecSleep(1);
243 ndbout <<
"Testing array of pointer operations" << endl;
246 for(
int i = 0;
i<Rows;
i++){
247 EmpData[
i] = &EMP_TABLE_DATA[
i];
248 EmpDataRead[
i] = &EMP_TABLE_DATA_READ[
i];
251 void *
const * EMP_TABLE_DATA2 = (
void *
const *)EmpData;
252 void *
const * EMP_TABLE_DATA_READ2 = (
void *
const *)EmpDataRead;
256 NdbSleep_SecSleep(1);
257 DBA_ReadRows (EmpB, EMP_TABLE_DATA_READ2, Rows-2, readCallback);
258 NdbSleep_SecSleep(1);
259 CompareRows(EMP_TABLE_DATA, Rows-2, EMP_TABLE_DATA_READ);
262 AlterRows(EMP_TABLE_DATA, Rows-2);
264 NdbSleep_SecSleep(1);
265 DBA_ReadRows (EmpB, EMP_TABLE_DATA_READ2, Rows-2, readCallback);
266 NdbSleep_SecSleep(1);
267 CompareRows(EMP_TABLE_DATA, Rows-2, EMP_TABLE_DATA_READ);
270 AlterRows (EMP_TABLE_DATA, Rows);
272 NdbSleep_SecSleep(1);
273 DBA_ReadRows (EmpB, EMP_TABLE_DATA_READ2, Rows, readCallback);
274 NdbSleep_SecSleep(1);
275 CompareRows(EMP_TABLE_DATA, Rows, EMP_TABLE_DATA_READ);
279 NdbSleep_SecSleep(1);
283 NDB_COMMAND(newton_basic,
"newton_basic",
284 "newton_basic",
"newton_basic", 65535){
304 callbackStatusCheck(
DBA_Error_t status,
const char* operation) {
305 ndbout_c(
"%s: %d", operation, status);
309 callbackStatusCheck(s,
"insert");
312 callbackStatusCheck(s,
"delete");
315 callbackStatusCheck(s,
"update");
318 callbackStatusCheck(s,
"read");
321 callbackStatusCheck(s,
"write");