4 * Copyright (C) 2004, 2005, 2007-2009 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: db_test.c,v 1.68 2009/09/02 23:48:01 tbox Exp */
24 * Principal Author: Bob Halley
31 #include <isc/commandline.h>
35 #include <isc/string.h>
39 #include <dns/dbiterator.h>
40 #include <dns/dbtable.h>
41 #include <dns/fixedname.h>
43 #include <dns/rdataset.h>
44 #include <dns/rdatasetiter.h>
45 #include <dns/result.h>
48 #define MAXVERSIONS 100
50 typedef struct dbinfo
{
52 dns_dbversion_t
* version
;
53 dns_dbversion_t
* wversion
;
54 dns_dbversion_t
* rversions
[MAXVERSIONS
];
56 dns_dbnode_t
* hold_nodes
[MAXHOLD
];
58 dns_dbiterator_t
* dbiterator
;
59 dns_dbversion_t
* iversion
;
61 isc_boolean_t ascending
;
62 ISC_LINK(struct dbinfo
) link
;
65 static isc_mem_t
* mctx
= NULL
;
66 static char dbtype
[128];
67 static dns_dbtable_t
* dbtable
;
68 static ISC_LIST(dbinfo
) dbs
;
69 static dbinfo
* cache_dbi
= NULL
;
70 static int pause_every
= 0;
71 static isc_boolean_t ascending
= ISC_TRUE
;
74 print_result(const char *message
, isc_result_t result
) {
77 if (message
== NULL
) {
81 len
= strlen(message
);
82 printf("%s%sresult %08x: %s\n", message
, (len
== 0U) ? "" : " ",
83 result
, isc_result_totext(result
));
87 print_rdataset(dns_name_t
*name
, dns_rdataset_t
*rdataset
) {
93 isc_buffer_init(&text
, t
, sizeof(t
));
94 result
= dns_rdataset_totext(rdataset
, name
, ISC_FALSE
, ISC_FALSE
,
96 isc_buffer_usedregion(&text
, &r
);
97 if (result
== ISC_R_SUCCESS
)
98 printf("%.*s", (int)r
.length
, (char *)r
.base
);
100 print_result("", result
);
104 print_rdatasets(dns_name_t
*name
, dns_rdatasetiter_t
*rdsiter
) {
106 dns_rdataset_t rdataset
;
108 dns_rdataset_init(&rdataset
);
109 result
= dns_rdatasetiter_first(rdsiter
);
110 while (result
== ISC_R_SUCCESS
) {
111 dns_rdatasetiter_current(rdsiter
, &rdataset
);
112 print_rdataset(name
, &rdataset
);
113 dns_rdataset_disassociate(&rdataset
);
114 result
= dns_rdatasetiter_next(rdsiter
);
116 if (result
!= ISC_R_NOMORE
)
117 print_result("", result
);
121 select_db(char *origintext
) {
122 dns_fixedname_t forigin
;
129 if (strcasecmp(origintext
, "cache") == 0) {
130 if (cache_dbi
== NULL
)
131 printf("the cache does not exist\n");
134 len
= strlen(origintext
);
135 isc_buffer_init(&source
, origintext
, len
);
136 isc_buffer_add(&source
, len
);
137 dns_fixedname_init(&forigin
);
138 origin
= dns_fixedname_name(&forigin
);
139 result
= dns_name_fromtext(origin
, &source
, dns_rootname
, 0, NULL
);
140 if (result
!= ISC_R_SUCCESS
) {
141 print_result("bad name", result
);
145 for (dbi
= ISC_LIST_HEAD(dbs
);
147 dbi
= ISC_LIST_NEXT(dbi
, link
)) {
148 if (dns_name_compare(dns_db_origin(dbi
->db
), origin
) == 0)
156 list(dbinfo
*dbi
, char *seektext
) {
157 dns_fixedname_t fname
;
160 dns_rdatasetiter_t
*rdsiter
;
164 dns_fixedname_t fseekname
;
165 dns_name_t
*seekname
;
168 dns_fixedname_init(&fname
);
169 name
= dns_fixedname_name(&fname
);
171 if (dbi
->dbiterator
== NULL
) {
172 INSIST(dbi
->iversion
== NULL
);
173 if (dns_db_iszone(dbi
->db
)) {
174 if (dbi
->version
!= NULL
)
175 dns_db_attachversion(dbi
->db
, dbi
->version
,
178 dns_db_currentversion(dbi
->db
, &dbi
->iversion
);
181 result
= dns_db_createiterator(dbi
->db
, 0, &dbi
->dbiterator
);
182 if (result
== ISC_R_SUCCESS
) {
183 if (seektext
!= NULL
) {
184 len
= strlen(seektext
);
185 isc_buffer_init(&source
, seektext
, len
);
186 isc_buffer_add(&source
, len
);
187 dns_fixedname_init(&fseekname
);
188 seekname
= dns_fixedname_name(&fseekname
);
189 result
= dns_name_fromtext(seekname
, &source
,
193 if (result
== ISC_R_SUCCESS
)
194 result
= dns_dbiterator_seek(
197 } else if (dbi
->ascending
)
198 result
= dns_dbiterator_first(dbi
->dbiterator
);
200 result
= dns_dbiterator_last(dbi
->dbiterator
);
203 result
= ISC_R_SUCCESS
;
208 while (result
== ISC_R_SUCCESS
) {
209 result
= dns_dbiterator_current(dbi
->dbiterator
, &node
, name
);
210 if (result
!= ISC_R_SUCCESS
&& result
!= DNS_R_NEWORIGIN
)
212 result
= dns_db_allrdatasets(dbi
->db
, node
, dbi
->iversion
, 0,
214 if (result
!= ISC_R_SUCCESS
) {
215 dns_db_detachnode(dbi
->db
, &node
);
218 print_rdatasets(name
, rdsiter
);
219 dns_rdatasetiter_destroy(&rdsiter
);
220 dns_db_detachnode(dbi
->db
, &node
);
222 result
= dns_dbiterator_next(dbi
->dbiterator
);
224 result
= dns_dbiterator_prev(dbi
->dbiterator
);
226 if (result
== ISC_R_SUCCESS
&& i
== dbi
->pause_every
) {
227 printf("[more...]\n");
228 result
= dns_dbiterator_pause(dbi
->dbiterator
);
229 if (result
== ISC_R_SUCCESS
)
233 if (result
!= ISC_R_NOMORE
)
234 print_result("", result
);
236 dns_dbiterator_destroy(&dbi
->dbiterator
);
237 if (dbi
->iversion
!= NULL
)
238 dns_db_closeversion(dbi
->db
, &dbi
->iversion
, ISC_FALSE
);
242 load(const char *filename
, const char *origintext
, isc_boolean_t cache
) {
243 dns_fixedname_t forigin
;
251 dbi
= isc_mem_get(mctx
, sizeof(*dbi
));
253 return (ISC_R_NOMEMORY
);
257 dbi
->wversion
= NULL
;
258 for (i
= 0; i
< MAXVERSIONS
; i
++)
259 dbi
->rversions
[i
] = NULL
;
261 for (i
= 0; i
< MAXHOLD
; i
++)
262 dbi
->hold_nodes
[i
] = NULL
;
263 dbi
->dbiterator
= NULL
;
264 dbi
->iversion
= NULL
;
265 dbi
->pause_every
= pause_every
;
266 dbi
->ascending
= ascending
;
267 ISC_LINK_INIT(dbi
, link
);
269 len
= strlen(origintext
);
270 isc_buffer_init(&source
, origintext
, len
);
271 isc_buffer_add(&source
, len
);
272 dns_fixedname_init(&forigin
);
273 origin
= dns_fixedname_name(&forigin
);
274 result
= dns_name_fromtext(origin
, &source
, dns_rootname
, 0, NULL
);
275 if (result
!= ISC_R_SUCCESS
)
278 result
= dns_db_create(mctx
, dbtype
, origin
,
279 cache
? dns_dbtype_cache
: dns_dbtype_zone
,
282 if (result
!= ISC_R_SUCCESS
) {
283 isc_mem_put(mctx
, dbi
, sizeof(*dbi
));
287 printf("loading %s (%s)\n", filename
, origintext
);
288 result
= dns_db_load(dbi
->db
, filename
);
289 if (result
!= ISC_R_SUCCESS
&& result
!= DNS_R_SEENINCLUDE
) {
290 dns_db_detach(&dbi
->db
);
291 isc_mem_put(mctx
, dbi
, sizeof(*dbi
));
297 INSIST(cache_dbi
== NULL
);
298 dns_dbtable_adddefault(dbtable
, dbi
->db
);
301 if (dns_dbtable_add(dbtable
, dbi
->db
) != ISC_R_SUCCESS
) {
302 dns_db_detach(&dbi
->db
);
303 isc_mem_put(mctx
, dbi
, sizeof(*dbi
));
307 ISC_LIST_APPEND(dbs
, dbi
, link
);
309 return (ISC_R_SUCCESS
);
314 dbinfo
*dbi
, *dbi_next
;
316 for (dbi
= ISC_LIST_HEAD(dbs
); dbi
!= NULL
; dbi
= dbi_next
) {
317 dbi_next
= ISC_LIST_NEXT(dbi
, link
);
318 if (dns_db_iszone(dbi
->db
))
319 dns_dbtable_remove(dbtable
, dbi
->db
);
321 INSIST(dbi
== cache_dbi
);
322 dns_dbtable_removedefault(dbtable
);
325 dns_db_detach(&dbi
->db
);
326 ISC_LIST_UNLINK(dbs
, dbi
, link
);
327 isc_mem_put(mctx
, dbi
, sizeof(*dbi
));
331 #define DBI_CHECK(dbi) \
332 if ((dbi) == NULL) { \
333 printf("You must first select a database with !DB\n"); \
338 main(int argc
, char *argv
[]) {
343 dns_offsets_t offsets
;
345 isc_buffer_t source
, target
;
348 dns_rdataset_t rdataset
, sigrdataset
;
350 dns_rdatatype_t type
= 1;
351 isc_boolean_t printnode
= ISC_FALSE
;
352 isc_boolean_t addmode
= ISC_FALSE
;
353 isc_boolean_t delmode
= ISC_FALSE
;
354 isc_boolean_t holdmode
= ISC_FALSE
;
355 isc_boolean_t verbose
= ISC_FALSE
;
356 isc_boolean_t done
= ISC_FALSE
;
357 isc_boolean_t quiet
= ISC_FALSE
;
358 isc_boolean_t time_lookups
= ISC_FALSE
;
359 isc_boolean_t found_as
;
360 isc_boolean_t find_zonecut
= ISC_FALSE
;
361 isc_boolean_t noexact_zonecut
= ISC_FALSE
;
363 dns_rdatasetiter_t
*rdsiter
;
366 isc_buffer_t tb1
, tb2
;
368 dns_fixedname_t foundname
;
370 unsigned int options
= 0, zcoptions
;
371 isc_time_t start
, finish
;
374 dns_dbversion_t
*version
;
376 size_t memory_quota
= 0;
377 dns_trust_t trust
= 0;
378 unsigned int addopts
;
379 isc_log_t
*lctx
= NULL
;
381 dns_result_register();
383 RUNTIME_CHECK(isc_mem_create(0, 0, &mctx
) == ISC_R_SUCCESS
);
384 RUNTIME_CHECK(dns_dbtable_create(mctx
, dns_rdataclass_in
, &dbtable
) ==
389 strcpy(dbtype
, "rbt");
390 while ((ch
= isc_commandline_parse(argc
, argv
, "c:d:t:z:P:Q:glpqvT"))
394 result
= load(isc_commandline_argument
, ".", ISC_TRUE
);
395 if (result
!= ISC_R_SUCCESS
)
396 printf("cache load(%s) %08x: %s\n",
397 isc_commandline_argument
, result
,
398 isc_result_totext(result
));
401 strcpy(dbtype
, isc_commandline_argument
);
404 options
|= (DNS_DBFIND_GLUEOK
|DNS_DBFIND_VALIDATEGLUE
);
407 RUNTIME_CHECK(isc_log_create(mctx
, &lctx
,
408 NULL
) == ISC_R_SUCCESS
);
409 isc_log_setcontext(lctx
);
411 dns_log_setcontext(lctx
);
418 printnode
= ISC_TRUE
;
421 pause_every
= atoi(isc_commandline_argument
);
424 memory_quota
= atoi(isc_commandline_argument
);
425 isc_mem_setquota(mctx
, memory_quota
);
428 type
= atoi(isc_commandline_argument
);
431 time_lookups
= ISC_TRUE
;
437 origintext
= strrchr(isc_commandline_argument
, '/');
438 if (origintext
== NULL
)
439 origintext
= isc_commandline_argument
;
441 origintext
++; /* Skip '/'. */
442 result
= load(isc_commandline_argument
, origintext
,
444 if (result
!= ISC_R_SUCCESS
)
445 printf("zone load(%s) %08x: %s\n",
446 isc_commandline_argument
, result
,
447 isc_result_totext(result
));
452 argc
-= isc_commandline_index
;
453 argv
+= isc_commandline_index
;
456 printf("ignoring trailing arguments\n");
459 * Some final initialization...
461 dns_fixedname_init(&foundname
);
462 fname
= dns_fixedname_name(&foundname
);
464 origin
= dns_rootname
;
474 if (fgets(s
, sizeof(s
), stdin
) == NULL
) {
479 if (len
> 0U && s
[len
- 1] == '\n') {
483 if (verbose
&& dbi
!= NULL
) {
484 if (dbi
->wversion
!= NULL
)
485 printf("future version (%p)\n", dbi
->wversion
);
486 for (i
= 0; i
< dbi
->rcount
; i
++)
487 if (dbi
->rversions
[i
] != NULL
)
488 printf("open version %d (%p)\n", i
,
491 dns_name_init(&name
, offsets
);
492 if (strcmp(s
, "!R") == 0) {
494 if (dbi
->rcount
== MAXVERSIONS
) {
495 printf("too many open versions\n");
498 dns_db_currentversion(dbi
->db
,
499 &dbi
->rversions
[dbi
->rcount
]);
500 printf("opened version %d\n", dbi
->rcount
);
501 dbi
->version
= dbi
->rversions
[dbi
->rcount
];
502 version
= dbi
->version
;
505 } else if (strcmp(s
, "!W") == 0) {
507 if (dbi
->wversion
!= NULL
) {
508 printf("using existing future version\n");
509 dbi
->version
= dbi
->wversion
;
510 version
= dbi
->version
;
513 result
= dns_db_newversion(dbi
->db
, &dbi
->wversion
);
514 if (result
!= ISC_R_SUCCESS
)
515 print_result("", result
);
517 printf("newversion\n");
518 dbi
->version
= dbi
->wversion
;
519 version
= dbi
->version
;
521 } else if (strcmp(s
, "!C") == 0) {
525 if (dbi
->version
== NULL
)
527 if (dbi
->version
== dbi
->wversion
) {
528 printf("closing future version\n");
529 dbi
->wversion
= NULL
;
531 for (i
= 0; i
< dbi
->rcount
; i
++) {
534 dbi
->rversions
[i
] = NULL
;
535 printf("closing open version %d\n",
541 dns_db_closeversion(dbi
->db
, &dbi
->version
, ISC_TRUE
);
544 } else if (strcmp(s
, "!X") == 0) {
548 if (dbi
->version
== NULL
)
550 if (dbi
->version
== dbi
->wversion
) {
551 printf("aborting future version\n");
552 dbi
->wversion
= NULL
;
554 for (i
= 0; i
< dbi
->rcount
; i
++) {
557 dbi
->rversions
[i
] = NULL
;
558 printf("closing open version %d\n",
564 dns_db_closeversion(dbi
->db
, &dbi
->version
, ISC_FALSE
);
567 } else if (strcmp(s
, "!A") == 0) {
574 printf("addmode = %s\n", addmode
? "TRUE" : "FALSE");
576 } else if (strcmp(s
, "!D") == 0) {
583 printf("delmode = %s\n", delmode
? "TRUE" : "FALSE");
585 } else if (strcmp(s
, "!H") == 0) {
588 holdmode
= ISC_FALSE
;
591 printf("holdmode = %s\n", holdmode
? "TRUE" : "FALSE");
593 } else if (strcmp(s
, "!HR") == 0) {
595 for (i
= 0; i
< dbi
->hold_count
; i
++)
596 dns_db_detachnode(dbi
->db
,
597 &dbi
->hold_nodes
[i
]);
599 holdmode
= ISC_FALSE
;
600 printf("held nodes have been detached\n");
602 } else if (strcmp(s
, "!VC") == 0) {
604 printf("switching to current version\n");
608 } else if (strstr(s
, "!V") == s
) {
611 if (v
>= dbi
->rcount
) {
612 printf("unknown open version %d\n", v
);
614 } else if (dbi
->rversions
[v
] == NULL
) {
615 printf("version %d is not open\n", v
);
618 printf("switching to open version %d\n", v
);
619 dbi
->version
= dbi
->rversions
[v
];
620 version
= dbi
->version
;
622 } else if (strstr(s
, "!TR") == s
) {
623 trust
= (unsigned int)atoi(&s
[3]);
624 printf("trust level is now %u\n", (unsigned int)trust
);
626 } else if (strstr(s
, "!T") == s
) {
627 type
= (unsigned int)atoi(&s
[2]);
628 printf("now searching for type %u\n", type
);
630 } else if (strcmp(s
, "!G") == 0) {
631 if ((options
& DNS_DBFIND_GLUEOK
) != 0)
632 options
&= ~DNS_DBFIND_GLUEOK
;
634 options
|= DNS_DBFIND_GLUEOK
;
635 printf("glue ok = %s\n",
636 ((options
& DNS_DBFIND_GLUEOK
) != 0) ?
639 } else if (strcmp(s
, "!GV") == 0) {
640 if ((options
& DNS_DBFIND_VALIDATEGLUE
) != 0)
641 options
&= ~DNS_DBFIND_VALIDATEGLUE
;
643 options
|= DNS_DBFIND_VALIDATEGLUE
;
644 printf("validate glue = %s\n",
645 ((options
& DNS_DBFIND_VALIDATEGLUE
) != 0) ?
648 } else if (strcmp(s
, "!WC") == 0) {
649 if ((options
& DNS_DBFIND_NOWILD
) != 0)
650 options
&= ~DNS_DBFIND_NOWILD
;
652 options
|= DNS_DBFIND_NOWILD
;
653 printf("wildcard matching = %s\n",
654 ((options
& DNS_DBFIND_NOWILD
) == 0) ?
657 } else if (strstr(s
, "!LS ") == s
) {
661 } else if (strcmp(s
, "!LS") == 0) {
665 } else if (strstr(s
, "!DU ") == s
) {
667 result
= dns_db_dump(dbi
->db
, dbi
->version
, s
+4);
668 if (result
!= ISC_R_SUCCESS
) {
670 print_result("", result
);
673 } else if (strcmp(s
, "!PN") == 0) {
675 printnode
= ISC_FALSE
;
677 printnode
= ISC_TRUE
;
678 printf("printnode = %s\n",
679 printnode
? "TRUE" : "FALSE");
681 } else if (strstr(s
, "!P") == s
) {
684 dbi
->pause_every
= v
;
686 } else if (strcmp(s
, "!+") == 0) {
688 dbi
->ascending
= ISC_TRUE
;
690 } else if (strcmp(s
, "!-") == 0) {
692 dbi
->ascending
= ISC_FALSE
;
694 } else if (strcmp(s
, "!DB") == 0) {
696 origin
= dns_rootname
;
698 printf("now searching all databases\n");
700 } else if (strncmp(s
, "!DB ", 4) == 0) {
701 dbi
= select_db(s
+4);
704 origin
= dns_db_origin(dbi
->db
);
705 version
= dbi
->version
;
708 holdmode
= ISC_FALSE
;
712 origin
= dns_rootname
;
713 printf("database not found; "
714 "now searching all databases\n");
717 } else if (strcmp(s
, "!ZC") == 0) {
719 find_zonecut
= ISC_FALSE
;
721 find_zonecut
= ISC_TRUE
;
722 printf("find_zonecut = %s\n",
723 find_zonecut
? "TRUE" : "FALSE");
725 } else if (strcmp(s
, "!NZ") == 0) {
727 noexact_zonecut
= ISC_FALSE
;
729 noexact_zonecut
= ISC_TRUE
;
730 printf("noexact_zonecut = %s\n",
731 noexact_zonecut
? "TRUE" : "FALSE");
735 isc_buffer_init(&source
, s
, len
);
736 isc_buffer_add(&source
, len
);
737 isc_buffer_init(&target
, b
, sizeof(b
));
738 result
= dns_name_fromtext(&name
, &source
, origin
, 0, &target
);
739 if (result
!= ISC_R_SUCCESS
) {
740 print_result("bad name: ", result
);
747 zcoptions
|= DNS_DBTABLEFIND_NOEXACT
;
749 result
= dns_dbtable_find(dbtable
, &name
, zcoptions
,
751 if (result
!= ISC_R_SUCCESS
&&
752 result
!= DNS_R_PARTIALMATCH
) {
755 print_result("", result
);
759 isc_buffer_init(&tb1
, t1
, sizeof(t1
));
760 result
= dns_name_totext(dns_db_origin(db
), ISC_FALSE
,
762 if (result
!= ISC_R_SUCCESS
) {
764 print_result("", result
);
768 isc_buffer_usedregion(&tb1
, &r1
);
769 printf("\ndatabase = %.*s (%s)\n",
770 (int)r1
.length
, r1
.base
,
771 (dns_db_iszone(db
)) ? "zone" : "cache");
774 dns_rdataset_init(&rdataset
);
775 dns_rdataset_init(&sigrdataset
);
777 if (find_zonecut
&& dns_db_iscache(db
)) {
780 zcoptions
|= DNS_DBFIND_NOEXACT
;
781 result
= dns_db_findzonecut(db
, &name
, zcoptions
,
783 &rdataset
, &sigrdataset
);
785 result
= dns_db_find(db
, &name
, version
, type
,
786 options
, 0, &node
, fname
,
787 &rdataset
, &sigrdataset
);
793 print_result("", result
);
796 found_as
= ISC_FALSE
;
804 case DNS_R_DELEGATION
:
808 if (dns_rdataset_isassociated(&rdataset
))
812 RUNTIME_CHECK(dbi
->hold_count
<
814 dbi
->hold_nodes
[dbi
->hold_count
++] =
818 dns_db_detachnode(db
, &node
);
820 dns_db_detachnode(db
, &node
);
825 if (dns_rdataset_isassociated(&rdataset
))
832 print_result("", result
);
835 if (found_as
&& !quiet
) {
836 isc_buffer_init(&tb1
, t1
, sizeof(t1
));
837 isc_buffer_init(&tb2
, t2
, sizeof(t2
));
838 result
= dns_name_totext(&name
, ISC_FALSE
, &tb1
);
839 if (result
!= ISC_R_SUCCESS
) {
840 print_result("", result
);
841 dns_db_detachnode(db
, &node
);
846 result
= dns_name_totext(fname
, ISC_FALSE
, &tb2
);
847 if (result
!= ISC_R_SUCCESS
) {
848 print_result("", result
);
849 dns_db_detachnode(db
, &node
);
854 isc_buffer_usedregion(&tb1
, &r1
);
855 isc_buffer_usedregion(&tb2
, &r2
);
856 printf("found %.*s as %.*s\n",
857 (int)r1
.length
, r1
.base
,
858 (int)r2
.length
, r2
.base
);
862 dns_db_printnode(db
, node
, stdout
);
864 if (!found_as
&& type
== dns_rdatatype_any
) {
866 result
= dns_db_allrdatasets(db
, node
, version
, 0,
868 if (result
== ISC_R_SUCCESS
) {
870 print_rdatasets(fname
, rdsiter
);
871 dns_rdatasetiter_destroy(&rdsiter
);
873 print_result("", result
);
876 print_rdataset(fname
, &rdataset
);
877 if (dns_rdataset_isassociated(&sigrdataset
)) {
879 print_rdataset(fname
, &sigrdataset
);
880 dns_rdataset_disassociate(&sigrdataset
);
882 if (dbi
!= NULL
&& addmode
&& !found_as
) {
884 rdataset
.trust
= trust
;
885 if (dns_db_iszone(db
))
886 addopts
= DNS_DBADD_MERGE
;
889 result
= dns_db_addrdataset(db
, node
, version
,
892 if (result
!= ISC_R_SUCCESS
)
893 print_result("", result
);
895 dns_db_printnode(db
, node
, stdout
);
896 } else if (dbi
!= NULL
&& delmode
&& !found_as
) {
897 result
= dns_db_deleterdataset(db
, node
,
900 if (result
!= ISC_R_SUCCESS
)
901 print_result("", result
);
903 dns_db_printnode(db
, node
, stdout
);
905 dns_rdataset_disassociate(&rdataset
);
910 RUNTIME_CHECK(dbi
->hold_count
< MAXHOLD
);
911 dbi
->hold_nodes
[dbi
->hold_count
++] = node
;
914 dns_db_detachnode(db
, &node
);
916 dns_db_detachnode(db
, &node
);
926 usec
= isc_time_microdiff(&finish
, &start
);
928 printf("elapsed time: %lu.%06lu seconds\n",
929 (unsigned long)(usec
/ 1000000),
930 (unsigned long)(usec
% 1000000));
935 dns_dbtable_detach(&dbtable
);
938 isc_log_destroy(&lctx
);
941 isc_mem_stats(mctx
, stdout
);