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 #define FLG_INSERT_CONTONDUP 0x00000001
42 
44 #define FLG_INSERT_RETURN_OID 0x00000002
45 
46 #define FLG_INSERT_REPLACEONDUP 0x00000004
47 
49 {
50  SDB_LOB_CREATEONLY = 0x00000001,
51  SDB_LOB_READ = 0x00000004
52 } ;
53 typedef enum _SDB_LOB_OPEN_MODE SDB_LOB_OPEN_MODE ;
54 
56 {
60 } ;
61 typedef enum _SDB_LOB_SEEK SDB_LOB_SEEK ;
62 
63 #define SDB_INVALID_HANDLE ((ossValuePtr) 0)
64 typedef ossValuePtr sdbConnectionHandle ;
65 typedef ossValuePtr sdbCSHandle ;
66 typedef ossValuePtr sdbCollectionHandle ;
67 typedef ossValuePtr sdbCursorHandle ;
68 typedef ossValuePtr sdbReplicaGroupHandle ;
69 typedef ossValuePtr sdbNodeHandle ;
70 typedef ossValuePtr sdbDomainHandle ;
71 typedef ossValuePtr sdbLobHandle ;
72 typedef ossValuePtr sdbDCHandle ;
73 
75 typedef void (*ERROR_ON_REPLY_FUNC)( const CHAR *pErrorObj,
76  UINT32 objSize,
77  INT32 flag,
78  const CHAR *pDescription,
79  const CHAR *pDetail ) ;
80 
85 SDB_EXPORT void sdbSetErrorOnReplyCallback( ERROR_ON_REPLY_FUNC func ) ;
86 
88 typedef sdbNodeHandle sdbReplicaNodeHandle ;
89 
91 #define sdbCreateReplicaNode sdbCreateNode
92 
93 #define sdbRemoveReplicaNode sdbRemoveNode
94 
95 #define sdbGetReplicaNodeMaster sdbGetNodeMaster
96 
97 #define sdbGetReplicaNodeSlave sdbGetNodeSlave
98 
99 #define sdbGetReplicaNodeByName sdbGetNodeByName
100 
101 #define sdbGetReplicaNodeByHost sdbGetNodeByHost
102 
103 #define sdbGetReplicaNodeSddr sdbGetNodeAddr
104 
105 #define sdbStartReplicaNode sdbStartNode
106 
107 #define sdbStopReplicaNode sdbStopNode
108 
109 #define sdbReleaseReplicaNode sdbReleaseNode
110 
112 #define QUERY_FORCE_HINT 0x00000080
113 
114 #define QUERY_PARALLED 0x00000100
115 
116 #define QUERY_WITH_RETURNDATA 0x00000200
117 
118 
125 SDB_EXPORT INT32 initClient( sdbClientConf* config ) ;
126 
141 SDB_EXPORT INT32 sdbConnect ( const CHAR *pHostName, const CHAR *pServiceName,
142  const CHAR *pUsrName, const CHAR *pPasswd ,
143  sdbConnectionHandle *handle ) ;
144 
157 SDB_EXPORT INT32 sdbConnect1 ( const CHAR **pConnAddrs, INT32 arrSize,
158  const CHAR *pUsrName, const CHAR *pPasswd ,
159  sdbConnectionHandle *handle ) ;
160 
175 SDB_EXPORT INT32 sdbSecureConnect ( const CHAR *pHostName, const CHAR *pServiceName,
176  const CHAR *pUsrName, const CHAR *pPasswd ,
177  sdbConnectionHandle *handle ) ;
178 
191 SDB_EXPORT INT32 sdbSecureConnect1 ( const CHAR **pConnAddrs, INT32 arrSize,
192  const CHAR *pUsrName, const CHAR *pPasswd ,
193  sdbConnectionHandle *handle ) ;
194 
199 SDB_EXPORT void sdbDisconnect ( sdbConnectionHandle handle ) ;
200 
208 SDB_EXPORT INT32 sdbGetLastErrorObj( bson *obj ) ;
209 
213 SDB_EXPORT void sdbCleanLastErrorObj() ;
214 
224 SDB_EXPORT INT32 sdbCreateUsr( sdbConnectionHandle cHandle, const CHAR *pUsrName,
225  const CHAR *pPasswd ) ;
226 
247 SDB_EXPORT INT32 sdbCreateUsr2( sdbConnectionHandle cHandle, const CHAR *pUsrName,
248  const CHAR *pPasswd, bson *options ) ;
249 
259 SDB_EXPORT INT32 sdbRemoveUsr( sdbConnectionHandle cHandle, const CHAR *pUsrName,
260  const CHAR *pPasswd ) ;
261 
262 /* \fn INT32 sdbModifyConfig ( sdbConnectionHandle cHandle,
263  bson *config )
264  \brief Modify config for the current node
265  \param [in] cHandle The connection handle
266  \param [in] config The new configurations
267  \retval SDB_OK Modify Success
268  \retval Others Modify Fail
269 
270 SDB_EXPORT INT32 sdbModifyConfig ( sdbConnectionHandle cHandle,
271  bson *config ) ;*/
272 
273 /* \fn INT32 sdbModifyNodeConfig ( sdbConnectionHandle cHandle,
274  INT32 nodeID,
275  bson *config )
276  \brief Modify config for a given node
277  \param [in] cHandle The connection handle
278  \param [in] nodeID The node id that want to be modified
279  \param [in] config The new configurations
280  \retval SDB_OK Modify Success
281  \retval Others Modify Fail
282 
283 SDB_EXPORT INT32 sdbModifyNodeConfig ( sdbConnectionHandle cHandle,
284  INT32 nodeID,
285  bson *config ) ;*/
286 
310 SDB_EXPORT INT32 sdbGetDataBlocks ( sdbCollectionHandle cHandle,
311  bson *condition,
312  bson *select,
313  bson *orderBy,
314  bson *hint,
315  INT64 numToSkip,
316  INT64 numToReturn,
317  sdbCursorHandle *handle );
318 
340 SDB_EXPORT INT32 sdbGetQueryMeta ( sdbCollectionHandle cHandle,
341  bson *condition,
342  bson *orderBy,
343  bson *hint,
344  INT64 numToSkip,
345  INT64 numToReturn,
346  sdbCursorHandle *handle ) ;
347 
377 SDB_EXPORT INT32 sdbGetSnapshot ( sdbConnectionHandle cHandle,
378  INT32 snapType,
379  bson *condition,
380  bson *selector,
381  bson *orderBy,
382  sdbCursorHandle *handle ) ;
383 
419 SDB_EXPORT INT32 sdbGetSnapshot1 ( sdbConnectionHandle cHandle,
420  INT32 snapType,
421  bson *condition,
422  bson *selector,
423  bson *orderBy,
424  bson *hint,
425  INT64 numToSkip,
426  INT64 numToReturn,
427  sdbCursorHandle *handle ) ;
428 
444 SDB_EXPORT INT32 sdbResetSnapshot ( sdbConnectionHandle cHandle,
445  bson *condition ) ;
446 
485 SDB_EXPORT INT32 sdbTraceStart ( sdbConnectionHandle cHandle,
486  UINT32 traceBufferSize,
487  CHAR * component,
488  CHAR * breakPoint ) ;
495 SDB_EXPORT INT32 sdbTraceResume ( sdbConnectionHandle cHandle ) ;
496 
505 SDB_EXPORT INT32 sdbTraceStop ( sdbConnectionHandle cHandle,
506  const CHAR *pDumpFileName ) ;
507 
516 SDB_EXPORT INT32 sdbTraceStatus ( sdbConnectionHandle cHandle,
517  sdbCursorHandle *handle ) ;
518 
551 SDB_EXPORT INT32 sdbGetList ( sdbConnectionHandle cHandle,
552  INT32 listType,
553  bson *condition,
554  bson *selector,
555  bson *orderBy,
556  sdbCursorHandle *handle ) ;
557 
597 SDB_EXPORT INT32 sdbGetList1( sdbConnectionHandle cHandle,
598  INT32 listType,
599  bson *condition,
600  bson *selector,
601  bson *orderBy,
602  bson *hint,
603  SINT64 numToSkip,
604  SINT64 numToReturn,
605  sdbCursorHandle *handle ) ;
606 
617 SDB_EXPORT INT32 sdbGetCollection ( sdbConnectionHandle cHandle,
618  const CHAR *pCollectionFullName,
619  sdbCollectionHandle *handle ) ;
620 
631 SDB_EXPORT INT32 sdbGetCollectionSpace ( sdbConnectionHandle cHandle,
632  const CHAR *pCollectionSpaceName,
633  sdbCSHandle *handle ) ;
634 
645 SDB_EXPORT INT32 sdbGetReplicaGroup ( sdbConnectionHandle cHandle,
646  const CHAR *pRGName,
647  sdbReplicaGroupHandle *handle ) ;
648 
659 SDB_EXPORT INT32 sdbGetReplicaGroup1 ( sdbConnectionHandle cHandle,
660  UINT32 id,
661  sdbReplicaGroupHandle *handle ) ;
662 
672 SDB_EXPORT INT32 sdbGetReplicaGroupName ( sdbReplicaGroupHandle cHandle,
673  CHAR **ppRGName ) ;
674 
684 SDB_EXPORT INT32 sdbGetRGName ( sdbReplicaGroupHandle cHandle,
685  CHAR *pBuffer, INT32 size ) ;
686 
693 SDB_EXPORT BOOLEAN sdbIsReplicaGroupCatalog ( sdbReplicaGroupHandle cHandle ) ;
694 
716 SDB_EXPORT INT32 sdbCreateCollectionSpace ( sdbConnectionHandle cHandle,
717  const CHAR *pCollectionSpaceName,
718  INT32 iPageSize,
719  sdbCSHandle *handle ) ;
720 
738 SDB_EXPORT INT32 sdbCreateCollectionSpaceV2 ( sdbConnectionHandle cHandle,
739  const CHAR *pCollectionSpaceName,
740  bson *options,
741  sdbCSHandle *handle ) ;
742 
751 SDB_EXPORT INT32 sdbDropCollectionSpace ( sdbConnectionHandle cHandle,
752  const CHAR *pCollectionSpaceName ) ;
753 
764 SDB_EXPORT INT32 sdbCreateReplicaGroup ( sdbConnectionHandle cHandle,
765  const CHAR *pRGName,
766  sdbReplicaGroupHandle *handle ) ;
767 
776 SDB_EXPORT INT32 sdbRemoveReplicaGroup ( sdbConnectionHandle cHandle,
777  const CHAR *pRGName ) ;
778 
785 SDB_EXPORT INT32 sdbStartReplicaGroup ( sdbReplicaGroupHandle cHandle ) ;
786 
795 SDB_EXPORT INT32 sdbGetNodeMaster ( sdbReplicaGroupHandle cHandle,
796  sdbNodeHandle *handle ) ;
797 
807 SDB_EXPORT INT32 sdbGetNodeSlave ( sdbReplicaGroupHandle cHandle,
808  sdbNodeHandle *handle ) ;
809 
821 SDB_EXPORT INT32 sdbGetNodeByName ( sdbReplicaGroupHandle cHandle,
822  const CHAR *pNodeName,
823  sdbNodeHandle *handle ) ;
824 
838 SDB_EXPORT INT32 sdbGetNodeByHost ( sdbReplicaGroupHandle cHandle,
839  const CHAR *pHostName,
840  const CHAR *pServiceName,
841  sdbNodeHandle *handle ) ;
842 
857 SDB_EXPORT INT32 sdbGetNodeAddr ( sdbNodeHandle cHandle,
858  const CHAR **ppHostName,
859  const CHAR **ppServiceName,
860  const CHAR **ppNodeName,
861  INT32 *pNodeID ) ;
862 
869 SDB_EXPORT INT32 sdbStartNode ( sdbNodeHandle cHandle ) ;
870 
877 SDB_EXPORT INT32 sdbStopNode ( sdbNodeHandle cHandle ) ;
878 
885 SDB_EXPORT INT32 sdbStopReplicaGroup ( sdbReplicaGroupHandle cHandle ) ;
886 
901 SDB_EXPORT INT32 sdbCreateReplicaCataGroup ( sdbConnectionHandle cHandle,
902  const CHAR *pHostName,
903  const CHAR *pServiceName,
904  const CHAR *pDatabasePath,
905  bson *configure );
906 
921 SDB_EXPORT INT32 sdbCreateNode ( sdbReplicaGroupHandle cHandle,
922  const CHAR *pHostName,
923  const CHAR *pServiceName,
924  const CHAR *pDatabasePath,
925  bson *configure ) ;
926 
939 SDB_EXPORT INT32 sdbRemoveNode ( sdbReplicaGroupHandle cHandle,
940  const CHAR *pHostName,
941  const CHAR *pServiceName,
942  bson *configure ) ;
943 
952 SDB_EXPORT INT32 sdbListCollectionSpaces ( sdbConnectionHandle cHandle,
953  sdbCursorHandle *handle ) ;
954 
963 SDB_EXPORT INT32 sdbListCollections ( sdbConnectionHandle cHandle,
964  sdbCursorHandle *handle ) ;
965 
974 SDB_EXPORT INT32 sdbListReplicaGroups ( sdbConnectionHandle cHandle,
975  sdbCursorHandle *handle ) ;
976 
999 SDB_EXPORT INT32 sdbFlushConfigure( sdbConnectionHandle cHandle,
1000  bson *options ) ;
1001 
1010 SDB_EXPORT INT32 sdbCrtJSProcedure( sdbConnectionHandle cHandle,
1011  const CHAR *code ) ;
1012 
1021 SDB_EXPORT INT32 sdbRmProcedure( sdbConnectionHandle cHandle,
1022  const CHAR *spName ) ;
1023 
1024 
1035 SDB_EXPORT INT32 sdbListProcedures( sdbConnectionHandle cHandle,
1036  bson *condition,
1037  sdbCursorHandle *handle ) ;
1038 
1055 SDB_EXPORT INT32 sdbEvalJS( sdbConnectionHandle cHandle,
1056  const CHAR *code,
1057  SDB_SPD_RES_TYPE *type,
1058  sdbCursorHandle *handle,
1059  bson *errmsg ) ;
1060 
1071 SDB_EXPORT INT32 sdbGetCollection1 ( sdbCSHandle cHandle,
1072  const CHAR *pCollectionName,
1073  sdbCollectionHandle *handle ) ;
1074 
1088 SDB_EXPORT INT32 sdbCreateCollection ( sdbCSHandle cHandle,
1089  const CHAR *pCollectionName,
1090  sdbCollectionHandle *handle ) ;
1091 
1108 SDB_EXPORT INT32 sdbCreateCollection1 ( sdbCSHandle cHandle,
1109  const CHAR *pCollectionName,
1110  bson *options,
1111  sdbCollectionHandle *handle ) ;
1112 
1129 SDB_EXPORT INT32 sdbAlterCollection ( sdbCollectionHandle cHandle,
1130  bson *options ) ;
1131 
1140 SDB_EXPORT INT32 sdbDropCollection ( sdbCSHandle cHandle,
1141  const CHAR *pCollectionName ) ;
1142 
1152 SDB_EXPORT INT32 sdbGetCSName ( sdbCSHandle cHandle,
1153  CHAR *pBuffer, INT32 size ) ;
1154 
1167 SDB_EXPORT INT32 sdbRenameCollection( sdbCSHandle cHandle,
1168  const CHAR *pOldName,
1169  const CHAR *pNewName,
1170  bson *options ) ;
1171 
1181 SDB_EXPORT INT32 sdbGetCLName ( sdbCollectionHandle cHandle,
1182  CHAR *pBuffer, INT32 size ) ;
1183 
1193 SDB_EXPORT INT32 sdbGetCLFullName ( sdbCollectionHandle cHandle,
1194  CHAR *pBuffer, INT32 size ) ;
1195 
1214 SDB_EXPORT INT32 sdbSplitCollection ( sdbCollectionHandle cHandle,
1215  const CHAR *pSourceRG,
1216  const CHAR *pTargetRG,
1217  const bson *pSplitCondition,
1218  const bson *pSplitEndCondition ) ;
1219 
1240 SDB_EXPORT INT32 sdbSplitCLAsync ( sdbCollectionHandle cHandle,
1241  const CHAR *pSourceRG,
1242  const CHAR *pTargetRG,
1243  const bson *pSplitCondition,
1244  const bson *pSplitEndCondition,
1245  SINT64 *taskID ) ;
1246 
1259 SDB_EXPORT INT32 sdbSplitCollectionByPercent ( sdbCollectionHandle cHandle,
1260  const CHAR *pSourceRG,
1261  const CHAR *pTargetRG,
1262  FLOAT64 percent ) ;
1263 
1278 SDB_EXPORT INT32 sdbSplitCLByPercentAsync ( sdbCollectionHandle cHandle,
1279  const CHAR *pSourceRG,
1280  const CHAR *pTargetRG,
1281  FLOAT64 percent,
1282  SINT64 *taskID ) ;
1283 
1299 SDB_EXPORT INT32 sdbCreateIndex ( sdbCollectionHandle cHandle,
1300  bson *indexDef,
1301  const CHAR *pIndexName,
1302  BOOLEAN isUnique,
1303  BOOLEAN isEnforced ) ;
1304 
1323 SDB_EXPORT INT32 sdbCreateIndex1 ( sdbCollectionHandle cHandle,
1324  bson *indexDef,
1325  const CHAR *pIndexName,
1326  BOOLEAN isUnique,
1327  BOOLEAN isEnforced,
1328  INT32 sortBufferSize ) ;
1329 
1340 SDB_EXPORT INT32 sdbGetIndexes ( sdbCollectionHandle cHandle,
1341  const CHAR *pIndexName,
1342  sdbCursorHandle *handle ) ;
1343 
1352 SDB_EXPORT INT32 sdbDropIndex ( sdbCollectionHandle cHandle,
1353  const CHAR *pIndexName ) ;
1354 
1365 SDB_EXPORT INT32 sdbGetCount ( sdbCollectionHandle cHandle,
1366  bson *condition,
1367  SINT64 *count );
1368 
1369 
1385 SDB_EXPORT INT32 sdbGetCount1 ( sdbCollectionHandle cHandle,
1386  bson *condition,
1387  bson *hint,
1388  SINT64 *count );
1389 
1398 SDB_EXPORT INT32 sdbInsert ( sdbCollectionHandle cHandle,
1399  bson *obj ) ;
1400 
1410 SDB_EXPORT INT32 sdbInsert1 ( sdbCollectionHandle cHandle,
1411  bson *obj, bson_iterator *id ) ;
1412 
1445 SDB_EXPORT INT32 sdbInsert2 ( sdbCollectionHandle cHandle,
1446  bson *obj, INT32 flag, bson_iterator *id ) ;
1447 
1507 SDB_EXPORT INT32 sdbBulkInsert ( sdbCollectionHandle cHandle,
1508  SINT32 flags, bson **obj, SINT32 num ) ;
1509 
1526 SDB_EXPORT INT32 sdbUpdate ( sdbCollectionHandle cHandle,
1527  bson *rule,
1528  bson *condition,
1529  bson *hint ) ;
1530 
1547 SDB_EXPORT INT32 sdbUpsert ( sdbCollectionHandle cHandle,
1548  bson *rule,
1549  bson *condition,
1550  bson *hint ) ;
1551 
1570 SDB_EXPORT INT32 sdbUpsert1 ( sdbCollectionHandle cHandle,
1571  bson *rule,
1572  bson *condition,
1573  bson *hint,
1574  bson *setOnInsert ) ;
1575 
1589 SDB_EXPORT INT32 sdbDelete ( sdbCollectionHandle cHandle,
1590  bson *condition,
1591  bson *hint ) ;
1592 
1623 SDB_EXPORT INT32 sdbQuery1 ( sdbCollectionHandle cHandle,
1624  bson *condition,
1625  bson *select,
1626  bson *orderBy,
1627  bson *hint,
1628  INT64 numToSkip,
1629  INT64 numToReturn,
1630  INT32 flags,
1631  sdbCursorHandle *handle ) ;
1632 
1633 
1657 SDB_EXPORT INT32 sdbQuery ( sdbCollectionHandle cHandle,
1658  bson *condition,
1659  bson *select,
1660  bson *orderBy,
1661  bson *hint,
1662  INT64 numToSkip,
1663  INT64 numToReturn,
1664  sdbCursorHandle *handle ) ;
1665 
1700 SDB_EXPORT INT32 sdbQueryAndUpdate ( sdbCollectionHandle cHandle,
1701  bson *condition,
1702  bson *select,
1703  bson *orderBy,
1704  bson *hint,
1705  bson *update,
1706  INT64 numToSkip,
1707  INT64 numToReturn,
1708  INT32 flag,
1709  BOOLEAN returnNew,
1710  sdbCursorHandle *handle ) ;
1711 
1742 SDB_EXPORT INT32 sdbQueryAndRemove ( sdbCollectionHandle cHandle,
1743  bson *condition,
1744  bson *select,
1745  bson *orderBy,
1746  bson *hint,
1747  INT64 numToSkip,
1748  INT64 numToReturn,
1749  INT32 flag,
1750  sdbCursorHandle *handle ) ;
1751 
1788 SDB_EXPORT INT32 sdbExplain ( sdbCollectionHandle cHandle,
1789  bson *condition,
1790  bson *select,
1791  bson *orderBy,
1792  bson *hint,
1793  INT32 flag,
1794  INT64 numToSkip,
1795  INT64 numToReturn,
1796  bson *options,
1797  sdbCursorHandle *handle ) ;
1798 
1807 SDB_EXPORT INT32 sdbNext ( sdbCursorHandle cHandle,
1808  bson *obj ) ;
1809 
1818 SDB_EXPORT INT32 sdbCurrent ( sdbCursorHandle cHandle,
1819  bson *obj ) ;
1820 
1821 /* \fn INT32 sdbUpdateCurrent ( sdbCursorHandle cHandle, bson *rule )
1822  \brief Update the current document of cursor
1823  \param [in] cHandle The cursor handle
1824  \param [in] rule The updating rule, cannot be null
1825  \retval SDB_OK Operation Success
1826  \retval Others Operation Fail
1827 */
1828 /*
1829 SDB_EXPORT INT32 sdbUpdateCurrent ( sdbCursorHandle cHandle,
1830  bson *rule ) ;
1831 */
1832 /* \fn INT32 sdbDeleteCurrent ( sdbCursorHandle cHandle )
1833  \brief Delete the current document of cursor
1834  \param [in] cHandle The cursor handle
1835  \retval SDB_OK Operation Success
1836  \retval Others Operation Fail
1837 */
1838 /*
1839 SDB_EXPORT INT32 sdbDeleteCurrent ( sdbCursorHandle cHandle ) ;
1840 */
1841 
1850 SDB_EXPORT INT32 sdbCloseCursor ( sdbCursorHandle cHandle ) ;
1851 
1859 SDB_EXPORT INT32 sdbCloseAllCursors ( sdbConnectionHandle cHandle ) ;
1860 
1861 
1872 SDB_EXPORT INT32 sdbExec( sdbConnectionHandle cHandle,
1873  const CHAR *sql,
1874  sdbCursorHandle *result );
1875 
1884 SDB_EXPORT INT32 sdbExecUpdate( sdbConnectionHandle cHandle,
1885  const CHAR *sql ) ;
1886 
1893 SDB_EXPORT INT32 sdbTransactionBegin( sdbConnectionHandle cHandle ) ;
1894 
1901 SDB_EXPORT INT32 sdbTransactionCommit( sdbConnectionHandle cHandle ) ;
1902 
1909 SDB_EXPORT INT32 sdbTransactionRollback( sdbConnectionHandle cHandle ) ;
1910 
1915 SDB_EXPORT void sdbReleaseConnection ( sdbConnectionHandle cHandle ) ;
1916 
1921 SDB_EXPORT void sdbReleaseCollection ( sdbCollectionHandle cHandle ) ;
1922 
1927 SDB_EXPORT void sdbReleaseCS ( sdbCSHandle cHandle ) ;
1928 
1933 SDB_EXPORT void sdbReleaseCursor ( sdbCursorHandle cHandle ) ;
1934 
1939 SDB_EXPORT void sdbReleaseReplicaGroup ( sdbReplicaGroupHandle cHandle ) ;
1940 
1945 SDB_EXPORT void sdbReleaseNode ( sdbNodeHandle cHandle ) ;
1946 
1951 SDB_EXPORT void sdbReleaseDomain ( sdbDomainHandle cHandle ) ;
1952 
1953 /* \fn void sdbReleaseDC ( sdbDCHandle cHandle )
1954  \brief Release the data center handle
1955  \param [in] cHandle the data center handle
1956 */
1957 SDB_EXPORT void sdbReleaseDC ( sdbDCHandle cHandle ) ;
1958 
2002 SDB_EXPORT INT32 sdbAggregate ( sdbCollectionHandle cHandle,
2003  bson **obj, SINT32 num,
2004  sdbCursorHandle *handle ) ;
2005 
2017 SDB_EXPORT INT32 sdbAttachCollection ( sdbCollectionHandle cHandle,
2018  const CHAR *subClFullName,
2019  bson *options) ;
2020 
2029 SDB_EXPORT INT32 sdbDetachCollection ( sdbCollectionHandle cHandle,
2030  const CHAR *subClFullName) ;
2031 
2052 SDB_EXPORT INT32 sdbBackupOffline ( sdbConnectionHandle cHandle,
2053  bson *options) ;
2054 
2079 SDB_EXPORT INT32 sdbListBackup ( sdbConnectionHandle cHandle,
2080  bson *options,
2081  bson *condition,
2082  bson *selector,
2083  bson *orderBy,
2084  sdbCursorHandle *handle ) ;
2085 
2102 SDB_EXPORT INT32 sdbRemoveBackup ( sdbConnectionHandle cHandle,
2103  bson *options) ;
2104 
2124 SDB_EXPORT INT32 sdbListTasks ( sdbConnectionHandle cHandle,
2125  bson *condition,
2126  bson *selector,
2127  bson *orderBy,
2128  bson *hint,
2129  sdbCursorHandle *handle ) ;
2130 
2141 SDB_EXPORT INT32 sdbWaitTasks ( sdbConnectionHandle cHandle,
2142  const SINT64 *taskIDs,
2143  SINT32 num );
2144 
2156 SDB_EXPORT INT32 sdbCancelTask ( sdbConnectionHandle cHandle,
2157  SINT64 taskID,
2158  BOOLEAN isAsync ) ;
2159 
2183 SDB_EXPORT INT32 sdbSetSessionAttr ( sdbConnectionHandle cHandle,
2184  bson *options ) ;
2185 
2194 SDB_EXPORT INT32 sdbGetSessionAttr ( sdbConnectionHandle cHandle,
2195  bson * result ) ;
2196 
2203 SDB_EXPORT INT32 sdbIsValid( sdbConnectionHandle cHandle, BOOLEAN *result ) ;
2204 
2205 SDB_EXPORT INT32 _sdbMsg ( sdbConnectionHandle cHandle, const CHAR *msg ) ;
2206 
2227 SDB_EXPORT INT32 sdbCreateDomain ( sdbConnectionHandle cHandle,
2228  const CHAR *pDomainName,
2229  bson *options,
2230  sdbDomainHandle *handle ) ;
2231 
2240 SDB_EXPORT INT32 sdbDropDomain ( sdbConnectionHandle cHandle,
2241  const CHAR *pDomainName ) ;
2242 
2253 SDB_EXPORT INT32 sdbGetDomain ( sdbConnectionHandle cHandle,
2254  const CHAR *pDomainName,
2255  sdbDomainHandle *handle ) ;
2256 
2275 SDB_EXPORT INT32 sdbListDomains ( sdbConnectionHandle cHandle,
2276  bson *condition,
2277  bson *selector,
2278  bson *orderBy,
2279  sdbCursorHandle *handle ) ;
2280 
2300 SDB_EXPORT INT32 sdbAlterDomain( sdbDomainHandle cHandle,
2301  const bson *options ) ;
2302 
2311 SDB_EXPORT INT32 sdbListCollectionSpacesInDomain( sdbDomainHandle cHandle,
2312  sdbCursorHandle *cursor ) ;
2313 
2322 SDB_EXPORT INT32 sdbListCollectionsInDomain( sdbDomainHandle cHandle,
2323  sdbCursorHandle *cursor ) ;
2324 
2333 SDB_EXPORT INT32 sdbListGroupsInDomain( sdbDomainHandle cHandle,
2334  sdbCursorHandle *cursor ) ;
2335 
2344 SDB_EXPORT INT32 sdbInvalidateCache( sdbConnectionHandle cHandle,
2345  bson *condition ) ;
2346 
2356 SDB_EXPORT INT32 sdbForceSession( sdbConnectionHandle cHandle,
2357  SINT64 sessionID,
2358  bson *options ) ;
2359 
2372 SDB_EXPORT INT32 sdbOpenLob( sdbCollectionHandle cHandle,
2373  const bson_oid_t *oid,
2374  INT32 mode,
2375  sdbLobHandle *lobHandle ) ;
2376 
2387 SDB_EXPORT INT32 sdbWriteLob( sdbLobHandle lobHandle,
2388  const CHAR *buf,
2389  UINT32 len ) ;
2390 
2403 SDB_EXPORT INT32 sdbReadLob( sdbLobHandle lobHandle,
2404  UINT32 len,
2405  CHAR *buf,
2406  UINT32 *read ) ;
2407 
2414 SDB_EXPORT INT32 sdbCloseLob( sdbLobHandle *lobHandle ) ;
2415 
2424 SDB_EXPORT INT32 sdbRemoveLob( sdbCollectionHandle cHandle,
2425  const bson_oid_t *oid ) ;
2426 
2435 SDB_EXPORT INT32 sdbGetLobSize( sdbLobHandle lobHandle,
2436  SINT64 *size ) ;
2437 
2448 SDB_EXPORT INT32 sdbGetLobCreateTime( sdbLobHandle lobHandle,
2449  UINT64 *millis ) ;
2450 
2461 SDB_EXPORT INT32 sdbSeekLob( sdbLobHandle lobHandle,
2462  SINT64 size,
2463  SDB_LOB_SEEK whence ) ;
2464 
2473 SDB_EXPORT INT32 sdbListLobs( sdbCollectionHandle cHandle,
2474  sdbCursorHandle *cursor ) ;
2475 
2484 SDB_EXPORT INT32 sdbListLobPieces( sdbCollectionHandle cHandle,
2485  sdbCursorHandle *cursor ) ;
2486 
2487 
2495 SDB_EXPORT INT32 sdbReelect( sdbReplicaGroupHandle cHandle,
2496  const bson *options ) ;
2497 
2505 SDB_EXPORT INT32 sdbForceStepUp( sdbConnectionHandle cHandle,
2506  const bson *options ) ;
2507 
2516 SDB_EXPORT INT32 sdbTruncateCollection( sdbConnectionHandle cHandle,
2517  const CHAR *fullName ) ;
2518 
2538 SDB_EXPORT INT32 sdbDetachNode( sdbReplicaGroupHandle cHandle,
2539  const CHAR *hostName,
2540  const CHAR *serviceName,
2541  const bson *options ) ;
2542 
2560 SDB_EXPORT INT32 sdbAttachNode( sdbReplicaGroupHandle cHandle,
2561  const CHAR *hostName,
2562  const CHAR *serviceName,
2563  const bson *options ) ;
2564 
2575 SDB_EXPORT INT32 sdbCreateIdIndex( sdbCollectionHandle cHandle,
2576  const bson *args ) ;
2577 
2585 SDB_EXPORT INT32 sdbDropIdIndex( sdbCollectionHandle cHandle ) ;
2586 
2587 /* \fn INT32 sdbGetDCName( sdbDCHandle cHandle, CHAR *pBuffer, INT32 size )
2588  \brief Get the name of the data center
2589  \param [in] cHandle The data center handle
2590  \param [in] pBuffer The output buffer
2591  \param [in] size The size of the output buffer
2592  \retval SDB_OK Operation Success
2593  \retval Others Operation Fail
2594 */
2595 SDB_EXPORT INT32 sdbGetDCName( sdbDCHandle cHandle, CHAR *pBuffer, INT32 size ) ;
2596 
2597 /* \fn INT32 sdbGetDC( sdbConnectionHandle cHandle, sdbDCHandle *handle )
2598  \brief Get the data center
2599  \param [in] cHandle The connection handle
2600  \param [out] handle The data center handle
2601  \retval SDB_OK Operation Success
2602  \retval Others Operation Fail
2603 */
2604 SDB_EXPORT INT32 sdbGetDC( sdbConnectionHandle cHandle, sdbDCHandle *handle ) ;
2605 
2606 /* \fn INT32 sdbGetDCDetail( sdbDCHandle cHandle, bson *retInfo )
2607  \brief Get the detail of data center
2608  \param [in] cHandle The connection handle
2609  \param [out] retInfo The the detail of data center
2610  \retval SDB_OK Operation Success
2611  \retval Others Operation Fail
2612 */
2613 SDB_EXPORT INT32 sdbGetDCDetail( sdbDCHandle cHandle, bson *retInfo ) ;
2614 
2615 /* \fn INT32 sdbActivateDC( sdbDCHandle cHandle )
2616  \brief Activate the data center
2617  \param [in] cHandle The data center handle
2618  \retval SDB_OK Operation Success
2619  \retval Others Operation Fail
2620 */
2621 SDB_EXPORT INT32 sdbActivateDC( sdbDCHandle cHandle ) ;
2622 
2623 /* \fn INT32 sdbDeactivateDC( sdbDCHandle cHandle )
2624  \brief Deactivate the data center
2625  \param [in] cHandle The data center handle
2626  \retval SDB_OK Operation Success
2627  \retval Others Operation Fail
2628 */
2629 SDB_EXPORT INT32 sdbDeactivateDC( sdbDCHandle cHandle ) ;
2630 
2631 /* \fn INT32 sdbEnableReadOnly( sdbDCHandle cHandle, BOOLEAN isReadOnly )
2632  \brief Enable data center works in readonly mode or not
2633  \param [in] cHandle The data center handle
2634  \param [in] isReadOnly Whether to use readonly mode or not
2635  \retval SDB_OK Operation Success
2636  \retval Others Operation Fail
2637 */
2638 SDB_EXPORT INT32 sdbEnableReadOnly( sdbDCHandle cHandle, BOOLEAN isReadOnly ) ;
2639 
2640 /* \fn INT32 sdbCreateImage( sdbDCHandle cHandle, const CHAR *pCataAddrList )
2641  \brief Create image in data center
2642  \param [in] cHandle The data center handle
2643  \param [in] pCataAddrList Catalog address list of remote data center, e.g. "192.168.20.165:30003",
2644  "192.168.20.165:30003,192.168.20.166:30003"
2645  \retval SDB_OK Operation Success
2646  \retval Others Operation Fail
2647 */
2648 SDB_EXPORT INT32 sdbCreateImage( sdbDCHandle cHandle, const CHAR *pCataAddrList ) ;
2649 
2650 /* \fn INT32 sdbRemoveImage( sdbDCHandle cHandle )
2651  \brief Remove image in data center
2652  \param [in] cHandle The data center handle
2653  \retval SDB_OK Operation Success
2654  \retval Others Operation Fail
2655 */
2656 SDB_EXPORT INT32 sdbRemoveImage( sdbDCHandle cHandle ) ;
2657 
2658 /* \fn INT32 sdbEnableImage( sdbDCHandle cHandle )
2659  \brief Enable image in data center
2660  \param [in] cHandle The data center handle
2661  \retval SDB_OK Operation Success
2662  \retval Others Operation Fail
2663 */
2664 SDB_EXPORT INT32 sdbEnableImage( sdbDCHandle cHandle ) ;
2665 
2666 /* \fn INT32 sdbDisableImage( sdbDCHandle cHandle )
2667  \brief Disable image in data center
2668  \param [in] cHandle The data center handle
2669  \retval SDB_OK Operation Success
2670  \retval Others Operation Fail
2671 */
2672 SDB_EXPORT INT32 sdbDisableImage( sdbDCHandle cHandle ) ;
2673 
2674 /* \fn INT32 sdbAttachGroups( sdbDCHandle cHandle, bson *info )
2675  \brief Attach specified groups to data center
2676  \param [in] cHandle The data center handle
2677  \param [in] info The information of groups to attach, e.g. {Groups:[["group1", "group1"], ["group2", "group2"]]}
2678  \code
2679  bson obj ;
2680  bson_init( &obj ) ;
2681  bson_append_start_array( &obj, "Groups" ) ;
2682 
2683  bson_append_start_array( &obj, "0" ) ;
2684  bson_append_string( &obj, "0", "group1" ) ;
2685  bson_append_string( &obj, "1", "group1" ) ;
2686  bson_append_finish_array( &obj ) ;
2687 
2688  bson_append_start_array( &obj, "0" ) ;
2689  bson_append_string( &obj, "0", "group2" ) ;
2690  bson_append_string( &obj, "1", "group2" ) ;
2691  bson_append_finish_array( &obj ) ;
2692 
2693  bson_append_finish_array( &obj ) ;
2694 
2695  rc = bson_finish( &obj ) ;
2696  ASSERT_EQ( SDB_OK, rc ) ;
2697 
2698  rc = sdbAttachGroups( dc, &obj ) ;
2699  ASSERT_EQ( SDB_OK, rc ) ;
2700 
2701  bson_destroy( &obj ) ;
2702  \endcode
2703  \retval SDB_OK Operation Success
2704  \retval Others Operation Fail
2705 */
2706 SDB_EXPORT INT32 sdbAttachGroups( sdbDCHandle cHandle, bson *info ) ;
2707 
2708 /* \fn INT32 sdbDetachGroups( sdbDCHandle cHandle, bson *info )
2709  \brief Detach specified groups from data center
2710  \param [in] cHandle The data center handle
2711  \param [in] info The information of groups to detach, e.g. {Groups:[["a", "a"], ["b", "b"]]}
2712  \retval SDB_OK Operation Success
2713  \retval Others Operation Fail
2714 */
2715 SDB_EXPORT INT32 sdbDetachGroups( sdbDCHandle cHandle, bson *info ) ;
2716 
2740 SDB_EXPORT INT32 sdbSyncDB( sdbConnectionHandle cHandle,
2741  bson *options ) ;
2742 
2759 SDB_EXPORT INT32 sdbLoadCollectionSpace( sdbConnectionHandle cHandle,
2760  const CHAR *csName,
2761  bson *options ) ;
2762 
2779 SDB_EXPORT INT32 sdbUnloadCollectionSpace( sdbConnectionHandle cHandle,
2780  const CHAR *csName,
2781  bson *options ) ;
2782 
2799 SDB_EXPORT INT32 sdbSetPDLevel( sdbConnectionHandle cHandle,
2800  INT32 pdLevel,
2801  bson *options ) ;
2802 
2817 SDB_EXPORT INT32 sdbReloadConfig( sdbConnectionHandle cHandle,
2818  bson *options ) ;
2819 
2832 SDB_EXPORT INT32 sdbRenameCollectionSpace( sdbConnectionHandle cHandle,
2833  const CHAR *pOldName,
2834  const CHAR *pNewName,
2835  bson *options ) ;
2836 
2843 SDB_EXPORT void sdbSetConnectionInterruptFunc(
2844  sdbConnectionHandle cHandle,
2845  socketInterruptFunc func ) ;
2846 
2847 SDB_EXTERN_C_END
2848 #endif
2849