1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332
|
/*-
* Public Domain 2014-2019 MongoDB, Inc.
* Public Domain 2008-2014 WiredTiger, Inc.
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* ex_all.c
* Containing a call to every method in the WiredTiger API.
*
* It doesn't do anything very useful, just demonstrates how to call each
* method. This file is used to populate the API reference with code
* fragments.
*/
#include <test_util.h>
static const char *home;
static void add_collator(WT_CONNECTION *conn);
static void add_extractor(WT_CONNECTION *conn);
static void backup(WT_SESSION *session);
static void checkpoint_ops(WT_SESSION *session);
static void connection_ops(WT_CONNECTION *conn);
static int cursor_ops(WT_SESSION *session);
static void cursor_search_near(WT_CURSOR *cursor);
static void cursor_statistics(WT_SESSION *session);
static void named_snapshot_ops(WT_SESSION *session);
static void pack_ops(WT_SESSION *session);
static void session_ops(WT_SESSION *session);
static void transaction_ops(WT_SESSION *session);
static int
cursor_ops(WT_SESSION *session)
{
WT_CURSOR *cursor;
int ret;
/*! [Open a cursor] */
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
/*! [Open a cursor] */
/*! [Open a cursor on the metadata] */
error_check(session->open_cursor(session, "metadata:", NULL, NULL, &cursor));
/*! [Open a cursor on the metadata] */
{
const char *key = "some key", *value = "some value";
/*! [Reconfigure a cursor] */
error_check(
session->open_cursor(session, "table:mytable", NULL, "overwrite=false", &cursor));
/* Reconfigure the cursor to overwrite the record. */
error_check(cursor->reconfigure(cursor, "overwrite=true"));
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
error_check(cursor->insert(cursor));
/*! [Reconfigure a cursor] */
}
{
WT_CURSOR *duplicate;
const char *key = "some key";
/*! [Duplicate a cursor] */
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
cursor->set_key(cursor, key);
error_check(cursor->search(cursor));
/* Duplicate the cursor. */
error_check(session->open_cursor(session, NULL, cursor, NULL, &duplicate));
/*! [Duplicate a cursor] */
}
{
/*! [boolean configuration string example] */
error_check(session->open_cursor(session, "table:mytable", NULL, "overwrite", &cursor));
error_check(
session->open_cursor(session, "table:mytable", NULL, "overwrite=true", &cursor));
error_check(session->open_cursor(session, "table:mytable", NULL, "overwrite=1", &cursor));
/*! [boolean configuration string example] */
}
error_check(session->checkpoint(session, "name=midnight"));
{
/*! [open a named checkpoint] */
error_check(
session->open_cursor(session, "table:mytable", NULL, "checkpoint=midnight", &cursor));
/*! [open a named checkpoint] */
}
{
/*! [open the default checkpoint] */
error_check(session->open_cursor(
session, "table:mytable", NULL, "checkpoint=WiredTigerCheckpoint", &cursor));
/*! [open the default checkpoint] */
}
{
/*! [Set the cursor's string key] */
/* Set the cursor's string key. */
const char *key = "another key";
cursor->set_key(cursor, key);
/*! [Set the cursor's string key] */
}
{
/*! [Get the cursor's string key] */
const char *key; /* Get the cursor's string key. */
error_check(cursor->get_key(cursor, &key));
/*! [Get the cursor's string key] */
}
/* Switch to a recno table. */
error_check(session->create(session, "table:recno", "key_format=r,value_format=S"));
error_check(session->open_cursor(session, "table:recno", NULL, NULL, &cursor));
{
/*! [Set the cursor's record number key] */
uint64_t recno = 37; /* Set the cursor's record number key. */
cursor->set_key(cursor, recno);
/*! [Set the cursor's record number key] */
}
{
/*! [Get the cursor's record number key] */
uint64_t recno; /* Get the cursor's record number key. */
error_check(cursor->get_key(cursor, &recno));
/*! [Get the cursor's record number key] */
}
/* Switch to a composite table. */
error_check(session->create(session, "table:composite", "key_format=SiH,value_format=S"));
error_check(session->open_cursor(session, "table:recno", NULL, NULL, &cursor));
{
/*! [Set the cursor's composite key] */
/* Set the cursor's "SiH" format composite key. */
cursor->set_key(cursor, "first", (int32_t)5, (uint16_t)7);
/*! [Set the cursor's composite key] */
}
{
/*! [Get the cursor's composite key] */
/* Get the cursor's "SiH" format composite key. */
const char *first;
int32_t second;
uint16_t third;
error_check(cursor->get_key(cursor, &first, &second, &third));
/*! [Get the cursor's composite key] */
}
{
/*! [Set the cursor's string value] */
/* Set the cursor's string value. */
const char *value = "another value";
cursor->set_value(cursor, value);
/*! [Set the cursor's string value] */
}
{
/*! [Get the cursor's string value] */
const char *value; /* Get the cursor's string value. */
error_check(cursor->get_value(cursor, &value));
/*! [Get the cursor's string value] */
}
{
/*! [Get the cursor's raw value] */
WT_ITEM value; /* Get the cursor's raw value. */
error_check(cursor->get_value(cursor, &value));
/*! [Get the cursor's raw value] */
}
{
/*! [Set the cursor's raw value] */
WT_ITEM value; /* Set the cursor's raw value. */
value.data = "another value";
value.size = strlen("another value");
cursor->set_value(cursor, &value);
/*! [Set the cursor's raw value] */
error_check(cursor->insert(cursor));
}
/*! [Return the next record] */
error_check(cursor->next(cursor));
/*! [Return the next record] */
/*! [Reset the cursor] */
error_check(cursor->reset(cursor));
/*! [Reset the cursor] */
/*! [Return the previous record] */
error_check(cursor->prev(cursor));
/*! [Return the previous record] */
{
WT_CURSOR *other = NULL;
error_check(session->open_cursor(session, NULL, cursor, NULL, &other));
{
/*! [Cursor comparison] */
int compare;
error_check(cursor->compare(cursor, other, &compare));
if (compare == 0) {
/* Cursors reference the same key */
} else if (compare < 0) {
/* Cursor key less than other key */
} else if (compare > 0) {
/* Cursor key greater than other key */
}
/*! [Cursor comparison] */
}
{
/*! [Cursor equality] */
int equal;
error_check(cursor->equals(cursor, other, &equal));
if (equal) {
/* Cursors reference the same key */
}
/*! [Cursor equality] */
}
}
{
/*! [Insert a new record or overwrite an existing record] */
/* Insert a new record or overwrite an existing record. */
const char *key = "some key", *value = "some value";
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
error_check(cursor->insert(cursor));
/*! [Insert a new record or overwrite an existing record] */
}
{
/*! [Search for an exact match] */
const char *key = "some key";
cursor->set_key(cursor, key);
error_check(cursor->search(cursor));
/*! [Search for an exact match] */
}
cursor_search_near(cursor);
{
/*! [Insert a new record and fail if the record exists] */
/* Insert a new record and fail if the record exists. */
const char *key = "new key", *value = "some value";
error_check(
session->open_cursor(session, "table:mytable", NULL, "overwrite=false", &cursor));
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
error_check(cursor->insert(cursor));
/*! [Insert a new record and fail if the record exists] */
}
error_check(session->open_cursor(session, "table:recno", NULL, "append", &cursor));
{
/*! [Insert a new record and assign a record number] */
/* Insert a new record and assign a record number. */
uint64_t recno;
const char *value = "some value";
cursor->set_value(cursor, value);
error_check(cursor->insert(cursor));
error_check(cursor->get_key(cursor, &recno));
/*! [Insert a new record and assign a record number] */
}
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
{
/*! [Reserve a record] */
const char *key = "some key";
error_check(session->begin_transaction(session, NULL));
cursor->set_key(cursor, key);
error_check(cursor->reserve(cursor));
error_check(session->commit_transaction(session, NULL));
/*! [Reserve a record] */
}
error_check(session->create(session, "table:blob", "key_format=S,value_format=u"));
error_check(session->open_cursor(session, "table:blob", NULL, NULL, &cursor));
{
WT_ITEM value;
value.data =
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz";
value.size = strlen(value.data);
cursor->set_key(cursor, "some key");
cursor->set_value(cursor, &value);
error_check(cursor->insert(cursor));
}
/* Modify requires an explicit transaction. */
error_check(session->begin_transaction(session, NULL));
{
/*! [Modify an existing record] */
WT_MODIFY entries[3];
const char *key = "some key";
/* Position the cursor. */
cursor->set_key(cursor, key);
error_check(cursor->search(cursor));
/* Replace 20 bytes starting at byte offset 5. */
entries[0].data.data = "some data";
entries[0].data.size = strlen(entries[0].data.data);
entries[0].offset = 5;
entries[0].size = 20;
/* Insert data at byte offset 40. */
entries[1].data.data = "and more data";
entries[1].data.size = strlen(entries[1].data.data);
entries[1].offset = 40;
entries[1].size = 0;
/* Replace 2 bytes starting at byte offset 10. */
entries[2].data.data = "and more data";
entries[2].data.size = strlen(entries[2].data.data);
entries[2].offset = 10;
entries[2].size = 2;
error_check(cursor->modify(cursor, entries, 3));
/*! [Modify an existing record] */
}
error_check(session->commit_transaction(session, NULL));
{
/*! [Update an existing record or insert a new record] */
const char *key = "some key", *value = "some value";
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
error_check(cursor->update(cursor));
/*! [Update an existing record or insert a new record] */
}
{
/*! [Update an existing record and fail if DNE] */
const char *key = "some key", *value = "some value";
error_check(
session->open_cursor(session, "table:mytable", NULL, "overwrite=false", &cursor));
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
error_check(cursor->update(cursor));
/*! [Update an existing record and fail if DNE] */
}
{
/*! [Remove a record and fail if DNE] */
const char *key = "some key";
error_check(
session->open_cursor(session, "table:mytable", NULL, "overwrite=false", &cursor));
cursor->set_key(cursor, key);
error_check(cursor->remove(cursor));
/*! [Remove a record and fail if DNE] */
}
{
/*! [Remove a record] */
const char *key = "some key";
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
cursor->set_key(cursor, key);
error_check(cursor->remove(cursor));
/*! [Remove a record] */
}
{
/*! [Display an error] */
const char *key = "non-existent key";
cursor->set_key(cursor, key);
if ((ret = cursor->remove(cursor)) != 0) {
fprintf(stderr, "cursor.remove: %s\n", wiredtiger_strerror(ret));
return (ret);
}
/*! [Display an error] */
}
{
/*! [Display an error thread safe] */
const char *key = "non-existent key";
cursor->set_key(cursor, key);
if ((ret = cursor->remove(cursor)) != 0) {
fprintf(stderr, "cursor.remove: %s\n", cursor->session->strerror(cursor->session, ret));
return (ret);
}
/*! [Display an error thread safe] */
}
/*! [Close the cursor] */
error_check(cursor->close(cursor));
/*! [Close the cursor] */
return (0);
}
static void
cursor_search_near(WT_CURSOR *cursor)
{
int exact, ret;
const char *key = "some key";
/*! [Search for an exact or adjacent match] */
cursor->set_key(cursor, key);
error_check(cursor->search_near(cursor, &exact));
if (exact == 0) {
/* an exact match */
} else if (exact < 0) {
/* returned smaller key */
} else if (exact > 0) {
/* returned larger key */
}
/*! [Search for an exact or adjacent match] */
/*! [Forward scan greater than or equal] */
cursor->set_key(cursor, key);
error_check(cursor->search_near(cursor, &exact));
if (exact >= 0) {
/* include first key returned in the scan */
}
while ((ret = cursor->next(cursor)) == 0) {
/* the rest of the scan */
}
scan_end_check(ret == WT_NOTFOUND);
/*! [Forward scan greater than or equal] */
/*! [Backward scan less than] */
cursor->set_key(cursor, key);
error_check(cursor->search_near(cursor, &exact));
if (exact < 0) {
/* include first key returned in the scan */
}
while ((ret = cursor->prev(cursor)) == 0) {
/* the rest of the scan */
}
scan_end_check(ret == WT_NOTFOUND);
/*! [Backward scan less than] */
}
static void
checkpoint_ops(WT_SESSION *session)
{
error_check(session->create(session, "table:table1", NULL));
error_check(session->create(session, "table:table2", NULL));
/*! [Checkpoint examples] */
/* Checkpoint the database. */
error_check(session->checkpoint(session, NULL));
/* Checkpoint of the database, creating a named snapshot. */
error_check(session->checkpoint(session, "name=June01"));
/*
* Checkpoint a list of objects. JSON parsing requires quoting the list of target URIs.
*/
error_check(session->checkpoint(session, "target=(\"table:table1\",\"table:table2\")"));
/*
* Checkpoint a list of objects, creating a named snapshot. JSON parsing requires quoting the
* list of target URIs.
*/
error_check(session->checkpoint(session, "target=(\"table:mytable\"),name=midnight"));
/* Checkpoint the database, discarding all previous snapshots. */
error_check(session->checkpoint(session, "drop=(from=all)"));
/* Checkpoint the database, discarding the "midnight" snapshot. */
error_check(session->checkpoint(session, "drop=(midnight)"));
/*
* Checkpoint the database, discarding all snapshots after and including "noon".
*/
error_check(session->checkpoint(session, "drop=(from=noon)"));
/*
* Checkpoint the database, discarding all snapshots before and including "midnight".
*/
error_check(session->checkpoint(session, "drop=(to=midnight)"));
/*
* Create a checkpoint of a table, creating the "July01" snapshot and discarding the "May01" and
* "June01" snapshots. JSON parsing requires quoting the list of target URIs.
*/
error_check(
session->checkpoint(session, "target=(\"table:mytable\"),name=July01,drop=(May01,June01)"));
/*! [Checkpoint examples] */
/*! [JSON quoting example] */
/*
* Checkpoint a list of objects. JSON parsing requires quoting the list of target URIs.
*/
error_check(session->checkpoint(session, "target=(\"table:table1\",\"table:table2\")"));
/*! [JSON quoting example] */
}
static void
cursor_statistics(WT_SESSION *session)
{
WT_CURSOR *cursor;
/*! [Statistics cursor database] */
error_check(session->open_cursor(session, "statistics:", NULL, NULL, &cursor));
/*! [Statistics cursor database] */
/*! [Statistics cursor table] */
error_check(session->open_cursor(session, "statistics:table:mytable", NULL, NULL, &cursor));
/*! [Statistics cursor table] */
/*! [Statistics cursor table fast] */
error_check(session->open_cursor(
session, "statistics:table:mytable", NULL, "statistics=(fast)", &cursor));
/*! [Statistics cursor table fast] */
/*! [Statistics clear configuration] */
error_check(
session->open_cursor(session, "statistics:", NULL, "statistics=(fast,clear)", &cursor));
/*! [Statistics clear configuration] */
/*! [Statistics cursor clear configuration] */
error_check(session->open_cursor(
session, "statistics:table:mytable", NULL, "statistics=(all,clear)", &cursor));
/*! [Statistics cursor clear configuration] */
/*! [Statistics cursor session] */
error_check(session->open_cursor(session, "statistics:session", NULL, NULL, &cursor));
/*! [Statistics cursor session] */
}
static void
named_snapshot_ops(WT_SESSION *session)
{
/*! [Snapshot examples] */
/* Create a named snapshot */
error_check(session->snapshot(session, "name=June01"));
/* Open a transaction at a given snapshot */
error_check(session->begin_transaction(session, "snapshot=June01"));
/* Drop all named snapshots */
error_check(session->snapshot(session, "drop=(all)"));
/*! [Snapshot examples] */
error_check(session->rollback_transaction(session, NULL));
}
static void
session_ops_create(WT_SESSION *session)
{
/*! [Create a table] */
error_check(session->create(session, "table:mytable", "key_format=S,value_format=S"));
/*! [Create a table] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Create a column-store table] */
error_check(session->create(session, "table:mytable", "key_format=r,value_format=S"));
/*! [Create a column-store table] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Create a table with columns] */
/*
* Create a table with columns: keys are record numbers, values are
* (string, signed 32-bit integer, unsigned 16-bit integer).
*/
error_check(session->create(session, "table:mytable",
"key_format=r,value_format=SiH,"
"columns=(id,department,salary,year-started)"));
/*! [Create a table with columns] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Create a table and configure the page size] */
error_check(session->create(session, "table:mytable",
"key_format=S,value_format=S,"
"internal_page_max=16KB,leaf_page_max=1MB,leaf_value_max=64KB"));
/*! [Create a table and configure the page size] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Create a table and configure a large leaf value max] */
error_check(session->create(session, "table:mytable",
"key_format=S,value_format=S,"
"leaf_page_max=16KB,leaf_value_max=256KB"));
/*! [Create a table and configure a large leaf value max] */
error_check(session->drop(session, "table:mytable", NULL));
/*
* This example code gets run, and the compression libraries might not be loaded, causing the create
* to fail. The documentation requires the code snippets, use #ifdef's to avoid running it.
*/
#ifdef MIGHT_NOT_RUN
/*! [Create a lz4 compressed table] */
error_check(session->create(
session, "table:mytable", "block_compressor=lz4,key_format=S,value_format=S"));
/*! [Create a lz4 compressed table] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Create a snappy compressed table] */
error_check(session->create(
session, "table:mytable", "block_compressor=snappy,key_format=S,value_format=S"));
/*! [Create a snappy compressed table] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Create a zlib compressed table] */
error_check(session->create(
session, "table:mytable", "block_compressor=zlib,key_format=S,value_format=S"));
/*! [Create a zlib compressed table] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Create a zstd compressed table] */
error_check(session->create(
session, "table:mytable", "block_compressor=zstd,key_format=S,value_format=S"));
/*! [Create a zstd compressed table] */
error_check(session->drop(session, "table:mytable", NULL));
#endif
/*! [Configure checksums to uncompressed] */
error_check(session->create(
session, "table:mytable", "key_format=S,value_format=S,checksum=uncompressed"));
/*! [Configure checksums to uncompressed] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Configure dictionary compression on] */
error_check(
session->create(session, "table:mytable", "key_format=S,value_format=S,dictionary=1000"));
/*! [Configure dictionary compression on] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Configure key prefix compression on] */
error_check(session->create(
session, "table:mytable", "key_format=S,value_format=S,prefix_compression=true"));
/*! [Configure key prefix compression on] */
error_check(session->drop(session, "table:mytable", NULL));
#ifdef MIGHT_NOT_RUN
/* Requires sync_file_range */
/*! [os_cache_dirty_max configuration] */
error_check(session->create(session, "table:mytable", "os_cache_dirty_max=500MB"));
/*! [os_cache_dirty_max configuration] */
error_check(session->drop(session, "table:mytable", NULL));
/* Requires posix_fadvise */
/*! [os_cache_max configuration] */
error_check(session->create(session, "table:mytable", "os_cache_max=1GB"));
/*! [os_cache_max configuration] */
error_check(session->drop(session, "table:mytable", NULL));
#endif
/*! [Configure block_allocation] */
error_check(session->create(
session, "table:mytable", "key_format=S,value_format=S,block_allocation=first"));
/*! [Configure block_allocation] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Create a cache-resident object] */
error_check(
session->create(session, "table:mytable", "key_format=r,value_format=S,cache_resident=true"));
/*! [Create a cache-resident object] */
error_check(session->drop(session, "table:mytable", NULL));
}
static void
session_ops(WT_SESSION *session)
{
WT_CONNECTION *conn;
conn = session->connection;
/* WT_SESSION.create operations. */
session_ops_create(session);
/*! [Reconfigure a session] */
error_check(session->reconfigure(session, "isolation=snapshot"));
/*! [Reconfigure a session] */
{
/* Create a table for the session operations. */
error_check(session->create(session, "table:mytable", "key_format=S,value_format=S"));
/*! [Alter a table] */
error_check(session->alter(session, "table:mytable", "access_pattern_hint=random"));
/*! [Alter a table] */
/*! [Compact a table] */
error_check(session->compact(session, "table:mytable", NULL));
/*! [Compact a table] */
#ifdef MIGHT_NOT_RUN
/*! [Import a file] */
error_check(session->import(session, "file:import", NULL));
/*! [Import a file] */
#endif
/*! [Rebalance a table] */
error_check(session->rebalance(session, "table:mytable", NULL));
/*! [Rebalance a table] */
error_check(
session->create(session, "table:old", "key_format=r,value_format=S,cache_resident=true"));
/*! [Rename a table] */
error_check(session->rename(session, "table:old", "table:new", NULL));
/*! [Rename a table] */
/*! [Salvage a table] */
error_check(session->salvage(session, "table:mytable", NULL));
/*! [Salvage a table] */
/*! [Truncate a table] */
error_check(session->truncate(session, "table:mytable", NULL, NULL, NULL));
/*! [Truncate a table] */
/*! [Transaction sync] */
error_check(session->transaction_sync(session, NULL));
/*! [Transaction sync] */
/*! [Reset the session] */
error_check(session->reset(session));
/*! [Reset the session] */
{
/*
* Insert a pair of keys so we can truncate a range.
*/
WT_CURSOR *cursor;
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
cursor->set_key(cursor, "June01");
cursor->set_value(cursor, "value");
error_check(cursor->update(cursor));
cursor->set_key(cursor, "June30");
cursor->set_value(cursor, "value");
error_check(cursor->update(cursor));
error_check(cursor->close(cursor));
{
/*! [Truncate a range] */
WT_CURSOR *start, *stop;
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &start));
start->set_key(start, "June01");
error_check(start->search(start));
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &stop));
stop->set_key(stop, "June30");
error_check(stop->search(stop));
error_check(session->truncate(session, NULL, start, stop, NULL));
/*! [Truncate a range] */
error_check(stop->close(stop));
error_check(start->close(start));
}
}
/*! [Upgrade a table] */
error_check(session->upgrade(session, "table:mytable", NULL));
/*! [Upgrade a table] */
/*! [Verify a table] */
error_check(session->verify(session, "table:mytable", NULL));
/*! [Verify a table] */
/*
* We can't call the backup function because it includes absolute paths for documentation
* purposes that don't exist on test systems. That said, we have to reference the function
* to avoid build warnings about unused static code.
*/
(void)backup;
/* Call other functions, where possible. */
checkpoint_ops(session);
error_check(cursor_ops(session));
cursor_statistics(session);
named_snapshot_ops(session);
pack_ops(session);
transaction_ops(session);
/*! [Close a session] */
error_check(session->close(session, NULL));
/*! [Close a session] */
/*
* We close the old session first to close all cursors, open a new one for the drop.
*/
error_check(conn->open_session(conn, NULL, NULL, &session));
/*! [Drop a table] */
error_check(session->drop(session, "table:mytable", NULL));
/*! [Drop a table] */
}
}
static void
transaction_ops(WT_SESSION *session_arg)
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
session = session_arg;
conn = session->connection;
/*! [transaction commit/rollback] */
/*
* Cursors may be opened before or after the transaction begins, and in either case, subsequent
* operations are included in the transaction. Opening cursors before the transaction begins
* allows applications to cache cursors and use them for multiple operations.
*/
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
error_check(session->begin_transaction(session, NULL));
cursor->set_key(cursor, "key");
cursor->set_value(cursor, "value");
switch (cursor->update(cursor)) {
case 0: /* Update success */
error_check(session->commit_transaction(session, NULL));
/*
* If commit_transaction succeeds, cursors remain positioned; if commit_transaction fails,
* the transaction was rolled-back and all cursors are reset.
*/
break;
case WT_ROLLBACK: /* Update conflict */
default: /* Other error */
error_check(session->rollback_transaction(session, NULL));
/* The rollback_transaction call resets all cursors. */
break;
}
/*
* Cursors remain open and may be used for multiple transactions.
*/
/*! [transaction commit/rollback] */
error_check(cursor->close(cursor));
/*! [transaction isolation] */
/* A single transaction configured for snapshot isolation. */
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
error_check(session->begin_transaction(session, "isolation=snapshot"));
cursor->set_key(cursor, "some-key");
cursor->set_value(cursor, "some-value");
error_check(cursor->update(cursor));
error_check(session->commit_transaction(session, NULL));
/*! [transaction isolation] */
{
/*! [transaction prepare] */
/*
* Prepare a transaction which guarantees a subsequent commit will succeed. Only commit and
* rollback are allowed on a transaction after it has been prepared.
*/
error_check(session->open_cursor(session, "table:mytable", NULL, NULL, &cursor));
error_check(session->begin_transaction(session, NULL));
cursor->set_key(cursor, "key");
cursor->set_value(cursor, "value");
error_check(session->prepare_transaction(session, "prepare_timestamp=2a"));
error_check(
session->commit_transaction(session, "commit_timestamp=2b,durable_timestamp=2b"));
/*! [transaction prepare] */
}
/*! [session isolation configuration] */
/* Open a session configured for read-uncommitted isolation. */
error_check(conn->open_session(conn, NULL, "isolation=read-uncommitted", &session));
/*! [session isolation configuration] */
/*! [session isolation re-configuration] */
/* Re-configure a session for snapshot isolation. */
error_check(session->reconfigure(session, "isolation=snapshot"));
/*! [session isolation re-configuration] */
error_check(session->close(session, NULL));
session = session_arg;
{
/*! [transaction pinned range] */
/* Check the transaction ID range pinned by the session handle. */
uint64_t range;
error_check(session->transaction_pinned_range(session, &range));
/*! [transaction pinned range] */
}
error_check(session->begin_transaction(session, NULL));
{
/*! [query timestamp] */
char timestamp_buf[2 * sizeof(uint64_t) + 1];
/*! [transaction timestamp] */
error_check(session->timestamp_transaction(session, "commit_timestamp=2a"));
/*! [transaction timestamp] */
error_check(session->commit_transaction(session, NULL));
error_check(conn->query_timestamp(conn, timestamp_buf, "get=all_committed"));
/*! [query timestamp] */
}
/*! [set commit timestamp] */
error_check(conn->set_timestamp(conn, "commit_timestamp=2a"));
/*! [set commit timestamp] */
/*! [set oldest timestamp] */
error_check(conn->set_timestamp(conn, "oldest_timestamp=2a"));
/*! [set oldest timestamp] */
/*! [set stable timestamp] */
error_check(conn->set_timestamp(conn, "stable_timestamp=2a"));
/*! [set stable timestamp] */
/*! [rollback to stable] */
error_check(conn->rollback_to_stable(conn, NULL));
/*! [rollback to stable] */
}
/*! [Implement WT_COLLATOR] */
/*
* A simple example of the collator API: compare the keys as strings.
*/
static int
my_compare(WT_COLLATOR *collator, WT_SESSION *session, const WT_ITEM *value1, const WT_ITEM *value2,
int *cmp)
{
const char *p1, *p2;
/* Unused parameters */
(void)collator;
(void)session;
p1 = (const char *)value1->data;
p2 = (const char *)value2->data;
for (; *p1 != '\0' && *p1 == *p2; ++p1, ++p2)
;
*cmp = (int)*p2 - (int)*p1;
return (0);
}
/*! [Implement WT_COLLATOR] */
static void
add_collator(WT_CONNECTION *conn)
{
/*! [WT_COLLATOR register] */
static WT_COLLATOR my_collator = {my_compare, NULL, NULL};
error_check(conn->add_collator(conn, "my_collator", &my_collator, NULL));
/*! [WT_COLLATOR register] */
}
/*! [WT_EXTRACTOR] */
static int
my_extract(WT_EXTRACTOR *extractor, WT_SESSION *session, const WT_ITEM *key, const WT_ITEM *value,
WT_CURSOR *result_cursor)
{
/* Unused parameters */
(void)extractor;
(void)session;
(void)key;
result_cursor->set_key(result_cursor, value);
return (result_cursor->insert(result_cursor));
}
/*! [WT_EXTRACTOR] */
static void
add_extractor(WT_CONNECTION *conn)
{
/*! [WT_EXTRACTOR register] */
static WT_EXTRACTOR my_extractor = {my_extract, NULL, NULL};
error_check(conn->add_extractor(conn, "my_extractor", &my_extractor, NULL));
/*! [WT_EXTRACTOR register] */
}
static void
connection_ops(WT_CONNECTION *conn)
{
#ifdef MIGHT_NOT_RUN
/*! [Load an extension] */
error_check(conn->load_extension(conn, "my_extension.dll", NULL));
error_check(conn->load_extension(
conn, "datasource/libdatasource.so", "config=[device=/dev/sd1,alignment=64]"));
/*! [Load an extension] */
#endif
add_collator(conn);
add_extractor(conn);
/*! [Reconfigure a connection] */
error_check(conn->reconfigure(conn, "eviction_target=75"));
/*! [Reconfigure a connection] */
/*! [Get the database home directory] */
printf("The database home is %s\n", conn->get_home(conn));
/*! [Get the database home directory] */
/*! [Check if the database is newly created] */
if (conn->is_new(conn)) {
/* First time initialization. */
}
/*! [Check if the database is newly created] */
/*! [Validate a configuration string] */
/*
* Validate a configuration string for a WiredTiger function or method.
*
* Functions are specified by name (for example, "wiredtiger_open").
*
* Methods are specified using a concatenation of the handle name, a
* period and the method name (for example, session create would be
* "WT_SESSION.create" and cursor close would be WT_CURSOR.close").
*/
error_check(
wiredtiger_config_validate(NULL, NULL, "WT_SESSION.create", "allocation_size=32KB"));
/*! [Validate a configuration string] */
{
/*! [Open a session] */
WT_SESSION *session;
error_check(conn->open_session(conn, NULL, NULL, &session));
/*! [Open a session] */
session_ops(session);
}
/*! [Configure method configuration] */
/*
* Applications opening a cursor for the data-source object "my_data"
* have an additional configuration option "entries", which is an
* integer type, defaults to 5, and must be an integer between 1 and 10.
*
* The method being configured is specified using a concatenation of the
* handle name, a period and the method name.
*/
error_check(conn->configure_method(
conn, "WT_SESSION.open_cursor", "my_data:", "entries=5", "int", "min=1,max=10"));
/*
* Applications opening a cursor for the data-source object "my_data" have an additional
* configuration option "devices", which is a list of strings.
*/
error_check(
conn->configure_method(conn, "WT_SESSION.open_cursor", "my_data:", "devices", "list", NULL));
/*! [Configure method configuration] */
/*! [Close a connection] */
error_check(conn->close(conn, NULL));
/*! [Close a connection] */
}
static void
pack_ops(WT_SESSION *session)
{
{
/*! [Get the packed size] */
size_t size;
error_check(wiredtiger_struct_size(session, &size, "iSh", 42, "hello", -3));
/*! [Get the packed size] */
}
{
/*! [Pack fields into a buffer] */
char buf[100];
error_check(wiredtiger_struct_pack(session, buf, sizeof(buf), "iSh", 42, "hello", -3));
/*! [Pack fields into a buffer] */
{
/*! [Unpack fields from a buffer] */
int i;
char *s;
short h;
error_check(wiredtiger_struct_unpack(session, buf, sizeof(buf), "iSh", &i, &s, &h));
/*! [Unpack fields from a buffer] */
}
}
}
static void
backup(WT_SESSION *session)
{
char buf[1024];
/*! [backup]*/
WT_CURSOR *cursor;
const char *filename;
int ret;
/* Create the backup directory. */
error_check(mkdir("/path/database.backup", 077));
/* Open the backup data source. */
error_check(session->open_cursor(session, "backup:", NULL, NULL, &cursor));
/* Copy the list of files. */
while ((ret = cursor->next(cursor)) == 0) {
error_check(cursor->get_key(cursor, &filename));
(void)snprintf(
buf, sizeof(buf), "cp /path/database/%s /path/database.backup/%s", filename, filename);
error_check(system(buf));
}
scan_end_check(ret == WT_NOTFOUND);
error_check(cursor->close(cursor));
/*! [backup]*/
/*! [incremental backup]*/
/* Open the backup data source for incremental backup. */
error_check(session->open_cursor(session, "backup:", NULL, "target=(\"log:\")", &cursor));
/*! [incremental backup]*/
error_check(cursor->close(cursor));
/*! [backup of a checkpoint]*/
error_check(session->checkpoint(session, "drop=(from=June01),name=June01"));
/*! [backup of a checkpoint]*/
}
int
main(int argc, char *argv[])
{
WT_CONNECTION *conn;
home = example_setup(argc, argv);
/*! [Open a connection] */
error_check(wiredtiger_open(
home, NULL, "create,cache_size=5GB,log=(enabled,recover=on),statistics=(all)", &conn));
/*! [Open a connection] */
connection_ops(conn);
/*
* The connection has been closed.
*/
#ifdef MIGHT_NOT_RUN
/*
* This example code gets run, and the compression libraries might not be installed, causing the
* open to fail. The documentation requires the code snippets, use #ifdef's to avoid running it.
*/
/*! [Configure lz4 extension] */
error_check(wiredtiger_open(home, NULL,
"create,"
"extensions=[/usr/local/lib/libwiredtiger_lz4.so]",
&conn));
/*! [Configure lz4 extension] */
error_check(conn->close(conn, NULL));
/*! [Configure snappy extension] */
error_check(wiredtiger_open(home, NULL,
"create,"
"extensions=[/usr/local/lib/libwiredtiger_snappy.so]",
&conn));
/*! [Configure snappy extension] */
error_check(conn->close(conn, NULL));
/*! [Configure zlib extension] */
error_check(wiredtiger_open(home, NULL,
"create,"
"extensions=[/usr/local/lib/libwiredtiger_zlib.so]",
&conn));
/*! [Configure zlib extension] */
error_check(conn->close(conn, NULL));
/*! [Configure zlib extension with compression level] */
error_check(wiredtiger_open(home, NULL,
"create,"
"extensions=[/usr/local/lib/"
"libwiredtiger_zlib.so=[config=[compression_level=3]]]",
&conn));
/*! [Configure zlib extension with compression level] */
error_check(conn->close(conn, NULL));
/*! [Configure zstd extension] */
error_check(wiredtiger_open(home, NULL,
"create,"
"extensions=[/usr/local/lib/libwiredtiger_zstd.so]",
&conn));
/*! [Configure zstd extension] */
error_check(conn->close(conn, NULL));
/*! [Configure zstd extension with compression level] */
error_check(wiredtiger_open(home, NULL,
"create,"
"extensions=[/usr/local/lib/"
"libwiredtiger_zstd.so=[config=[compression_level=9]]]",
&conn));
/*! [Configure zstd extension with compression level] */
error_check(conn->close(conn, NULL));
/*
* This example code gets run, and direct I/O might not be available, causing the open to fail.
* The documentation requires code snippets, use #ifdef's to avoid running it.
*/
/* Might Not Run: direct I/O may not be available. */
/*! [Configure direct_io for data files] */
error_check(wiredtiger_open(home, NULL, "create,direct_io=[data]", &conn));
/*! [Configure direct_io for data files] */
error_check(conn->close(conn, NULL));
#endif
/*! [Configure file_extend] */
error_check(wiredtiger_open(home, NULL, "create,file_extend=(data=16MB)", &conn));
/*! [Configure file_extend] */
error_check(conn->close(conn, NULL));
/*! [Configure capacity] */
error_check(wiredtiger_open(home, NULL, "create,io_capacity=(total=40MB)", &conn));
/*! [Configure capacity] */
error_check(conn->close(conn, NULL));
/*! [Eviction configuration] */
/*
* Configure eviction to begin at 90% full, and run until the cache is only 75% dirty.
*/
error_check(
wiredtiger_open(home, NULL, "create,eviction_trigger=90,eviction_dirty_target=75", &conn));
/*! [Eviction configuration] */
error_check(conn->close(conn, NULL));
/*! [Eviction worker configuration] */
/* Configure up to four eviction threads */
error_check(
wiredtiger_open(home, NULL, "create,eviction_trigger=90,eviction=(threads_max=4)", &conn));
/*! [Eviction worker configuration] */
error_check(conn->close(conn, NULL));
/*! [Statistics configuration] */
error_check(wiredtiger_open(home, NULL, "create,statistics=(all)", &conn));
/*! [Statistics configuration] */
error_check(conn->close(conn, NULL));
/*! [Statistics logging] */
error_check(wiredtiger_open(home, NULL, "create,statistics_log=(wait=30)", &conn));
/*! [Statistics logging] */
error_check(conn->close(conn, NULL));
#ifdef MIGHT_NOT_RUN
/*
* Don't run this code, statistics logging doesn't yet support tables.
*/
/*! [Statistics logging with a table] */
error_check(wiredtiger_open(home, NULL,
"create, statistics_log=("
"sources=(\"table:table1\",\"table:table2\"), wait=5)",
&conn));
/*! [Statistics logging with a table] */
error_check(conn->close(conn, NULL));
/*
* Don't run this code, statistics logging doesn't yet support indexes.
*/
/*! [Statistics logging with a source type] */
error_check(
wiredtiger_open(home, NULL, "create, statistics_log=(sources=(\"index:\"), wait=5)", &conn));
/*! [Statistics logging with a source type] */
error_check(conn->close(conn, NULL));
/*
* Don't run this code, because memory checkers get very upset when we leak memory.
*/
error_check(wiredtiger_open(home, NULL, "create", &conn));
/*! [Connection close leaking memory] */
error_check(conn->close(conn, "leak_memory=true"));
/*! [Connection close leaking memory] */
#endif
/*! [Get the WiredTiger library version #1] */
printf("WiredTiger version %s\n", wiredtiger_version(NULL, NULL, NULL));
/*! [Get the WiredTiger library version #1] */
{
/*! [Get the WiredTiger library version #2] */
int major_v, minor_v, patch;
(void)wiredtiger_version(&major_v, &minor_v, &patch);
printf("WiredTiger version is %d, %d (patch %d)\n", major_v, minor_v, patch);
/*! [Get the WiredTiger library version #2] */
}
{
/*! [Calculate a modify operation] */
WT_MODIFY mod[3];
int nmod = 3;
WT_ITEM prev, newv;
prev.data =
"the quick brown fox jumped over the lazy dog. "
"THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. "
"the quick brown fox jumped over the lazy dog. "
"THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. ";
prev.size = strlen(prev.data);
newv.data =
"A quick brown fox jumped over the lazy dog. "
"THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. "
"then a quick brown fox jumped over the lazy dog. "
"THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. "
"then what?";
newv.size = strlen(newv.data);
error_check(wiredtiger_calc_modify(NULL, &prev, &newv, 20, mod, &nmod));
/*! [Calculate a modify operation] */
}
{
const char *buffer = "some string";
size_t len = strlen(buffer);
/*! [Checksum a buffer] */
uint32_t crc32c, (*func)(const void *, size_t);
func = wiredtiger_crc32c_func();
crc32c = func(buffer, len);
/*! [Checksum a buffer] */
(void)crc32c;
}
return (EXIT_SUCCESS);
}
|