9 |
10 | // Chainable struct used to store host information.
11 | typedef struct RepHostInfoObj{
12 | bool creator;
13 | char* host;
14 | int port;
15 | bool peer; // only relevant for "other" hosts
16 | RepHostInfoObj* next; // used for chaining multiple "other" hosts.
17 | } REP_HOST_INFO;
18 |
19 | class RepConfigInfo {
20 | public:
21 | RepConfigInfo();
22 | virtual ~RepConfigInfo();
23 |
24 | void addOtherHost(char* host, int port, bool peer);
25 | public:
26 | u_int32_t start_policy;
27 | const char* home;
28 | bool got_listen_address;
29 | REP_HOST_INFO this_host;
30 | int nrsites;
31 | int priority;
32 | bool verbose;
33 | // used to store a set of optional other hosts.
34 | REP_HOST_INFO *other_hosts;
35 | int ack_policy;
36 | bool bulk;
37 | };
38 |
--------------------------------------------------------------------------------
/lang/cxx/cxx_dbt.cpp:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | #include "db_cxx.h"
14 | #include "dbinc/cxx_int.h"
15 |
16 | #include "dbinc/db_page.h"
17 | #include "dbinc_auto/db_auto.h"
18 | #include "dbinc_auto/crdel_auto.h"
19 | #include "dbinc/db_dispatch.h"
20 | #include "dbinc_auto/db_ext.h"
21 | #include "dbinc_auto/common_ext.h"
22 |
23 | Dbt::Dbt()
24 | {
25 | DBT *dbt = this;
26 | memset(dbt, 0, sizeof(DBT));
27 | }
28 |
29 | Dbt::Dbt(void *data_arg, u_int32_t size_arg)
30 | {
31 | DBT *dbt = this;
32 | memset(dbt, 0, sizeof(DBT));
33 | set_data(data_arg);
34 | set_size(size_arg);
35 | }
36 |
37 | Dbt::~Dbt()
38 | {
39 | }
40 |
41 | Dbt::Dbt(const Dbt &that)
42 | {
43 | const DBT *from = &that;
44 | DBT *to = this;
45 | memcpy(to, from, sizeof(DBT));
46 | }
47 |
48 | Dbt &Dbt::operator = (const Dbt &that)
49 | {
50 | if (this != &that) {
51 | const DBT *from = &that;
52 | DBT *to = this;
53 | memcpy(to, from, sizeof(DBT));
54 | }
55 | return (*this);
56 | }
57 |
--------------------------------------------------------------------------------
/lang/cxx/cxx_lock.cpp:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | #include "db_cxx.h"
14 | #include "dbinc/cxx_int.h"
15 |
16 | ////////////////////////////////////////////////////////////////////////
17 | // //
18 | // DbLock //
19 | // //
20 | ////////////////////////////////////////////////////////////////////////
21 |
22 | DbLock::DbLock(DB_LOCK value)
23 | : lock_(value)
24 | {
25 | }
26 |
27 | DbLock::DbLock()
28 | {
29 | memset(&lock_, 0, sizeof(DB_LOCK));
30 | }
31 |
32 | DbLock::DbLock(const DbLock &that)
33 | : lock_(that.lock_)
34 | {
35 | }
36 |
37 | DbLock &DbLock::operator = (const DbLock &that)
38 | {
39 | lock_ = that.lock_;
40 | return (*this);
41 | }
42 |
--------------------------------------------------------------------------------
/lang/cxx/cxx_rid.cpp:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | #include "db_cxx.h"
14 |
15 | DbHeapRecordId::DbHeapRecordId()
16 | {
17 | DB_HEAP_RID *rid = this;
18 | memset(rid, 0, sizeof(DB_HEAP_RID));
19 | }
20 |
21 | DbHeapRecordId::DbHeapRecordId(db_pgno_t pgno_arg, db_indx_t indx_arg)
22 | {
23 | DB_HEAP_RID *rid = this;
24 | memset(rid, 0, sizeof(DB_HEAP_RID));
25 | set_pgno(pgno_arg);
26 | set_indx(indx_arg);
27 | }
28 |
29 | DbHeapRecordId::~DbHeapRecordId()
30 | {
31 | }
32 |
33 | DbHeapRecordId::DbHeapRecordId(const DbHeapRecordId &that)
34 | {
35 | const DB_HEAP_RID *from = &that;
36 | memcpy((DB_HEAP_RID *)this, from, sizeof(DB_HEAP_RID));
37 | }
38 |
39 | DbHeapRecordId &DbHeapRecordId::operator = (const DbHeapRecordId &that)
40 | {
41 | if (this != &that) {
42 | const DB_HEAP_RID *from = &that;
43 | memcpy((DB_HEAP_RID *)this, from, sizeof(DB_HEAP_RID));
44 | }
45 | return (*this);
46 | }
47 |
--------------------------------------------------------------------------------
/lang/cxx/stl/dbstl_utility.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/berkeleydb/libdb/5b7b02ae052442626af54c176335b67ecc613a30/lang/cxx/stl/dbstl_utility.h
--------------------------------------------------------------------------------
/lang/tcl/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Complete Tcl Interface for Berkeley DB
12 |
13 |
17 |
18 |
37 |
38 |
51 |
--------------------------------------------------------------------------------
/lang/tcl/docs/library.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Convenience Commands
11 | The convenience commands are provided for ease of use with the DB test
12 | suite.
13 | > berkdb rand
14 |
This command will invoke the rand function and return the random number.
15 |
16 |
> berkdb random_int low high
17 | This command will invoke the rand function and return a number between
18 | low
19 | and high.
20 |
21 |
22 | > berkdb srand seed
23 |
This command will invoke the srand function with the given seed
24 | and return 0.
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/clib/bsearch.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * bsearch --
15 | *
16 | * PUBLIC: #ifndef HAVE_BSEARCH
17 | * PUBLIC: void *bsearch __P((const void *, const void *, size_t,
18 | * PUBLIC: size_t, int (*)(const void *, const void *)));
19 | * PUBLIC: #endif
20 | */
21 |
22 | void *bsearch(key, base, nmemb, size, cmp)
23 | const void *key;
24 | const void *base;
25 | size_t nmemb;
26 | size_t size;
27 | int (*cmp) __P((const void *, const void *));
28 | {
29 | size_t i;
30 |
31 | /* not doing a binary search, but searching linearly */
32 | for (i=0; i < nmemb; i++) {
33 | if ((*cmp)(key, (const void *)((char *)base + i * size)) == 0)
34 | return ((void *)((char *)base + i * size));
35 | }
36 |
37 | return (NULL);
38 | }
39 |
--------------------------------------------------------------------------------
/src/clib/isalpha.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * isalpha --
15 | *
16 | * PUBLIC: #ifndef HAVE_ISALPHA
17 | * PUBLIC: int isalpha __P((int));
18 | * PUBLIC: #endif
19 | */
20 | int
21 | isalpha(c)
22 | int c;
23 | {
24 | /*
25 | * Depends on ASCII-like character ordering.
26 | */
27 | return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ? 1 : 0);
28 | }
29 |
--------------------------------------------------------------------------------
/src/clib/isdigit.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * isdigit --
15 | *
16 | * PUBLIC: #ifndef HAVE_ISDIGIT
17 | * PUBLIC: int isdigit __P((int));
18 | * PUBLIC: #endif
19 | */
20 | int
21 | isdigit(c)
22 | int c;
23 | {
24 | /*
25 | * Depends on ASCII-like character ordering.
26 | */
27 | return (c >= '0' && c <= '9' ? 1 : 0);
28 | }
29 |
--------------------------------------------------------------------------------
/src/clib/isprint.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * isprint --
15 | *
16 | * PUBLIC: #ifndef HAVE_ISPRINT
17 | * PUBLIC: int isprint __P((int));
18 | * PUBLIC: #endif
19 | */
20 | int
21 | isprint(c)
22 | int c;
23 | {
24 | /*
25 | * Depends on ASCII character values.
26 | */
27 | return ((c >= ' ' && c <= '~') ? 1 : 0);
28 | }
29 |
--------------------------------------------------------------------------------
/src/clib/isspace.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * isspace --
15 | *
16 | * PUBLIC: #ifndef HAVE_ISSPACE
17 | * PUBLIC: int isspace __P((int));
18 | * PUBLIC: #endif
19 | */
20 | int
21 | isspace(c)
22 | int c;
23 | {
24 | return (c == '\t' || c == '\n' ||
25 | c == '\v' || c == '\f' || c == '\r' || c == ' ' ? 1 : 0);
26 | }
27 |
--------------------------------------------------------------------------------
/src/clib/raise.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * raise --
15 | * Send a signal to the current process.
16 | *
17 | * PUBLIC: #ifndef HAVE_RAISE
18 | * PUBLIC: int raise __P((int));
19 | * PUBLIC: #endif
20 | */
21 | int
22 | raise(s)
23 | int s;
24 | {
25 | return (kill(getpid(), s));
26 | }
27 |
--------------------------------------------------------------------------------
/src/clib/rand.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copied from the ANSI C standard 4.10.2.2.
3 | */
4 | #include "db_config.h"
5 |
6 | #include "db_int.h"
7 |
8 | /*
9 | * rand, srand --
10 | *
11 | * PUBLIC: #ifndef HAVE_RAND
12 | * PUBLIC: int rand __P((void));
13 | * PUBLIC: void srand __P((unsigned int));
14 | * PUBLIC: #endif
15 | */
16 | int rand(void) /* RAND_MAX assumed to be 32767 */
17 | {
18 | DB_GLOBAL(rand_next) = DB_GLOBAL(rand_next) * 1103515245 + 12345;
19 | return (unsigned int) (DB_GLOBAL(rand_next)/65536) % 32768;
20 | }
21 |
22 | void srand(unsigned int seed)
23 | {
24 | DB_GLOBAL(rand_next) = seed;
25 | }
26 |
--------------------------------------------------------------------------------
/src/clib/time.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2006, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * time --
15 | *
16 | * PUBLIC: #ifndef HAVE_TIME
17 | * PUBLIC: time_t time __P((time_t *));
18 | * PUBLIC: #endif
19 | */
20 | time_t
21 | time(nowp)
22 | time_t *nowp;
23 | {
24 | db_timespec t;
25 | time_t res;
26 |
27 | __os_gettime(NULL, &t, 0);
28 |
29 | res = t.tv_sec + t.tv_nsec / NS_PER_SEC;
30 |
31 | if (nowp != NULL)
32 | *nowp = res;
33 | return (res);
34 | }
35 |
--------------------------------------------------------------------------------
/src/common/clock.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 | /*
13 | * __clock_set_expires --
14 | * Set the expire time given the time to live.
15 | *
16 | * PUBLIC: void __clock_set_expires __P((ENV *, db_timespec *, db_timeout_t));
17 | */
18 | void
19 | __clock_set_expires(env, timespecp, timeout)
20 | ENV *env;
21 | db_timespec *timespecp;
22 | db_timeout_t timeout;
23 | {
24 | db_timespec v;
25 |
26 | /*
27 | * If timespecp is set then it contains "now". This avoids repeated
28 | * system calls to get the time.
29 | */
30 | if (!timespecisset(timespecp))
31 | __os_gettime(env, timespecp, 1);
32 |
33 | /* Convert the microsecond timeout argument to a timespec. */
34 | DB_TIMEOUT_TO_TIMESPEC(timeout, &v);
35 |
36 | /* Add the timeout to "now". */
37 | timespecadd(timespecp, &v);
38 | }
39 |
40 | /*
41 | * __clock_expired -- determine if a timeout has expired.
42 | *
43 | * PUBLIC: int __clock_expired __P((ENV *, db_timespec *, db_timespec *));
44 | */
45 | int
46 | __clock_expired(env, now, timespecp)
47 | ENV *env;
48 | db_timespec *now, *timespecp;
49 | {
50 | if (!timespecisset(timespecp))
51 | return (0);
52 |
53 | if (!timespecisset(now))
54 | __os_gettime(env, now, 1);
55 |
56 | return (timespeccmp(now, timespecp, >=));
57 | }
58 |
--------------------------------------------------------------------------------
/src/common/crypto_stub.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __crypto_region_init --
15 | * Initialize crypto.
16 | *
17 | *
18 | * !!!
19 | * We don't put this stub file in the crypto/ directory of the distribution
20 | * because that entire directory is removed for non-crypto distributions.
21 | *
22 | * PUBLIC: int __crypto_region_init __P((ENV *));
23 | */
24 | int
25 | __crypto_region_init(env)
26 | ENV *env;
27 | {
28 | REGENV *renv;
29 | REGINFO *infop;
30 | int ret;
31 |
32 | infop = env->reginfo;
33 | renv = infop->primary;
34 | MUTEX_LOCK(env, renv->mtx_regenv);
35 | ret = !(renv->cipher_off == INVALID_ROFF);
36 | MUTEX_UNLOCK(env, renv->mtx_regenv);
37 |
38 | if (ret == 0)
39 | return (0);
40 |
41 | __db_errx(env, DB_STR("0040",
42 | "Encrypted environment: library build did not include cryptography support"));
43 | return (DB_OPNOTSUP);
44 | }
45 |
--------------------------------------------------------------------------------
/src/common/db_byteorder.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __db_isbigendian --
15 | * Return 1 if big-endian (Motorola and Sparc), not little-endian
16 | * (Intel and Vax). We do this work at run-time, rather than at
17 | * configuration time so cross-compilation and general embedded
18 | * system support is simpler.
19 | *
20 | * PUBLIC: int __db_isbigendian __P((void));
21 | */
22 | int
23 | __db_isbigendian()
24 | {
25 | union { /* From Harbison & Steele. */
26 | long l;
27 | char c[sizeof(long)];
28 | } u;
29 |
30 | u.l = 1;
31 | return (u.c[sizeof(long) - 1] == 1);
32 | }
33 |
34 | /*
35 | * __db_byteorder --
36 | * Return if we need to do byte swapping, checking for illegal
37 | * values.
38 | *
39 | * PUBLIC: int __db_byteorder __P((ENV *, int));
40 | */
41 | int
42 | __db_byteorder(env, lorder)
43 | ENV *env;
44 | int lorder;
45 | {
46 | switch (lorder) {
47 | case 0:
48 | break;
49 | case 1234:
50 | if (!F_ISSET(env, ENV_LITTLEENDIAN))
51 | return (DB_SWAPBYTES);
52 | break;
53 | case 4321:
54 | if (F_ISSET(env, ENV_LITTLEENDIAN))
55 | return (DB_SWAPBYTES);
56 | break;
57 | default:
58 | __db_errx(env, DB_STR("0041",
59 | "unsupported byte order, only big and little-endian supported"));
60 | return (EINVAL);
61 | }
62 | return (0);
63 | }
64 |
--------------------------------------------------------------------------------
/src/common/openflags.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __db_openflags --
15 | * Convert open(2) flags to DB flags.
16 | *
17 | * PUBLIC: u_int32_t __db_openflags __P((int));
18 | */
19 | u_int32_t
20 | __db_openflags(oflags)
21 | int oflags;
22 | {
23 | u_int32_t dbflags;
24 |
25 | dbflags = 0;
26 |
27 | if (oflags & O_CREAT)
28 | dbflags |= DB_CREATE;
29 |
30 | if (oflags & O_TRUNC)
31 | dbflags |= DB_TRUNCATE;
32 |
33 | /*
34 | * !!!
35 | * Convert POSIX 1003.1 open(2) mode flags to DB flags. This isn't
36 | * an exact science as few POSIX implementations have a flag value
37 | * for O_RDONLY, it's simply the lack of a write flag.
38 | */
39 | #ifndef O_ACCMODE
40 | #define O_ACCMODE (O_RDONLY | O_RDWR | O_WRONLY)
41 | #endif
42 | switch (oflags & O_ACCMODE) {
43 | case O_RDWR:
44 | case O_WRONLY:
45 | break;
46 | default:
47 | dbflags |= DB_RDONLY;
48 | break;
49 | }
50 | return (dbflags);
51 | }
52 |
--------------------------------------------------------------------------------
/src/common/util_arg.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2001, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | #if DB_VERSION_MAJOR < 4 || DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 5
14 | /*
15 | * !!!
16 | * We build this file in old versions of Berkeley DB when we're doing test
17 | * runs using the test_micro tool. Without a prototype in place, we get
18 | * warnings, and there's no simple workaround.
19 | */
20 | char *strsep();
21 | #endif
22 |
23 | /*
24 | * __db_util_arg --
25 | * Convert a string into an argc/argv pair.
26 | *
27 | * PUBLIC: int __db_util_arg __P((char *, char *, int *, char ***));
28 | */
29 | int
30 | __db_util_arg(arg0, str, argcp, argvp)
31 | char *arg0, *str, ***argvp;
32 | int *argcp;
33 | {
34 | int n, ret;
35 | char **ap, **argv;
36 |
37 | #define MAXARGS 25
38 | if ((ret =
39 | __os_malloc(NULL, (MAXARGS + 1) * sizeof(char **), &argv)) != 0)
40 | return (ret);
41 |
42 | ap = argv;
43 | *ap++ = arg0;
44 | for (n = 1; (*ap = strsep(&str, " \t")) != NULL;)
45 | if (**ap != '\0') {
46 | ++ap;
47 | if (++n == MAXARGS)
48 | break;
49 | }
50 | *ap = NULL;
51 |
52 | *argcp = (int)(ap - argv);
53 | *argvp = argv;
54 |
55 | return (0);
56 | }
57 |
--------------------------------------------------------------------------------
/src/common/util_cache.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __db_util_cache --
15 | * Compute if we have enough cache.
16 | *
17 | * PUBLIC: int __db_util_cache __P((DB *, u_int32_t *, int *));
18 | */
19 | int
20 | __db_util_cache(dbp, cachep, resizep)
21 | DB *dbp;
22 | u_int32_t *cachep;
23 | int *resizep;
24 | {
25 | u_int32_t pgsize;
26 | int ret;
27 |
28 | /* Get the current page size. */
29 | if ((ret = dbp->get_pagesize(dbp, &pgsize)) != 0)
30 | return (ret);
31 |
32 | /*
33 | * The current cache size is in cachep. If it's insufficient, set the
34 | * the memory referenced by resizep to 1 and set cachep to the minimum
35 | * size needed.
36 | *
37 | * Make sure our current cache is big enough. We want at least
38 | * DB_MINPAGECACHE pages in the cache.
39 | */
40 | if ((*cachep / pgsize) < DB_MINPAGECACHE) {
41 | *resizep = 1;
42 | *cachep = pgsize * DB_MINPAGECACHE;
43 | } else
44 | *resizep = 0;
45 |
46 | return (0);
47 | }
48 |
--------------------------------------------------------------------------------
/src/common/util_log.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __db_util_logset --
15 | * Log that we're running.
16 | *
17 | * PUBLIC: int __db_util_logset __P((const char *, char *));
18 | */
19 | int
20 | __db_util_logset(progname, fname)
21 | const char *progname;
22 | char *fname;
23 | {
24 | pid_t pid;
25 | FILE *fp;
26 | time_t now;
27 | char time_buf[CTIME_BUFLEN];
28 |
29 | if ((fp = fopen(fname, "w")) == NULL)
30 | goto err;
31 |
32 | (void)time(&now);
33 |
34 | __os_id(NULL, &pid, NULL);
35 | fprintf(fp,
36 | "%s: %lu %s", progname, (u_long)pid, __os_ctime(&now, time_buf));
37 |
38 | if (fclose(fp) == EOF)
39 | goto err;
40 |
41 | return (0);
42 |
43 | err: fprintf(stderr, "%s: %s: %s\n", progname, fname, strerror(errno));
44 | return (1);
45 | }
46 |
--------------------------------------------------------------------------------
/src/crypto/rijndael/rijndael-alg-fst.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | */
4 | /**
5 | * rijndael-alg-fst.h
6 | *
7 | * @version 3.0 (December 2000)
8 | *
9 | * Optimised ANSI C code for the Rijndael cipher (now AES)
10 | *
11 | * @author Vincent Rijmen
12 | * @author Antoon Bosselaers
13 | * @author Paulo Barreto
14 | *
15 | * This code is hereby placed in the public domain.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 | #ifndef __RIJNDAEL_ALG_FST_H
30 | #define __RIJNDAEL_ALG_FST_H
31 |
32 | #define MAXKC (256/32)
33 | #define MAXKB (256/8)
34 | #define MAXNR 14
35 |
36 | typedef u_int8_t u8;
37 | typedef u_int16_t u16;
38 | typedef u_int32_t u32;
39 |
40 | #endif /* __RIJNDAEL_ALG_FST_H */
41 |
--------------------------------------------------------------------------------
/src/db/db_copy.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 | #include "db_int.h"
11 | #include "dbinc/db_page.h"
12 | #include "dbinc/db_am.h"
13 |
14 | /*
15 | * db_copy --
16 | * Copy a database file coordinated with mpool.
17 | * This is for backward compatibility to the quick fix in 5.2.
18 | *
19 | * EXTERN: int db_copy __P((DB_ENV *,
20 | * EXTERN: const char *, const char *, const char *));
21 | */
22 | int
23 | db_copy(dbenv, dbfile, target, passwd)
24 | DB_ENV *dbenv;
25 | const char *dbfile;
26 | const char *target;
27 | const char *passwd;
28 | {
29 | COMPQUIET(passwd, NULL);
30 | return (__db_dbbackup_pp(dbenv, dbfile, target, 0));
31 | }
32 |
--------------------------------------------------------------------------------
/src/dbinc/db_join.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #ifndef _DB_JOIN_H_
10 | #define _DB_JOIN_H_
11 |
12 | #if defined(__cplusplus)
13 | extern "C" {
14 | #endif
15 |
16 | /*
17 | * Joins use a join cursor that is similar to a regular DB cursor except
18 | * that it only supports c_get and c_close functionality. Also, it does
19 | * not support the full range of flags for get.
20 | */
21 | typedef struct __join_cursor {
22 | u_int8_t *j_exhausted; /* Array of flags; is cursor i exhausted? */
23 | DBC **j_curslist; /* Array of cursors in the join: constant. */
24 | DBC **j_fdupcurs; /* Cursors w/ first instances of current dup. */
25 | DBC **j_workcurs; /* Scratch cursor copies to muck with. */
26 | DB *j_primary; /* Primary dbp. */
27 | DBT j_key; /* Used to do lookups. */
28 | DBT j_rdata; /* Memory used for data return. */
29 | u_int32_t j_ncurs; /* How many cursors do we have? */
30 | #define JOIN_RETRY 0x01 /* Error on primary get; re-return same key. */
31 | u_int32_t flags;
32 | } JOIN_CURSOR;
33 |
34 | #if defined(__cplusplus)
35 | }
36 | #endif
37 | #endif /* !_DB_JOIN_H_ */
38 |
--------------------------------------------------------------------------------
/src/dbinc/fop.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2001, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #ifndef _DB_FOP_H_
10 | #define _DB_FOP_H_
11 |
12 | #if defined(__cplusplus)
13 | extern "C" {
14 | #endif
15 |
16 | #define MAKE_INMEM(D) do { \
17 | F_SET((D), DB_AM_INMEM); \
18 | (void)__memp_set_flags((D)->mpf, DB_MPOOL_NOFILE, 1); \
19 | } while (0)
20 |
21 | #define CLR_INMEM(D) do { \
22 | F_CLR((D), DB_AM_INMEM); \
23 | (void)__memp_set_flags((D)->mpf, DB_MPOOL_NOFILE, 0); \
24 | } while (0)
25 |
26 | #include "dbinc_auto/fileops_auto.h"
27 | #include "dbinc_auto/fileops_ext.h"
28 |
29 | #if defined(__cplusplus)
30 | }
31 | #endif
32 | #endif /* !_DB_FOP_H_ */
33 |
--------------------------------------------------------------------------------
/src/dbinc/hmac.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #ifndef _DB_HMAC_H_
10 | #define _DB_HMAC_H_
11 |
12 | #if defined(__cplusplus)
13 | extern "C" {
14 | #endif
15 |
16 | /*
17 | * Algorithm specific information.
18 | */
19 | /*
20 | * SHA1 checksumming
21 | */
22 | typedef struct {
23 | u_int32_t state[5];
24 | u_int32_t count[2];
25 | unsigned char buffer[64];
26 | } SHA1_CTX;
27 |
28 | /*
29 | * AES assumes the SHA1 checksumming (also called MAC)
30 | */
31 | #define DB_MAC_MAGIC "mac derivation key magic value"
32 | #define DB_ENC_MAGIC "encryption and decryption key value magic"
33 |
34 | #if defined(__cplusplus)
35 | }
36 | #endif
37 |
38 | #include "dbinc_auto/hmac_ext.h"
39 | #endif /* !_DB_HMAC_H_ */
40 |
--------------------------------------------------------------------------------
/src/dbinc/partition.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
5 | */
6 | /*
7 | * $Id$
8 | */
9 | #ifndef _DB_PART_H_
10 | #define _DB_PART_H_
11 |
12 | #if defined(__cplusplus)
13 | extern "C" {
14 | #endif
15 |
16 | typedef struct __db_partition {
17 | u_int32_t nparts; /* number of partitions. */
18 | DBT *keys; /* array of range keys. */
19 | void *data; /* the partition info. */
20 | const char **dirs; /* locations for partitions. */
21 | DB **handles; /* array of partition handles. */
22 | u_int32_t (*callback) (DB *, DBT *);
23 | #define PART_CALLBACK 0x01
24 | #define PART_RANGE 0x02
25 | u_int32_t flags;
26 | } DB_PARTITION;
27 |
28 | /*
29 | * Internal part of a partitioned cursor.
30 | */
31 | typedef struct __part_internal {
32 | __DBC_INTERNAL
33 | u_int32_t part_id;
34 | DBC *sub_cursor;
35 | } PART_CURSOR;
36 |
37 | #ifdef HAVE_PARTITION
38 | #define PART_NAME "__dbp.%s.%03d"
39 | #define PART_LEN (strlen("__dbp..")+3)
40 | #define PART_PREFIX "__dbp."
41 | #define IS_PARTITION_DB_FILE(name) (strncmp(name, PART_PREFIX, \
42 | sizeof(PART_PREFIX) - 1) == 0)
43 |
44 | #define DB_IS_PARTITIONED(dbp) \
45 | (dbp->p_internal != NULL && \
46 | ((DB_PARTITION *)dbp->p_internal)->handles != NULL)
47 |
48 | #define DBC_PART_REFRESH(dbc) (F_SET(dbc, DBC_PARTITIONED))
49 | #else
50 | #define DBC_PART_REFRESH(dbc)
51 | #define DB_IS_PARTITIONED(dbp) (0)
52 | #endif
53 |
54 | #if defined(__cplusplus)
55 | }
56 | #endif
57 | #endif
58 |
--------------------------------------------------------------------------------
/src/dbinc_auto/dbreg_auto.h:
--------------------------------------------------------------------------------
1 | /* Do not edit: automatically built by gen_rec.awk. */
2 |
3 | #ifndef __dbreg_AUTO_H
4 | #define __dbreg_AUTO_H
5 | #include "dbinc/log.h"
6 | #define DB___dbreg_register 2
7 | typedef struct ___dbreg_register_args {
8 | u_int32_t type;
9 | DB_TXN *txnp;
10 | DB_LSN prev_lsn;
11 | u_int32_t opcode;
12 | DBT name;
13 | DBT uid;
14 | int32_t fileid;
15 | DBTYPE ftype;
16 | db_pgno_t meta_pgno;
17 | u_int32_t id;
18 | } __dbreg_register_args;
19 |
20 | extern __DB_IMPORT DB_LOG_RECSPEC __dbreg_register_desc[];
21 | static inline int
22 | __dbreg_register_log(ENV *env, DB_TXN *txnp, DB_LSN *ret_lsnp, u_int32_t flags,
23 | u_int32_t opcode, const DBT *name, const DBT *uid, int32_t fileid, DBTYPE ftype,
24 | db_pgno_t meta_pgno, u_int32_t id)
25 | {
26 | return (__log_put_record(env, NULL, txnp, ret_lsnp,
27 | flags, DB___dbreg_register, 0,
28 | sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(DB_LSN) +
29 | sizeof(u_int32_t) + LOG_DBT_SIZE(name) + LOG_DBT_SIZE(uid) +
30 | sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(u_int32_t) +
31 | sizeof(u_int32_t),
32 | __dbreg_register_desc,
33 | opcode, name, uid, fileid, ftype, meta_pgno, id));
34 | }
35 |
36 | static inline int __dbreg_register_read(ENV *env,
37 | void *data, __dbreg_register_args **arg)
38 | {
39 | *arg = NULL;
40 | return (__log_read_record(env,
41 | NULL, NULL, data, __dbreg_register_desc, sizeof(__dbreg_register_args), (void**)arg));
42 | }
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/dbinc_auto/ext_185_def.in:
--------------------------------------------------------------------------------
1 |
2 | /* DO NOT EDIT: automatically built by dist/s_include. */
3 | #ifndef _DB_EXT_185_DEF_IN_
4 | #define _DB_EXT_185_DEF_IN_
5 |
6 | #ifdef _DB185_INT_H_
7 | #define __db185_open __db185_open@DB_VERSION_UNIQUE_NAME@
8 | #else
9 | #define __db185_open __db185_open@DB_VERSION_UNIQUE_NAME@
10 | #endif
11 |
12 | #endif /* !_DB_EXT_185_DEF_IN_ */
13 |
--------------------------------------------------------------------------------
/src/dbinc_auto/ext_185_prot.in:
--------------------------------------------------------------------------------
1 |
2 | /* DO NOT EDIT: automatically built by dist/s_include. */
3 | #ifndef _DB_EXT_185_PROT_IN_
4 | #define _DB_EXT_185_PROT_IN_
5 |
6 | #if defined(__cplusplus)
7 | extern "C" {
8 | #endif
9 |
10 | #ifdef _DB185_INT_H_
11 | DB185 *__db185_open __P((const char *, int, int, DBTYPE, const void *));
12 | #else
13 | DB *__db185_open __P((const char *, int, int, DBTYPE, const void *));
14 | #endif
15 |
16 | #if defined(__cplusplus)
17 | }
18 | #endif
19 | #endif /* !_DB_EXT_185_PROT_IN_ */
20 |
--------------------------------------------------------------------------------
/src/dbinc_auto/hmac_ext.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT: automatically built by dist/s_include. */
2 | #ifndef _hmac_ext_h_
3 | #define _hmac_ext_h_
4 |
5 | #if defined(__cplusplus)
6 | extern "C" {
7 | #endif
8 |
9 | void __db_chksum __P((void *, u_int8_t *, size_t, u_int8_t *, u_int8_t *));
10 | void __db_derive_mac __P((u_int8_t *, size_t, u_int8_t *));
11 | int __db_check_chksum __P((ENV *, void *, DB_CIPHER *, u_int8_t *, void *, size_t, int));
12 | void __db_SHA1Transform __P((u_int32_t *, unsigned char *));
13 | void __db_SHA1Init __P((SHA1_CTX *));
14 | void __db_SHA1Update __P((SHA1_CTX *, unsigned char *, size_t));
15 | void __db_SHA1Final __P((unsigned char *, SHA1_CTX *));
16 |
17 | #if defined(__cplusplus)
18 | }
19 | #endif
20 | #endif /* !_hmac_ext_h_ */
21 |
--------------------------------------------------------------------------------
/src/dbinc_auto/repmgr_auto.h:
--------------------------------------------------------------------------------
1 | /* Do not edit: automatically built by gen_rec.awk. */
2 |
3 | #ifndef __repmgr_AUTO_H
4 | #define __repmgr_AUTO_H
5 | #ifdef HAVE_REPLICATION_THREADS
6 | #include "dbinc/log.h"
7 | #define DB___repmgr_member 200
8 | typedef struct ___repmgr_member_args {
9 | u_int32_t type;
10 | DB_TXN *txnp;
11 | DB_LSN prev_lsn;
12 | u_int32_t version;
13 | u_int32_t prev_status;
14 | u_int32_t status;
15 | DBT host;
16 | u_int32_t port;
17 | } __repmgr_member_args;
18 |
19 | extern __DB_IMPORT DB_LOG_RECSPEC __repmgr_member_desc[];
20 | static inline int
21 | __repmgr_member_log(ENV *env, DB_TXN *txnp, DB_LSN *ret_lsnp, u_int32_t flags,
22 | u_int32_t version, u_int32_t prev_status, u_int32_t status, const DBT *host, u_int32_t port)
23 | {
24 | return (__log_put_record(env, NULL, txnp, ret_lsnp,
25 | flags, DB___repmgr_member, 0,
26 | sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(DB_LSN) +
27 | sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(u_int32_t) +
28 | LOG_DBT_SIZE(host) + sizeof(u_int32_t),
29 | __repmgr_member_desc,
30 | version, prev_status, status, host, port));
31 | }
32 |
33 | static inline int __repmgr_member_read(ENV *env,
34 | void *data, __repmgr_member_args **arg)
35 | {
36 | *arg = NULL;
37 | return (__log_read_record(env,
38 | NULL, NULL, data, __repmgr_member_desc, sizeof(__repmgr_member_args), (void**)arg));
39 | }
40 | #endif /* HAVE_REPLICATION_THREADS */
41 | #endif
42 |
--------------------------------------------------------------------------------
/src/dbinc_auto/sequence_ext.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT: automatically built by dist/s_include. */
2 | #ifndef _sequence_ext_h_
3 | #define _sequence_ext_h_
4 |
5 | #if defined(__cplusplus)
6 | extern "C" {
7 | #endif
8 |
9 | int __seq_stat __P((DB_SEQUENCE *, DB_SEQUENCE_STAT **, u_int32_t));
10 | int __seq_stat_print __P((DB_SEQUENCE *, u_int32_t));
11 | const FN * __db_get_seq_flags_fn __P((void));
12 | const FN * __db_get_seq_flags_fn __P((void));
13 |
14 | #if defined(__cplusplus)
15 | }
16 | #endif
17 | #endif /* !_sequence_ext_h_ */
18 |
--------------------------------------------------------------------------------
/src/dbinc_auto/xa_ext.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT: automatically built by dist/s_include. */
2 | #ifndef _xa_ext_h_
3 | #define _xa_ext_h_
4 |
5 | #if defined(__cplusplus)
6 | extern "C" {
7 | #endif
8 |
9 | int __db_rmid_to_env __P((int, ENV **));
10 | int __db_xid_to_txn __P((ENV *, XID *, TXN_DETAIL **));
11 | void __db_map_rmid __P((int, ENV *));
12 | int __db_unmap_rmid __P((int));
13 | void __db_unmap_xid __P((ENV *, XID *, size_t));
14 |
15 | #if defined(__cplusplus)
16 | }
17 | #endif
18 | #endif /* !_xa_ext_h_ */
19 |
--------------------------------------------------------------------------------
/src/dbreg/dbreg.src:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | DBPRIVATE
10 | PREFIX __dbreg
11 |
12 | INCLUDE #include "db_int.h"
13 | INCLUDE #include "dbinc/crypto.h"
14 | INCLUDE #include "dbinc/db_page.h"
15 | INCLUDE #include "dbinc/db_dispatch.h"
16 | INCLUDE #include "dbinc/db_am.h"
17 | INCLUDE #include "dbinc/txn.h"
18 | INCLUDE
19 |
20 | /*
21 | * Used for registering name/id translations at open or close.
22 | * opcode: register or unregister
23 | * name: file name
24 | * fileid: unique file id
25 | * ftype: file type
26 | * ftype: database type
27 | * id: transaction id of the subtransaction that created the fs object
28 | */
29 | BEGIN register 42 2
30 | DBOP opcode u_int32_t lu
31 | DBT name DBT s
32 | DBT uid DBT s
33 | ARG fileid int32_t ld
34 | ARG ftype DBTYPE lx
35 | ARG meta_pgno db_pgno_t lu
36 | ARG id u_int32_t lx
37 | END
38 |
--------------------------------------------------------------------------------
/src/dbreg/dbreg_auto.c:
--------------------------------------------------------------------------------
1 | /* Do not edit: automatically built by gen_rec.awk. */
2 |
3 | #include "db_config.h"
4 | #include "db_int.h"
5 | #include "dbinc/crypto.h"
6 | #include "dbinc/db_page.h"
7 | #include "dbinc/db_dispatch.h"
8 | #include "dbinc/db_am.h"
9 | #include "dbinc/txn.h"
10 |
11 | DB_LOG_RECSPEC __dbreg_register_desc[] = {
12 | {LOGREC_DBOP, SSZ(__dbreg_register_args, opcode), "opcode", ""},
13 | {LOGREC_DBT, SSZ(__dbreg_register_args, name), "name", ""},
14 | {LOGREC_DBT, SSZ(__dbreg_register_args, uid), "uid", ""},
15 | {LOGREC_ARG, SSZ(__dbreg_register_args, fileid), "fileid", "%ld"},
16 | {LOGREC_ARG, SSZ(__dbreg_register_args, ftype), "ftype", "%lx"},
17 | {LOGREC_ARG, SSZ(__dbreg_register_args, meta_pgno), "meta_pgno", "%lu"},
18 | {LOGREC_ARG, SSZ(__dbreg_register_args, id), "id", "%lx"},
19 | {LOGREC_Done, 0, "", ""}
20 | };
21 | /*
22 | * PUBLIC: int __dbreg_init_recover __P((ENV *, DB_DISTAB *));
23 | */
24 | int
25 | __dbreg_init_recover(env, dtabp)
26 | ENV *env;
27 | DB_DISTAB *dtabp;
28 | {
29 | int ret;
30 |
31 | if ((ret = __db_add_recovery_int(env, dtabp,
32 | __dbreg_register_recover, DB___dbreg_register)) != 0)
33 | return (ret);
34 | return (0);
35 | }
36 |
--------------------------------------------------------------------------------
/src/dbreg/dbreg_autop.c:
--------------------------------------------------------------------------------
1 | /* Do not edit: automatically built by gen_rec.awk. */
2 |
3 | #include "db_config.h"
4 |
5 | #include "db_int.h"
6 | #include "dbinc/crypto.h"
7 | #include "dbinc/db_page.h"
8 | #include "dbinc/db_dispatch.h"
9 | #include "dbinc/db_am.h"
10 | #include "dbinc/txn.h"
11 |
12 | /*
13 | * PUBLIC: int __dbreg_register_print __P((ENV *, DBT *, DB_LSN *,
14 | * PUBLIC: db_recops, void *));
15 | */
16 | int
17 | __dbreg_register_print(env, dbtp, lsnp, notused2, info)
18 | ENV *env;
19 | DBT *dbtp;
20 | DB_LSN *lsnp;
21 | db_recops notused2;
22 | void *info;
23 | {
24 | COMPQUIET(notused2, DB_TXN_PRINT);
25 |
26 | return (__log_print_record(env, dbtp, lsnp, "__dbreg_register", __dbreg_register_desc, info));
27 | }
28 |
29 | /*
30 | * PUBLIC: int __dbreg_init_print __P((ENV *, DB_DISTAB *));
31 | */
32 | int
33 | __dbreg_init_print(env, dtabp)
34 | ENV *env;
35 | DB_DISTAB *dtabp;
36 | {
37 | int ret;
38 |
39 | if ((ret = __db_add_recovery_int(env, dtabp,
40 | __dbreg_register_print, DB___dbreg_register)) != 0)
41 | return (ret);
42 | return (0);
43 | }
44 |
--------------------------------------------------------------------------------
/src/mutex/uts4_cc.s:
--------------------------------------------------------------------------------
1 | / See the file LICENSE for redistribution information.
2 | /
3 | / Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
4 | /
5 | / $Id$
6 | /
7 | / int uts_lock ( int *p, int i );
8 | / Update the lock word pointed to by p with the
9 | / value i, using compare-and-swap.
10 | / Returns 0 if update was successful.
11 | / Returns 1 if update failed.
12 | /
13 | entry uts_lock
14 | uts_lock:
15 | using .,r15
16 | st r2,8(sp) / Save R2
17 | l r2,64+0(sp) / R2 -> word to update
18 | slr r0, r0 / R0 = current lock value must be 0
19 | l r1,64+4(sp) / R1 = new lock value
20 | cs r0,r1,0(r2) / Try the update ...
21 | be x / ... Success. Return 0
22 | la r0,1 / ... Failure. Return 1
23 | x: /
24 | l r2,8(sp) / Restore R2
25 | b 2(,r14) / Return to caller
26 | drop r15
27 |
--------------------------------------------------------------------------------
/src/os/os_abort.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_abort --
15 | *
16 | * PUBLIC: void __os_abort __P((ENV *));
17 | */
18 | void
19 | __os_abort(env)
20 | ENV *env;
21 | {
22 | __os_stack(env); /* Try and get a stack trace. */
23 |
24 | #ifdef HAVE_ABORT
25 | abort(); /* Try and drop core. */
26 | /* NOTREACHED */
27 | #endif
28 | #ifdef SIGABRT
29 | (void)raise(SIGABRT); /* Try and drop core. */
30 | #endif
31 | exit(1); /* Quit anyway. */
32 | /* NOTREACHED */
33 | }
34 |
--------------------------------------------------------------------------------
/src/os/os_abs.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_abspath --
15 | * Return if a path is an absolute path.
16 | *
17 | * PUBLIC: int __os_abspath __P((const char *));
18 | */
19 | int
20 | __os_abspath(path)
21 | const char *path;
22 | {
23 | return (path[0] == '/');
24 | }
25 |
--------------------------------------------------------------------------------
/src/os/os_config.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_fs_notzero --
15 | * Return 1 if allocated filesystem blocks are not zeroed.
16 | *
17 | * PUBLIC: int __os_fs_notzero __P((void));
18 | */
19 | int
20 | __os_fs_notzero()
21 | {
22 | /* Most filesystems zero out implicitly created pages. */
23 | return (0);
24 | }
25 |
26 | /*
27 | * __os_support_direct_io --
28 | * Return 1 if we support direct I/O.
29 | *
30 | * PUBLIC: int __os_support_direct_io __P((void));
31 | */
32 | int
33 | __os_support_direct_io()
34 | {
35 | int ret;
36 |
37 | ret = 0;
38 |
39 | #ifdef HAVE_O_DIRECT
40 | ret = 1;
41 | #endif
42 | #if defined(HAVE_DIRECTIO) && defined(DIRECTIO_ON)
43 | ret = 1;
44 | #endif
45 | return (ret);
46 | }
47 |
48 | /*
49 | * __os_support_db_register --
50 | * Return 1 if the system supports DB_REGISTER.
51 | *
52 | * PUBLIC: int __os_support_db_register __P((void));
53 | */
54 | int
55 | __os_support_db_register()
56 | {
57 | return (1);
58 | }
59 |
60 | /*
61 | * __os_support_replication --
62 | * Return 1 if the system supports replication.
63 | *
64 | * PUBLIC: int __os_support_replication __P((void));
65 | */
66 | int
67 | __os_support_replication()
68 | {
69 | return (1);
70 | }
71 |
--------------------------------------------------------------------------------
/src/os/os_cpu.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | #ifdef HAVE_SYSTEM_INCLUDE_FILES
14 | #if defined(HAVE_PSTAT_GETDYNAMIC)
15 | #include
16 | #endif
17 | #endif
18 |
19 | /*
20 | * __os_cpu_count --
21 | * Return the number of CPUs.
22 | *
23 | * PUBLIC: u_int32_t __os_cpu_count __P((void));
24 | */
25 | u_int32_t
26 | __os_cpu_count()
27 | {
28 | #if defined(HAVE_PSTAT_GETDYNAMIC)
29 | /*
30 | * HP/UX.
31 | */
32 | struct pst_dynamic psd;
33 |
34 | return ((u_int32_t)pstat_getdynamic(&psd,
35 | sizeof(psd), (size_t)1, 0) == -1 ? 1 : psd.psd_proc_cnt);
36 | #elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
37 | /*
38 | * Solaris, Linux.
39 | */
40 | long nproc;
41 |
42 | nproc = sysconf(_SC_NPROCESSORS_ONLN);
43 | return ((u_int32_t)(nproc > 1 ? nproc : 1));
44 | #else
45 | return (1);
46 | #endif
47 | }
48 |
--------------------------------------------------------------------------------
/src/os/os_ctime.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2001, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_ctime --
15 | * Format a time-stamp.
16 | *
17 | * PUBLIC: char *__os_ctime __P((const time_t *, char *));
18 | */
19 | char *
20 | __os_ctime(tod, time_buf)
21 | const time_t *tod;
22 | char *time_buf;
23 | {
24 | time_buf[CTIME_BUFLEN - 1] = '\0';
25 |
26 | /*
27 | * The ctime_r interface is the POSIX standard, thread-safe version of
28 | * ctime. However, it was implemented in three different ways (with
29 | * and without a buffer length argument, and where the buffer length
30 | * argument was an int vs. a size_t *). Also, you can't depend on a
31 | * return of (char *) from ctime_r, HP-UX 10.XX's version returned an
32 | * int.
33 | */
34 | #if defined(HAVE_VXWORKS)
35 | {
36 | size_t buflen = CTIME_BUFLEN;
37 | (void)ctime_r(tod, time_buf, &buflen);
38 | }
39 | #elif defined(HAVE_CTIME_R_3ARG)
40 | (void)ctime_r(tod, time_buf, CTIME_BUFLEN);
41 | #elif defined(HAVE_CTIME_R)
42 | (void)ctime_r(tod, time_buf);
43 | #else
44 | (void)strncpy(time_buf, ctime(tod), CTIME_BUFLEN - 1);
45 | #endif
46 | return (time_buf);
47 | }
48 |
--------------------------------------------------------------------------------
/src/os/os_getenv.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_getenv --
15 | * Retrieve an environment variable.
16 | *
17 | * PUBLIC: int __os_getenv __P((ENV *, const char *, char **, size_t));
18 | */
19 | int
20 | __os_getenv(env, name, bpp, buflen)
21 | ENV *env;
22 | const char *name;
23 | char **bpp;
24 | size_t buflen;
25 | {
26 | /*
27 | * If we have getenv, there's a value and the buffer is large enough:
28 | * copy value into the pointer, return 0
29 | * If we have getenv, there's a value and the buffer is too short:
30 | * set pointer to NULL, return EINVAL
31 | * If we have getenv and there's no value:
32 | * set pointer to NULL, return 0
33 | * If we don't have getenv:
34 | * set pointer to NULL, return 0
35 | */
36 | #ifdef HAVE_GETENV
37 | char *p;
38 |
39 | if ((p = getenv(name)) != NULL) {
40 | if (strlen(p) < buflen) {
41 | (void)strcpy(*bpp, p);
42 | return (0);
43 | }
44 |
45 | *bpp = NULL;
46 | __db_errx(env, DB_STR_A("0157",
47 | "%s: buffer too small to hold environment variable %s",
48 | "%s %s"), name, p);
49 | return (EINVAL);
50 | }
51 | #else
52 | COMPQUIET(env, NULL);
53 | COMPQUIET(name, NULL);
54 | COMPQUIET(buflen, 0);
55 | #endif
56 | *bpp = NULL;
57 | return (0);
58 | }
59 |
--------------------------------------------------------------------------------
/src/os/os_mkdir.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_mkdir --
15 | * Create a directory.
16 | *
17 | * PUBLIC: int __os_mkdir __P((ENV *, const char *, int));
18 | */
19 | int
20 | __os_mkdir(env, name, mode)
21 | ENV *env;
22 | const char *name;
23 | int mode;
24 | {
25 | DB_ENV *dbenv;
26 | int ret;
27 |
28 | dbenv = env == NULL ? NULL : env->dbenv;
29 | if (dbenv != NULL &&
30 | FLD_ISSET(dbenv->verbose, DB_VERB_FILEOPS | DB_VERB_FILEOPS_ALL))
31 | __db_msg(env, DB_STR_A("0129", "fileops: mkdir %s",
32 | "%s"), name);
33 |
34 | /* Make the directory, with paranoid permissions. */
35 | #if defined(HAVE_VXWORKS)
36 | RETRY_CHK((mkdir(CHAR_STAR_CAST name)), ret);
37 | #else
38 | RETRY_CHK((mkdir(name, DB_MODE_700)), ret);
39 | #endif
40 | if (ret != 0)
41 | return (__os_posix_err(ret));
42 |
43 | /* Set the absolute permissions, if specified. */
44 | #if !defined(HAVE_VXWORKS)
45 | if (mode != 0) {
46 | RETRY_CHK((chmod(name, mode)), ret);
47 | if (ret != 0)
48 | ret = __os_posix_err(ret);
49 | }
50 | #endif
51 | return (ret);
52 | }
53 |
--------------------------------------------------------------------------------
/src/os/os_path.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 | /*
13 | * __os_concat_path --
14 | * Concatenate two elements of a path.
15 | * PUBLIC: int __os_concat_path __P((char *,
16 | * PUBLIC: size_t, const char *, const char *));
17 | */
18 | int __os_concat_path(dest, destsize, path, file)
19 | char *dest;
20 | size_t destsize;
21 | const char *path, *file;
22 | {
23 | if ((size_t)snprintf(dest, destsize,
24 | "%s%c%s", path, PATH_SEPARATOR[0], file) >= destsize)
25 | return (EINVAL);
26 | return (0);
27 | }
28 |
--------------------------------------------------------------------------------
/src/os/os_pid.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2001, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_id --
15 | * Return the current process ID.
16 | *
17 | * PUBLIC: void __os_id __P((DB_ENV *, pid_t *, db_threadid_t*));
18 | */
19 | void
20 | __os_id(dbenv, pidp, tidp)
21 | DB_ENV *dbenv;
22 | pid_t *pidp;
23 | db_threadid_t *tidp;
24 | {
25 | /*
26 | * We can't depend on dbenv not being NULL, this routine is called
27 | * from places where there's no DB_ENV handle.
28 | *
29 | * We cache the pid in the ENV handle, getting the process ID is a
30 | * fairly slow call on lots of systems.
31 | */
32 | if (pidp != NULL) {
33 | if (dbenv == NULL) {
34 | #if defined(HAVE_VXWORKS)
35 | *pidp = taskIdSelf();
36 | #else
37 | *pidp = getpid();
38 | #endif
39 | } else
40 | *pidp = dbenv->env->pid_cache;
41 | }
42 |
43 | /*
44 | * When building on MinGW, we define both HAVE_PTHREAD_SELF and DB_WIN32,
45 | * and we are using pthreads instead of Windows threads implementation.
46 | * So here, we need to check the thread implementations before checking
47 | * the platform.
48 | */
49 | if (tidp != NULL) {
50 | #if defined(HAVE_PTHREAD_SELF)
51 | *tidp = pthread_self();
52 | #elif defined(HAVE_MUTEX_UI_THREADS)
53 | *tidp = thr_self();
54 | #elif defined(DB_WIN32)
55 | *tidp = GetCurrentThreadId();
56 | #else
57 | /*
58 | * Default to just getpid.
59 | */
60 | DB_THREADID_INIT(*tidp);
61 | #endif
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/os/os_rename.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_rename --
15 | * Rename a file.
16 | *
17 | * PUBLIC: int __os_rename __P((ENV *,
18 | * PUBLIC: const char *, const char *, u_int32_t));
19 | */
20 | int
21 | __os_rename(env, oldname, newname, silent)
22 | ENV *env;
23 | const char *oldname, *newname;
24 | u_int32_t silent;
25 | {
26 | DB_ENV *dbenv;
27 | int ret;
28 |
29 | dbenv = env == NULL ? NULL : env->dbenv;
30 | if (dbenv != NULL &&
31 | FLD_ISSET(dbenv->verbose, DB_VERB_FILEOPS | DB_VERB_FILEOPS_ALL))
32 | __db_msg(env, DB_STR_A("0168", "fileops: rename %s to %s",
33 | "%s %s"), oldname, newname);
34 |
35 | LAST_PANIC_CHECK_BEFORE_IO(env);
36 |
37 | if (DB_GLOBAL(j_rename) != NULL)
38 | ret = DB_GLOBAL(j_rename)(oldname, newname);
39 | else
40 | RETRY_CHK((rename(oldname, newname)), ret);
41 |
42 | /*
43 | * If "silent" is not set, then errors are OK and we should not output
44 | * an error message.
45 | */
46 | if (ret != 0) {
47 | if (!silent)
48 | __db_syserr(env, ret, DB_STR_A("0169",
49 | "rename %s %s", "%s %s"), oldname, newname);
50 | ret = __os_posix_err(ret);
51 | }
52 | return (ret);
53 | }
54 |
--------------------------------------------------------------------------------
/src/os/os_root.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1999, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_isroot --
15 | * Return if user has special permissions.
16 | *
17 | * PUBLIC: int __os_isroot __P((void));
18 | */
19 | int
20 | __os_isroot()
21 | {
22 | #ifdef HAVE_GETUID
23 | return (getuid() == 0);
24 | #else
25 | return (0);
26 | #endif
27 | }
28 |
--------------------------------------------------------------------------------
/src/os/os_rpath.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __db_rpath --
15 | * Return the last path separator in the path or NULL if none found.
16 | *
17 | * PUBLIC: char *__db_rpath __P((const char *));
18 | */
19 | char *
20 | __db_rpath(path)
21 | const char *path;
22 | {
23 | const char *s, *last;
24 |
25 | s = path;
26 | last = NULL;
27 | if (PATH_SEPARATOR[1] != '\0') {
28 | for (; s[0] != '\0'; ++s)
29 | if (strchr(PATH_SEPARATOR, s[0]) != NULL)
30 | last = s;
31 | } else
32 | for (; s[0] != '\0'; ++s)
33 | if (s[0] == PATH_SEPARATOR[0])
34 | last = s;
35 | return ((char *)last);
36 | }
37 |
--------------------------------------------------------------------------------
/src/os/os_seek.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 1997, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_seek --
15 | * Seek to a page/byte offset in the file.
16 | *
17 | * PUBLIC: int __os_seek __P((ENV *,
18 | * PUBLIC: DB_FH *, db_pgno_t, u_int32_t, off_t));
19 | */
20 | int
21 | __os_seek(env, fhp, pgno, pgsize, relative)
22 | ENV *env;
23 | DB_FH *fhp;
24 | db_pgno_t pgno;
25 | u_int32_t pgsize;
26 | off_t relative;
27 | {
28 | DB_ENV *dbenv;
29 | off_t offset;
30 | int ret;
31 |
32 | dbenv = env == NULL ? NULL : env->dbenv;
33 |
34 | DB_ASSERT(env, F_ISSET(fhp, DB_FH_OPENED) && fhp->fd != -1);
35 |
36 | #if defined(HAVE_STATISTICS)
37 | ++fhp->seek_count;
38 | #endif
39 |
40 | offset = (off_t)pgsize * pgno + relative;
41 |
42 | if (dbenv != NULL && FLD_ISSET(dbenv->verbose, DB_VERB_FILEOPS_ALL))
43 | __db_msg(env, DB_STR_A("0170",
44 | "fileops: seek %s to %lu", "%s %lu"),
45 | fhp->name, (u_long)offset);
46 |
47 | if (DB_GLOBAL(j_seek) != NULL)
48 | ret = DB_GLOBAL(j_seek)(fhp->fd, offset, SEEK_SET);
49 | else
50 | RETRY_CHK((lseek(
51 | fhp->fd, offset, SEEK_SET) == -1 ? 1 : 0), ret);
52 |
53 | if (ret == 0) {
54 | fhp->pgsize = pgsize;
55 | fhp->pgno = pgno;
56 | fhp->offset = relative;
57 | } else {
58 | __db_syserr(env, ret, DB_STR_A("0171",
59 | "seek: %lu: (%lu * %lu) + %lu", "%lu %lu %lu %lu"),
60 | (u_long)offset, (u_long)pgno, (u_long)pgsize,
61 | (u_long)relative);
62 | ret = __os_posix_err(ret);
63 | }
64 |
65 | return (ret);
66 | }
67 |
--------------------------------------------------------------------------------
/src/os/os_stack.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2001, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 | #if defined(HAVE_SYSTEM_INCLUDE_FILES) && defined(HAVE_BACKTRACE) && \
13 | defined(HAVE_BACKTRACE_SYMBOLS) && defined(HAVE_EXECINFO_H)
14 | #include
15 | #endif
16 |
17 | /*
18 | * __os_stack --
19 | * Output a stack trace to the message file handle.
20 | *
21 | * PUBLIC: void __os_stack __P((ENV *));
22 | */
23 | void
24 | __os_stack(env)
25 | ENV *env;
26 | {
27 | #if defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
28 | void *array[200];
29 | size_t i, size;
30 | char **strings;
31 |
32 | /*
33 | * Solaris and the GNU C library support this interface. Solaris
34 | * has additional interfaces (printstack and walkcontext), I don't
35 | * know if they offer any additional value or not.
36 | */
37 | size = backtrace(array, sizeof(array) / sizeof(array[0]));
38 | strings = backtrace_symbols(array, size);
39 |
40 | for (i = 0; i < size; ++i)
41 | __db_errx(env, "%s", strings[i]);
42 | free(strings);
43 | #endif
44 | COMPQUIET(env, NULL);
45 | }
46 |
--------------------------------------------------------------------------------
/src/os/os_truncate.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2004, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_truncate --
15 | * Truncate the file.
16 | *
17 | * PUBLIC: int __os_truncate __P((ENV *, DB_FH *, db_pgno_t, u_int32_t));
18 | */
19 | int
20 | __os_truncate(env, fhp, pgno, pgsize)
21 | ENV *env;
22 | DB_FH *fhp;
23 | db_pgno_t pgno;
24 | u_int32_t pgsize;
25 | {
26 | DB_ENV *dbenv;
27 | off_t offset;
28 | int ret;
29 |
30 | dbenv = env == NULL ? NULL : env->dbenv;
31 |
32 | /*
33 | * Truncate a file so that "pgno" is discarded from the end of the
34 | * file.
35 | */
36 | offset = (off_t)pgsize * pgno;
37 |
38 | if (dbenv != NULL &&
39 | FLD_ISSET(dbenv->verbose, DB_VERB_FILEOPS | DB_VERB_FILEOPS_ALL))
40 | __db_msg(env, DB_STR_A("0141",
41 | "fileops: truncate %s to %lu", "%s %lu"),
42 | fhp->name, (u_long)offset);
43 |
44 | LAST_PANIC_CHECK_BEFORE_IO(env);
45 |
46 | if (DB_GLOBAL(j_ftruncate) != NULL)
47 | ret = DB_GLOBAL(j_ftruncate)(fhp->fd, offset);
48 | else {
49 | #ifdef HAVE_FTRUNCATE
50 | RETRY_CHK((ftruncate(fhp->fd, offset)), ret);
51 | #else
52 | ret = DB_OPNOTSUP;
53 | #endif
54 | }
55 |
56 | if (ret != 0) {
57 | __db_syserr(env, ret, DB_STR_A("0142",
58 | "ftruncate: %lu", "%lu"), (u_long)offset);
59 | ret = __os_posix_err(ret);
60 | }
61 |
62 | return (ret);
63 | }
64 |
--------------------------------------------------------------------------------
/src/os/os_uid.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2001, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db_config.h"
10 |
11 | #include "db_int.h"
12 |
13 | /*
14 | * __os_unique_id --
15 | * Return a unique 32-bit value.
16 | *
17 | * PUBLIC: void __os_unique_id __P((ENV *, u_int32_t *));
18 | */
19 | void
20 | __os_unique_id(env, idp)
21 | ENV *env;
22 | u_int32_t *idp;
23 | {
24 | DB_ENV *dbenv;
25 | db_timespec v;
26 | pid_t pid;
27 | u_int32_t id;
28 |
29 | *idp = 0;
30 |
31 | dbenv = env == NULL ? NULL : env->dbenv;
32 |
33 | /*
34 | * Our randomized value is comprised of our process ID, the current
35 | * time of day and a stack address, all XOR'd together.
36 | */
37 | __os_id(dbenv, &pid, NULL);
38 | __os_gettime(env, &v, 1);
39 |
40 | id = (u_int32_t)pid ^
41 | (u_int32_t)v.tv_sec ^ (u_int32_t)v.tv_nsec ^ P_TO_UINT32(&pid);
42 |
43 | /*
44 | * We could try and find a reasonable random-number generator, but
45 | * that's not all that easy to do. Seed and use srand()/rand(), if
46 | * we can find them.
47 | */
48 | if (DB_GLOBAL(uid_init) == 0) {
49 | DB_GLOBAL(uid_init) = 1;
50 | srand((u_int)id);
51 | }
52 | id ^= (u_int)rand();
53 |
54 | *idp = id;
55 | }
56 |
--------------------------------------------------------------------------------
/src/repmgr/repmgr.src:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
5 | */
6 |
7 | DBPRIVATE
8 | PREFIX __repmgr
9 |
10 | INCLUDE #include "db_int.h"
11 | INCLUDE #include "dbinc/db_page.h"
12 | INCLUDE #include "dbinc/db_dispatch.h"
13 | INCLUDE #include "dbinc/db_am.h"
14 | INCLUDE #include "dbinc_auto/repmgr_auto.h"
15 | INCLUDE
16 |
17 | BEGIN member 52 200
18 | ARG version u_int32_t lu
19 | ARG prev_status u_int32_t lu
20 | ARG status u_int32_t lu
21 | DBT host DBT s
22 | ARG port u_int32_t lu
23 | END
24 |
--------------------------------------------------------------------------------
/src/repmgr/repmgr_auto.c:
--------------------------------------------------------------------------------
1 | /* Do not edit: automatically built by gen_rec.awk. */
2 |
3 | #include "db_config.h"
4 | #include "db_int.h"
5 | #include "dbinc/db_page.h"
6 | #include "dbinc/db_dispatch.h"
7 | #include "dbinc/db_am.h"
8 | #include "dbinc_auto/repmgr_auto.h"
9 |
10 | DB_LOG_RECSPEC __repmgr_member_desc[] = {
11 | {LOGREC_ARG, SSZ(__repmgr_member_args, version), "version", "%lu"},
12 | {LOGREC_ARG, SSZ(__repmgr_member_args, prev_status), "prev_status", "%lu"},
13 | {LOGREC_ARG, SSZ(__repmgr_member_args, status), "status", "%lu"},
14 | {LOGREC_DBT, SSZ(__repmgr_member_args, host), "host", ""},
15 | {LOGREC_ARG, SSZ(__repmgr_member_args, port), "port", "%lu"},
16 | {LOGREC_Done, 0, "", ""}
17 | };
18 | /*
19 | * PUBLIC: int __repmgr_init_recover __P((ENV *, DB_DISTAB *));
20 | */
21 | int
22 | __repmgr_init_recover(env, dtabp)
23 | ENV *env;
24 | DB_DISTAB *dtabp;
25 | {
26 | int ret;
27 |
28 | if ((ret = __db_add_recovery_int(env, dtabp,
29 | __repmgr_member_recover, DB___repmgr_member)) != 0)
30 | return (ret);
31 | return (0);
32 | }
33 |
--------------------------------------------------------------------------------
/src/repmgr/repmgr_autop.c:
--------------------------------------------------------------------------------
1 | /* Do not edit: automatically built by gen_rec.awk. */
2 |
3 | #include "db_config.h"
4 |
5 | #ifdef HAVE_REPLICATION_THREADS
6 | #include "db_int.h"
7 | #include "dbinc/db_page.h"
8 | #include "dbinc/db_dispatch.h"
9 | #include "dbinc/db_am.h"
10 | #include "dbinc_auto/repmgr_auto.h"
11 |
12 | /*
13 | * PUBLIC: int __repmgr_member_print __P((ENV *, DBT *, DB_LSN *,
14 | * PUBLIC: db_recops, void *));
15 | */
16 | int
17 | __repmgr_member_print(env, dbtp, lsnp, notused2, info)
18 | ENV *env;
19 | DBT *dbtp;
20 | DB_LSN *lsnp;
21 | db_recops notused2;
22 | void *info;
23 | {
24 | COMPQUIET(notused2, DB_TXN_PRINT);
25 |
26 | return (__log_print_record(env, dbtp, lsnp, "__repmgr_member", __repmgr_member_desc, info));
27 | }
28 |
29 | /*
30 | * PUBLIC: int __repmgr_init_print __P((ENV *, DB_DISTAB *));
31 | */
32 | int
33 | __repmgr_init_print(env, dtabp)
34 | ENV *env;
35 | DB_DISTAB *dtabp;
36 | {
37 | int ret;
38 |
39 | if ((ret = __db_add_recovery_int(env, dtabp,
40 | __repmgr_member_print, DB___repmgr_member)) != 0)
41 | return (ret);
42 | return (0);
43 | }
44 | #endif /* HAVE_REPLICATION_THREADS */
45 |
--------------------------------------------------------------------------------
/src/repmgr/repmgr_rec.c:
--------------------------------------------------------------------------------
1 | #include "db_config.h"
2 |
3 | #include "db_int.h"
4 | #include "dbinc/db_page.h"
5 | #include "dbinc/db_am.h"
6 | #include "dbinc_auto/repmgr_auto.h"
7 |
8 | /*
9 | * __repmgr_member_recover --
10 | * Recovery function for member.
11 | *
12 | * PUBLIC: int __repmgr_member_recover
13 | * PUBLIC: __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
14 | */
15 | int
16 | __repmgr_member_recover(env, dbtp, lsnp, op, info)
17 | ENV *env;
18 | DBT *dbtp;
19 | DB_LSN *lsnp;
20 | db_recops op;
21 | void *info;
22 | {
23 | __repmgr_member_args *argp;
24 | int ret;
25 |
26 | COMPQUIET(info, NULL);
27 | COMPQUIET(op, DB_TXN_APPLY);
28 |
29 | REC_PRINT(__repmgr_member_print);
30 | REC_NOOP_INTRO(__repmgr_member_read);
31 |
32 | /*
33 | * The annotation log record describes the update in enough detail for
34 | * us to be able to optimize our tracking of it at clients sites.
35 | * However, for now we just simply reread the whole (small) database
36 | * each time, since changes happen so seldom (and we need to have the
37 | * code for reading the whole thing anyway, for other cases).
38 | */
39 | env->rep_handle->gmdb_dirty = TRUE;
40 |
41 | *lsnp = argp->prev_lsn;
42 | ret = 0;
43 |
44 | REC_NOOP_CLOSE;
45 | }
46 |
--------------------------------------------------------------------------------
/test/3n1/README:
--------------------------------------------------------------------------------
1 | https://github.com/ddanderson/libdb-3n
2 |
3 | This code implements the 3n+1 benchmark. A description of the benchmark and results is on the libdb blog here:
4 | http://libdb.wordpress.com/2011/01/31/revving-up-a-benchmark-from-626-to-74000-operations-per-second/
5 |
--------------------------------------------------------------------------------
/test/c/chk.ctests:
--------------------------------------------------------------------------------
1 | #!/bin/sh -
2 | #
3 | # $Id$
4 | #
5 | # Check to make sure we can run DB 1.85 code.
6 | d=../../
7 | b=./tmp_build/
8 | s=$d/src
9 |
10 | mkdir -p $b
11 |
12 | [ -f $d/LICENSE ] || {
13 | echo 'FAIL: Test must be run from scr directory.'
14 | exit 1
15 | }
16 |
17 | nocleanup=0
18 | while [ $# -gt 0 ]
19 | do
20 | case "$1" in
21 | -nocleanup)
22 | nocleanup=1; shift;;
23 | *)
24 | echo "Unrecognized option: $1, ignoring"
25 | shift;;
26 | esac
27 | done
28 |
29 | opts="--enable-compat185 --disable-shared"
30 | echo "Building DB library, this can take a while."
31 | (cd $b && ../../../dist/configure $opts > /dev/null && make libdb.a > /dev/null) || {
32 | echo 'FAIL: unable to build libdb.a'
33 | exit 1
34 | }
35 |
36 | # if compiling on linux blade server, add -pthread on cc
37 | CINC="-I$b -I$s -I$s/dbinc"
38 | [ `uname` = "Linux" ] && CINC="$CINC -pthread"
39 |
40 | for i in `ls test_*.c`; do
41 |
42 | echo "=== Running $i ===" | tee -a compile.out
43 | if cc -g -Wall $CINC $i $b/libdb.a -o t >> compile.out 2>&1; then
44 | :
45 | else
46 | echo "FAIL: unable to compile test program $i"
47 | exit 1
48 | fi
49 |
50 | if ./t; then
51 | :
52 | else
53 | echo "FAIL: test program failed"
54 | exit 1
55 | fi
56 | rm -f ./t
57 | done
58 |
59 | # Cleanup.
60 | # TODO: The test should be consistent, so this cleanup isn't so haphazard.
61 | # Alternatively we could build each test in a sub-dir and cleanup after
62 | # individual runs.
63 | rm a.db __db.* output
64 | rm -rf ./TESTDIR
65 |
66 | if [ nocleanup = 0 ]; then
67 | rm -rf compile.out $b
68 | fi
69 |
70 | exit 0
71 |
--------------------------------------------------------------------------------
/test/c/cutest/license.txt:
--------------------------------------------------------------------------------
1 | NOTE
2 |
3 | The license is based on the zlib/libpng license. For more details see
4 | http://www.opensource.org/licenses/zlib-license.html. The intent of the
5 | license is to:
6 |
7 | - keep the license as simple as possible
8 | - encourage the use of CuTest in both free and commercial applications
9 | and libraries
10 | - keep the source code together
11 | - give credit to the CuTest contributors for their work
12 |
13 | If you ship CuTest in source form with your source distribution, the
14 | following license document must be included with it in unaltered form.
15 | If you find CuTest useful we would like to hear about it.
16 |
17 | LICENSE
18 |
19 | Copyright (c) 2003 Asim Jalis
20 |
21 | This software is provided 'as-is', without any express or implied
22 | warranty. In no event will the authors be held liable for any damages
23 | arising from the use of this software.
24 |
25 | Permission is granted to anyone to use this software for any purpose,
26 | including commercial applications, and to alter it and redistribute it
27 | freely, subject to the following restrictions:
28 |
29 | 1. The origin of this software must not be misrepresented; you must not
30 | claim that you wrote the original software. If you use this software in
31 | a product, an acknowledgment in the product documentation would be
32 | appreciated but is not required.
33 |
34 | 2. Altered source versions must be plainly marked as such, and must not
35 | be misrepresented as being the original software.
36 |
37 | 3. This notice may not be removed or altered from any source
38 | distribution.
39 |
--------------------------------------------------------------------------------
/test/c/suites/TestEnvMethod.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
5 | *
6 | * $Id$
7 | */
8 |
9 | #include "db.h"
10 | #include "CuTest.h"
11 | #include "test_util.h"
12 |
13 | int TestSetThreadCount(CuTest *ct) { /* SKIP */
14 | /* Run this test only when hash is supported. */
15 | #ifdef HAVE_HASH
16 | DB_ENV *dbenv;
17 | DB *db;
18 |
19 | CuAssert(ct, "db_env_create", db_env_create(&dbenv, 0) == 0);
20 |
21 | dbenv->set_errpfx(dbenv, "TestSetThreadCount");
22 | CuAssert(ct, "set_thread_count", dbenv->set_thread_count(dbenv, 2) == 0);
23 | CuAssert(ct, "env->open", dbenv->open(dbenv, ".",
24 | DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
25 | DB_INIT_TXN | DB_PRIVATE | DB_THREAD, 0) == 0);
26 |
27 | CuAssert(ct, "db_create", db_create(&db, dbenv, 0) == 0);
28 | CuAssert(ct, "DB->open", db->open(
29 | db, NULL, NULL, "TestSetThreadCount", DB_HASH, DB_CREATE, 0) == 0);
30 |
31 | db->close(db, 0);
32 | dbenv->close(dbenv, 0);
33 | #else
34 | printf("TestSetThreadCount is not supported by the build.\n");
35 | #endif /* HAVE_HASH */
36 | return (0);
37 | }
38 |
--------------------------------------------------------------------------------
/test/cxx/TestConstruct01.testerr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/berkeleydb/libdb/5b7b02ae052442626af54c176335b67ecc613a30/test/cxx/TestConstruct01.testerr
--------------------------------------------------------------------------------
/test/cxx/TestConstruct01.testout:
--------------------------------------------------------------------------------
1 | (0/1) construct01 running:
2 | Running test 1:
3 | finished.
4 | Running test 2:
5 | finished.
6 | Running test 3:
7 | finished.
8 | Running test 4:
9 | finished.
10 | Running test 5:
11 | finished.
12 | Running test 6:
13 | finished.
14 | Running test 1:
15 | finished.
16 | Running test 2:
17 | finished.
18 | Running test 3:
19 | finished.
20 | Running test 4:
21 | finished.
22 | Running test 5:
23 | finished.
24 | Running test 6:
25 | finished.
26 |
27 | ALL TESTS SUCCESSFUL
28 |
--------------------------------------------------------------------------------
/test/cxx/TestKeyRange.testin:
--------------------------------------------------------------------------------
1 | first line is alphabetically somewhere in the middle.
2 | Blah blah
3 | let's have exactly eight lines of input.
4 | stuff
5 | more stuff
6 | and even more stuff
7 | lastly
8 | but not leastly.
9 |
--------------------------------------------------------------------------------
/test/cxx/TestKeyRange.testout:
--------------------------------------------------------------------------------
1 | input>
2 | input>
3 | input>
4 | input>
5 | input>
6 | input>
7 | input>
8 | input>
9 | input>less: 0.375000
10 | equal: 0.125000
11 | greater: 0.500000
12 | Blah blah : halb halB
13 | and even more stuff : ffuts erom neve dna
14 | but not leastly. : .yltsael ton tub
15 | first line is alphabetically somewhere in the middle. : .elddim eht ni erehwemos yllacitebahpla si enil tsrif
16 | lastly : yltsal
17 | let's have exactly eight lines of input. : .tupni fo senil thgie yltcaxe evah s'tel
18 | more stuff : ffuts erom
19 | stuff : ffuts
20 |
--------------------------------------------------------------------------------
/test/cxx/TestLogc.testout:
--------------------------------------------------------------------------------
1 | TestLogc done.
2 |
--------------------------------------------------------------------------------
/test/cxx/TestSimpleAccess.testout:
--------------------------------------------------------------------------------
1 | got data: data
2 | get using bad key: BDB0073 DB_NOTFOUND: No matching key/data pair found
3 | finished test
4 |
--------------------------------------------------------------------------------
/test/cxx/TestTruncate.testout:
--------------------------------------------------------------------------------
1 | got data: data
2 | get using bad key: BDB0073 DB_NOTFOUND: No matching key/data pair found
3 | truncating data...
4 | truncate returns 1
5 | after truncate get: BDB0073 DB_NOTFOUND: No matching key/data pair found
6 | finished test
7 |
--------------------------------------------------------------------------------
/test/cxx/ignore:
--------------------------------------------------------------------------------
1 | #
2 | # $Id$
3 | #
4 | # A list of tests to ignore
5 |
--------------------------------------------------------------------------------
/test/cxx/testall:
--------------------------------------------------------------------------------
1 | #!/bin/sh -
2 | # $Id$
3 | #
4 | # Run all the C++ regression tests
5 |
6 | ecode=0
7 | prefixarg=""
8 | stdinarg=""
9 | while :
10 | do
11 | case "$1" in
12 | --prefix=* )
13 | prefixarg="$1"; shift;;
14 | --stdin )
15 | stdinarg="$1"; shift;;
16 | * )
17 | break
18 | esac
19 | done
20 | files="`find . -name \*.cpp -print`"
21 | for file in $files; do
22 | name=`echo $file | sed -e 's:^\./::' -e 's/\.cpp$//'`
23 | if grep $name ignore > /dev/null; then
24 | echo " **** cxx test $name ignored"
25 | else
26 | echo " ==== cxx test $name"
27 | if ! sh ./testone $prefixarg $stdinarg $name; then
28 | ecode=1
29 | fi
30 | fi
31 | done
32 | exit $ecode
33 |
--------------------------------------------------------------------------------
/test/micro/report.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 |
3 | /^[^#]/ {
4 | total[$1] += $2
5 | sum[$1] += $2 * $2
6 | ++count[$1];
7 | }
8 | END {
9 | # Compute the average, find the maximum.
10 | for (i in total) {
11 | avg[i] = total[i] / count[i];
12 | if (max < avg[i])
13 | max = avg[i]
14 | }
15 |
16 | for (i in total) {
17 | # Calculate variance by raw score method.
18 | var = (sum[i] - ((total[i] * total[i]) / count[i])) / count[i];
19 |
20 | # The standard deviation is the square root of the variance.
21 | stdv = sqrt(var);
22 |
23 | # Display the release value, the average score, and run count.
24 | printf("%s:%.2f:%d:", i, avg[i], count[i]);
25 |
26 | # If this run wasn't the fastest, display the percent by which
27 | # this run was slower.
28 | if (max != avg[i])
29 | printf("%.0f%%", ((max - avg[i]) / max) * 100);
30 |
31 | printf(":");
32 |
33 | # If there was more than a single run, display the relative
34 | # standard deviation.
35 | if (count[i] > 1)
36 | printf("%.0f%%", stdv * 100 / avg[i]);
37 |
38 | printf("\n");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/test/tcl/bigfile002.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2001, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST bigfile002
8 | # TEST This one should be faster and not require so much disk space,
9 | # TEST although it doesn't test as extensively. Create an mpool file
10 | # TEST with 1K pages. Dirty page 6000000. Sync.
11 | proc bigfile002 { args } {
12 | source ./include.tcl
13 | global is_fat32
14 | if { $is_fat32 } {
15 | puts "Skipping bigfile002 for FAT32 file system."
16 | return
17 | }
18 | puts "Bigfile002: Creating large, sparse file through mpool..."
19 | flush stdout
20 |
21 | env_cleanup $testdir
22 |
23 | # Create env.
24 | set env [berkdb_env -create -home $testdir]
25 | error_check_good valid_env [is_valid_env $env] TRUE
26 |
27 | # Create the file.
28 | set name big002.file
29 | set file [$env mpool -create -pagesize 1024 $name]
30 |
31 | # Dirty page 6000000
32 | set pg [$file get -create 6000000]
33 | error_check_good pg_init [$pg init A] 0
34 | error_check_good pg_set [$pg is_setto A] 1
35 |
36 | # Put page back.
37 | error_check_good pg_put [$pg put] 0
38 |
39 | # Fsync.
40 | error_check_good fsync [$file fsync] 0
41 |
42 | # Close.
43 | error_check_good fclose [$file close] 0
44 | error_check_good env_close [$env close] 0
45 | }
46 |
--------------------------------------------------------------------------------
/test/tcl/byteorder.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # Byte Order Test
8 | # Use existing tests and run with both byte orders.
9 | proc byteorder { method {nentries 1000} } {
10 | source ./include.tcl
11 | puts "Byteorder: $method $nentries"
12 |
13 | eval {test001 $method $nentries 0 0 "001" -lorder 1234}
14 | eval {verify_dir $testdir}
15 | eval {test001 $method $nentries 0 0 "001" -lorder 4321}
16 | eval {verify_dir $testdir}
17 | eval {test003 $method -lorder 1234}
18 | eval {verify_dir $testdir}
19 | eval {test003 $method -lorder 4321}
20 | eval {verify_dir $testdir}
21 | eval {test010 $method $nentries 5 "010" -lorder 1234}
22 | eval {verify_dir $testdir}
23 | eval {test010 $method $nentries 5 "010" -lorder 4321}
24 | eval {verify_dir $testdir}
25 | eval {test011 $method $nentries 5 "011" -lorder 1234}
26 | eval {verify_dir $testdir}
27 | eval {test011 $method $nentries 5 "011" -lorder 4321}
28 | eval {verify_dir $testdir}
29 | eval {test018 $method $nentries -lorder 1234}
30 | eval {verify_dir $testdir}
31 | eval {test018 $method $nentries -lorder 4321}
32 | eval {verify_dir $testdir}
33 | }
34 |
--------------------------------------------------------------------------------
/test/tcl/ddscript.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # Deadlock detector script tester.
8 | # Usage: ddscript dir test lockerid objid numprocs
9 | # dir: DBHOME directory
10 | # test: Which test to run
11 | # lockerid: Lock id for this locker
12 | # objid: Object id to lock.
13 | # numprocs: Total number of processes running
14 |
15 | source ./include.tcl
16 | source $test_path/test.tcl
17 | source $test_path/testutils.tcl
18 |
19 | set usage "ddscript dir test lockerid objid numprocs"
20 |
21 | # Verify usage
22 | if { $argc != 5 } {
23 | puts stderr "FAIL:[timestamp] Usage: $usage"
24 | exit
25 | }
26 |
27 | # Initialize arguments
28 | set dir [lindex $argv 0]
29 | set test [ lindex $argv 1 ]
30 | set lockerid [ lindex $argv 2 ]
31 | set objid [ lindex $argv 3 ]
32 | set numprocs [ lindex $argv 4 ]
33 |
34 | set myenv [berkdb_env -lock -home $dir -create -mode 0644 ]
35 | error_check_bad lock_open $myenv NULL
36 | error_check_good lock_open [is_substr $myenv "env"] 1
37 |
38 | puts [eval $test $myenv $lockerid $objid $numprocs]
39 |
40 | error_check_good lock_id_free [$myenv lock_id_free $lockerid] 0
41 | error_check_good envclose [$myenv close] 0
42 |
43 | exit
44 |
--------------------------------------------------------------------------------
/test/tcl/dead006.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST dead006
8 | # TEST use timeouts rather than the normal dd algorithm.
9 | proc dead006 { { procs "2 4 10" } {tests "ring clump" } \
10 | {timeout 1000} {tnum 006} } {
11 | source ./include.tcl
12 |
13 | dead001 $procs $tests $timeout $tnum
14 | dead002 $procs $tests $timeout $tnum
15 | }
16 |
--------------------------------------------------------------------------------
/test/tcl/dead007.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST dead007
8 | # TEST Tests for locker and txn id wraparound.
9 | proc dead007 { {tnum "007"} } {
10 | source ./include.tcl
11 | global lock_curid
12 | global lock_maxid
13 |
14 | set save_curid $lock_curid
15 | set save_maxid $lock_maxid
16 | puts "Dead$tnum.a -- wrap around"
17 | set lock_curid [expr $lock_maxid - 2]
18 | dead001 "2 10" "ring clump" "0" $tnum
19 | ## Oldest/youngest breaks when the id wraps
20 | # dead003 "4 10"
21 | dead004 $tnum
22 |
23 | puts "Dead$tnum.b -- extend space"
24 | set lock_maxid [expr $lock_maxid - 3]
25 | set lock_curid [expr $lock_maxid - 1]
26 | dead001 "4 10" "ring clump" "0" $tnum
27 | ## Oldest/youngest breaks when the id wraps
28 | # dead003 "10"
29 | dead004 $tnum
30 |
31 | set lock_curid $save_curid
32 | set lock_maxid $save_maxid
33 | # Return the empty string so we don't return lock_maxid.
34 | return ""
35 | }
36 |
--------------------------------------------------------------------------------
/test/tcl/dead008.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST dead008
8 | # TEST Run dead001 deadlock test using priorities
9 | proc dead008 { {tnum "008"} } {
10 | source ./include.tcl
11 | dead001 "2 4 10" "ring clump" "0" $tnum 1
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/test/tcl/dead009.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST dead009
8 | # TEST Run dead002 deadlock test using priorities
9 | proc dead009 { {tnum "009"} } {
10 | source ./include.tcl
11 | dead002 "2 4 10" "ring clump" "0" $tnum 1
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/test/tcl/dead010.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST dead010
8 | # TEST
9 | # TEST Same test as dead003, except the actual youngest and oldest will have
10 | # TEST higher priorities. Verify that the oldest/youngest of the lower
11 | # TEST priority lockers gets killed. Doesn't apply to 2 procs.
12 | proc dead010 { {procs "4 10"} {tests "ring clump"} {tnum "010"} } {
13 | source ./include.tcl
14 |
15 | dead003 $procs $tests $tnum 1
16 | }
17 |
--------------------------------------------------------------------------------
/test/tcl/dead011.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST dead011
8 | # TEST Test out the minlocks, maxlocks, and minwrites options
9 | # TEST to the deadlock detector when priorities are used.
10 | proc dead011 { { procs "4 6 10" } \
11 | {tests "maxlocks maxwrites minlocks minwrites" } { tnum "011" } } {
12 | source ./include.tcl
13 |
14 | dead005 $procs $tests $tnum 1
15 | }
16 |
--------------------------------------------------------------------------------
/test/tcl/env007script.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # env007script - for use with env007.
6 | # Usage: configarg configval getter getval
7 | #
8 |
9 | source ./include.tcl
10 |
11 | set usage "env007script configarg configval getter getval"
12 |
13 | # Verify usage
14 | if { $argc != 4 } {
15 | puts stderr "FAIL:[timestamp] Usage: $usage"
16 | exit
17 | }
18 |
19 | # Initialize arguments
20 | set configarg [lindex $argv 0]
21 | set configval [lindex $argv 1]
22 | set getter [lindex $argv 2]
23 | set getval [lindex $argv 3]
24 |
25 | set e "berkdb_env_noerr -create -mode 0644 -home $testdir -txn"
26 |
27 | env007_make_config $configarg $configval
28 |
29 | # Verify using config file
30 | set dbenv [eval $e]
31 | error_check_good envvalid:1 [is_valid_env $dbenv] TRUE
32 | set db [berkdb_open_noerr -create -env $dbenv -btree env007script.db]
33 | error_check_good dbvalid:1 [is_valid_db $db] TRUE
34 | error_check_good dbclose [$db close] 0
35 | error_check_good getter:1 [eval $dbenv $getter] $getval
36 | error_check_good envclose:1 [$dbenv close] 0
37 |
38 |
--------------------------------------------------------------------------------
/test/tcl/env010.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1999, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST env010
8 | # TEST Run recovery in an empty directory, and then make sure we can still
9 | # TEST create a database in that directory.
10 | proc env010 { } {
11 | source ./include.tcl
12 |
13 | puts "Env010: Test of recovery in an empty directory."
14 |
15 | # Create a new directory used only for this test
16 |
17 | if { [file exists $testdir/EMPTYDIR] != 1 } {
18 | file mkdir $testdir/EMPTYDIR
19 | } else {
20 | puts "\nDirectory already exists."
21 | }
22 |
23 | # Do the test twice, for regular recovery and catastrophic
24 | # Open environment and recover, but don't create a database
25 |
26 | foreach rmethod {recover recover_fatal} {
27 |
28 | puts "\tEnv010: Creating env for $rmethod test."
29 | env_cleanup $testdir/EMPTYDIR
30 | set e [berkdb_env \
31 | -create -home $testdir/EMPTYDIR -txn -$rmethod]
32 | error_check_good dbenv [is_valid_env $e] TRUE
33 |
34 | # Open and close a database
35 | # The method doesn't matter, so picked btree arbitrarily
36 |
37 | set db [eval {berkdb_open -env $e \
38 | -btree -create -mode 0644} ]
39 | error_check_good dbopen [is_valid_db $db] TRUE
40 | error_check_good db_close [$db close] 0
41 |
42 | # Close environment
43 |
44 | error_check_good envclose [$e close] 0
45 | error_check_good berkdb:envremove \
46 | [berkdb envremove -home $testdir/EMPTYDIR] 0
47 | }
48 | puts "\tEnv010 complete."
49 | }
50 |
--------------------------------------------------------------------------------
/test/tcl/env011.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1999, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST env011
8 | # TEST Run with region overwrite flag.
9 | proc env011 { } {
10 | source ./include.tcl
11 |
12 | puts "Env011: Test of region overwriting."
13 | env_cleanup $testdir
14 |
15 | puts "\tEnv011: Creating/closing env for open test."
16 | set e [berkdb_env -create -overwrite -home $testdir -txn]
17 | error_check_good dbenv [is_valid_env $e] TRUE
18 | set db [eval \
19 | {berkdb_open -auto_commit -env $e -btree -create -mode 0644} ]
20 | error_check_good dbopen [is_valid_db $db] TRUE
21 | set ret [eval {$db put} "aaa" "data"]
22 | error_check_good put $ret 0
23 | set ret [eval {$db put} "bbb" "data"]
24 | error_check_good put $ret 0
25 | error_check_good db_close [$db close] 0
26 | error_check_good envclose [$e close] 0
27 |
28 | puts "\tEnv011: Opening the environment with overwrite set."
29 | set e [berkdb_env -create -overwrite -home $testdir -txn -recover]
30 | error_check_good dbenv [is_valid_env $e] TRUE
31 | error_check_good envclose [$e close] 0
32 |
33 | puts "\tEnv011: Removing the environment with overwrite set."
34 | error_check_good berkdb:envremove \
35 | [berkdb envremove -home $testdir -overwrite] 0
36 |
37 | puts "\tEnv011 complete."
38 | }
39 |
--------------------------------------------------------------------------------
/test/tcl/fop007.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST fop007
8 | # TEST Test file system operations on named in-memory databases.
9 | # TEST Combine two ops in one transaction.
10 | proc fop007 { method args } {
11 |
12 | # Queue extents are not allowed with in-memory databases.
13 | if { [is_queueext $method] == 1 } {
14 | puts "Skipping fop007 for method $method."
15 | return
16 | }
17 | eval {fop001 $method 1 0} $args
18 | }
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/tcl/fop008.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST fop008
8 | # TEST Test file system operations on named in-memory databases.
9 | # TEST Combine two ops in one transaction.
10 | proc fop008 { method args } {
11 | eval {fop006 $method 1 0} $args
12 | }
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/tcl/fop009.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST fop009
8 | # TEST Test file system operations in child transactions.
9 | # TEST Combine two ops in one child transaction.
10 | proc fop009 { method args } {
11 |
12 | # Run for btree only to cut down on redundant testing.
13 | if { [is_btree $method] == 0 } {
14 | puts "Skipping fop009 for method $method"
15 | return
16 | }
17 |
18 | eval {fop001 $method 0 1} $args
19 | }
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test/tcl/fop010.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST fop010
8 | # TEST Test file system operations in child transactions.
9 | # TEST Two ops, each in its own child txn.
10 | proc fop010 { method args } {
11 |
12 | # Run for btree only to cut down on redundant testing.
13 | if { [is_btree $method] == 0 } {
14 | puts "Skipping fop010 for method $method"
15 | return
16 | }
17 |
18 | eval {fop006 $method 0 1} $args
19 | }
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test/tcl/fop011.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST fop011
8 | # TEST Test file system operations in child transactions.
9 | # TEST Combine two ops in one child transaction, with in-emory
10 | # TEST databases.
11 | proc fop011 { method args } {
12 |
13 | # Run for btree only to cut down on redundant testing.
14 | if { [is_btree $method] == 0 } {
15 | puts "Skipping fop011 for method $method"
16 | return
17 | }
18 |
19 | eval {fop001 $method 1 1} $args
20 | }
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/test/tcl/fop012.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST fop012
8 | # TEST Test file system operations in child transactions.
9 | # TEST Two ops, each in its own child txn, with in-memory dbs.
10 | proc fop012 { method args } {
11 |
12 | # Run for btree only to cut down on redundant testing.
13 | if { [is_btree $method] == 0 } {
14 | puts "Skipping fop012 for method $method"
15 | return
16 | }
17 |
18 | eval {fop006 $method 1 1} $args
19 | }
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test/tcl/hsearch.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # Historic Hsearch interface test.
8 | # Use the first 1000 entries from the dictionary.
9 | # Insert each with self as key and data; retrieve each.
10 | # After all are entered, retrieve all; compare output to original.
11 | # Then reopen the file, re-retrieve everything.
12 | # Finally, delete everything.
13 | proc hsearch { { nentries 1000 } } {
14 | source ./include.tcl
15 |
16 | puts "HSEARCH interfaces test: $nentries"
17 |
18 | # Create the database and open the dictionary
19 | set t1 $testdir/t1
20 | set t2 $testdir/t2
21 | set t3 $testdir/t3
22 | cleanup $testdir NULL
23 |
24 | error_check_good hcreate [berkdb hcreate $nentries] 0
25 | set did [open $dict]
26 | set count 0
27 |
28 | puts "\tHSEARCH.a: put/get loop"
29 | # Here is the loop where we put and get each key/data pair
30 | while { [gets $did str] != -1 && $count < $nentries } {
31 | set ret [berkdb hsearch $str $str enter]
32 | error_check_good hsearch:enter $ret 0
33 |
34 | set d [berkdb hsearch $str 0 find]
35 | error_check_good hsearch:find $d $str
36 | incr count
37 | }
38 | close $did
39 |
40 | puts "\tHSEARCH.b: re-get loop"
41 | set did [open $dict]
42 | # Here is the loop where we retrieve each key
43 | while { [gets $did str] != -1 && $count < $nentries } {
44 | set d [berkdb hsearch $str 0 find]
45 | error_check_good hsearch:find $d $str
46 | incr count
47 | }
48 | close $did
49 | error_check_good hdestroy [berkdb hdestroy] 0
50 | }
51 |
--------------------------------------------------------------------------------
/test/tcl/include.tcl:
--------------------------------------------------------------------------------
1 | # Automatically built by dist/s_test; may require local editing.
2 |
3 | set tclsh_path @TCL_TCLSH@
4 | set tcllib .libs/libdb_tcl-@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@@LIBTSO_MODSUFFIX@
5 |
6 | set src_root @srcdir@/..
7 | set test_path @srcdir@/../test/tcl
8 | set je_root @srcdir@/../../je
9 | set tcl_utils @srcdir@/../test/tcl_utils
10 |
11 | global testdir
12 | set testdir ./TESTDIR
13 |
14 | global dict
15 | global util_path
16 |
17 | global is_freebsd_test
18 | global is_hp_test
19 | global is_linux_test
20 | global is_osx_test
21 | global is_qnx_test
22 | global is_sunos_test
23 | global is_windows_test
24 | global is_windows9x_test
25 |
26 | global valid_methods
27 | global checking_valid_methods
28 | global test_recopts
29 |
30 | set KILL "@KILL@"
31 |
--------------------------------------------------------------------------------
/test/tcl/lock004.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST lock004
8 | # TEST Test locker ids wraping around.
9 |
10 | proc lock004 {} {
11 | source ./include.tcl
12 | global lock_curid
13 | global lock_maxid
14 |
15 | set save_curid $lock_curid
16 | set save_maxid $lock_maxid
17 |
18 | set lock_curid [expr $lock_maxid - 1]
19 | puts "Lock004: Locker id wraparound test"
20 | puts "\tLock004.a: repeat lock001-lock003 with wraparound lockids"
21 |
22 | lock001
23 | lock002
24 | lock003
25 |
26 | set lock_curid $save_curid
27 | set lock_maxid $save_maxid
28 | }
29 |
--------------------------------------------------------------------------------
/test/tcl/log008.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST log008
8 | # TEST Test what happens if a txn_ckp record falls into a
9 | # TEST different log file than the DBREG_CKP records generated
10 | # TEST by the same checkpoint.
11 |
12 | proc log008 { { nhandles 100 } args } {
13 | source ./include.tcl
14 | set tnum "008"
15 |
16 | puts "Log$tnum: Checkpoint test with records spanning log files."
17 | env_cleanup $testdir
18 |
19 | # Set up env command for use later.
20 | set envcmd "berkdb_env -create -txn -home $testdir"
21 |
22 | # Start up a child process which will open a bunch of handles
23 | # on a database and write to it, running until it creates a
24 | # checkpoint with records spanning two log files.
25 | puts "\tLog$tnum.a: Spawning child tclsh."
26 | set pid [exec $tclsh_path $test_path/wrap.tcl \
27 | log008script.tcl $testdir/log008script.log $nhandles &]
28 |
29 | watch_procs $pid 3
30 |
31 | puts "\tLog$tnum.b: Child is done."
32 |
33 | # Join the env with recovery. This ought to work.
34 | puts "\tLog$tnum.c: Join abandoned child env with recovery."
35 | set env [eval $envcmd -recover]
36 |
37 | # Clean up.
38 | error_check_good env_close [$env close] 0
39 |
40 | # Check log file for failures.
41 | set errstrings [eval findfail $testdir/log008script.log]
42 | foreach str $errstrings {
43 | puts "FAIL: error message in log008 log file: $str"
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/test/tcl/logtrack.list:
--------------------------------------------------------------------------------
1 | PREFIX __crdel
2 | BEGIN metasub 42 142
3 | BEGIN inmem_create 44 138
4 | BEGIN inmem_rename 44 139
5 | BEGIN inmem_remove 44 140
6 | PREFIX __db
7 | BEGIN addrem 50 41
8 | BEGIN big 50 43
9 | BEGIN ovref 42 44
10 | BEGIN debug 42 47
11 | BEGIN noop 42 48
12 | BEGIN pg_alloc 43 49
13 | BEGIN pg_free 43 50
14 | BEGIN cksum 42 51
15 | BEGIN pg_freedata 43 52
16 | BEGIN pg_init 43 60
17 | BEGIN pg_trunc 50 66
18 | BEGIN realloc 50 36
19 | BEGIN relink 44 147
20 | BEGIN merge 47 148
21 | BEGIN pgno 44 149
22 | PREFIX __dbreg
23 | BEGIN register 42 2
24 | PREFIX __bam
25 | BEGIN split 50 62
26 | BEGIN rsplit 42 63
27 | BEGIN adj 42 55
28 | BEGIN cadjust 42 56
29 | BEGIN cdel 42 57
30 | BEGIN repl 42 58
31 | BEGIN irep 50 67
32 | BEGIN root 42 59
33 | BEGIN curadj 42 64
34 | BEGIN rcuradj 42 65
35 | PREFIX __fop
36 | BEGIN create 48 143
37 | BEGIN remove 42 144
38 | BEGIN write 48 145
39 | BEGIN rename 48 146
40 | BEGIN file_remove 42 141
41 | PREFIX __ham
42 | BEGIN insdel 50 21
43 | BEGIN newpage 42 22
44 | BEGIN splitdata 42 24
45 | BEGIN replace 50 25
46 | BEGIN copypage 42 28
47 | BEGIN metagroup 43 29
48 | BEGIN groupalloc 43 32
49 | BEGIN changeslot 50 35
50 | BEGIN contract 50 37
51 | BEGIN curadj 42 33
52 | BEGIN chgpg 42 34
53 | PREFIX __heap
54 | BEGIN addrem 49 151
55 | BEGIN pg_alloc 49 152
56 | PREFIX __qam
57 | BEGIN incfirst 42 84
58 | BEGIN mvptr 42 85
59 | BEGIN del 42 79
60 | BEGIN add 42 80
61 | BEGIN delext 42 83
62 | PREFIX __txn
63 | BEGIN regop 44 10
64 | BEGIN ckp 43 11
65 | BEGIN child 42 12
66 | BEGIN prepare 48 13
67 | BEGIN recycle 42 14
68 |
--------------------------------------------------------------------------------
/test/tcl/mut002script.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # Mut002script: for use with mut002, a 2-process mutex test.
8 | # Usage: mut002script testdir
9 | # testdir: directory containing the env we are joining.
10 | # mutex: id of mutex
11 |
12 | source ./include.tcl
13 |
14 | set usage "mut002script testdir mutex"
15 |
16 | # Verify usage
17 | if { $argc != 2 } {
18 | puts stderr "FAIL:[timestamp] Usage: $usage"
19 | exit
20 | }
21 |
22 | # Initialize arguments.
23 | set testdir [ lindex $argv 0 ]
24 | set mutex [ lindex $argv 1 ]
25 |
26 | # Open environment.
27 | if {[catch {eval {berkdb_env} -create -home $testdir } dbenv]} {
28 | puts "FAIL: opening env returned $dbenv"
29 | }
30 | error_check_good envopen [is_valid_env $dbenv] TRUE
31 |
32 | # Pause for a while to let the original process block.
33 | tclsleep 10
34 |
35 | # Unlock the mutex and let the original process proceed.
36 | $dbenv mutex_unlock $mutex
37 |
38 | # Clean up.
39 | error_check_good env_close [$dbenv close] 0
40 |
--------------------------------------------------------------------------------
/test/tcl/mut003.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST mut003
8 | # TEST Try doing mutex operations out of order. Make sure
9 | # TEST we get appropriate errors.
10 |
11 | proc mut003 { } {
12 | source ./include.tcl
13 | env_cleanup $testdir
14 |
15 | puts "Mut003: Out of order mutex operations."
16 |
17 | # Allocate a mutex. Try to unlock it before it's locked.
18 | puts "\tMut003.a: Try to unlock a mutex that's not locked."
19 | set env [berkdb_env_noerr -create -home $testdir]
20 | set mutex [$env mutex]
21 | catch { $env mutex_unlock $mutex } res
22 | error_check_good \
23 | already_unlocked [is_substr $res "lock already unlocked"] 1
24 | env_cleanup $testdir
25 |
26 | # Allocate and lock a mutex. Try to unlock it twice.
27 | puts "\tMut003.b: Try to unlock a mutex twice."
28 | set env [berkdb_env_noerr -create -home $testdir]
29 | set mutex [$env mutex]
30 | error_check_good mutex_lock [$env mutex_lock $mutex] 0
31 | error_check_good mutex_unlock [$env mutex_unlock $mutex] 0
32 | catch { $env mutex_unlock $mutex } res
33 | error_check_good \
34 | already_unlocked [is_substr $res "lock already unlocked"] 1
35 | env_cleanup $testdir
36 |
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/test/tcl/recdscript.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # Recovery txn prepare script
8 | # Usage: recdscript op dir envcmd dbfile cmd
9 | # op: primary txn operation
10 | # dir: test directory
11 | # envcmd: command to open env
12 | # dbfile: name of database file
13 | # gidf: name of global id file
14 | # cmd: db command to execute
15 |
16 | source ./include.tcl
17 | source $test_path/test.tcl
18 |
19 | set usage "recdscript op dir envcmd dbfile gidfile cmd"
20 |
21 | # Verify usage
22 | if { $argc < 6 } {
23 | puts stderr "FAIL:[timestamp] Usage: $usage"
24 | exit
25 | }
26 |
27 | # Initialize arguments
28 | set op [ lindex $argv 0 ]
29 | set dir [ lindex $argv 1 ]
30 | set envcmd [ lindex $argv 2 ]
31 | set dbfile [ lindex $argv 3 ]
32 | set gidfile [ lindex $argv 4 ]
33 | set cmd [ lindex $argv 5 ]
34 | set args [ lindex $argv 6 ]
35 |
36 | eval {op_recover_prep $op $dir $envcmd $dbfile $gidfile $cmd} $args
37 | flush stdout
38 |
--------------------------------------------------------------------------------
/test/tcl/repmgr028script.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # Repmgr028 script - subordinate repmgr processes and dynamic role changes
6 |
7 | source ./include.tcl
8 | source $test_path/test.tcl
9 |
10 | # Make sure a subordinate process is not allowed to set the ELECTIONS config.
11 | #
12 | set dbenv [berkdb_env_noerr -thread -home $testdir/SITE_A -txn -rep]
13 | $dbenv repmgr -start elect
14 | set ret [catch {$dbenv rep_config {mgrelections off}} result]
15 | error_check_bad role_chg_attempt $ret 0
16 | $dbenv close
17 |
18 | puts "OK"
19 |
--------------------------------------------------------------------------------
/test/tcl/repmgr029script.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 |
7 | source ./include.tcl
8 | source $test_path/test.tcl
9 | source $test_path/testutils.tcl
10 | source $test_path/reputils.tcl
11 |
12 | set dirC [lindex $argv 0]
13 | set portC [lindex $argv 1]
14 | set rv [lindex $argv 2]
15 |
16 | proc in_sync_state { d } {
17 | global util_path
18 | set stat [exec $util_path/db_stat -N -r -R A -h $d]
19 | puts "stat is $stat"
20 | set in_page [is_substr $stat "SYNC_PAGE"]
21 | puts "value is $in_page"
22 | return $in_page
23 | }
24 |
25 | puts "Start site C"
26 | set envC [berkdb env -create -errpfx C -home $dirC -txn -rep -thread \
27 | -recover -verbose [list rep $rv]]
28 | $envC repmgr -local [list 127.0.0.1 $portC] -start elect
29 |
30 | puts "Wait until it gets into SYNC_PAGES state"
31 | while {![in_sync_state $dirC]} {
32 | tclsleep 1
33 | }
34 |
--------------------------------------------------------------------------------
/test/tcl/repmgr029script2.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 |
7 | source ./include.tcl
8 | source $test_path/test.tcl
9 | source $test_path/testutils.tcl
10 | source $test_path/reputils.tcl
11 |
12 | set dirB [lindex $argv 0]
13 | set portB [lindex $argv 1]
14 | set dirA [lindex $argv 2]
15 | set portA [lindex $argv 3]
16 |
17 | puts "Repmgr029script2: Open env of A."
18 | set ma_cmd "berkdb_env -home $dirA -txn -thread"
19 | set envA [eval $ma_cmd]
20 | error_check_good script_env_open [is_valid_env $envA] TRUE
21 |
22 | puts "Repmgr029script2: Wait until there is an active txn"
23 | set maxcount 100
24 | for { set count 0 } { $count < $maxcount } { incr count } {
25 | set active_txn_1 [stat_field $envA txn_stat "Number active txns"]
26 | if { $active_txn_1 > 0 } {
27 | break
28 | } else {
29 | tclsleep 1
30 | }
31 | }
32 | error_check_good a_txn_A_1 $active_txn_1 1
33 |
34 | puts "Repmgr029script2: Start up B. It finishes when the txn has been aborted."
35 | set envB [berkdb env -create -errpfx B -home $dirB -txn -rep -thread]
36 | $envB repmgr -local [list 127.0.0.1 $portB] -remote [list 127.0.0.1 $portA] \
37 | -start client
38 | await_startup_done $envB
39 | error_check_good a_txn_A_0 [stat_field $envA txn_stat "Number active txns"] 0
40 |
41 | puts "Repmgr029script2: Check gmdb at site B"
42 | error_check_good nsites_B [$envB rep_get_nsites] 2
43 |
44 | error_check_good client_close [$envB close] 0
45 |
--------------------------------------------------------------------------------
/test/tcl/rsrc004.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2001, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST rsrc004
8 | # TEST Recno backing file test for EOF-terminated records.
9 | proc rsrc004 { } {
10 | source ./include.tcl
11 |
12 | foreach isfixed { 0 1 } {
13 | cleanup $testdir NULL
14 |
15 | # Create the backing text file.
16 | set oid1 [open $testdir/rsrc.txt w]
17 | if { $isfixed == 1 } {
18 | puts -nonewline $oid1 "record 1xxx"
19 | puts -nonewline $oid1 "record 2xxx"
20 | } else {
21 | puts $oid1 "record 1xxx"
22 | puts $oid1 "record 2xxx"
23 | }
24 | puts -nonewline $oid1 "record 3"
25 | close $oid1
26 |
27 | set args "-create -mode 0644 -recno -source $testdir/rsrc.txt"
28 | if { $isfixed == 1 } {
29 | append args " -len [string length "record 1xxx"]"
30 | set match "record 3 "
31 | puts "Rsrc004: EOF-terminated recs: fixed length"
32 | } else {
33 | puts "Rsrc004: EOF-terminated recs: variable length"
34 | set match "record 3"
35 | }
36 |
37 | puts "\tRsrc004.a: Read file, verify correctness."
38 | set db [eval berkdb_open $args "$testdir/rsrc004.db"]
39 | error_check_good dbopen [is_valid_db $db] TRUE
40 |
41 | # Read the last record
42 | set dbc [eval {$db cursor} ""]
43 | error_check_good db_cursor [is_valid_cursor $dbc $db] TRUE
44 |
45 | set rec [$dbc get -last]
46 | error_check_good get_last $rec [list [list 3 $match]]
47 |
48 | error_check_good dbc_close [$dbc close] 0
49 | error_check_good db_close [$db close] 0
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/test/tcl/sdbscript.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1999, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # Usage: subdbscript testfile subdbnumber factor
8 | # testfile: name of DB itself
9 | # subdbnumber: n, subdb indicator, of form sub$n.db
10 | # factor: Delete over factor'th + n'th from my subdb.
11 | #
12 | # I.e. if factor is 10, and n is 0, remove entries, 0, 10, 20, ...
13 | # if factor is 10 and n is 1, remove entries 1, 11, 21, ...
14 | source ./include.tcl
15 | source $test_path/test.tcl
16 |
17 | set usage "subdbscript testfile subdbnumber factor"
18 |
19 | # Verify usage
20 | if { $argc != 3 } {
21 | puts stderr "FAIL:[timestamp] Usage: $usage"
22 | exit
23 | }
24 |
25 | # Initialize arguments
26 | set testfile [lindex $argv 0]
27 | set n [ lindex $argv 1 ]
28 | set factor [ lindex $argv 2 ]
29 |
30 | set db [berkdb_open -unknown $testfile sub$n.db]
31 | error_check_good db_open [is_valid_db $db] TRUE
32 |
33 | set dbc [$db cursor]
34 | error_check_good db_cursor [is_valid_cursor $dbc $db] TRUE
35 | set i 1
36 | for {set d [$dbc get -first]} {[llength $d] != 0} {set d [$dbc get -next]} {
37 | set x [expr $i - $n]
38 | if { $x >= 0 && [expr $x % $factor] == 0 } {
39 | puts "Deleting $d"
40 | error_check_good dbc_del [$dbc del] 0
41 | }
42 | incr i
43 | }
44 | error_check_good db_close [$db close] 0
45 |
46 | exit
47 |
--------------------------------------------------------------------------------
/test/tcl/test005.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test005
8 | # TEST Small keys/medium data
9 | # TEST Put/get per key
10 | # TEST Close, reopen
11 | # TEST Sequential (cursor) get/delete
12 | # TEST
13 | # TEST Check that cursor operations work. Create a database; close
14 | # TEST it and reopen it. Then read through the database sequentially
15 | # TEST using cursors and delete each element.
16 | proc test005 { method {nentries 10000} args } {
17 | eval {test004 $method $nentries "005" 0} $args
18 | }
19 |
--------------------------------------------------------------------------------
/test/tcl/test007.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test007
8 | # TEST Small keys/medium data
9 | # TEST Put/get per key
10 | # TEST Close, reopen
11 | # TEST Keyed delete
12 | # TEST
13 | # TEST Check that delete operations work. Create a database; close
14 | # TEST database and reopen it. Then issues delete by key for each
15 | # TEST entry. (Test006 plus reopen)
16 | proc test007 { method {nentries 10000} {tnum "007"} {ndups 5} args} {
17 | eval {test006 $method $nentries 1 $tnum $ndups} $args
18 | }
19 |
--------------------------------------------------------------------------------
/test/tcl/test009.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test009
8 | # TEST Small keys/large data
9 | # TEST Same as test008; close and reopen database
10 | # TEST
11 | # TEST Check that we reuse overflow pages. Create database with lots of
12 | # TEST big key/data pairs. Go through and delete and add keys back
13 | # TEST randomly. Then close the DB and make sure that we have everything
14 | # TEST we think we should.
15 | proc test009 { method args} {
16 | eval {test008 $method "009" 0} $args
17 | }
18 |
--------------------------------------------------------------------------------
/test/tcl/test018.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test018
8 | # TEST Offpage duplicate test
9 | # TEST Key_{first,last,before,after} offpage duplicates.
10 | # TEST Run duplicates with small page size so that we test off page
11 | # TEST duplicates.
12 | proc test018 { method {nentries 10000} args} {
13 | puts "Test018: Off page duplicate tests"
14 | set pgindex [lsearch -exact $args "-pagesize"]
15 | if { $pgindex != -1 } {
16 | puts "Test018: Skipping for specific pagesizes"
17 | return
18 | }
19 | eval {test011 $method $nentries 19 "018" -pagesize 512} $args
20 | }
21 |
--------------------------------------------------------------------------------
/test/tcl/test027.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test027
8 | # TEST Off-page duplicate test
9 | # TEST Test026 with parameters to force off-page duplicates.
10 | # TEST
11 | # TEST Check that delete operations work. Create a database; close
12 | # TEST database and reopen it. Then issues delete by key for each
13 | # TEST entry.
14 | proc test027 { method {nentries 100} args} {
15 | eval {test026 $method $nentries 100 "027"} $args
16 | }
17 |
--------------------------------------------------------------------------------
/test/tcl/test034.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test034
8 | # TEST test032 with off-page or overflow case with non-duplicates
9 | # TEST and duplicates.
10 | # TEST
11 | # TEST DB_GET_BOTH, DB_GET_BOTH_RANGE functionality with off-page
12 | # TEST or overflow case within non-duplicates and duplicates.
13 | proc test034 { method {nentries 10000} args} {
14 | set pgindex [lsearch -exact $args "-pagesize"]
15 | if { $pgindex != -1 } {
16 | puts "Test034: Skipping for specific pagesizes"
17 | return
18 | }
19 |
20 | # Test without duplicate and without overflow.
21 | eval {test032 $method $nentries 1 "034" 0} $args
22 |
23 | # Test without duplicate but with overflows.
24 | eval {test032 $method [expr $nentries / 100] 1 "034" 1} $args
25 |
26 | # Test with off-page duplicates
27 | eval {test032 $method $nentries 20 "034" 0} -pagesize 512 $args
28 |
29 | # Test with multiple pages of off-page duplicates
30 | eval {test032 $method [expr $nentries / 10] 100 "034" 0} -pagesize 512 $args
31 |
32 | # Test with overflow duplicate.
33 | eval {test032 $method [expr $nentries / 100] 5 "034" 1} $args
34 | }
35 |
--------------------------------------------------------------------------------
/test/tcl/test035.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test035
8 | # TEST Test033 with off-page non-duplicates and duplicates
9 | # TEST DB_GET_BOTH functionality with off-page non-duplicates
10 | # TEST and duplicates.
11 | proc test035 { method {nentries 10000} args} {
12 | set pgindex [lsearch -exact $args "-pagesize"]
13 | if { $pgindex != -1 } {
14 | puts "Test035: Skipping for specific pagesizes"
15 | return
16 | }
17 | # Test with off-page duplicates
18 | eval {test033 $method $nentries 20 "035" 0 -pagesize 512} $args
19 | # Test with multiple pages of off-page duplicates
20 | eval {test033 $method [expr $nentries / 10] 100 "035" 0 -pagesize 512} \
21 | $args
22 | # Test with overflow duplicates
23 | eval {test033 $method [expr $nentries / 100] 20 "035" 1 -pagesize 512} \
24 | $args
25 | # Test with off-page non-duplicates
26 | eval {test033 $method $nentries 1 "035" 0 -pagesize 512} $args
27 | # Test with overflow non-duplicates
28 | eval {test033 $method [expr $nentries / 100] 1 "035" 1 -pagesize 512} \
29 | $args
30 | }
31 |
--------------------------------------------------------------------------------
/test/tcl/test040.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test040
8 | # TEST Test038 with off-page duplicates
9 | # TEST DB_GET_BOTH functionality with off-page duplicates.
10 | proc test040 { method {nentries 10000} args} {
11 | set pgindex [lsearch -exact $args "-pagesize"]
12 | if { $pgindex != -1 } {
13 | puts "Test040: skipping for specific pagesizes"
14 | return
15 | }
16 | # Test with off-page duplicates
17 | eval {test038 $method $nentries 20 "040" -pagesize 512} $args
18 |
19 | # Test with multiple pages of off-page duplicates
20 | eval {test038 $method [expr $nentries / 10] 100 "040" -pagesize 512} \
21 | $args
22 | }
23 |
--------------------------------------------------------------------------------
/test/tcl/test041.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test041
8 | # TEST Test039 with off-page duplicates
9 | # TEST DB_GET_BOTH functionality with off-page duplicates.
10 | proc test041 { method {nentries 10000} args} {
11 | # Test with off-page duplicates
12 | eval {test039 $method $nentries 20 "041" -pagesize 512} $args
13 |
14 | # Test with multiple pages of off-page duplicates
15 | eval {test039 $method [expr $nentries / 10] 100 "041" -pagesize 512} \
16 | $args
17 | }
18 |
--------------------------------------------------------------------------------
/test/tcl/test069.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1999, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test069
8 | # TEST Test of DB_CURRENT partial puts without duplicates-- test067 w/
9 | # TEST small ndups to ensure that partial puts to DB_CURRENT work
10 | # TEST correctly in the absence of duplicate pages.
11 | proc test069 { method {ndups 50} {tnum "069"} args } {
12 | eval test067 $method $ndups $tnum $args
13 | }
14 |
--------------------------------------------------------------------------------
/test/tcl/test071.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1999, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test071
8 | # TEST Test of DB_CONSUME (One consumer, 10000 items.)
9 | # TEST This is DB Test 70, with one consumer, one producers, and 10000 items.
10 | proc test071 { method {nconsumers 1} {nproducers 1} {nitems 10000} \
11 | {mode CONSUME} {start 0 } {txn -txn} {tnum "071"} args } {
12 |
13 | eval test070 $method \
14 | $nconsumers $nproducers $nitems $mode $start $txn $tnum $args
15 | }
16 |
--------------------------------------------------------------------------------
/test/tcl/test079.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test079
8 | # TEST Test of deletes in large trees. (test006 w/ sm. pagesize).
9 | # TEST
10 | # TEST Check that delete operations work in large btrees. 10000 entries
11 | # TEST and a pagesize of 512 push this out to a four-level btree, with a
12 | # TEST small fraction of the entries going on overflow pages.
13 | proc test079 { method {nentries 10000} {pagesize 512} {tnum "079"} \
14 | {ndups 20} args} {
15 | if { [ is_queueext $method ] == 1 } {
16 | set method "queue";
17 | lappend args "-extent" "20"
18 | }
19 |
20 | set pgindex [lsearch -exact $args "-pagesize"]
21 | if { $pgindex != -1 } {
22 | puts "Test$tnum: skipping for specific pagesizes"
23 | return
24 | }
25 |
26 | eval {test006 $method $nentries 1 $tnum $ndups -pagesize \
27 | $pagesize} $args
28 | }
29 |
--------------------------------------------------------------------------------
/test/tcl/test081.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1999, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test081
8 | # TEST Test off-page duplicates and overflow pages together with
9 | # TEST very large keys (key/data as file contents).
10 | proc test081 { method {ndups 13} {tnum "081"} args} {
11 | source ./include.tcl
12 |
13 | eval {test017 $method 1 $ndups $tnum} $args
14 | }
15 |
--------------------------------------------------------------------------------
/test/tcl/test082.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test082
8 | # TEST Test of DB_PREV_NODUP (uses test074).
9 | proc test082 { method {dir -prevnodup} {nitems 100} {tnum "082"} args} {
10 | source ./include.tcl
11 |
12 | eval {test074 $method $dir $nitems $tnum} $args
13 | }
14 |
--------------------------------------------------------------------------------
/test/tcl/test084.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test084
8 | # TEST Basic sanity test (test001) with large (64K) pages.
9 | proc test084 { method {nentries 10000} {tnum "084"} {pagesize 65536} args} {
10 | source ./include.tcl
11 |
12 | set txnenv 0
13 | set eindex [lsearch -exact $args "-env"]
14 | #
15 | # If we are using an env, then testfile should just be the db name.
16 | # Otherwise it is the test directory and the name.
17 | if { $eindex == -1 } {
18 | set testfile $testdir/test$tnum-empty.db
19 | set env NULL
20 | } else {
21 | set testfile test$tnum-empty.db
22 | incr eindex
23 | set env [lindex $args $eindex]
24 | set txnenv [is_txnenv $env]
25 | if { $txnenv == 1 } {
26 | append args " -auto_commit "
27 | }
28 | set testdir [get_home $env]
29 | }
30 |
31 | set pgindex [lsearch -exact $args "-pagesize"]
32 | if { $pgindex != -1 } {
33 | puts "Test084: skipping for specific pagesizes"
34 | return
35 | }
36 |
37 | cleanup $testdir $env
38 |
39 | set args "-pagesize $pagesize $args"
40 |
41 | eval {test001 $method $nentries 0 0 $tnum} $args
42 |
43 | set omethod [convert_method $method]
44 | set args [convert_args $method $args]
45 |
46 | # For good measure, create a second database that's empty
47 | # with the large page size. (There was a verifier bug that
48 | # choked on empty 64K pages. [#2408])
49 | set db [eval {berkdb_open -create -mode 0644} $args $omethod $testfile]
50 | error_check_good empty_db [is_valid_db $db] TRUE
51 | error_check_good empty_db_close [$db close] 0
52 | }
53 |
--------------------------------------------------------------------------------
/test/tcl/test090.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test090
8 | # TEST Test for functionality near the end of the queue using test001.
9 | proc test090 { method {nentries 10000} {tnum "090"} args} {
10 | if { [is_queueext $method ] == 0 } {
11 | puts "Skipping test$tnum for $method."
12 | return;
13 | }
14 | eval {test001 $method $nentries 4294967000 0 $tnum} $args
15 | }
16 |
--------------------------------------------------------------------------------
/test/tcl/test091.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test091
8 | # TEST Test of DB_CONSUME_WAIT.
9 | proc test091 { method {nconsumers 4} \
10 | {nproducers 2} {nitems 1000} {start 0 } {tnum "091"} args} {
11 | if { [is_queue $method ] == 0 } {
12 | puts "Skipping test0$tnum for $method."
13 | return;
14 | }
15 | eval {test070 $method \
16 | $nconsumers $nproducers $nitems WAIT $start -txn $tnum } $args
17 | eval {test070 $method \
18 | $nconsumers $nproducers $nitems WAIT $start -cdb $tnum } $args
19 | }
20 |
--------------------------------------------------------------------------------
/test/tcl/test100.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test100
8 | # TEST Test for functionality near the end of the queue
9 | # TEST using test025 (DB_APPEND).
10 | proc test100 { method {nentries 10000} {tnum "100"} args} {
11 | if { [is_queueext $method ] == 0 } {
12 | puts "Skipping test$tnum for $method."
13 | return;
14 | }
15 | eval {test025 $method $nentries 4294967000 $tnum} $args
16 | }
17 |
--------------------------------------------------------------------------------
/test/tcl/test101.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test101
8 | # TEST Test for functionality near the end of the queue
9 | # TEST using test070 (DB_CONSUME).
10 | proc test101 { method {nentries 1000} {txn -txn} {tnum "101"} args} {
11 | if { [is_queueext $method ] == 0 } {
12 | puts "Skipping test$tnum for $method."
13 | return;
14 | }
15 | eval {test070 $method 4 2 $nentries WAIT 4294967000 $txn $tnum} $args
16 | }
17 |
--------------------------------------------------------------------------------
/test/tcl/test128.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test128
8 | # TEST Test database bulk update for non-duplicate databases, with different
9 | # TEST configurations.
10 | # TEST
11 | # TEST This is essentially test126 with the following configurations:
12 | # TEST * sub database.
13 | # TEST * secondary database.
14 | # TEST * bulk buffer pre-sort.
15 |
16 | proc test128 {method { nentries 10000 } {callback 1} args } {
17 | source ./include.tcl
18 |
19 | if { [is_partition_callback $args] == 1 } {
20 | set nodump 1
21 | } else {
22 | set nodump 0
23 | }
24 | # Test using sub database
25 | eval {test126 $method $nentries "128" $callback 1 0 0} $args
26 | eval {verify_dir $testdir "" 1 0 $nodump}
27 | eval {salvage_dir $testdir "" 1}
28 |
29 | # Test using secondary database
30 | eval {test126 $method $nentries "128" $callback 0 1 0} $args
31 | eval {verify_dir $testdir "" 1 0 $nodump}
32 | eval {salvage_dir $testdir "" 1}
33 |
34 | # Test with -sort_multiple
35 | eval {test126 $method $nentries "128" $callback 0 0 1} $args
36 | eval {verify_dir $testdir "" 1 0 $nodump}
37 | eval {salvage_dir $testdir "" 1}
38 |
39 | # Test using both sub database and secondary database,
40 | # and with -sort_multiple
41 | eval {test126 $method $nentries "128" $callback 1 1 1} $args
42 |
43 | }
44 |
45 |
46 |
--------------------------------------------------------------------------------
/test/tcl/test129.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test129
8 | # TEST Test database bulk update for duplicate database, with different
9 | # TEST configurations.
10 | # TEST
11 | # TEST This is essentially test127 with the following configurations:
12 | # TEST * sub database.
13 | # TEST * bulk buffer pre-sort.
14 |
15 | proc test129 {method { nentries 10000 } { ndups 5} args } {
16 | source ./include.tcl
17 |
18 | if { [is_partition_callback $args] == 1 } {
19 | set nodump 1
20 | } else {
21 | set nodump 0
22 | }
23 |
24 | # Test using sub database.
25 | eval {test127 $method $nentries $ndups "129" 1 0} $args
26 | eval {verify_dir $testdir "" 1 0 $nodump}
27 | eval {salvage_dir $testdir "" 1}
28 |
29 | # Test with -sort_multiple.
30 | eval {test127 $method $nentries $ndups "129" 0 1} $args
31 | eval {verify_dir $testdir "" 1 0 $nodump}
32 | eval {salvage_dir $testdir "" 1}
33 |
34 | # Test using sub database, and with -sort_multiple.
35 | eval {test127 $method $nentries $ndups "129" 1 1} $args
36 |
37 | }
38 |
39 |
40 |
--------------------------------------------------------------------------------
/test/tcl/test132.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test132
8 | # TEST Test foreign database operations on sub databases and
9 | # TEST in-memory databases.
10 |
11 | proc test132 {method {nentries 1000} {ndups 5} args } {
12 | source ./include.tcl
13 |
14 | if { [is_partition_callback $args] == 1 } {
15 | set nodump 1
16 | } else {
17 | set nodump 0
18 | }
19 |
20 | # Test using on-disk sub databases.
21 | eval {test131 $method $nentries "132" $ndups 1 0} $args
22 | eval {verify_dir $testdir "" 1 0 $nodump}
23 | eval {salvage_dir $testdir "" 1}
24 |
25 | # Test using in-memory databases.
26 | eval {test131 $method $nentries "132" $ndups 0 1} $args
27 |
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/test/tcl/test134.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test134
8 | # TEST Test cursor cleanup for sub databases.
9 |
10 | proc test134 {method {nentries 1000} args} {
11 | source ./include.tcl
12 |
13 | eval {test133 $method $nentries "134" 1} $args
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/test/tcl/test136.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test136
8 | # TEST Test operations on similar overflow records. [#20329]
9 | # TEST Here, we use subdatabases.
10 |
11 | proc test136 {method {keycnt 10} {datacnt 10} args} {
12 | source ./include.tcl
13 |
14 | eval {test135 $method $keycnt $datacnt 1 "136"} $args
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/test/tcl/test138.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST test138
8 | # TEST Test Automatic Resource Management. [#16188][#20281]
9 | # TEST Here, we test the following cases:
10 | # TEST Non-encrypt for cds
11 | # TEST Non-encrypt for tds
12 | # TEST Encrypt for ds
13 | # TEST Encrypt for cds
14 | # TEST Encrypt for tds
15 |
16 | proc test138 { method {nentries 1000} {start 0} {skip 0} args } {
17 | source ./include.tcl
18 |
19 | eval {test137 $method $nentries $start $skip 0 "138" "cds"} $args
20 | eval {test137 $method $nentries $start $skip 0 "138" "tds"} $args
21 | eval {test137 $method $nentries $start $skip 1 "138" "ds"} $args
22 | eval {test137 $method $nentries $start $skip 1 "138" "cds"} $args
23 | eval {test137 $method $nentries $start $skip 1 "138" "tds"} $args
24 | }
25 |
--------------------------------------------------------------------------------
/test/tcl/txn006.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | #TEST txn006
8 | #TEST Test dump/load in transactional environment.
9 | proc txn006 { { iter 50 } } {
10 | source ./include.tcl
11 | set testfile txn006.db
12 |
13 | puts "Txn006: Test dump/load in transaction environment"
14 | env_cleanup $testdir
15 |
16 | puts "\tTxn006.a: Create environment and database"
17 | # Open/create the txn region
18 | set e [berkdb_env -create -home $testdir -txn]
19 | error_check_good env_open [is_valid_env $e] TRUE
20 |
21 | # Open/create database
22 | set db [berkdb_open -auto_commit -env $e \
23 | -create -btree -dup $testfile]
24 | error_check_good db_open [is_valid_db $db] TRUE
25 |
26 | # Start a transaction
27 | set txn [$e txn]
28 | error_check_good txn [is_valid_txn $txn $e] TRUE
29 |
30 | puts "\tTxn006.b: Put data"
31 | # Put some data
32 | for { set i 1 } { $i < $iter } { incr i } {
33 | error_check_good put [$db put -txn $txn key$i data$i] 0
34 | }
35 |
36 | # End transaction, close db
37 | error_check_good txn_commit [$txn commit] 0
38 | error_check_good db_close [$db close] 0
39 | error_check_good env_close [$e close] 0
40 |
41 | puts "\tTxn006.c: dump/load"
42 | # Dump and load
43 | exec $util_path/db_dump -p -h $testdir $testfile | \
44 | $util_path/db_load -h $testdir $testfile
45 | }
46 |
--------------------------------------------------------------------------------
/test/tcl/txn008.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST txn008
8 | # TEST Test of wraparound txnids (txn002)
9 | proc txn008 { } {
10 | source ./include.tcl
11 | global txn_curid
12 | global txn_maxid
13 |
14 | set orig_curid $txn_curid
15 | set orig_maxid $txn_maxid
16 | puts "\tTxn008.1: wraparound txnids"
17 | set txn_curid [expr $txn_maxid - 2]
18 | txn002 "008.1"
19 | puts "\tTxn008.2: closer wraparound txnids"
20 | set txn_curid [expr $txn_maxid - 3]
21 | set txn_maxid [expr $txn_maxid - 2]
22 | txn002 "008.2"
23 |
24 | puts "\tTxn008.3: test wraparound txnids"
25 | txn_idwrap_check $testdir
26 | set txn_curid $orig_curid
27 | set txn_maxid $orig_maxid
28 | return
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/test/tcl/txn009.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # TEST txn009
8 | # TEST Test of wraparound txnids (txn003)
9 | proc txn009 { } {
10 | source ./include.tcl
11 | global txn_curid
12 | global txn_maxid
13 |
14 | set orig_curid $txn_curid
15 | set orig_maxid $txn_maxid
16 | puts "\tTxn009.1: wraparound txnids"
17 | set txn_curid [expr $txn_maxid - 2]
18 | txn003 "009.1"
19 | puts "\tTxn009.2: closer wraparound txnids"
20 | set txn_curid [expr $txn_maxid - 3]
21 | set txn_maxid [expr $txn_maxid - 2]
22 | txn003 "009.2"
23 |
24 | puts "\tTxn009.3: test wraparound txnids"
25 | txn_idwrap_check $testdir
26 | set txn_curid $orig_curid
27 | set txn_maxid $orig_maxid
28 | return
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/test/tcl/txn012script.tcl:
--------------------------------------------------------------------------------
1 | # See the file LICENSE for redistribution information.
2 | #
3 | # Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # $Id$
6 | #
7 | # Script to check that txn names can be seen across processes.
8 | # Names over 50 characters will be truncated.
9 | #
10 | # Usage: txn012script dir txnname longtxnname
11 |
12 | source ./include.tcl
13 | source $test_path/test.tcl
14 |
15 | set usage "txn012script dir txnname longtxnname"
16 |
17 | # Verify usage
18 | if { $argc != 3 } {
19 | puts stderr "FAIL:[timestamp] Usage: $usage"
20 | exit
21 | }
22 |
23 | # Initialize arguments
24 | set dir [ lindex $argv 0 ]
25 | set txnname [ lindex $argv 1 ]
26 | set longtxnname [ lindex $argv 2 ]
27 |
28 | # Run db_stat to view txn names.
29 | set stat [exec $util_path/db_stat -h $dir -t]
30 | error_check_good txnname [is_substr $stat $txnname] 1
31 | error_check_good longtxnname [is_substr $stat $longtxnname] 0
32 | set truncname [string range $longtxnname 0 49]
33 | error_check_good truncname [is_substr $stat $truncname] 1
34 |
--------------------------------------------------------------------------------
/test/xa/src1/datafml.fml:
--------------------------------------------------------------------------------
1 | # datafml.fml was generated by tuxdev on 12/18/98 @ 12:15:33 ***** DO NOT EDIT *****
2 |
3 | SEQ_NO 401 long -
4 | TS_SEC 402 long -
5 | TS_USEC 403 long -
6 |
--------------------------------------------------------------------------------
/test/xa/src1/datafml.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
5 | */
6 |
7 | /* fname fldid */
8 | /* ----- ----- */
9 | #define SEQ_NO ((FLDID32)33554833) /* number: 401 type: long */
10 | #define TS_SEC ((FLDID32)33554834) /* number: 402 type: long */
11 | #define TS_USEC ((FLDID32)33554835) /* number: 403 type: long */
12 |
--------------------------------------------------------------------------------
/test/xa/src1/hdbrec.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
5 | */
6 |
7 | #ifndef HDBREC_H
8 | #define HDBREC_H
9 |
10 | #include "htimestampxa.h"
11 |
12 | /*
13 | * DB record
14 | */
15 | typedef struct __HDbRec {
16 | long SeqNo;
17 | HTimestampData Ts;
18 | char Msg[10];
19 | } HDbRec;
20 | #endif
21 |
--------------------------------------------------------------------------------
/test/xa/src1/htimestampxa.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include "htimestampxa.h"
11 |
12 | void
13 | GetTime(HTimestampData *ts)
14 | {
15 | struct timeval timeNow;
16 |
17 | (void)gettimeofday(&timeNow, 0);
18 | ts->Sec = timeNow.tv_sec;
19 | ts->Usec = timeNow.tv_usec;
20 | }
21 |
--------------------------------------------------------------------------------
/test/xa/src1/htimestampxa.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * See the file LICENSE for redistribution information.
3 | *
4 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
5 | */
6 |
7 | #ifndef HTIMESTAMPXA_H
8 | #define HTIMESTAMPXA_H
9 |
10 | /*
11 | * Timestamp with microseconds precision
12 | */
13 | typedef struct __HTimestampData {
14 | time_t Sec;
15 | time_t Usec;
16 | } HTimestampData;
17 |
18 | void GetTime(HTimestampData *);
19 | #endif
20 |
--------------------------------------------------------------------------------
/test/xa/src1/tuxconfig.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | # Build the configuration file for test 1 --
4 | # We do this work in the shell script because we have to fill in
5 | # lots of shell variables.
6 |
7 | MACHINE_NAME=`uname -n`
8 | cat > $RUN/config/ubb.cfg << END_OF_UBB_FILE
9 | *RESOURCES
10 | IPCKEY 200103
11 | DOMAINID domain3
12 | MASTER cluster3
13 | MAXACCESSERS 10
14 | MAXSERVERS 5
15 | MAXSERVICES 10
16 | MODEL SHM
17 | LDBAL N
18 |
19 | *MACHINES
20 | DEFAULT:
21 | APPDIR="$APPDIR"
22 | TUXCONFIG="$TUXCONFIG"
23 | TLOGDEVICE="$TLOGDEVICE"
24 | TUXDIR="$TUXDIR"
25 | # Machine name is 30 characters max
26 | "$MACHINE_NAME" LMID=cluster3
27 |
28 | *GROUPS
29 | # Group name is 30 characters max
30 | group_tm LMID=cluster3 GRPNO=1 TMSNAME=DBRM TMSCOUNT=2 OPENINFO="BERKELEY-DB:$RUN/data"
31 |
32 | *SERVERS
33 | DEFAULT:
34 | CLOPT="-A"
35 |
36 | # Server name is 78 characters max (same for any pathname)
37 | server1 SRVGRP=group_tm SRVID=1 MAXGEN=3 RESTART=Y
38 | server2 SRVGRP=group_tm SRVID=2 MAXGEN=3 RESTART=Y
39 |
40 | *SERVICES
41 | # Service name is 15 characters max
42 | # server1
43 | TestTxn1
44 | # server2
45 | TestTxn2
46 | END_OF_UBB_FILE
47 | tmloadcf -y $RUN/config/ubb.cfg
48 |
--------------------------------------------------------------------------------
/test/xa/src2/tuxconfig.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | # Build the configuration file for test 2 --
4 | # We do this work in the shell script because we have to fill in
5 | #
6 | cat > $RUN/config/ubb.cfg << END_OF_UBB_FILE
7 | *RESOURCES
8 | IPCKEY 261110
9 |
10 | DOMAINID BDBapp
11 | MASTER L1
12 | MAXACCESSERS 100
13 | MAXSERVERS 50
14 | MAXSERVICES 200
15 | MODEL SHM
16 | LDBAL Y
17 |
18 | *MACHINES
19 |
20 | "$MACHINE_NAME" LMID=L1
21 | TUXDIR="$TUXDIR"
22 | APPDIR="$APPDIR"
23 | TUXCONFIG="$TUXCONFIG"
24 | TLOGDEVICE="$TLOGDEVICE"
25 | TLOGNAME="$TLOGNAME"
26 | TYPE="machine1"
27 |
28 | *GROUPS
29 | BDBG
30 | LMID=L1 GRPNO=1 TMSNAME=TMS_BDB TMSCOUNT=3
31 | OPENINFO="BERKELEY-DB:$RUN/data"
32 |
33 | LMSG LMID=L1 GRPNO=2
34 |
35 | *SERVERS
36 | DEFAULT:
37 | CLOPT="-A"
38 |
39 | bdb1 SRVGRP=BDBG SRVID=1
40 | MIN=2 MAX=2
41 | #RQADDR="BDB1.QUEUE" REPLYQ=Y CLOPT="-A -- -t 1"
42 | RQADDR="BDB1.QUEUE" REPLYQ=Y CLOPT="-A -p L10,10:100,10 -- -t 1"
43 |
44 | bdb2 SRVGRP=BDBG SRVID=11
45 | MIN=1 MAX=1 RQADDR="BDB2.QUEUE" REPLYQ=Y
46 |
47 | #LMS SRVGRP=LMSG SRVID= 1 CLOPT="-A -- -l$MACHINE_NAME:8080/tsam"
48 |
49 | *SERVICES
50 | DEFAULT:
51 | SVCTIMEOUT=30
52 | END_OF_UBB_FILE
53 | tmloadcf -y $RUN/config/ubb.cfg
54 |
--------------------------------------------------------------------------------
/test/xa/src3/tuxconfig.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | # Build the configuration file for test 3 --
4 | # We do this work in the shell script because we have to fill in
5 | # lots of shell variables.
6 |
7 | if [ $1 == 1 ]; then
8 | IPCKEY=200104
9 | else
10 | IPCKEY=200105
11 | fi
12 | MACHINE_NAME=`uname -n`
13 | cat > $RUN/config/ubb.cfg << END_OF_UBB_FILE
14 | *RESOURCES
15 | IPCKEY $IPCKEY
16 | DOMAINID domain3
17 | MASTER cluster3
18 | MAXACCESSERS 16
19 | MAXSERVERS 6
20 | MAXSERVICES 16
21 | MODEL SHM
22 | LDBAL N
23 |
24 | *MACHINES
25 | DEFAULT:
26 | APPDIR="$APPDIR"
27 | TUXCONFIG="$TUXCONFIG"
28 | TLOGDEVICE="$TLOGDEVICE"
29 | TUXDIR="$TUXDIR"
30 | # Machine name is 30 characters max
31 | "$MACHINE_NAME" LMID=cluster3
32 |
33 | *GROUPS
34 | # Group name is 30 characters max
35 | group_tm LMID=cluster3 GRPNO=1 TMSNAME=DBRM TMSCOUNT=2 OPENINFO="BERKELEY-DB:$RUN/data"
36 |
37 | *SERVERS
38 | DEFAULT:
39 | CLOPT="-A"
40 | MINDISPATCHTHREADS=1
41 | MAXDISPATCHTHREADS=8
42 |
43 | # Server name is 78 characters max (same for any pathname)
44 | server1 SRVGRP=group_tm SRVID=1 MAXGEN=4 RESTART=Y
45 | server2 SRVGRP=group_tm SRVID=2 MAXGEN=4 RESTART=Y
46 |
47 | *SERVICES
48 | DEFAULT:
49 | SVCTIMEOUT=20
50 | # Service name is 15 characters max
51 | # server1
52 | TestThread1
53 | # server2
54 | TestThread2
55 | END_OF_UBB_FILE
56 | tmloadcf -y $RUN/config/ubb.cfg
57 |
--------------------------------------------------------------------------------
/test/xa/src4/tuxconfig.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | # Build the configuration file for test 4 --
4 | # We do this work in the shell script because we have to fill in
5 | # lots of shell variables.
6 |
7 | MACHINE_NAME=`uname -n`
8 | cat > $RUN/config/ubb.cfg << END_OF_UBB_FILE
9 | *RESOURCES
10 | IPCKEY 200103
11 | DOMAINID domain3
12 | MASTER cluster3
13 | MAXACCESSERS 10
14 | MAXSERVERS 5
15 | MAXSERVICES 10
16 | MODEL SHM
17 | LDBAL N
18 |
19 | *MACHINES
20 | DEFAULT:
21 | APPDIR="$APPDIR"
22 | TUXCONFIG="$TUXCONFIG"
23 | TLOGDEVICE="$TLOGDEVICE"
24 | TUXDIR="$TUXDIR"
25 | # Machine name is 30 characters max
26 | "$MACHINE_NAME" LMID=cluster3
27 |
28 | *GROUPS
29 | # Group name is 30 characters max
30 | group_tm LMID=cluster3 GRPNO=1 TMSNAME=DBRM TMSCOUNT=2 OPENINFO="BERKELEY-DB:$RUN/data"
31 |
32 | *SERVERS
33 | DEFAULT:
34 | CLOPT="-A"
35 |
36 | # Server name is 78 characters max (same for any pathname)
37 | server1 SRVGRP=group_tm SRVID=1 MAXGEN=3 RESTART=Y
38 | server2 SRVGRP=group_tm SRVID=2 MAXGEN=3 RESTART=Y
39 |
40 | *SERVICES
41 | # Service name is 15 characters max
42 | # server1
43 | TestTxn1
44 | # server2
45 | TestTxn2
46 | END_OF_UBB_FILE
47 | tmloadcf -y $RUN/config/ubb.cfg
48 |
--------------------------------------------------------------------------------
/test/xa/src5/DB_CONFIG:
--------------------------------------------------------------------------------
1 | set_flags DB_MULTIVERSION
2 | set_flags DB_TXN_SNAPSHOT
3 |
4 |
--------------------------------------------------------------------------------
/test/xa/utilities/multi_1thr_tuxconfig.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | # Build the configuration file for multithreaded tests --
4 | # We do this work in the shell script because we have to fill in
5 | # lots of shell variables.
6 | #
7 | # Usage: ./multi_tuxconfig.sh
8 |
9 | if test $# -ne 1; then
10 | echo "Usage: ./multi_1thr_tuxconfig.sh \n"
11 | exit 1
12 | fi
13 |
14 |
15 | IPCKEY=$1
16 | MACHINE_NAME=`uname -n`
17 | cat > $RUN/config/ubb.cfg << END_OF_UBB_FILE
18 | *RESOURCES
19 | IPCKEY $IPCKEY
20 | DOMAINID domain3
21 | MASTER cluster3
22 | MAXACCESSERS 16
23 | MAXSERVERS 6
24 | MAXSERVICES 16
25 | MODEL SHM
26 | LDBAL N
27 |
28 | *MACHINES
29 | DEFAULT:
30 | APPDIR="$APPDIR"
31 | TUXCONFIG="$TUXCONFIG"
32 | TLOGDEVICE="$TLOGDEVICE"
33 | TUXDIR="$TUXDIR"
34 | # Machine name is 30 characters max
35 | "$MACHINE_NAME" LMID=cluster3
36 |
37 | *GROUPS
38 | # Group name is 30 characters max
39 | group_tm LMID=cluster3 GRPNO=1 TMSNAME=DBRM TMSCOUNT=2 OPENINFO="BERKELEY-DB:$RUN/data"
40 |
41 | *SERVERS
42 | DEFAULT:
43 | CLOPT="-A"
44 | MINDISPATCHTHREADS=1
45 | MAXDISPATCHTHREADS=8
46 |
47 | # Server name is 78 characters max (same for any pathname)
48 | server1 SRVGRP=group_tm SRVID=1 MAXGEN=3 RESTART=Y
49 |
50 | *SERVICES
51 | DEFAULT:
52 | SVCTIMEOUT=20
53 | # Service name is 15 characters max
54 | # server1
55 | read_db1
56 | write_db1
57 |
58 | END_OF_UBB_FILE
59 | tmloadcf -y $RUN/config/ubb.cfg
60 |
--------------------------------------------------------------------------------
/test/xa/utilities/multi_tuxconfig.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | # Build the configuration file for multithreaded tests --
4 | # We do this work in the shell script because we have to fill in
5 | # lots of shell variables.
6 | #
7 | # Usage: ./multi_tuxconfig.sh
8 |
9 | if test $# -ne 1; then
10 | echo "Usage: ./multi_tuxconfig.sh \n"
11 | exit 1
12 | fi
13 |
14 |
15 | IPCKEY=$1
16 | MACHINE_NAME=`uname -n`
17 | cat > $RUN/config/ubb.cfg << END_OF_UBB_FILE
18 | *RESOURCES
19 | IPCKEY $IPCKEY
20 | DOMAINID domain3
21 | MASTER cluster3
22 | MAXACCESSERS 16
23 | MAXSERVERS 6
24 | MAXSERVICES 16
25 | MODEL SHM
26 | LDBAL N
27 |
28 | *MACHINES
29 | DEFAULT:
30 | APPDIR="$APPDIR"
31 | TUXCONFIG="$TUXCONFIG"
32 | TLOGDEVICE="$TLOGDEVICE"
33 | TUXDIR="$TUXDIR"
34 | # Machine name is 30 characters max
35 | "$MACHINE_NAME" LMID=cluster3
36 |
37 | *GROUPS
38 | # Group name is 30 characters max
39 | group_tm LMID=cluster3 GRPNO=1 TMSNAME=DBRM TMSCOUNT=2 OPENINFO="BERKELEY-DB:$RUN/data"
40 |
41 | *SERVERS
42 | DEFAULT:
43 | CLOPT="-A"
44 | MINDISPATCHTHREADS=1
45 | MAXDISPATCHTHREADS=8
46 |
47 | # Server name is 78 characters max (same for any pathname)
48 | server1 SRVGRP=group_tm SRVID=1 MAXGEN=3 RESTART=Y
49 | server2 SRVGRP=group_tm SRVID=2 MAXGEN=3 RESTART=Y
50 |
51 | *SERVICES
52 | DEFAULT:
53 | SVCTIMEOUT=20
54 | # Service name is 15 characters max
55 | # server1
56 | TestThread1
57 | # server2
58 | TestThread2
59 | END_OF_UBB_FILE
60 | tmloadcf -y $RUN/config/ubb.cfg
61 |
--------------------------------------------------------------------------------
/test/xa/utilities/tuxconfig.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | # Build the configuration file for single thread tests --
4 | # We do this work in the shell script because we have to fill in
5 | # lots of shell variables.
6 | #
7 | # Usage: ./tuxconfig.sh
8 |
9 | if test $# -ne 1; then
10 | echo "Usage: ./tuxconfig.sh \n"
11 | exit 1
12 | fi
13 | IPCKEY=$1
14 | MACHINE_NAME=`uname -n`
15 | cat > $RUN/config/ubb.cfg << END_OF_UBB_FILE
16 | *RESOURCES
17 | IPCKEY $IPCKEY
18 | DOMAINID domain3
19 | MASTER cluster3
20 | MAXACCESSERS 10
21 | MAXSERVERS 5
22 | MAXSERVICES 10
23 | MODEL SHM
24 | LDBAL N
25 |
26 | *MACHINES
27 | DEFAULT:
28 | APPDIR="$APPDIR"
29 | TUXCONFIG="$TUXCONFIG"
30 | TLOGDEVICE="$TLOGDEVICE"
31 | TUXDIR="$TUXDIR"
32 | # Machine name is 30 characters max
33 | "$MACHINE_NAME" LMID=cluster3
34 |
35 | *GROUPS
36 | # Group name is 30 characters max
37 | group_tm LMID=cluster3 GRPNO=1 TMSNAME=DBRM TMSCOUNT=2 OPENINFO="BERKELEY-DB:$RUN/data"
38 |
39 | *SERVERS
40 | DEFAULT:
41 | CLOPT="-A"
42 |
43 | # Server name is 78 characters max (same for any pathname)
44 | server1 SRVGRP=group_tm SRVID=1 MAXGEN=3 RESTART=Y
45 | server2 SRVGRP=group_tm SRVID=2 MAXGEN=3 RESTART=Y
46 |
47 | *SERVICES
48 | # Service name is 15 characters max
49 | # server1
50 | TestTxn1
51 | # server2
52 | TestTxn2
53 | END_OF_UBB_FILE
54 | tmloadcf -y $RUN/config/ubb.cfg
55 |
--------------------------------------------------------------------------------
/util/db_printlog/README:
--------------------------------------------------------------------------------
1 | # $Id$
2 |
3 | Berkeley DB log dump utility. This utility dumps out a DB log in human
4 | readable form, a record at a time, to assist in recovery and transaction
5 | abort debugging.
6 |
7 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 | commit.awk Output transaction ID of committed transactions.
9 |
10 | count.awk Print out the number of log records for transactions
11 | that we encountered.
12 |
13 | dbname.awk Take a comma-separated list of database names and spit
14 | out all the log records that affect those databases.
15 |
16 | fileid.awk Take a comma-separated list of file numbers and spit out
17 | all the log records that affect those file numbers.
18 |
19 | logstat.awk Display log record count/size statistics.
20 |
21 | pgno.awk Take a comma-separated list of page numbers and spit
22 | out all the log records that affect those page numbers.
23 |
24 | range.awk Print out a range of the log.
25 |
26 | rectype.awk Print out a range of the log -- command line should
27 | set RECTYPE to the a comma separated list of the
28 | rectypes (or partial strings of rectypes) sought.
29 |
30 | status.awk Read through db_printlog output and list the transactions
31 | encountered, and whether they committed or aborted.
32 |
33 | txn.awk Print out all the records for a comma-separated list of
34 | transaction IDs.
35 |
--------------------------------------------------------------------------------
/util/db_printlog/commit.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Output tid of committed transactions.
4 |
5 | /txn_regop/ {
6 | print $5
7 | }
8 |
--------------------------------------------------------------------------------
/util/db_printlog/count.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Print out the number of log records for transactions that we
4 | # encountered.
5 |
6 | /^\[/{
7 | if ($5 != 0)
8 | print $5
9 | }
10 |
--------------------------------------------------------------------------------
/util/db_printlog/fileid.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Take a comma-separated list of file numbers and spit out all the
4 | # log records that affect those file numbers.
5 |
6 | NR == 1 {
7 | nfiles = 0
8 | while ((ndx = index(FILEID, ",")) != 0) {
9 | files[nfiles] = substr(FILEID, 1, ndx - 1);
10 | FILEID = substr(FILEID, ndx + 1, length(FILEID) - ndx);
11 | nfiles++
12 | }
13 | files[nfiles] = FILEID;
14 | }
15 |
16 | /^\[/{
17 | if (printme == 1) {
18 | printf("%s\n", rec);
19 | printme = 0
20 | }
21 | rec = "";
22 |
23 | rec = $0
24 | }
25 | /^ /{
26 | if (length(rec) + length($0) < 2040)
27 | rec = sprintf("%s\n%s", rec, $0);
28 | }
29 | /fileid/{
30 | for (i = 0; i <= nfiles; i++)
31 | if ($2 == files[i])
32 | printme = 1
33 | }
34 |
35 | END {
36 | if (printme == 1)
37 | printf("%s\n", rec);
38 | }
39 |
--------------------------------------------------------------------------------
/util/db_printlog/logstat.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Output accumulated log record count/size statistics.
4 | BEGIN {
5 | l_file = 0;
6 | l_offset = 0;
7 | }
8 |
9 | /^\[/{
10 | gsub("[][: ]", " ", $1)
11 | split($1, a)
12 |
13 | if (a[1] == l_file) {
14 | l[a[3]] += a[2] - l_offset
15 | ++n[a[3]]
16 | } else
17 | ++s[a[3]]
18 |
19 | l_file = a[1]
20 | l_offset = a[2]
21 | }
22 |
23 | END {
24 | # We can't figure out the size of the first record in each log file,
25 | # use the average for other records we found as an estimate.
26 | for (i in s)
27 | if (s[i] != 0 && n[i] != 0) {
28 | l[i] += s[i] * (l[i]/n[i])
29 | n[i] += s[i]
30 | delete s[i]
31 | }
32 | for (i in l)
33 | printf "%s: %d (n: %d, avg: %.2f)\n", i, l[i], n[i], l[i]/n[i]
34 | for (i in s)
35 | printf "%s: unknown (n: %d, unknown)\n", i, s[i]
36 | }
37 |
--------------------------------------------------------------------------------
/util/db_printlog/pgno.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Take a comma-separated list of page numbers and spit out all the
4 | # log records that affect those page numbers.
5 |
6 | BEGIN {
7 | INDX = -1
8 | }
9 | NR == 1 {
10 | npages = 0
11 | while ((ndx = index(PGNO, ",")) != 0) {
12 | pgno[npages] = substr(PGNO, 1, ndx - 1);
13 | PGNO = substr(PGNO, ndx + 1, length(PGNO) - ndx);
14 | npages++
15 | }
16 | pgno[npages] = PGNO;
17 | }
18 |
19 | /^\[/{
20 | if (printme == 1) {
21 | printf("%s\n", rec);
22 | printme = 0
23 | }
24 | rec = "";
25 |
26 | rec = $0
27 | }
28 | /^ /{
29 | if (length(rec) + length($0) < 2040)
30 | rec = sprintf("%s\n%s", rec, $0);
31 | }
32 | /pgno/{
33 | for (i = 0; i <= npages; i++)
34 | if ($2 == pgno[i])
35 | printme = 1
36 | }
37 | /right/{
38 | for (i = 0; i <= npages; i++)
39 | if ($2 == pgno[i])
40 | printme = 1
41 | }
42 | /left/{
43 | for (i = 0; i <= npages; i++)
44 | if ($2 == pgno[i])
45 | printme = 1
46 | }
47 | /indx/{
48 | if (printme == 1 && INDX != -1)
49 | if(INDX != $2)
50 | printme = 0;
51 | }
52 |
53 | END {
54 | if (printme == 1)
55 | printf("%s\n", rec);
56 | }
57 |
--------------------------------------------------------------------------------
/util/db_printlog/range.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Print out a range of the log
4 |
5 | /^\[/{
6 | l = length($1) - 1;
7 | i = index($1, "]");
8 | file = substr($1, 2, i - 2);
9 | file += 0;
10 | start = i + 2;
11 | offset = substr($1, start, l - start + 1);
12 | i = index(offset, "]");
13 | offset = substr($1, start, i - 1);
14 | offset += 0;
15 |
16 | if ((file == START_FILE && offset >= START_OFFSET || file > START_FILE)\
17 | && (file < END_FILE || (file == END_FILE && offset < END_OFFSET)))
18 | printme = 1
19 | else if (file == END_FILE && offset > END_OFFSET || file > END_FILE)
20 | exit
21 | else
22 | printme = 0
23 | }
24 | {
25 | if (printme == 1)
26 | print $0
27 | }
28 |
--------------------------------------------------------------------------------
/util/db_printlog/rectype.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Print out a range of the log.
4 | # Command line should set RECTYPE to a comma separated list
5 | # of the rectypes (or partial strings of rectypes) sought.
6 | NR == 1 {
7 | ntypes = 0
8 | while ((ndx = index(RECTYPE, ",")) != 0) {
9 | types[ntypes] = substr(RECTYPE, 1, ndx - 1);
10 | RECTYPE = substr(RECTYPE, ndx + 1, length(RECTYPE) - ndx);
11 | ntypes++
12 | }
13 | types[ntypes] = RECTYPE;
14 | }
15 |
16 | /^\[/{
17 | printme = 0
18 | for (i = 0; i <= ntypes; i++)
19 | if (index($1, types[i]) != 0) {
20 | printme = 1
21 | break;
22 | }
23 | }
24 | {
25 | if (printme == 1)
26 | print $0
27 | }
28 |
--------------------------------------------------------------------------------
/util/db_printlog/status.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Read through db_printlog output and list all the transactions encountered
4 | # and whether they committed or aborted.
5 | #
6 | # 1 = started
7 | # 2 = committed
8 | # 3 = explicitly aborted
9 | # 4 = other
10 | BEGIN {
11 | cur_txn = 0
12 | }
13 | /^\[.*]\[/{
14 | in_regop = 0
15 | if (status[$5] == 0) {
16 | status[$5] = 1;
17 | txns[cur_txn] = $5;
18 | cur_txn++;
19 | }
20 | }
21 | / child:/ {
22 | txnid = substr($2, 3);
23 | status[txnid] = 2;
24 | }
25 | /txn_regop/ {
26 | txnid = $5
27 | in_regop = 1
28 | }
29 | /opcode:/ {
30 | if (in_regop == 1) {
31 | if ($2 == 1)
32 | status[txnid] = 2
33 | else if ($2 == 3)
34 | status[txnid] = 3
35 | else
36 | status[txnid] = 4
37 | }
38 | }
39 | END {
40 | for (i = 0; i < cur_txn; i++) {
41 | if (status[txns[i]] == 1)
42 | printf("%s\tABORT\n", txns[i]);
43 | else if (status[txns[i]] == 2)
44 | printf("%s\tCOMMIT\n", txns[i]);
45 | else if (status[txns[i]] == 3)
46 | printf("%s\tABORT\n", txns[i]);
47 | else if (status[txns[i]] == 4)
48 | printf("%s\tOTHER\n", txns[i]);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/util/db_printlog/txn.awk:
--------------------------------------------------------------------------------
1 | # $Id$
2 | #
3 | # Print out all the records for a comma-separated list of transaction ids.
4 | NR == 1 {
5 | ntxns = 0
6 | while ((ndx = index(TXN, ",")) != 0) {
7 | txn[ntxns] = substr(TXN, 1, ndx - 1);
8 | TXN = substr(TXN, ndx + 1, length(TXN) - ndx);
9 | ntxns++
10 | }
11 | txn[ntxns] = TXN;
12 | }
13 |
14 | /^\[/{
15 | if (printme == 1) {
16 | printf("%s\n", rec);
17 | printme = 0
18 | }
19 | rec = "";
20 |
21 | for (i = 0; i <= ntxns; i++)
22 | if (txn[i] == $5) {
23 | rec = $0
24 | printme = 1
25 | }
26 | }
27 | /^ /{
28 | if (length(rec) + length($0) < 2040)
29 | rec = sprintf("%s\n%s", rec, $0);
30 | }
31 |
32 | END {
33 | if (printme == 1)
34 | printf("%s\n", rec);
35 | }
36 |
--------------------------------------------------------------------------------
/util/dtrace/apicalls.d:
--------------------------------------------------------------------------------
1 | #!/usr/sbin/dtrace -qs
2 | /*
3 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | *
5 | * apicalls.d - Summarize DB API function calls
6 | *
7 | * This script graphs the count of the main API calls grouped by thread.
8 | *
9 | * The optional integer maxcount parameter directs the script to exit once
10 | * that many functions calls have been accumulated.
11 | *
12 | * usage: apicalls.d { -p | -c " [ 0 ? $1 : -1;
19 | functioncount = 0;
20 | printf("DB API call counts of process %d; interrupt to display summary\n", $target);
21 | }
22 |
23 | pid$target::db*_create:return,
24 | pid$target::__*_pp:return
25 | {
26 | @calls[tid, probefunc] = count();
27 | functioncount++;
28 | }
29 |
30 | pid$target::db*_create:return,
31 | pid$target::__*_pp:return
32 | /functioncount == maxcount/
33 | {
34 | exit(0);
35 | }
36 |
--------------------------------------------------------------------------------
/util/dtrace/apitimes.d:
--------------------------------------------------------------------------------
1 | #!/usr/sbin/dtrace -qs
2 | /*
3 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | *
5 | * apitimes.d - Summarize time spent in DB API functions
6 | *
7 | * This script graphs the time spent in the main API calls, grouped by thread.
8 | *
9 | * The optional integer maxcount parameter directs the script to exit after
10 | * that many functions have been accumulated.
11 | *
12 | * usage: apitimes.d { -p | -c " [ 0 ? $1 : -1;
22 | functioncount = 0;
23 | printf("DB API times of process %d grouped by function; ", $target);
24 | printf("interrupt to display summary\n");
25 | }
26 |
27 | pid$target::db*_create:entry,
28 | pid$target::__*_pp:entry
29 | {
30 | self->start = timestamp;
31 | }
32 |
33 | pid$target::db*_create:return,
34 | pid$target::__*_pp:return
35 | /self->start != 0/
36 | {
37 | @calltimes[tid, probefunc] = quantize(timestamp - self->start);
38 | self->start = 0;
39 | functioncount++;
40 | }
41 |
42 | pid$target::db*_create:return,
43 | pid$target::__*_pp:return
44 | /functioncount == maxcount/
45 | {
46 | exit(0);
47 | }
48 |
49 | dtrace:::END
50 | {
51 | printf("\n");
52 | printa("Times that thread %x spent in %s in nanoseconds %@a", @calltimes);
53 | }
54 |
--------------------------------------------------------------------------------
/util/systemtap/apicalls.stp:
--------------------------------------------------------------------------------
1 | #!/usr/bin/stap
2 | /*
3 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | *
5 | * apicalls - Summarize DB API call count grouped by thread.
6 | *
7 | * This summarizes the count of DB apicalls grouped by thread or process.
8 | *
9 | * The path to the DB library is required to be the first argument.
10 | *
11 | * To limit tracing to a particular process use one of the stap options:
12 | * -x or
13 | * -c " [..]"
14 | *
15 | */
16 |
17 | global calls
18 |
19 | probe begin
20 | {
21 | printf("DB API call counts of ");
22 | if (target() == 0)
23 | printf("processes using \"%s\"", @1)
24 | else
25 | printf("process %d", target());
26 | printf("; interrupt to display summary\n")
27 | }
28 |
29 | probe process(@1).function("db_*create").call,
30 | process(@1).function("__*pp").call
31 | {
32 | calls[(target() == 0 ? pid() : tid()), probefunc()] <<< 1;
33 | }
34 |
35 | probe end
36 | {
37 | any_seen = 0;
38 | /* Display counts grouped by process, or by thread. */
39 | if (target() == 0)
40 | printf("%-20s %7s %9s\n",
41 | "Function", "process", "callcount")
42 | else
43 | printf("%-20s %7s %9s for process %d\n",
44 | "Function", "thread", "callcount", target());
45 | foreach ([a,b] in calls+) {
46 | printf("%-20s %7d %9d\n", b, a, @count(calls[a,b]));
47 | any_seen = 1;
48 | }
49 | if (!any_seen)
50 | printf("No probes were triggered in %s; it might not be the correct library\n", @1);
51 | }
52 |
--------------------------------------------------------------------------------
/util/systemtap/apitimes.stp:
--------------------------------------------------------------------------------
1 | #!/usr/bin/stap
2 | /*
3 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | *
5 | * apitimes - Graph the time spent in DB API calls grouped by thread or processid
6 | *
7 | * The path to the DB library is required to be the first argument.
8 | *
9 | * To limit tracing to a particular process use one of the stap options:
10 | * -x or
11 | * -c " [..]"
12 | *
13 | */
14 |
15 | global functioncount, maxcount, starts, times;
16 |
17 | probe begin
18 | {
19 | functioncount = 0;
20 | maxcount = -1;
21 | %( $# >= 2 %? maxcount = $2 %)
22 | printf("DB API times of ");
23 | if (target() == 0)
24 | printf("processes using \"%s\"", @1)
25 | else
26 | printf("process %d", target());
27 | printf(" grouped by function; interrupt to display summary\n");
28 | }
29 |
30 | probe process(@1).function("db*_create").call,
31 | process(@1).function("__*_pp").call
32 | {
33 | starts[tid(), probefunc()] = gettimeofday_ns();
34 | }
35 |
36 |
37 | probe process(@1).function("db*_create").return,
38 | process(@1).function("__*_pp").return
39 | {
40 | if ((start = starts[tid(), probefunc()]) != 0) {
41 | times[tid(), probefunc()] <<< gettimeofday_ns() - start;
42 | if (++functioncount == maxcount)
43 | exit();
44 | }
45 | }
46 |
47 | probe end
48 | {
49 | foreach ([tid, func] in times) {
50 | printf("Times that thread %x spent in %s in nanoseconds\n",
51 | tid, func);
52 | print(@hist_log(times[tid, func]));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/util/systemtap/apitrace.stp:
--------------------------------------------------------------------------------
1 | #!/usr/bin/stap
2 | /*
3 | * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
4 | *
5 | * apitrace - Display DB API calls and return values
6 | *
7 | * The path to the DB library is required to be the first argument.
8 | *
9 | * To limit tracing to a particular process use one of the stap options:
10 | * -x or
11 | * -c " [..]"
12 | *
13 | */
14 |
15 | global tracecount, maxlimit;
16 |
17 | probe begin
18 | {
19 | printf("DB API call trace of ");
20 | if (target() == 0)
21 | printf("processes using \"%s\"\n", @1);
22 | else
23 | printf("process %d\n", target());
24 | printf("Interrupt to display summary\n");
25 | maxlimit = -1;
26 | %( $# >= 2 %? maxlimit = $2 %)
27 | tracecount = 0;
28 | }
29 |
30 | probe process(@1).function("db_*create").call,
31 | process(@1).function("__*_*pp").call
32 | {
33 | printf("%s -> %s called with (%s)\n",
34 | thread_indent(1), probefunc(), $$parms);
35 |
36 | }
37 |
38 | probe process(@1).function("db*_create").return,
39 | process(@1).function("__*_*pp").return
40 | {
41 | printf("%s <- %s returns %d\n", thread_indent(-1),
42 | probefunc(), $return)
43 | if (++tracecount == maxlimit)
44 | exit();
45 | }
46 |
--------------------------------------------------------------------------------