⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db_method.c

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 C
📖 第 1 页 / 共 2 页
字号:
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 1999-2002 *	Sleepycat Software.  All rights reserved. */#include "db_config.h"#ifndef lintstatic const char revid[] = "$Id: db_method.c,v 11.78 2002/07/02 19:26:55 sue Exp $";#endif /* not lint */#ifndef NO_SYSTEM_INCLUDES#include <sys/types.h>#ifdef HAVE_RPC#include <rpc/rpc.h>#endif#include <string.h>#endif#include "db_int.h"#include "dbinc/crypto.h"#include "dbinc/db_page.h"#include "dbinc/db_shash.h"#include "dbinc/btree.h"#include "dbinc/hash.h"#include "dbinc/qam.h"#include "dbinc/xa.h"#include "dbinc_auto/xa_ext.h"#include "dbinc/db_shash.h"#include "dbinc/lock.h"#ifdef HAVE_RPC#include "dbinc_auto/db_server.h"#include "dbinc_auto/rpc_client_ext.h"#endifstatic int  __db_get_byteswapped __P((DB *, int *));static int  __db_get_type __P((DB *, DBTYPE *dbtype));static int  __db_init __P((DB *, u_int32_t));static int  __db_key_range		__P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));static int  __db_set_alloc __P((DB *, void *(*)(size_t),		void *(*)(void *, size_t), void (*)(void *)));static int  __db_set_append_recno __P((DB *, int (*)(DB *, DBT *, db_recno_t)));static int  __db_set_cachesize __P((DB *, u_int32_t, u_int32_t, int));static int  __db_set_cache_priority __P((DB *, DB_CACHE_PRIORITY));static int  __db_set_dup_compare		__P((DB *, int (*)(DB *, const DBT *, const DBT *)));static int  __db_set_encrypt __P((DB *, const char *, u_int32_t));static int  __db_set_feedback __P((DB *, void (*)(DB *, int, int)));static int  __db_set_flags __P((DB *, u_int32_t));static int  __db_set_pagesize __P((DB *, u_int32_t));static int  __db_set_paniccall __P((DB *, void (*)(DB_ENV *, int)));static void __db_set_errcall __P((DB *, void (*)(const char *, char *)));static void __db_set_errfile __P((DB *, FILE *));static void __db_set_errpfx __P((DB *, const char *));static int  __db_stat_fail __P((DB *, void *, u_int32_t));static void __dbh_err __P((DB *, int, const char *, ...));static void __dbh_errx __P((DB *, const char *, ...));#ifdef HAVE_RPCstatic int  __dbcl_init __P((DB *, DB_ENV *, u_int32_t));#endif/* * db_create -- *	DB constructor. * * EXTERN: int db_create __P((DB **, DB_ENV *, u_int32_t)); */intdb_create(dbpp, dbenv, flags)	DB **dbpp;	DB_ENV *dbenv;	u_int32_t flags;{	DB *dbp;	int ret;	/* Check for invalid function flags. */	switch (flags) {	case 0:		break;	case DB_XA_CREATE:		if (dbenv != NULL) {			__db_err(dbenv,		"XA applications may not specify an environment to db_create");			return (EINVAL);		}		/*		 * If it's an XA database, open it within the XA environment,		 * taken from the global list of environments.  (When the XA		 * transaction manager called our xa_start() routine the		 * "current" environment was moved to the start of the list.		 */		dbenv = TAILQ_FIRST(&DB_GLOBAL(db_envq));		break;	default:		return (__db_ferr(dbenv, "db_create", 0));	}	/* Allocate the DB. */	if ((ret = __os_calloc(dbenv, 1, sizeof(*dbp), &dbp)) != 0)		return (ret);#ifdef HAVE_RPC	if (dbenv != NULL && RPC_ON(dbenv))		ret = __dbcl_init(dbp, dbenv, flags);	else#endif		ret = __db_init(dbp, flags);	if (ret != 0) {		__os_free(dbenv, dbp);		return (ret);	}	/* If we don't have an environment yet, allocate a local one. */	if (dbenv == NULL) {		if ((ret = db_env_create(&dbenv, 0)) != 0) {			__os_free(dbenv, dbp);			return (ret);		}		F_SET(dbenv, DB_ENV_DBLOCAL);	}	++dbenv->db_ref;	dbp->dbenv = dbenv;	*dbpp = dbp;	return (0);}/* * __db_init -- *	Initialize a DB structure. */static int__db_init(dbp, flags)	DB *dbp;	u_int32_t flags;{	int ret;	dbp->lid = DB_LOCK_INVALIDID;	LOCK_INIT(dbp->handle_lock);	TAILQ_INIT(&dbp->free_queue);	TAILQ_INIT(&dbp->active_queue);	TAILQ_INIT(&dbp->join_queue);	LIST_INIT(&dbp->s_secondaries);	FLD_SET(dbp->am_ok,	    DB_OK_BTREE | DB_OK_HASH | DB_OK_QUEUE | DB_OK_RECNO);	dbp->associate = __db_associate;	dbp->close = __db_close;	dbp->cursor = __db_cursor;	dbp->del = __db_delete;	dbp->err = __dbh_err;	dbp->errx = __dbh_errx;	dbp->fd = __db_fd;	dbp->get = __db_get;	dbp->get_byteswapped = __db_get_byteswapped;	dbp->get_type = __db_get_type;	dbp->join = __db_join;	dbp->key_range = __db_key_range;	dbp->open = __db_open;	dbp->pget = __db_pget;	dbp->put = __db_put;	dbp->remove = __db_remove;	dbp->rename = __db_rename;	dbp->truncate = __db_truncate;	dbp->set_alloc = __db_set_alloc;	dbp->set_append_recno = __db_set_append_recno;	dbp->set_cachesize = __db_set_cachesize;	dbp->set_cache_priority = __db_set_cache_priority;	dbp->set_dup_compare = __db_set_dup_compare;	dbp->set_encrypt = __db_set_encrypt;	dbp->set_errcall = __db_set_errcall;	dbp->set_errfile = __db_set_errfile;	dbp->set_errpfx = __db_set_errpfx;	dbp->set_feedback = __db_set_feedback;	dbp->set_flags = __db_set_flags;	dbp->set_lorder = __db_set_lorder;	dbp->set_pagesize = __db_set_pagesize;	dbp->set_paniccall = __db_set_paniccall;	dbp->stat = __db_stat_fail;	dbp->sync = __db_sync;	dbp->upgrade = __db_upgrade;	dbp->verify = __db_verify;					/* Access method specific. */	if ((ret = __bam_db_create(dbp)) != 0)		return (ret);	if ((ret = __ham_db_create(dbp)) != 0)		return (ret);	if ((ret = __qam_db_create(dbp)) != 0)		return (ret);	/*	 * XA specific: must be last, as we replace methods set by the	 * access methods.	 */	if (LF_ISSET(DB_XA_CREATE) && (ret = __db_xa_create(dbp)) != 0)		return (ret);	return (0);}/* * __dbh_am_chk -- *	Error if an unreasonable method is called. * * PUBLIC: int __dbh_am_chk __P((DB *, u_int32_t)); */int__dbh_am_chk(dbp, flags)	DB *dbp;	u_int32_t flags;{	/*	 * We start out allowing any access methods to be called, and as the	 * application calls the methods the options become restricted.  The	 * idea is to quit as soon as an illegal method combination is called.	 */	if ((LF_ISSET(DB_OK_BTREE) && FLD_ISSET(dbp->am_ok, DB_OK_BTREE)) ||	    (LF_ISSET(DB_OK_HASH) && FLD_ISSET(dbp->am_ok, DB_OK_HASH)) ||	    (LF_ISSET(DB_OK_QUEUE) && FLD_ISSET(dbp->am_ok, DB_OK_QUEUE)) ||	    (LF_ISSET(DB_OK_RECNO) && FLD_ISSET(dbp->am_ok, DB_OK_RECNO))) {		FLD_CLR(dbp->am_ok, ~flags);		return (0);	}	__db_err(dbp->dbenv,    "call implies an access method which is inconsistent with previous calls");	return (EINVAL);}/* * __dbh_err -- *	Error message, including the standard error string. */static void#ifdef __STDC____dbh_err(DB *dbp, int error, const char *fmt, ...)#else__dbh_err(dbp, error, fmt, va_alist)	DB *dbp;	int error;	const char *fmt;	va_dcl#endif{	DB_REAL_ERR(dbp->dbenv, error, 1, 1, fmt);}/* * __dbh_errx -- *	Error message. */static void#ifdef __STDC____dbh_errx(DB *dbp, const char *fmt, ...)#else__dbh_errx(dbp, fmt, va_alist)	DB *dbp;	const char *fmt;	va_dcl#endif{	DB_REAL_ERR(dbp->dbenv, 0, 0, 1, fmt);}/* * __db_get_byteswapped -- *	Return if database requires byte swapping. */static int__db_get_byteswapped(dbp, isswapped)	DB *dbp;	int *isswapped;{	DB_ILLEGAL_BEFORE_OPEN(dbp, "get_byteswapped");	*isswapped = F_ISSET(dbp, DB_AM_SWAP) ? 1 : 0;	return (0);}/* * __db_get_type -- *	Return type of underlying database. */static int__db_get_type(dbp, dbtype)	DB *dbp;	DBTYPE *dbtype;{	DB_ILLEGAL_BEFORE_OPEN(dbp, "get_type");	*dbtype = dbp->type;	return (0);}/* * __db_key_range -- *	Return proportion of keys above and below given key. */static int__db_key_range(dbp, txn, key, kr, flags)	DB *dbp;	DB_TXN *txn;	DBT *key;	DB_KEY_RANGE *kr;	u_int32_t flags;{	COMPQUIET(txn, NULL);	COMPQUIET(key, NULL);	COMPQUIET(kr, NULL);	COMPQUIET(flags, 0);	DB_ILLEGAL_BEFORE_OPEN(dbp, "key_range");	DB_ILLEGAL_METHOD(dbp, DB_OK_BTREE);	return (EINVAL);}/* * __db_set_append_recno -- *	Set record number append routine. */static int__db_set_append_recno(dbp, func)	DB *dbp;	int (*func) __P((DB *, DBT *, db_recno_t));{	DB_ILLEGAL_AFTER_OPEN(dbp, "set_append_recno");	DB_ILLEGAL_METHOD(dbp, DB_OK_QUEUE | DB_OK_RECNO);	dbp->db_append_recno = func;	return (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -