SequoiaDB
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Typedefs | Enumerations | Functions
client.h File Reference

C Client Driver. More...

#include "core.h"
#include "ossTypes.h"
#include "bson/bson.h"
#include "jstobs.h"
#include "spd.h"
#include "clientDef.h"

Go to the source code of this file.

Macros

#define SDB_PAGESIZE_4K   4096
 
#define SDB_PAGESIZE_8K   8192
 
#define SDB_PAGESIZE_16K   16384
 
#define SDB_PAGESIZE_32K   32768
 
#define SDB_PAGESIZE_64K   65536
 
#define SDB_PAGESIZE_DEFAULT   0
 
#define FLG_INSERT_CONTONDUP   0x00000001
 
#define FLG_INSERT_RETURN_OID   0x00000002
 
#define FLG_INSERT_REPLACEONDUP   0x00000004
 
#define SDB_INVALID_HANDLE   ((ossValuePtr) 0)
 
#define sdbCreateReplicaNode   sdbCreateNode
 
#define sdbRemoveReplicaNode   sdbRemoveNode
 
#define sdbGetReplicaNodeMaster   sdbGetNodeMaster
 
#define sdbGetReplicaNodeSlave   sdbGetNodeSlave
 
#define sdbGetReplicaNodeByName   sdbGetNodeByName
 
#define sdbGetReplicaNodeByHost   sdbGetNodeByHost
 
#define sdbGetReplicaNodeSddr   sdbGetNodeAddr
 
#define sdbStartReplicaNode   sdbStartNode
 
#define sdbStopReplicaNode   sdbStopNode
 
#define sdbReleaseReplicaNode   sdbReleaseNode
 
#define QUERY_FORCE_HINT   0x00000080
 
#define QUERY_PARALLED   0x00000100
 
#define QUERY_WITH_RETURNDATA   0x00000200
 

Typedefs

typedef enum _SDB_LOB_OPEN_MODE SDB_LOB_OPEN_MODE
 
typedef enum _SDB_LOB_SEEK SDB_LOB_SEEK
 
typedef ossValuePtr sdbConnectionHandle
 
typedef ossValuePtr sdbCSHandle
 
typedef ossValuePtr sdbCollectionHandle
 
typedef ossValuePtr sdbCursorHandle
 
typedef ossValuePtr sdbReplicaGroupHandle
 
typedef ossValuePtr sdbNodeHandle
 
typedef ossValuePtr sdbDomainHandle
 
typedef ossValuePtr sdbLobHandle
 
typedef ossValuePtr sdbDCHandle
 
typedef void(* ERROR_ON_REPLY_FUNC )(const CHAR *pErrorObj, UINT32 objSize, INT32 flag, const CHAR *pDescription, const CHAR *pDetail)
 
typedef sdbNodeHandle sdbReplicaNodeHandle
 

Enumerations

enum  _SDB_LOB_OPEN_MODE { SDB_LOB_CREATEONLY = 0x00000001, SDB_LOB_READ = 0x00000004 }
 
enum  _SDB_LOB_SEEK { SDB_LOB_SEEK_SET = 0, SDB_LOB_SEEK_CUR, SDB_LOB_SEEK_END }
 

Functions

SDB_EXPORT void sdbSetErrorOnReplyCallback (ERROR_ON_REPLY_FUNC func)
 Set the callback function when reply message if error from server.
 
SDB_EXPORT INT32 initClient (sdbClientConf *config)
 set client global configuration such as cache strategy to improve performance
 
SDB_EXPORT INT32 sdbConnect (const CHAR *pHostName, const CHAR *pServiceName, const CHAR *pUsrName, const CHAR *pPasswd, sdbConnectionHandle *handle)
 Connect to database.
 
SDB_EXPORT INT32 sdbConnect1 (const CHAR **pConnAddrs, INT32 arrSize, const CHAR *pUsrName, const CHAR *pPasswd, sdbConnectionHandle *handle)
 Connect to database used a random valid address in the array.
 
SDB_EXPORT INT32 sdbSecureConnect (const CHAR *pHostName, const CHAR *pServiceName, const CHAR *pUsrName, const CHAR *pPasswd, sdbConnectionHandle *handle)
 Connect to database with SSL.
 
SDB_EXPORT INT32 sdbSecureConnect1 (const CHAR **pConnAddrs, INT32 arrSize, const CHAR *pUsrName, const CHAR *pPasswd, sdbConnectionHandle *handle)
 Connect to database used a random valid address in the array, with SSL.
 
SDB_EXPORT void sdbDisconnect (sdbConnectionHandle handle)
 Disconnect to database.
 
SDB_EXPORT INT32 sdbGetLastErrorObj (bson *obj)
 Get the error object info for the last operation in the thread.
 
SDB_EXPORT void sdbCleanLastErrorObj ()
 Clean the last error object info in the thread.
 
SDB_EXPORT INT32 sdbCreateUsr (sdbConnectionHandle cHandle, const CHAR *pUsrName, const CHAR *pPasswd)
 Create an account.
 
SDB_EXPORT INT32 sdbCreateUsr2 (sdbConnectionHandle cHandle, const CHAR *pUsrName, const CHAR *pPasswd, bson *options)
 Create an account.
 
SDB_EXPORT INT32 sdbRemoveUsr (sdbConnectionHandle cHandle, const CHAR *pUsrName, const CHAR *pPasswd)
 Delete an account.
 
SDB_EXPORT INT32 sdbGetDataBlocks (sdbCollectionHandle cHandle, bson *condition, bson *select, bson *orderBy, bson *hint, INT64 numToSkip, INT64 numToReturn, sdbCursorHandle *handle)
 Get the data blocks' infomation for concurrent query.
 
SDB_EXPORT INT32 sdbGetQueryMeta (sdbCollectionHandle cHandle, bson *condition, bson *orderBy, bson *hint, INT64 numToSkip, INT64 numToReturn, sdbCursorHandle *handle)
 Get the index blocks' or data blocks' infomations for concurrent query.
 
SDB_EXPORT INT32 sdbGetSnapshot (sdbConnectionHandle cHandle, INT32 snapType, bson *condition, bson *selector, bson *orderBy, sdbCursorHandle *handle)
 Get the snapshot.
 
SDB_EXPORT INT32 sdbGetSnapshot1 (sdbConnectionHandle cHandle, INT32 snapType, bson *condition, bson *selector, bson *orderBy, bson *hint, INT64 numToSkip, INT64 numToReturn, sdbCursorHandle *handle)
 Get the snapshot.
 
SDB_EXPORT INT32 sdbResetSnapshot (sdbConnectionHandle cHandle, bson *condition)
 Reset the snapshot.
 
SDB_EXPORT INT32 sdbTraceStart (sdbConnectionHandle cHandle, UINT32 traceBufferSize, CHAR *component, CHAR *breakPoint)
 Start trace with given trace buffer size and component list.
 
SDB_EXPORT INT32 sdbTraceResume (sdbConnectionHandle cHandle)
 Resume trace.
 
SDB_EXPORT INT32 sdbTraceStop (sdbConnectionHandle cHandle, const CHAR *pDumpFileName)
 Stop trace and dump into file.
 
SDB_EXPORT INT32 sdbTraceStatus (sdbConnectionHandle cHandle, sdbCursorHandle *handle)
 Get the current status for trace.
 
SDB_EXPORT INT32 sdbGetList (sdbConnectionHandle cHandle, INT32 listType, bson *condition, bson *selector, bson *orderBy, sdbCursorHandle *handle)
 Get the specified list.
 
SDB_EXPORT INT32 sdbGetList1 (sdbConnectionHandle cHandle, INT32 listType, bson *condition, bson *selector, bson *orderBy, bson *hint, SINT64 numToSkip, SINT64 numToReturn, sdbCursorHandle *handle)
 Get the specified list.
 
SDB_EXPORT INT32 sdbGetCollection (sdbConnectionHandle cHandle, const CHAR *pCollectionFullName, sdbCollectionHandle *handle)
 Get the specified collection.
 
SDB_EXPORT INT32 sdbGetCollectionSpace (sdbConnectionHandle cHandle, const CHAR *pCollectionSpaceName, sdbCSHandle *handle)
 Get the specified collection space.
 
SDB_EXPORT INT32 sdbGetReplicaGroup (sdbConnectionHandle cHandle, const CHAR *pRGName, sdbReplicaGroupHandle *handle)
 Get the specified replica group.
 
SDB_EXPORT INT32 sdbGetReplicaGroup1 (sdbConnectionHandle cHandle, UINT32 id, sdbReplicaGroupHandle *handle)
 Get the specified replica group.
 
SDB_EXPORT INT32 sdbGetReplicaGroupName (sdbReplicaGroupHandle cHandle, CHAR **ppRGName)
 Get the specified replica group's name.
 
SDB_EXPORT INT32 sdbGetRGName (sdbReplicaGroupHandle cHandle, CHAR *pBuffer, INT32 size)
 Get the specified replica group's name.
 
SDB_EXPORT BOOLEAN sdbIsReplicaGroupCatalog (sdbReplicaGroupHandle cHandle)
 Test whether the specified replica group is catalog.
 
SDB_EXPORT INT32 sdbCreateCollectionSpace (sdbConnectionHandle cHandle, const CHAR *pCollectionSpaceName, INT32 iPageSize, sdbCSHandle *handle)
 Create the specified collection space.
 
SDB_EXPORT INT32 sdbCreateCollectionSpaceV2 (sdbConnectionHandle cHandle, const CHAR *pCollectionSpaceName, bson *options, sdbCSHandle *handle)
 Create the specified collection space.
 
SDB_EXPORT INT32 sdbDropCollectionSpace (sdbConnectionHandle cHandle, const CHAR *pCollectionSpaceName)
 Drop the specified collection space.
 
SDB_EXPORT INT32 sdbCreateReplicaGroup (sdbConnectionHandle cHandle, const CHAR *pRGName, sdbReplicaGroupHandle *handle)
 Create the specified replica group.
 
SDB_EXPORT INT32 sdbRemoveReplicaGroup (sdbConnectionHandle cHandle, const CHAR *pRGName)
 Remove the specified replica group.
 
SDB_EXPORT INT32 sdbStartReplicaGroup (sdbReplicaGroupHandle cHandle)
 Start and activate the specified replica group.
 
SDB_EXPORT INT32 sdbGetNodeMaster (sdbReplicaGroupHandle cHandle, sdbNodeHandle *handle)
 Get the master node of the specified replica group.
 
SDB_EXPORT INT32 sdbGetNodeSlave (sdbReplicaGroupHandle cHandle, sdbNodeHandle *handle)
 Get one of slave node of the specified replica group, if no slave exists then get master.
 
SDB_EXPORT INT32 sdbGetNodeByName (sdbReplicaGroupHandle cHandle, const CHAR *pNodeName, sdbNodeHandle *handle)
 Get the node from the specified replica group.
 
SDB_EXPORT INT32 sdbGetNodeByHost (sdbReplicaGroupHandle cHandle, const CHAR *pHostName, const CHAR *pServiceName, sdbNodeHandle *handle)
 Get the node from the specified replica group.
 
SDB_EXPORT INT32 sdbGetNodeAddr (sdbNodeHandle cHandle, const CHAR **ppHostName, const CHAR **ppServiceName, const CHAR **ppNodeName, INT32 *pNodeID)
 Get the host and service name for the specified node.
 
SDB_EXPORT INT32 sdbStartNode (sdbNodeHandle cHandle)
 Start up the specified node.
 
SDB_EXPORT INT32 sdbStopNode (sdbNodeHandle cHandle)
 Stop the specified node.
 
SDB_EXPORT INT32 sdbStopReplicaGroup (sdbReplicaGroupHandle cHandle)
 Stop the specified replica group.
 
SDB_EXPORT INT32 sdbCreateReplicaCataGroup (sdbConnectionHandle cHandle, const CHAR *pHostName, const CHAR *pServiceName, const CHAR *pDatabasePath, bson *configure)
 Create a catalog replica group.
 
SDB_EXPORT INT32 sdbCreateNode (sdbReplicaGroupHandle cHandle, const CHAR *pHostName, const CHAR *pServiceName, const CHAR *pDatabasePath, bson *configure)
 Create node in a given replica group.
 
SDB_EXPORT INT32 sdbRemoveNode (sdbReplicaGroupHandle cHandle, const CHAR *pHostName, const CHAR *pServiceName, bson *configure)
 remove node in a given replica group
 
SDB_EXPORT INT32 sdbListCollectionSpaces (sdbConnectionHandle cHandle, sdbCursorHandle *handle)
 List all collection space of current database(include temporary collection space)
 
SDB_EXPORT INT32 sdbListCollections (sdbConnectionHandle cHandle, sdbCursorHandle *handle)
 List all collection of current database(not include temporary collection of temporary collection space)
 
SDB_EXPORT INT32 sdbListReplicaGroups (sdbConnectionHandle cHandle, sdbCursorHandle *handle)
 List all the replica groups of current database.
 
SDB_EXPORT INT32 sdbFlushConfigure (sdbConnectionHandle cHandle, bson *options)
 flush the options to configure file.
 
SDB_EXPORT INT32 sdbCrtJSProcedure (sdbConnectionHandle cHandle, const CHAR *code)
 create a store procedure.
 
SDB_EXPORT INT32 sdbRmProcedure (sdbConnectionHandle cHandle, const CHAR *spName)
 remove a store procedure.
 
SDB_EXPORT INT32 sdbListProcedures (sdbConnectionHandle cHandle, bson *condition, sdbCursorHandle *handle)
 List store procedures.
 
SDB_EXPORT INT32 sdbEvalJS (sdbConnectionHandle cHandle, const CHAR *code, SDB_SPD_RES_TYPE *type, sdbCursorHandle *handle, bson *errmsg)
 Eval a func. \ type is declared in spd.h. see SDB_FMP_RES_TYPE.
 
SDB_EXPORT INT32 sdbGetCollection1 (sdbCSHandle cHandle, const CHAR *pCollectionName, sdbCollectionHandle *handle)
 Get the specified collection of current collection space.
 
SDB_EXPORT INT32 sdbCreateCollection (sdbCSHandle cHandle, const CHAR *pCollectionName, sdbCollectionHandle *handle)
 Create the specified collection in current collection space This function creates a non-sharded collection with default replsize.
 
SDB_EXPORT INT32 sdbCreateCollection1 (sdbCSHandle cHandle, const CHAR *pCollectionName, bson *options, sdbCollectionHandle *handle)
 Create the specified collection in current collection space.
 
SDB_EXPORT INT32 sdbAlterCollection (sdbCollectionHandle cHandle, bson *options)
 Alter the specified collection.
 
SDB_EXPORT INT32 sdbDropCollection (sdbCSHandle cHandle, const CHAR *pCollectionName)
 Drop the specified collection in current collection space.
 
SDB_EXPORT INT32 sdbGetCSName (sdbCSHandle cHandle, CHAR *pBuffer, INT32 size)
 Get the specified collection space name.
 
SDB_EXPORT INT32 sdbRenameCollection (sdbCSHandle cHandle, const CHAR *pOldName, const CHAR *pNewName, bson *options)
 Rename collection name.
 
SDB_EXPORT INT32 sdbGetCLName (sdbCollectionHandle cHandle, CHAR *pBuffer, INT32 size)
 Get the specified collection name.
 
SDB_EXPORT INT32 sdbGetCLFullName (sdbCollectionHandle cHandle, CHAR *pBuffer, INT32 size)
 Get the specified collection full name.
 
SDB_EXPORT INT32 sdbSplitCollection (sdbCollectionHandle cHandle, const CHAR *pSourceRG, const CHAR *pTargetRG, const bson *pSplitCondition, const bson *pSplitEndCondition)
 Split the specified collection from source replica group to target by range.
 
SDB_EXPORT INT32 sdbSplitCLAsync (sdbCollectionHandle cHandle, const CHAR *pSourceRG, const CHAR *pTargetRG, const bson *pSplitCondition, const bson *pSplitEndCondition, SINT64 *taskID)
 Split the specified collection from source replica group to target by range.
 
SDB_EXPORT INT32 sdbSplitCollectionByPercent (sdbCollectionHandle cHandle, const CHAR *pSourceRG, const CHAR *pTargetRG, FLOAT64 percent)
 Split the specified collection from source replica group to target by percent.
 
SDB_EXPORT INT32 sdbSplitCLByPercentAsync (sdbCollectionHandle cHandle, const CHAR *pSourceRG, const CHAR *pTargetRG, FLOAT64 percent, SINT64 *taskID)
 Split the specified collection from source replica group to target by percent.
 
SDB_EXPORT INT32 sdbCreateIndex (sdbCollectionHandle cHandle, bson *indexDef, const CHAR *pIndexName, BOOLEAN isUnique, BOOLEAN isEnforced)
 Create the index in current collection.
 
SDB_EXPORT INT32 sdbCreateIndex1 (sdbCollectionHandle cHandle, bson *indexDef, const CHAR *pIndexName, BOOLEAN isUnique, BOOLEAN isEnforced, INT32 sortBufferSize)
 Create the index in current collection.
 
SDB_EXPORT INT32 sdbGetIndexes (sdbCollectionHandle cHandle, const CHAR *pIndexName, sdbCursorHandle *handle)
 Get all of or one of the indexes in current collection.
 
SDB_EXPORT INT32 sdbDropIndex (sdbCollectionHandle cHandle, const CHAR *pIndexName)
 Drop the index in current collection.
 
SDB_EXPORT INT32 sdbGetCount (sdbCollectionHandle cHandle, bson *condition, SINT64 *count)
 Get the count of documents in specified collection.
 
SDB_EXPORT INT32 sdbGetCount1 (sdbCollectionHandle cHandle, bson *condition, bson *hint, SINT64 *count)
 Get the count of documents in specified collection.
 
SDB_EXPORT INT32 sdbInsert (sdbCollectionHandle cHandle, bson *obj)
 Insert a bson object into current collection.
 
SDB_EXPORT INT32 sdbInsert1 (sdbCollectionHandle cHandle, bson *obj, bson_iterator *id)
 Insert a bson object into current collection.
 
SDB_EXPORT INT32 sdbInsert2 (sdbCollectionHandle cHandle, bson *obj, INT32 flag, bson_iterator *id)
 Insert a bson object into current collection.
 
SDB_EXPORT INT32 sdbBulkInsert (sdbCollectionHandle cHandle, SINT32 flags, bson **obj, SINT32 num)
 Insert a bulk of bson objects into current collection.
 
SDB_EXPORT INT32 sdbUpdate (sdbCollectionHandle cHandle, bson *rule, bson *condition, bson *hint)
 Update the matching documents in current collection.
 
SDB_EXPORT INT32 sdbUpsert (sdbCollectionHandle cHandle, bson *rule, bson *condition, bson *hint)
 Update the matching documents in current collection, insert if no matching.
 
SDB_EXPORT INT32 sdbUpsert1 (sdbCollectionHandle cHandle, bson *rule, bson *condition, bson *hint, bson *setOnInsert)
 Update the matching documents in current collection, insert if no matching.
 
SDB_EXPORT INT32 sdbDelete (sdbCollectionHandle cHandle, bson *condition, bson *hint)
 Delete the matching documents in current collection, never rollback if failed.
 
SDB_EXPORT INT32 sdbQuery1 (sdbCollectionHandle cHandle, bson *condition, bson *select, bson *orderBy, bson *hint, INT64 numToSkip, INT64 numToReturn, INT32 flags, sdbCursorHandle *handle)
 Get the matching documents in current collection.
 
SDB_EXPORT INT32 sdbQuery (sdbCollectionHandle cHandle, bson *condition, bson *select, bson *orderBy, bson *hint, INT64 numToSkip, INT64 numToReturn, sdbCursorHandle *handle)
 Get the matching documents in current collection.
 
SDB_EXPORT INT32 sdbQueryAndUpdate (sdbCollectionHandle cHandle, bson *condition, bson *select, bson *orderBy, bson *hint, bson *update, INT64 numToSkip, INT64 numToReturn, INT32 flag, BOOLEAN returnNew, sdbCursorHandle *handle)
 Get the matching documents in current collection and update.
 
SDB_EXPORT INT32 sdbQueryAndRemove (sdbCollectionHandle cHandle, bson *condition, bson *select, bson *orderBy, bson *hint, INT64 numToSkip, INT64 numToReturn, INT32 flag, sdbCursorHandle *handle)
 Get the matching documents in current collection and remove.
 
SDB_EXPORT INT32 sdbExplain (sdbCollectionHandle cHandle, bson *condition, bson *select, bson *orderBy, bson *hint, INT32 flag, INT64 numToSkip, INT64 numToReturn, bson *options, sdbCursorHandle *handle)
 get access plan of query
 
SDB_EXPORT INT32 sdbNext (sdbCursorHandle cHandle, bson *obj)
 Return the next document of current cursor, and move forward.
 
SDB_EXPORT INT32 sdbCurrent (sdbCursorHandle cHandle, bson *obj)
 Return the current document of cursor, and don't move.
 
SDB_EXPORT INT32 sdbCloseCursor (sdbCursorHandle cHandle)
 Close the cursor's connection to database, we can't use this handle to get data again.
 
SDB_EXPORT INT32 sdbCloseAllCursors (sdbConnectionHandle cHandle)
 Send a "Interrpt" message to engine, as a result, all the cursors and lobs created by current connection will be closed.
 
SDB_EXPORT INT32 sdbExec (sdbConnectionHandle cHandle, const CHAR *sql, sdbCursorHandle *result)
 Executing SQL command.
 
SDB_EXPORT INT32 sdbExecUpdate (sdbConnectionHandle cHandle, const CHAR *sql)
 Executing SQL command for updating.
 
SDB_EXPORT INT32 sdbTransactionBegin (sdbConnectionHandle cHandle)
 Transaction begin.
 
SDB_EXPORT INT32 sdbTransactionCommit (sdbConnectionHandle cHandle)
 Transaction commit.
 
SDB_EXPORT INT32 sdbTransactionRollback (sdbConnectionHandle cHandle)
 Transaction rollback.
 
SDB_EXPORT void sdbReleaseConnection (sdbConnectionHandle cHandle)
 Release the database connection handle.
 
SDB_EXPORT void sdbReleaseCollection (sdbCollectionHandle cHandle)
 Release collection handle, the cursor handle of this collection will still available.
 
SDB_EXPORT void sdbReleaseCS (sdbCSHandle cHandle)
 Release the collection space handle, the collecion and cursor handle of this collection space will still available.
 
SDB_EXPORT void sdbReleaseCursor (sdbCursorHandle cHandle)
 Release the cursor handle.
 
SDB_EXPORT void sdbReleaseReplicaGroup (sdbReplicaGroupHandle cHandle)
 Release the replica group handle.
 
SDB_EXPORT void sdbReleaseNode (sdbNodeHandle cHandle)
 Release the node handle.
 
SDB_EXPORT void sdbReleaseDomain (sdbDomainHandle cHandle)
 Release the domain handle.
 
SDB_EXPORT void sdbReleaseDC (sdbDCHandle cHandle)
 
SDB_EXPORT INT32 sdbAggregate (sdbCollectionHandle cHandle, bson **obj, SINT32 num, sdbCursorHandle *handle)
 Execute aggregate operation in specified collection.
 
SDB_EXPORT INT32 sdbAttachCollection (sdbCollectionHandle cHandle, const CHAR *subClFullName, bson *options)
 Attach the specified collection.
 
SDB_EXPORT INT32 sdbDetachCollection (sdbCollectionHandle cHandle, const CHAR *subClFullName)
 Detach the specified collection.
 
SDB_EXPORT INT32 sdbBackupOffline (sdbConnectionHandle cHandle, bson *options)
 Backup the whole database or specifed replica group.
 
SDB_EXPORT INT32 sdbListBackup (sdbConnectionHandle cHandle, bson *options, bson *condition, bson *selector, bson *orderBy, sdbCursorHandle *handle)
 List the backups.
 
SDB_EXPORT INT32 sdbRemoveBackup (sdbConnectionHandle cHandle, bson *options)
 Remove the backups.
 
SDB_EXPORT INT32 sdbListTasks (sdbConnectionHandle cHandle, bson *condition, bson *selector, bson *orderBy, bson *hint, sdbCursorHandle *handle)
 List the tasks.
 
SDB_EXPORT INT32 sdbWaitTasks (sdbConnectionHandle cHandle, const SINT64 *taskIDs, SINT32 num)
 Wait the tasks to finish.
 
SDB_EXPORT INT32 sdbCancelTask (sdbConnectionHandle cHandle, SINT64 taskID, BOOLEAN isAsync)
 Cancel the specified task.
 
SDB_EXPORT INT32 sdbSetSessionAttr (sdbConnectionHandle cHandle, bson *options)
 Set the attributes of the session.
 
SDB_EXPORT INT32 sdbGetSessionAttr (sdbConnectionHandle cHandle, bson *result)
 Set the attributes of the session.
 
SDB_EXPORT INT32 sdbIsValid (sdbConnectionHandle cHandle, BOOLEAN *result)
 Judge whether the connection is valid.
 
SDB_EXPORT INT32 _sdbMsg (sdbConnectionHandle cHandle, const CHAR *msg)
 
SDB_EXPORT INT32 sdbCreateDomain (sdbConnectionHandle cHandle, const CHAR *pDomainName, bson *options, sdbDomainHandle *handle)
 Create a domain.
 
SDB_EXPORT INT32 sdbDropDomain (sdbConnectionHandle cHandle, const CHAR *pDomainName)
 Drop a domain.
 
SDB_EXPORT INT32 sdbGetDomain (sdbConnectionHandle cHandle, const CHAR *pDomainName, sdbDomainHandle *handle)
 Get a domain.
 
SDB_EXPORT INT32 sdbListDomains (sdbConnectionHandle cHandle, bson *condition, bson *selector, bson *orderBy, sdbCursorHandle *handle)
 List the domains.
 
SDB_EXPORT INT32 sdbAlterDomain (sdbDomainHandle cHandle, const bson *options)
 alter the current domain.
 
SDB_EXPORT INT32 sdbListCollectionSpacesInDomain (sdbDomainHandle cHandle, sdbCursorHandle *cursor)
 list the collection spaces in domain.
 
SDB_EXPORT INT32 sdbListCollectionsInDomain (sdbDomainHandle cHandle, sdbCursorHandle *cursor)
 list the collections in domain.
 
SDB_EXPORT INT32 sdbListGroupsInDomain (sdbDomainHandle cHandle, sdbCursorHandle *cursor)
 list the groups in domain.
 
SDB_EXPORT INT32 sdbInvalidateCache (sdbConnectionHandle cHandle, bson *condition)
 invalidate cache on specified nodes.
 
SDB_EXPORT INT32 sdbForceSession (sdbConnectionHandle cHandle, SINT64 sessionID, bson *options)
 
SDB_EXPORT INT32 sdbOpenLob (sdbCollectionHandle cHandle, const bson_oid_t *oid, INT32 mode, sdbLobHandle *lobHandle)
 create a large object
 
SDB_EXPORT INT32 sdbWriteLob (sdbLobHandle lobHandle, const CHAR *buf, UINT32 len)
 write lob
 
SDB_EXPORT INT32 sdbReadLob (sdbLobHandle lobHandle, UINT32 len, CHAR *buf, UINT32 *read)
 read lob
 
SDB_EXPORT INT32 sdbCloseLob (sdbLobHandle *lobHandle)
 close lob
 
SDB_EXPORT INT32 sdbRemoveLob (sdbCollectionHandle cHandle, const bson_oid_t *oid)
 remove lob
 
SDB_EXPORT INT32 sdbGetLobSize (sdbLobHandle lobHandle, SINT64 *size)
 get the lob's size
 
SDB_EXPORT INT32 sdbGetLobCreateTime (sdbLobHandle lobHandle, UINT64 *millis)
 get lob's create time
 
SDB_EXPORT INT32 sdbSeekLob (sdbLobHandle lobHandle, SINT64 size, SDB_LOB_SEEK whence)
 seek the place to read
 
SDB_EXPORT INT32 sdbListLobs (sdbCollectionHandle cHandle, sdbCursorHandle *cursor)
 list all the lobs' meta data in current collection
 
SDB_EXPORT INT32 sdbListLobPieces (sdbCollectionHandle cHandle, sdbCursorHandle *cursor)
 list all the pieces in the lob
 
SDB_EXPORT INT32 sdbReelect (sdbReplicaGroupHandle cHandle, const bson *options)
 
SDB_EXPORT INT32 sdbForceStepUp (sdbConnectionHandle cHandle, const bson *options)
 
SDB_EXPORT INT32 sdbTruncateCollection (sdbConnectionHandle cHandle, const CHAR *fullName)
 truncate the collection
 
SDB_EXPORT INT32 sdbDetachNode (sdbReplicaGroupHandle cHandle, const CHAR *hostName, const CHAR *serviceName, const bson *options)
 detach a node from the group
 
SDB_EXPORT INT32 sdbAttachNode (sdbReplicaGroupHandle cHandle, const CHAR *hostName, const CHAR *serviceName, const bson *options)
 attach a node to the group
 
SDB_EXPORT INT32 sdbCreateIdIndex (sdbCollectionHandle cHandle, const bson *args)
 Create $id index in collection.
 
SDB_EXPORT INT32 sdbDropIdIndex (sdbCollectionHandle cHandle)
 Drop $id index in collection.
 
SDB_EXPORT INT32 sdbGetDCName (sdbDCHandle cHandle, CHAR *pBuffer, INT32 size)
 
SDB_EXPORT INT32 sdbGetDC (sdbConnectionHandle cHandle, sdbDCHandle *handle)
 
SDB_EXPORT INT32 sdbGetDCDetail (sdbDCHandle cHandle, bson *retInfo)
 
SDB_EXPORT INT32 sdbActivateDC (sdbDCHandle cHandle)
 
SDB_EXPORT INT32 sdbDeactivateDC (sdbDCHandle cHandle)
 
SDB_EXPORT INT32 sdbEnableReadOnly (sdbDCHandle cHandle, BOOLEAN isReadOnly)
 
SDB_EXPORT INT32 sdbCreateImage (sdbDCHandle cHandle, const CHAR *pCataAddrList)
 
SDB_EXPORT INT32 sdbRemoveImage (sdbDCHandle cHandle)
 
SDB_EXPORT INT32 sdbEnableImage (sdbDCHandle cHandle)
 
SDB_EXPORT INT32 sdbDisableImage (sdbDCHandle cHandle)
 
SDB_EXPORT INT32 sdbAttachGroups (sdbDCHandle cHandle, bson *info)
 
SDB_EXPORT INT32 sdbDetachGroups (sdbDCHandle cHandle, bson *info)
 
SDB_EXPORT INT32 sdbSyncDB (sdbConnectionHandle cHandle, bson *options)
 sync database which are specified
 
SDB_EXPORT INT32 sdbLoadCollectionSpace (sdbConnectionHandle cHandle, const CHAR *csName, bson *options)
 Load the specified collection space to database from file.
 
SDB_EXPORT INT32 sdbUnloadCollectionSpace (sdbConnectionHandle cHandle, const CHAR *csName, bson *options)
 Unload the specified collection space from database.
 
SDB_EXPORT INT32 sdbSetPDLevel (sdbConnectionHandle cHandle, INT32 pdLevel, bson *options)
 Set the node's diagnostic level.
 
SDB_EXPORT INT32 sdbReloadConfig (sdbConnectionHandle cHandle, bson *options)
 Force the node to reload configs online.
 
SDB_EXPORT INT32 sdbRenameCollectionSpace (sdbConnectionHandle cHandle, const CHAR *pOldName, const CHAR *pNewName, bson *options)
 Rename the collectionspace name.
 
SDB_EXPORT void sdbSetConnectionInterruptFunc (sdbConnectionHandle cHandle, socketInterruptFunc func)
 

Detailed Description

C Client Driver.

Macro Definition Documentation

#define FLG_INSERT_CONTONDUP   0x00000001

The flags represent whether bulk insert continue when hitting index key duplicate error

#define FLG_INSERT_REPLACEONDUP   0x00000004

The flag represent replacing the existing record by the new record and continuing when insert hitting index key duplicate error

#define FLG_INSERT_RETURN_OID   0x00000002

The flag represent whether insert return the "_id" field of the record for user

#define QUERY_FORCE_HINT   0x00000080

Force to use specified hint to query, if database have no index assigned by the hint, fail to query.

#define QUERY_PARALLED   0x00000100

Enable parallel sub query, each sub query will finish scanning diffent part of the data.

#define QUERY_WITH_RETURNDATA   0x00000200

In general, query won't return data until cursor gets from database, when add this flag, return data in query response, it will be more high-performance

#define SDB_PAGESIZE_DEFAULT   0

0 means using database's default pagesize, it 64k now

#define sdbCreateReplicaNode   sdbCreateNode

sdbCreateReplicaNode will be deprecated in version 2.x, use sdbCreateNode instead of it.

#define sdbGetReplicaNodeByHost   sdbGetNodeByHost

sdbGetReplicaNodeByHost will be deprecated in version 2.x, use sdbGetNodeByHost instead of it.

#define sdbGetReplicaNodeByName   sdbGetNodeByName

sdbGetReplicaNodeByName will be deprecated in version 2.x, use sdbGetNodeByName instead of it.

#define sdbGetReplicaNodeMaster   sdbGetNodeMaster

sdbGetReplicaNodeMaster will be deprecated in version 2.x, use sdbGetNodeMaster instead of it.

#define sdbGetReplicaNodeSddr   sdbGetNodeAddr

sdbGetReplicaNodeSddr will be deprecated in version 2.x, use sdbGetNodeAddr instead of it.

#define sdbGetReplicaNodeSlave   sdbGetNodeSlave

sdbGetReplicaNodeSlave will be deprecated in version 2.x, use sdbGetNodeSlave instead of it.

#define sdbReleaseReplicaNode   sdbReleaseNode

sdbReleaseReplicaNode will be deprecated in version 2.x, use sdbReleaseNode instead of it.

#define sdbRemoveReplicaNode   sdbRemoveNode

sdbRemoveReplicaNode will be deprecated in version 2.x, use sdbRemoveNode instead of it.

#define sdbStartReplicaNode   sdbStartNode

sdbStartReplicaNode will be deprecated in version 2.x, use sdbStartNode instead of it.

#define sdbStopReplicaNode   sdbStopNode

sdbStopReplicaNode will be deprecated in version 2.x, use sdbStopNode instead of it.

Typedef Documentation

typedef void(* ERROR_ON_REPLY_FUNC)(const CHAR *pErrorObj, UINT32 objSize, INT32 flag, const CHAR *pDescription, const CHAR *pDetail)

Callback function when the reply message is error

typedef sdbNodeHandle sdbReplicaNodeHandle

sdbReplicaNodeHandle will be deprecated in version 2.x, use sdbNodeHandle instead of it.

Enumeration Type Documentation

Enumerator:
SDB_LOB_CREATEONLY 

Open a new lob only

SDB_LOB_READ 

Open an existing lob to read

Enumerator:
SDB_LOB_SEEK_SET 

Seek from the beginning of file

SDB_LOB_SEEK_CUR 

Seek from the current place

SDB_LOB_SEEK_END 

Seek from the end of file

Function Documentation

INT32 initClient ( sdbClientConf config)

set client global configuration such as cache strategy to improve performance

Parameters
[in]configThe configuration struct, see detail of sdbClientConf
Return values
SDB_OKopen cache strategy Success
OthersFail
INT32 sdbAggregate ( sdbCollectionHandle  cHandle,
bson **  obj,
SINT32  num,
sdbCursorHandle *  handle 
)

Execute aggregate operation in specified collection.

Parameters
[in]cHandleThe collection handle
[in]objThe array of bson objects
[in]numThe number of inserted bson objects
[out]handleThe cursor handle of result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 rc = 0 ;
INT32 i = 0 ;
sdbCollectionHandle cl ;
sdbCursorHandle cursor ;
const INT32 num = 2 ;
bson* obj[num] ;
const CHAR* pArr[num] = {
"{ $match: { $and: [ { no: { $gt: 1002 } },{ no: { $lt: 1015 } },{ dep
: \"IT Academy\" } ] } }",
"{ $project: { no: 1, \"info.name\": 1, major: 1 } }"
} ;
// create bson poiter array
for ( i = 0; i < num; i++ )
{
obj[i] = bson_create();
jsonToBson ( obj[i], pArr[i] ) ;
}
// TODO: get collection handle
// aggregate
//rc = sdbAggregate ( cl, obj, num, &cursor ) ;
if ( rc )
printf ( "something wrong, rc = %d.\n", rc ) ;
// free memory
for ( i = 0; i < num; i++ )
{
bson_print( obj[i] ) ;
bson_dispose ( obj[i] ) ;
}
// TODO: release collection and cursor handles
INT32 sdbAlterCollection ( sdbCollectionHandle  cHandle,
bson *  options 
)

Alter the specified collection.

Parameters
[in]cHandleThe colleciton handle
[in]optionsThe options are as following:
ReplSize     : Assign how many replica nodes need to be synchronized when a write request(insert, update, etc) is executed
ShardingKey  : Assign the sharding key
ShardingType : Assign the sharding type
Partition    : When the ShardingType is "hash", need to assign Partition, it's the bucket number for hash, the range is [2^3,2^20]
               e.g. {RepliSize:0, ShardingKey:{a:1}, ShardingType:"hash", Partition:1024}
Note
Can't alter attributes about split in partition collection; After altering a collection to be a partition collection, need to split this collection manually
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbAlterDomain ( sdbDomainHandle  cHandle,
const bson *  options 
)

alter the current domain.

Parameters
[in]cHandleThe domain handle
[in]optionsThe options user wants to alter
Groups:    The list of replica groups' names which the domain is going to contain.
           eg: { "Groups": [ "group1", "group2", "group3" ] }, it means that domain
           changes to contain "group1" "group2" or "group3".
           We can add or remove groups in current domain. However, if a group has data
           in it, remove it out of domain will be failing.
AutoSplit: Alter current domain to have the ability of automatically split or not.
           If this option is set to be true, while creating collection(ShardingType is "hash") in this domain,
           the data of this collection will be split(hash split) into all the groups in this domain automatically.
           However, it won't automatically split data into those groups which were add into this domain later.
           eg: { "Groups": [ "group1", "group2", "group3" ], "AutoSplit: true" }
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbAttachCollection ( sdbCollectionHandle  cHandle,
const CHAR *  subClFullName,
bson *  options 
)

Attach the specified collection.

Parameters
[in]cHandleThe collection handle
[in]subClFullNameThe name of the subcollection
[in]optionsThe low boudary and up boudary eg: {"LowBound":{a:1},"UpBound":{a:100}}
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbAttachNode ( sdbReplicaGroupHandle  cHandle,
const CHAR *  hostName,
const CHAR *  serviceName,
const bson *  options 
)

attach a node to the group

Parameters
[in]cHandleThe handle of group.
[in]hostNameThe host name of node.
[in]serviceNameThe service name of node.
[in]optoinsThe options of attach. Can not be null or empty. Can be the follow options:
  • KeepData : Whether to keep the original data of the new node. This option has no default value. User should specify its value explicitly.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbBackupOffline ( sdbConnectionHandle  cHandle,
bson *  options 
)

Backup the whole database or specifed replica group.

Parameters
[in]cHandleThe connection handle
[in]optionsContains a series of backup configuration infomations. Backup the whole cluster if null. The "options" contains 5 options as below. All the elements in options are optional. eg: {"GroupName":["RGName1", "RGName2"], "Path":"/opt/sequoiadb/backup", "Name":"backupName", "Description":description, "EnsureInc":true, "OverWrite":true}
GroupID     : The id(s) of replica group(s) which to be backuped
GroupName   : The replica groups which to be backuped
Path        : The backup path, if not assign, use the backup path assigned in the configuration file,
              the path support to use wildcard(%g/%G:group name, %h/%H:host name, %s/%S:service name). e.g.  {Path:"/opt/sequoiadb/backup/%g"}
isSubDir    : Whether the path specified by paramer "Path" is a subdirectory of the path specified in the configuration file, default to be false
Name        : The name for the backup
Prefix      : The prefix of name for the backup, default to be null. e.g. {Prefix:"%g_bk_"}
EnableDateDir : Whether turn on the feature which will create subdirectory named to current date like "YYYY-MM-DD" automatically, default to be false
Description : The description for the backup
EnsureInc   : Whether excute increment synchronization, default to be false
OverWrite   : Whether overwrite the old backup file, default to be false
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbBulkInsert ( sdbCollectionHandle  cHandle,
SINT32  flags,
bson **  obj,
SINT32  num 
)

Insert a bulk of bson objects into current collection.

Parameters
[in]cHandleThe collection handle
[in]flagThe flag to control the behavior of inserting. The value of flag default to be 0, and it can choose the follow values:
  • 0: while 0 is set(default to be 0), database will stop inserting when the record hit index key duplicate error.
  • FLG_INSERT_CONTONDUP: if the record hit index key duplicate error, database will skip them and go on inserting.
  • FLG_INSERT_RETURN_OID: return the value of "_id" field in the record.
  • FLG_INSERT_REPLACEONDUP: if the record hit index key duplicate error, database will replace the existing record by the inserting new record and then go on inserting.

[in]objThe array of inserted bson objects, cannot be null
[in]numThe number of inserted bson objects
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 rc = 0 ;
INT32 i = 0 ;
const INT32 num = 10 ;
bson* obj[num] ;
// create bson poiter array
for ( i = 0; i < num; i++ )
{
obj[i] = bson_create();
rc = bson_append_int( obj[i], "num", i ) ;
if ( rc != 0 )
printf ( "something wrong.\n" ) ;
rc = bson_finish ( obj[i] ) ;
if ( rc != 0 )
printf ( "something wrong.\n" ) ;
}
// bulk insert
rc = sdbBulkInsert ( cl, 0, obj, num ) ;
if ( rc )
printf ( "something wrong, rc = %d.\n", rc ) ;
// free memory
for ( i = 0; i < num; i++ )
{
bson_dispose ( obj[i] ) ;
}
INT32 sdbCancelTask ( sdbConnectionHandle  cHandle,
SINT64  taskID,
BOOLEAN  isAsync 
)

Cancel the specified task.

Parameters
[in]cHandleThe connection handle
[in]taskIDThe task id
[in]isAsyncThe operation "cancel task" is async or not, "true" for async, "false" for sync. Default sync.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCloseAllCursors ( sdbConnectionHandle  cHandle)

Send a "Interrpt" message to engine, as a result, all the cursors and lobs created by current connection will be closed.

Parameters
[in]cHandleThe database connection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCloseCursor ( sdbCursorHandle  cHandle)

Close the cursor's connection to database, we can't use this handle to get data again.

Parameters
[in]cHandleThe cursor handle
Note
Don't call this method after the connection handle had been released.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCloseLob ( sdbLobHandle *  lobHandle)

close lob

Parameters
[in]lobHandleThe large object handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbConnect ( const CHAR *  pHostName,
const CHAR *  pServiceName,
const CHAR *  pUsrName,
const CHAR *  pPasswd,
sdbConnectionHandle *  handle 
)

Connect to database.

Parameters
[in]pHostNameThe Host Name or IP Address of Database Server
[in]pServiceNameThe Service Name or Port of Database Server
[in]pUsrNameThe User's Name of the account
[in]pPasswdThe Password of the account
[out]handleThe database connection handle, when fail to connect, *handle == SDB_INVALID_HANDLE and error code is return
Return values
SDB_OKConnection Success
OthersConnection Fail
INT32 sdbConnect1 ( const CHAR **  pConnAddrs,
INT32  arrSize,
const CHAR *  pUsrName,
const CHAR *  pPasswd,
sdbConnectionHandle *  handle 
)

Connect to database used a random valid address in the array.

Parameters
[in]pConnAddrsThe array of the coord's address
[in]arrSizeThe size of the array
[in]pUsrNameThe User's Name of the account
[in]pPasswdThe Password of the account
[out]handleThe database connection handle
Return values
SDB_OKConnection Success
OthersConnection Fail
INT32 sdbCreateCollection ( sdbCSHandle  cHandle,
const CHAR *  pCollectionName,
sdbCollectionHandle *  handle 
)

Create the specified collection in current collection space This function creates a non-sharded collection with default replsize.

Parameters
[in]cHandleThe collection space handle
[in]pCollectionNameThe collection name
[out]handleThe collection handle, when fail to create collection, *handle == -1 and error code is return
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateCollection1 ( sdbCSHandle  cHandle,
const CHAR *  pCollectionName,
bson *  options,
sdbCollectionHandle *  handle 
)

Create the specified collection in current collection space.

Parameters
[in]cHandleThe collection space handle
[in]pCollectionNameThe collection name
[in]optionsThe options for creating collection, including "ShardingKey", "ReplSize", "IsMainCL" and "Compressed" informations, no options, if null
[out]handleThe collection handle when fail to create collection, *handle == -1 and error code is return
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateCollectionSpace ( sdbConnectionHandle  cHandle,
const CHAR *  pCollectionSpaceName,
INT32  iPageSize,
sdbCSHandle *  handle 
)

Create the specified collection space.

Parameters
[in]cHandleThe database connection handle
[in]pCollectionSpaceNameThe name of collection space
[in]iPageSizeThe Page Size as below
SDB_PAGESIZE_4K
SDB_PAGESIZE_8K
SDB_PAGESIZE_16K
SDB_PAGESIZE_32K
SDB_PAGESIZE_64K
SDB_PAGESIZE_DEFAULT
[out]handleThe collection space handle when fail to create collection space, *handle == -1 and error code is return
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateCollectionSpaceV2 ( sdbConnectionHandle  cHandle,
const CHAR *  pCollectionSpaceName,
bson *  options,
sdbCSHandle *  handle 
)

Create the specified collection space.

Parameters
[in]cHandleThe database connection handle
[in]pCollectionSpaceNameThe name of collection space
[in]optionsThe options specified by user, e.g. {"PageSize": 4096, "Domain": "mydomain"}.
PageSize   : Assign the pagesize of the collection space
Domain     : Assign which domain does current collection space belong to
[out]handleThe collection space handle when fail to create collection space, *handle == -1 and error code is return
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateDomain ( sdbConnectionHandle  cHandle,
const CHAR *  pDomainName,
bson *  options,
sdbDomainHandle *  handle 
)

Create a domain.

Parameters
[in]cHandleThe database connection handle
[in]pDomainNameThe name of the domain
[in]optionsThe options for the domain. The options are as below:
Groups:    The list of replica groups' names which the domain is going to contain.
           eg: { "Groups": [ "group1", "group2", "group3" ] }
           If this argument is not included, the domain will contain all replica groups in the cluster.
AutoSplit: If this option is set to be true, while creating collection(ShardingType is "hash") in this domain,
           the data of this collection will be split(hash split) into all the groups in this domain automatically.
           However, it won't automatically split data into those groups which were add into this domain later.
           eg: { "Groups": [ "group1", "group2", "group3" ], "AutoSplit: true" }
[out]handleThe domain handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateIdIndex ( sdbCollectionHandle  cHandle,
const bson *  args 
)

Create $id index in collection.

Parameters
[in]cHandleThe collection handle.
[in]argsThe arguments of creating id index. set it as null if no args. e.g.{SortBufferSize:64}
SortBufferSize     : The size of sort buffer used when creating index, the unit is MB,
                     zero means don't use sort buffer
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateIndex ( sdbCollectionHandle  cHandle,
bson *  indexDef,
const CHAR *  pIndexName,
BOOLEAN  isUnique,
BOOLEAN  isEnforced 
)

Create the index in current collection.

Parameters
[in]cHandleThe collection handle
[in]indexDefThe bson structure of index element, e.g. {name:1, age:-1}
[in]pIndexNameThe index name
[in]isUniqueWhether the index elements are unique or not
[in]isEnforcedWhether the index is enforced unique This element is meaningful when isUnique is set to true
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateIndex1 ( sdbCollectionHandle  cHandle,
bson *  indexDef,
const CHAR *  pIndexName,
BOOLEAN  isUnique,
BOOLEAN  isEnforced,
INT32  sortBufferSize 
)

Create the index in current collection.

Parameters
[in]cHandleThe collection handle
[in]indexDefThe bson structure of index element, e.g. {name:1, age:-1}
[in]pIndexNameThe index name
[in]isUniqueWhether the index elements are unique or not
[in]isEnforcedWhether the index is enforced unique This element is meaningful when isUnique is set to true
[in]sortBufferSizeThe size of sort buffer used when creating index, the unit is MB, zero means don't use sort buffer
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateNode ( sdbReplicaGroupHandle  cHandle,
const CHAR *  pHostName,
const CHAR *  pServiceName,
const CHAR *  pDatabasePath,
bson *  configure 
)

Create node in a given replica group.

Parameters
[in]cHandleThe replica group handle
[in]pHostNameThe hostname for the node
[in]pServiceNameThe servicename for the node
[in]pDatabasePathThe database path for the node
[in]configureThe configurations for the node
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateReplicaCataGroup ( sdbConnectionHandle  cHandle,
const CHAR *  pHostName,
const CHAR *  pServiceName,
const CHAR *  pDatabasePath,
bson *  configure 
)

Create a catalog replica group.

Parameters
[in]cHandleThe database connection handle
[in]pHostNameThe hostname for the catalog replica group
[in]pServiceNameThe servicename for the catalog replica group
[in]pDatabasePathThe path for the catalog replica group
[in]configureThe configurations for the catalog replica group
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateReplicaGroup ( sdbConnectionHandle  cHandle,
const CHAR *  pRGName,
sdbReplicaGroupHandle *  handle 
)

Create the specified replica group.

Parameters
[in]cHandleThe database connection handle
[in]pRGNameThe name of the replica group
[out]handleThe replica group handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCreateUsr ( sdbConnectionHandle  cHandle,
const CHAR *  pUsrName,
const CHAR *  pPasswd 
)

Create an account.

Parameters
[in]cHandleThe database connection handle
[in]pUsrNameThe User's Name of the account
[in]pPasswdThe Password of the account
Return values
SDB_OKConnection Success
OthersConnection Fail
INT32 sdbCreateUsr2 ( sdbConnectionHandle  cHandle,
const CHAR *  pUsrName,
const CHAR *  pPasswd,
bson *  options 
)

Create an account.

Parameters
[in]cHandleThe database connection handle
[in]pUsrNameThe User's Name of the account
[in]pPasswdThe Password of the account
[in]optionsThe options for user, such as: { AuditMask:"DDL|DML" } AuditMask : User audit log mask, value list: ACCESS,CLUSTER,SYSTEM,DML,DDL,DCL,DQL,INSERT,DELETE, UPDATE,OTHER. You can combine multiple values with '|'. 'ALL' means that all mask items are turned on, and 'NONE' means that no mask items are turned on. If an item in the user audit log is not configured, the configuration of the corresponding mask item on the node is inherited. You can also use '!' to disable inheritance of this mask( e.g. "!DDL|DML" ).
Return values
SDB_OKConnection Success
OthersConnection Fail
INT32 sdbCrtJSProcedure ( sdbConnectionHandle  cHandle,
const CHAR *  code 
)

create a store procedure.

Parameters
[in]cHandleThe collection space space handle
[in]codeThe code of store procedures
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbCurrent ( sdbCursorHandle  cHandle,
bson *  obj 
)

Return the current document of cursor, and don't move.

Parameters
[in]cHandleThe cursor handle
[out]objThe return bson object
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbDelete ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  hint 
)

Delete the matching documents in current collection, never rollback if failed.

Parameters
[in]cHandleThe collection handle
[in]conditionThe matching rule, delete all the documents if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbDetachCollection ( sdbCollectionHandle  cHandle,
const CHAR *  subClFullName 
)

Detach the specified collection.

Parameters
[in]cHandleThe collection handle
[in]subClFullNameThe name of the subcollection
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbDetachNode ( sdbReplicaGroupHandle  cHandle,
const CHAR *  hostName,
const CHAR *  serviceName,
const bson *  options 
)

detach a node from the group

Parameters
[in]cHandleThe handle of group.
[in]hostNameThe host name of node.
[in]serviceNameThe service name of node.
[in]optoinsThe options of detach. Can not be null or empty. Can be the follow options:
  • KeepData: Whether to keep the original data of the detached node. This option has no default value. User should specify its value explicitly.
  • Enforced: Whether to detach the node forcibly , default to be false.
Return values
SDB_OKOperation Success
OthersOperation Fail
void sdbDisconnect ( sdbConnectionHandle  handle)

Disconnect to database.

Parameters
[in]handleThe database connection handle
INT32 sdbDropCollection ( sdbCSHandle  cHandle,
const CHAR *  pCollectionName 
)

Drop the specified collection in current collection space.

Parameters
[in]cHandleThe collection space handle
[in]pCollectionNameThe collection name
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbDropCollectionSpace ( sdbConnectionHandle  cHandle,
const CHAR *  pCollectionSpaceName 
)

Drop the specified collection space.

Parameters
[in]cHandleThe database connection handle
[in]pCollectionSpaceNameThe name of collection space
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbDropDomain ( sdbConnectionHandle  cHandle,
const CHAR *  pDomainName 
)

Drop a domain.

Parameters
[in]cHandleThe database connection handle
[in]pDomainNameThe name of the domain
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbDropIdIndex ( sdbCollectionHandle  cHandle)

Drop $id index in collection.

Parameters
[in]cHandleThe collection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
Note
delete, update and upsert do not work after index "$id" was drop
INT32 sdbDropIndex ( sdbCollectionHandle  cHandle,
const CHAR *  pIndexName 
)

Drop the index in current collection.

Parameters
[in]cHandleThe collection handle
[in]pIndexNameThe index name
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbEvalJS ( sdbConnectionHandle  cHandle,
const CHAR *  code,
SDB_SPD_RES_TYPE type,
sdbCursorHandle *  handle,
bson *  errmsg 
)

Eval a func. \ type is declared in spd.h. see SDB_FMP_RES_TYPE.

Parameters
[in]cHandleThe collection space space handle
[in]codeThe code to eval
[out]typeThe type of value
[out]handleThe cursor handle of current eval
[out]errmsgThe errmsg from eval
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbExec ( sdbConnectionHandle  cHandle,
const CHAR *  sql,
sdbCursorHandle *  result 
)

Executing SQL command.

Parameters
[in]cHandleThe database connection handle
[in]sqlThe SQL command.
[out]resultThe return cursor handle of matching documents.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbExecUpdate ( sdbConnectionHandle  cHandle,
const CHAR *  sql 
)

Executing SQL command for updating.

Parameters
[in]cHandleThe database connection handle
[in]sqlThe SQL command.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbExplain ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  select,
bson *  orderBy,
bson *  hint,
INT32  flag,
INT64  numToSkip,
INT64  numToReturn,
bson *  options,
sdbCursorHandle *  handle 
)

get access plan of query

Parameters
[in]cHandleThe collection handle
[in]conditionThe matching rule, return all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
QUERY_FORCE_HINT
QUERY_PARALLED
QUERY_WITH_RETURNDATA
[in]numToSkipSkip the first numToSkip documents, never skip if this parameter is 0
[in]numToReturnOnly return numToReturn documents, return all if this parameter is -1
[in]optionsthe rules of explain, the options are as below:
Run     : Whether execute query explain or not, true for excuting query explain then get
          the data and time information; false for not excuting query explain but get the
          query explain information only. e.g. {Run:true}
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbFlushConfigure ( sdbConnectionHandle  cHandle,
bson *  options 
)

flush the options to configure file.

Parameters
[in]cHandleThe connection handle
[in]optionsThe configure infomation, pass {"Global":true} or {"Global":false} In cluster environment, passing {"Global":true} will flush data's and catalog's configuration file, while passing {"Global":false} will flush coord's configuration file. In stand-alone environment, both them have the same behaviour.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbForceStepUp ( sdbConnectionHandle  cHandle,
const bson *  options 
)
Parameters
[in]cHandleThe connection handle
[in]optionsThe options of step up
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetCLFullName ( sdbCollectionHandle  cHandle,
CHAR *  pBuffer,
INT32  size 
)

Get the specified collection full name.

Parameters
[in]cHandleThe collection handle
[in]pBufferThe buffer for output cl full name
[in]sizeThe size of the buffer
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetCLName ( sdbCollectionHandle  cHandle,
CHAR *  pCLName,
INT32  size 
)

Get the specified collection name.

Parameters
[in]cHandleThe collection handle
[in]pBufferThe buffer for output cl name
[in]sizeThe size of the buffer
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetCollection ( sdbConnectionHandle  cHandle,
const CHAR *  pCollectionFullName,
sdbCollectionHandle *  handle 
)

Get the specified collection.

Parameters
[in]cHandleThe database connection handle
[in]pCollectionFullNameThe full name of collection
[out]handleThe collection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetCollection1 ( sdbCSHandle  cHandle,
const CHAR *  pCollectionName,
sdbCollectionHandle *  handle 
)

Get the specified collection of current collection space.

Get the specified collection.

Parameters
[in]cHandleThe collection space handle
[in]pCollectionNameThe collection name
[out]handleThe collection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
Parameters
[in]cHandleThe database connection handle
[in]pCollectionNameThe name of collection
[out]handleThe collection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetCollectionSpace ( sdbConnectionHandle  cHandle,
const CHAR *  pCollectionSpaceName,
sdbCSHandle *  handle 
)

Get the specified collection space.

Parameters
[in]cHandleThe database connection handle
[in]pCollectionSpaceNameThe name of collection space
[out]handleThe collection space handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetCount ( sdbCollectionHandle  cHandle,
bson *  condition,
SINT64 *  count 
)

Get the count of documents in specified collection.

Parameters
[in]cHandleThe collection handle
[in]conditionThe matching rule, return the count of all documents if this parameter is null
[out]countThe count of matching documents
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetCount1 ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  hint,
SINT64 *  count 
)

Get the count of documents in specified collection.

Parameters
[in]cHandleThe collection handle
[in]conditionThe matching rule, return the count of all documents if this parameter is null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[out]countThe count of matching documents
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetCSName ( sdbCSHandle  cHandle,
CHAR *  pCSName,
INT32  size 
)

Get the specified collection space name.

Parameters
[in]cHandleThe collection space handle
[in]pBufferThe buffer for output cs name
[in]sizeThe size of the buffer
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetDataBlocks ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  select,
bson *  orderBy,
bson *  hint,
INT64  numToSkip,
INT64  numToReturn,
sdbCursorHandle *  handle 
)

Get the data blocks' infomation for concurrent query.

Parameters
[in]cHandleThe connection handle
[in]conditionThe matching rule, return all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintThe hint, The collection full name eg: {"Collection":"foo.bar"} while "foo.bar" is the full name of current collection
[in]numToSkipSkip the first numToSkip documents, never skip if this parameter is 0
[in]numToReturnOnly return numToReturn documents, return all if this parameter is -1
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
Deprecated:
this API only support in java
INT32 sdbGetDomain ( sdbConnectionHandle  cHandle,
const CHAR *  pDomainName,
sdbDomainHandle *  handle 
)

Get a domain.

Parameters
[in]cHandleThe database connection handle
[in]pDomainNameThe name of the domain
[out]handleThe domain handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetIndexes ( sdbCollectionHandle  cHandle,
const CHAR *  pIndexName,
sdbCursorHandle *  handle 
)

Get all of or one of the indexes in current collection.

Parameters
[in]cHandleThe collection handle
[in]pIndexNameThe index name, returns all of the indexes if this parameter is null
[out]handleThe cursor handle of returns
Return values
SDB_OKOperation Success
OthersOperation Fail
void sdbGetLastErrorObj ( bson *  obj)

Get the error object info for the last operation in the thread.

Parameters
[out]objThe return error bson object
Return values
SDB_OKGet error object Success
SDB_DMS_EOCThere is no error object
OthersGet error object Fail
INT32 sdbGetList ( sdbConnectionHandle  cHandle,
INT32  listType,
bson *  condition,
bson *  selector,
bson *  orderBy,
sdbCursorHandle *  handle 
)

Get the specified list.

Parameters
[in]cHandleThe collection handle
[in]listTypeThe list type as below
SDB_LIST_CONTEXTS         : Get all contexts list
SDB_LIST_CONTEXTS_CURRENT : Get contexts list for the current session
SDB_LIST_SESSIONS         : Get all sessions list
SDB_LIST_SESSIONS_CURRENT : Get the current session
SDB_LIST_COLLECTIONS      : Get all collections list
SDB_LIST_COLLECTIONSPACES : Get all collecion spaces' list
SDB_LIST_STORAGEUNITS     : Get storage units list
SDB_LIST_GROUPS           : Get replicaGroup list ( only applicable in sharding env )
SDB_LIST_STOREPROCEDURES  : Get all the stored procedure list
SDB_LIST_DOMAINS          : Get all the domains list
SDB_LIST_TASKS            : Get all the running split tasks ( only applicable in sharding env )
SDB_LIST_TRANSACTIONS     : Get all the transactions information.
SDB_LIST_TRANSACTIONS_CURRENT : Get the transactions information of current session.
SDB_LIST_USERS            : Get all the user informations.
[in]conditionThe matching rule, match all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetList1 ( sdbConnectionHandle  cHandle,
INT32  listType,
bson *  condition,
bson *  selector,
bson *  orderBy,
bson *  hint,
SINT64  numToSkip,
SINT64  numToReturn,
sdbCursorHandle *  handle 
)

Get the specified list.

Parameters
[in]cHandleThe collection handle
[in]listTypeThe list type as below
SDB_LIST_CONTEXTS         : Get all contexts list
SDB_LIST_CONTEXTS_CURRENT : Get contexts list for the current session
SDB_LIST_SESSIONS         : Get all sessions list
SDB_LIST_SESSIONS_CURRENT : Get the current session
SDB_LIST_COLLECTIONS      : Get all collections list
SDB_LIST_COLLECTIONSPACES : Get all collecion spaces' list
SDB_LIST_STORAGEUNITS     : Get storage units list
SDB_LIST_GROUPS           : Get replicaGroup list ( only applicable in sharding env )
SDB_LIST_STOREPROCEDURES  : Get all the stored procedure list
SDB_LIST_DOMAINS          : Get all the domains list
SDB_LIST_TASKS            : Get all the running split tasks ( only applicable in sharding env )
SDB_LIST_TRANSACTIONS     : Get all the transactions information.
SDB_LIST_TRANSACTIONS_CURRENT : Get the transactions information of current session.
SDB_LIST_USERS            : Get all the user informations.
[in]conditionThe matching rule, match all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintThe options provided for specific list type. Reserved.
[in]numToSkipSkip the first numToSkip documents.
[in]numToReturnOnly return numToReturn documents. -1 means return all matched results.
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetLobCreateTime ( sdbLobHandle  lobHandle,
UINT64 *  millis 
)

get lob's create time

Parameters
[in]lobHandleThe large object handle
[out]millisThe create time in milliseconds of lob, while open a new lob, the create time is 0
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetLobSize ( sdbLobHandle  lobHandle,
SINT64 *  size 
)

get the lob's size

Parameters
[in]lobHandleThe large object handle
[out]sizeThe size of lob
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetNodeAddr ( sdbNodeHandle  cHandle,
const CHAR **  ppHostName,
const CHAR **  ppServiceName,
const CHAR **  ppNodeName,
INT32 *  pNodeID 
)

Get the host and service name for the specified node.

Parameters
[in]cHandleThe node handle
[out]ppHostNameThe hostname for the node
[out]ppServiceNameThe servicename for the node
[out]ppNodeNameThe name for the node
[out]pNodeIDThe id for the node
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetNodeByHost ( sdbReplicaGroupHandle  cHandle,
const CHAR *  pHostName,
const CHAR *  pServiceName,
sdbNodeHandle *  handle 
)

Get the node from the specified replica group.

Parameters
[in]cHandleThe replica group handle
[in]pNodeNameThe name of the node, with the format of "hostname:port".
[in]pServiceNameThe service name of the node
[out]handleThe node handle, when fail to get node, *handle == -1, and error code is return
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetNodeByName ( sdbReplicaGroupHandle  cHandle,
const CHAR *  pNodeName,
sdbNodeHandle *  handle 
)

Get the node from the specified replica group.

Parameters
[in]cHandleThe replica group handle
[in]pNodeNameThe name of node
[out]handleThe node handle, when fail to get node, *handle == -1, and error code is return
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetNodeMaster ( sdbReplicaGroupHandle  cHandle,
sdbNodeHandle *  handle 
)

Get the master node of the specified replica group.

Parameters
[in]cHandleThe replica group handle
[out]handleThe master node handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetNodeSlave ( sdbReplicaGroupHandle  cHandle,
sdbNodeHandle *  handle 
)

Get one of slave node of the specified replica group, if no slave exists then get master.

Parameters
[in]cHandleThe replica group handle
[out]handleThe slave node handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetQueryMeta ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  orderBy,
bson *  hint,
INT64  numToSkip,
INT64  numToReturn,
sdbCursorHandle *  handle 
)

Get the index blocks' or data blocks' infomations for concurrent query.

Parameters
[in]conditionThe matching rule, return all the documents if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, never skip if this parameter is 0
[in]numToReturnOnly return numToReturn documents, return all if this parameter is -1
[out]handleThe handle of query result
Return values
SDB_OKOperation Success
OthersOperation Fail
Deprecated:
this API only support in java
INT32 sdbGetReplicaGroup ( sdbConnectionHandle  cHandle,
const CHAR *  pRGName,
sdbReplicaGroupHandle *  handle 
)

Get the specified replica group.

Parameters
[in]cHandleThe database connection handle
[in]pRGNameThe name of replica group
[out]handleThe replica group handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetReplicaGroup1 ( sdbConnectionHandle  cHandle,
UINT32  id,
sdbReplicaGroupHandle *  handle 
)

Get the specified replica group.

Parameters
[in]cHandleThe database connection handle
[in]idThe id of the replica group
[out]handleThe replica group handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetReplicaGroupName ( sdbReplicaGroupHandle  cHandle,
CHAR **  ppRGName 
)

Get the specified replica group's name.

Parameters
[in]cHandleThe replica group handle
[out]ppRGNameThe replica group name
Return values
SDB_OKOperation Success
OthersOperation Fail
Deprecated:
This api will be deprecated at version 2.x
INT32 sdbGetRGName ( sdbReplicaGroupHandle  cHandle,
CHAR *  pBuffer,
INT32  size 
)

Get the specified replica group's name.

Parameters
[in]cHandleThe replica group handle
[in]pBufferThe buffer for output replica group name
[in]sizethe size of the buffer
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetSessionAttr ( sdbConnectionHandle  cHandle,
bson *  result 
)

Set the attributes of the session.

Parameters
[in]cHandleThe connection handle
[out]resultThe return bson object
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetSnapshot ( sdbConnectionHandle  cHandle,
INT32  snapType,
bson *  condition,
bson *  selector,
bson *  orderBy,
sdbCursorHandle *  handle 
)

Get the snapshot.

Parameters
[in]cHandleThe connection handle
[in]snapTypeThe snapshot type as below
SDB_SNAP_CONTEXTS         : Get the snapshot of all the contexts
SDB_SNAP_CONTEXTS_CURRENT : Get the snapshot of current context
SDB_SNAP_SESSIONS         : Get the snapshot of all the sessions
SDB_SNAP_SESSIONS_CURRENT : Get the snapshot of current session
SDB_SNAP_COLLECTIONS      : Get the snapshot of all the collections
SDB_SNAP_COLLECTIONSPACES : Get the snapshot of all the collection spaces
SDB_SNAP_DATABASE         : Get the snapshot of the database
SDB_SNAP_SYSTEM           : Get the snapshot of the system
SDB_SNAP_CATALOG          : Get the snapshot of the catalog
SDB_SNAP_TRANSACTIONS     : Get snapshot of transactions in current session
SDB_SNAP_TRANSACTIONS_CURRENT : Get snapshot of all the transactions
[in]conditionThe matching rule, match all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbGetSnapshot1 ( sdbConnectionHandle  cHandle,
INT32  snapType,
bson *  condition,
bson *  selector,
bson *  orderBy,
bson *  hint,
INT64  numToSkip,
INT64  numToReturn,
sdbCursorHandle *  handle 
)

Get the snapshot.

Parameters
[in]cHandleThe connection handle
[in]snapTypeThe snapshot type as below
SDB_SNAP_CONTEXTS         : Get the snapshot of all the contexts
SDB_SNAP_CONTEXTS_CURRENT : Get the snapshot of current context
SDB_SNAP_SESSIONS         : Get the snapshot of all the sessions
SDB_SNAP_SESSIONS_CURRENT : Get the snapshot of current session
SDB_SNAP_COLLECTIONS      : Get the snapshot of all the collections
SDB_SNAP_COLLECTIONSPACES : Get the snapshot of all the collection spaces
SDB_SNAP_DATABASE         : Get the snapshot of the database
SDB_SNAP_SYSTEM           : Get the snapshot of the system
SDB_SNAP_CATALOG          : Get the snapshot of the catalog
SDB_SNAP_TRANSACTIONS     : Get snapshot of transactions in current session
SDB_SNAP_TRANSACTIONS_CURRENT : Get snapshot of all the transactions
[in]conditionThe matching rule, match all the documents if null.
[in]selectThe selective rule, return the whole document if null.
[in]orderByThe ordered rule, never sort if null.
[in]hintReserved.
[in]numToSkipReserved.
[in]numToReturnReserved.
[out]handleThe cursor handle of current query.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbInsert ( sdbCollectionHandle  cHandle,
bson *  obj 
)

Insert a bson object into current collection.

Parameters
[in]cHandleThe collection handle
[in]objThe inserted bson object, cannot be null
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbInsert1 ( sdbCollectionHandle  cHandle,
bson *  obj,
bson_iterator *  id 
)

Insert a bson object into current collection.

Parameters
[in]cHandleThe collection handle
[in]objThe inserted bson object, cannot be null
[out]idThe object id of inserted bson object in current collection
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbInsert2 ( sdbCollectionHandle  cHandle,
bson *  obj,
INT32  flag,
bson_iterator *  id 
)

Insert a bson object into current collection.

Parameters
[in]cHandleThe collection handle
[in]objThe inserted bson object, cannot be null
[in]flagThe flag to control the behavior of inserting. The value of flag default to be 0, and it can choose the follow values:
  • 0: while 0 is set(default to be 0), database will stop inserting when the record hit index key duplicate error.
  • FLG_INSERT_CONTONDUP: if the record hit index key duplicate error, database will skip them and go on inserting.
  • FLG_INSERT_RETURN_OID: return the value of "_id" field in the record.
  • FLG_INSERT_REPLACEONDUP: if the record hit index key duplicate error, database will replace the existing record by the inserting new record and then go on inserting.

[out]idThe object id of inserted bson object in current collection
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbInvalidateCache ( sdbConnectionHandle  cHandle,
bson *  condition 
)

invalidate cache on specified nodes.

Parameters
[in]cHandleThe connection handle
[in]conditionThe destination we want to invalidate.
Return values
SDB_OKOperation Success
OthersOperation Fail
BOOLEAN sdbIsReplicaGroupCatalog ( sdbReplicaGroupHandle  cHandle)

Test whether the specified replica group is catalog.

Parameters
[in]cHandleThe replica group handle
Return values
TRUEThe replica group is catalog
FALSEThe replica group is not catalog
INT32 sdbIsValid ( sdbConnectionHandle  cHandle,
BOOLEAN *  result 
)

Judge whether the connection is valid.

Parameters
[out]resultthe output result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListBackup ( sdbConnectionHandle  cHandle,
bson *  options,
bson *  condition,
bson *  selector,
bson *  orderBy,
sdbCursorHandle *  handle 
)

List the backups.

Parameters
[in]cHandleThe connection handle
[in]optionsContains configuration infomations for remove backups, list all the backups in the default backup path if null. The "options" contains 3 options as below. All the elements in options are optional. eg: {"GroupName":["RGName1", "RGName2"], "Path":"/opt/sequoiadb/backup", "Name":"backupName"}
GroupID     : Specified the group id of the backups, default to list all the backups of all the groups.
GroupName   : Specified the group name of the backups, default to list all the backups of all the groups.
Path        : Specified the path of the backups, default to use the backup path asigned in the configuration file.
Name        : Specified the name of backup, default to list all the backups.
IsSubDir    : Specified the "Path" is a subdirectory of the backup path assigned in the configuration file or not, default to be false.
Prefix      : Specified the prefix name of the backups, support for using wildcards("%g","%G","%h","%H","%s","%s"),such as: Prefix:"%g_bk_", default to not using wildcards.
Detail      : Display the detail of the backups or not, default to be false.
[in]conditionThe matching rule, return all the documents if null
[in]selectorThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[out]handleThe cusor handle of result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListCollections ( sdbConnectionHandle  cHandle,
sdbCursorHandle *  handle 
)

List all collection of current database(not include temporary collection of temporary collection space)

Parameters
[in]cHandleThe database connection handle
[out]handleThe cursor handle of all collection names
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListCollectionsInDomain ( sdbDomainHandle  cHandle,
sdbCursorHandle *  cursor 
)

list the collections in domain.

Parameters
[in]cHandleThe domain handle
[out]handleThe cusor handle of result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListCollectionSpaces ( sdbConnectionHandle  cHandle,
sdbCursorHandle *  handle 
)

List all collection space of current database(include temporary collection space)

Parameters
[in]cHandleThe database connection handle
[out]handleThe cursor handle of all collection space names
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListCollectionSpacesInDomain ( sdbDomainHandle  cHandle,
sdbCursorHandle *  cursor 
)

list the collection spaces in domain.

Parameters
[in]cHandleThe domain handle
[out]handleThe cusor handle of result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListDomains ( sdbConnectionHandle  cHandle,
bson *  condition,
bson *  selector,
bson *  orderBy,
sdbCursorHandle *  handle 
)

List the domains.

Parameters
[in]cHandleThe connection handle
[in]conditionThe matching rule, return all the documents if null
[in]selectorThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[out]handleThe cusor handle of result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListGroupsInDomain ( sdbDomainHandle  cHandle,
sdbCursorHandle *  cursor 
)

list the groups in domain.

Parameters
[in]cHandleThe domain handle
[out]handleThe cusor handle of result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListLobPieces ( sdbCollectionHandle  cHandle,
sdbCursorHandle *  cursor 
)

list all the pieces in the lob

Parameters
[in]cHandleThe collection handle
[out]cursorThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListLobs ( sdbCollectionHandle  cHandle,
sdbCursorHandle *  cursor 
)

list all the lobs' meta data in current collection

Parameters
[in]cHandleThe collection handle
[out]cursorThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListProcedures ( sdbConnectionHandle  cHandle,
bson *  condition,
sdbCursorHandle *  handle 
)

List store procedures.

Parameters
[in]cHandleThe collection space space handle
[in]conditionThe condition of list
[out]handleThe cursor handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListReplicaGroups ( sdbConnectionHandle  cHandle,
sdbCursorHandle *  handle 
)

List all the replica groups of current database.

Parameters
[in]cHandleThe database connection handle
[out]handleThe cursor handle of all replica groups
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbListTasks ( sdbConnectionHandle  cHandle,
bson *  condition,
bson *  selector,
bson *  orderBy,
bson *  hint,
sdbCursorHandle *  handle 
)

List the tasks.

Parameters
[in]cHandleThe connection handle
[in]conditionThe matching rule, return all the documents if null
[in]selectorThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[out]handleThe cusor handle of result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbLoadCollectionSpace ( sdbConnectionHandle  cHandle,
const CHAR *  csName,
bson *  options 
)

Load the specified collection space to database from file.

Parameters
[in]cHandleThe database connection handle
[in]csNameThe specified collection space name
[in]optionsThe control options:(Only take effect in coordinate nodes) GroupID:INT32, GroupName:String, NodeID:INT32, HostName:String, svcname:String, ...
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbNext ( sdbCursorHandle  cHandle,
bson *  obj 
)

Return the next document of current cursor, and move forward.

Parameters
[in]cHandleThe cursor handle
[out]objThe return bson object
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbOpenLob ( sdbCollectionHandle  cHandle,
const bson_oid_t *  oid,
INT32  mode,
sdbLobHandle *  lobHandle 
)

create a large object

Parameters
[in]cHandleThe collection handle
[in]oidThe object id
[in]modeThe open mode: SDB_LOB_CREATEONLY/SDB_LOB_READ
[out]lobHandleThe handle of object
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbQuery ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  select,
bson *  orderBy,
bson *  hint,
INT64  numToSkip,
INT64  numToReturn,
sdbCursorHandle *  handle 
)

Get the matching documents in current collection.

Parameters
[in]cHandleThe collection handle
[in]conditionThe matching rule, return all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, never skip if this parameter is 0
[in]numToReturnOnly return numToReturn documents, return all if this parameter is -1
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbQuery1 ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  select,
bson *  orderBy,
bson *  hint,
INT64  numToSkip,
INT64  numToReturn,
INT32  flag,
sdbCursorHandle *  handle 
)

Get the matching documents in current collection.

Parameters
[in]cHandleThe collection handle
[in]conditionThe matching rule, return all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, never skip if this parameter is 0
[in]numToReturnOnly return numToReturn documents, return all if this parameter is -1
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
QUERY_FORCE_HINT
QUERY_PARALLED
QUERY_WITH_RETURNDATA
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbQueryAndRemove ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  select,
bson *  orderBy,
bson *  hint,
INT64  numToSkip,
INT64  numToReturn,
INT32  flag,
sdbCursorHandle *  handle 
)

Get the matching documents in current collection and remove.

Parameters
[in]cHandleThe collection handle
[in]conditionThe matching rule, return all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, never skip if this parameter is 0
[in]numToReturnOnly return numToReturn documents, return all if this parameter is -1
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
FLG_QUERY_FORCE_HINT
FLG_QUERY_PARALLED
FLG_QUERY_WITH_RETURNDATA
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbQueryAndUpdate ( sdbCollectionHandle  cHandle,
bson *  condition,
bson *  select,
bson *  orderBy,
bson *  hint,
bson *  update,
INT64  numToSkip,
INT64  numToReturn,
INT32  flag,
BOOLEAN  returnNew,
sdbCursorHandle *  handle 
)

Get the matching documents in current collection and update.

Parameters
[in]cHandleThe collection handle
[in]conditionThe matching rule, return all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[in]updateThe update rule, can't be null
[in]numToSkipSkip the first numToSkip documents, never skip if this parameter is 0
[in]numToReturnOnly return numToReturn documents, return all if this parameter is -1
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
QUERY_FORCE_HINT
QUERY_PARALLED
QUERY_WITH_RETURNDATA
[in]returnNewWhen TRUE, returns the updated document rather than the original
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbReadLob ( sdbLobHandle  lobHandle,
UINT32  len,
CHAR *  buf,
UINT32 *  read 
)

read lob

Parameters
[in]lobHandleThe large object handle
[in]lenThe length want to read
[out]bufPut the data into buf
[out]readThe length of read
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbReelect ( sdbReplicaGroupHandle  cHandle,
const bson *  options 
)
Parameters
[in]cHandleThe replica group handle
[in]optionsThe options of reelection
Return values
SDB_OKOperation Success
OthersOperation Fail
void sdbReleaseCollection ( sdbCollectionHandle  cHandle)

Release collection handle, the cursor handle of this collection will still available.

Parameters
[in]cHandleThe collection handle
void sdbReleaseConnection ( sdbConnectionHandle  cHandle)

Release the database connection handle.

Parameters
[in]cHandleThe database connection handle
void sdbReleaseCS ( sdbCSHandle  cHandle)

Release the collection space handle, the collecion and cursor handle of this collection space will still available.

Parameters
[in]cHandleThe database connection handle
void sdbReleaseCursor ( sdbCursorHandle  cHandle)

Release the cursor handle.

Parameters
[in]cHandleThe cursor handle
void sdbReleaseDomain ( sdbDomainHandle  cHandle)

Release the domain handle.

Parameters
[in]cHandlethe domain handle
void sdbReleaseNode ( sdbNodeHandle  cHandle)

Release the node handle.

Parameters
[in]cHandleThe node handle
void sdbReleaseReplicaGroup ( sdbReplicaGroupHandle  cHandle)

Release the replica group handle.

Parameters
[in]cHandleThe replica group handle
INT32 sdbReloadConfig ( sdbConnectionHandle  cHandle,
bson *  options 
)

Force the node to reload configs online.

Parameters
[in]cHandleThe database connection handle
[in]optionsThe control options:(Only take effect in coordinate nodes) GroupID:INT32, GroupName:String, NodeID:INT32, HostName:String, svcname:String, ...
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbRemoveBackup ( sdbConnectionHandle  cHandle,
bson *  options 
)

Remove the backups.

Parameters
[in]cHandleThe connection handle
[in]optionsContains configuration infomations for remove backups, remove all the backups in the default backup path if null. The "options" contains 3 options as below. All the elements in options are optional. eg: {"GroupName":["RGName1", "RGName2"], "Path":"/opt/sequoiadb/backup", "Name":"backupName"}
GroupID     : Specified the group id of the backups, default to list all the backups of all the groups.
GroupName   : Specified the group name of the backups, default to list all the backups of all the groups.
Path        : Specified the path of the backups, default to use the backup path asigned in the configuration file.
Name        : Specified the name of backup, default to list all the backups.
IsSubDir    : Specified the "Path" is a subdirectory of the backup path assigned in the configuration file or not, default to be false.
Prefix      : Specified the prefix name of the backups, support for using wildcards("%g","%G","%h","%H","%s","%s"),such as: Prefix:"%g_bk_", default to not using wildcards.
Detail      : Display the detail of the backups or not, default to be false.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbRemoveLob ( sdbCollectionHandle  cHandle,
const bson_oid_t *  oid 
)

remove lob

Parameters
[in]cHandleThe handle of collection
[in]oidThe large object id
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbRemoveNode ( sdbReplicaGroupHandle  cHandle,
const CHAR *  pHostName,
const CHAR *  pServiceName,
bson *  configure 
)

remove node in a given replica group

Parameters
[in]cHandleThe replica group handle
[in]pHostNameThe hostname for the node
[in]pServiceNameThe servicename for the node
[in]configureThe configurations for the node
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbRemoveReplicaGroup ( sdbConnectionHandle  cHandle,
const CHAR *  pRGName 
)

Remove the specified replica group.

Parameters
[in]cHandleThe database connection handle
[in]pRGNameThe name of the replica group
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbRemoveUsr ( sdbConnectionHandle  cHandle,
const CHAR *  pUsrName,
const CHAR *  pPasswd 
)

Delete an account.

Parameters
[in]cHandleThe database connection handle
[in]pUsrNameThe User's Name of the account
[in]pPasswdThe Password of the account
Return values
SDB_OKConnection Success
OthersConnection Fail
INT32 sdbRenameCollection ( sdbCSHandle  cHandle,
const CHAR *  pOldName,
const CHAR *  pNewName,
bson *  options 
)

Rename collection name.

Parameters
[in]cHandleThe collection space handle
[in]pOldNameThe old collection short name
[in]pNewNameThe new collection short name
[in]optionsReserved
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbRenameCollectionSpace ( sdbConnectionHandle  cHandle,
const CHAR *  pOldName,
const CHAR *  pNewName,
bson *  options 
)

Rename the collectionspace name.

Parameters
[in]cHandleThe database connection handle
[in]pOldNameThe old collection space name
[in]pNewNameThe new collection space name
[in]optionsReserved
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbResetSnapshot ( sdbConnectionHandle  cHandle,
bson *  condition 
)

Reset the snapshot.

Parameters
[in]cHandleThe connection handle
[in]conditionThe control options are as below: (please visit the official website to search "Location Elements" for more detail.) GroupID :INT32, GroupName :String, NodeID :INT32, HostName :String, svcname :String, ...
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbRmProcedure ( sdbConnectionHandle  cHandle,
const CHAR *  spName 
)

remove a store procedure.

Parameters
[in]cHandleThe collection space space handle
[in]spNameThe name of store procedure
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbSecureConnect ( const CHAR *  pHostName,
const CHAR *  pServiceName,
const CHAR *  pUsrName,
const CHAR *  pPasswd,
sdbConnectionHandle *  handle 
)

Connect to database with SSL.

Parameters
[in]pHostNameThe Host Name or IP Address of Database Server
[in]pServiceNameThe Service Name or Port of Database Server
[in]pUsrNameThe User's Name of the account
[in]pPasswdThe Password of the account
[out]handleThe database connection handle, when fail to connect, *handle == SDB_INVALID_HANDLE and error code is return
Return values
SDB_OKConnection Success
OthersConnection Fail
INT32 sdbSecureConnect1 ( const CHAR **  pConnAddrs,
INT32  arrSize,
const CHAR *  pUsrName,
const CHAR *  pPasswd,
sdbConnectionHandle *  handle 
)

Connect to database used a random valid address in the array, with SSL.

Parameters
[in]pConnAddrsThe array of the coord's address
[in]arrSizeThe size of the array
[in]pUsrNameThe User's Name of the account
[in]pPasswdThe Password of the account
[out]handleThe database connection handle
Return values
SDB_OKConnection Success
OthersConnection Fail
INT32 sdbSeekLob ( sdbLobHandle  lobHandle,
SINT64  size,
SDB_LOB_SEEK  whence 
)

seek the place to read

Parameters
[in]lobHandleThe large object handle
[in]sizeThe size of seek
[in]whenceThe whence of seek
Return values
SDB_OKOperation Success
OthersOperation Fail
void sdbSetConnectionInterruptFunc ( sdbConnectionHandle  cHandle,
socketInterruptFunc  func 
)
Parameters
[in]cHandleThe handle of connection.
[in]funcThe function that check the app is interrupt or not
Return values
void
INT32 sdbSetErrorOnReplyCallback ( ERROR_ON_REPLY_FUNC  func)

Set the callback function when reply message if error from server.

Parameters
[in]funcThe callback function when called on reply error
INT32 sdbSetPDLevel ( sdbConnectionHandle  cHandle,
INT32  pdLevel,
bson *  options 
)

Set the node's diagnostic level.

Parameters
[in]cHandleThe database connection handle
[in]pdLevelDiagnostic level, value:[0~5]
[in]optionsThe control options:(Only take effect in coordinate nodes) GroupID:INT32, GroupName:String, NodeID:INT32, HostName:String, svcname:String, ...
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbSetSessionAttr ( sdbConnectionHandle  cHandle,
bson *  options 
)

Set the attributes of the session.

Parameters
[in]cHandleThe connection handle
[in]optionsThe configuration options for session.The options are as below:
PreferedInstance : Preferred instance for read request in the current session. Could be single value in "M", "m", "S", "s", "A", "a", 1-255, or BSON Array to include multiple values.
                   e.g. { "PreferedInstance" : [ 1, 7 ] }.
                   "M", "m": read and write instance( master instance ). If multiple numeric instances are given with "M", matched master instance will be chosen in higher priority. If multiple numeric instances are given with "M" or "m", master instance will be chosen if no numeric instance is matched.
                   "S", "s": read only instance( slave instance ). If multiple numeric instances are given with "S", matched slave instances will be chosen in higher priority. If multiple numeric instances are given with "S" or "s", slave instance will be chosen if no numeric instance is matched.
                   "A", "a": any instance.
                   1-255: the instance with specified instance ID.
                   If multiple alphabet instances are given, only first one will be used.
                   If matched instance is not found, will choose instance by random.
PreferedInstanceMode : The mode to choose query instance when multiple preferred instances are found in the current session.
                       e.g. { "PreferedInstanceMode : "random" }.
                       "random": choose the instance from matched instances by random.
                       "ordered": choose the instance from matched instances by the order of "PreferedInstance".
Timeout : The timeout (in ms) for operations in the current session. -1 means no timeout for operations.
          e.g. { "Timeout" : 10000 }.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbSplitCLAsync ( sdbCollectionHandle  cHandle,
const CHAR *  pSourceRG,
const CHAR *  pTargetRG,
const bson *  pSplitCondition,
const bson *  pSplitEndCondition,
SINT64 *  taskID 
)

Split the specified collection from source replica group to target by range.

Parameters
[in]cHandleThe collection handle
[in]pSourceRGThe source replica group name
[in]pTargetRGThe target replica group name
[in]pSplitConditionThe split condition
[in]splitEndConditionThe split end condition or null eg:If we create a collection with the option {ShardingKey:{"age":1},ShardingType:"Hash",Partition:2^10}, we can fill {age:30} as the splitCondition, and fill {age:60} as the splitEndCondition. when split, the target replica group will get the records whose age's hash value are in [30,60). If splitEndCondition is null, they are in [30,max).
[out]taskIDThe id of current task
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbSplitCLByPercentAsync ( sdbCollectionHandle  cHandle,
const CHAR *  pSourceRG,
const CHAR *  pTargetRG,
FLOAT64  percent,
SINT64 *  taskID 
)

Split the specified collection from source replica group to target by percent.

Parameters
[in]cHandleThe collection handle
[in]pSourceRGThe source replica group name
[in]pTargetRGThe target replica group name
[in]percentThe split percent, Range:(0.0, 100.0]
[out]taskIDThe id of current task
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbSplitCollection ( sdbCollectionHandle  cHandle,
const CHAR *  pSourceRG,
const CHAR *  pTargetRG,
const bson *  pSplitCondition,
const bson *  pSplitEndCondition 
)

Split the specified collection from source replica group to target by range.

Parameters
[in]cHandleThe collection handle
[in]pSourceRGThe source replica group name
[in]pTargetRGThe target replica group name
[in]pSplitConditionThe split condition
[in]splitEndConditionThe split end condition or null eg:If we create a collection with the option {ShardingKey:{"age":1},ShardingType:"Hash",Partition:2^10}, we can fill {age:30} as the splitCondition, and fill {age:60} as the splitEndCondition. when split, the target replica group will get the records whose age's hash value are in [30,60). If splitEndCondition is null, they are in [30,max).
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbSplitCollectionByPercent ( sdbCollectionHandle  cHandle,
const CHAR *  pSourceRG,
const CHAR *  pTargetRG,
FLOAT64  percent 
)

Split the specified collection from source replica group to target by percent.

Parameters
[in]cHandleThe collection handle
[in]pSourceRGThe source replica group name
[in]pTargetRGThe target replica group name
[in]percentThe split percent, Range:(0.0, 100.0]
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbStartNode ( sdbNodeHandle  cHandle)

Start up the specified node.

Parameters
[in]cHandleThe node handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbStartReplicaGroup ( sdbReplicaGroupHandle  cHandle)

Start and activate the specified replica group.

Parameters
[in]cHandleThe replica group handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbStopNode ( sdbNodeHandle  cHandle)

Stop the specified node.

Parameters
[in]cHandleThe node handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbStopReplicaGroup ( sdbReplicaGroupHandle  cHandle)

Stop the specified replica group.

Parameters
[in]cHandleThe replica group handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbSyncDB ( sdbConnectionHandle  cHandle,
bson *  options 
)

sync database which are specified

Parameters
[in]cHandleThe database connection handle
[in]optionsThe control options: Deep: (INT32) Flush with deep mode or not. 1 in default. 0 for non-deep mode,1 for deep mode,-1 means use the configuration with server Block: (Bool) Flush with block mode or not. false in default. CollectionSpace: (String) Specify the collectionspace to sync. If not set, will sync all the collectionspaces and logs, otherwise, will only sync the collectionspace specified. Others:(Only take effect in coordinate nodes) GroupID:INT32, GroupName:String, NodeID:INT32, HostName:String, svcname:String ...
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbTraceResume ( sdbConnectionHandle  cHandle)

Resume trace.

Parameters
[in]cHandleThe connection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbTraceStart ( sdbConnectionHandle  cHandle,
UINT32  traceBufferSize,
CHAR *  component,
CHAR *  breakpoint 
)

Start trace with given trace buffer size and component list.

Parameters
[in]cHandleThe connection handle
[in]traceBufferSizeThe size for trace buffer on bytes
[in]componentThe trace component list as below, NULL for all components, separated by comma (,)
auth   : Authentication
bps    : BufferPool Services
cat    : Catalog Services
cls    : Cluster Services
dps    : Data Protection Services
mig    : Migration Services
msg    : Messaging Services
net    : Network Services
oss    : Operating System Services
pd     : Problem Determination
rtn    : RunTime
sql    : SQL Parser
tools  : Tools
bar    : Backup And Recovery
client : Client
coord  : Coord Services
dms    : Data Management Services
ixm    : Index Management Services
mon    : Monitoring Services
mth    : Methods Services
opt    : Optimizer
pmd    : Process Model
rest   : RESTful Services
spt    : Scripting
util   : Utilities
[in]breakpointThe functions need to break, separated by comma (,)
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbTraceStatus ( sdbConnectionHandle  cHandle,
sdbCursorHandle *  handle 
)

Get the current status for trace.

Parameters
[in]cHandleThe connection handle
[out]handleThe cursor handle of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbTraceStop ( sdbConnectionHandle  cHandle,
const CHAR *  pDumpFileName 
)

Stop trace and dump into file.

Parameters
[in]cHandleThe connection handle
[in]pDumpFileNameThe file to dump, NULL for stop only
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbTransactionBegin ( sdbConnectionHandle  cHandle)

Transaction begin.

Parameters
[in]cHandleThe database connection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbTransactionCommit ( sdbConnectionHandle  cHandle)

Transaction commit.

Parameters
[in]cHandleThe database connection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbTransactionRollback ( sdbConnectionHandle  cHandle)

Transaction rollback.

Parameters
[in]cHandleThe database connection handle
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbTruncateCollection ( sdbConnectionHandle  cHandle,
const CHAR *  fullName 
)

truncate the collection

Parameters
[in]cHandleThe handle of connection.
[in]fullNameThe full name of collection to be truncated, eg: foo.bar.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbUnloadCollectionSpace ( sdbConnectionHandle  cHandle,
const CHAR *  csName,
bson *  options 
)

Unload the specified collection space from database.

Parameters
[in]cHandleThe database connection handle
[in]csNameThe specified collection space name
[in]optionsThe control options:(Only take effect in coordinate nodes) GroupID:INT32, GroupName:String, NodeID:INT32, HostName:String, svcname:String, ...
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbUpdate ( sdbCollectionHandle  cHandle,
bson *  rule,
bson *  condition,
bson *  hint 
)

Update the matching documents in current collection.

Parameters
[in]cHandleThe collection handle
[in]ruleThe updating rule, cannot be null
[in]conditionThe matching rule, update all the documents if this parameter is null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
Return values
SDB_OKOperation Success
OthersOperation Fail
Note
It won't work to update the "ShardingKey" field, but the other fields take effect
INT32 sdbUpsert ( sdbCollectionHandle  cHandle,
bson *  rule,
bson *  condition,
bson *  hint 
)

Update the matching documents in current collection, insert if no matching.

Parameters
[in]cHandleThe collection handle
[in]ruleThe updating rule, cannot be null
[in]conditionThe matching rule, update all the documents if this parameter is null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
Return values
SDB_OKOperation Success
OthersOperation Fail
Note
It won't work to upsert the "ShardingKey" field, but the other fields take effect
INT32 sdbUpsert1 ( sdbCollectionHandle  cHandle,
bson *  rule,
bson *  condition,
bson *  hint,
bson *  setOnInsert 
)

Update the matching documents in current collection, insert if no matching.

Parameters
[in]cHandleThe collection handle
[in]ruleThe updating rule, cannot be null
[in]conditionThe matching rule, update all the documents if this parameter is null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is null, database automatically match the optimal index to scan data
[in]setOnInsertThe setOnInsert assigns the specified values to the fileds when insert
Return values
SDB_OKOperation Success
OthersOperation Fail
Note
It won't work to upsert the "ShardingKey" field, but the other fields take effect
INT32 sdbWaitTasks ( sdbConnectionHandle  cHandle,
const SINT64 *  taskIDs,
SINT32  num 
)

Wait the tasks to finish.

Parameters
[in]cHandleThe connection handle
[in]taskIDsThe array of task id
[in]numThe number of task id
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbWriteLob ( sdbLobHandle  lobHandle,
const CHAR *  buf,
UINT32  len 
)

write lob

Parameters
[in]lobHandleThe large object handle
[in]bufThe buf of write
[in]lenThe length of write
Return values
SDB_OKOperation Success
OthersOperation Fail