Branch data Line data Source code
1 : : /* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */
2 : :
3 : : #include <config.h>
4 : : #include "tests/idltest.h"
5 : : #include <limits.h>
6 : : #include "ovs-thread.h"
7 : : #include "ovsdb-data.h"
8 : : #include "ovsdb-error.h"
9 : : #include "util.h"
10 : :
11 : : #ifdef __CHECKER__
12 : : /* Sparse dislikes sizeof(bool) ("warning: expression using sizeof bool"). */
13 : : enum { sizeof_bool = 1 };
14 : : #else
15 : : enum { sizeof_bool = sizeof(bool) };
16 : : #endif
17 : :
18 : : static bool inited;
19 : :
20 : :
21 : : static struct idltest_link1 *
22 : 374 : idltest_link1_cast(const struct ovsdb_idl_row *row)
23 : : {
24 : 374 : return row ? CONTAINER_OF(row, struct idltest_link1, header_) : NULL;
25 : : }
26 : :
27 : : static struct idltest_link2 *
28 : 78 : idltest_link2_cast(const struct ovsdb_idl_row *row)
29 : : {
30 : 78 : return row ? CONTAINER_OF(row, struct idltest_link2, header_) : NULL;
31 : : }
32 : :
33 : : static struct idltest_simple *
34 : 1103 : idltest_simple_cast(const struct ovsdb_idl_row *row)
35 : : {
36 : 1103 : return row ? CONTAINER_OF(row, struct idltest_simple, header_) : NULL;
37 : : }
38 : :
39 : : static struct idltest_simple2 *
40 : 32 : idltest_simple2_cast(const struct ovsdb_idl_row *row)
41 : : {
42 : 32 : return row ? CONTAINER_OF(row, struct idltest_simple2, header_) : NULL;
43 : : }
44 : :
45 : : static struct idltest_simple3 *
46 : 46 : idltest_simple3_cast(const struct ovsdb_idl_row *row)
47 : : {
48 : 46 : return row ? CONTAINER_OF(row, struct idltest_simple3, header_) : NULL;
49 : : }
50 : :
51 : : static struct idltest_simple4 *
52 : 6 : idltest_simple4_cast(const struct ovsdb_idl_row *row)
53 : : {
54 : 6 : return row ? CONTAINER_OF(row, struct idltest_simple4, header_) : NULL;
55 : : }
56 : :
57 : : /* link1 table. */
58 : :
59 : : static void
60 : 35 : idltest_link1_parse_i(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
61 : : {
62 : 35 : struct idltest_link1 *row = idltest_link1_cast(row_);
63 : :
64 [ - + ]: 35 : ovs_assert(inited);
65 [ + - ]: 35 : if (datum->n >= 1) {
66 : 35 : row->i = datum->keys[0].integer;
67 : : } else {
68 : 0 : row->i = 0;
69 : : }
70 : 35 : }
71 : :
72 : : static void
73 : 35 : idltest_link1_parse_k(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
74 : : {
75 : 35 : struct idltest_link1 *row = idltest_link1_cast(row_);
76 : :
77 [ - + ]: 35 : ovs_assert(inited);
78 [ + - ]: 35 : if (datum->n >= 1) {
79 : 35 : row->k = idltest_link1_cast(ovsdb_idl_get_row_arc(row_, &idltest_table_classes[IDLTEST_TABLE_LINK1], &datum->keys[0].uuid));
80 : : } else {
81 : 0 : row->k = NULL;
82 : : }
83 : 35 : }
84 : :
85 : : static void
86 : 35 : idltest_link1_parse_ka(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
87 : : {
88 : 35 : struct idltest_link1 *row = idltest_link1_cast(row_);
89 : : size_t i;
90 : :
91 [ - + ]: 35 : ovs_assert(inited);
92 : 35 : row->ka = NULL;
93 : 35 : row->n_ka = 0;
94 [ + + ]: 82 : for (i = 0; i < datum->n; i++) {
95 : 47 : struct idltest_link1 *keyRow = idltest_link1_cast(ovsdb_idl_get_row_arc(row_, &idltest_table_classes[IDLTEST_TABLE_LINK1], &datum->keys[i].uuid));
96 [ + + ]: 47 : if (keyRow) {
97 [ + + ]: 37 : if (!row->n_ka) {
98 : 17 : row->ka = xmalloc(datum->n * sizeof *row->ka);
99 : : }
100 : 37 : row->ka[row->n_ka] = keyRow;
101 : 37 : row->n_ka++;
102 : : }
103 : : }
104 : 35 : }
105 : :
106 : : static void
107 : 35 : idltest_link1_parse_l2(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
108 : : {
109 : 35 : struct idltest_link1 *row = idltest_link1_cast(row_);
110 : :
111 [ - + ]: 35 : ovs_assert(inited);
112 [ + + ]: 35 : if (datum->n >= 1) {
113 : 1 : row->l2 = idltest_link2_cast(ovsdb_idl_get_row_arc(row_, &idltest_table_classes[IDLTEST_TABLE_LINK2], &datum->keys[0].uuid));
114 : : } else {
115 : 34 : row->l2 = NULL;
116 : : }
117 : 35 : }
118 : :
119 : : static void
120 : 35 : idltest_link1_unparse_i(struct ovsdb_idl_row *row OVS_UNUSED)
121 : : {
122 : : /* Nothing to do. */
123 : 35 : }
124 : :
125 : : static void
126 : 35 : idltest_link1_unparse_k(struct ovsdb_idl_row *row OVS_UNUSED)
127 : : {
128 : : /* Nothing to do. */
129 : 35 : }
130 : :
131 : : static void
132 : 35 : idltest_link1_unparse_ka(struct ovsdb_idl_row *row_)
133 : : {
134 : 35 : struct idltest_link1 *row = idltest_link1_cast(row_);
135 : :
136 [ - + ]: 35 : ovs_assert(inited);
137 : 35 : free(row->ka);
138 : 35 : }
139 : :
140 : : static void
141 : 35 : idltest_link1_unparse_l2(struct ovsdb_idl_row *row OVS_UNUSED)
142 : : {
143 : : /* Nothing to do. */
144 : 35 : }
145 : :
146 : : static void
147 : 14 : idltest_link1_init__(struct ovsdb_idl_row *row)
148 : : {
149 : 14 : idltest_link1_init(idltest_link1_cast(row));
150 : 14 : }
151 : :
152 : : /* Clears the contents of 'row' in table "link1". */
153 : : void
154 : 14 : idltest_link1_init(struct idltest_link1 *row)
155 : : {
156 : 14 : memset(row, 0, sizeof *row);
157 : 14 : }
158 : :
159 : : /* Searches table "link1" in 'idl' for a row with UUID 'uuid'. Returns
160 : : * a pointer to the row if there is one, otherwise a null pointer. */
161 : : const struct idltest_link1 *
162 : 0 : idltest_link1_get_for_uuid(const struct ovsdb_idl *idl, const struct uuid *uuid)
163 : : {
164 : 0 : return idltest_link1_cast(ovsdb_idl_get_row_for_uuid(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1], uuid));
165 : : }
166 : :
167 : : /* Returns a row in table "link1" in 'idl', or a null pointer if that
168 : : * table is empty.
169 : : *
170 : : * Database tables are internally maintained as hash tables, so adding or
171 : : * removing rows while traversing the same table can cause some rows to be
172 : : * visited twice or not at apply. */
173 : : const struct idltest_link1 *
174 : 61 : idltest_link1_first(const struct ovsdb_idl *idl)
175 : : {
176 : 61 : return idltest_link1_cast(ovsdb_idl_first_row(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1]));
177 : : }
178 : :
179 : : /* Returns a row following 'row' within its table, or a null pointer if 'row'
180 : : * is the last row in its table. */
181 : : const struct idltest_link1 *
182 : 34 : idltest_link1_next(const struct idltest_link1 *row)
183 : : {
184 : 34 : return idltest_link1_cast(ovsdb_idl_next_row(&row->header_));
185 : : }
186 : :
187 : 0 : unsigned int idltest_link1_get_seqno(const struct ovsdb_idl *idl)
188 : : {
189 : 0 : return ovsdb_idl_table_get_seqno(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1]);
190 : : }
191 : :
192 : 0 : unsigned int idltest_link1_row_get_seqno(const struct idltest_link1 *row, enum ovsdb_idl_change change)
193 : : {
194 : 0 : return ovsdb_idl_row_get_seqno(&row->header_, change);
195 : : }
196 : :
197 : : const struct idltest_link1 *
198 : 8 : idltest_link1_track_get_first(const struct ovsdb_idl *idl)
199 : : {
200 : 8 : return idltest_link1_cast(ovsdb_idl_track_get_first(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1]));
201 : : }
202 : :
203 : : const struct idltest_link1
204 : 0 : *idltest_link1_track_get_next(const struct idltest_link1 *row)
205 : : {
206 : 0 : return idltest_link1_cast(ovsdb_idl_track_get_next(&row->header_));
207 : : }
208 : :
209 : :
210 : : /* Deletes 'row' from table "link1". 'row' may be freed, so it must not be
211 : : * accessed afterward.
212 : : *
213 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
214 : : void
215 : 0 : idltest_link1_delete(const struct idltest_link1 *row)
216 : : {
217 : 0 : ovsdb_idl_txn_delete(&row->header_);
218 : 0 : }
219 : :
220 : : /* Inserts and returns a new row in the table "link1" in the database
221 : : * with open transaction 'txn'.
222 : : *
223 : : * The new row is assigned a randomly generated provisional UUID.
224 : : * ovsdb-server will assign a different UUID when 'txn' is committed,
225 : : * but the IDL will replace any uses of the provisional UUID in the
226 : : * data to be to be committed by the UUID assigned by ovsdb-server. */
227 : : struct idltest_link1 *
228 : 0 : idltest_link1_insert(struct ovsdb_idl_txn *txn)
229 : : {
230 : 0 : return idltest_link1_cast(ovsdb_idl_txn_insert(txn, &idltest_table_classes[IDLTEST_TABLE_LINK1], NULL));
231 : : }
232 : :
233 : : bool
234 : 136 : idltest_link1_is_updated(const struct idltest_link1 *row, enum idltest_link1_column_id column)
235 : : {
236 : 136 : return ovsdb_idl_track_is_updated(&row->header_, &idltest_link1_columns[column]);
237 : : }
238 : :
239 : : /* Causes the original contents of column "i" in 'row' to be
240 : : * verified as a prerequisite to completing the transaction. That is, if
241 : : * "i" in 'row' changed (or if 'row' was deleted) between the
242 : : * time that the IDL originally read its contents and the time that the
243 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
244 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
245 : : * change has already been received).
246 : : *
247 : : * The intention is that, to ensure that no transaction commits based on dirty
248 : : * reads, an application should call this function any time "i" is
249 : : * read as part of a read-modify-write operation.
250 : : *
251 : : * In some cases this function reduces to a no-op, because the current value
252 : : * of "i" is already known:
253 : : *
254 : : * - If 'row' is a row created by the current transaction (returned by
255 : : * idltest_link1_insert()).
256 : : *
257 : : * - If "i" has already been modified (with
258 : : * idltest_link1_set_i()) within the current transaction.
259 : : *
260 : : * Because of the latter property, always call this function *before*
261 : : * idltest_link1_set_i() for a given read-modify-write.
262 : : *
263 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
264 : : void
265 : 0 : idltest_link1_verify_i(const struct idltest_link1 *row)
266 : : {
267 [ # # ]: 0 : ovs_assert(inited);
268 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_link1_columns[IDLTEST_LINK1_COL_I]);
269 : 0 : }
270 : :
271 : : /* Causes the original contents of column "k" in 'row' to be
272 : : * verified as a prerequisite to completing the transaction. That is, if
273 : : * "k" in 'row' changed (or if 'row' was deleted) between the
274 : : * time that the IDL originally read its contents and the time that the
275 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
276 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
277 : : * change has already been received).
278 : : *
279 : : * The intention is that, to ensure that no transaction commits based on dirty
280 : : * reads, an application should call this function any time "k" is
281 : : * read as part of a read-modify-write operation.
282 : : *
283 : : * In some cases this function reduces to a no-op, because the current value
284 : : * of "k" is already known:
285 : : *
286 : : * - If 'row' is a row created by the current transaction (returned by
287 : : * idltest_link1_insert()).
288 : : *
289 : : * - If "k" has already been modified (with
290 : : * idltest_link1_set_k()) within the current transaction.
291 : : *
292 : : * Because of the latter property, always call this function *before*
293 : : * idltest_link1_set_k() for a given read-modify-write.
294 : : *
295 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
296 : : void
297 : 0 : idltest_link1_verify_k(const struct idltest_link1 *row)
298 : : {
299 [ # # ]: 0 : ovs_assert(inited);
300 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_link1_columns[IDLTEST_LINK1_COL_K]);
301 : 0 : }
302 : :
303 : : /* Causes the original contents of column "ka" in 'row' to be
304 : : * verified as a prerequisite to completing the transaction. That is, if
305 : : * "ka" in 'row' changed (or if 'row' was deleted) between the
306 : : * time that the IDL originally read its contents and the time that the
307 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
308 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
309 : : * change has already been received).
310 : : *
311 : : * The intention is that, to ensure that no transaction commits based on dirty
312 : : * reads, an application should call this function any time "ka" is
313 : : * read as part of a read-modify-write operation.
314 : : *
315 : : * In some cases this function reduces to a no-op, because the current value
316 : : * of "ka" is already known:
317 : : *
318 : : * - If 'row' is a row created by the current transaction (returned by
319 : : * idltest_link1_insert()).
320 : : *
321 : : * - If "ka" has already been modified (with
322 : : * idltest_link1_set_ka()) within the current transaction.
323 : : *
324 : : * Because of the latter property, always call this function *before*
325 : : * idltest_link1_set_ka() for a given read-modify-write.
326 : : *
327 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
328 : : void
329 : 0 : idltest_link1_verify_ka(const struct idltest_link1 *row)
330 : : {
331 [ # # ]: 0 : ovs_assert(inited);
332 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_link1_columns[IDLTEST_LINK1_COL_KA]);
333 : 0 : }
334 : :
335 : : /* Causes the original contents of column "l2" in 'row' to be
336 : : * verified as a prerequisite to completing the transaction. That is, if
337 : : * "l2" in 'row' changed (or if 'row' was deleted) between the
338 : : * time that the IDL originally read its contents and the time that the
339 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
340 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
341 : : * change has already been received).
342 : : *
343 : : * The intention is that, to ensure that no transaction commits based on dirty
344 : : * reads, an application should call this function any time "l2" is
345 : : * read as part of a read-modify-write operation.
346 : : *
347 : : * In some cases this function reduces to a no-op, because the current value
348 : : * of "l2" is already known:
349 : : *
350 : : * - If 'row' is a row created by the current transaction (returned by
351 : : * idltest_link1_insert()).
352 : : *
353 : : * - If "l2" has already been modified (with
354 : : * idltest_link1_set_l2()) within the current transaction.
355 : : *
356 : : * Because of the latter property, always call this function *before*
357 : : * idltest_link1_set_l2() for a given read-modify-write.
358 : : *
359 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
360 : : void
361 : 0 : idltest_link1_verify_l2(const struct idltest_link1 *row)
362 : : {
363 [ # # ]: 0 : ovs_assert(inited);
364 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_link1_columns[IDLTEST_LINK1_COL_L2]);
365 : 0 : }
366 : :
367 : : /* Returns the "i" column's value from the "link1" table in 'row'
368 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
369 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
370 : : * for a given key than implementing the same operation on the "cooked"
371 : : * form in 'row'.
372 : : *
373 : : * 'key_type' must be OVSDB_TYPE_INTEGER.
374 : : * (This helps to avoid silent bugs if someone changes i's
375 : : * type without updating the caller.)
376 : : *
377 : : * The caller must not modify or free the returned value.
378 : : *
379 : : * Various kinds of changes can invalidate the returned value: modifying
380 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
381 : : * If the returned value is needed for a long time, it is best to make a copy
382 : : * of it with ovsdb_datum_clone().
383 : : *
384 : : * This function is rarely useful, since it is easier to access the value
385 : : * directly through the "i" member in idltest_link1. */
386 : : const struct ovsdb_datum *
387 : 0 : idltest_link1_get_i(const struct idltest_link1 *row,
388 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
389 : : {
390 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_INTEGER);
391 : 0 : return ovsdb_idl_read(&row->header_, &idltest_link1_col_i);
392 : : }
393 : :
394 : : /* Returns the "k" column's value from the "link1" table in 'row'
395 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
396 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
397 : : * for a given key than implementing the same operation on the "cooked"
398 : : * form in 'row'.
399 : : *
400 : : * 'key_type' must be OVSDB_TYPE_UUID.
401 : : * (This helps to avoid silent bugs if someone changes k's
402 : : * type without updating the caller.)
403 : : *
404 : : * The caller must not modify or free the returned value.
405 : : *
406 : : * Various kinds of changes can invalidate the returned value: modifying
407 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
408 : : * If the returned value is needed for a long time, it is best to make a copy
409 : : * of it with ovsdb_datum_clone().
410 : : *
411 : : * This function is rarely useful, since it is easier to access the value
412 : : * directly through the "k" member in idltest_link1. */
413 : : const struct ovsdb_datum *
414 : 0 : idltest_link1_get_k(const struct idltest_link1 *row,
415 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
416 : : {
417 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_UUID);
418 : 0 : return ovsdb_idl_read(&row->header_, &idltest_link1_col_k);
419 : : }
420 : :
421 : : /* Returns the "ka" column's value from the "link1" table in 'row'
422 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
423 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
424 : : * for a given key than implementing the same operation on the "cooked"
425 : : * form in 'row'.
426 : : *
427 : : * 'key_type' must be OVSDB_TYPE_UUID.
428 : : * (This helps to avoid silent bugs if someone changes ka's
429 : : * type without updating the caller.)
430 : : *
431 : : * The caller must not modify or free the returned value.
432 : : *
433 : : * Various kinds of changes can invalidate the returned value: modifying
434 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
435 : : * If the returned value is needed for a long time, it is best to make a copy
436 : : * of it with ovsdb_datum_clone().
437 : : *
438 : : * This function is rarely useful, since it is easier to access the value
439 : : * directly through the "ka" member in idltest_link1. */
440 : : const struct ovsdb_datum *
441 : 0 : idltest_link1_get_ka(const struct idltest_link1 *row,
442 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
443 : : {
444 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_UUID);
445 : 0 : return ovsdb_idl_read(&row->header_, &idltest_link1_col_ka);
446 : : }
447 : :
448 : : /* Returns the "l2" column's value from the "link1" table in 'row'
449 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
450 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
451 : : * for a given key than implementing the same operation on the "cooked"
452 : : * form in 'row'.
453 : : *
454 : : * 'key_type' must be OVSDB_TYPE_UUID.
455 : : * (This helps to avoid silent bugs if someone changes l2's
456 : : * type without updating the caller.)
457 : : *
458 : : * The caller must not modify or free the returned value.
459 : : *
460 : : * Various kinds of changes can invalidate the returned value: modifying
461 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
462 : : * If the returned value is needed for a long time, it is best to make a copy
463 : : * of it with ovsdb_datum_clone().
464 : : *
465 : : * This function is rarely useful, since it is easier to access the value
466 : : * directly through the "l2" member in idltest_link1. */
467 : : const struct ovsdb_datum *
468 : 0 : idltest_link1_get_l2(const struct idltest_link1 *row,
469 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
470 : : {
471 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_UUID);
472 : 0 : return ovsdb_idl_read(&row->header_, &idltest_link1_col_l2);
473 : : }
474 : :
475 : : /* Sets the "i" column from the "link1" table in 'row' to
476 : : * 'i'.
477 : : *
478 : : * The caller retains ownership of the arguments. */
479 : : void
480 : 0 : idltest_link1_set_i(const struct idltest_link1 *row, int64_t i)
481 : : {
482 : : struct ovsdb_datum datum;
483 : : union ovsdb_atom key;
484 : :
485 [ # # ]: 0 : ovs_assert(inited);
486 : 0 : datum.n = 1;
487 : 0 : datum.keys = &key;
488 : 0 : key.integer = i;
489 : 0 : datum.values = NULL;
490 : 0 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_link1_columns[IDLTEST_LINK1_COL_I], &datum);
491 : 0 : }
492 : :
493 : : /* Sets the "k" column from the "link1" table in 'row' to
494 : : * 'k'.
495 : : *
496 : : * The caller retains ownership of the arguments. */
497 : : void
498 : 0 : idltest_link1_set_k(const struct idltest_link1 *row, const struct idltest_link1 *k)
499 : : {
500 : : struct ovsdb_datum datum;
501 : : union ovsdb_atom key;
502 : :
503 [ # # ]: 0 : ovs_assert(inited);
504 : 0 : datum.n = 1;
505 : 0 : datum.keys = &key;
506 : 0 : key.uuid = k->header_.uuid;
507 : 0 : datum.values = NULL;
508 : 0 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_link1_columns[IDLTEST_LINK1_COL_K], &datum);
509 : 0 : }
510 : :
511 : : /* Sets the "ka" column from the "link1" table in 'row' to
512 : : * the 'ka' set with 'n_ka' entries.
513 : : *
514 : : * The caller retains ownership of the arguments. */
515 : : void
516 : 0 : idltest_link1_set_ka(const struct idltest_link1 *row, struct idltest_link1 **ka, size_t n_ka)
517 : : {
518 : : struct ovsdb_datum datum;
519 : : size_t i;
520 : :
521 [ # # ]: 0 : ovs_assert(inited);
522 : 0 : datum.n = n_ka;
523 [ # # ]: 0 : datum.keys = n_ka ? xmalloc(n_ka * sizeof *datum.keys) : NULL;
524 : 0 : datum.values = NULL;
525 [ # # ]: 0 : for (i = 0; i < n_ka; i++) {
526 : 0 : datum.keys[i].uuid = ka[i]->header_.uuid;
527 : : }
528 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
529 : 0 : ovsdb_idl_txn_write(&row->header_, &idltest_link1_columns[IDLTEST_LINK1_COL_KA], &datum);
530 : 0 : }
531 : :
532 : : /* Sets the "l2" column from the "link1" table in 'row' to
533 : : * the 'l2' set.
534 : : *
535 : : * If "l2" is null, the column will be the empty set,
536 : : * otherwise it will contain the specified value.
537 : : *
538 : : * The caller retains ownership of the arguments. */
539 : : void
540 : 0 : idltest_link1_set_l2(const struct idltest_link1 *row, const struct idltest_link2 *l2)
541 : : {
542 : : struct ovsdb_datum datum;
543 : : union ovsdb_atom key;
544 : :
545 [ # # ]: 0 : ovs_assert(inited);
546 [ # # ]: 0 : if (l2) {
547 : 0 : datum.n = 1;
548 : 0 : datum.keys = &key;
549 : 0 : key.uuid = l2->header_.uuid;
550 : : } else {
551 : 0 : datum.n = 0;
552 : 0 : datum.keys = NULL;
553 : : }
554 : 0 : datum.values = NULL;
555 : 0 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_link1_columns[IDLTEST_LINK1_COL_L2], &datum);
556 : 0 : }
557 : :
558 : : /* Adds the value 'new_value' to the "ka" set column from the "link1" table
559 : : * in 'row'.
560 : : *
561 : : */
562 : : void
563 : 0 : idltest_link1_update_ka_addvalue(const struct idltest_link1 *row, const struct idltest_link1 *new_value)
564 : : {
565 : : struct ovsdb_datum *datum;
566 : :
567 [ # # ]: 0 : ovs_assert(inited);
568 : :
569 : 0 : datum = xmalloc(sizeof *datum);
570 : 0 : datum->n = 1;
571 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
572 : 0 : datum->values = NULL;
573 : :
574 : 0 : datum->keys[0].uuid = new_value->header_.uuid;
575 : :
576 : 0 : ovsdb_idl_txn_write_partial_set(&row->header_,
577 : : &idltest_link1_columns[IDLTEST_LINK1_COL_KA],
578 : : datum);
579 : 0 : }
580 : :
581 : : /* Deletes the value 'delete_value' from the "ka" set column from the
582 : : * "link1" table in 'row'.
583 : : *
584 : : */
585 : : void
586 : 0 : idltest_link1_update_ka_delvalue(const struct idltest_link1 *row, const struct idltest_link1 *delete_value)
587 : : {
588 : : struct ovsdb_datum *datum;
589 : :
590 [ # # ]: 0 : ovs_assert(inited);
591 : :
592 : 0 : datum = xmalloc(sizeof *datum);
593 : 0 : datum->n = 1;
594 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
595 : 0 : datum->values = NULL;
596 : :
597 : 0 : datum->keys[0].uuid = delete_value->header_.uuid;
598 : :
599 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
600 : : &idltest_link1_columns[IDLTEST_LINK1_COL_KA],
601 : : datum);
602 : 0 : }
603 : :
604 : : /* Adds the value 'new_value' to the "l2" set column from the "link1" table
605 : : * in 'row'.
606 : : *
607 : : */
608 : : void
609 : 0 : idltest_link1_update_l2_addvalue(const struct idltest_link1 *row, const struct idltest_link2 *new_value)
610 : : {
611 : : struct ovsdb_datum *datum;
612 : :
613 [ # # ]: 0 : ovs_assert(inited);
614 : :
615 : 0 : datum = xmalloc(sizeof *datum);
616 : 0 : datum->n = 1;
617 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
618 : 0 : datum->values = NULL;
619 : :
620 : 0 : datum->keys[0].uuid = new_value->header_.uuid;
621 : :
622 : 0 : ovsdb_idl_txn_write_partial_set(&row->header_,
623 : : &idltest_link1_columns[IDLTEST_LINK1_COL_L2],
624 : : datum);
625 : 0 : }
626 : :
627 : : /* Deletes the value 'delete_value' from the "l2" set column from the
628 : : * "link1" table in 'row'.
629 : : *
630 : : */
631 : : void
632 : 0 : idltest_link1_update_l2_delvalue(const struct idltest_link1 *row, const struct idltest_link2 *delete_value)
633 : : {
634 : : struct ovsdb_datum *datum;
635 : :
636 [ # # ]: 0 : ovs_assert(inited);
637 : :
638 : 0 : datum = xmalloc(sizeof *datum);
639 : 0 : datum->n = 1;
640 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
641 : 0 : datum->values = NULL;
642 : :
643 : 0 : datum->keys[0].uuid = delete_value->header_.uuid;
644 : :
645 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
646 : : &idltest_link1_columns[IDLTEST_LINK1_COL_L2],
647 : : datum);
648 : 0 : }
649 : :
650 : : /* Sets the "i" column from the "link1" table in 'row' to
651 : : * 'i'.
652 : : *
653 : : * The caller retains ownership of the arguments. */
654 : : void
655 : 1 : idltest_link1_add_clause_i(struct ovsdb_idl *idl, enum ovsdb_function function, int64_t i)
656 : : {
657 : : struct ovsdb_datum datum;
658 : : union ovsdb_atom key;
659 : :
660 [ - + ]: 1 : ovs_assert(inited);
661 : 1 : datum.n = 1;
662 : 1 : datum.keys = &key;
663 : 1 : key.integer = i;
664 : 1 : datum.values = NULL;
665 : 1 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1],
666 : : function,
667 : : &idltest_link1_columns[IDLTEST_LINK1_COL_I],
668 : : &datum);
669 : 1 : }
670 : :
671 : : /* Sets the "k" column from the "link1" table in 'row' to
672 : : * 'k'.
673 : : *
674 : : * The caller retains ownership of the arguments. */
675 : : void
676 : 0 : idltest_link1_add_clause_k(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *k)
677 : : {
678 : : struct ovsdb_datum datum;
679 : : union ovsdb_atom key;
680 : :
681 [ # # ]: 0 : ovs_assert(inited);
682 : 0 : datum.n = 1;
683 : 0 : datum.keys = &key;
684 : 0 : key.uuid = *k;
685 : 0 : datum.values = NULL;
686 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1],
687 : : function,
688 : : &idltest_link1_columns[IDLTEST_LINK1_COL_K],
689 : : &datum);
690 : 0 : }
691 : :
692 : : /* Sets the "ka" column from the "link1" table in 'row' to
693 : : * the 'ka' set with 'n_ka' entries.
694 : : *
695 : : * The caller retains ownership of the arguments. */
696 : : void
697 : 0 : idltest_link1_add_clause_ka(struct ovsdb_idl *idl, enum ovsdb_function function, struct uuid **ka, size_t n_ka)
698 : : {
699 : : struct ovsdb_datum datum;
700 : : size_t i;
701 : :
702 [ # # ]: 0 : ovs_assert(inited);
703 : 0 : datum.n = n_ka;
704 [ # # ]: 0 : datum.keys = n_ka ? xmalloc(n_ka * sizeof *datum.keys) : NULL;
705 : 0 : datum.values = NULL;
706 [ # # ]: 0 : for (i = 0; i < n_ka; i++) {
707 : 0 : datum.keys[i].uuid = *ka[i];
708 : : }
709 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
710 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1],
711 : : function,
712 : : &idltest_link1_columns[IDLTEST_LINK1_COL_KA],
713 : : &datum);
714 : 0 : free(datum.keys);
715 : 0 : }
716 : :
717 : : /* Sets the "l2" column from the "link1" table in 'row' to
718 : : * the 'l2' set.
719 : : *
720 : : * If "l2" is null, the column will be the empty set,
721 : : * otherwise it will contain the specified value.
722 : : *
723 : : * The caller retains ownership of the arguments. */
724 : : void
725 : 0 : idltest_link1_add_clause_l2(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *l2)
726 : : {
727 : : struct ovsdb_datum datum;
728 : : union ovsdb_atom key;
729 : :
730 [ # # ]: 0 : ovs_assert(inited);
731 [ # # ]: 0 : if (l2) {
732 : 0 : datum.n = 1;
733 : 0 : datum.keys = &key;
734 : 0 : key.uuid = *l2;
735 : : } else {
736 : 0 : datum.n = 0;
737 : 0 : datum.keys = NULL;
738 : : }
739 : 0 : datum.values = NULL;
740 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1],
741 : : function,
742 : : &idltest_link1_columns[IDLTEST_LINK1_COL_L2],
743 : : &datum);
744 : 0 : }
745 : : void
746 : 1 : idltest_link1_add_clause_false(struct ovsdb_idl *idl)
747 : : {
748 : : struct ovsdb_datum datum;
749 : :
750 : 1 : ovsdb_datum_init_empty(&datum);
751 : 1 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1], OVSDB_F_FALSE, NULL, &datum);
752 : 1 : }
753 : : void
754 : 0 : idltest_link1_add_clause_true(struct ovsdb_idl *idl)
755 : : {
756 : : struct ovsdb_datum datum;
757 : :
758 : 0 : ovsdb_datum_init_empty(&datum);
759 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1], OVSDB_F_TRUE, NULL, &datum);
760 : 0 : }
761 : :
762 : : /* Sets the "i" column from the "link1" table in 'row' to
763 : : * 'i'.
764 : : *
765 : : * The caller retains ownership of the arguments. */
766 : : void
767 : 0 : idltest_link1_remove_clause_i(struct ovsdb_idl *idl, enum ovsdb_function function, int64_t i)
768 : : {
769 : : struct ovsdb_datum datum;
770 : : union ovsdb_atom key;
771 : :
772 [ # # ]: 0 : ovs_assert(inited);
773 : 0 : datum.n = 1;
774 : 0 : datum.keys = &key;
775 : 0 : key.integer = i;
776 : 0 : datum.values = NULL;
777 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1],
778 : : function,
779 : : &idltest_link1_columns[IDLTEST_LINK1_COL_I],
780 : : &datum);
781 : 0 : }
782 : :
783 : : /* Sets the "k" column from the "link1" table in 'row' to
784 : : * 'k'.
785 : : *
786 : : * The caller retains ownership of the arguments. */
787 : : void
788 : 0 : idltest_link1_remove_clause_k(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *k)
789 : : {
790 : : struct ovsdb_datum datum;
791 : : union ovsdb_atom key;
792 : :
793 [ # # ]: 0 : ovs_assert(inited);
794 : 0 : datum.n = 1;
795 : 0 : datum.keys = &key;
796 : 0 : key.uuid = *k;
797 : 0 : datum.values = NULL;
798 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1],
799 : : function,
800 : : &idltest_link1_columns[IDLTEST_LINK1_COL_K],
801 : : &datum);
802 : 0 : }
803 : :
804 : : /* Sets the "ka" column from the "link1" table in 'row' to
805 : : * the 'ka' set with 'n_ka' entries.
806 : : *
807 : : * The caller retains ownership of the arguments. */
808 : : void
809 : 0 : idltest_link1_remove_clause_ka(struct ovsdb_idl *idl, enum ovsdb_function function, struct uuid **ka, size_t n_ka)
810 : : {
811 : : struct ovsdb_datum datum;
812 : : size_t i;
813 : :
814 [ # # ]: 0 : ovs_assert(inited);
815 : 0 : datum.n = n_ka;
816 [ # # ]: 0 : datum.keys = n_ka ? xmalloc(n_ka * sizeof *datum.keys) : NULL;
817 : 0 : datum.values = NULL;
818 [ # # ]: 0 : for (i = 0; i < n_ka; i++) {
819 : 0 : datum.keys[i].uuid = *ka[i];
820 : : }
821 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
822 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1],
823 : : function,
824 : : &idltest_link1_columns[IDLTEST_LINK1_COL_KA],
825 : : &datum);
826 : 0 : free(datum.keys);
827 : 0 : }
828 : :
829 : : /* Sets the "l2" column from the "link1" table in 'row' to
830 : : * the 'l2' set.
831 : : *
832 : : * If "l2" is null, the column will be the empty set,
833 : : * otherwise it will contain the specified value.
834 : : *
835 : : * The caller retains ownership of the arguments. */
836 : : void
837 : 0 : idltest_link1_remove_clause_l2(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *l2)
838 : : {
839 : : struct ovsdb_datum datum;
840 : : union ovsdb_atom key;
841 : :
842 [ # # ]: 0 : ovs_assert(inited);
843 [ # # ]: 0 : if (l2) {
844 : 0 : datum.n = 1;
845 : 0 : datum.keys = &key;
846 : 0 : key.uuid = *l2;
847 : : } else {
848 : 0 : datum.n = 0;
849 : 0 : datum.keys = NULL;
850 : : }
851 : 0 : datum.values = NULL;
852 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1],
853 : : function,
854 : : &idltest_link1_columns[IDLTEST_LINK1_COL_L2],
855 : : &datum);
856 : 0 : }
857 : : void
858 : 0 : idltest_link1_remove_clause_false(struct ovsdb_idl *idl)
859 : : {
860 : : struct ovsdb_datum datum;
861 : :
862 : 0 : ovsdb_datum_init_empty(&datum);
863 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1], OVSDB_F_FALSE, NULL, &datum);
864 : 0 : }
865 : : void
866 : 0 : idltest_link1_remove_clause_true(struct ovsdb_idl *idl)
867 : : {
868 : : struct ovsdb_datum datum;
869 : :
870 : 0 : ovsdb_datum_init_empty(&datum);
871 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK1], OVSDB_F_TRUE, NULL, &datum);
872 : 0 : }
873 : :
874 : : struct ovsdb_idl_column idltest_link1_columns[IDLTEST_LINK1_N_COLUMNS];
875 : :
876 : : static void
877 : 23 : idltest_link1_columns_init(void)
878 : : {
879 : : struct ovsdb_idl_column *c;
880 : :
881 : : /* Initialize idltest_link1_col_i. */
882 : 23 : c = &idltest_link1_col_i;
883 : 23 : c->name = "i";
884 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_INTEGER);
885 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
886 : 23 : c->type.n_min = 1;
887 : 23 : c->type.n_max = 1;
888 : 23 : c->mutable = true;
889 : 23 : c->parse = idltest_link1_parse_i;
890 : 23 : c->unparse = idltest_link1_unparse_i;
891 : :
892 : : /* Initialize idltest_link1_col_k. */
893 : 23 : c = &idltest_link1_col_k;
894 : 23 : c->name = "k";
895 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_UUID);
896 : 23 : c->type.key.u.uuid.refTableName = "link1";
897 : 23 : c->type.key.u.uuid.refType = OVSDB_REF_STRONG;
898 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
899 : 23 : c->type.n_min = 1;
900 : 23 : c->type.n_max = 1;
901 : 23 : c->mutable = true;
902 : 23 : c->parse = idltest_link1_parse_k;
903 : 23 : c->unparse = idltest_link1_unparse_k;
904 : :
905 : : /* Initialize idltest_link1_col_ka. */
906 : 23 : c = &idltest_link1_col_ka;
907 : 23 : c->name = "ka";
908 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_UUID);
909 : 23 : c->type.key.u.uuid.refTableName = "link1";
910 : 23 : c->type.key.u.uuid.refType = OVSDB_REF_STRONG;
911 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
912 : 23 : c->type.n_min = 0;
913 : 23 : c->type.n_max = UINT_MAX;
914 : 23 : c->mutable = true;
915 : 23 : c->parse = idltest_link1_parse_ka;
916 : 23 : c->unparse = idltest_link1_unparse_ka;
917 : :
918 : : /* Initialize idltest_link1_col_l2. */
919 : 23 : c = &idltest_link1_col_l2;
920 : 23 : c->name = "l2";
921 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_UUID);
922 : 23 : c->type.key.u.uuid.refTableName = "link2";
923 : 23 : c->type.key.u.uuid.refType = OVSDB_REF_STRONG;
924 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
925 : 23 : c->type.n_min = 0;
926 : 23 : c->type.n_max = 1;
927 : 23 : c->mutable = true;
928 : 23 : c->parse = idltest_link1_parse_l2;
929 : 23 : c->unparse = idltest_link1_unparse_l2;
930 : 23 : }
931 : :
932 : : /* link2 table. */
933 : :
934 : : static void
935 : 2 : idltest_link2_parse_i(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
936 : : {
937 : 2 : struct idltest_link2 *row = idltest_link2_cast(row_);
938 : :
939 [ - + ]: 2 : ovs_assert(inited);
940 [ + - ]: 2 : if (datum->n >= 1) {
941 : 2 : row->i = datum->keys[0].integer;
942 : : } else {
943 : 0 : row->i = 0;
944 : : }
945 : 2 : }
946 : :
947 : : static void
948 : 2 : idltest_link2_parse_l1(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
949 : : {
950 : 2 : struct idltest_link2 *row = idltest_link2_cast(row_);
951 : :
952 [ - + ]: 2 : ovs_assert(inited);
953 [ - + ]: 2 : if (datum->n >= 1) {
954 : 0 : row->l1 = idltest_link1_cast(ovsdb_idl_get_row_arc(row_, &idltest_table_classes[IDLTEST_TABLE_LINK1], &datum->keys[0].uuid));
955 : : } else {
956 : 2 : row->l1 = NULL;
957 : : }
958 : 2 : }
959 : :
960 : : static void
961 : 2 : idltest_link2_unparse_i(struct ovsdb_idl_row *row OVS_UNUSED)
962 : : {
963 : : /* Nothing to do. */
964 : 2 : }
965 : :
966 : : static void
967 : 2 : idltest_link2_unparse_l1(struct ovsdb_idl_row *row OVS_UNUSED)
968 : : {
969 : : /* Nothing to do. */
970 : 2 : }
971 : :
972 : : static void
973 : 2 : idltest_link2_init__(struct ovsdb_idl_row *row)
974 : : {
975 : 2 : idltest_link2_init(idltest_link2_cast(row));
976 : 2 : }
977 : :
978 : : /* Clears the contents of 'row' in table "link2". */
979 : : void
980 : 2 : idltest_link2_init(struct idltest_link2 *row)
981 : : {
982 : 2 : memset(row, 0, sizeof *row);
983 : 2 : }
984 : :
985 : : /* Searches table "link2" in 'idl' for a row with UUID 'uuid'. Returns
986 : : * a pointer to the row if there is one, otherwise a null pointer. */
987 : : const struct idltest_link2 *
988 : 0 : idltest_link2_get_for_uuid(const struct ovsdb_idl *idl, const struct uuid *uuid)
989 : : {
990 : 0 : return idltest_link2_cast(ovsdb_idl_get_row_for_uuid(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2], uuid));
991 : : }
992 : :
993 : : /* Returns a row in table "link2" in 'idl', or a null pointer if that
994 : : * table is empty.
995 : : *
996 : : * Database tables are internally maintained as hash tables, so adding or
997 : : * removing rows while traversing the same table can cause some rows to be
998 : : * visited twice or not at apply. */
999 : : const struct idltest_link2 *
1000 : 61 : idltest_link2_first(const struct ovsdb_idl *idl)
1001 : : {
1002 : 61 : return idltest_link2_cast(ovsdb_idl_first_row(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2]));
1003 : : }
1004 : :
1005 : : /* Returns a row following 'row' within its table, or a null pointer if 'row'
1006 : : * is the last row in its table. */
1007 : : const struct idltest_link2 *
1008 : 2 : idltest_link2_next(const struct idltest_link2 *row)
1009 : : {
1010 : 2 : return idltest_link2_cast(ovsdb_idl_next_row(&row->header_));
1011 : : }
1012 : :
1013 : 0 : unsigned int idltest_link2_get_seqno(const struct ovsdb_idl *idl)
1014 : : {
1015 : 0 : return ovsdb_idl_table_get_seqno(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2]);
1016 : : }
1017 : :
1018 : 0 : unsigned int idltest_link2_row_get_seqno(const struct idltest_link2 *row, enum ovsdb_idl_change change)
1019 : : {
1020 : 0 : return ovsdb_idl_row_get_seqno(&row->header_, change);
1021 : : }
1022 : :
1023 : : const struct idltest_link2 *
1024 : 8 : idltest_link2_track_get_first(const struct ovsdb_idl *idl)
1025 : : {
1026 : 8 : return idltest_link2_cast(ovsdb_idl_track_get_first(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2]));
1027 : : }
1028 : :
1029 : : const struct idltest_link2
1030 : 0 : *idltest_link2_track_get_next(const struct idltest_link2 *row)
1031 : : {
1032 : 0 : return idltest_link2_cast(ovsdb_idl_track_get_next(&row->header_));
1033 : : }
1034 : :
1035 : :
1036 : : /* Deletes 'row' from table "link2". 'row' may be freed, so it must not be
1037 : : * accessed afterward.
1038 : : *
1039 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1040 : : void
1041 : 0 : idltest_link2_delete(const struct idltest_link2 *row)
1042 : : {
1043 : 0 : ovsdb_idl_txn_delete(&row->header_);
1044 : 0 : }
1045 : :
1046 : : /* Inserts and returns a new row in the table "link2" in the database
1047 : : * with open transaction 'txn'.
1048 : : *
1049 : : * The new row is assigned a randomly generated provisional UUID.
1050 : : * ovsdb-server will assign a different UUID when 'txn' is committed,
1051 : : * but the IDL will replace any uses of the provisional UUID in the
1052 : : * data to be to be committed by the UUID assigned by ovsdb-server. */
1053 : : struct idltest_link2 *
1054 : 0 : idltest_link2_insert(struct ovsdb_idl_txn *txn)
1055 : : {
1056 : 0 : return idltest_link2_cast(ovsdb_idl_txn_insert(txn, &idltest_table_classes[IDLTEST_TABLE_LINK2], NULL));
1057 : : }
1058 : :
1059 : : bool
1060 : 4 : idltest_link2_is_updated(const struct idltest_link2 *row, enum idltest_link2_column_id column)
1061 : : {
1062 : 4 : return ovsdb_idl_track_is_updated(&row->header_, &idltest_link2_columns[column]);
1063 : : }
1064 : :
1065 : : /* Causes the original contents of column "i" in 'row' to be
1066 : : * verified as a prerequisite to completing the transaction. That is, if
1067 : : * "i" in 'row' changed (or if 'row' was deleted) between the
1068 : : * time that the IDL originally read its contents and the time that the
1069 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1070 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1071 : : * change has already been received).
1072 : : *
1073 : : * The intention is that, to ensure that no transaction commits based on dirty
1074 : : * reads, an application should call this function any time "i" is
1075 : : * read as part of a read-modify-write operation.
1076 : : *
1077 : : * In some cases this function reduces to a no-op, because the current value
1078 : : * of "i" is already known:
1079 : : *
1080 : : * - If 'row' is a row created by the current transaction (returned by
1081 : : * idltest_link2_insert()).
1082 : : *
1083 : : * - If "i" has already been modified (with
1084 : : * idltest_link2_set_i()) within the current transaction.
1085 : : *
1086 : : * Because of the latter property, always call this function *before*
1087 : : * idltest_link2_set_i() for a given read-modify-write.
1088 : : *
1089 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1090 : : void
1091 : 0 : idltest_link2_verify_i(const struct idltest_link2 *row)
1092 : : {
1093 [ # # ]: 0 : ovs_assert(inited);
1094 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_link2_columns[IDLTEST_LINK2_COL_I]);
1095 : 0 : }
1096 : :
1097 : : /* Causes the original contents of column "l1" in 'row' to be
1098 : : * verified as a prerequisite to completing the transaction. That is, if
1099 : : * "l1" in 'row' changed (or if 'row' was deleted) between the
1100 : : * time that the IDL originally read its contents and the time that the
1101 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1102 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1103 : : * change has already been received).
1104 : : *
1105 : : * The intention is that, to ensure that no transaction commits based on dirty
1106 : : * reads, an application should call this function any time "l1" is
1107 : : * read as part of a read-modify-write operation.
1108 : : *
1109 : : * In some cases this function reduces to a no-op, because the current value
1110 : : * of "l1" is already known:
1111 : : *
1112 : : * - If 'row' is a row created by the current transaction (returned by
1113 : : * idltest_link2_insert()).
1114 : : *
1115 : : * - If "l1" has already been modified (with
1116 : : * idltest_link2_set_l1()) within the current transaction.
1117 : : *
1118 : : * Because of the latter property, always call this function *before*
1119 : : * idltest_link2_set_l1() for a given read-modify-write.
1120 : : *
1121 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1122 : : void
1123 : 0 : idltest_link2_verify_l1(const struct idltest_link2 *row)
1124 : : {
1125 [ # # ]: 0 : ovs_assert(inited);
1126 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_link2_columns[IDLTEST_LINK2_COL_L1]);
1127 : 0 : }
1128 : :
1129 : : /* Returns the "i" column's value from the "link2" table in 'row'
1130 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
1131 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
1132 : : * for a given key than implementing the same operation on the "cooked"
1133 : : * form in 'row'.
1134 : : *
1135 : : * 'key_type' must be OVSDB_TYPE_INTEGER.
1136 : : * (This helps to avoid silent bugs if someone changes i's
1137 : : * type without updating the caller.)
1138 : : *
1139 : : * The caller must not modify or free the returned value.
1140 : : *
1141 : : * Various kinds of changes can invalidate the returned value: modifying
1142 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
1143 : : * If the returned value is needed for a long time, it is best to make a copy
1144 : : * of it with ovsdb_datum_clone().
1145 : : *
1146 : : * This function is rarely useful, since it is easier to access the value
1147 : : * directly through the "i" member in idltest_link2. */
1148 : : const struct ovsdb_datum *
1149 : 0 : idltest_link2_get_i(const struct idltest_link2 *row,
1150 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
1151 : : {
1152 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_INTEGER);
1153 : 0 : return ovsdb_idl_read(&row->header_, &idltest_link2_col_i);
1154 : : }
1155 : :
1156 : : /* Returns the "l1" column's value from the "link2" table in 'row'
1157 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
1158 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
1159 : : * for a given key than implementing the same operation on the "cooked"
1160 : : * form in 'row'.
1161 : : *
1162 : : * 'key_type' must be OVSDB_TYPE_UUID.
1163 : : * (This helps to avoid silent bugs if someone changes l1's
1164 : : * type without updating the caller.)
1165 : : *
1166 : : * The caller must not modify or free the returned value.
1167 : : *
1168 : : * Various kinds of changes can invalidate the returned value: modifying
1169 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
1170 : : * If the returned value is needed for a long time, it is best to make a copy
1171 : : * of it with ovsdb_datum_clone().
1172 : : *
1173 : : * This function is rarely useful, since it is easier to access the value
1174 : : * directly through the "l1" member in idltest_link2. */
1175 : : const struct ovsdb_datum *
1176 : 0 : idltest_link2_get_l1(const struct idltest_link2 *row,
1177 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
1178 : : {
1179 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_UUID);
1180 : 0 : return ovsdb_idl_read(&row->header_, &idltest_link2_col_l1);
1181 : : }
1182 : :
1183 : : /* Sets the "i" column from the "link2" table in 'row' to
1184 : : * 'i'.
1185 : : *
1186 : : * The caller retains ownership of the arguments. */
1187 : : void
1188 : 0 : idltest_link2_set_i(const struct idltest_link2 *row, int64_t i)
1189 : : {
1190 : : struct ovsdb_datum datum;
1191 : : union ovsdb_atom key;
1192 : :
1193 [ # # ]: 0 : ovs_assert(inited);
1194 : 0 : datum.n = 1;
1195 : 0 : datum.keys = &key;
1196 : 0 : key.integer = i;
1197 : 0 : datum.values = NULL;
1198 : 0 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_link2_columns[IDLTEST_LINK2_COL_I], &datum);
1199 : 0 : }
1200 : :
1201 : : /* Sets the "l1" column from the "link2" table in 'row' to
1202 : : * the 'l1' set.
1203 : : *
1204 : : * If "l1" is null, the column will be the empty set,
1205 : : * otherwise it will contain the specified value.
1206 : : *
1207 : : * The caller retains ownership of the arguments. */
1208 : : void
1209 : 0 : idltest_link2_set_l1(const struct idltest_link2 *row, const struct idltest_link1 *l1)
1210 : : {
1211 : : struct ovsdb_datum datum;
1212 : : union ovsdb_atom key;
1213 : :
1214 [ # # ]: 0 : ovs_assert(inited);
1215 [ # # ]: 0 : if (l1) {
1216 : 0 : datum.n = 1;
1217 : 0 : datum.keys = &key;
1218 : 0 : key.uuid = l1->header_.uuid;
1219 : : } else {
1220 : 0 : datum.n = 0;
1221 : 0 : datum.keys = NULL;
1222 : : }
1223 : 0 : datum.values = NULL;
1224 : 0 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_link2_columns[IDLTEST_LINK2_COL_L1], &datum);
1225 : 0 : }
1226 : :
1227 : : /* Adds the value 'new_value' to the "l1" set column from the "link2" table
1228 : : * in 'row'.
1229 : : *
1230 : : */
1231 : : void
1232 : 0 : idltest_link2_update_l1_addvalue(const struct idltest_link2 *row, const struct idltest_link1 *new_value)
1233 : : {
1234 : : struct ovsdb_datum *datum;
1235 : :
1236 [ # # ]: 0 : ovs_assert(inited);
1237 : :
1238 : 0 : datum = xmalloc(sizeof *datum);
1239 : 0 : datum->n = 1;
1240 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
1241 : 0 : datum->values = NULL;
1242 : :
1243 : 0 : datum->keys[0].uuid = new_value->header_.uuid;
1244 : :
1245 : 0 : ovsdb_idl_txn_write_partial_set(&row->header_,
1246 : : &idltest_link2_columns[IDLTEST_LINK2_COL_L1],
1247 : : datum);
1248 : 0 : }
1249 : :
1250 : : /* Deletes the value 'delete_value' from the "l1" set column from the
1251 : : * "link2" table in 'row'.
1252 : : *
1253 : : */
1254 : : void
1255 : 0 : idltest_link2_update_l1_delvalue(const struct idltest_link2 *row, const struct idltest_link1 *delete_value)
1256 : : {
1257 : : struct ovsdb_datum *datum;
1258 : :
1259 [ # # ]: 0 : ovs_assert(inited);
1260 : :
1261 : 0 : datum = xmalloc(sizeof *datum);
1262 : 0 : datum->n = 1;
1263 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
1264 : 0 : datum->values = NULL;
1265 : :
1266 : 0 : datum->keys[0].uuid = delete_value->header_.uuid;
1267 : :
1268 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
1269 : : &idltest_link2_columns[IDLTEST_LINK2_COL_L1],
1270 : : datum);
1271 : 0 : }
1272 : :
1273 : : /* Sets the "i" column from the "link2" table in 'row' to
1274 : : * 'i'.
1275 : : *
1276 : : * The caller retains ownership of the arguments. */
1277 : : void
1278 : 1 : idltest_link2_add_clause_i(struct ovsdb_idl *idl, enum ovsdb_function function, int64_t i)
1279 : : {
1280 : : struct ovsdb_datum datum;
1281 : : union ovsdb_atom key;
1282 : :
1283 [ - + ]: 1 : ovs_assert(inited);
1284 : 1 : datum.n = 1;
1285 : 1 : datum.keys = &key;
1286 : 1 : key.integer = i;
1287 : 1 : datum.values = NULL;
1288 : 1 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2],
1289 : : function,
1290 : : &idltest_link2_columns[IDLTEST_LINK2_COL_I],
1291 : : &datum);
1292 : 1 : }
1293 : :
1294 : : /* Sets the "l1" column from the "link2" table in 'row' to
1295 : : * the 'l1' set.
1296 : : *
1297 : : * If "l1" is null, the column will be the empty set,
1298 : : * otherwise it will contain the specified value.
1299 : : *
1300 : : * The caller retains ownership of the arguments. */
1301 : : void
1302 : 0 : idltest_link2_add_clause_l1(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *l1)
1303 : : {
1304 : : struct ovsdb_datum datum;
1305 : : union ovsdb_atom key;
1306 : :
1307 [ # # ]: 0 : ovs_assert(inited);
1308 [ # # ]: 0 : if (l1) {
1309 : 0 : datum.n = 1;
1310 : 0 : datum.keys = &key;
1311 : 0 : key.uuid = *l1;
1312 : : } else {
1313 : 0 : datum.n = 0;
1314 : 0 : datum.keys = NULL;
1315 : : }
1316 : 0 : datum.values = NULL;
1317 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2],
1318 : : function,
1319 : : &idltest_link2_columns[IDLTEST_LINK2_COL_L1],
1320 : : &datum);
1321 : 0 : }
1322 : : void
1323 : 1 : idltest_link2_add_clause_false(struct ovsdb_idl *idl)
1324 : : {
1325 : : struct ovsdb_datum datum;
1326 : :
1327 : 1 : ovsdb_datum_init_empty(&datum);
1328 : 1 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2], OVSDB_F_FALSE, NULL, &datum);
1329 : 1 : }
1330 : : void
1331 : 0 : idltest_link2_add_clause_true(struct ovsdb_idl *idl)
1332 : : {
1333 : : struct ovsdb_datum datum;
1334 : :
1335 : 0 : ovsdb_datum_init_empty(&datum);
1336 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2], OVSDB_F_TRUE, NULL, &datum);
1337 : 0 : }
1338 : :
1339 : : /* Sets the "i" column from the "link2" table in 'row' to
1340 : : * 'i'.
1341 : : *
1342 : : * The caller retains ownership of the arguments. */
1343 : : void
1344 : 0 : idltest_link2_remove_clause_i(struct ovsdb_idl *idl, enum ovsdb_function function, int64_t i)
1345 : : {
1346 : : struct ovsdb_datum datum;
1347 : : union ovsdb_atom key;
1348 : :
1349 [ # # ]: 0 : ovs_assert(inited);
1350 : 0 : datum.n = 1;
1351 : 0 : datum.keys = &key;
1352 : 0 : key.integer = i;
1353 : 0 : datum.values = NULL;
1354 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2],
1355 : : function,
1356 : : &idltest_link2_columns[IDLTEST_LINK2_COL_I],
1357 : : &datum);
1358 : 0 : }
1359 : :
1360 : : /* Sets the "l1" column from the "link2" table in 'row' to
1361 : : * the 'l1' set.
1362 : : *
1363 : : * If "l1" is null, the column will be the empty set,
1364 : : * otherwise it will contain the specified value.
1365 : : *
1366 : : * The caller retains ownership of the arguments. */
1367 : : void
1368 : 0 : idltest_link2_remove_clause_l1(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *l1)
1369 : : {
1370 : : struct ovsdb_datum datum;
1371 : : union ovsdb_atom key;
1372 : :
1373 [ # # ]: 0 : ovs_assert(inited);
1374 [ # # ]: 0 : if (l1) {
1375 : 0 : datum.n = 1;
1376 : 0 : datum.keys = &key;
1377 : 0 : key.uuid = *l1;
1378 : : } else {
1379 : 0 : datum.n = 0;
1380 : 0 : datum.keys = NULL;
1381 : : }
1382 : 0 : datum.values = NULL;
1383 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2],
1384 : : function,
1385 : : &idltest_link2_columns[IDLTEST_LINK2_COL_L1],
1386 : : &datum);
1387 : 0 : }
1388 : : void
1389 : 0 : idltest_link2_remove_clause_false(struct ovsdb_idl *idl)
1390 : : {
1391 : : struct ovsdb_datum datum;
1392 : :
1393 : 0 : ovsdb_datum_init_empty(&datum);
1394 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2], OVSDB_F_FALSE, NULL, &datum);
1395 : 0 : }
1396 : : void
1397 : 0 : idltest_link2_remove_clause_true(struct ovsdb_idl *idl)
1398 : : {
1399 : : struct ovsdb_datum datum;
1400 : :
1401 : 0 : ovsdb_datum_init_empty(&datum);
1402 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_LINK2], OVSDB_F_TRUE, NULL, &datum);
1403 : 0 : }
1404 : :
1405 : : struct ovsdb_idl_column idltest_link2_columns[IDLTEST_LINK2_N_COLUMNS];
1406 : :
1407 : : static void
1408 : 23 : idltest_link2_columns_init(void)
1409 : : {
1410 : : struct ovsdb_idl_column *c;
1411 : :
1412 : : /* Initialize idltest_link2_col_i. */
1413 : 23 : c = &idltest_link2_col_i;
1414 : 23 : c->name = "i";
1415 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_INTEGER);
1416 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
1417 : 23 : c->type.n_min = 1;
1418 : 23 : c->type.n_max = 1;
1419 : 23 : c->mutable = true;
1420 : 23 : c->parse = idltest_link2_parse_i;
1421 : 23 : c->unparse = idltest_link2_unparse_i;
1422 : :
1423 : : /* Initialize idltest_link2_col_l1. */
1424 : 23 : c = &idltest_link2_col_l1;
1425 : 23 : c->name = "l1";
1426 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_UUID);
1427 : 23 : c->type.key.u.uuid.refTableName = "link1";
1428 : 23 : c->type.key.u.uuid.refType = OVSDB_REF_STRONG;
1429 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
1430 : 23 : c->type.n_min = 0;
1431 : 23 : c->type.n_max = 1;
1432 : 23 : c->mutable = true;
1433 : 23 : c->parse = idltest_link2_parse_l1;
1434 : 23 : c->unparse = idltest_link2_unparse_l1;
1435 : 23 : }
1436 : :
1437 : : /* simple table. */
1438 : :
1439 : : static void
1440 : 64 : idltest_simple_parse_b(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1441 : : {
1442 : 64 : struct idltest_simple *row = idltest_simple_cast(row_);
1443 : :
1444 [ - + ]: 64 : ovs_assert(inited);
1445 [ + - ]: 64 : if (datum->n >= 1) {
1446 : 64 : row->b = datum->keys[0].boolean;
1447 : : } else {
1448 : 0 : row->b = false;
1449 : : }
1450 : 64 : }
1451 : :
1452 : : static void
1453 : 60 : idltest_simple_parse_ba(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1454 : : {
1455 : 60 : struct idltest_simple *row = idltest_simple_cast(row_);
1456 : 60 : size_t n = MIN(1, datum->n);
1457 : : size_t i;
1458 : :
1459 [ - + ]: 60 : ovs_assert(inited);
1460 : 60 : row->ba = NULL;
1461 : 60 : row->n_ba = 0;
1462 [ + + ]: 77 : for (i = 0; i < n; i++) {
1463 [ + - ]: 17 : if (!row->n_ba) {
1464 : 17 : row->ba = xmalloc(n * sizeof_bool);
1465 : : }
1466 : 17 : row->ba[row->n_ba] = datum->keys[i].boolean;
1467 : 17 : row->n_ba++;
1468 : : }
1469 : 60 : }
1470 : :
1471 : : static void
1472 : 61 : idltest_simple_parse_i(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1473 : : {
1474 : 61 : struct idltest_simple *row = idltest_simple_cast(row_);
1475 : :
1476 [ - + ]: 61 : ovs_assert(inited);
1477 [ + - ]: 61 : if (datum->n >= 1) {
1478 : 61 : row->i = datum->keys[0].integer;
1479 : : } else {
1480 : 0 : row->i = 0;
1481 : : }
1482 : 61 : }
1483 : :
1484 : : static void
1485 : 60 : idltest_simple_parse_ia(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1486 : : {
1487 : 60 : struct idltest_simple *row = idltest_simple_cast(row_);
1488 : : size_t i;
1489 : :
1490 [ - + ]: 60 : ovs_assert(inited);
1491 : 60 : row->ia = NULL;
1492 : 60 : row->n_ia = 0;
1493 [ + + ]: 99 : for (i = 0; i < datum->n; i++) {
1494 [ + + ]: 39 : if (!row->n_ia) {
1495 : 17 : row->ia = xmalloc(datum->n * sizeof *row->ia);
1496 : : }
1497 : 39 : row->ia[row->n_ia] = datum->keys[i].integer;
1498 : 39 : row->n_ia++;
1499 : : }
1500 : 60 : }
1501 : :
1502 : : static void
1503 : 66 : idltest_simple_parse_r(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1504 : : {
1505 : 66 : struct idltest_simple *row = idltest_simple_cast(row_);
1506 : :
1507 [ - + ]: 66 : ovs_assert(inited);
1508 [ + - ]: 66 : if (datum->n >= 1) {
1509 : 66 : row->r = datum->keys[0].real;
1510 : : } else {
1511 : 0 : row->r = 0.0;
1512 : : }
1513 : 66 : }
1514 : :
1515 : : static void
1516 : 60 : idltest_simple_parse_ra(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1517 : : {
1518 : 60 : struct idltest_simple *row = idltest_simple_cast(row_);
1519 : : size_t i;
1520 : :
1521 [ - + ]: 60 : ovs_assert(inited);
1522 : 60 : row->ra = NULL;
1523 : 60 : row->n_ra = 0;
1524 [ + + ]: 77 : for (i = 0; i < datum->n; i++) {
1525 [ + - ]: 17 : if (!row->n_ra) {
1526 : 17 : row->ra = xmalloc(datum->n * sizeof *row->ra);
1527 : : }
1528 : 17 : row->ra[row->n_ra] = datum->keys[i].real;
1529 : 17 : row->n_ra++;
1530 : : }
1531 : 60 : }
1532 : :
1533 : : static void
1534 : 60 : idltest_simple_parse_s(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1535 : : {
1536 : 60 : struct idltest_simple *row = idltest_simple_cast(row_);
1537 : :
1538 [ - + ]: 60 : ovs_assert(inited);
1539 [ + - ]: 60 : if (datum->n >= 1) {
1540 : 60 : row->s = datum->keys[0].string;
1541 : : } else {
1542 : 0 : row->s = "";
1543 : : }
1544 : 60 : }
1545 : :
1546 : : static void
1547 : 60 : idltest_simple_parse_sa(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1548 : : {
1549 : 60 : struct idltest_simple *row = idltest_simple_cast(row_);
1550 : : size_t i;
1551 : :
1552 [ - + ]: 60 : ovs_assert(inited);
1553 : 60 : row->sa = NULL;
1554 : 60 : row->n_sa = 0;
1555 [ + + ]: 82 : for (i = 0; i < datum->n; i++) {
1556 [ + + ]: 22 : if (!row->n_sa) {
1557 : 11 : row->sa = xmalloc(datum->n * sizeof *row->sa);
1558 : : }
1559 : 22 : row->sa[row->n_sa] = datum->keys[i].string;
1560 : 22 : row->n_sa++;
1561 : : }
1562 : 60 : }
1563 : :
1564 : : static void
1565 : 60 : idltest_simple_parse_u(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1566 : : {
1567 : 60 : struct idltest_simple *row = idltest_simple_cast(row_);
1568 : :
1569 [ - + ]: 60 : ovs_assert(inited);
1570 [ + - ]: 60 : if (datum->n >= 1) {
1571 : 60 : row->u = datum->keys[0].uuid;
1572 : : } else {
1573 : 0 : uuid_zero(&row->u);
1574 : : }
1575 : 60 : }
1576 : :
1577 : : static void
1578 : 60 : idltest_simple_parse_ua(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
1579 : : {
1580 : 60 : struct idltest_simple *row = idltest_simple_cast(row_);
1581 : : size_t i;
1582 : :
1583 [ - + ]: 60 : ovs_assert(inited);
1584 : 60 : row->ua = NULL;
1585 : 60 : row->n_ua = 0;
1586 [ + + ]: 82 : for (i = 0; i < datum->n; i++) {
1587 [ + + ]: 22 : if (!row->n_ua) {
1588 : 11 : row->ua = xmalloc(datum->n * sizeof *row->ua);
1589 : : }
1590 : 22 : row->ua[row->n_ua] = datum->keys[i].uuid;
1591 : 22 : row->n_ua++;
1592 : : }
1593 : 60 : }
1594 : :
1595 : : static void
1596 : 65 : idltest_simple_unparse_b(struct ovsdb_idl_row *row OVS_UNUSED)
1597 : : {
1598 : : /* Nothing to do. */
1599 : 65 : }
1600 : :
1601 : : static void
1602 : 61 : idltest_simple_unparse_ba(struct ovsdb_idl_row *row_)
1603 : : {
1604 : 61 : struct idltest_simple *row = idltest_simple_cast(row_);
1605 : :
1606 [ - + ]: 61 : ovs_assert(inited);
1607 : 61 : free(row->ba);
1608 : 61 : }
1609 : :
1610 : : static void
1611 : 62 : idltest_simple_unparse_i(struct ovsdb_idl_row *row OVS_UNUSED)
1612 : : {
1613 : : /* Nothing to do. */
1614 : 62 : }
1615 : :
1616 : : static void
1617 : 61 : idltest_simple_unparse_ia(struct ovsdb_idl_row *row_)
1618 : : {
1619 : 61 : struct idltest_simple *row = idltest_simple_cast(row_);
1620 : :
1621 [ - + ]: 61 : ovs_assert(inited);
1622 : 61 : free(row->ia);
1623 : 61 : }
1624 : :
1625 : : static void
1626 : 67 : idltest_simple_unparse_r(struct ovsdb_idl_row *row OVS_UNUSED)
1627 : : {
1628 : : /* Nothing to do. */
1629 : 67 : }
1630 : :
1631 : : static void
1632 : 61 : idltest_simple_unparse_ra(struct ovsdb_idl_row *row_)
1633 : : {
1634 : 61 : struct idltest_simple *row = idltest_simple_cast(row_);
1635 : :
1636 [ - + ]: 61 : ovs_assert(inited);
1637 : 61 : free(row->ra);
1638 : 61 : }
1639 : :
1640 : : static void
1641 : 61 : idltest_simple_unparse_s(struct ovsdb_idl_row *row OVS_UNUSED)
1642 : : {
1643 : : /* Nothing to do. */
1644 : 61 : }
1645 : :
1646 : : static void
1647 : 61 : idltest_simple_unparse_sa(struct ovsdb_idl_row *row_)
1648 : : {
1649 : 61 : struct idltest_simple *row = idltest_simple_cast(row_);
1650 : :
1651 [ - + ]: 61 : ovs_assert(inited);
1652 : 61 : free(row->sa);
1653 : 61 : }
1654 : :
1655 : : static void
1656 : 61 : idltest_simple_unparse_u(struct ovsdb_idl_row *row OVS_UNUSED)
1657 : : {
1658 : : /* Nothing to do. */
1659 : 61 : }
1660 : :
1661 : : static void
1662 : 61 : idltest_simple_unparse_ua(struct ovsdb_idl_row *row_)
1663 : : {
1664 : 61 : struct idltest_simple *row = idltest_simple_cast(row_);
1665 : :
1666 [ - + ]: 61 : ovs_assert(inited);
1667 : 61 : free(row->ua);
1668 : 61 : }
1669 : :
1670 : : static void
1671 : 31 : idltest_simple_init__(struct ovsdb_idl_row *row)
1672 : : {
1673 : 31 : idltest_simple_init(idltest_simple_cast(row));
1674 : 31 : }
1675 : :
1676 : : /* Clears the contents of 'row' in table "simple". */
1677 : : void
1678 : 31 : idltest_simple_init(struct idltest_simple *row)
1679 : : {
1680 : 31 : memset(row, 0, sizeof *row);
1681 : 31 : }
1682 : :
1683 : : /* Searches table "simple" in 'idl' for a row with UUID 'uuid'. Returns
1684 : : * a pointer to the row if there is one, otherwise a null pointer. */
1685 : : const struct idltest_simple *
1686 : 0 : idltest_simple_get_for_uuid(const struct ovsdb_idl *idl, const struct uuid *uuid)
1687 : : {
1688 : 0 : return idltest_simple_cast(ovsdb_idl_get_row_for_uuid(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE], uuid));
1689 : : }
1690 : :
1691 : : /* Returns a row in table "simple" in 'idl', or a null pointer if that
1692 : : * table is empty.
1693 : : *
1694 : : * Database tables are internally maintained as hash tables, so adding or
1695 : : * removing rows while traversing the same table can cause some rows to be
1696 : : * visited twice or not at apply. */
1697 : : const struct idltest_simple *
1698 : 79 : idltest_simple_first(const struct ovsdb_idl *idl)
1699 : : {
1700 : 79 : return idltest_simple_cast(ovsdb_idl_first_row(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE]));
1701 : : }
1702 : :
1703 : : /* Returns a row following 'row' within its table, or a null pointer if 'row'
1704 : : * is the last row in its table. */
1705 : : const struct idltest_simple *
1706 : 59 : idltest_simple_next(const struct idltest_simple *row)
1707 : : {
1708 : 59 : return idltest_simple_cast(ovsdb_idl_next_row(&row->header_));
1709 : : }
1710 : :
1711 : 0 : unsigned int idltest_simple_get_seqno(const struct ovsdb_idl *idl)
1712 : : {
1713 : 0 : return ovsdb_idl_table_get_seqno(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE]);
1714 : : }
1715 : :
1716 : 9 : unsigned int idltest_simple_row_get_seqno(const struct idltest_simple *row, enum ovsdb_idl_change change)
1717 : : {
1718 : 9 : return ovsdb_idl_row_get_seqno(&row->header_, change);
1719 : : }
1720 : :
1721 : : const struct idltest_simple *
1722 : 8 : idltest_simple_track_get_first(const struct ovsdb_idl *idl)
1723 : : {
1724 : 8 : return idltest_simple_cast(ovsdb_idl_track_get_first(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE]));
1725 : : }
1726 : :
1727 : : const struct idltest_simple
1728 : 9 : *idltest_simple_track_get_next(const struct idltest_simple *row)
1729 : : {
1730 : 9 : return idltest_simple_cast(ovsdb_idl_track_get_next(&row->header_));
1731 : : }
1732 : :
1733 : :
1734 : : /* Deletes 'row' from table "simple". 'row' may be freed, so it must not be
1735 : : * accessed afterward.
1736 : : *
1737 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1738 : : void
1739 : 1 : idltest_simple_delete(const struct idltest_simple *row)
1740 : : {
1741 : 1 : ovsdb_idl_txn_delete(&row->header_);
1742 : 1 : }
1743 : :
1744 : : /* Inserts and returns a new row in the table "simple" in the database
1745 : : * with open transaction 'txn'.
1746 : : *
1747 : : * The new row is assigned a randomly generated provisional UUID.
1748 : : * ovsdb-server will assign a different UUID when 'txn' is committed,
1749 : : * but the IDL will replace any uses of the provisional UUID in the
1750 : : * data to be to be committed by the UUID assigned by ovsdb-server. */
1751 : : struct idltest_simple *
1752 : 1 : idltest_simple_insert(struct ovsdb_idl_txn *txn)
1753 : : {
1754 : 1 : return idltest_simple_cast(ovsdb_idl_txn_insert(txn, &idltest_table_classes[IDLTEST_TABLE_SIMPLE], NULL));
1755 : : }
1756 : :
1757 : : bool
1758 : 600 : idltest_simple_is_updated(const struct idltest_simple *row, enum idltest_simple_column_id column)
1759 : : {
1760 : 600 : return ovsdb_idl_track_is_updated(&row->header_, &idltest_simple_columns[column]);
1761 : : }
1762 : :
1763 : : /* Causes the original contents of column "b" in 'row' to be
1764 : : * verified as a prerequisite to completing the transaction. That is, if
1765 : : * "b" in 'row' changed (or if 'row' was deleted) between the
1766 : : * time that the IDL originally read its contents and the time that the
1767 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1768 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1769 : : * change has already been received).
1770 : : *
1771 : : * The intention is that, to ensure that no transaction commits based on dirty
1772 : : * reads, an application should call this function any time "b" is
1773 : : * read as part of a read-modify-write operation.
1774 : : *
1775 : : * In some cases this function reduces to a no-op, because the current value
1776 : : * of "b" is already known:
1777 : : *
1778 : : * - If 'row' is a row created by the current transaction (returned by
1779 : : * idltest_simple_insert()).
1780 : : *
1781 : : * - If "b" has already been modified (with
1782 : : * idltest_simple_set_b()) within the current transaction.
1783 : : *
1784 : : * Because of the latter property, always call this function *before*
1785 : : * idltest_simple_set_b() for a given read-modify-write.
1786 : : *
1787 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1788 : : void
1789 : 2 : idltest_simple_verify_b(const struct idltest_simple *row)
1790 : : {
1791 [ - + ]: 2 : ovs_assert(inited);
1792 : 2 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_B]);
1793 : 2 : }
1794 : :
1795 : : /* Causes the original contents of column "ba" in 'row' to be
1796 : : * verified as a prerequisite to completing the transaction. That is, if
1797 : : * "ba" in 'row' changed (or if 'row' was deleted) between the
1798 : : * time that the IDL originally read its contents and the time that the
1799 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1800 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1801 : : * change has already been received).
1802 : : *
1803 : : * The intention is that, to ensure that no transaction commits based on dirty
1804 : : * reads, an application should call this function any time "ba" is
1805 : : * read as part of a read-modify-write operation.
1806 : : *
1807 : : * In some cases this function reduces to a no-op, because the current value
1808 : : * of "ba" is already known:
1809 : : *
1810 : : * - If 'row' is a row created by the current transaction (returned by
1811 : : * idltest_simple_insert()).
1812 : : *
1813 : : * - If "ba" has already been modified (with
1814 : : * idltest_simple_set_ba()) within the current transaction.
1815 : : *
1816 : : * Because of the latter property, always call this function *before*
1817 : : * idltest_simple_set_ba() for a given read-modify-write.
1818 : : *
1819 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1820 : : void
1821 : 0 : idltest_simple_verify_ba(const struct idltest_simple *row)
1822 : : {
1823 [ # # ]: 0 : ovs_assert(inited);
1824 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_BA]);
1825 : 0 : }
1826 : :
1827 : : /* Causes the original contents of column "i" in 'row' to be
1828 : : * verified as a prerequisite to completing the transaction. That is, if
1829 : : * "i" in 'row' changed (or if 'row' was deleted) between the
1830 : : * time that the IDL originally read its contents and the time that the
1831 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1832 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1833 : : * change has already been received).
1834 : : *
1835 : : * The intention is that, to ensure that no transaction commits based on dirty
1836 : : * reads, an application should call this function any time "i" is
1837 : : * read as part of a read-modify-write operation.
1838 : : *
1839 : : * In some cases this function reduces to a no-op, because the current value
1840 : : * of "i" is already known:
1841 : : *
1842 : : * - If 'row' is a row created by the current transaction (returned by
1843 : : * idltest_simple_insert()).
1844 : : *
1845 : : * - If "i" has already been modified (with
1846 : : * idltest_simple_set_i()) within the current transaction.
1847 : : *
1848 : : * Because of the latter property, always call this function *before*
1849 : : * idltest_simple_set_i() for a given read-modify-write.
1850 : : *
1851 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1852 : : void
1853 : 1 : idltest_simple_verify_i(const struct idltest_simple *row)
1854 : : {
1855 [ - + ]: 1 : ovs_assert(inited);
1856 : 1 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_I]);
1857 : 1 : }
1858 : :
1859 : : /* Causes the original contents of column "ia" in 'row' to be
1860 : : * verified as a prerequisite to completing the transaction. That is, if
1861 : : * "ia" in 'row' changed (or if 'row' was deleted) between the
1862 : : * time that the IDL originally read its contents and the time that the
1863 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1864 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1865 : : * change has already been received).
1866 : : *
1867 : : * The intention is that, to ensure that no transaction commits based on dirty
1868 : : * reads, an application should call this function any time "ia" is
1869 : : * read as part of a read-modify-write operation.
1870 : : *
1871 : : * In some cases this function reduces to a no-op, because the current value
1872 : : * of "ia" is already known:
1873 : : *
1874 : : * - If 'row' is a row created by the current transaction (returned by
1875 : : * idltest_simple_insert()).
1876 : : *
1877 : : * - If "ia" has already been modified (with
1878 : : * idltest_simple_set_ia()) within the current transaction.
1879 : : *
1880 : : * Because of the latter property, always call this function *before*
1881 : : * idltest_simple_set_ia() for a given read-modify-write.
1882 : : *
1883 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1884 : : void
1885 : 0 : idltest_simple_verify_ia(const struct idltest_simple *row)
1886 : : {
1887 [ # # ]: 0 : ovs_assert(inited);
1888 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_IA]);
1889 : 0 : }
1890 : :
1891 : : /* Causes the original contents of column "r" in 'row' to be
1892 : : * verified as a prerequisite to completing the transaction. That is, if
1893 : : * "r" in 'row' changed (or if 'row' was deleted) between the
1894 : : * time that the IDL originally read its contents and the time that the
1895 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1896 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1897 : : * change has already been received).
1898 : : *
1899 : : * The intention is that, to ensure that no transaction commits based on dirty
1900 : : * reads, an application should call this function any time "r" is
1901 : : * read as part of a read-modify-write operation.
1902 : : *
1903 : : * In some cases this function reduces to a no-op, because the current value
1904 : : * of "r" is already known:
1905 : : *
1906 : : * - If 'row' is a row created by the current transaction (returned by
1907 : : * idltest_simple_insert()).
1908 : : *
1909 : : * - If "r" has already been modified (with
1910 : : * idltest_simple_set_r()) within the current transaction.
1911 : : *
1912 : : * Because of the latter property, always call this function *before*
1913 : : * idltest_simple_set_r() for a given read-modify-write.
1914 : : *
1915 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1916 : : void
1917 : 3 : idltest_simple_verify_r(const struct idltest_simple *row)
1918 : : {
1919 [ - + ]: 3 : ovs_assert(inited);
1920 : 3 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_R]);
1921 : 3 : }
1922 : :
1923 : : /* Causes the original contents of column "ra" in 'row' to be
1924 : : * verified as a prerequisite to completing the transaction. That is, if
1925 : : * "ra" in 'row' changed (or if 'row' was deleted) between the
1926 : : * time that the IDL originally read its contents and the time that the
1927 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1928 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1929 : : * change has already been received).
1930 : : *
1931 : : * The intention is that, to ensure that no transaction commits based on dirty
1932 : : * reads, an application should call this function any time "ra" is
1933 : : * read as part of a read-modify-write operation.
1934 : : *
1935 : : * In some cases this function reduces to a no-op, because the current value
1936 : : * of "ra" is already known:
1937 : : *
1938 : : * - If 'row' is a row created by the current transaction (returned by
1939 : : * idltest_simple_insert()).
1940 : : *
1941 : : * - If "ra" has already been modified (with
1942 : : * idltest_simple_set_ra()) within the current transaction.
1943 : : *
1944 : : * Because of the latter property, always call this function *before*
1945 : : * idltest_simple_set_ra() for a given read-modify-write.
1946 : : *
1947 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1948 : : void
1949 : 0 : idltest_simple_verify_ra(const struct idltest_simple *row)
1950 : : {
1951 [ # # ]: 0 : ovs_assert(inited);
1952 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_RA]);
1953 : 0 : }
1954 : :
1955 : : /* Causes the original contents of column "s" in 'row' to be
1956 : : * verified as a prerequisite to completing the transaction. That is, if
1957 : : * "s" in 'row' changed (or if 'row' was deleted) between the
1958 : : * time that the IDL originally read its contents and the time that the
1959 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1960 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1961 : : * change has already been received).
1962 : : *
1963 : : * The intention is that, to ensure that no transaction commits based on dirty
1964 : : * reads, an application should call this function any time "s" is
1965 : : * read as part of a read-modify-write operation.
1966 : : *
1967 : : * In some cases this function reduces to a no-op, because the current value
1968 : : * of "s" is already known:
1969 : : *
1970 : : * - If 'row' is a row created by the current transaction (returned by
1971 : : * idltest_simple_insert()).
1972 : : *
1973 : : * - If "s" has already been modified (with
1974 : : * idltest_simple_set_s()) within the current transaction.
1975 : : *
1976 : : * Because of the latter property, always call this function *before*
1977 : : * idltest_simple_set_s() for a given read-modify-write.
1978 : : *
1979 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
1980 : : void
1981 : 0 : idltest_simple_verify_s(const struct idltest_simple *row)
1982 : : {
1983 [ # # ]: 0 : ovs_assert(inited);
1984 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_S]);
1985 : 0 : }
1986 : :
1987 : : /* Causes the original contents of column "sa" in 'row' to be
1988 : : * verified as a prerequisite to completing the transaction. That is, if
1989 : : * "sa" in 'row' changed (or if 'row' was deleted) between the
1990 : : * time that the IDL originally read its contents and the time that the
1991 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
1992 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
1993 : : * change has already been received).
1994 : : *
1995 : : * The intention is that, to ensure that no transaction commits based on dirty
1996 : : * reads, an application should call this function any time "sa" is
1997 : : * read as part of a read-modify-write operation.
1998 : : *
1999 : : * In some cases this function reduces to a no-op, because the current value
2000 : : * of "sa" is already known:
2001 : : *
2002 : : * - If 'row' is a row created by the current transaction (returned by
2003 : : * idltest_simple_insert()).
2004 : : *
2005 : : * - If "sa" has already been modified (with
2006 : : * idltest_simple_set_sa()) within the current transaction.
2007 : : *
2008 : : * Because of the latter property, always call this function *before*
2009 : : * idltest_simple_set_sa() for a given read-modify-write.
2010 : : *
2011 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
2012 : : void
2013 : 0 : idltest_simple_verify_sa(const struct idltest_simple *row)
2014 : : {
2015 [ # # ]: 0 : ovs_assert(inited);
2016 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_SA]);
2017 : 0 : }
2018 : :
2019 : : /* Causes the original contents of column "u" in 'row' to be
2020 : : * verified as a prerequisite to completing the transaction. That is, if
2021 : : * "u" in 'row' changed (or if 'row' was deleted) between the
2022 : : * time that the IDL originally read its contents and the time that the
2023 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
2024 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
2025 : : * change has already been received).
2026 : : *
2027 : : * The intention is that, to ensure that no transaction commits based on dirty
2028 : : * reads, an application should call this function any time "u" is
2029 : : * read as part of a read-modify-write operation.
2030 : : *
2031 : : * In some cases this function reduces to a no-op, because the current value
2032 : : * of "u" is already known:
2033 : : *
2034 : : * - If 'row' is a row created by the current transaction (returned by
2035 : : * idltest_simple_insert()).
2036 : : *
2037 : : * - If "u" has already been modified (with
2038 : : * idltest_simple_set_u()) within the current transaction.
2039 : : *
2040 : : * Because of the latter property, always call this function *before*
2041 : : * idltest_simple_set_u() for a given read-modify-write.
2042 : : *
2043 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
2044 : : void
2045 : 0 : idltest_simple_verify_u(const struct idltest_simple *row)
2046 : : {
2047 [ # # ]: 0 : ovs_assert(inited);
2048 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_U]);
2049 : 0 : }
2050 : :
2051 : : /* Causes the original contents of column "ua" in 'row' to be
2052 : : * verified as a prerequisite to completing the transaction. That is, if
2053 : : * "ua" in 'row' changed (or if 'row' was deleted) between the
2054 : : * time that the IDL originally read its contents and the time that the
2055 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
2056 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
2057 : : * change has already been received).
2058 : : *
2059 : : * The intention is that, to ensure that no transaction commits based on dirty
2060 : : * reads, an application should call this function any time "ua" is
2061 : : * read as part of a read-modify-write operation.
2062 : : *
2063 : : * In some cases this function reduces to a no-op, because the current value
2064 : : * of "ua" is already known:
2065 : : *
2066 : : * - If 'row' is a row created by the current transaction (returned by
2067 : : * idltest_simple_insert()).
2068 : : *
2069 : : * - If "ua" has already been modified (with
2070 : : * idltest_simple_set_ua()) within the current transaction.
2071 : : *
2072 : : * Because of the latter property, always call this function *before*
2073 : : * idltest_simple_set_ua() for a given read-modify-write.
2074 : : *
2075 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
2076 : : void
2077 : 0 : idltest_simple_verify_ua(const struct idltest_simple *row)
2078 : : {
2079 [ # # ]: 0 : ovs_assert(inited);
2080 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_UA]);
2081 : 0 : }
2082 : :
2083 : : /* Returns the "b" column's value from the "simple" table in 'row'
2084 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2085 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2086 : : * for a given key than implementing the same operation on the "cooked"
2087 : : * form in 'row'.
2088 : : *
2089 : : * 'key_type' must be OVSDB_TYPE_BOOLEAN.
2090 : : * (This helps to avoid silent bugs if someone changes b's
2091 : : * type without updating the caller.)
2092 : : *
2093 : : * The caller must not modify or free the returned value.
2094 : : *
2095 : : * Various kinds of changes can invalidate the returned value: modifying
2096 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2097 : : * If the returned value is needed for a long time, it is best to make a copy
2098 : : * of it with ovsdb_datum_clone().
2099 : : *
2100 : : * This function is rarely useful, since it is easier to access the value
2101 : : * directly through the "b" member in idltest_simple. */
2102 : : const struct ovsdb_datum *
2103 : 0 : idltest_simple_get_b(const struct idltest_simple *row,
2104 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2105 : : {
2106 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_BOOLEAN);
2107 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_b);
2108 : : }
2109 : :
2110 : : /* Returns the "ba" column's value from the "simple" table in 'row'
2111 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2112 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2113 : : * for a given key than implementing the same operation on the "cooked"
2114 : : * form in 'row'.
2115 : : *
2116 : : * 'key_type' must be OVSDB_TYPE_BOOLEAN.
2117 : : * (This helps to avoid silent bugs if someone changes ba's
2118 : : * type without updating the caller.)
2119 : : *
2120 : : * The caller must not modify or free the returned value.
2121 : : *
2122 : : * Various kinds of changes can invalidate the returned value: modifying
2123 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2124 : : * If the returned value is needed for a long time, it is best to make a copy
2125 : : * of it with ovsdb_datum_clone().
2126 : : *
2127 : : * This function is rarely useful, since it is easier to access the value
2128 : : * directly through the "ba" member in idltest_simple. */
2129 : : const struct ovsdb_datum *
2130 : 0 : idltest_simple_get_ba(const struct idltest_simple *row,
2131 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2132 : : {
2133 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_BOOLEAN);
2134 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_ba);
2135 : : }
2136 : :
2137 : : /* Returns the "i" column's value from the "simple" table in 'row'
2138 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2139 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2140 : : * for a given key than implementing the same operation on the "cooked"
2141 : : * form in 'row'.
2142 : : *
2143 : : * 'key_type' must be OVSDB_TYPE_INTEGER.
2144 : : * (This helps to avoid silent bugs if someone changes i's
2145 : : * type without updating the caller.)
2146 : : *
2147 : : * The caller must not modify or free the returned value.
2148 : : *
2149 : : * Various kinds of changes can invalidate the returned value: modifying
2150 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2151 : : * If the returned value is needed for a long time, it is best to make a copy
2152 : : * of it with ovsdb_datum_clone().
2153 : : *
2154 : : * This function is rarely useful, since it is easier to access the value
2155 : : * directly through the "i" member in idltest_simple. */
2156 : : const struct ovsdb_datum *
2157 : 0 : idltest_simple_get_i(const struct idltest_simple *row,
2158 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2159 : : {
2160 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_INTEGER);
2161 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_i);
2162 : : }
2163 : :
2164 : : /* Returns the "ia" column's value from the "simple" table in 'row'
2165 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2166 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2167 : : * for a given key than implementing the same operation on the "cooked"
2168 : : * form in 'row'.
2169 : : *
2170 : : * 'key_type' must be OVSDB_TYPE_INTEGER.
2171 : : * (This helps to avoid silent bugs if someone changes ia's
2172 : : * type without updating the caller.)
2173 : : *
2174 : : * The caller must not modify or free the returned value.
2175 : : *
2176 : : * Various kinds of changes can invalidate the returned value: modifying
2177 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2178 : : * If the returned value is needed for a long time, it is best to make a copy
2179 : : * of it with ovsdb_datum_clone().
2180 : : *
2181 : : * This function is rarely useful, since it is easier to access the value
2182 : : * directly through the "ia" member in idltest_simple. */
2183 : : const struct ovsdb_datum *
2184 : 0 : idltest_simple_get_ia(const struct idltest_simple *row,
2185 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2186 : : {
2187 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_INTEGER);
2188 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_ia);
2189 : : }
2190 : :
2191 : : /* Returns the "r" column's value from the "simple" table in 'row'
2192 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2193 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2194 : : * for a given key than implementing the same operation on the "cooked"
2195 : : * form in 'row'.
2196 : : *
2197 : : * 'key_type' must be OVSDB_TYPE_REAL.
2198 : : * (This helps to avoid silent bugs if someone changes r's
2199 : : * type without updating the caller.)
2200 : : *
2201 : : * The caller must not modify or free the returned value.
2202 : : *
2203 : : * Various kinds of changes can invalidate the returned value: modifying
2204 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2205 : : * If the returned value is needed for a long time, it is best to make a copy
2206 : : * of it with ovsdb_datum_clone().
2207 : : *
2208 : : * This function is rarely useful, since it is easier to access the value
2209 : : * directly through the "r" member in idltest_simple. */
2210 : : const struct ovsdb_datum *
2211 : 0 : idltest_simple_get_r(const struct idltest_simple *row,
2212 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2213 : : {
2214 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_REAL);
2215 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_r);
2216 : : }
2217 : :
2218 : : /* Returns the "ra" column's value from the "simple" table in 'row'
2219 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2220 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2221 : : * for a given key than implementing the same operation on the "cooked"
2222 : : * form in 'row'.
2223 : : *
2224 : : * 'key_type' must be OVSDB_TYPE_REAL.
2225 : : * (This helps to avoid silent bugs if someone changes ra's
2226 : : * type without updating the caller.)
2227 : : *
2228 : : * The caller must not modify or free the returned value.
2229 : : *
2230 : : * Various kinds of changes can invalidate the returned value: modifying
2231 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2232 : : * If the returned value is needed for a long time, it is best to make a copy
2233 : : * of it with ovsdb_datum_clone().
2234 : : *
2235 : : * This function is rarely useful, since it is easier to access the value
2236 : : * directly through the "ra" member in idltest_simple. */
2237 : : const struct ovsdb_datum *
2238 : 0 : idltest_simple_get_ra(const struct idltest_simple *row,
2239 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2240 : : {
2241 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_REAL);
2242 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_ra);
2243 : : }
2244 : :
2245 : : /* Returns the "s" column's value from the "simple" table in 'row'
2246 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2247 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2248 : : * for a given key than implementing the same operation on the "cooked"
2249 : : * form in 'row'.
2250 : : *
2251 : : * 'key_type' must be OVSDB_TYPE_STRING.
2252 : : * (This helps to avoid silent bugs if someone changes s's
2253 : : * type without updating the caller.)
2254 : : *
2255 : : * The caller must not modify or free the returned value.
2256 : : *
2257 : : * Various kinds of changes can invalidate the returned value: modifying
2258 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2259 : : * If the returned value is needed for a long time, it is best to make a copy
2260 : : * of it with ovsdb_datum_clone().
2261 : : *
2262 : : * This function is rarely useful, since it is easier to access the value
2263 : : * directly through the "s" member in idltest_simple. */
2264 : : const struct ovsdb_datum *
2265 : 0 : idltest_simple_get_s(const struct idltest_simple *row,
2266 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2267 : : {
2268 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_STRING);
2269 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_s);
2270 : : }
2271 : :
2272 : : /* Returns the "sa" column's value from the "simple" table in 'row'
2273 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2274 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2275 : : * for a given key than implementing the same operation on the "cooked"
2276 : : * form in 'row'.
2277 : : *
2278 : : * 'key_type' must be OVSDB_TYPE_STRING.
2279 : : * (This helps to avoid silent bugs if someone changes sa's
2280 : : * type without updating the caller.)
2281 : : *
2282 : : * The caller must not modify or free the returned value.
2283 : : *
2284 : : * Various kinds of changes can invalidate the returned value: modifying
2285 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2286 : : * If the returned value is needed for a long time, it is best to make a copy
2287 : : * of it with ovsdb_datum_clone().
2288 : : *
2289 : : * This function is rarely useful, since it is easier to access the value
2290 : : * directly through the "sa" member in idltest_simple. */
2291 : : const struct ovsdb_datum *
2292 : 0 : idltest_simple_get_sa(const struct idltest_simple *row,
2293 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2294 : : {
2295 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_STRING);
2296 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_sa);
2297 : : }
2298 : :
2299 : : /* Returns the "u" column's value from the "simple" table in 'row'
2300 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2301 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2302 : : * for a given key than implementing the same operation on the "cooked"
2303 : : * form in 'row'.
2304 : : *
2305 : : * 'key_type' must be OVSDB_TYPE_UUID.
2306 : : * (This helps to avoid silent bugs if someone changes u's
2307 : : * type without updating the caller.)
2308 : : *
2309 : : * The caller must not modify or free the returned value.
2310 : : *
2311 : : * Various kinds of changes can invalidate the returned value: modifying
2312 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2313 : : * If the returned value is needed for a long time, it is best to make a copy
2314 : : * of it with ovsdb_datum_clone().
2315 : : *
2316 : : * This function is rarely useful, since it is easier to access the value
2317 : : * directly through the "u" member in idltest_simple. */
2318 : : const struct ovsdb_datum *
2319 : 0 : idltest_simple_get_u(const struct idltest_simple *row,
2320 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2321 : : {
2322 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_UUID);
2323 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_u);
2324 : : }
2325 : :
2326 : : /* Returns the "ua" column's value from the "simple" table in 'row'
2327 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
2328 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
2329 : : * for a given key than implementing the same operation on the "cooked"
2330 : : * form in 'row'.
2331 : : *
2332 : : * 'key_type' must be OVSDB_TYPE_UUID.
2333 : : * (This helps to avoid silent bugs if someone changes ua's
2334 : : * type without updating the caller.)
2335 : : *
2336 : : * The caller must not modify or free the returned value.
2337 : : *
2338 : : * Various kinds of changes can invalidate the returned value: modifying
2339 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
2340 : : * If the returned value is needed for a long time, it is best to make a copy
2341 : : * of it with ovsdb_datum_clone().
2342 : : *
2343 : : * This function is rarely useful, since it is easier to access the value
2344 : : * directly through the "ua" member in idltest_simple. */
2345 : : const struct ovsdb_datum *
2346 : 0 : idltest_simple_get_ua(const struct idltest_simple *row,
2347 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
2348 : : {
2349 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_UUID);
2350 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple_col_ua);
2351 : : }
2352 : :
2353 : : /* Sets the "b" column from the "simple" table in 'row' to
2354 : : * 'b'.
2355 : : *
2356 : : * The caller retains ownership of the arguments. */
2357 : : void
2358 : 4 : idltest_simple_set_b(const struct idltest_simple *row, bool b)
2359 : : {
2360 : : struct ovsdb_datum datum;
2361 : : union ovsdb_atom key;
2362 : :
2363 [ - + ]: 4 : ovs_assert(inited);
2364 : 4 : datum.n = 1;
2365 : 4 : datum.keys = &key;
2366 : 4 : key.boolean = b;
2367 : 4 : datum.values = NULL;
2368 : 4 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_B], &datum);
2369 : 4 : }
2370 : :
2371 : : /* Sets the "ba" column from the "simple" table in 'row' to
2372 : : * the 'ba' set with 'n_ba' entries.
2373 : : *
2374 : : * 'n_ba' may be 0 or 1; if it is 0, then 'ba'
2375 : : * may be NULL.
2376 : : *
2377 : : * The caller retains ownership of the arguments. */
2378 : : void
2379 : 0 : idltest_simple_set_ba(const struct idltest_simple *row, const bool *ba, size_t n_ba)
2380 : : {
2381 : : struct ovsdb_datum datum;
2382 : : union ovsdb_atom key;
2383 : :
2384 [ # # ]: 0 : ovs_assert(inited);
2385 [ # # ]: 0 : if (n_ba) {
2386 : 0 : datum.n = 1;
2387 : 0 : datum.keys = &key;
2388 : 0 : key.boolean = *ba;
2389 : : } else {
2390 : 0 : datum.n = 0;
2391 : 0 : datum.keys = NULL;
2392 : : }
2393 : 0 : datum.values = NULL;
2394 : 0 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_BA], &datum);
2395 : 0 : }
2396 : :
2397 : : /* Sets the "i" column from the "simple" table in 'row' to
2398 : : * 'i'.
2399 : : *
2400 : : * The caller retains ownership of the arguments. */
2401 : : void
2402 : 1 : idltest_simple_set_i(const struct idltest_simple *row, int64_t i)
2403 : : {
2404 : : struct ovsdb_datum datum;
2405 : : union ovsdb_atom key;
2406 : :
2407 [ - + ]: 1 : ovs_assert(inited);
2408 : 1 : datum.n = 1;
2409 : 1 : datum.keys = &key;
2410 : 1 : key.integer = i;
2411 : 1 : datum.values = NULL;
2412 : 1 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_I], &datum);
2413 : 1 : }
2414 : :
2415 : : /* Sets the "ia" column from the "simple" table in 'row' to
2416 : : * the 'ia' set with 'n_ia' entries.
2417 : : *
2418 : : * The caller retains ownership of the arguments. */
2419 : : void
2420 : 0 : idltest_simple_set_ia(const struct idltest_simple *row, const int64_t *ia, size_t n_ia)
2421 : : {
2422 : : struct ovsdb_datum datum;
2423 : : size_t i;
2424 : :
2425 [ # # ]: 0 : ovs_assert(inited);
2426 : 0 : datum.n = n_ia;
2427 [ # # ]: 0 : datum.keys = n_ia ? xmalloc(n_ia * sizeof *datum.keys) : NULL;
2428 : 0 : datum.values = NULL;
2429 [ # # ]: 0 : for (i = 0; i < n_ia; i++) {
2430 : 0 : datum.keys[i].integer = ia[i];
2431 : : }
2432 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_INTEGER, OVSDB_TYPE_VOID);
2433 : 0 : ovsdb_idl_txn_write(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_IA], &datum);
2434 : 0 : }
2435 : :
2436 : : /* Sets the "r" column from the "simple" table in 'row' to
2437 : : * 'r'.
2438 : : *
2439 : : * The caller retains ownership of the arguments. */
2440 : : void
2441 : 6 : idltest_simple_set_r(const struct idltest_simple *row, double r)
2442 : : {
2443 : : struct ovsdb_datum datum;
2444 : : union ovsdb_atom key;
2445 : :
2446 [ - + ]: 6 : ovs_assert(inited);
2447 : 6 : datum.n = 1;
2448 : 6 : datum.keys = &key;
2449 : 6 : key.real = r;
2450 : 6 : datum.values = NULL;
2451 : 6 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_R], &datum);
2452 : 6 : }
2453 : :
2454 : : /* Sets the "ra" column from the "simple" table in 'row' to
2455 : : * the 'ra' set with 'n_ra' entries.
2456 : : *
2457 : : * The caller retains ownership of the arguments. */
2458 : : void
2459 : 0 : idltest_simple_set_ra(const struct idltest_simple *row, const double *ra, size_t n_ra)
2460 : : {
2461 : : struct ovsdb_datum datum;
2462 : : size_t i;
2463 : :
2464 [ # # ]: 0 : ovs_assert(inited);
2465 : 0 : datum.n = n_ra;
2466 [ # # ]: 0 : datum.keys = n_ra ? xmalloc(n_ra * sizeof *datum.keys) : NULL;
2467 : 0 : datum.values = NULL;
2468 [ # # ]: 0 : for (i = 0; i < n_ra; i++) {
2469 : 0 : datum.keys[i].real = ra[i];
2470 : : }
2471 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_REAL, OVSDB_TYPE_VOID);
2472 : 0 : ovsdb_idl_txn_write(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_RA], &datum);
2473 : 0 : }
2474 : :
2475 : : /* Sets the "s" column from the "simple" table in 'row' to
2476 : : * 's'.
2477 : : *
2478 : : * The caller retains ownership of the arguments. */
2479 : : void
2480 : 0 : idltest_simple_set_s(const struct idltest_simple *row, const char *s)
2481 : : {
2482 : : struct ovsdb_datum datum;
2483 : : union ovsdb_atom key;
2484 : :
2485 [ # # ]: 0 : ovs_assert(inited);
2486 : 0 : datum.n = 1;
2487 : 0 : datum.keys = &key;
2488 : 0 : key.string = CONST_CAST(char *, s);
2489 : 0 : datum.values = NULL;
2490 : 0 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_S], &datum);
2491 : 0 : }
2492 : :
2493 : : /* Sets the "sa" column from the "simple" table in 'row' to
2494 : : * the 'sa' set with 'n_sa' entries.
2495 : : *
2496 : : * The caller retains ownership of the arguments. */
2497 : : void
2498 : 0 : idltest_simple_set_sa(const struct idltest_simple *row, const char **sa, size_t n_sa)
2499 : : {
2500 : : struct ovsdb_datum datum;
2501 : : size_t i;
2502 : :
2503 [ # # ]: 0 : ovs_assert(inited);
2504 : 0 : datum.n = n_sa;
2505 [ # # ]: 0 : datum.keys = n_sa ? xmalloc(n_sa * sizeof *datum.keys) : NULL;
2506 : 0 : datum.values = NULL;
2507 [ # # ]: 0 : for (i = 0; i < n_sa; i++) {
2508 : 0 : datum.keys[i].string = xstrdup(sa[i]);
2509 : : }
2510 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_STRING, OVSDB_TYPE_VOID);
2511 : 0 : ovsdb_idl_txn_write(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_SA], &datum);
2512 : 0 : }
2513 : :
2514 : : /* Sets the "u" column from the "simple" table in 'row' to
2515 : : * 'u'.
2516 : : *
2517 : : * The caller retains ownership of the arguments. */
2518 : : void
2519 : 0 : idltest_simple_set_u(const struct idltest_simple *row, struct uuid u)
2520 : : {
2521 : : struct ovsdb_datum datum;
2522 : : union ovsdb_atom key;
2523 : :
2524 [ # # ]: 0 : ovs_assert(inited);
2525 : 0 : datum.n = 1;
2526 : 0 : datum.keys = &key;
2527 : 0 : key.uuid = u;
2528 : 0 : datum.values = NULL;
2529 : 0 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_U], &datum);
2530 : 0 : }
2531 : :
2532 : : /* Sets the "ua" column from the "simple" table in 'row' to
2533 : : * the 'ua' set with 'n_ua' entries.
2534 : : *
2535 : : * The caller retains ownership of the arguments. */
2536 : : void
2537 : 0 : idltest_simple_set_ua(const struct idltest_simple *row, const struct uuid *ua, size_t n_ua)
2538 : : {
2539 : : struct ovsdb_datum datum;
2540 : : size_t i;
2541 : :
2542 [ # # ]: 0 : ovs_assert(inited);
2543 : 0 : datum.n = n_ua;
2544 [ # # ]: 0 : datum.keys = n_ua ? xmalloc(n_ua * sizeof *datum.keys) : NULL;
2545 : 0 : datum.values = NULL;
2546 [ # # ]: 0 : for (i = 0; i < n_ua; i++) {
2547 : 0 : datum.keys[i].uuid = ua[i];
2548 : : }
2549 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
2550 : 0 : ovsdb_idl_txn_write(&row->header_, &idltest_simple_columns[IDLTEST_SIMPLE_COL_UA], &datum);
2551 : 0 : }
2552 : :
2553 : : /* Adds the value 'new_value' to the "ba" set column from the "simple" table
2554 : : * in 'row'.
2555 : : *
2556 : : */
2557 : : void
2558 : 0 : idltest_simple_update_ba_addvalue(const struct idltest_simple *row, bool new_value)
2559 : : {
2560 : : struct ovsdb_datum *datum;
2561 : :
2562 [ # # ]: 0 : ovs_assert(inited);
2563 : :
2564 : 0 : datum = xmalloc(sizeof *datum);
2565 : 0 : datum->n = 1;
2566 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2567 : 0 : datum->values = NULL;
2568 : :
2569 : 0 : datum->keys[0].boolean = new_value;
2570 : :
2571 : 0 : ovsdb_idl_txn_write_partial_set(&row->header_,
2572 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_BA],
2573 : : datum);
2574 : 0 : }
2575 : :
2576 : : /* Deletes the value 'delete_value' from the "ba" set column from the
2577 : : * "simple" table in 'row'.
2578 : : *
2579 : : */
2580 : : void
2581 : 0 : idltest_simple_update_ba_delvalue(const struct idltest_simple *row, bool delete_value)
2582 : : {
2583 : : struct ovsdb_datum *datum;
2584 : :
2585 [ # # ]: 0 : ovs_assert(inited);
2586 : :
2587 : 0 : datum = xmalloc(sizeof *datum);
2588 : 0 : datum->n = 1;
2589 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2590 : 0 : datum->values = NULL;
2591 : :
2592 : 0 : datum->keys[0].boolean = delete_value;
2593 : :
2594 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
2595 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_BA],
2596 : : datum);
2597 : 0 : }
2598 : :
2599 : : /* Adds the value 'new_value' to the "ia" set column from the "simple" table
2600 : : * in 'row'.
2601 : : *
2602 : : */
2603 : : void
2604 : 0 : idltest_simple_update_ia_addvalue(const struct idltest_simple *row, int64_t new_value)
2605 : : {
2606 : : struct ovsdb_datum *datum;
2607 : :
2608 [ # # ]: 0 : ovs_assert(inited);
2609 : :
2610 : 0 : datum = xmalloc(sizeof *datum);
2611 : 0 : datum->n = 1;
2612 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2613 : 0 : datum->values = NULL;
2614 : :
2615 : 0 : datum->keys[0].integer = new_value;
2616 : :
2617 : 0 : ovsdb_idl_txn_write_partial_set(&row->header_,
2618 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_IA],
2619 : : datum);
2620 : 0 : }
2621 : :
2622 : : /* Deletes the value 'delete_value' from the "ia" set column from the
2623 : : * "simple" table in 'row'.
2624 : : *
2625 : : */
2626 : : void
2627 : 0 : idltest_simple_update_ia_delvalue(const struct idltest_simple *row, int64_t delete_value)
2628 : : {
2629 : : struct ovsdb_datum *datum;
2630 : :
2631 [ # # ]: 0 : ovs_assert(inited);
2632 : :
2633 : 0 : datum = xmalloc(sizeof *datum);
2634 : 0 : datum->n = 1;
2635 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2636 : 0 : datum->values = NULL;
2637 : :
2638 : 0 : datum->keys[0].integer = delete_value;
2639 : :
2640 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
2641 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_IA],
2642 : : datum);
2643 : 0 : }
2644 : :
2645 : : /* Adds the value 'new_value' to the "ra" set column from the "simple" table
2646 : : * in 'row'.
2647 : : *
2648 : : */
2649 : : void
2650 : 0 : idltest_simple_update_ra_addvalue(const struct idltest_simple *row, double new_value)
2651 : : {
2652 : : struct ovsdb_datum *datum;
2653 : :
2654 [ # # ]: 0 : ovs_assert(inited);
2655 : :
2656 : 0 : datum = xmalloc(sizeof *datum);
2657 : 0 : datum->n = 1;
2658 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2659 : 0 : datum->values = NULL;
2660 : :
2661 : 0 : datum->keys[0].real = new_value;
2662 : :
2663 : 0 : ovsdb_idl_txn_write_partial_set(&row->header_,
2664 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_RA],
2665 : : datum);
2666 : 0 : }
2667 : :
2668 : : /* Deletes the value 'delete_value' from the "ra" set column from the
2669 : : * "simple" table in 'row'.
2670 : : *
2671 : : */
2672 : : void
2673 : 0 : idltest_simple_update_ra_delvalue(const struct idltest_simple *row, double delete_value)
2674 : : {
2675 : : struct ovsdb_datum *datum;
2676 : :
2677 [ # # ]: 0 : ovs_assert(inited);
2678 : :
2679 : 0 : datum = xmalloc(sizeof *datum);
2680 : 0 : datum->n = 1;
2681 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2682 : 0 : datum->values = NULL;
2683 : :
2684 : 0 : datum->keys[0].real = delete_value;
2685 : :
2686 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
2687 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_RA],
2688 : : datum);
2689 : 0 : }
2690 : :
2691 : : /* Adds the value 'new_value' to the "sa" set column from the "simple" table
2692 : : * in 'row'.
2693 : : *
2694 : : */
2695 : : void
2696 : 0 : idltest_simple_update_sa_addvalue(const struct idltest_simple *row, const char *new_value)
2697 : : {
2698 : : struct ovsdb_datum *datum;
2699 : :
2700 [ # # ]: 0 : ovs_assert(inited);
2701 : :
2702 : 0 : datum = xmalloc(sizeof *datum);
2703 : 0 : datum->n = 1;
2704 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2705 : 0 : datum->values = NULL;
2706 : :
2707 : 0 : datum->keys[0].string = xstrdup(new_value);
2708 : :
2709 : 0 : ovsdb_idl_txn_write_partial_set(&row->header_,
2710 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_SA],
2711 : : datum);
2712 : 0 : }
2713 : :
2714 : : /* Deletes the value 'delete_value' from the "sa" set column from the
2715 : : * "simple" table in 'row'.
2716 : : *
2717 : : */
2718 : : void
2719 : 0 : idltest_simple_update_sa_delvalue(const struct idltest_simple *row, const char *delete_value)
2720 : : {
2721 : : struct ovsdb_datum *datum;
2722 : :
2723 [ # # ]: 0 : ovs_assert(inited);
2724 : :
2725 : 0 : datum = xmalloc(sizeof *datum);
2726 : 0 : datum->n = 1;
2727 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2728 : 0 : datum->values = NULL;
2729 : :
2730 : 0 : datum->keys[0].string = xstrdup(delete_value);
2731 : :
2732 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
2733 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_SA],
2734 : : datum);
2735 : 0 : }
2736 : :
2737 : : /* Adds the value 'new_value' to the "ua" set column from the "simple" table
2738 : : * in 'row'.
2739 : : *
2740 : : */
2741 : : void
2742 : 0 : idltest_simple_update_ua_addvalue(const struct idltest_simple *row, struct uuid new_value)
2743 : : {
2744 : : struct ovsdb_datum *datum;
2745 : :
2746 [ # # ]: 0 : ovs_assert(inited);
2747 : :
2748 : 0 : datum = xmalloc(sizeof *datum);
2749 : 0 : datum->n = 1;
2750 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2751 : 0 : datum->values = NULL;
2752 : :
2753 : 0 : datum->keys[0].uuid = new_value;
2754 : :
2755 : 0 : ovsdb_idl_txn_write_partial_set(&row->header_,
2756 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_UA],
2757 : : datum);
2758 : 0 : }
2759 : :
2760 : : /* Deletes the value 'delete_value' from the "ua" set column from the
2761 : : * "simple" table in 'row'.
2762 : : *
2763 : : */
2764 : : void
2765 : 0 : idltest_simple_update_ua_delvalue(const struct idltest_simple *row, struct uuid delete_value)
2766 : : {
2767 : : struct ovsdb_datum *datum;
2768 : :
2769 [ # # ]: 0 : ovs_assert(inited);
2770 : :
2771 : 0 : datum = xmalloc(sizeof *datum);
2772 : 0 : datum->n = 1;
2773 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
2774 : 0 : datum->values = NULL;
2775 : :
2776 : 0 : datum->keys[0].uuid = delete_value;
2777 : :
2778 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
2779 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_UA],
2780 : : datum);
2781 : 0 : }
2782 : :
2783 : : /* Sets the "b" column from the "simple" table in 'row' to
2784 : : * 'b'.
2785 : : *
2786 : : * The caller retains ownership of the arguments. */
2787 : : void
2788 : 0 : idltest_simple_add_clause_b(struct ovsdb_idl *idl, enum ovsdb_function function, bool b)
2789 : : {
2790 : : struct ovsdb_datum datum;
2791 : : union ovsdb_atom key;
2792 : :
2793 [ # # ]: 0 : ovs_assert(inited);
2794 : 0 : datum.n = 1;
2795 : 0 : datum.keys = &key;
2796 : 0 : key.boolean = b;
2797 : 0 : datum.values = NULL;
2798 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2799 : : function,
2800 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_B],
2801 : : &datum);
2802 : 0 : }
2803 : :
2804 : : /* Sets the "ba" column from the "simple" table in 'row' to
2805 : : * the 'ba' set with 'n_ba' entries.
2806 : : *
2807 : : * 'n_ba' may be 0 or 1; if it is 0, then 'ba'
2808 : : * may be NULL.
2809 : : *
2810 : : * The caller retains ownership of the arguments. */
2811 : : void
2812 : 0 : idltest_simple_add_clause_ba(struct ovsdb_idl *idl, enum ovsdb_function function, const bool *ba, size_t n_ba)
2813 : : {
2814 : : struct ovsdb_datum datum;
2815 : : union ovsdb_atom key;
2816 : :
2817 [ # # ]: 0 : ovs_assert(inited);
2818 [ # # ]: 0 : if (n_ba) {
2819 : 0 : datum.n = 1;
2820 : 0 : datum.keys = &key;
2821 : 0 : key.boolean = *ba;
2822 : : } else {
2823 : 0 : datum.n = 0;
2824 : 0 : datum.keys = NULL;
2825 : : }
2826 : 0 : datum.values = NULL;
2827 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2828 : : function,
2829 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_BA],
2830 : : &datum);
2831 : 0 : }
2832 : :
2833 : : /* Sets the "i" column from the "simple" table in 'row' to
2834 : : * 'i'.
2835 : : *
2836 : : * The caller retains ownership of the arguments. */
2837 : : void
2838 : 6 : idltest_simple_add_clause_i(struct ovsdb_idl *idl, enum ovsdb_function function, int64_t i)
2839 : : {
2840 : : struct ovsdb_datum datum;
2841 : : union ovsdb_atom key;
2842 : :
2843 [ - + ]: 6 : ovs_assert(inited);
2844 : 6 : datum.n = 1;
2845 : 6 : datum.keys = &key;
2846 : 6 : key.integer = i;
2847 : 6 : datum.values = NULL;
2848 : 6 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2849 : : function,
2850 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_I],
2851 : : &datum);
2852 : 6 : }
2853 : :
2854 : : /* Sets the "ia" column from the "simple" table in 'row' to
2855 : : * the 'ia' set with 'n_ia' entries.
2856 : : *
2857 : : * The caller retains ownership of the arguments. */
2858 : : void
2859 : 0 : idltest_simple_add_clause_ia(struct ovsdb_idl *idl, enum ovsdb_function function, const int64_t *ia, size_t n_ia)
2860 : : {
2861 : : struct ovsdb_datum datum;
2862 : : size_t i;
2863 : :
2864 [ # # ]: 0 : ovs_assert(inited);
2865 : 0 : datum.n = n_ia;
2866 [ # # ]: 0 : datum.keys = n_ia ? xmalloc(n_ia * sizeof *datum.keys) : NULL;
2867 : 0 : datum.values = NULL;
2868 [ # # ]: 0 : for (i = 0; i < n_ia; i++) {
2869 : 0 : datum.keys[i].integer = ia[i];
2870 : : }
2871 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_INTEGER, OVSDB_TYPE_VOID);
2872 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2873 : : function,
2874 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_IA],
2875 : : &datum);
2876 : 0 : free(datum.keys);
2877 : 0 : }
2878 : :
2879 : : /* Sets the "r" column from the "simple" table in 'row' to
2880 : : * 'r'.
2881 : : *
2882 : : * The caller retains ownership of the arguments. */
2883 : : void
2884 : 0 : idltest_simple_add_clause_r(struct ovsdb_idl *idl, enum ovsdb_function function, double r)
2885 : : {
2886 : : struct ovsdb_datum datum;
2887 : : union ovsdb_atom key;
2888 : :
2889 [ # # ]: 0 : ovs_assert(inited);
2890 : 0 : datum.n = 1;
2891 : 0 : datum.keys = &key;
2892 : 0 : key.real = r;
2893 : 0 : datum.values = NULL;
2894 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2895 : : function,
2896 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_R],
2897 : : &datum);
2898 : 0 : }
2899 : :
2900 : : /* Sets the "ra" column from the "simple" table in 'row' to
2901 : : * the 'ra' set with 'n_ra' entries.
2902 : : *
2903 : : * The caller retains ownership of the arguments. */
2904 : : void
2905 : 0 : idltest_simple_add_clause_ra(struct ovsdb_idl *idl, enum ovsdb_function function, const double *ra, size_t n_ra)
2906 : : {
2907 : : struct ovsdb_datum datum;
2908 : : size_t i;
2909 : :
2910 [ # # ]: 0 : ovs_assert(inited);
2911 : 0 : datum.n = n_ra;
2912 [ # # ]: 0 : datum.keys = n_ra ? xmalloc(n_ra * sizeof *datum.keys) : NULL;
2913 : 0 : datum.values = NULL;
2914 [ # # ]: 0 : for (i = 0; i < n_ra; i++) {
2915 : 0 : datum.keys[i].real = ra[i];
2916 : : }
2917 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_REAL, OVSDB_TYPE_VOID);
2918 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2919 : : function,
2920 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_RA],
2921 : : &datum);
2922 : 0 : free(datum.keys);
2923 : 0 : }
2924 : :
2925 : : /* Sets the "s" column from the "simple" table in 'row' to
2926 : : * 's'.
2927 : : *
2928 : : * The caller retains ownership of the arguments. */
2929 : : void
2930 : 0 : idltest_simple_add_clause_s(struct ovsdb_idl *idl, enum ovsdb_function function, const char *s)
2931 : : {
2932 : : struct ovsdb_datum datum;
2933 : : union ovsdb_atom key;
2934 : :
2935 [ # # ]: 0 : ovs_assert(inited);
2936 : 0 : datum.n = 1;
2937 : 0 : datum.keys = &key;
2938 : 0 : key.string = CONST_CAST(char *, s);
2939 : 0 : datum.values = NULL;
2940 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2941 : : function,
2942 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_S],
2943 : : &datum);
2944 : 0 : }
2945 : :
2946 : : /* Sets the "sa" column from the "simple" table in 'row' to
2947 : : * the 'sa' set with 'n_sa' entries.
2948 : : *
2949 : : * The caller retains ownership of the arguments. */
2950 : : void
2951 : 0 : idltest_simple_add_clause_sa(struct ovsdb_idl *idl, enum ovsdb_function function, const char **sa, size_t n_sa)
2952 : : {
2953 : : struct ovsdb_datum datum;
2954 : : size_t i;
2955 : :
2956 [ # # ]: 0 : ovs_assert(inited);
2957 : 0 : datum.n = n_sa;
2958 [ # # ]: 0 : datum.keys = n_sa ? xmalloc(n_sa * sizeof *datum.keys) : NULL;
2959 : 0 : datum.values = NULL;
2960 [ # # ]: 0 : for (i = 0; i < n_sa; i++) {
2961 : 0 : datum.keys[i].string = CONST_CAST(char *, sa[i]);
2962 : : }
2963 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_STRING, OVSDB_TYPE_VOID);
2964 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2965 : : function,
2966 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_SA],
2967 : : &datum);
2968 : 0 : free(datum.keys);
2969 : 0 : }
2970 : :
2971 : : /* Sets the "u" column from the "simple" table in 'row' to
2972 : : * 'u'.
2973 : : *
2974 : : * The caller retains ownership of the arguments. */
2975 : : void
2976 : 0 : idltest_simple_add_clause_u(struct ovsdb_idl *idl, enum ovsdb_function function, struct uuid u)
2977 : : {
2978 : : struct ovsdb_datum datum;
2979 : : union ovsdb_atom key;
2980 : :
2981 [ # # ]: 0 : ovs_assert(inited);
2982 : 0 : datum.n = 1;
2983 : 0 : datum.keys = &key;
2984 : 0 : key.uuid = u;
2985 : 0 : datum.values = NULL;
2986 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
2987 : : function,
2988 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_U],
2989 : : &datum);
2990 : 0 : }
2991 : :
2992 : : /* Sets the "ua" column from the "simple" table in 'row' to
2993 : : * the 'ua' set with 'n_ua' entries.
2994 : : *
2995 : : * The caller retains ownership of the arguments. */
2996 : : void
2997 : 0 : idltest_simple_add_clause_ua(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *ua, size_t n_ua)
2998 : : {
2999 : : struct ovsdb_datum datum;
3000 : : size_t i;
3001 : :
3002 [ # # ]: 0 : ovs_assert(inited);
3003 : 0 : datum.n = n_ua;
3004 [ # # ]: 0 : datum.keys = n_ua ? xmalloc(n_ua * sizeof *datum.keys) : NULL;
3005 : 0 : datum.values = NULL;
3006 [ # # ]: 0 : for (i = 0; i < n_ua; i++) {
3007 : 0 : datum.keys[i].uuid = ua[i];
3008 : : }
3009 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
3010 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3011 : : function,
3012 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_UA],
3013 : : &datum);
3014 : 0 : free(datum.keys);
3015 : 0 : }
3016 : : void
3017 : 6 : idltest_simple_add_clause_false(struct ovsdb_idl *idl)
3018 : : {
3019 : : struct ovsdb_datum datum;
3020 : :
3021 : 6 : ovsdb_datum_init_empty(&datum);
3022 : 6 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE], OVSDB_F_FALSE, NULL, &datum);
3023 : 6 : }
3024 : : void
3025 : 1 : idltest_simple_add_clause_true(struct ovsdb_idl *idl)
3026 : : {
3027 : : struct ovsdb_datum datum;
3028 : :
3029 : 1 : ovsdb_datum_init_empty(&datum);
3030 : 1 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE], OVSDB_F_TRUE, NULL, &datum);
3031 : 1 : }
3032 : :
3033 : : /* Sets the "b" column from the "simple" table in 'row' to
3034 : : * 'b'.
3035 : : *
3036 : : * The caller retains ownership of the arguments. */
3037 : : void
3038 : 0 : idltest_simple_remove_clause_b(struct ovsdb_idl *idl, enum ovsdb_function function, bool b)
3039 : : {
3040 : : struct ovsdb_datum datum;
3041 : : union ovsdb_atom key;
3042 : :
3043 [ # # ]: 0 : ovs_assert(inited);
3044 : 0 : datum.n = 1;
3045 : 0 : datum.keys = &key;
3046 : 0 : key.boolean = b;
3047 : 0 : datum.values = NULL;
3048 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3049 : : function,
3050 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_B],
3051 : : &datum);
3052 : 0 : }
3053 : :
3054 : : /* Sets the "ba" column from the "simple" table in 'row' to
3055 : : * the 'ba' set with 'n_ba' entries.
3056 : : *
3057 : : * 'n_ba' may be 0 or 1; if it is 0, then 'ba'
3058 : : * may be NULL.
3059 : : *
3060 : : * The caller retains ownership of the arguments. */
3061 : : void
3062 : 0 : idltest_simple_remove_clause_ba(struct ovsdb_idl *idl, enum ovsdb_function function, const bool *ba, size_t n_ba)
3063 : : {
3064 : : struct ovsdb_datum datum;
3065 : : union ovsdb_atom key;
3066 : :
3067 [ # # ]: 0 : ovs_assert(inited);
3068 [ # # ]: 0 : if (n_ba) {
3069 : 0 : datum.n = 1;
3070 : 0 : datum.keys = &key;
3071 : 0 : key.boolean = *ba;
3072 : : } else {
3073 : 0 : datum.n = 0;
3074 : 0 : datum.keys = NULL;
3075 : : }
3076 : 0 : datum.values = NULL;
3077 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3078 : : function,
3079 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_BA],
3080 : : &datum);
3081 : 0 : }
3082 : :
3083 : : /* Sets the "i" column from the "simple" table in 'row' to
3084 : : * 'i'.
3085 : : *
3086 : : * The caller retains ownership of the arguments. */
3087 : : void
3088 : 1 : idltest_simple_remove_clause_i(struct ovsdb_idl *idl, enum ovsdb_function function, int64_t i)
3089 : : {
3090 : : struct ovsdb_datum datum;
3091 : : union ovsdb_atom key;
3092 : :
3093 [ - + ]: 1 : ovs_assert(inited);
3094 : 1 : datum.n = 1;
3095 : 1 : datum.keys = &key;
3096 : 1 : key.integer = i;
3097 : 1 : datum.values = NULL;
3098 : 1 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3099 : : function,
3100 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_I],
3101 : : &datum);
3102 : 1 : }
3103 : :
3104 : : /* Sets the "ia" column from the "simple" table in 'row' to
3105 : : * the 'ia' set with 'n_ia' entries.
3106 : : *
3107 : : * The caller retains ownership of the arguments. */
3108 : : void
3109 : 0 : idltest_simple_remove_clause_ia(struct ovsdb_idl *idl, enum ovsdb_function function, const int64_t *ia, size_t n_ia)
3110 : : {
3111 : : struct ovsdb_datum datum;
3112 : : size_t i;
3113 : :
3114 [ # # ]: 0 : ovs_assert(inited);
3115 : 0 : datum.n = n_ia;
3116 [ # # ]: 0 : datum.keys = n_ia ? xmalloc(n_ia * sizeof *datum.keys) : NULL;
3117 : 0 : datum.values = NULL;
3118 [ # # ]: 0 : for (i = 0; i < n_ia; i++) {
3119 : 0 : datum.keys[i].integer = ia[i];
3120 : : }
3121 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_INTEGER, OVSDB_TYPE_VOID);
3122 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3123 : : function,
3124 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_IA],
3125 : : &datum);
3126 : 0 : free(datum.keys);
3127 : 0 : }
3128 : :
3129 : : /* Sets the "r" column from the "simple" table in 'row' to
3130 : : * 'r'.
3131 : : *
3132 : : * The caller retains ownership of the arguments. */
3133 : : void
3134 : 0 : idltest_simple_remove_clause_r(struct ovsdb_idl *idl, enum ovsdb_function function, double r)
3135 : : {
3136 : : struct ovsdb_datum datum;
3137 : : union ovsdb_atom key;
3138 : :
3139 [ # # ]: 0 : ovs_assert(inited);
3140 : 0 : datum.n = 1;
3141 : 0 : datum.keys = &key;
3142 : 0 : key.real = r;
3143 : 0 : datum.values = NULL;
3144 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3145 : : function,
3146 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_R],
3147 : : &datum);
3148 : 0 : }
3149 : :
3150 : : /* Sets the "ra" column from the "simple" table in 'row' to
3151 : : * the 'ra' set with 'n_ra' entries.
3152 : : *
3153 : : * The caller retains ownership of the arguments. */
3154 : : void
3155 : 0 : idltest_simple_remove_clause_ra(struct ovsdb_idl *idl, enum ovsdb_function function, const double *ra, size_t n_ra)
3156 : : {
3157 : : struct ovsdb_datum datum;
3158 : : size_t i;
3159 : :
3160 [ # # ]: 0 : ovs_assert(inited);
3161 : 0 : datum.n = n_ra;
3162 [ # # ]: 0 : datum.keys = n_ra ? xmalloc(n_ra * sizeof *datum.keys) : NULL;
3163 : 0 : datum.values = NULL;
3164 [ # # ]: 0 : for (i = 0; i < n_ra; i++) {
3165 : 0 : datum.keys[i].real = ra[i];
3166 : : }
3167 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_REAL, OVSDB_TYPE_VOID);
3168 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3169 : : function,
3170 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_RA],
3171 : : &datum);
3172 : 0 : free(datum.keys);
3173 : 0 : }
3174 : :
3175 : : /* Sets the "s" column from the "simple" table in 'row' to
3176 : : * 's'.
3177 : : *
3178 : : * The caller retains ownership of the arguments. */
3179 : : void
3180 : 0 : idltest_simple_remove_clause_s(struct ovsdb_idl *idl, enum ovsdb_function function, const char *s)
3181 : : {
3182 : : struct ovsdb_datum datum;
3183 : : union ovsdb_atom key;
3184 : :
3185 [ # # ]: 0 : ovs_assert(inited);
3186 : 0 : datum.n = 1;
3187 : 0 : datum.keys = &key;
3188 : 0 : key.string = CONST_CAST(char *, s);
3189 : 0 : datum.values = NULL;
3190 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3191 : : function,
3192 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_S],
3193 : : &datum);
3194 : 0 : }
3195 : :
3196 : : /* Sets the "sa" column from the "simple" table in 'row' to
3197 : : * the 'sa' set with 'n_sa' entries.
3198 : : *
3199 : : * The caller retains ownership of the arguments. */
3200 : : void
3201 : 0 : idltest_simple_remove_clause_sa(struct ovsdb_idl *idl, enum ovsdb_function function, const char **sa, size_t n_sa)
3202 : : {
3203 : : struct ovsdb_datum datum;
3204 : : size_t i;
3205 : :
3206 [ # # ]: 0 : ovs_assert(inited);
3207 : 0 : datum.n = n_sa;
3208 [ # # ]: 0 : datum.keys = n_sa ? xmalloc(n_sa * sizeof *datum.keys) : NULL;
3209 : 0 : datum.values = NULL;
3210 [ # # ]: 0 : for (i = 0; i < n_sa; i++) {
3211 : 0 : datum.keys[i].string = CONST_CAST(char *, sa[i]);
3212 : : }
3213 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_STRING, OVSDB_TYPE_VOID);
3214 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3215 : : function,
3216 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_SA],
3217 : : &datum);
3218 : 0 : free(datum.keys);
3219 : 0 : }
3220 : :
3221 : : /* Sets the "u" column from the "simple" table in 'row' to
3222 : : * 'u'.
3223 : : *
3224 : : * The caller retains ownership of the arguments. */
3225 : : void
3226 : 0 : idltest_simple_remove_clause_u(struct ovsdb_idl *idl, enum ovsdb_function function, struct uuid u)
3227 : : {
3228 : : struct ovsdb_datum datum;
3229 : : union ovsdb_atom key;
3230 : :
3231 [ # # ]: 0 : ovs_assert(inited);
3232 : 0 : datum.n = 1;
3233 : 0 : datum.keys = &key;
3234 : 0 : key.uuid = u;
3235 : 0 : datum.values = NULL;
3236 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3237 : : function,
3238 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_U],
3239 : : &datum);
3240 : 0 : }
3241 : :
3242 : : /* Sets the "ua" column from the "simple" table in 'row' to
3243 : : * the 'ua' set with 'n_ua' entries.
3244 : : *
3245 : : * The caller retains ownership of the arguments. */
3246 : : void
3247 : 0 : idltest_simple_remove_clause_ua(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *ua, size_t n_ua)
3248 : : {
3249 : : struct ovsdb_datum datum;
3250 : : size_t i;
3251 : :
3252 [ # # ]: 0 : ovs_assert(inited);
3253 : 0 : datum.n = n_ua;
3254 [ # # ]: 0 : datum.keys = n_ua ? xmalloc(n_ua * sizeof *datum.keys) : NULL;
3255 : 0 : datum.values = NULL;
3256 [ # # ]: 0 : for (i = 0; i < n_ua; i++) {
3257 : 0 : datum.keys[i].uuid = ua[i];
3258 : : }
3259 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
3260 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE],
3261 : : function,
3262 : : &idltest_simple_columns[IDLTEST_SIMPLE_COL_UA],
3263 : : &datum);
3264 : 0 : free(datum.keys);
3265 : 0 : }
3266 : : void
3267 : 1 : idltest_simple_remove_clause_false(struct ovsdb_idl *idl)
3268 : : {
3269 : : struct ovsdb_datum datum;
3270 : :
3271 : 1 : ovsdb_datum_init_empty(&datum);
3272 : 1 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE], OVSDB_F_FALSE, NULL, &datum);
3273 : 1 : }
3274 : : void
3275 : 0 : idltest_simple_remove_clause_true(struct ovsdb_idl *idl)
3276 : : {
3277 : : struct ovsdb_datum datum;
3278 : :
3279 : 0 : ovsdb_datum_init_empty(&datum);
3280 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE], OVSDB_F_TRUE, NULL, &datum);
3281 : 0 : }
3282 : :
3283 : : struct ovsdb_idl_column idltest_simple_columns[IDLTEST_SIMPLE_N_COLUMNS];
3284 : :
3285 : : static void
3286 : 23 : idltest_simple_columns_init(void)
3287 : : {
3288 : : struct ovsdb_idl_column *c;
3289 : :
3290 : : /* Initialize idltest_simple_col_b. */
3291 : 23 : c = &idltest_simple_col_b;
3292 : 23 : c->name = "b";
3293 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_BOOLEAN);
3294 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3295 : 23 : c->type.n_min = 1;
3296 : 23 : c->type.n_max = 1;
3297 : 23 : c->mutable = true;
3298 : 23 : c->parse = idltest_simple_parse_b;
3299 : 23 : c->unparse = idltest_simple_unparse_b;
3300 : :
3301 : : /* Initialize idltest_simple_col_ba. */
3302 : 23 : c = &idltest_simple_col_ba;
3303 : 23 : c->name = "ba";
3304 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_BOOLEAN);
3305 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3306 : 23 : c->type.n_min = 0;
3307 : 23 : c->type.n_max = 1;
3308 : 23 : c->mutable = true;
3309 : 23 : c->parse = idltest_simple_parse_ba;
3310 : 23 : c->unparse = idltest_simple_unparse_ba;
3311 : :
3312 : : /* Initialize idltest_simple_col_i. */
3313 : 23 : c = &idltest_simple_col_i;
3314 : 23 : c->name = "i";
3315 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_INTEGER);
3316 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3317 : 23 : c->type.n_min = 1;
3318 : 23 : c->type.n_max = 1;
3319 : 23 : c->mutable = true;
3320 : 23 : c->parse = idltest_simple_parse_i;
3321 : 23 : c->unparse = idltest_simple_unparse_i;
3322 : :
3323 : : /* Initialize idltest_simple_col_ia. */
3324 : 23 : c = &idltest_simple_col_ia;
3325 : 23 : c->name = "ia";
3326 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_INTEGER);
3327 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3328 : 23 : c->type.n_min = 0;
3329 : 23 : c->type.n_max = UINT_MAX;
3330 : 23 : c->mutable = true;
3331 : 23 : c->parse = idltest_simple_parse_ia;
3332 : 23 : c->unparse = idltest_simple_unparse_ia;
3333 : :
3334 : : /* Initialize idltest_simple_col_r. */
3335 : 23 : c = &idltest_simple_col_r;
3336 : 23 : c->name = "r";
3337 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_REAL);
3338 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3339 : 23 : c->type.n_min = 1;
3340 : 23 : c->type.n_max = 1;
3341 : 23 : c->mutable = true;
3342 : 23 : c->parse = idltest_simple_parse_r;
3343 : 23 : c->unparse = idltest_simple_unparse_r;
3344 : :
3345 : : /* Initialize idltest_simple_col_ra. */
3346 : 23 : c = &idltest_simple_col_ra;
3347 : 23 : c->name = "ra";
3348 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_REAL);
3349 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3350 : 23 : c->type.n_min = 0;
3351 : 23 : c->type.n_max = UINT_MAX;
3352 : 23 : c->mutable = true;
3353 : 23 : c->parse = idltest_simple_parse_ra;
3354 : 23 : c->unparse = idltest_simple_unparse_ra;
3355 : :
3356 : : /* Initialize idltest_simple_col_s. */
3357 : 23 : c = &idltest_simple_col_s;
3358 : 23 : c->name = "s";
3359 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_STRING);
3360 : 23 : c->type.key.u.string.minLen = 0;
3361 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3362 : 23 : c->type.n_min = 1;
3363 : 23 : c->type.n_max = 1;
3364 : 23 : c->mutable = true;
3365 : 23 : c->parse = idltest_simple_parse_s;
3366 : 23 : c->unparse = idltest_simple_unparse_s;
3367 : :
3368 : : /* Initialize idltest_simple_col_sa. */
3369 : 23 : c = &idltest_simple_col_sa;
3370 : 23 : c->name = "sa";
3371 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_STRING);
3372 : 23 : c->type.key.u.string.minLen = 0;
3373 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3374 : 23 : c->type.n_min = 0;
3375 : 23 : c->type.n_max = UINT_MAX;
3376 : 23 : c->mutable = true;
3377 : 23 : c->parse = idltest_simple_parse_sa;
3378 : 23 : c->unparse = idltest_simple_unparse_sa;
3379 : :
3380 : : /* Initialize idltest_simple_col_u. */
3381 : 23 : c = &idltest_simple_col_u;
3382 : 23 : c->name = "u";
3383 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_UUID);
3384 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3385 : 23 : c->type.n_min = 1;
3386 : 23 : c->type.n_max = 1;
3387 : 23 : c->mutable = true;
3388 : 23 : c->parse = idltest_simple_parse_u;
3389 : 23 : c->unparse = idltest_simple_unparse_u;
3390 : :
3391 : : /* Initialize idltest_simple_col_ua. */
3392 : 23 : c = &idltest_simple_col_ua;
3393 : 23 : c->name = "ua";
3394 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_UUID);
3395 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
3396 : 23 : c->type.n_min = 0;
3397 : 23 : c->type.n_max = UINT_MAX;
3398 : 23 : c->mutable = true;
3399 : 23 : c->parse = idltest_simple_parse_ua;
3400 : 23 : c->unparse = idltest_simple_unparse_ua;
3401 : 23 : }
3402 : :
3403 : : /* simple2 table. */
3404 : :
3405 : : static void
3406 : 4 : idltest_simple2_parse_imap(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
3407 : : {
3408 : 4 : struct idltest_simple2 *row = idltest_simple2_cast(row_);
3409 : : size_t i;
3410 : :
3411 [ - + ]: 4 : ovs_assert(inited);
3412 : 4 : row->key_imap = NULL;
3413 : 4 : row->value_imap = NULL;
3414 : 4 : row->n_imap = 0;
3415 [ + + ]: 6 : for (i = 0; i < datum->n; i++) {
3416 [ + - ]: 2 : if (!row->n_imap) {
3417 : 2 : row->key_imap = xmalloc(datum->n * sizeof *row->key_imap);
3418 : 2 : row->value_imap = xmalloc(datum->n * sizeof *row->value_imap);
3419 : : }
3420 : 2 : row->key_imap[row->n_imap] = datum->keys[i].integer;
3421 : 2 : row->value_imap[row->n_imap] = datum->values[i].string;
3422 : 2 : row->n_imap++;
3423 : : }
3424 : 4 : }
3425 : :
3426 : : static void
3427 : 5 : idltest_simple2_parse_name(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
3428 : : {
3429 : 5 : struct idltest_simple2 *row = idltest_simple2_cast(row_);
3430 : :
3431 [ - + ]: 5 : ovs_assert(inited);
3432 [ + - ]: 5 : if (datum->n >= 1) {
3433 : 5 : row->name = datum->keys[0].string;
3434 : : } else {
3435 : 0 : row->name = "";
3436 : : }
3437 : 5 : }
3438 : :
3439 : : static void
3440 : 4 : idltest_simple2_parse_smap(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
3441 : : {
3442 : 4 : struct idltest_simple2 *row = idltest_simple2_cast(row_);
3443 : : size_t i;
3444 : :
3445 [ - + ]: 4 : ovs_assert(inited);
3446 : 4 : smap_init(&row->smap);
3447 [ + + ]: 11 : for (i = 0; i < datum->n; i++) {
3448 : 7 : smap_add(&row->smap,
3449 : 7 : datum->keys[i].string,
3450 : 7 : datum->values[i].string);
3451 : : }
3452 : 4 : }
3453 : :
3454 : : static void
3455 : 3 : idltest_simple2_unparse_imap(struct ovsdb_idl_row *row_)
3456 : : {
3457 : 3 : struct idltest_simple2 *row = idltest_simple2_cast(row_);
3458 : :
3459 [ - + ]: 3 : ovs_assert(inited);
3460 : 3 : free(row->key_imap);
3461 : 3 : free(row->value_imap);
3462 : 3 : }
3463 : :
3464 : : static void
3465 : 4 : idltest_simple2_unparse_name(struct ovsdb_idl_row *row OVS_UNUSED)
3466 : : {
3467 : : /* Nothing to do. */
3468 : 4 : }
3469 : :
3470 : : static void
3471 : 3 : idltest_simple2_unparse_smap(struct ovsdb_idl_row *row_)
3472 : : {
3473 : 3 : struct idltest_simple2 *row = idltest_simple2_cast(row_);
3474 : :
3475 [ - + ]: 3 : ovs_assert(inited);
3476 : 3 : smap_destroy(&row->smap);
3477 : 3 : }
3478 : :
3479 : : static void
3480 : 1 : idltest_simple2_init__(struct ovsdb_idl_row *row)
3481 : : {
3482 : 1 : idltest_simple2_init(idltest_simple2_cast(row));
3483 : 1 : }
3484 : :
3485 : : /* Clears the contents of 'row' in table "simple2". */
3486 : : void
3487 : 1 : idltest_simple2_init(struct idltest_simple2 *row)
3488 : : {
3489 : 1 : memset(row, 0, sizeof *row);
3490 : 1 : smap_init(&row->smap);
3491 : 1 : }
3492 : :
3493 : : /* Searches table "simple2" in 'idl' for a row with UUID 'uuid'. Returns
3494 : : * a pointer to the row if there is one, otherwise a null pointer. */
3495 : : const struct idltest_simple2 *
3496 : 0 : idltest_simple2_get_for_uuid(const struct ovsdb_idl *idl, const struct uuid *uuid)
3497 : : {
3498 : 0 : return idltest_simple2_cast(ovsdb_idl_get_row_for_uuid(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2], uuid));
3499 : : }
3500 : :
3501 : : /* Returns a row in table "simple2" in 'idl', or a null pointer if that
3502 : : * table is empty.
3503 : : *
3504 : : * Database tables are internally maintained as hash tables, so adding or
3505 : : * removing rows while traversing the same table can cause some rows to be
3506 : : * visited twice or not at apply. */
3507 : : const struct idltest_simple2 *
3508 : 7 : idltest_simple2_first(const struct ovsdb_idl *idl)
3509 : : {
3510 : 7 : return idltest_simple2_cast(ovsdb_idl_first_row(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2]));
3511 : : }
3512 : :
3513 : : /* Returns a row following 'row' within its table, or a null pointer if 'row'
3514 : : * is the last row in its table. */
3515 : : const struct idltest_simple2 *
3516 : 5 : idltest_simple2_next(const struct idltest_simple2 *row)
3517 : : {
3518 : 5 : return idltest_simple2_cast(ovsdb_idl_next_row(&row->header_));
3519 : : }
3520 : :
3521 : 0 : unsigned int idltest_simple2_get_seqno(const struct ovsdb_idl *idl)
3522 : : {
3523 : 0 : return ovsdb_idl_table_get_seqno(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2]);
3524 : : }
3525 : :
3526 : 0 : unsigned int idltest_simple2_row_get_seqno(const struct idltest_simple2 *row, enum ovsdb_idl_change change)
3527 : : {
3528 : 0 : return ovsdb_idl_row_get_seqno(&row->header_, change);
3529 : : }
3530 : :
3531 : : const struct idltest_simple2 *
3532 : 0 : idltest_simple2_track_get_first(const struct ovsdb_idl *idl)
3533 : : {
3534 : 0 : return idltest_simple2_cast(ovsdb_idl_track_get_first(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2]));
3535 : : }
3536 : :
3537 : : const struct idltest_simple2
3538 : 0 : *idltest_simple2_track_get_next(const struct idltest_simple2 *row)
3539 : : {
3540 : 0 : return idltest_simple2_cast(ovsdb_idl_track_get_next(&row->header_));
3541 : : }
3542 : :
3543 : :
3544 : : /* Deletes 'row' from table "simple2". 'row' may be freed, so it must not be
3545 : : * accessed afterward.
3546 : : *
3547 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
3548 : : void
3549 : 0 : idltest_simple2_delete(const struct idltest_simple2 *row)
3550 : : {
3551 : 0 : ovsdb_idl_txn_delete(&row->header_);
3552 : 0 : }
3553 : :
3554 : : /* Inserts and returns a new row in the table "simple2" in the database
3555 : : * with open transaction 'txn'.
3556 : : *
3557 : : * The new row is assigned a randomly generated provisional UUID.
3558 : : * ovsdb-server will assign a different UUID when 'txn' is committed,
3559 : : * but the IDL will replace any uses of the provisional UUID in the
3560 : : * data to be to be committed by the UUID assigned by ovsdb-server. */
3561 : : struct idltest_simple2 *
3562 : 0 : idltest_simple2_insert(struct ovsdb_idl_txn *txn)
3563 : : {
3564 : 0 : return idltest_simple2_cast(ovsdb_idl_txn_insert(txn, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2], NULL));
3565 : : }
3566 : :
3567 : : bool
3568 : 0 : idltest_simple2_is_updated(const struct idltest_simple2 *row, enum idltest_simple2_column_id column)
3569 : : {
3570 : 0 : return ovsdb_idl_track_is_updated(&row->header_, &idltest_simple2_columns[column]);
3571 : : }
3572 : :
3573 : : /* Causes the original contents of column "imap" in 'row' to be
3574 : : * verified as a prerequisite to completing the transaction. That is, if
3575 : : * "imap" in 'row' changed (or if 'row' was deleted) between the
3576 : : * time that the IDL originally read its contents and the time that the
3577 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
3578 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
3579 : : * change has already been received).
3580 : : *
3581 : : * The intention is that, to ensure that no transaction commits based on dirty
3582 : : * reads, an application should call this function any time "imap" is
3583 : : * read as part of a read-modify-write operation.
3584 : : *
3585 : : * In some cases this function reduces to a no-op, because the current value
3586 : : * of "imap" is already known:
3587 : : *
3588 : : * - If 'row' is a row created by the current transaction (returned by
3589 : : * idltest_simple2_insert()).
3590 : : *
3591 : : * - If "imap" has already been modified (with
3592 : : * idltest_simple2_set_imap()) within the current transaction.
3593 : : *
3594 : : * Because of the latter property, always call this function *before*
3595 : : * idltest_simple2_set_imap() for a given read-modify-write.
3596 : : *
3597 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
3598 : : void
3599 : 0 : idltest_simple2_verify_imap(const struct idltest_simple2 *row)
3600 : : {
3601 [ # # ]: 0 : ovs_assert(inited);
3602 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_IMAP]);
3603 : 0 : }
3604 : :
3605 : : /* Causes the original contents of column "name" in 'row' to be
3606 : : * verified as a prerequisite to completing the transaction. That is, if
3607 : : * "name" in 'row' changed (or if 'row' was deleted) between the
3608 : : * time that the IDL originally read its contents and the time that the
3609 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
3610 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
3611 : : * change has already been received).
3612 : : *
3613 : : * The intention is that, to ensure that no transaction commits based on dirty
3614 : : * reads, an application should call this function any time "name" is
3615 : : * read as part of a read-modify-write operation.
3616 : : *
3617 : : * In some cases this function reduces to a no-op, because the current value
3618 : : * of "name" is already known:
3619 : : *
3620 : : * - If 'row' is a row created by the current transaction (returned by
3621 : : * idltest_simple2_insert()).
3622 : : *
3623 : : * - If "name" has already been modified (with
3624 : : * idltest_simple2_set_name()) within the current transaction.
3625 : : *
3626 : : * Because of the latter property, always call this function *before*
3627 : : * idltest_simple2_set_name() for a given read-modify-write.
3628 : : *
3629 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
3630 : : void
3631 : 0 : idltest_simple2_verify_name(const struct idltest_simple2 *row)
3632 : : {
3633 [ # # ]: 0 : ovs_assert(inited);
3634 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_NAME]);
3635 : 0 : }
3636 : :
3637 : : /* Causes the original contents of column "smap" in 'row' to be
3638 : : * verified as a prerequisite to completing the transaction. That is, if
3639 : : * "smap" in 'row' changed (or if 'row' was deleted) between the
3640 : : * time that the IDL originally read its contents and the time that the
3641 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
3642 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
3643 : : * change has already been received).
3644 : : *
3645 : : * The intention is that, to ensure that no transaction commits based on dirty
3646 : : * reads, an application should call this function any time "smap" is
3647 : : * read as part of a read-modify-write operation.
3648 : : *
3649 : : * In some cases this function reduces to a no-op, because the current value
3650 : : * of "smap" is already known:
3651 : : *
3652 : : * - If 'row' is a row created by the current transaction (returned by
3653 : : * idltest_simple2_insert()).
3654 : : *
3655 : : * - If "smap" has already been modified (with
3656 : : * idltest_simple2_set_smap()) within the current transaction.
3657 : : *
3658 : : * Because of the latter property, always call this function *before*
3659 : : * idltest_simple2_set_smap() for a given read-modify-write.
3660 : : *
3661 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
3662 : : void
3663 : 0 : idltest_simple2_verify_smap(const struct idltest_simple2 *row)
3664 : : {
3665 [ # # ]: 0 : ovs_assert(inited);
3666 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_SMAP]);
3667 : 0 : }
3668 : :
3669 : : /* Returns the "imap" column's value from the "simple2" table in 'row'
3670 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
3671 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
3672 : : * for a given key than implementing the same operation on the "cooked"
3673 : : * form in 'row'.
3674 : : *
3675 : : * 'key_type' must be OVSDB_TYPE_INTEGER.
3676 : : * 'value_type' must be OVSDB_TYPE_STRING.
3677 : : * (This helps to avoid silent bugs if someone changes imap's
3678 : : * type without updating the caller.)
3679 : : *
3680 : : * The caller must not modify or free the returned value.
3681 : : *
3682 : : * Various kinds of changes can invalidate the returned value: modifying
3683 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
3684 : : * If the returned value is needed for a long time, it is best to make a copy
3685 : : * of it with ovsdb_datum_clone().
3686 : : *
3687 : : * This function is rarely useful, since it is easier to access the value
3688 : : * directly through the "imap" member in idltest_simple2. */
3689 : : const struct ovsdb_datum *
3690 : 6 : idltest_simple2_get_imap(const struct idltest_simple2 *row,
3691 : : enum ovsdb_atomic_type key_type OVS_UNUSED,
3692 : : enum ovsdb_atomic_type value_type OVS_UNUSED)
3693 : : {
3694 [ - + ]: 6 : ovs_assert(key_type == OVSDB_TYPE_INTEGER);
3695 [ - + ]: 6 : ovs_assert(value_type == OVSDB_TYPE_STRING);
3696 : 6 : return ovsdb_idl_read(&row->header_, &idltest_simple2_col_imap);
3697 : : }
3698 : :
3699 : : /* Returns the "name" column's value from the "simple2" table in 'row'
3700 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
3701 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
3702 : : * for a given key than implementing the same operation on the "cooked"
3703 : : * form in 'row'.
3704 : : *
3705 : : * 'key_type' must be OVSDB_TYPE_STRING.
3706 : : * (This helps to avoid silent bugs if someone changes name's
3707 : : * type without updating the caller.)
3708 : : *
3709 : : * The caller must not modify or free the returned value.
3710 : : *
3711 : : * Various kinds of changes can invalidate the returned value: modifying
3712 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
3713 : : * If the returned value is needed for a long time, it is best to make a copy
3714 : : * of it with ovsdb_datum_clone().
3715 : : *
3716 : : * This function is rarely useful, since it is easier to access the value
3717 : : * directly through the "name" member in idltest_simple2. */
3718 : : const struct ovsdb_datum *
3719 : 0 : idltest_simple2_get_name(const struct idltest_simple2 *row,
3720 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
3721 : : {
3722 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_STRING);
3723 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple2_col_name);
3724 : : }
3725 : :
3726 : : /* Returns the "smap" column's value from the "simple2" table in 'row'
3727 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
3728 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
3729 : : * for a given key than implementing the same operation on the "cooked"
3730 : : * form in 'row'.
3731 : : *
3732 : : * 'key_type' must be OVSDB_TYPE_STRING.
3733 : : * 'value_type' must be OVSDB_TYPE_STRING.
3734 : : * (This helps to avoid silent bugs if someone changes smap's
3735 : : * type without updating the caller.)
3736 : : *
3737 : : * The caller must not modify or free the returned value.
3738 : : *
3739 : : * Various kinds of changes can invalidate the returned value: modifying
3740 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
3741 : : * If the returned value is needed for a long time, it is best to make a copy
3742 : : * of it with ovsdb_datum_clone().
3743 : : *
3744 : : * This function is rarely useful, since it is easier to access the value
3745 : : * directly through the "smap" member in idltest_simple2. */
3746 : : const struct ovsdb_datum *
3747 : 7 : idltest_simple2_get_smap(const struct idltest_simple2 *row,
3748 : : enum ovsdb_atomic_type key_type OVS_UNUSED,
3749 : : enum ovsdb_atomic_type value_type OVS_UNUSED)
3750 : : {
3751 [ - + ]: 7 : ovs_assert(key_type == OVSDB_TYPE_STRING);
3752 [ - + ]: 7 : ovs_assert(value_type == OVSDB_TYPE_STRING);
3753 : 7 : return ovsdb_idl_read(&row->header_, &idltest_simple2_col_smap);
3754 : : }
3755 : :
3756 : : /* Sets the "imap" column from the "simple2" table in 'row' to
3757 : : * the map with keys 'key_imap' and values 'value_imap'
3758 : : * with 'n_imap' entries.
3759 : : *
3760 : : * Argument constraints: key in range 0 to 4,095
3761 : : *
3762 : : * The caller retains ownership of the arguments. */
3763 : : void
3764 : 0 : idltest_simple2_set_imap(const struct idltest_simple2 *row, const int64_t *key_imap, const char **value_imap, size_t n_imap)
3765 : : {
3766 : : struct ovsdb_datum datum;
3767 : : size_t i;
3768 : :
3769 [ # # ]: 0 : ovs_assert(inited);
3770 : 0 : datum.n = n_imap;
3771 [ # # ]: 0 : datum.keys = n_imap ? xmalloc(n_imap * sizeof *datum.keys) : NULL;
3772 : 0 : datum.values = xmalloc(n_imap * sizeof *datum.values);
3773 [ # # ]: 0 : for (i = 0; i < n_imap; i++) {
3774 : 0 : datum.keys[i].integer = key_imap[i];
3775 : 0 : datum.values[i].string = xstrdup(value_imap[i]);
3776 : : }
3777 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_INTEGER, OVSDB_TYPE_STRING);
3778 : 0 : ovsdb_idl_txn_write(&row->header_, &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_IMAP], &datum);
3779 : 0 : }
3780 : :
3781 : : /* Sets the "name" column from the "simple2" table in 'row' to
3782 : : * 'name'.
3783 : : *
3784 : : * The caller retains ownership of the arguments. */
3785 : : void
3786 : 1 : idltest_simple2_set_name(const struct idltest_simple2 *row, const char *name)
3787 : : {
3788 : : struct ovsdb_datum datum;
3789 : : union ovsdb_atom key;
3790 : :
3791 [ - + ]: 1 : ovs_assert(inited);
3792 : 1 : datum.n = 1;
3793 : 1 : datum.keys = &key;
3794 : 1 : key.string = CONST_CAST(char *, name);
3795 : 1 : datum.values = NULL;
3796 : 1 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_NAME], &datum);
3797 : 1 : }
3798 : :
3799 : : /* Sets the "smap" column's value from the "simple2" table in 'row'
3800 : : * to 'smap'.
3801 : : *
3802 : : * The caller retains ownership of 'smap' and everything in it. */
3803 : : void
3804 : 0 : idltest_simple2_set_smap(const struct idltest_simple2 *row, const struct smap *smap)
3805 : : {
3806 : : struct ovsdb_datum datum;
3807 : :
3808 [ # # ]: 0 : ovs_assert(inited);
3809 [ # # ]: 0 : if (smap) {
3810 : : struct smap_node *node;
3811 : : size_t i;
3812 : :
3813 : 0 : datum.n = smap_count(smap);
3814 : 0 : datum.keys = xmalloc(datum.n * sizeof *datum.keys);
3815 : 0 : datum.values = xmalloc(datum.n * sizeof *datum.values);
3816 : :
3817 : 0 : i = 0;
3818 [ # # ][ # # ]: 0 : SMAP_FOR_EACH (node, smap) {
3819 : 0 : datum.keys[i].string = xstrdup(node->key);
3820 : 0 : datum.values[i].string = xstrdup(node->value);
3821 : 0 : i++;
3822 : : }
3823 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING);
3824 : : } else {
3825 : 0 : ovsdb_datum_init_empty(&datum);
3826 : : }
3827 : 0 : ovsdb_idl_txn_write(&row->header_,
3828 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_SMAP],
3829 : : &datum);
3830 : 0 : }
3831 : :
3832 : :
3833 : : /* Sets an element of the "imap" map column from the "simple2" table in 'row'
3834 : : * to 'new_value' given the key value 'new_key'.
3835 : : *
3836 : : */
3837 : : void
3838 : 1 : idltest_simple2_update_imap_setkey(const struct idltest_simple2 *row, int64_t new_key, const char *new_value)
3839 : : {
3840 : : struct ovsdb_datum *datum;
3841 : :
3842 [ - + ]: 1 : ovs_assert(inited);
3843 : :
3844 : 1 : datum = xmalloc(sizeof *datum);
3845 : 1 : datum->n = 1;
3846 : 1 : datum->keys = xmalloc(datum->n * sizeof *datum->keys);
3847 : 1 : datum->values = xmalloc(datum->n * sizeof *datum->values);
3848 : :
3849 : 1 : datum->keys[0].integer = new_key;
3850 : 1 : datum->values[0].string = xstrdup(new_value);
3851 : :
3852 : 1 : ovsdb_idl_txn_write_partial_map(&row->header_,
3853 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_IMAP],
3854 : : datum);
3855 : 1 : }
3856 : :
3857 : : /* Deletes an element of the "imap" map column from the "simple2" table in 'row'
3858 : : * given the key value 'delete_key'.
3859 : : *
3860 : : */
3861 : : void
3862 : 0 : idltest_simple2_update_imap_delkey(const struct idltest_simple2 *row, int64_t delete_key)
3863 : : {
3864 : : struct ovsdb_datum *datum;
3865 : :
3866 [ # # ]: 0 : ovs_assert(inited);
3867 : :
3868 : 0 : datum = xmalloc(sizeof *datum);
3869 : 0 : datum->n = 1;
3870 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->keys);
3871 : 0 : datum->values = NULL;
3872 : :
3873 : 0 : datum->keys[0].integer = delete_key;
3874 : :
3875 : 0 : ovsdb_idl_txn_delete_partial_map(&row->header_,
3876 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_IMAP],
3877 : : datum);
3878 : 0 : }
3879 : :
3880 : : /* Sets an element of the "smap" map column from the "simple2" table in 'row'
3881 : : * to 'new_value' given the key value 'new_key'.
3882 : : *
3883 : : */
3884 : : void
3885 : 2 : idltest_simple2_update_smap_setkey(const struct idltest_simple2 *row, const char *new_key, const char *new_value)
3886 : : {
3887 : : struct ovsdb_datum *datum;
3888 : :
3889 [ - + ]: 2 : ovs_assert(inited);
3890 : :
3891 : 2 : datum = xmalloc(sizeof *datum);
3892 : 2 : datum->n = 1;
3893 : 2 : datum->keys = xmalloc(datum->n * sizeof *datum->keys);
3894 : 2 : datum->values = xmalloc(datum->n * sizeof *datum->values);
3895 : :
3896 : 2 : datum->keys[0].string = xstrdup(new_key);
3897 : 2 : datum->values[0].string = xstrdup(new_value);
3898 : :
3899 : 2 : ovsdb_idl_txn_write_partial_map(&row->header_,
3900 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_SMAP],
3901 : : datum);
3902 : 2 : }
3903 : :
3904 : : /* Deletes an element of the "smap" map column from the "simple2" table in 'row'
3905 : : * given the key value 'delete_key'.
3906 : : *
3907 : : */
3908 : : void
3909 : 2 : idltest_simple2_update_smap_delkey(const struct idltest_simple2 *row, const char *delete_key)
3910 : : {
3911 : : struct ovsdb_datum *datum;
3912 : :
3913 [ - + ]: 2 : ovs_assert(inited);
3914 : :
3915 : 2 : datum = xmalloc(sizeof *datum);
3916 : 2 : datum->n = 1;
3917 : 2 : datum->keys = xmalloc(datum->n * sizeof *datum->keys);
3918 : 2 : datum->values = NULL;
3919 : :
3920 : 2 : datum->keys[0].string = xstrdup(delete_key);
3921 : :
3922 : 2 : ovsdb_idl_txn_delete_partial_map(&row->header_,
3923 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_SMAP],
3924 : : datum);
3925 : 2 : }
3926 : :
3927 : : /* Sets the "imap" column from the "simple2" table in 'row' to
3928 : : * the map with keys 'key_imap' and values 'value_imap'
3929 : : * with 'n_imap' entries.
3930 : : *
3931 : : * Argument constraints: key in range 0 to 4,095
3932 : : *
3933 : : * The caller retains ownership of the arguments. */
3934 : : void
3935 : 0 : idltest_simple2_add_clause_imap(struct ovsdb_idl *idl, enum ovsdb_function function, const int64_t *key_imap, const char **value_imap, size_t n_imap)
3936 : : {
3937 : : struct ovsdb_datum datum;
3938 : : size_t i;
3939 : :
3940 [ # # ]: 0 : ovs_assert(inited);
3941 : 0 : datum.n = n_imap;
3942 [ # # ]: 0 : datum.keys = n_imap ? xmalloc(n_imap * sizeof *datum.keys) : NULL;
3943 : 0 : datum.values = xmalloc(n_imap * sizeof *datum.values);
3944 [ # # ]: 0 : for (i = 0; i < n_imap; i++) {
3945 : 0 : datum.keys[i].integer = key_imap[i];
3946 : 0 : datum.values[i].string = CONST_CAST(char *, value_imap[i]);
3947 : : }
3948 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_INTEGER, OVSDB_TYPE_STRING);
3949 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2],
3950 : : function,
3951 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_IMAP],
3952 : : &datum);
3953 : 0 : free(datum.keys);
3954 : 0 : free(datum.values);
3955 : 0 : }
3956 : :
3957 : : /* Sets the "name" column from the "simple2" table in 'row' to
3958 : : * 'name'.
3959 : : *
3960 : : * The caller retains ownership of the arguments. */
3961 : : void
3962 : 0 : idltest_simple2_add_clause_name(struct ovsdb_idl *idl, enum ovsdb_function function, const char *name)
3963 : : {
3964 : : struct ovsdb_datum datum;
3965 : : union ovsdb_atom key;
3966 : :
3967 [ # # ]: 0 : ovs_assert(inited);
3968 : 0 : datum.n = 1;
3969 : 0 : datum.keys = &key;
3970 : 0 : key.string = CONST_CAST(char *, name);
3971 : 0 : datum.values = NULL;
3972 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2],
3973 : : function,
3974 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_NAME],
3975 : : &datum);
3976 : 0 : }
3977 : :
3978 : : /* Sets the "smap" column's value from the "simple2" table in 'row'
3979 : : * to 'smap'.
3980 : : *
3981 : : * The caller retains ownership of 'smap' and everything in it. */
3982 : : void
3983 : 0 : idltest_simple2_add_clause_smap(struct ovsdb_idl *idl, enum ovsdb_function function, const struct smap *smap)
3984 : : {
3985 : : struct ovsdb_datum datum;
3986 : :
3987 [ # # ]: 0 : ovs_assert(inited);
3988 [ # # ]: 0 : if (smap) {
3989 : : struct smap_node *node;
3990 : : size_t i;
3991 : :
3992 : 0 : datum.n = smap_count(smap);
3993 : 0 : datum.keys = xmalloc(datum.n * sizeof *datum.keys);
3994 : 0 : datum.values = xmalloc(datum.n * sizeof *datum.values);
3995 : :
3996 : 0 : i = 0;
3997 [ # # ][ # # ]: 0 : SMAP_FOR_EACH (node, smap) {
3998 : 0 : datum.keys[i].string = xstrdup(node->key);
3999 : 0 : datum.values[i].string = xstrdup(node->value);
4000 : 0 : i++;
4001 : : }
4002 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING);
4003 : : } else {
4004 : 0 : ovsdb_datum_init_empty(&datum);
4005 : : }
4006 : :
4007 : 0 : ovsdb_idl_condition_add_clause(idl,
4008 : : &idltest_table_classes[IDLTEST_TABLE_SIMPLE2],
4009 : : function,
4010 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_SMAP],
4011 : : &datum);
4012 : :
4013 : 0 : ovsdb_datum_destroy(&datum, &idltest_simple2_col_smap.type);
4014 : 0 : }
4015 : :
4016 : : void
4017 : 0 : idltest_simple2_add_clause_false(struct ovsdb_idl *idl)
4018 : : {
4019 : : struct ovsdb_datum datum;
4020 : :
4021 : 0 : ovsdb_datum_init_empty(&datum);
4022 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2], OVSDB_F_FALSE, NULL, &datum);
4023 : 0 : }
4024 : : void
4025 : 0 : idltest_simple2_add_clause_true(struct ovsdb_idl *idl)
4026 : : {
4027 : : struct ovsdb_datum datum;
4028 : :
4029 : 0 : ovsdb_datum_init_empty(&datum);
4030 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2], OVSDB_F_TRUE, NULL, &datum);
4031 : 0 : }
4032 : :
4033 : : /* Sets the "imap" column from the "simple2" table in 'row' to
4034 : : * the map with keys 'key_imap' and values 'value_imap'
4035 : : * with 'n_imap' entries.
4036 : : *
4037 : : * Argument constraints: key in range 0 to 4,095
4038 : : *
4039 : : * The caller retains ownership of the arguments. */
4040 : : void
4041 : 0 : idltest_simple2_remove_clause_imap(struct ovsdb_idl *idl, enum ovsdb_function function, const int64_t *key_imap, const char **value_imap, size_t n_imap)
4042 : : {
4043 : : struct ovsdb_datum datum;
4044 : : size_t i;
4045 : :
4046 [ # # ]: 0 : ovs_assert(inited);
4047 : 0 : datum.n = n_imap;
4048 [ # # ]: 0 : datum.keys = n_imap ? xmalloc(n_imap * sizeof *datum.keys) : NULL;
4049 : 0 : datum.values = xmalloc(n_imap * sizeof *datum.values);
4050 [ # # ]: 0 : for (i = 0; i < n_imap; i++) {
4051 : 0 : datum.keys[i].integer = key_imap[i];
4052 : 0 : datum.values[i].string = CONST_CAST(char *, value_imap[i]);
4053 : : }
4054 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_INTEGER, OVSDB_TYPE_STRING);
4055 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2],
4056 : : function,
4057 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_IMAP],
4058 : : &datum);
4059 : 0 : free(datum.keys);
4060 : 0 : free(datum.values);
4061 : 0 : }
4062 : :
4063 : : /* Sets the "name" column from the "simple2" table in 'row' to
4064 : : * 'name'.
4065 : : *
4066 : : * The caller retains ownership of the arguments. */
4067 : : void
4068 : 0 : idltest_simple2_remove_clause_name(struct ovsdb_idl *idl, enum ovsdb_function function, const char *name)
4069 : : {
4070 : : struct ovsdb_datum datum;
4071 : : union ovsdb_atom key;
4072 : :
4073 [ # # ]: 0 : ovs_assert(inited);
4074 : 0 : datum.n = 1;
4075 : 0 : datum.keys = &key;
4076 : 0 : key.string = CONST_CAST(char *, name);
4077 : 0 : datum.values = NULL;
4078 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2],
4079 : : function,
4080 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_NAME],
4081 : : &datum);
4082 : 0 : }
4083 : :
4084 : : /* Sets the "smap" column's value from the "simple2" table in 'row'
4085 : : * to 'smap'.
4086 : : *
4087 : : * The caller retains ownership of 'smap' and everything in it. */
4088 : : void
4089 : 0 : idltest_simple2_remove_clause_smap(struct ovsdb_idl *idl, enum ovsdb_function function, const struct smap *smap)
4090 : : {
4091 : : struct ovsdb_datum datum;
4092 : :
4093 [ # # ]: 0 : ovs_assert(inited);
4094 [ # # ]: 0 : if (smap) {
4095 : : struct smap_node *node;
4096 : : size_t i;
4097 : :
4098 : 0 : datum.n = smap_count(smap);
4099 : 0 : datum.keys = xmalloc(datum.n * sizeof *datum.keys);
4100 : 0 : datum.values = xmalloc(datum.n * sizeof *datum.values);
4101 : :
4102 : 0 : i = 0;
4103 [ # # ][ # # ]: 0 : SMAP_FOR_EACH (node, smap) {
4104 : 0 : datum.keys[i].string = xstrdup(node->key);
4105 : 0 : datum.values[i].string = xstrdup(node->value);
4106 : 0 : i++;
4107 : : }
4108 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING);
4109 : : } else {
4110 : 0 : ovsdb_datum_init_empty(&datum);
4111 : : }
4112 : :
4113 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2],
4114 : : function,
4115 : : &idltest_simple2_columns[IDLTEST_SIMPLE2_COL_SMAP],
4116 : : &datum);
4117 : :
4118 : 0 : ovsdb_datum_destroy(&datum, &idltest_simple2_col_smap.type);
4119 : 0 : }
4120 : :
4121 : : void
4122 : 0 : idltest_simple2_remove_clause_false(struct ovsdb_idl *idl)
4123 : : {
4124 : : struct ovsdb_datum datum;
4125 : :
4126 : 0 : ovsdb_datum_init_empty(&datum);
4127 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2], OVSDB_F_FALSE, NULL, &datum);
4128 : 0 : }
4129 : : void
4130 : 0 : idltest_simple2_remove_clause_true(struct ovsdb_idl *idl)
4131 : : {
4132 : : struct ovsdb_datum datum;
4133 : :
4134 : 0 : ovsdb_datum_init_empty(&datum);
4135 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE2], OVSDB_F_TRUE, NULL, &datum);
4136 : 0 : }
4137 : :
4138 : : struct ovsdb_idl_column idltest_simple2_columns[IDLTEST_SIMPLE2_N_COLUMNS];
4139 : :
4140 : : static void
4141 : 23 : idltest_simple2_columns_init(void)
4142 : : {
4143 : : struct ovsdb_idl_column *c;
4144 : :
4145 : : /* Initialize idltest_simple2_col_imap. */
4146 : 23 : c = &idltest_simple2_col_imap;
4147 : 23 : c->name = "imap";
4148 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_INTEGER);
4149 : 23 : c->type.key.u.integer.min = INT64_C(0);
4150 : 23 : c->type.key.u.integer.max = INT64_C(4095);
4151 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_STRING);
4152 : 23 : c->type.value.u.string.minLen = 0;
4153 : 23 : c->type.n_min = 0;
4154 : 23 : c->type.n_max = UINT_MAX;
4155 : 23 : c->mutable = true;
4156 : 23 : c->parse = idltest_simple2_parse_imap;
4157 : 23 : c->unparse = idltest_simple2_unparse_imap;
4158 : :
4159 : : /* Initialize idltest_simple2_col_name. */
4160 : 23 : c = &idltest_simple2_col_name;
4161 : 23 : c->name = "name";
4162 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_STRING);
4163 : 23 : c->type.key.u.string.minLen = 0;
4164 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
4165 : 23 : c->type.n_min = 1;
4166 : 23 : c->type.n_max = 1;
4167 : 23 : c->mutable = true;
4168 : 23 : c->parse = idltest_simple2_parse_name;
4169 : 23 : c->unparse = idltest_simple2_unparse_name;
4170 : :
4171 : : /* Initialize idltest_simple2_col_smap. */
4172 : 23 : c = &idltest_simple2_col_smap;
4173 : 23 : c->name = "smap";
4174 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_STRING);
4175 : 23 : c->type.key.u.string.minLen = 0;
4176 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_STRING);
4177 : 23 : c->type.value.u.string.minLen = 0;
4178 : 23 : c->type.n_min = 0;
4179 : 23 : c->type.n_max = UINT_MAX;
4180 : 23 : c->mutable = true;
4181 : 23 : c->parse = idltest_simple2_parse_smap;
4182 : 23 : c->unparse = idltest_simple2_unparse_smap;
4183 : 23 : }
4184 : :
4185 : : /* simple3 table. */
4186 : :
4187 : : static void
4188 : 7 : idltest_simple3_parse_name(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
4189 : : {
4190 : 7 : struct idltest_simple3 *row = idltest_simple3_cast(row_);
4191 : :
4192 [ - + ]: 7 : ovs_assert(inited);
4193 [ + - ]: 7 : if (datum->n >= 1) {
4194 : 7 : row->name = datum->keys[0].string;
4195 : : } else {
4196 : 0 : row->name = "";
4197 : : }
4198 : 7 : }
4199 : :
4200 : : static void
4201 : 6 : idltest_simple3_parse_uref(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
4202 : : {
4203 : 6 : struct idltest_simple3 *row = idltest_simple3_cast(row_);
4204 : : size_t i;
4205 : :
4206 [ - + ]: 6 : ovs_assert(inited);
4207 : 6 : row->uref = NULL;
4208 : 6 : row->n_uref = 0;
4209 [ + + ]: 7 : for (i = 0; i < datum->n; i++) {
4210 : 1 : struct idltest_simple4 *keyRow = idltest_simple4_cast(ovsdb_idl_get_row_arc(row_, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4], &datum->keys[i].uuid));
4211 [ + - ]: 1 : if (keyRow) {
4212 [ + - ]: 1 : if (!row->n_uref) {
4213 : 1 : row->uref = xmalloc(datum->n * sizeof *row->uref);
4214 : : }
4215 : 1 : row->uref[row->n_uref] = keyRow;
4216 : 1 : row->n_uref++;
4217 : : }
4218 : : }
4219 : 6 : }
4220 : :
4221 : : static void
4222 : 6 : idltest_simple3_parse_uset(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
4223 : : {
4224 : 6 : struct idltest_simple3 *row = idltest_simple3_cast(row_);
4225 : : size_t i;
4226 : :
4227 [ - + ]: 6 : ovs_assert(inited);
4228 : 6 : row->uset = NULL;
4229 : 6 : row->n_uset = 0;
4230 [ + + ]: 23 : for (i = 0; i < datum->n; i++) {
4231 [ + + ]: 17 : if (!row->n_uset) {
4232 : 6 : row->uset = xmalloc(datum->n * sizeof *row->uset);
4233 : : }
4234 : 17 : row->uset[row->n_uset] = datum->keys[i].uuid;
4235 : 17 : row->n_uset++;
4236 : : }
4237 : 6 : }
4238 : :
4239 : : static void
4240 : 6 : idltest_simple3_unparse_name(struct ovsdb_idl_row *row OVS_UNUSED)
4241 : : {
4242 : : /* Nothing to do. */
4243 : 6 : }
4244 : :
4245 : : static void
4246 : 5 : idltest_simple3_unparse_uref(struct ovsdb_idl_row *row_)
4247 : : {
4248 : 5 : struct idltest_simple3 *row = idltest_simple3_cast(row_);
4249 : :
4250 [ - + ]: 5 : ovs_assert(inited);
4251 : 5 : free(row->uref);
4252 : 5 : }
4253 : :
4254 : : static void
4255 : 5 : idltest_simple3_unparse_uset(struct ovsdb_idl_row *row_)
4256 : : {
4257 : 5 : struct idltest_simple3 *row = idltest_simple3_cast(row_);
4258 : :
4259 [ - + ]: 5 : ovs_assert(inited);
4260 : 5 : free(row->uset);
4261 : 5 : }
4262 : :
4263 : : static void
4264 : 1 : idltest_simple3_init__(struct ovsdb_idl_row *row)
4265 : : {
4266 : 1 : idltest_simple3_init(idltest_simple3_cast(row));
4267 : 1 : }
4268 : :
4269 : : /* Clears the contents of 'row' in table "simple3". */
4270 : : void
4271 : 1 : idltest_simple3_init(struct idltest_simple3 *row)
4272 : : {
4273 : 1 : memset(row, 0, sizeof *row);
4274 : 1 : }
4275 : :
4276 : : /* Searches table "simple3" in 'idl' for a row with UUID 'uuid'. Returns
4277 : : * a pointer to the row if there is one, otherwise a null pointer. */
4278 : : const struct idltest_simple3 *
4279 : 0 : idltest_simple3_get_for_uuid(const struct ovsdb_idl *idl, const struct uuid *uuid)
4280 : : {
4281 : 0 : return idltest_simple3_cast(ovsdb_idl_get_row_for_uuid(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3], uuid));
4282 : : }
4283 : :
4284 : : /* Returns a row in table "simple3" in 'idl', or a null pointer if that
4285 : : * table is empty.
4286 : : *
4287 : : * Database tables are internally maintained as hash tables, so adding or
4288 : : * removing rows while traversing the same table can cause some rows to be
4289 : : * visited twice or not at apply. */
4290 : : const struct idltest_simple3 *
4291 : 10 : idltest_simple3_first(const struct ovsdb_idl *idl)
4292 : : {
4293 : 10 : return idltest_simple3_cast(ovsdb_idl_first_row(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3]));
4294 : : }
4295 : :
4296 : : /* Returns a row following 'row' within its table, or a null pointer if 'row'
4297 : : * is the last row in its table. */
4298 : : const struct idltest_simple3 *
4299 : 6 : idltest_simple3_next(const struct idltest_simple3 *row)
4300 : : {
4301 : 6 : return idltest_simple3_cast(ovsdb_idl_next_row(&row->header_));
4302 : : }
4303 : :
4304 : 0 : unsigned int idltest_simple3_get_seqno(const struct ovsdb_idl *idl)
4305 : : {
4306 : 0 : return ovsdb_idl_table_get_seqno(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3]);
4307 : : }
4308 : :
4309 : 0 : unsigned int idltest_simple3_row_get_seqno(const struct idltest_simple3 *row, enum ovsdb_idl_change change)
4310 : : {
4311 : 0 : return ovsdb_idl_row_get_seqno(&row->header_, change);
4312 : : }
4313 : :
4314 : : const struct idltest_simple3 *
4315 : 0 : idltest_simple3_track_get_first(const struct ovsdb_idl *idl)
4316 : : {
4317 : 0 : return idltest_simple3_cast(ovsdb_idl_track_get_first(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3]));
4318 : : }
4319 : :
4320 : : const struct idltest_simple3
4321 : 0 : *idltest_simple3_track_get_next(const struct idltest_simple3 *row)
4322 : : {
4323 : 0 : return idltest_simple3_cast(ovsdb_idl_track_get_next(&row->header_));
4324 : : }
4325 : :
4326 : :
4327 : : /* Deletes 'row' from table "simple3". 'row' may be freed, so it must not be
4328 : : * accessed afterward.
4329 : : *
4330 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
4331 : : void
4332 : 0 : idltest_simple3_delete(const struct idltest_simple3 *row)
4333 : : {
4334 : 0 : ovsdb_idl_txn_delete(&row->header_);
4335 : 0 : }
4336 : :
4337 : : /* Inserts and returns a new row in the table "simple3" in the database
4338 : : * with open transaction 'txn'.
4339 : : *
4340 : : * The new row is assigned a randomly generated provisional UUID.
4341 : : * ovsdb-server will assign a different UUID when 'txn' is committed,
4342 : : * but the IDL will replace any uses of the provisional UUID in the
4343 : : * data to be to be committed by the UUID assigned by ovsdb-server. */
4344 : : struct idltest_simple3 *
4345 : 0 : idltest_simple3_insert(struct ovsdb_idl_txn *txn)
4346 : : {
4347 : 0 : return idltest_simple3_cast(ovsdb_idl_txn_insert(txn, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3], NULL));
4348 : : }
4349 : :
4350 : : bool
4351 : 0 : idltest_simple3_is_updated(const struct idltest_simple3 *row, enum idltest_simple3_column_id column)
4352 : : {
4353 : 0 : return ovsdb_idl_track_is_updated(&row->header_, &idltest_simple3_columns[column]);
4354 : : }
4355 : :
4356 : : /* Causes the original contents of column "name" in 'row' to be
4357 : : * verified as a prerequisite to completing the transaction. That is, if
4358 : : * "name" in 'row' changed (or if 'row' was deleted) between the
4359 : : * time that the IDL originally read its contents and the time that the
4360 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
4361 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
4362 : : * change has already been received).
4363 : : *
4364 : : * The intention is that, to ensure that no transaction commits based on dirty
4365 : : * reads, an application should call this function any time "name" is
4366 : : * read as part of a read-modify-write operation.
4367 : : *
4368 : : * In some cases this function reduces to a no-op, because the current value
4369 : : * of "name" is already known:
4370 : : *
4371 : : * - If 'row' is a row created by the current transaction (returned by
4372 : : * idltest_simple3_insert()).
4373 : : *
4374 : : * - If "name" has already been modified (with
4375 : : * idltest_simple3_set_name()) within the current transaction.
4376 : : *
4377 : : * Because of the latter property, always call this function *before*
4378 : : * idltest_simple3_set_name() for a given read-modify-write.
4379 : : *
4380 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
4381 : : void
4382 : 0 : idltest_simple3_verify_name(const struct idltest_simple3 *row)
4383 : : {
4384 [ # # ]: 0 : ovs_assert(inited);
4385 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_NAME]);
4386 : 0 : }
4387 : :
4388 : : /* Causes the original contents of column "uref" in 'row' to be
4389 : : * verified as a prerequisite to completing the transaction. That is, if
4390 : : * "uref" in 'row' changed (or if 'row' was deleted) between the
4391 : : * time that the IDL originally read its contents and the time that the
4392 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
4393 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
4394 : : * change has already been received).
4395 : : *
4396 : : * The intention is that, to ensure that no transaction commits based on dirty
4397 : : * reads, an application should call this function any time "uref" is
4398 : : * read as part of a read-modify-write operation.
4399 : : *
4400 : : * In some cases this function reduces to a no-op, because the current value
4401 : : * of "uref" is already known:
4402 : : *
4403 : : * - If 'row' is a row created by the current transaction (returned by
4404 : : * idltest_simple3_insert()).
4405 : : *
4406 : : * - If "uref" has already been modified (with
4407 : : * idltest_simple3_set_uref()) within the current transaction.
4408 : : *
4409 : : * Because of the latter property, always call this function *before*
4410 : : * idltest_simple3_set_uref() for a given read-modify-write.
4411 : : *
4412 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
4413 : : void
4414 : 0 : idltest_simple3_verify_uref(const struct idltest_simple3 *row)
4415 : : {
4416 [ # # ]: 0 : ovs_assert(inited);
4417 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_UREF]);
4418 : 0 : }
4419 : :
4420 : : /* Causes the original contents of column "uset" in 'row' to be
4421 : : * verified as a prerequisite to completing the transaction. That is, if
4422 : : * "uset" in 'row' changed (or if 'row' was deleted) between the
4423 : : * time that the IDL originally read its contents and the time that the
4424 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
4425 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
4426 : : * change has already been received).
4427 : : *
4428 : : * The intention is that, to ensure that no transaction commits based on dirty
4429 : : * reads, an application should call this function any time "uset" is
4430 : : * read as part of a read-modify-write operation.
4431 : : *
4432 : : * In some cases this function reduces to a no-op, because the current value
4433 : : * of "uset" is already known:
4434 : : *
4435 : : * - If 'row' is a row created by the current transaction (returned by
4436 : : * idltest_simple3_insert()).
4437 : : *
4438 : : * - If "uset" has already been modified (with
4439 : : * idltest_simple3_set_uset()) within the current transaction.
4440 : : *
4441 : : * Because of the latter property, always call this function *before*
4442 : : * idltest_simple3_set_uset() for a given read-modify-write.
4443 : : *
4444 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
4445 : : void
4446 : 0 : idltest_simple3_verify_uset(const struct idltest_simple3 *row)
4447 : : {
4448 [ # # ]: 0 : ovs_assert(inited);
4449 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_USET]);
4450 : 0 : }
4451 : :
4452 : : /* Returns the "name" column's value from the "simple3" table in 'row'
4453 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
4454 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
4455 : : * for a given key than implementing the same operation on the "cooked"
4456 : : * form in 'row'.
4457 : : *
4458 : : * 'key_type' must be OVSDB_TYPE_STRING.
4459 : : * (This helps to avoid silent bugs if someone changes name's
4460 : : * type without updating the caller.)
4461 : : *
4462 : : * The caller must not modify or free the returned value.
4463 : : *
4464 : : * Various kinds of changes can invalidate the returned value: modifying
4465 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
4466 : : * If the returned value is needed for a long time, it is best to make a copy
4467 : : * of it with ovsdb_datum_clone().
4468 : : *
4469 : : * This function is rarely useful, since it is easier to access the value
4470 : : * directly through the "name" member in idltest_simple3. */
4471 : : const struct ovsdb_datum *
4472 : 0 : idltest_simple3_get_name(const struct idltest_simple3 *row,
4473 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
4474 : : {
4475 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_STRING);
4476 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple3_col_name);
4477 : : }
4478 : :
4479 : : /* Returns the "uref" column's value from the "simple3" table in 'row'
4480 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
4481 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
4482 : : * for a given key than implementing the same operation on the "cooked"
4483 : : * form in 'row'.
4484 : : *
4485 : : * 'key_type' must be OVSDB_TYPE_UUID.
4486 : : * (This helps to avoid silent bugs if someone changes uref's
4487 : : * type without updating the caller.)
4488 : : *
4489 : : * The caller must not modify or free the returned value.
4490 : : *
4491 : : * Various kinds of changes can invalidate the returned value: modifying
4492 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
4493 : : * If the returned value is needed for a long time, it is best to make a copy
4494 : : * of it with ovsdb_datum_clone().
4495 : : *
4496 : : * This function is rarely useful, since it is easier to access the value
4497 : : * directly through the "uref" member in idltest_simple3. */
4498 : : const struct ovsdb_datum *
4499 : 6 : idltest_simple3_get_uref(const struct idltest_simple3 *row,
4500 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
4501 : : {
4502 [ - + ]: 6 : ovs_assert(key_type == OVSDB_TYPE_UUID);
4503 : 6 : return ovsdb_idl_read(&row->header_, &idltest_simple3_col_uref);
4504 : : }
4505 : :
4506 : : /* Returns the "uset" column's value from the "simple3" table in 'row'
4507 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
4508 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
4509 : : * for a given key than implementing the same operation on the "cooked"
4510 : : * form in 'row'.
4511 : : *
4512 : : * 'key_type' must be OVSDB_TYPE_UUID.
4513 : : * (This helps to avoid silent bugs if someone changes uset's
4514 : : * type without updating the caller.)
4515 : : *
4516 : : * The caller must not modify or free the returned value.
4517 : : *
4518 : : * Various kinds of changes can invalidate the returned value: modifying
4519 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
4520 : : * If the returned value is needed for a long time, it is best to make a copy
4521 : : * of it with ovsdb_datum_clone().
4522 : : *
4523 : : * This function is rarely useful, since it is easier to access the value
4524 : : * directly through the "uset" member in idltest_simple3. */
4525 : : const struct ovsdb_datum *
4526 : 8 : idltest_simple3_get_uset(const struct idltest_simple3 *row,
4527 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
4528 : : {
4529 [ - + ]: 8 : ovs_assert(key_type == OVSDB_TYPE_UUID);
4530 : 8 : return ovsdb_idl_read(&row->header_, &idltest_simple3_col_uset);
4531 : : }
4532 : :
4533 : : /* Sets the "name" column from the "simple3" table in 'row' to
4534 : : * 'name'.
4535 : : *
4536 : : * The caller retains ownership of the arguments. */
4537 : : void
4538 : 1 : idltest_simple3_set_name(const struct idltest_simple3 *row, const char *name)
4539 : : {
4540 : : struct ovsdb_datum datum;
4541 : : union ovsdb_atom key;
4542 : :
4543 [ - + ]: 1 : ovs_assert(inited);
4544 : 1 : datum.n = 1;
4545 : 1 : datum.keys = &key;
4546 : 1 : key.string = CONST_CAST(char *, name);
4547 : 1 : datum.values = NULL;
4548 : 1 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_NAME], &datum);
4549 : 1 : }
4550 : :
4551 : : /* Sets the "uref" column from the "simple3" table in 'row' to
4552 : : * the 'uref' set with 'n_uref' entries.
4553 : : *
4554 : : * The caller retains ownership of the arguments. */
4555 : : void
4556 : 0 : idltest_simple3_set_uref(const struct idltest_simple3 *row, struct idltest_simple4 **uref, size_t n_uref)
4557 : : {
4558 : : struct ovsdb_datum datum;
4559 : : size_t i;
4560 : :
4561 [ # # ]: 0 : ovs_assert(inited);
4562 : 0 : datum.n = n_uref;
4563 [ # # ]: 0 : datum.keys = n_uref ? xmalloc(n_uref * sizeof *datum.keys) : NULL;
4564 : 0 : datum.values = NULL;
4565 [ # # ]: 0 : for (i = 0; i < n_uref; i++) {
4566 : 0 : datum.keys[i].uuid = uref[i]->header_.uuid;
4567 : : }
4568 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
4569 : 0 : ovsdb_idl_txn_write(&row->header_, &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_UREF], &datum);
4570 : 0 : }
4571 : :
4572 : : /* Sets the "uset" column from the "simple3" table in 'row' to
4573 : : * the 'uset' set with 'n_uset' entries.
4574 : : *
4575 : : * The caller retains ownership of the arguments. */
4576 : : void
4577 : 0 : idltest_simple3_set_uset(const struct idltest_simple3 *row, const struct uuid *uset, size_t n_uset)
4578 : : {
4579 : : struct ovsdb_datum datum;
4580 : : size_t i;
4581 : :
4582 [ # # ]: 0 : ovs_assert(inited);
4583 : 0 : datum.n = n_uset;
4584 [ # # ]: 0 : datum.keys = n_uset ? xmalloc(n_uset * sizeof *datum.keys) : NULL;
4585 : 0 : datum.values = NULL;
4586 [ # # ]: 0 : for (i = 0; i < n_uset; i++) {
4587 : 0 : datum.keys[i].uuid = uset[i];
4588 : : }
4589 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
4590 : 0 : ovsdb_idl_txn_write(&row->header_, &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_USET], &datum);
4591 : 0 : }
4592 : :
4593 : : /* Adds the value 'new_value' to the "uref" set column from the "simple3" table
4594 : : * in 'row'.
4595 : : *
4596 : : */
4597 : : void
4598 : 1 : idltest_simple3_update_uref_addvalue(const struct idltest_simple3 *row, const struct idltest_simple4 *new_value)
4599 : : {
4600 : : struct ovsdb_datum *datum;
4601 : :
4602 [ - + ]: 1 : ovs_assert(inited);
4603 : :
4604 : 1 : datum = xmalloc(sizeof *datum);
4605 : 1 : datum->n = 1;
4606 : 1 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
4607 : 1 : datum->values = NULL;
4608 : :
4609 : 1 : datum->keys[0].uuid = new_value->header_.uuid;
4610 : :
4611 : 1 : ovsdb_idl_txn_write_partial_set(&row->header_,
4612 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_UREF],
4613 : : datum);
4614 : 1 : }
4615 : :
4616 : : /* Deletes the value 'delete_value' from the "uref" set column from the
4617 : : * "simple3" table in 'row'.
4618 : : *
4619 : : */
4620 : : void
4621 : 0 : idltest_simple3_update_uref_delvalue(const struct idltest_simple3 *row, const struct idltest_simple4 *delete_value)
4622 : : {
4623 : : struct ovsdb_datum *datum;
4624 : :
4625 [ # # ]: 0 : ovs_assert(inited);
4626 : :
4627 : 0 : datum = xmalloc(sizeof *datum);
4628 : 0 : datum->n = 1;
4629 : 0 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
4630 : 0 : datum->values = NULL;
4631 : :
4632 : 0 : datum->keys[0].uuid = delete_value->header_.uuid;
4633 : :
4634 : 0 : ovsdb_idl_txn_delete_partial_set(&row->header_,
4635 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_UREF],
4636 : : datum);
4637 : 0 : }
4638 : :
4639 : : /* Adds the value 'new_value' to the "uset" set column from the "simple3" table
4640 : : * in 'row'.
4641 : : *
4642 : : */
4643 : : void
4644 : 2 : idltest_simple3_update_uset_addvalue(const struct idltest_simple3 *row, struct uuid new_value)
4645 : : {
4646 : : struct ovsdb_datum *datum;
4647 : :
4648 [ - + ]: 2 : ovs_assert(inited);
4649 : :
4650 : 2 : datum = xmalloc(sizeof *datum);
4651 : 2 : datum->n = 1;
4652 : 2 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
4653 : 2 : datum->values = NULL;
4654 : :
4655 : 2 : datum->keys[0].uuid = new_value;
4656 : :
4657 : 2 : ovsdb_idl_txn_write_partial_set(&row->header_,
4658 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_USET],
4659 : : datum);
4660 : 2 : }
4661 : :
4662 : : /* Deletes the value 'delete_value' from the "uset" set column from the
4663 : : * "simple3" table in 'row'.
4664 : : *
4665 : : */
4666 : : void
4667 : 2 : idltest_simple3_update_uset_delvalue(const struct idltest_simple3 *row, struct uuid delete_value)
4668 : : {
4669 : : struct ovsdb_datum *datum;
4670 : :
4671 [ - + ]: 2 : ovs_assert(inited);
4672 : :
4673 : 2 : datum = xmalloc(sizeof *datum);
4674 : 2 : datum->n = 1;
4675 : 2 : datum->keys = xmalloc(datum->n * sizeof *datum->values);
4676 : 2 : datum->values = NULL;
4677 : :
4678 : 2 : datum->keys[0].uuid = delete_value;
4679 : :
4680 : 2 : ovsdb_idl_txn_delete_partial_set(&row->header_,
4681 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_USET],
4682 : : datum);
4683 : 2 : }
4684 : :
4685 : : /* Sets the "name" column from the "simple3" table in 'row' to
4686 : : * 'name'.
4687 : : *
4688 : : * The caller retains ownership of the arguments. */
4689 : : void
4690 : 0 : idltest_simple3_add_clause_name(struct ovsdb_idl *idl, enum ovsdb_function function, const char *name)
4691 : : {
4692 : : struct ovsdb_datum datum;
4693 : : union ovsdb_atom key;
4694 : :
4695 [ # # ]: 0 : ovs_assert(inited);
4696 : 0 : datum.n = 1;
4697 : 0 : datum.keys = &key;
4698 : 0 : key.string = CONST_CAST(char *, name);
4699 : 0 : datum.values = NULL;
4700 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3],
4701 : : function,
4702 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_NAME],
4703 : : &datum);
4704 : 0 : }
4705 : :
4706 : : /* Sets the "uref" column from the "simple3" table in 'row' to
4707 : : * the 'uref' set with 'n_uref' entries.
4708 : : *
4709 : : * The caller retains ownership of the arguments. */
4710 : : void
4711 : 0 : idltest_simple3_add_clause_uref(struct ovsdb_idl *idl, enum ovsdb_function function, struct uuid **uref, size_t n_uref)
4712 : : {
4713 : : struct ovsdb_datum datum;
4714 : : size_t i;
4715 : :
4716 [ # # ]: 0 : ovs_assert(inited);
4717 : 0 : datum.n = n_uref;
4718 [ # # ]: 0 : datum.keys = n_uref ? xmalloc(n_uref * sizeof *datum.keys) : NULL;
4719 : 0 : datum.values = NULL;
4720 [ # # ]: 0 : for (i = 0; i < n_uref; i++) {
4721 : 0 : datum.keys[i].uuid = *uref[i];
4722 : : }
4723 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
4724 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3],
4725 : : function,
4726 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_UREF],
4727 : : &datum);
4728 : 0 : free(datum.keys);
4729 : 0 : }
4730 : :
4731 : : /* Sets the "uset" column from the "simple3" table in 'row' to
4732 : : * the 'uset' set with 'n_uset' entries.
4733 : : *
4734 : : * The caller retains ownership of the arguments. */
4735 : : void
4736 : 0 : idltest_simple3_add_clause_uset(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *uset, size_t n_uset)
4737 : : {
4738 : : struct ovsdb_datum datum;
4739 : : size_t i;
4740 : :
4741 [ # # ]: 0 : ovs_assert(inited);
4742 : 0 : datum.n = n_uset;
4743 [ # # ]: 0 : datum.keys = n_uset ? xmalloc(n_uset * sizeof *datum.keys) : NULL;
4744 : 0 : datum.values = NULL;
4745 [ # # ]: 0 : for (i = 0; i < n_uset; i++) {
4746 : 0 : datum.keys[i].uuid = uset[i];
4747 : : }
4748 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
4749 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3],
4750 : : function,
4751 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_USET],
4752 : : &datum);
4753 : 0 : free(datum.keys);
4754 : 0 : }
4755 : : void
4756 : 0 : idltest_simple3_add_clause_false(struct ovsdb_idl *idl)
4757 : : {
4758 : : struct ovsdb_datum datum;
4759 : :
4760 : 0 : ovsdb_datum_init_empty(&datum);
4761 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3], OVSDB_F_FALSE, NULL, &datum);
4762 : 0 : }
4763 : : void
4764 : 0 : idltest_simple3_add_clause_true(struct ovsdb_idl *idl)
4765 : : {
4766 : : struct ovsdb_datum datum;
4767 : :
4768 : 0 : ovsdb_datum_init_empty(&datum);
4769 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3], OVSDB_F_TRUE, NULL, &datum);
4770 : 0 : }
4771 : :
4772 : : /* Sets the "name" column from the "simple3" table in 'row' to
4773 : : * 'name'.
4774 : : *
4775 : : * The caller retains ownership of the arguments. */
4776 : : void
4777 : 0 : idltest_simple3_remove_clause_name(struct ovsdb_idl *idl, enum ovsdb_function function, const char *name)
4778 : : {
4779 : : struct ovsdb_datum datum;
4780 : : union ovsdb_atom key;
4781 : :
4782 [ # # ]: 0 : ovs_assert(inited);
4783 : 0 : datum.n = 1;
4784 : 0 : datum.keys = &key;
4785 : 0 : key.string = CONST_CAST(char *, name);
4786 : 0 : datum.values = NULL;
4787 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3],
4788 : : function,
4789 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_NAME],
4790 : : &datum);
4791 : 0 : }
4792 : :
4793 : : /* Sets the "uref" column from the "simple3" table in 'row' to
4794 : : * the 'uref' set with 'n_uref' entries.
4795 : : *
4796 : : * The caller retains ownership of the arguments. */
4797 : : void
4798 : 0 : idltest_simple3_remove_clause_uref(struct ovsdb_idl *idl, enum ovsdb_function function, struct uuid **uref, size_t n_uref)
4799 : : {
4800 : : struct ovsdb_datum datum;
4801 : : size_t i;
4802 : :
4803 [ # # ]: 0 : ovs_assert(inited);
4804 : 0 : datum.n = n_uref;
4805 [ # # ]: 0 : datum.keys = n_uref ? xmalloc(n_uref * sizeof *datum.keys) : NULL;
4806 : 0 : datum.values = NULL;
4807 [ # # ]: 0 : for (i = 0; i < n_uref; i++) {
4808 : 0 : datum.keys[i].uuid = *uref[i];
4809 : : }
4810 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
4811 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3],
4812 : : function,
4813 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_UREF],
4814 : : &datum);
4815 : 0 : free(datum.keys);
4816 : 0 : }
4817 : :
4818 : : /* Sets the "uset" column from the "simple3" table in 'row' to
4819 : : * the 'uset' set with 'n_uset' entries.
4820 : : *
4821 : : * The caller retains ownership of the arguments. */
4822 : : void
4823 : 0 : idltest_simple3_remove_clause_uset(struct ovsdb_idl *idl, enum ovsdb_function function, const struct uuid *uset, size_t n_uset)
4824 : : {
4825 : : struct ovsdb_datum datum;
4826 : : size_t i;
4827 : :
4828 [ # # ]: 0 : ovs_assert(inited);
4829 : 0 : datum.n = n_uset;
4830 [ # # ]: 0 : datum.keys = n_uset ? xmalloc(n_uset * sizeof *datum.keys) : NULL;
4831 : 0 : datum.values = NULL;
4832 [ # # ]: 0 : for (i = 0; i < n_uset; i++) {
4833 : 0 : datum.keys[i].uuid = uset[i];
4834 : : }
4835 : 0 : ovsdb_datum_sort_unique(&datum, OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
4836 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3],
4837 : : function,
4838 : : &idltest_simple3_columns[IDLTEST_SIMPLE3_COL_USET],
4839 : : &datum);
4840 : 0 : free(datum.keys);
4841 : 0 : }
4842 : : void
4843 : 0 : idltest_simple3_remove_clause_false(struct ovsdb_idl *idl)
4844 : : {
4845 : : struct ovsdb_datum datum;
4846 : :
4847 : 0 : ovsdb_datum_init_empty(&datum);
4848 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3], OVSDB_F_FALSE, NULL, &datum);
4849 : 0 : }
4850 : : void
4851 : 0 : idltest_simple3_remove_clause_true(struct ovsdb_idl *idl)
4852 : : {
4853 : : struct ovsdb_datum datum;
4854 : :
4855 : 0 : ovsdb_datum_init_empty(&datum);
4856 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE3], OVSDB_F_TRUE, NULL, &datum);
4857 : 0 : }
4858 : :
4859 : : struct ovsdb_idl_column idltest_simple3_columns[IDLTEST_SIMPLE3_N_COLUMNS];
4860 : :
4861 : : static void
4862 : 23 : idltest_simple3_columns_init(void)
4863 : : {
4864 : : struct ovsdb_idl_column *c;
4865 : :
4866 : : /* Initialize idltest_simple3_col_name. */
4867 : 23 : c = &idltest_simple3_col_name;
4868 : 23 : c->name = "name";
4869 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_STRING);
4870 : 23 : c->type.key.u.string.minLen = 0;
4871 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
4872 : 23 : c->type.n_min = 1;
4873 : 23 : c->type.n_max = 1;
4874 : 23 : c->mutable = true;
4875 : 23 : c->parse = idltest_simple3_parse_name;
4876 : 23 : c->unparse = idltest_simple3_unparse_name;
4877 : :
4878 : : /* Initialize idltest_simple3_col_uref. */
4879 : 23 : c = &idltest_simple3_col_uref;
4880 : 23 : c->name = "uref";
4881 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_UUID);
4882 : 23 : c->type.key.u.uuid.refTableName = "simple4";
4883 : 23 : c->type.key.u.uuid.refType = OVSDB_REF_STRONG;
4884 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
4885 : 23 : c->type.n_min = 0;
4886 : 23 : c->type.n_max = UINT_MAX;
4887 : 23 : c->mutable = true;
4888 : 23 : c->parse = idltest_simple3_parse_uref;
4889 : 23 : c->unparse = idltest_simple3_unparse_uref;
4890 : :
4891 : : /* Initialize idltest_simple3_col_uset. */
4892 : 23 : c = &idltest_simple3_col_uset;
4893 : 23 : c->name = "uset";
4894 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_UUID);
4895 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
4896 : 23 : c->type.n_min = 0;
4897 : 23 : c->type.n_max = UINT_MAX;
4898 : 23 : c->mutable = true;
4899 : 23 : c->parse = idltest_simple3_parse_uset;
4900 : 23 : c->unparse = idltest_simple3_unparse_uset;
4901 : 23 : }
4902 : :
4903 : : /* simple4 table. */
4904 : :
4905 : : static void
4906 : 2 : idltest_simple4_parse_name(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum)
4907 : : {
4908 : 2 : struct idltest_simple4 *row = idltest_simple4_cast(row_);
4909 : :
4910 [ - + ]: 2 : ovs_assert(inited);
4911 [ + - ]: 2 : if (datum->n >= 1) {
4912 : 2 : row->name = datum->keys[0].string;
4913 : : } else {
4914 : 0 : row->name = "";
4915 : : }
4916 : 2 : }
4917 : :
4918 : : static void
4919 : 2 : idltest_simple4_unparse_name(struct ovsdb_idl_row *row OVS_UNUSED)
4920 : : {
4921 : : /* Nothing to do. */
4922 : 2 : }
4923 : :
4924 : : static void
4925 : 2 : idltest_simple4_init__(struct ovsdb_idl_row *row)
4926 : : {
4927 : 2 : idltest_simple4_init(idltest_simple4_cast(row));
4928 : 2 : }
4929 : :
4930 : : /* Clears the contents of 'row' in table "simple4". */
4931 : : void
4932 : 2 : idltest_simple4_init(struct idltest_simple4 *row)
4933 : : {
4934 : 2 : memset(row, 0, sizeof *row);
4935 : 2 : }
4936 : :
4937 : : /* Searches table "simple4" in 'idl' for a row with UUID 'uuid'. Returns
4938 : : * a pointer to the row if there is one, otherwise a null pointer. */
4939 : : const struct idltest_simple4 *
4940 : 0 : idltest_simple4_get_for_uuid(const struct ovsdb_idl *idl, const struct uuid *uuid)
4941 : : {
4942 : 0 : return idltest_simple4_cast(ovsdb_idl_get_row_for_uuid(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4], uuid));
4943 : : }
4944 : :
4945 : : /* Returns a row in table "simple4" in 'idl', or a null pointer if that
4946 : : * table is empty.
4947 : : *
4948 : : * Database tables are internally maintained as hash tables, so adding or
4949 : : * removing rows while traversing the same table can cause some rows to be
4950 : : * visited twice or not at apply. */
4951 : : const struct idltest_simple4 *
4952 : 0 : idltest_simple4_first(const struct ovsdb_idl *idl)
4953 : : {
4954 : 0 : return idltest_simple4_cast(ovsdb_idl_first_row(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4]));
4955 : : }
4956 : :
4957 : : /* Returns a row following 'row' within its table, or a null pointer if 'row'
4958 : : * is the last row in its table. */
4959 : : const struct idltest_simple4 *
4960 : 0 : idltest_simple4_next(const struct idltest_simple4 *row)
4961 : : {
4962 : 0 : return idltest_simple4_cast(ovsdb_idl_next_row(&row->header_));
4963 : : }
4964 : :
4965 : 0 : unsigned int idltest_simple4_get_seqno(const struct ovsdb_idl *idl)
4966 : : {
4967 : 0 : return ovsdb_idl_table_get_seqno(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4]);
4968 : : }
4969 : :
4970 : 0 : unsigned int idltest_simple4_row_get_seqno(const struct idltest_simple4 *row, enum ovsdb_idl_change change)
4971 : : {
4972 : 0 : return ovsdb_idl_row_get_seqno(&row->header_, change);
4973 : : }
4974 : :
4975 : : const struct idltest_simple4 *
4976 : 0 : idltest_simple4_track_get_first(const struct ovsdb_idl *idl)
4977 : : {
4978 : 0 : return idltest_simple4_cast(ovsdb_idl_track_get_first(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4]));
4979 : : }
4980 : :
4981 : : const struct idltest_simple4
4982 : 0 : *idltest_simple4_track_get_next(const struct idltest_simple4 *row)
4983 : : {
4984 : 0 : return idltest_simple4_cast(ovsdb_idl_track_get_next(&row->header_));
4985 : : }
4986 : :
4987 : :
4988 : : /* Deletes 'row' from table "simple4". 'row' may be freed, so it must not be
4989 : : * accessed afterward.
4990 : : *
4991 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
4992 : : void
4993 : 0 : idltest_simple4_delete(const struct idltest_simple4 *row)
4994 : : {
4995 : 0 : ovsdb_idl_txn_delete(&row->header_);
4996 : 0 : }
4997 : :
4998 : : /* Inserts and returns a new row in the table "simple4" in the database
4999 : : * with open transaction 'txn'.
5000 : : *
5001 : : * The new row is assigned a randomly generated provisional UUID.
5002 : : * ovsdb-server will assign a different UUID when 'txn' is committed,
5003 : : * but the IDL will replace any uses of the provisional UUID in the
5004 : : * data to be to be committed by the UUID assigned by ovsdb-server. */
5005 : : struct idltest_simple4 *
5006 : 1 : idltest_simple4_insert(struct ovsdb_idl_txn *txn)
5007 : : {
5008 : 1 : return idltest_simple4_cast(ovsdb_idl_txn_insert(txn, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4], NULL));
5009 : : }
5010 : :
5011 : : bool
5012 : 0 : idltest_simple4_is_updated(const struct idltest_simple4 *row, enum idltest_simple4_column_id column)
5013 : : {
5014 : 0 : return ovsdb_idl_track_is_updated(&row->header_, &idltest_simple4_columns[column]);
5015 : : }
5016 : :
5017 : : /* Causes the original contents of column "name" in 'row' to be
5018 : : * verified as a prerequisite to completing the transaction. That is, if
5019 : : * "name" in 'row' changed (or if 'row' was deleted) between the
5020 : : * time that the IDL originally read its contents and the time that the
5021 : : * transaction commits, then the transaction aborts and ovsdb_idl_txn_commit()
5022 : : * returns TXN_AGAIN_WAIT or TXN_AGAIN_NOW (depending on whether the database
5023 : : * change has already been received).
5024 : : *
5025 : : * The intention is that, to ensure that no transaction commits based on dirty
5026 : : * reads, an application should call this function any time "name" is
5027 : : * read as part of a read-modify-write operation.
5028 : : *
5029 : : * In some cases this function reduces to a no-op, because the current value
5030 : : * of "name" is already known:
5031 : : *
5032 : : * - If 'row' is a row created by the current transaction (returned by
5033 : : * idltest_simple4_insert()).
5034 : : *
5035 : : * - If "name" has already been modified (with
5036 : : * idltest_simple4_set_name()) within the current transaction.
5037 : : *
5038 : : * Because of the latter property, always call this function *before*
5039 : : * idltest_simple4_set_name() for a given read-modify-write.
5040 : : *
5041 : : * The caller must have started a transaction with ovsdb_idl_txn_create(). */
5042 : : void
5043 : 0 : idltest_simple4_verify_name(const struct idltest_simple4 *row)
5044 : : {
5045 [ # # ]: 0 : ovs_assert(inited);
5046 : 0 : ovsdb_idl_txn_verify(&row->header_, &idltest_simple4_columns[IDLTEST_SIMPLE4_COL_NAME]);
5047 : 0 : }
5048 : :
5049 : : /* Returns the "name" column's value from the "simple4" table in 'row'
5050 : : * as a struct ovsdb_datum. This is useful occasionally: for example,
5051 : : * ovsdb_datum_find_key() is an easier and more efficient way to search
5052 : : * for a given key than implementing the same operation on the "cooked"
5053 : : * form in 'row'.
5054 : : *
5055 : : * 'key_type' must be OVSDB_TYPE_STRING.
5056 : : * (This helps to avoid silent bugs if someone changes name's
5057 : : * type without updating the caller.)
5058 : : *
5059 : : * The caller must not modify or free the returned value.
5060 : : *
5061 : : * Various kinds of changes can invalidate the returned value: modifying
5062 : : * 'column' within 'row', deleting 'row', or completing an ongoing transaction.
5063 : : * If the returned value is needed for a long time, it is best to make a copy
5064 : : * of it with ovsdb_datum_clone().
5065 : : *
5066 : : * This function is rarely useful, since it is easier to access the value
5067 : : * directly through the "name" member in idltest_simple4. */
5068 : : const struct ovsdb_datum *
5069 : 0 : idltest_simple4_get_name(const struct idltest_simple4 *row,
5070 : : enum ovsdb_atomic_type key_type OVS_UNUSED)
5071 : : {
5072 [ # # ]: 0 : ovs_assert(key_type == OVSDB_TYPE_STRING);
5073 : 0 : return ovsdb_idl_read(&row->header_, &idltest_simple4_col_name);
5074 : : }
5075 : :
5076 : : /* Sets the "name" column from the "simple4" table in 'row' to
5077 : : * 'name'.
5078 : : *
5079 : : * The caller retains ownership of the arguments. */
5080 : : void
5081 : 1 : idltest_simple4_set_name(const struct idltest_simple4 *row, const char *name)
5082 : : {
5083 : : struct ovsdb_datum datum;
5084 : : union ovsdb_atom key;
5085 : :
5086 [ - + ]: 1 : ovs_assert(inited);
5087 : 1 : datum.n = 1;
5088 : 1 : datum.keys = &key;
5089 : 1 : key.string = CONST_CAST(char *, name);
5090 : 1 : datum.values = NULL;
5091 : 1 : ovsdb_idl_txn_write_clone(&row->header_, &idltest_simple4_columns[IDLTEST_SIMPLE4_COL_NAME], &datum);
5092 : 1 : }
5093 : :
5094 : : /* Sets the "name" column from the "simple4" table in 'row' to
5095 : : * 'name'.
5096 : : *
5097 : : * The caller retains ownership of the arguments. */
5098 : : void
5099 : 0 : idltest_simple4_add_clause_name(struct ovsdb_idl *idl, enum ovsdb_function function, const char *name)
5100 : : {
5101 : : struct ovsdb_datum datum;
5102 : : union ovsdb_atom key;
5103 : :
5104 [ # # ]: 0 : ovs_assert(inited);
5105 : 0 : datum.n = 1;
5106 : 0 : datum.keys = &key;
5107 : 0 : key.string = CONST_CAST(char *, name);
5108 : 0 : datum.values = NULL;
5109 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4],
5110 : : function,
5111 : : &idltest_simple4_columns[IDLTEST_SIMPLE4_COL_NAME],
5112 : : &datum);
5113 : 0 : }
5114 : : void
5115 : 0 : idltest_simple4_add_clause_false(struct ovsdb_idl *idl)
5116 : : {
5117 : : struct ovsdb_datum datum;
5118 : :
5119 : 0 : ovsdb_datum_init_empty(&datum);
5120 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4], OVSDB_F_FALSE, NULL, &datum);
5121 : 0 : }
5122 : : void
5123 : 0 : idltest_simple4_add_clause_true(struct ovsdb_idl *idl)
5124 : : {
5125 : : struct ovsdb_datum datum;
5126 : :
5127 : 0 : ovsdb_datum_init_empty(&datum);
5128 : 0 : ovsdb_idl_condition_add_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4], OVSDB_F_TRUE, NULL, &datum);
5129 : 0 : }
5130 : :
5131 : : /* Sets the "name" column from the "simple4" table in 'row' to
5132 : : * 'name'.
5133 : : *
5134 : : * The caller retains ownership of the arguments. */
5135 : : void
5136 : 0 : idltest_simple4_remove_clause_name(struct ovsdb_idl *idl, enum ovsdb_function function, const char *name)
5137 : : {
5138 : : struct ovsdb_datum datum;
5139 : : union ovsdb_atom key;
5140 : :
5141 [ # # ]: 0 : ovs_assert(inited);
5142 : 0 : datum.n = 1;
5143 : 0 : datum.keys = &key;
5144 : 0 : key.string = CONST_CAST(char *, name);
5145 : 0 : datum.values = NULL;
5146 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4],
5147 : : function,
5148 : : &idltest_simple4_columns[IDLTEST_SIMPLE4_COL_NAME],
5149 : : &datum);
5150 : 0 : }
5151 : : void
5152 : 0 : idltest_simple4_remove_clause_false(struct ovsdb_idl *idl)
5153 : : {
5154 : : struct ovsdb_datum datum;
5155 : :
5156 : 0 : ovsdb_datum_init_empty(&datum);
5157 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4], OVSDB_F_FALSE, NULL, &datum);
5158 : 0 : }
5159 : : void
5160 : 0 : idltest_simple4_remove_clause_true(struct ovsdb_idl *idl)
5161 : : {
5162 : : struct ovsdb_datum datum;
5163 : :
5164 : 0 : ovsdb_datum_init_empty(&datum);
5165 : 0 : ovsdb_idl_condition_remove_clause(idl, &idltest_table_classes[IDLTEST_TABLE_SIMPLE4], OVSDB_F_TRUE, NULL, &datum);
5166 : 0 : }
5167 : :
5168 : : struct ovsdb_idl_column idltest_simple4_columns[IDLTEST_SIMPLE4_N_COLUMNS];
5169 : :
5170 : : static void
5171 : 23 : idltest_simple4_columns_init(void)
5172 : : {
5173 : : struct ovsdb_idl_column *c;
5174 : :
5175 : : /* Initialize idltest_simple4_col_name. */
5176 : 23 : c = &idltest_simple4_col_name;
5177 : 23 : c->name = "name";
5178 : 23 : ovsdb_base_type_init(&c->type.key, OVSDB_TYPE_STRING);
5179 : 23 : c->type.key.u.string.minLen = 0;
5180 : 23 : ovsdb_base_type_init(&c->type.value, OVSDB_TYPE_VOID);
5181 : 23 : c->type.n_min = 1;
5182 : 23 : c->type.n_max = 1;
5183 : 23 : c->mutable = true;
5184 : 23 : c->parse = idltest_simple4_parse_name;
5185 : 23 : c->unparse = idltest_simple4_unparse_name;
5186 : 23 : }
5187 : :
5188 : : struct ovsdb_idl_table_class idltest_table_classes[IDLTEST_N_TABLES] = {
5189 : : {"link1", true,
5190 : : idltest_link1_columns, ARRAY_SIZE(idltest_link1_columns),
5191 : : sizeof(struct idltest_link1), idltest_link1_init__},
5192 : : {"link2", true,
5193 : : idltest_link2_columns, ARRAY_SIZE(idltest_link2_columns),
5194 : : sizeof(struct idltest_link2), idltest_link2_init__},
5195 : : {"simple", true,
5196 : : idltest_simple_columns, ARRAY_SIZE(idltest_simple_columns),
5197 : : sizeof(struct idltest_simple), idltest_simple_init__},
5198 : : {"simple2", true,
5199 : : idltest_simple2_columns, ARRAY_SIZE(idltest_simple2_columns),
5200 : : sizeof(struct idltest_simple2), idltest_simple2_init__},
5201 : : {"simple3", true,
5202 : : idltest_simple3_columns, ARRAY_SIZE(idltest_simple3_columns),
5203 : : sizeof(struct idltest_simple3), idltest_simple3_init__},
5204 : : {"simple4", true,
5205 : : idltest_simple4_columns, ARRAY_SIZE(idltest_simple4_columns),
5206 : : sizeof(struct idltest_simple4), idltest_simple4_init__},
5207 : : };
5208 : :
5209 : : struct ovsdb_idl_class idltest_idl_class = {
5210 : : "idltest", idltest_table_classes, ARRAY_SIZE(idltest_table_classes)
5211 : : };
5212 : :
5213 : : void
5214 : 23 : idltest_init(void)
5215 : : {
5216 [ - + ]: 23 : if (inited) {
5217 : 0 : return;
5218 : : }
5219 : 23 : assert_single_threaded();
5220 : 23 : inited = true;
5221 : :
5222 : 23 : idltest_link1_columns_init();
5223 : 23 : idltest_link2_columns_init();
5224 : 23 : idltest_simple_columns_init();
5225 : 23 : idltest_simple2_columns_init();
5226 : 23 : idltest_simple3_columns_init();
5227 : 23 : idltest_simple4_columns_init();
5228 : : }
5229 : :
5230 : : /* Return the schema version. The caller must not free the returned value. */
5231 : : const char *
5232 : 0 : idltest_get_db_version(void)
5233 : : {
5234 : 0 : return "1.2.3";
5235 : : }
5236 : :
|