SequoiaDB
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
client.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  Copyright (C) 2011-2018 SequoiaDB Ltd.
4 
5  Licensed under the Apache License, Version 2.0 (the "License");
6  you may not use this file except in compliance with the License.
7  You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 *******************************************************************************/
21 #ifndef CLIENT_H__
22 #define CLIENT_H__
23 #include "core.h"
24 #include "ossTypes.h"
25 #include "bson/bson.h"
26 #include "jstobs.h"
27 #include "spd.h"
28 #include "clientDef.h"
29 
30 SDB_EXTERN_C_START
31 
32 #define SDB_PAGESIZE_4K 4096
33 #define SDB_PAGESIZE_8K 8192
34 #define SDB_PAGESIZE_16K 16384
35 #define SDB_PAGESIZE_32K 32768
36 #define SDB_PAGESIZE_64K 65536
37 
38 #define SDB_PAGESIZE_DEFAULT 0
39 
41 {
42  SDB_LOB_CREATEONLY = 0x00000001,
43  SDB_LOB_READ = 0x00000004,
44  SDB_LOB_WRITE = 0x00000008
45 } ;
46 typedef enum _SDB_LOB_OPEN_MODE SDB_LOB_OPEN_MODE ;
47 
49 {
53 } ;
54 typedef enum _SDB_LOB_SEEK SDB_LOB_SEEK ;
55 
56 #define SDB_INVALID_HANDLE ((ossValuePtr) 0)
57 typedef ossValuePtr sdbConnectionHandle ;
58 typedef ossValuePtr sdbCSHandle ;
59 typedef ossValuePtr sdbCollectionHandle ;
60 typedef ossValuePtr sdbCursorHandle ;
61 typedef ossValuePtr sdbReplicaGroupHandle ;
62 typedef ossValuePtr sdbNodeHandle ;
63 typedef ossValuePtr sdbDomainHandle ;
64 typedef ossValuePtr sdbLobHandle ;
65 typedef ossValuePtr sdbDCHandle ;
66 
68 typedef void (*ERROR_ON_REPLY_FUNC)( const CHAR *pErrorObj,
69  UINT32 objSize,
70  INT32 flag,
71  const CHAR *pDescription,
72  const CHAR *pDetail ) ;
73 
78 SDB_EXPORT void sdbSetErrorOnReplyCallback( ERROR_ON_REPLY_FUNC func ) ;
79 
81 typedef sdbNodeHandle sdbReplicaNodeHandle ;
82 
84 #define sdbCreateReplicaNode sdbCreateNode
85 
86 #define sdbRemoveReplicaNode sdbRemoveNode
87 
88 #define sdbGetReplicaNodeMaster sdbGetNodeMaster
89 
90 #define sdbGetReplicaNodeSlave sdbGetNodeSlave
91 
92 #define sdbGetReplicaNodeByName sdbGetNodeByName
93 
94 #define sdbGetReplicaNodeByHost sdbGetNodeByHost
95 
96 #define sdbGetReplicaNodeSddr sdbGetNodeAddr
97 
98 #define sdbStartReplicaNode sdbStartNode
99 
100 #define sdbStopReplicaNode sdbStopNode
101 
102 #define sdbReleaseReplicaNode sdbReleaseNode
103 
105 #define QUERY_FORCE_HINT 0x00000080
106 
107 #define QUERY_PARALLED 0x00000100
108 
109 #define QUERY_WITH_RETURNDATA 0x00000200
110 
111 #define QUERY_PREPARE_MORE 0x00004000
112 
113 #define QUERY_KEEP_SHARDINGKEY_IN_UPDATE 0x00008000
114 
119 #define QUERY_FOR_UPDATE 0x00010000
120 
121 
123 #define FLG_INSERT_CONTONDUP 0x00000001
124 
125 // #define FLG_INSERT_RETURNNUM 0x00000002
127 #define FLG_INSERT_REPLACEONDUP 0x00000004
128 
129 #define FLG_INSERT_RETURN_OID 0x10000000
130 
132 #define UPDATE_KEEP_SHARDINGKEY QUERY_KEEP_SHARDINGKEY_IN_UPDATE
133 
134 // #define UPDATE_RETURNNUM 0x00000004
135 
137 // #define FLG_DELETE_RETURNNUM 0x00000004
138 
145 SDB_EXPORT INT32 initClient( sdbClientConf* config ) ;
146 
162 SDB_EXPORT INT32 sdbGetPasswdByCipherFile( const CHAR *pUsrName,
163  const CHAR *pToken,
164  const CHAR *pCipherFile,
165  CHAR *pUser, CHAR *pPasswd ) ;
166 
181 SDB_EXPORT INT32 sdbConnect ( const CHAR *pHostName, const CHAR *pServiceName,
182  const CHAR *pUsrName, const CHAR *pPasswd ,
183  sdbConnectionHandle *handle ) ;
184 
197 SDB_EXPORT INT32 sdbConnect1 ( const CHAR **pConnAddrs, INT32 arrSize,
198  const CHAR *pUsrName, const CHAR *pPasswd ,
199  sdbConnectionHandle *handle ) ;
200 
215 SDB_EXPORT INT32 sdbSecureConnect ( const CHAR *pHostName, const CHAR *pServiceName,
216  const CHAR *pUsrName, const CHAR *pPasswd ,
217  sdbConnectionHandle *handle ) ;
218 
231 SDB_EXPORT INT32 sdbSecureConnect1 ( const CHAR **pConnAddrs, INT32 arrSize,
232  const CHAR *pUsrName, const CHAR *pPasswd ,
233  sdbConnectionHandle *handle ) ;
234 
239 SDB_EXPORT void sdbDisconnect ( sdbConnectionHandle handle ) ;
240 
250 SDB_EXPORT INT32 sdbCreateUsr( sdbConnectionHandle cHandle, const CHAR *pUsrName,
251  const CHAR *pPasswd ) ;
252 
262 SDB_EXPORT INT32 sdbRemoveUsr( sdbConnectionHandle cHandle, const CHAR *pUsrName,
263  const CHAR *pPasswd ) ;
264 
265 /* \fn INT32 sdbModifyConfig ( sdbConnectionHandle cHandle,
266  bson *config )
267  \brief Modify config for the current node
268  \param [in] cHandle The connection handle
269  \param [in] config The new configurations
270  \retval SDB_OK Modify Success
271  \retval Others Modify Fail
272 
273 SDB_EXPORT INT32 sdbModifyConfig ( sdbConnectionHandle cHandle,
274  bson *config ) ;*/
275 
276 /* \fn INT32 sdbModifyNodeConfig ( sdbConnectionHandle cHandle,
277  INT32 nodeID,
278  bson *config )
279  \brief Modify config for a given node
280  \param [in] cHandle The connection handle
281  \param [in] nodeID The node id that want to be modified
282  \param [in] config The new configurations
283  \retval SDB_OK Modify Success
284  \retval Others Modify Fail
285 
286 SDB_EXPORT INT32 sdbModifyNodeConfig ( sdbConnectionHandle cHandle,
287  INT32 nodeID,
288  bson *config ) ;*/
289 
313 SDB_EXPORT INT32 sdbGetDataBlocks ( sdbCollectionHandle cHandle,
314  bson *condition,
315  bson *select,
316  bson *orderBy,
317  bson *hint,
318  INT64 numToSkip,
319  INT64 numToReturn,
320  sdbCursorHandle *handle );
321 
343 SDB_EXPORT INT32 sdbGetQueryMeta ( sdbCollectionHandle cHandle,
344  bson *condition,
345  bson *orderBy,
346  bson *hint,
347  INT64 numToSkip,
348  INT64 numToReturn,
349  sdbCursorHandle *handle ) ;
350 
385 SDB_EXPORT INT32 sdbGetSnapshot ( sdbConnectionHandle cHandle,
386  INT32 snapType,
387  bson *condition,
388  bson *selector,
389  bson *orderBy,
390  sdbCursorHandle *handle ) ;
391 
433 SDB_EXPORT INT32 sdbGetSnapshot1 ( sdbConnectionHandle cHandle,
434  INT32 snapType,
435  bson *condition,
436  bson *selector,
437  bson *orderBy,
438  bson *hint,
439  INT64 numToSkip,
440  INT64 numToReturn,
441  sdbCursorHandle *handle ) ;
442 
467 SDB_EXPORT INT32 sdbResetSnapshot ( sdbConnectionHandle cHandle,
468  bson *options ) ;
469 
512 SDB_EXPORT INT32 sdbTraceStart ( sdbConnectionHandle cHandle,
513  UINT32 traceBufferSize,
514  CHAR * component,
515  CHAR * breakPoint ,
516  UINT32 *tids,
517  UINT32 nTids ) ;
524 SDB_EXPORT INT32 sdbTraceResume ( sdbConnectionHandle cHandle ) ;
525 
534 SDB_EXPORT INT32 sdbTraceStop ( sdbConnectionHandle cHandle,
535  const CHAR *pDumpFileName ) ;
536 
545 SDB_EXPORT INT32 sdbTraceStatus ( sdbConnectionHandle cHandle,
546  sdbCursorHandle *handle ) ;
547 
583 SDB_EXPORT INT32 sdbGetList ( sdbConnectionHandle cHandle,
584  INT32 listType,
585  bson *condition,
586  bson *selector,
587  bson *orderBy,
588  sdbCursorHandle *handle ) ;
589 
633 SDB_EXPORT INT32 sdbGetList1( sdbConnectionHandle cHandle,
634  INT32 listType,
635  bson *condition,
636  bson *selector,
637  bson *orderBy,
638  bson *hint,
639  INT64 numToSkip,
640  INT64 numToReturn,
641  sdbCursorHandle *handle ) ;
642 
653 SDB_EXPORT INT32 sdbGetCollection ( sdbConnectionHandle cHandle,
654  const CHAR *pCollectionFullName,
655  sdbCollectionHandle *handle ) ;
656 
667 SDB_EXPORT INT32 sdbGetCollectionSpace ( sdbConnectionHandle cHandle,
668  const CHAR *pCollectionSpaceName,
669  sdbCSHandle *handle ) ;
670 
681 SDB_EXPORT INT32 sdbGetReplicaGroup ( sdbConnectionHandle cHandle,
682  const CHAR *pRGName,
683  sdbReplicaGroupHandle *handle ) ;
684 
695 SDB_EXPORT INT32 sdbGetReplicaGroup1 ( sdbConnectionHandle cHandle,
696  UINT32 id,
697  sdbReplicaGroupHandle *handle ) ;
698 
708 SDB_EXPORT INT32 sdbGetReplicaGroupName ( sdbReplicaGroupHandle cHandle,
709  CHAR **ppRGName ) ;
710 
720 SDB_EXPORT INT32 sdbGetRGName ( sdbReplicaGroupHandle cHandle,
721  CHAR *pBuffer, INT32 size ) ;
722 
729 SDB_EXPORT BOOLEAN sdbIsReplicaGroupCatalog ( sdbReplicaGroupHandle cHandle ) ;
730 
752 SDB_EXPORT INT32 sdbCreateCollectionSpace ( sdbConnectionHandle cHandle,
753  const CHAR *pCollectionSpaceName,
754  INT32 iPageSize,
755  sdbCSHandle *handle ) ;
756 
774 SDB_EXPORT INT32 sdbCreateCollectionSpaceV2 ( sdbConnectionHandle cHandle,
775  const CHAR *pCollectionSpaceName,
776  bson *options,
777  sdbCSHandle *handle ) ;
778 
787 SDB_EXPORT INT32 sdbDropCollectionSpace ( sdbConnectionHandle cHandle,
788  const CHAR *pCollectionSpaceName ) ;
789 
800 SDB_EXPORT INT32 sdbCreateReplicaGroup ( sdbConnectionHandle cHandle,
801  const CHAR *pRGName,
802  sdbReplicaGroupHandle *handle ) ;
803 
812 SDB_EXPORT INT32 sdbRemoveReplicaGroup ( sdbConnectionHandle cHandle,
813  const CHAR *pRGName ) ;
814 
821 SDB_EXPORT INT32 sdbStartReplicaGroup ( sdbReplicaGroupHandle cHandle ) ;
822 
831 SDB_EXPORT INT32 sdbGetNodeMaster ( sdbReplicaGroupHandle cHandle,
832  sdbNodeHandle *handle ) ;
833 
843 SDB_EXPORT INT32 sdbGetNodeSlave ( sdbReplicaGroupHandle cHandle,
844  sdbNodeHandle *handle ) ;
845 
860 SDB_EXPORT INT32 sdbGetNodeSlave1 ( sdbReplicaGroupHandle cHandle,
861  const INT32 *positionsArray,
862  INT32 positionsCount,
863  sdbNodeHandle *handle ) ;
864 
865 
877 SDB_EXPORT INT32 sdbGetNodeByName ( sdbReplicaGroupHandle cHandle,
878  const CHAR *pNodeName,
879  sdbNodeHandle *handle ) ;
880 
894 SDB_EXPORT INT32 sdbGetNodeByHost ( sdbReplicaGroupHandle cHandle,
895  const CHAR *pHostName,
896  const CHAR *pServiceName,
897  sdbNodeHandle *handle ) ;
898 
913 SDB_EXPORT INT32 sdbGetNodeAddr ( sdbNodeHandle cHandle,
914  const CHAR **ppHostName,
915  const CHAR **ppServiceName,
916  const CHAR **ppNodeName,
917  INT32 *pNodeID ) ;
918 
925 SDB_EXPORT INT32 sdbStartNode ( sdbNodeHandle cHandle ) ;
926 
933 SDB_EXPORT INT32 sdbStopNode ( sdbNodeHandle cHandle ) ;
934 
941 SDB_EXPORT INT32 sdbStopReplicaGroup ( sdbReplicaGroupHandle cHandle ) ;
942 
957 SDB_EXPORT INT32 sdbCreateReplicaCataGroup ( sdbConnectionHandle cHandle,
958  const CHAR *pHostName,
959  const CHAR *pServiceName,
960  const CHAR *pDatabasePath,
961  bson *configure );
962 
977 SDB_EXPORT INT32 sdbCreateNode ( sdbReplicaGroupHandle cHandle,
978  const CHAR *pHostName,
979  const CHAR *pServiceName,
980  const CHAR *pDatabasePath,
981  bson *configure ) ;
982 
995 SDB_EXPORT INT32 sdbRemoveNode ( sdbReplicaGroupHandle cHandle,
996  const CHAR *pHostName,
997  const CHAR *pServiceName,
998  bson *configure ) ;
999 
1008 SDB_EXPORT INT32 sdbListCollectionSpaces ( sdbConnectionHandle cHandle,
1009  sdbCursorHandle *handle ) ;
1010 
1019 SDB_EXPORT INT32 sdbListCollections ( sdbConnectionHandle cHandle,
1020  sdbCursorHandle *handle ) ;
1021 
1031 SDB_EXPORT INT32 sdbListSequences ( sdbConnectionHandle cHandle,
1032  sdbCursorHandle *handle ) ;
1033 
1042 SDB_EXPORT INT32 sdbListReplicaGroups ( sdbConnectionHandle cHandle,
1043  sdbCursorHandle *handle ) ;
1044 
1067 SDB_EXPORT INT32 sdbFlushConfigure( sdbConnectionHandle cHandle,
1068  bson *options ) ;
1069 
1078 SDB_EXPORT INT32 sdbCrtJSProcedure( sdbConnectionHandle cHandle,
1079  const CHAR *code ) ;
1080 
1089 SDB_EXPORT INT32 sdbRmProcedure( sdbConnectionHandle cHandle,
1090  const CHAR *spName ) ;
1091 
1092 
1103 SDB_EXPORT INT32 sdbListProcedures( sdbConnectionHandle cHandle,
1104  bson *condition,
1105  sdbCursorHandle *handle ) ;
1106 
1123 SDB_EXPORT INT32 sdbEvalJS( sdbConnectionHandle cHandle,
1124  const CHAR *code,
1125  SDB_SPD_RES_TYPE *type,
1126  sdbCursorHandle *handle,
1127  bson *errmsg ) ;
1128 
1139 SDB_EXPORT INT32 sdbGetCollection1 ( sdbCSHandle cHandle,
1140  const CHAR *pCollectionName,
1141  sdbCollectionHandle *handle ) ;
1142 
1156 SDB_EXPORT INT32 sdbCreateCollection ( sdbCSHandle cHandle,
1157  const CHAR *pCollectionName,
1158  sdbCollectionHandle *handle ) ;
1159 
1176 SDB_EXPORT INT32 sdbCreateCollection1 ( sdbCSHandle cHandle,
1177  const CHAR *pCollectionName,
1178  bson *options,
1179  sdbCollectionHandle *handle ) ;
1180 
1203 SDB_EXPORT INT32 sdbAlterCollection ( sdbCollectionHandle cHandle,
1204  bson *options ) ;
1205 
1214 SDB_EXPORT INT32 sdbDropCollection ( sdbCSHandle cHandle,
1215  const CHAR *pCollectionName ) ;
1216 
1226 SDB_EXPORT INT32 sdbGetCSName ( sdbCSHandle cHandle,
1227  CHAR *pBuffer, INT32 size ) ;
1228 
1241 SDB_EXPORT INT32 sdbRenameCollection( sdbCSHandle cHandle,
1242  const CHAR *pOldName,
1243  const CHAR *pNewName,
1244  bson *options ) ;
1245 
1259 SDB_EXPORT INT32 sdbAlterCollectionSpace ( sdbCSHandle cHandle,
1260  bson * options ) ;
1261 
1273 SDB_EXPORT INT32 sdbCSSetDomain ( sdbCSHandle cHandle,
1274  bson * options ) ;
1275 
1282 SDB_EXPORT INT32 sdbCSRemoveDomain ( sdbCSHandle cHandle ) ;
1283 
1289 SDB_EXPORT INT32 sdbCSEnableCapped ( sdbCSHandle cHandle ) ;
1290 
1297 SDB_EXPORT INT32 sdbCSDisableCapped ( sdbCSHandle cHandle ) ;
1298 
1312 SDB_EXPORT INT32 sdbCSSetAttributes ( sdbCSHandle cHandle,
1313  bson * options ) ;
1314 
1324 SDB_EXPORT INT32 sdbGetCLName ( sdbCollectionHandle cHandle,
1325  CHAR *pBuffer, INT32 size ) ;
1326 
1336 SDB_EXPORT INT32 sdbGetCLFullName ( sdbCollectionHandle cHandle,
1337  CHAR *pBuffer, INT32 size ) ;
1338 
1357 SDB_EXPORT INT32 sdbSplitCollection ( sdbCollectionHandle cHandle,
1358  const CHAR *pSourceRG,
1359  const CHAR *pTargetRG,
1360  const bson *pSplitCondition,
1361  const bson *pSplitEndCondition ) ;
1362 
1383 SDB_EXPORT INT32 sdbSplitCLAsync ( sdbCollectionHandle cHandle,
1384  const CHAR *pSourceRG,
1385  const CHAR *pTargetRG,
1386  const bson *pSplitCondition,
1387  const bson *pSplitEndCondition,
1388  SINT64 *taskID ) ;
1389 
1402 SDB_EXPORT INT32 sdbSplitCollectionByPercent ( sdbCollectionHandle cHandle,
1403  const CHAR *pSourceRG,
1404  const CHAR *pTargetRG,
1405  FLOAT64 percent ) ;
1406 
1421 SDB_EXPORT INT32 sdbSplitCLByPercentAsync ( sdbCollectionHandle cHandle,
1422  const CHAR *pSourceRG,
1423  const CHAR *pTargetRG,
1424  FLOAT64 percent,
1425  SINT64 *taskID ) ;
1426 
1442 SDB_EXPORT INT32 sdbCreateIndex ( sdbCollectionHandle cHandle,
1443  bson *indexDef,
1444  const CHAR *pIndexName,
1445  BOOLEAN isUnique,
1446  BOOLEAN isEnforced ) ;
1447 
1466 SDB_EXPORT INT32 sdbCreateIndex1 ( sdbCollectionHandle cHandle,
1467  bson *indexDef,
1468  const CHAR *pIndexName,
1469  BOOLEAN isUnique,
1470  BOOLEAN isEnforced,
1471  INT32 sortBufferSize ) ;
1472 
1493 SDB_EXPORT INT32 sdbCreateIndex2 ( sdbCollectionHandle cHandle,
1494  bson *indexDef,
1495  const CHAR *pIndexName,
1496  bson *options ) ;
1497 
1509 SDB_EXPORT INT32 sdbGetIndexes ( sdbCollectionHandle cHandle,
1510  const CHAR *pIndexName,
1511  sdbCursorHandle *handle ) ;
1512 
1523 SDB_EXPORT INT32 sdbGetIndex ( sdbCollectionHandle cHandle,
1524  const CHAR *pIndexName,
1525  bson *info ) ;
1526 
1527 
1536 SDB_EXPORT INT32 sdbGetIndexInfo ( sdbCollectionHandle cHandle,
1537  sdbCursorHandle *handle ) ;
1538 
1539 
1548 SDB_EXPORT INT32 sdbDropIndex ( sdbCollectionHandle cHandle,
1549  const CHAR *pIndexName ) ;
1550 
1561 SDB_EXPORT INT32 sdbGetCount ( sdbCollectionHandle cHandle,
1562  bson *condition,
1563  SINT64 *count );
1564 
1565 
1581 SDB_EXPORT INT32 sdbGetCount1 ( sdbCollectionHandle cHandle,
1582  bson *condition,
1583  bson *hint,
1584  SINT64 *count );
1585 
1594 SDB_EXPORT INT32 sdbInsert ( sdbCollectionHandle cHandle,
1595  bson *obj ) ;
1596 
1615 SDB_EXPORT INT32 sdbInsert1 ( sdbCollectionHandle cHandle,
1616  bson *obj, bson_iterator *pId ) ;
1617 
1618 
1662 SDB_EXPORT INT32 sdbInsert2 ( sdbCollectionHandle cHandle,
1663  bson *obj, INT32 flags, bson *pResult ) ;
1664 
1721 SDB_EXPORT INT32 sdbBulkInsert ( sdbCollectionHandle cHandle,
1722  SINT32 flags, bson **objs, SINT32 num ) ;
1723 
1769 SDB_EXPORT INT32 sdbBulkInsert2 ( sdbCollectionHandle cHandle,
1770  SINT32 flags, bson **objs,
1771  SINT32 num,
1772  bson *pResult ) ;
1773 
1790 SDB_EXPORT INT32 sdbUpdate ( sdbCollectionHandle cHandle,
1791  bson *rule,
1792  bson *condition,
1793  bson *hint ) ;
1794 
1817 SDB_EXPORT INT32 sdbUpdate1 ( sdbCollectionHandle cHandle,
1818  bson *rule,
1819  bson *condition,
1820  bson *hint,
1821  INT32 flag ) ;
1822 
1839 SDB_EXPORT INT32 sdbUpsert ( sdbCollectionHandle cHandle,
1840  bson *rule,
1841  bson *condition,
1842  bson *hint ) ;
1843 
1862 SDB_EXPORT INT32 sdbUpsert1 ( sdbCollectionHandle cHandle,
1863  bson *rule,
1864  bson *condition,
1865  bson *hint,
1866  bson *setOnInsert ) ;
1867 
1892 SDB_EXPORT INT32 sdbUpsert2 ( sdbCollectionHandle cHandle,
1893  bson *rule,
1894  bson *condition,
1895  bson *hint,
1896  bson *setOnInsert,
1897  INT32 flag ) ;
1898 
1912 SDB_EXPORT INT32 sdbDelete ( sdbCollectionHandle cHandle,
1913  bson *condition,
1914  bson *hint ) ;
1915 
1947 SDB_EXPORT INT32 sdbQuery1 ( sdbCollectionHandle cHandle,
1948  bson *condition,
1949  bson *select,
1950  bson *orderBy,
1951  bson *hint,
1952  INT64 numToSkip,
1953  INT64 numToReturn,
1954  INT32 flags,
1955  sdbCursorHandle *handle ) ;
1956 
1957 
1981 SDB_EXPORT INT32 sdbQuery ( sdbCollectionHandle cHandle,
1982  bson *condition,
1983  bson *select,
1984  bson *orderBy,
1985  bson *hint,
1986  INT64 numToSkip,
1987  INT64 numToReturn,
1988  sdbCursorHandle *handle ) ;
1989 
2026 SDB_EXPORT INT32 sdbQueryAndUpdate ( sdbCollectionHandle cHandle,
2027  bson *condition,
2028  bson *select,
2029  bson *orderBy,
2030  bson *hint,
2031  bson *update,
2032  INT64 numToSkip,
2033  INT64 numToReturn,
2034  INT32 flag,
2035  BOOLEAN returnNew,
2036  sdbCursorHandle *handle ) ;
2037 
2069 SDB_EXPORT INT32 sdbQueryAndRemove ( sdbCollectionHandle cHandle,
2070  bson *condition,
2071  bson *select,
2072  bson *orderBy,
2073  bson *hint,
2074  INT64 numToSkip,
2075  INT64 numToReturn,
2076  INT32 flag,
2077  sdbCursorHandle *handle ) ;
2078 
2115 SDB_EXPORT INT32 sdbExplain ( sdbCollectionHandle cHandle,
2116  bson *condition,
2117  bson *select,
2118  bson *orderBy,
2119  bson *hint,
2120  INT32 flag,
2121  INT64 numToSkip,
2122  INT64 numToReturn,
2123  bson *options,
2124  sdbCursorHandle *handle ) ;
2125 
2134 SDB_EXPORT INT32 sdbNext ( sdbCursorHandle cHandle,
2135  bson *obj ) ;
2136 
2145 SDB_EXPORT INT32 sdbCurrent ( sdbCursorHandle cHandle,
2146  bson *obj ) ;
2147 
2148 /* \fn INT32 sdbUpdateCurrent ( sdbCursorHandle cHandle, bson *rule )
2149  \brief Update the current document of cursor
2150  \param [in] cHandle The cursor handle
2151  \param [in] rule The updating rule, cannot be null
2152  \retval SDB_OK Operation Success
2153  \retval Others Operation Fail
2154 */
2155 /*
2156 SDB_EXPORT INT32 sdbUpdateCurrent ( sdbCursorHandle cHandle,
2157  bson *rule ) ;
2158 */
2159 /* \fn INT32 sdbDeleteCurrent ( sdbCursorHandle cHandle )
2160  \brief Delete the current document of cursor
2161  \param [in] cHandle The cursor handle
2162  \retval SDB_OK Operation Success
2163  \retval Others Operation Fail
2164 */
2165 /*
2166 SDB_EXPORT INT32 sdbDeleteCurrent ( sdbCursorHandle cHandle ) ;
2167 */
2168 
2177 SDB_EXPORT INT32 sdbCloseCursor ( sdbCursorHandle cHandle ) ;
2178 
2186 SDB_EXPORT INT32 sdbCloseAllCursors ( sdbConnectionHandle cHandle ) ;
2187 
2195 SDB_EXPORT INT32 sdbInterrupt ( sdbConnectionHandle cHandle ) ;
2196 
2206 SDB_EXPORT INT32 sdbInterruptOperation ( sdbConnectionHandle cHandle ) ;
2207 
2208 
2219 SDB_EXPORT INT32 sdbExec( sdbConnectionHandle cHandle,
2220  const CHAR *sql,
2221  sdbCursorHandle *result );
2222 
2231 SDB_EXPORT INT32 sdbExecUpdate( sdbConnectionHandle cHandle,
2232  const CHAR *sql ) ;
2233 
2240 SDB_EXPORT INT32 sdbTransactionBegin( sdbConnectionHandle cHandle ) ;
2241 
2248 SDB_EXPORT INT32 sdbTransactionCommit( sdbConnectionHandle cHandle ) ;
2249 
2256 SDB_EXPORT INT32 sdbTransactionRollback( sdbConnectionHandle cHandle ) ;
2257 
2262 SDB_EXPORT void sdbReleaseConnection ( sdbConnectionHandle cHandle ) ;
2263 
2268 SDB_EXPORT void sdbReleaseCollection ( sdbCollectionHandle cHandle ) ;
2269 
2274 SDB_EXPORT void sdbReleaseCS ( sdbCSHandle cHandle ) ;
2275 
2280 SDB_EXPORT void sdbReleaseCursor ( sdbCursorHandle cHandle ) ;
2281 
2286 SDB_EXPORT void sdbReleaseReplicaGroup ( sdbReplicaGroupHandle cHandle ) ;
2287 
2292 SDB_EXPORT void sdbReleaseNode ( sdbNodeHandle cHandle ) ;
2293 
2298 SDB_EXPORT void sdbReleaseDomain ( sdbDomainHandle cHandle ) ;
2299 
2300 /* \fn void sdbReleaseDC ( sdbDCHandle cHandle )
2301  \brief Release the data center handle
2302  \param [in] cHandle the data center handle
2303 */
2304 SDB_EXPORT void sdbReleaseDC ( sdbDCHandle cHandle ) ;
2305 
2349 SDB_EXPORT INT32 sdbAggregate ( sdbCollectionHandle cHandle,
2350  bson **obj, SINT32 num,
2351  sdbCursorHandle *handle ) ;
2352 
2364 SDB_EXPORT INT32 sdbAttachCollection ( sdbCollectionHandle cHandle,
2365  const CHAR *subClFullName,
2366  bson *options) ;
2367 
2376 SDB_EXPORT INT32 sdbDetachCollection ( sdbCollectionHandle cHandle,
2377  const CHAR *subClFullName) ;
2378 
2400 SDB_EXPORT INT32 sdbBackupOffline ( sdbConnectionHandle cHandle,
2401  bson *options) ;
2402 
2422 SDB_EXPORT INT32 sdbBackup ( sdbConnectionHandle cHandle, bson *options) ;
2423 
2448 SDB_EXPORT INT32 sdbListBackup ( sdbConnectionHandle cHandle,
2449  bson *options,
2450  bson *condition,
2451  bson *selector,
2452  bson *orderBy,
2453  sdbCursorHandle *handle ) ;
2454 
2471 SDB_EXPORT INT32 sdbRemoveBackup ( sdbConnectionHandle cHandle,
2472  bson *options) ;
2473 
2493 SDB_EXPORT INT32 sdbListTasks ( sdbConnectionHandle cHandle,
2494  bson *condition,
2495  bson *selector,
2496  bson *orderBy,
2497  bson *hint,
2498  sdbCursorHandle *handle ) ;
2499 
2510 SDB_EXPORT INT32 sdbWaitTasks ( sdbConnectionHandle cHandle,
2511  const SINT64 *taskIDs,
2512  SINT32 num );
2513 
2525 SDB_EXPORT INT32 sdbCancelTask ( sdbConnectionHandle cHandle,
2526  SINT64 taskID,
2527  BOOLEAN isAsync ) ;
2528 
2541 SDB_EXPORT INT32 sdbSetSessionAttr ( sdbConnectionHandle cHandle,
2542  bson *options ) ;
2543 
2552 SDB_EXPORT INT32 sdbGetSessionAttr ( sdbConnectionHandle cHandle,
2553  bson * result ) ;
2554 
2565 SDB_EXPORT INT32 sdbGetSessionAttrEx ( sdbConnectionHandle cHandle,
2566  BOOLEAN useCache,
2567  bson * result ) ;
2568 
2574 SDB_EXPORT BOOLEAN sdbIsClosed( sdbConnectionHandle cHandle ) ;
2575 
2581 SDB_EXPORT BOOLEAN sdbIsValid( sdbConnectionHandle cHandle ) ;
2582 
2583 SDB_EXPORT INT32 _sdbMsg ( sdbConnectionHandle cHandle, const CHAR *msg ) ;
2584 
2605 SDB_EXPORT INT32 sdbCreateDomain ( sdbConnectionHandle cHandle,
2606  const CHAR *pDomainName,
2607  bson *options,
2608  sdbDomainHandle *handle ) ;
2609 
2618 SDB_EXPORT INT32 sdbDropDomain ( sdbConnectionHandle cHandle,
2619  const CHAR *pDomainName ) ;
2620 
2631 SDB_EXPORT INT32 sdbGetDomain ( sdbConnectionHandle cHandle,
2632  const CHAR *pDomainName,
2633  sdbDomainHandle *handle ) ;
2634 
2653 SDB_EXPORT INT32 sdbListDomains ( sdbConnectionHandle cHandle,
2654  bson *condition,
2655  bson *selector,
2656  bson *orderBy,
2657  sdbCursorHandle *handle ) ;
2658 
2678 SDB_EXPORT INT32 sdbAlterDomain( sdbDomainHandle cHandle,
2679  const bson *options ) ;
2680 
2693 SDB_EXPORT INT32 sdbDomainAddGroups ( sdbDomainHandle cHandle,
2694  const bson * options ) ;
2695 
2709 SDB_EXPORT INT32 sdbDomainRemoveGroups ( sdbDomainHandle cHandle,
2710  const bson * options ) ;
2711 
2726 SDB_EXPORT INT32 sdbDomainSetGroups ( sdbDomainHandle cHandle,
2727  const bson * options ) ;
2728 
2748 SDB_EXPORT INT32 sdbDomainSetAttributes ( sdbDomainHandle cHandle,
2749  const bson * options ) ;
2750 
2759 SDB_EXPORT INT32 sdbListCollectionSpacesInDomain( sdbDomainHandle cHandle,
2760  sdbCursorHandle *cursor ) ;
2761 
2770 SDB_EXPORT INT32 sdbListCollectionsInDomain( sdbDomainHandle cHandle,
2771  sdbCursorHandle *cursor ) ;
2772 
2781 SDB_EXPORT INT32 sdbListGroupsInDomain( sdbDomainHandle cHandle,
2782  sdbCursorHandle *cursor ) ;
2783 
2803 SDB_EXPORT INT32 sdbInvalidateCache( sdbConnectionHandle cHandle,
2804  bson *options ) ;
2805 
2816 SDB_EXPORT INT32 sdbForceSession( sdbConnectionHandle cHandle,
2817  SINT64 sessionID,
2818  bson *options ) ;
2819 
2828 SDB_EXPORT INT32 sdbCreateLobID( sdbCollectionHandle cHandle,
2829  bson_oid_t *oid ) ;
2830 
2831 
2844 SDB_EXPORT INT32 sdbCreateLobID1( sdbCollectionHandle cHandle,
2845  const CHAR *pTimeStamp,
2846  bson_oid_t *oid ) ;
2855 SDB_EXPORT INT32 sdbGetLobId( sdbLobHandle lobHandle,
2856  bson_oid_t *oid ) ;
2869 SDB_EXPORT INT32 sdbOpenLob( sdbCollectionHandle cHandle,
2870  const bson_oid_t *oid,
2871  INT32 mode,
2872  sdbLobHandle *lobHandle ) ;
2873 
2884 SDB_EXPORT INT32 sdbWriteLob( sdbLobHandle lobHandle,
2885  const CHAR *buf,
2886  UINT32 len ) ;
2887 
2898 SDB_EXPORT INT32 sdbLockLob( sdbLobHandle lobHandle,
2899  INT64 offset,
2900  INT64 length ) ;
2901 
2912 SDB_EXPORT INT32 sdbLockAndSeekLob( sdbLobHandle lobHandle,
2913  INT64 offset,
2914  INT64 length ) ;
2915 
2928 SDB_EXPORT INT32 sdbReadLob( sdbLobHandle lobHandle,
2929  UINT32 len,
2930  CHAR *buf,
2931  UINT32 *read ) ;
2932 
2939 SDB_EXPORT INT32 sdbCloseLob( sdbLobHandle *lobHandle ) ;
2940 
2949 SDB_EXPORT INT32 sdbRemoveLob( sdbCollectionHandle cHandle,
2950  const bson_oid_t *oid ) ;
2951 
2961 SDB_EXPORT INT32 sdbTruncateLob( sdbCollectionHandle cHandle,
2962  const bson_oid_t *oid, INT64 length ) ;
2963 
2972 SDB_EXPORT INT32 sdbGetLobSize( sdbLobHandle lobHandle,
2973  SINT64 *size ) ;
2974 
2983 SDB_EXPORT INT32 sdbGetLobCreateTime( sdbLobHandle lobHandle,
2984  UINT64 *millis ) ;
2985 
2994 SDB_EXPORT INT32 sdbGetLobModificationTime( sdbLobHandle lobHandle,
2995  UINT64 *millis ) ;
2996 
3003 SDB_EXPORT BOOLEAN sdbLobIsEof( sdbLobHandle lobHandle ) ;
3004 
3005 
3016 SDB_EXPORT INT32 sdbSeekLob( sdbLobHandle lobHandle,
3017  SINT64 size,
3018  SDB_LOB_SEEK whence ) ;
3019 
3028 SDB_EXPORT INT32 sdbListLobs( sdbCollectionHandle cHandle,
3029  sdbCursorHandle *cursor) ;
3030 
3031 
3048 SDB_EXPORT INT32 sdbListLobs1( sdbCollectionHandle cHandle,
3049  bson *condition,
3050  bson *selected,
3051  bson *orderBy,
3052  bson *hint,
3053  INT64 numToSkip,
3054  INT64 numToReturn,
3055  sdbCursorHandle *cursor) ;
3056 
3057 
3066 SDB_EXPORT INT32 sdbListLobPieces( sdbCollectionHandle cHandle,
3067  sdbCursorHandle *cursor ) ;
3068 
3069 
3091 SDB_EXPORT INT32 sdbListLobPieces1( sdbCollectionHandle cHandle,
3092  bson *condition,
3093  bson *selected,
3094  bson *orderBy,
3095  bson *hint,
3096  INT64 numToSkip,
3097  INT64 numToReturn,
3098  sdbCursorHandle *cursor ) ;
3099 
3100 
3110 SDB_EXPORT INT32 sdbReelect( sdbReplicaGroupHandle cHandle,
3111  const bson *options ) ;
3112 
3120 SDB_EXPORT INT32 sdbForceStepUp( sdbConnectionHandle cHandle,
3121  const bson *options ) ;
3122 
3131 SDB_EXPORT INT32 sdbTruncateCollection( sdbConnectionHandle cHandle,
3132  const CHAR *fullName ) ;
3133 
3153 SDB_EXPORT INT32 sdbDetachNode( sdbReplicaGroupHandle cHandle,
3154  const CHAR *hostName,
3155  const CHAR *serviceName,
3156  const bson *options ) ;
3157 
3175 SDB_EXPORT INT32 sdbAttachNode( sdbReplicaGroupHandle cHandle,
3176  const CHAR *hostName,
3177  const CHAR *serviceName,
3178  const bson *options ) ;
3179 
3190 SDB_EXPORT INT32 sdbCreateIdIndex( sdbCollectionHandle cHandle,
3191  const bson *args ) ;
3192 
3200 SDB_EXPORT INT32 sdbDropIdIndex( sdbCollectionHandle cHandle ) ;
3201 
3214 SDB_EXPORT INT32 sdbEnableSharding ( sdbCollectionHandle cHandle,
3215  const bson * args ) ;
3216 
3223 SDB_EXPORT INT32 sdbDisableSharding ( sdbCollectionHandle cHandle ) ;
3224 
3234 SDB_EXPORT INT32 sdbEnableCompression ( sdbCollectionHandle cHandle,
3235  const bson * args ) ;
3236 
3243 SDB_EXPORT INT32 sdbDisableCompression ( sdbCollectionHandle cHandle ) ;
3244 
3262 SDB_EXPORT INT32 sdbCreateAutoIncrement( sdbCollectionHandle cHandle,
3263  const bson * options ) ;
3264 
3274 SDB_EXPORT INT32 sdbDropAutoIncrement( sdbCollectionHandle cHandle,
3275  const bson * options ) ;
3276 
3297 SDB_EXPORT INT32 sdbCLSetAttributes ( sdbCollectionHandle cHandle,
3298  const bson *options ) ;
3299 
3308 SDB_EXPORT INT32 sdbCLGetDetail ( sdbCollectionHandle cHandle,
3309  sdbCursorHandle *handle ) ;
3310 
3311 /* \fn INT32 sdbPop( sdbCollectionHandle cHandle, bson *options )
3312  \brief pop records from capped collection
3313  \param [in] cHandle The handle of connection
3314  \param [in] fullName The full name of collection to be popped, eg: foo.bar
3315  \param [in] options Pop target and direction, including "LogicalID" and "Direction".
3316  Direction is optional. Its default value is 1.
3317  e.g. { LogicalID:100, Direction:1 }
3318  \retval SDB_OK Operation Success
3319  \retval Others Operation Fail
3320 */
3321 SDB_EXPORT INT32 sdbPop( sdbCollectionHandle cHandle, bson *options ) ;
3322 
3323 /* \fn INT32 sdbGetDCName( sdbDCHandle cHandle, CHAR *pBuffer, INT32 size )
3324  \brief Get the name of the data center
3325  \param [in] cHandle The data center handle
3326  \param [in] pBuffer The output buffer
3327  \param [in] size The size of the output buffer
3328  \retval SDB_OK Operation Success
3329  \retval Others Operation Fail
3330 */
3331 SDB_EXPORT INT32 sdbGetDCName( sdbDCHandle cHandle, CHAR *pBuffer, INT32 size ) ;
3332 
3333 /* \fn INT32 sdbGetDC( sdbConnectionHandle cHandle, sdbDCHandle *handle )
3334  \brief Get the data center
3335  \param [in] cHandle The connection handle
3336  \param [out] handle The data center handle
3337  \retval SDB_OK Operation Success
3338  \retval Others Operation Fail
3339 */
3340 SDB_EXPORT INT32 sdbGetDC( sdbConnectionHandle cHandle, sdbDCHandle *handle ) ;
3341 
3342 /* \fn INT32 sdbGetDCDetail( sdbDCHandle cHandle, bson *retInfo )
3343  \brief Get the detail of data center
3344  \param [in] cHandle The connection handle
3345  \param [out] retInfo The the detail of data center
3346  \retval SDB_OK Operation Success
3347  \retval Others Operation Fail
3348 */
3349 SDB_EXPORT INT32 sdbGetDCDetail( sdbDCHandle cHandle, bson *retInfo ) ;
3350 
3351 /* \fn INT32 sdbActivateDC( sdbDCHandle cHandle )
3352  \brief Activate the data center
3353  \param [in] cHandle The data center handle
3354  \retval SDB_OK Operation Success
3355  \retval Others Operation Fail
3356 */
3357 SDB_EXPORT INT32 sdbActivateDC( sdbDCHandle cHandle ) ;
3358 
3359 /* \fn INT32 sdbDeactivateDC( sdbDCHandle cHandle )
3360  \brief Deactivate the data center
3361  \param [in] cHandle The data center handle
3362  \retval SDB_OK Operation Success
3363  \retval Others Operation Fail
3364 */
3365 SDB_EXPORT INT32 sdbDeactivateDC( sdbDCHandle cHandle ) ;
3366 
3367 /* \fn INT32 sdbEnableReadOnly( sdbDCHandle cHandle, BOOLEAN isReadOnly )
3368  \brief Enable data center works in readonly mode or not
3369  \param [in] cHandle The data center handle
3370  \param [in] isReadOnly Whether to use readonly mode or not
3371  \retval SDB_OK Operation Success
3372  \retval Others Operation Fail
3373 */
3374 SDB_EXPORT INT32 sdbEnableReadOnly( sdbDCHandle cHandle, BOOLEAN isReadOnly ) ;
3375 
3376 /* \fn INT32 sdbCreateImage( sdbDCHandle cHandle, const CHAR *pCataAddrList )
3377  \brief Create image in data center
3378  \param [in] cHandle The data center handle
3379  \param [in] pCataAddrList Catalog address list of remote data center, e.g. "192.168.20.165:30003",
3380  "192.168.20.165:30003,192.168.20.166:30003"
3381  \retval SDB_OK Operation Success
3382  \retval Others Operation Fail
3383 */
3384 SDB_EXPORT INT32 sdbCreateImage( sdbDCHandle cHandle, const CHAR *pCataAddrList ) ;
3385 
3386 /* \fn INT32 sdbRemoveImage( sdbDCHandle cHandle )
3387  \brief Remove image in data center
3388  \param [in] cHandle The data center handle
3389  \retval SDB_OK Operation Success
3390  \retval Others Operation Fail
3391 */
3392 SDB_EXPORT INT32 sdbRemoveImage( sdbDCHandle cHandle ) ;
3393 
3394 /* \fn INT32 sdbEnableImage( sdbDCHandle cHandle )
3395  \brief Enable image in data center
3396  \param [in] cHandle The data center handle
3397  \retval SDB_OK Operation Success
3398  \retval Others Operation Fail
3399 */
3400 SDB_EXPORT INT32 sdbEnableImage( sdbDCHandle cHandle ) ;
3401 
3402 /* \fn INT32 sdbDisableImage( sdbDCHandle cHandle )
3403  \brief Disable image in data center
3404  \param [in] cHandle The data center handle
3405  \retval SDB_OK Operation Success
3406  \retval Others Operation Fail
3407 */
3408 SDB_EXPORT INT32 sdbDisableImage( sdbDCHandle cHandle ) ;
3409 
3410 /* \fn INT32 sdbAttachGroups( sdbDCHandle cHandle, bson *info )
3411  \brief Attach specified groups to data center
3412  \param [in] cHandle The data center handle
3413  \param [in] info The information of groups to attach, e.g. {Groups:[["group1", "group1"], ["group2", "group2"]]}
3414  \code
3415  bson obj ;
3416  bson_init( &obj ) ;
3417  bson_append_start_array( &obj, "Groups" ) ;
3418 
3419  bson_append_start_array( &obj, "0" ) ;
3420  bson_append_string( &obj, "0", "group1" ) ;
3421  bson_append_string( &obj, "1", "group1" ) ;
3422  bson_append_finish_array( &obj ) ;
3423 
3424  bson_append_start_array( &obj, "0" ) ;
3425  bson_append_string( &obj, "0", "group2" ) ;
3426  bson_append_string( &obj, "1", "group2" ) ;
3427  bson_append_finish_array( &obj ) ;
3428 
3429  bson_append_finish_array( &obj ) ;
3430 
3431  rc = bson_finish( &obj ) ;
3432  ASSERT_EQ( SDB_OK, rc ) ;
3433 
3434  rc = sdbAttachGroups( dc, &obj ) ;
3435  ASSERT_EQ( SDB_OK, rc ) ;
3436 
3437  bson_destroy( &obj ) ;
3438  \endcode
3439  \retval SDB_OK Operation Success
3440  \retval Others Operation Fail
3441 */
3442 SDB_EXPORT INT32 sdbAttachGroups( sdbDCHandle cHandle, bson *info ) ;
3443 
3444 /* \fn INT32 sdbDetachGroups( sdbDCHandle cHandle, bson *info )
3445  \brief Detach specified groups from data center
3446  \param [in] cHandle The data center handle
3447  \param [in] info The information of groups to detach, e.g. {Groups:[["a", "a"], ["b", "b"]]}
3448  \retval SDB_OK Operation Success
3449  \retval Others Operation Fail
3450 */
3451 SDB_EXPORT INT32 sdbDetachGroups( sdbDCHandle cHandle, bson *info ) ;
3452 
3476 SDB_EXPORT INT32 sdbSyncDB( sdbConnectionHandle cHandle,
3477  bson *options ) ;
3478 
3495 SDB_EXPORT INT32 sdbLoadCollectionSpace( sdbConnectionHandle cHandle,
3496  const CHAR *csName,
3497  bson *options ) ;
3498 
3515 SDB_EXPORT INT32 sdbUnloadCollectionSpace( sdbConnectionHandle cHandle,
3516  const CHAR *csName,
3517  bson *options ) ;
3518 
3535 SDB_EXPORT INT32 sdbSetPDLevel( sdbConnectionHandle cHandle,
3536  INT32 pdLevel,
3537  bson *options ) ;
3538 
3553 SDB_EXPORT INT32 sdbReloadConfig( sdbConnectionHandle cHandle,
3554  bson *options ) ;
3555 
3571 SDB_EXPORT INT32 sdbUpdateConfig( sdbConnectionHandle cHandle,
3572  bson *configs, bson *options ) ;
3573 
3589 SDB_EXPORT INT32 sdbDeleteConfig( sdbConnectionHandle cHandle,
3590  bson *configs, bson *options ) ;
3591 
3604 SDB_EXPORT INT32 sdbRenameCollectionSpace( sdbConnectionHandle cHandle,
3605  const CHAR *pOldName,
3606  const CHAR *pNewName,
3607  bson *options ) ;
3608 
3616 SDB_EXPORT void sdbSetConnectionInterruptFunc(
3617  sdbConnectionHandle cHandle,
3618  socketInterruptFunc func ) ;
3619 
3647 SDB_EXPORT INT32 sdbAnalyze( sdbConnectionHandle cHandle,
3648  bson *options ) ;
3649 
3662 SDB_EXPORT INT32 sdbGetLastErrorObj( sdbConnectionHandle cHandle, bson *errObj ) ;
3663 
3668 SDB_EXPORT void sdbCleanLastErrorObj( sdbConnectionHandle cHandle ) ;
3669 
3670 
3671 SDB_EXTERN_C_END
3672 #endif
3673