ovsdb-server: Fix various memory leaks.
[cascardo/ovs.git] / ovsdb / execution.c
1 /* Copyright (c) 2009, 2010 Nicira Networks
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <config.h>
17
18 #include <assert.h>
19 #include <limits.h>
20
21 #include "column.h"
22 #include "condition.h"
23 #include "file.h"
24 #include "json.h"
25 #include "mutation.h"
26 #include "ovsdb-data.h"
27 #include "ovsdb-error.h"
28 #include "ovsdb-parser.h"
29 #include "ovsdb.h"
30 #include "query.h"
31 #include "row.h"
32 #include "table.h"
33 #include "timeval.h"
34 #include "transaction.h"
35
36 struct ovsdb_execution {
37     struct ovsdb *db;
38     struct ovsdb_txn *txn;
39     struct ovsdb_symbol_table *symtab;
40     bool durable;
41
42     /* Triggers. */
43     long long int elapsed_msec;
44     long long int timeout_msec;
45 };
46
47 typedef struct ovsdb_error *ovsdb_operation_executor(struct ovsdb_execution *,
48                                                      struct ovsdb_parser *,
49                                                      struct json *result);
50
51 static ovsdb_operation_executor ovsdb_execute_insert;
52 static ovsdb_operation_executor ovsdb_execute_select;
53 static ovsdb_operation_executor ovsdb_execute_update;
54 static ovsdb_operation_executor ovsdb_execute_mutate;
55 static ovsdb_operation_executor ovsdb_execute_delete;
56 static ovsdb_operation_executor ovsdb_execute_wait;
57 static ovsdb_operation_executor ovsdb_execute_commit;
58 static ovsdb_operation_executor ovsdb_execute_abort;
59 static ovsdb_operation_executor ovsdb_execute_declare;
60 static ovsdb_operation_executor ovsdb_execute_comment;
61
62 static ovsdb_operation_executor *
63 lookup_executor(const char *name)
64 {
65     struct ovsdb_operation {
66         const char *name;
67         ovsdb_operation_executor *executor;
68     };
69
70     static const struct ovsdb_operation operations[] = {
71         { "insert", ovsdb_execute_insert },
72         { "select", ovsdb_execute_select },
73         { "update", ovsdb_execute_update },
74         { "mutate", ovsdb_execute_mutate },
75         { "delete", ovsdb_execute_delete },
76         { "wait", ovsdb_execute_wait },
77         { "commit", ovsdb_execute_commit },
78         { "abort", ovsdb_execute_abort },
79         { "declare", ovsdb_execute_declare },
80         { "comment", ovsdb_execute_comment },
81     };
82
83     size_t i;
84
85     for (i = 0; i < ARRAY_SIZE(operations); i++) {
86         const struct ovsdb_operation *c = &operations[i];
87         if (!strcmp(c->name, name)) {
88             return c->executor;
89         }
90     }
91     return NULL;
92 }
93
94 struct json *
95 ovsdb_execute(struct ovsdb *db, const struct json *params,
96               long long int elapsed_msec, long long int *timeout_msec)
97 {
98     struct ovsdb_execution x;
99     struct ovsdb_error *error;
100     struct json *results;
101     size_t n_operations;
102     size_t i;
103
104     if (params->type != JSON_ARRAY) {
105         struct ovsdb_error *error;
106
107         error = ovsdb_syntax_error(params, NULL, "array expected");
108         results = ovsdb_error_to_json(error);
109         ovsdb_error_destroy(error);
110         return results;
111     }
112
113     x.db = db;
114     x.txn = ovsdb_txn_create(db);
115     x.symtab = ovsdb_symbol_table_create();
116     x.durable = false;
117     x.elapsed_msec = elapsed_msec;
118     x.timeout_msec = LLONG_MAX;
119     results = NULL;
120
121     results = json_array_create_empty();
122     n_operations = params->u.array.n;
123     error = NULL;
124     for (i = 0; i < n_operations; i++) {
125         struct json *operation = params->u.array.elems[i];
126         struct ovsdb_error *parse_error;
127         struct ovsdb_parser parser;
128         struct json *result;
129         const struct json *op;
130
131         /* Parse and execute operation. */
132         ovsdb_parser_init(&parser, operation,
133                           "ovsdb operation %zu of %zu", i + 1, n_operations);
134         op = ovsdb_parser_member(&parser, "op", OP_ID);
135         result = json_object_create();
136         if (op) {
137             const char *op_name = json_string(op);
138             ovsdb_operation_executor *executor = lookup_executor(op_name);
139             if (executor) {
140                 error = executor(&x, &parser, result);
141             } else {
142                 ovsdb_parser_raise_error(&parser, "No operation \"%s\"",
143                                          op_name);
144             }
145         } else {
146             assert(ovsdb_parser_has_error(&parser));
147         }
148
149         /* A parse error overrides any other error.
150          * An error overrides any other result. */
151         parse_error = ovsdb_parser_finish(&parser);
152         if (parse_error) {
153             ovsdb_error_destroy(error);
154             error = parse_error;
155         }
156         if (error) {
157             json_destroy(result);
158             result = ovsdb_error_to_json(error);
159         }
160         if (error && !strcmp(ovsdb_error_get_tag(error), "not supported")
161             && timeout_msec) {
162             ovsdb_txn_abort(x.txn);
163             *timeout_msec = x.timeout_msec;
164
165             json_destroy(result);
166             json_destroy(results);
167             results = NULL;
168             goto exit;
169         }
170
171         /* Add result to array. */
172         json_array_add(results, result);
173         if (error) {
174             break;
175         }
176     }
177
178     if (!error) {
179         error = ovsdb_txn_commit(x.txn, x.durable);
180         if (error) {
181             json_array_add(results, ovsdb_error_to_json(error));
182         }
183     } else {
184         ovsdb_txn_abort(x.txn);
185     }
186
187     while (json_array(results)->n < n_operations) {
188         json_array_add(results, json_null_create());
189     }
190
191 exit:
192     ovsdb_error_destroy(error);
193     ovsdb_symbol_table_destroy(x.symtab);
194
195     return results;
196 }
197
198 struct ovsdb_error *
199 ovsdb_execute_commit(struct ovsdb_execution *x, struct ovsdb_parser *parser,
200                      struct json *result UNUSED)
201 {
202     const struct json *durable;
203
204     durable = ovsdb_parser_member(parser, "durable", OP_BOOLEAN);
205     if (durable && json_boolean(durable)) {
206         x->durable = true;
207     }
208     return NULL;
209 }
210
211 static struct ovsdb_error *
212 ovsdb_execute_abort(struct ovsdb_execution *x UNUSED,
213                     struct ovsdb_parser *parser UNUSED,
214                     struct json *result UNUSED)
215 {
216     return ovsdb_error("aborted", "aborted by request");
217 }
218
219 static struct ovsdb_table *
220 parse_table(struct ovsdb_execution *x,
221             struct ovsdb_parser *parser, const char *member)
222 {
223     struct ovsdb_table *table;
224     const char *table_name;
225     const struct json *json;
226
227     json = ovsdb_parser_member(parser, member, OP_ID);
228     if (!json) {
229         return NULL;
230     }
231     table_name = json_string(json);
232
233     table = shash_find_data(&x->db->tables, table_name);
234     if (!table) {
235         ovsdb_parser_raise_error(parser, "No table named %s.", table_name);
236     }
237     return table;
238 }
239
240 static WARN_UNUSED_RESULT struct ovsdb_error *
241 parse_row(struct ovsdb_parser *parser, const char *member,
242           const struct ovsdb_table *table,
243           const struct ovsdb_symbol_table *symtab,
244           struct ovsdb_row **rowp, struct ovsdb_column_set *columns)
245 {
246     struct ovsdb_error *error;
247     const struct json *json;
248     struct ovsdb_row *row;
249
250     *rowp = NULL;
251
252     if (!table) {
253         return OVSDB_BUG("null table");
254     }
255     json = ovsdb_parser_member(parser, member, OP_OBJECT);
256     if (!json) {
257         return OVSDB_BUG("null row member");
258     }
259
260     row = ovsdb_row_create(table);
261     error = ovsdb_row_from_json(row, json, symtab, columns);
262     if (error) {
263         ovsdb_row_destroy(row);
264         return error;
265     } else {
266         *rowp = row;
267         return NULL;
268     }
269 }
270
271 struct ovsdb_error *
272 ovsdb_execute_insert(struct ovsdb_execution *x, struct ovsdb_parser *parser,
273                      struct json *result)
274 {
275     struct ovsdb_table *table;
276     struct ovsdb_row *row = NULL;
277     const struct json *uuid_name;
278     struct ovsdb_error *error;
279     struct uuid row_uuid;
280
281     table = parse_table(x, parser, "table");
282     uuid_name = ovsdb_parser_member(parser, "uuid-name", OP_ID | OP_OPTIONAL);
283     error = ovsdb_parser_get_error(parser);
284
285     if (uuid_name) {
286         struct ovsdb_symbol *symbol;
287
288         symbol = ovsdb_symbol_table_get(x->symtab, json_string(uuid_name));
289         if (symbol) {
290             if (symbol->used) {
291                 return ovsdb_syntax_error(uuid_name, "duplicate uuid-name",
292                                           "This \"uuid-name\" appeared on an "
293                                           "earlier \"insert\" operation.");
294             }
295             row_uuid = symbol->uuid;
296             symbol->used = true;
297         } else {
298             uuid_generate(&row_uuid);
299             ovsdb_symbol_table_put(x->symtab, json_string(uuid_name),
300                                    &row_uuid, true);
301         }
302     } else {
303         uuid_generate(&row_uuid);
304     }
305
306     if (!error) {
307         error = parse_row(parser, "row", table, x->symtab, &row, NULL);
308     }
309     if (!error) {
310         *ovsdb_row_get_uuid_rw(row) = row_uuid;
311         ovsdb_txn_row_insert(x->txn, row);
312         json_object_put(result, "uuid",
313                         ovsdb_datum_to_json(&row->fields[OVSDB_COL_UUID],
314                                             &ovsdb_type_uuid));
315         row = NULL;
316     }
317     return error;
318 }
319
320 struct ovsdb_error *
321 ovsdb_execute_select(struct ovsdb_execution *x, struct ovsdb_parser *parser,
322                      struct json *result)
323 {
324     struct ovsdb_table *table;
325     const struct json *where, *columns_json, *sort_json;
326     struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER;
327     struct ovsdb_column_set columns = OVSDB_COLUMN_SET_INITIALIZER;
328     struct ovsdb_column_set sort = OVSDB_COLUMN_SET_INITIALIZER;
329     struct ovsdb_error *error;
330
331     table = parse_table(x, parser, "table");
332     where = ovsdb_parser_member(parser, "where", OP_ARRAY);
333     columns_json = ovsdb_parser_member(parser, "columns",
334                                        OP_ARRAY | OP_OPTIONAL);
335     sort_json = ovsdb_parser_member(parser, "sort", OP_ARRAY | OP_OPTIONAL);
336
337     error = ovsdb_parser_get_error(parser);
338     if (!error) {
339         error = ovsdb_condition_from_json(table->schema, where, x->symtab,
340                                           &condition);
341     }
342     if (!error) {
343         error = ovsdb_column_set_from_json(columns_json, table, &columns);
344     }
345     if (!error) {
346         error = ovsdb_column_set_from_json(sort_json, table, &sort);
347     }
348     if (!error) {
349         struct ovsdb_row_set rows = OVSDB_ROW_SET_INITIALIZER;
350
351         ovsdb_query_distinct(table, &condition, &columns, &rows);
352         ovsdb_row_set_sort(&rows, &sort);
353         json_object_put(result, "rows",
354                         ovsdb_row_set_to_json(&rows, &columns));
355
356         ovsdb_row_set_destroy(&rows);
357     }
358
359     ovsdb_column_set_destroy(&columns);
360     ovsdb_column_set_destroy(&sort);
361     ovsdb_condition_destroy(&condition);
362
363     return error;
364 }
365
366 struct update_row_cbdata {
367     size_t n_matches;
368     struct ovsdb_txn *txn;
369     const struct ovsdb_row *row;
370     const struct ovsdb_column_set *columns;
371 };
372
373 static bool
374 update_row_cb(const struct ovsdb_row *row, void *ur_)
375 {
376     struct update_row_cbdata *ur = ur_;
377
378     ur->n_matches++;
379     if (!ovsdb_row_equal_columns(row, ur->row, ur->columns)) {
380         ovsdb_row_update_columns(ovsdb_txn_row_modify(ur->txn, row),
381                                  ur->row, ur->columns);
382     }
383
384     return true;
385 }
386
387 struct ovsdb_error *
388 ovsdb_execute_update(struct ovsdb_execution *x, struct ovsdb_parser *parser,
389                      struct json *result)
390 {
391     struct ovsdb_table *table;
392     const struct json *where;
393     struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER;
394     struct ovsdb_column_set columns = OVSDB_COLUMN_SET_INITIALIZER;
395     struct ovsdb_row *row = NULL;
396     struct update_row_cbdata ur;
397     struct ovsdb_error *error;
398
399     table = parse_table(x, parser, "table");
400     where = ovsdb_parser_member(parser, "where", OP_ARRAY);
401     error = ovsdb_parser_get_error(parser);
402     if (!error) {
403         error = parse_row(parser, "row", table, x->symtab, &row, &columns);
404     }
405     if (!error) {
406         error = ovsdb_condition_from_json(table->schema, where, x->symtab,
407                                           &condition);
408     }
409     if (!error) {
410         ur.n_matches = 0;
411         ur.txn = x->txn;
412         ur.row = row;
413         ur.columns = &columns;
414         ovsdb_query(table, &condition, update_row_cb, &ur);
415         json_object_put(result, "count", json_integer_create(ur.n_matches));
416     }
417
418     ovsdb_row_destroy(row);
419     ovsdb_column_set_destroy(&columns);
420     ovsdb_condition_destroy(&condition);
421
422     return error;
423 }
424
425 struct mutate_row_cbdata {
426     size_t n_matches;
427     struct ovsdb_txn *txn;
428     const struct ovsdb_mutation_set *mutations;
429 };
430
431 static bool
432 mutate_row_cb(const struct ovsdb_row *row, void *mr_)
433 {
434     struct mutate_row_cbdata *mr = mr_;
435
436     mr->n_matches++;
437     ovsdb_mutation_set_execute(ovsdb_txn_row_modify(mr->txn, row),
438                                mr->mutations);
439
440     return true;
441 }
442
443 struct ovsdb_error *
444 ovsdb_execute_mutate(struct ovsdb_execution *x, struct ovsdb_parser *parser,
445                      struct json *result)
446 {
447     struct ovsdb_table *table;
448     const struct json *where;
449     const struct json *mutations_json;
450     struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER;
451     struct ovsdb_mutation_set mutations = OVSDB_MUTATION_SET_INITIALIZER;
452     struct ovsdb_row *row = NULL;
453     struct mutate_row_cbdata mr;
454     struct ovsdb_error *error;
455
456     table = parse_table(x, parser, "table");
457     where = ovsdb_parser_member(parser, "where", OP_ARRAY);
458     mutations_json = ovsdb_parser_member(parser, "mutations", OP_ARRAY);
459     error = ovsdb_parser_get_error(parser);
460     if (!error) {
461         error = ovsdb_mutation_set_from_json(table->schema, mutations_json,
462                                              x->symtab, &mutations);
463     }
464     if (!error) {
465         error = ovsdb_condition_from_json(table->schema, where, x->symtab,
466                                           &condition);
467     }
468     if (!error) {
469         mr.n_matches = 0;
470         mr.txn = x->txn;
471         mr.mutations = &mutations;
472         ovsdb_query(table, &condition, mutate_row_cb, &mr);
473         json_object_put(result, "count", json_integer_create(mr.n_matches));
474     }
475
476     ovsdb_row_destroy(row);
477     ovsdb_mutation_set_destroy(&mutations);
478     ovsdb_condition_destroy(&condition);
479
480     return error;
481 }
482
483 struct delete_row_cbdata {
484     size_t n_matches;
485     const struct ovsdb_table *table;
486     struct ovsdb_txn *txn;
487 };
488
489 static bool
490 delete_row_cb(const struct ovsdb_row *row, void *dr_)
491 {
492     struct delete_row_cbdata *dr = dr_;
493
494     dr->n_matches++;
495     ovsdb_txn_row_delete(dr->txn, row);
496
497     return true;
498 }
499
500 struct ovsdb_error *
501 ovsdb_execute_delete(struct ovsdb_execution *x, struct ovsdb_parser *parser,
502                      struct json *result)
503 {
504     struct ovsdb_table *table;
505     const struct json *where;
506     struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER;
507     struct ovsdb_error *error;
508
509     where = ovsdb_parser_member(parser, "where", OP_ARRAY);
510     table = parse_table(x, parser, "table");
511     error = ovsdb_parser_get_error(parser);
512     if (!error) {
513         error = ovsdb_condition_from_json(table->schema, where, x->symtab,
514                                           &condition);
515     }
516     if (!error) {
517         struct delete_row_cbdata dr;
518
519         dr.n_matches = 0;
520         dr.table = table;
521         dr.txn = x->txn;
522         ovsdb_query(table, &condition, delete_row_cb, &dr);
523
524         json_object_put(result, "count", json_integer_create(dr.n_matches));
525     }
526
527     ovsdb_condition_destroy(&condition);
528
529     return error;
530 }
531
532 struct wait_auxdata {
533     struct ovsdb_row_hash *actual;
534     struct ovsdb_row_hash *expected;
535     bool *equal;
536 };
537
538 static bool
539 ovsdb_execute_wait_query_cb(const struct ovsdb_row *row, void *aux_)
540 {
541     struct wait_auxdata *aux = aux_;
542
543     if (ovsdb_row_hash_contains(aux->expected, row)) {
544         ovsdb_row_hash_insert(aux->actual, row);
545         return true;
546     } else {
547         /* The query row isn't in the expected result set, so the actual and
548          * expected results sets definitely differ and we can short-circuit the
549          * rest of the query. */
550         *aux->equal = false;
551         return false;
552     }
553 }
554
555 static struct ovsdb_error *
556 ovsdb_execute_wait(struct ovsdb_execution *x, struct ovsdb_parser *parser,
557                    struct json *result UNUSED)
558 {
559     struct ovsdb_table *table;
560     const struct json *timeout, *where, *columns_json, *until, *rows;
561     struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER;
562     struct ovsdb_column_set columns = OVSDB_COLUMN_SET_INITIALIZER;
563     struct ovsdb_row_hash expected = OVSDB_ROW_HASH_INITIALIZER(expected);
564     struct ovsdb_row_hash actual = OVSDB_ROW_HASH_INITIALIZER(actual);
565     struct ovsdb_error *error;
566     struct wait_auxdata aux;
567     long long int timeout_msec = 0;
568     size_t i;
569
570     timeout = ovsdb_parser_member(parser, "timeout", OP_NUMBER | OP_OPTIONAL);
571     where = ovsdb_parser_member(parser, "where", OP_ARRAY);
572     columns_json = ovsdb_parser_member(parser, "columns",
573                                        OP_ARRAY | OP_OPTIONAL);
574     until = ovsdb_parser_member(parser, "until", OP_STRING);
575     rows = ovsdb_parser_member(parser, "rows", OP_ARRAY);
576     table = parse_table(x, parser, "table");
577     error = ovsdb_parser_get_error(parser);
578     if (!error) {
579         error = ovsdb_condition_from_json(table->schema, where, x->symtab,
580                                           &condition);
581     }
582     if (!error) {
583         error = ovsdb_column_set_from_json(columns_json, table, &columns);
584     }
585     if (!error) {
586         if (timeout) {
587             timeout_msec = MIN(LLONG_MAX, json_real(timeout));
588             if (timeout_msec < 0) {
589                 error = ovsdb_syntax_error(timeout, NULL,
590                                            "timeout must be nonnegative");
591             } else if (timeout_msec < x->timeout_msec) {
592                 x->timeout_msec = timeout_msec;
593             }
594         } else {
595             timeout_msec = LLONG_MAX;
596         }
597         if (strcmp(json_string(until), "==")
598             && strcmp(json_string(until), "!=")) {
599             error = ovsdb_syntax_error(until, NULL,
600                                        "\"until\" must be \"==\" or \"!=\"");
601         }
602     }
603     if (!error) {
604         /* Parse "rows" into 'expected'. */
605         ovsdb_row_hash_init(&expected, &columns);
606         for (i = 0; i < rows->u.array.n; i++) {
607             struct ovsdb_error *error;
608             struct ovsdb_row *row;
609
610             row = ovsdb_row_create(table);
611             error = ovsdb_row_from_json(row, rows->u.array.elems[i], x->symtab,
612                                         NULL);
613             if (error) {
614                 break;
615             }
616
617             if (!ovsdb_row_hash_insert(&expected, row)) {
618                 /* XXX Perhaps we should abort with an error or log a
619                  * warning. */
620                 ovsdb_row_destroy(row);
621             }
622         }
623     }
624     if (!error) {
625         /* Execute query. */
626         bool equal = true;
627         ovsdb_row_hash_init(&actual, &columns);
628         aux.actual = &actual;
629         aux.expected = &expected;
630         aux.equal = &equal;
631         ovsdb_query(table, &condition, ovsdb_execute_wait_query_cb, &aux);
632         if (equal) {
633             /* We know that every row in 'actual' is also in 'expected'.  We
634              * also know that all of the rows in 'actual' are distinct and that
635              * all of the rows in 'expected' are distinct.  Therefore, if
636              * 'actual' and 'expected' have the same number of rows, then they
637              * have the same content. */
638             size_t n_actual = ovsdb_row_hash_count(&actual);
639             size_t n_expected = ovsdb_row_hash_count(&expected);
640             equal = n_actual == n_expected;
641         }
642         if (!strcmp(json_string(until), "==") != equal) {
643             if (timeout && x->elapsed_msec >= timeout_msec) {
644                 if (x->elapsed_msec) {
645                     error = ovsdb_error("timed out",
646                                         "\"wait\" timed out after %lld ms",
647                                         x->elapsed_msec);
648                 } else {
649                     error = ovsdb_error("timed out", "\"wait\" timed out");
650                 }
651             } else {
652                 /* ovsdb_execute() will change this, if triggers really are
653                  * supported. */
654                 error = ovsdb_error("not supported", "triggers not supported");
655             }
656         }
657     }
658
659
660     ovsdb_row_hash_destroy(&expected, true);
661     ovsdb_row_hash_destroy(&actual, false);
662     ovsdb_column_set_destroy(&columns);
663     ovsdb_condition_destroy(&condition);
664
665     return error;
666 }
667
668 static struct ovsdb_error *
669 ovsdb_execute_declare(struct ovsdb_execution *x, struct ovsdb_parser *parser,
670                       struct json *result)
671 {
672     const struct json *uuid_name;
673     struct uuid uuid;
674
675     uuid_name = ovsdb_parser_member(parser, "uuid-name", OP_ID);
676     if (!uuid_name) {
677         return NULL;
678     }
679
680     if (ovsdb_symbol_table_get(x->symtab, json_string(uuid_name))) {
681         return ovsdb_syntax_error(uuid_name, "duplicate uuid-name",
682                                   "This \"uuid-name\" appeared on an "
683                                   "earlier \"declare\" or \"insert\" "
684                                   "operation.");
685     }
686
687     uuid_generate(&uuid);
688     ovsdb_symbol_table_put(x->symtab, json_string(uuid_name), &uuid, false);
689     json_object_put(result, "uuid", json_string_create_nocopy(
690                         xasprintf(UUID_FMT, UUID_ARGS(&uuid))));
691     return NULL;
692 }
693
694 static struct ovsdb_error *
695 ovsdb_execute_comment(struct ovsdb_execution *x, struct ovsdb_parser *parser,
696                       struct json *result UNUSED)
697 {
698     const struct json *comment;
699
700     comment = ovsdb_parser_member(parser, "comment", OP_STRING);
701     if (!comment) {
702         return NULL;
703     }
704     ovsdb_txn_add_comment(x->txn, json_string(comment));
705
706     return NULL;
707 }