SequoiaDB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
client.hpp
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 *******************************************************************************/
17 
18 
24 #ifndef CLIENT_HPP__
25 #define CLIENT_HPP__
26 #include "core.hpp"
27 #include "clientDef.h"
28 #if defined (SDB_ENGINE) || defined (SDB_CLIENT)
29 #include "../bson/bson.h"
30 #include "../util/fromjson.hpp"
31 #else
32 #include "bson/bson.hpp"
33 #include "fromjson.hpp"
34 #endif
35 #include "spd.h"
36 #include <map>
37 #include <string>
38 #include <vector>
39 
41 #define RELEASE_INNER_HANDLE( handle ) \
42 do \
43 { \
44  if ( handle ) \
45  { \
46  delete handle ; \
47  handle = NULL ; \
48  } \
49 } while( 0 )
50 
51 #define DLLEXPORT SDB_EXPORT
52 
54 #define SDB_PAGESIZE_4K 4096
55 
56 #define SDB_PAGESIZE_8K 8192
57 
58 #define SDB_PAGESIZE_16K 16384
59 
60 #define SDB_PAGESIZE_32K 32768
61 
62 #define SDB_PAGESIZE_64K 65536
63 
64 #define SDB_PAGESIZE_DEFAULT 0
65 
66 
68 #define FLG_INSERT_CONTONDUP 0x00000001
69 
70 #define FLG_INSERT_RETURNNUM 0x00000002
71 
72 #define FLG_INSERT_REPLACEONDUP 0x00000004
73 
74 #define FLG_INSERT_RETURN_OID 0x10000000
75 
76 // client socket timeout value
77 // since client and server may not sit in the same network, we need
78 // to set this value bigger than engine socket timeout
79 // this value is in millisec
80 // set to 10 seconds timeout
81 #define SDB_CLIENT_SOCKET_TIMEOUT_DFT 10000
82 
84 #define sdbReplicaNode sdbNode
85 
87 #define QUERY_FORCE_HINT 0x00000080
88 
89 #define QUERY_PARALLED 0x00000100
90 
91 #define QUERY_WITH_RETURNDATA 0x00000200
92 
93 #define QUERY_PREPARE_MORE 0x00004000
94 
95 #define QUERY_KEEP_SHARDINGKEY_IN_UPDATE 0x00008000
96 
101 #define QUERY_FOR_UPDATE 0x00010000
102 
103 
105 #define UPDATE_KEEP_SHARDINGKEY QUERY_KEEP_SHARDINGKEY_IN_UPDATE
106 
107 #define UPDATE_RETURNNUM 0x00000004
108 
110 #define FLG_DELETE_RETURNNUM 0x00000004
111 
112 #define SDB_INDEX_SORT_BUFFER_DEFAULT_SIZE 64
113 
115 {
116  SDB_LOB_CREATEONLY = 0x00000001,
117  SDB_LOB_READ = 0x00000004,
118  SDB_LOB_WRITE = 0x00000008
119 } ;
124 
126 {
130 } ;
135 
139 namespace sdbclient
140 {
141  const static bson::BSONObj _sdbStaticObject ;
142  const static bson::OID _sdbStaticOid ;
143  const static std::vector<INT32> _sdbStaticVec ;
144  const static std::vector<UINT32> _sdbStaticUINT32Vec ;
145  class _sdbCursor ;
146  class _sdbCollection ;
147  class sdb ;
148  class _sdb ;
149  class _ossSocket ;
150  class _sdbLob ;
151  class sdbLob ;
152 
154  typedef void (*ERROR_ON_REPLY_FUNC)( const CHAR *pErrorObj,
155  UINT32 objSize,
156  INT32 flag,
157  const CHAR *pDescription,
158  const CHAR *pDetail ) ;
159 
164  SDB_EXPORT void sdbSetErrorOnReplyCallback( ERROR_ON_REPLY_FUNC func ) ;
165 
166  class DLLEXPORT _sdbCursor
167  {
168  private :
169  _sdbCursor ( const _sdbCursor& other ) ;
170  _sdbCursor& operator=( const _sdbCursor& ) ;
171  public :
172  _sdbCursor () {}
173  virtual ~_sdbCursor () {}
174  virtual INT32 next ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE ) = 0 ;
175  virtual INT32 current ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE ) = 0 ;
176  virtual INT32 close () = 0 ;
177  } ;
178 
182  class DLLEXPORT sdbCursor
183  {
184  private :
185  sdbCursor ( const sdbCursor& other ) ;
186  sdbCursor& operator=( const sdbCursor& ) ;
187  public :
194  _sdbCursor *pCursor ;
195 
200  {
201  pCursor = NULL ;
202  }
203 
208  {
209  if ( pCursor )
210  {
211  delete pCursor ;
212  }
213  }
214 
231  INT32 next ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE )
232  {
233  if ( !pCursor )
234  {
235  return SDB_NOT_CONNECTED ;
236  }
237  return pCursor->next ( obj, getOwned ) ;
238  }
239 
256  INT32 current ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE )
257  {
258  if ( !pCursor )
259  {
260  return SDB_NOT_CONNECTED ;
261  }
262  return pCursor->current ( obj, getOwned ) ;
263  }
264 
270  INT32 close ()
271  {
272  if ( !pCursor )
273  {
274  return SDB_OK ;
275  }
276  return pCursor->close () ;
277  }
278  } ;
279 
280  class DLLEXPORT _sdbCollection
281  {
282  private :
283  _sdbCollection ( const _sdbCollection& other ) ;
284  _sdbCollection& operator=( const _sdbCollection& ) ;
285  public :
286  _sdbCollection () {}
287  virtual ~_sdbCollection () {}
288  // get the total number of records for a given condition, if the condition
289  // is NULL then match all records in the collection
290  virtual INT32 getCount ( SINT64 &count,
291  const bson::BSONObj &condition = _sdbStaticObject,
292  const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
293  // insert a bson object into current collection
294  // given:
295  // object ( required )
296  // returns id as the pointer pointing to _id bson element
297  virtual INT32 insert ( const bson::BSONObj &obj, bson::OID *id = NULL ) = 0 ;
298  virtual INT32 insert ( const bson::BSONObj &obj,
299  INT32 flags,
300  bson::BSONObj *pResult = NULL ) = 0 ;
301  virtual INT32 insert ( std::vector<bson::BSONObj> &objs,
302  INT32 flags = 0,
303  bson::BSONObj *pResult = NULL ) = 0 ;
304  virtual INT32 insert ( const bson::BSONObj objs[],
305  INT32 size,
306  INT32 flags = 0,
307  bson::BSONObj *pResult = NULL ) = 0 ;
308  virtual INT32 bulkInsert ( SINT32 flags,
309  std::vector<bson::BSONObj> &obj
310  ) = 0 ;
311  // update bson object from current collection
312  // given:
313  // update rule ( required )
314  // update condition ( optional )
315  // hint ( optional )
316  // flag ( optional )
317  // pResult ( optional )
318  virtual INT32 update ( const bson::BSONObj &rule,
319  const bson::BSONObj &condition = _sdbStaticObject,
320  const bson::BSONObj &hint = _sdbStaticObject,
321  INT32 flag = 0,
322  bson::BSONObj *pResult = NULL
323  ) = 0 ;
324 
325  // update bson object from current collection, if there's nothing match
326  // then insert an record that modified from empty BSON object
327  // given:
328  // update rule ( required )
329  // update condition ( optional )
330  // hint ( optional )
331  // setOnInsert ( optional )
332  // flag ( optional )
333  // pResult ( optional )
334  virtual INT32 upsert ( const bson::BSONObj &rule,
335  const bson::BSONObj &condition = _sdbStaticObject,
336  const bson::BSONObj &hint = _sdbStaticObject,
337  const bson::BSONObj &setOnInsert = _sdbStaticObject,
338  INT32 flag = 0,
339  bson::BSONObj *pResult = NULL
340  ) = 0 ;
341 
342  // delete bson objects from current collection
343  // given:
344  // delete condition ( optional )
345  // hint ( optional )
346  // flag ( optional )
347  // pResult ( optional )
348  virtual INT32 del ( const bson::BSONObj &condition = _sdbStaticObject,
349  const bson::BSONObj &hint = _sdbStaticObject,
350  INT32 flag = 0,
351  bson::BSONObj *pResult = NULL
352  ) = 0 ;
353 
354  // query objects from current collection
355  // given:
356  // query condition ( optional )
357  // query selected def ( optional )
358  // query orderby ( optional )
359  // hint ( optional )
360  // output: _sdbCursor ( required )
361  virtual INT32 query ( _sdbCursor **cursor,
362  const bson::BSONObj &condition = _sdbStaticObject,
363  const bson::BSONObj &selected = _sdbStaticObject,
364  const bson::BSONObj &orderBy = _sdbStaticObject,
365  const bson::BSONObj &hint = _sdbStaticObject,
366  INT64 numToSkip = 0,
367  INT64 numToReturn = -1,
368  INT32 flags = 0
369  ) = 0 ;
370 
371  virtual INT32 query ( sdbCursor &cursor,
372  const bson::BSONObj &condition = _sdbStaticObject,
373  const bson::BSONObj &selected = _sdbStaticObject,
374  const bson::BSONObj &orderBy = _sdbStaticObject,
375  const bson::BSONObj &hint = _sdbStaticObject,
376  INT64 numToSkip = 0,
377  INT64 numToReturn = -1,
378  INT32 flags = 0
379  ) = 0 ;
380 
381  virtual INT32 queryOne( bson::BSONObj &obj,
382  const bson::BSONObj &condition = _sdbStaticObject,
383  const bson::BSONObj &selected = _sdbStaticObject,
384  const bson::BSONObj &orderBy = _sdbStaticObject,
385  const bson::BSONObj &hint = _sdbStaticObject,
386  INT64 numToSkip = 0,
387  INT32 flags = 0 ) = 0 ;
388 
389  // query objects from current collection and update
390  // given:
391  // update rule ( required )
392  // query condition ( optional )
393  // query selected def ( optional )
394  // query orderby ( optional )
395  // hint ( optional )
396  // flags( optional )
397  // returnNew ( optioinal )
398  // output: sdbCursor ( required )
399  virtual INT32 queryAndUpdate ( _sdbCursor **cursor,
400  const bson::BSONObj &update,
401  const bson::BSONObj &condition = _sdbStaticObject,
402  const bson::BSONObj &selected = _sdbStaticObject,
403  const bson::BSONObj &orderBy = _sdbStaticObject,
404  const bson::BSONObj &hint = _sdbStaticObject,
405  INT64 numToSkip = 0,
406  INT64 numToReturn = -1,
407  INT32 flag = 0,
408  BOOLEAN returnNew = FALSE
409  ) = 0 ;
410 
411  // query objects from current collection and remove
412  // given:
413  // query condition ( optional )
414  // query selected def ( optional )
415  // query orderby ( optional )
416  // hint ( optional )
417  // flags( optional )
418  // output: sdbCursor ( required )
419  virtual INT32 queryAndRemove ( _sdbCursor **cursor,
420  const bson::BSONObj &condition = _sdbStaticObject,
421  const bson::BSONObj &selected = _sdbStaticObject,
422  const bson::BSONObj &orderBy = _sdbStaticObject,
423  const bson::BSONObj &hint = _sdbStaticObject,
424  INT64 numToSkip = 0,
425  INT64 numToReturn = -1,
426  INT32 flag = 0
427  ) = 0 ;
428 
429  //virtual INT32 rename ( const CHAR *pNewName ) = 0 ;
430  // create an index for the current collection
431  // given:
432  // index definition ( required )
433  // index name ( required )
434  // uniqueness ( required )
435  // enforceness ( required )
436  virtual INT32 createIndex ( const bson::BSONObj &indexDef,
437  const CHAR *pName,
438  BOOLEAN isUnique,
439  BOOLEAN isEnforced,
440  INT32 sortBufferSize ) = 0 ;
441  virtual INT32 createIndex ( const bson::BSONObj &indexDef,
442  const CHAR *pName,
443  const bson::BSONObj &options ) = 0 ;
444  virtual INT32 getIndexes ( _sdbCursor **cursor,
445  const CHAR *pName ) = 0 ;
446  virtual INT32 getIndexes ( sdbCursor &cursor,
447  const CHAR *pIndexName ) = 0 ;
448  virtual INT32 getIndexes ( std::vector<bson::BSONObj> &infos ) = 0 ;
449  virtual INT32 getIndex ( const CHAR *pIndexName, bson::BSONObj &info ) = 0 ;
450  virtual INT32 dropIndex ( const CHAR *pIndexName ) = 0 ;
451  virtual INT32 create () = 0 ;
452  virtual INT32 drop () = 0 ;
453  virtual const CHAR *getCollectionName () = 0 ;
454  virtual const CHAR *getCSName () = 0 ;
455  virtual const CHAR *getFullName () = 0 ;
456  virtual INT32 split ( const CHAR *pSourceGroupName,
457  const CHAR *pTargetGroupName,
458  const bson::BSONObj &splitConditon,
459  const bson::BSONObj &splitEndCondition = _sdbStaticObject) = 0 ;
460  virtual INT32 split ( const CHAR *pSourceGroupName,
461  const CHAR *pTargetGroupName,
462  FLOAT64 percent ) = 0 ;
463  virtual INT32 splitAsync ( SINT64 &taskID,
464  const CHAR *pSourceGroupName,
465  const CHAR *pTargetGroupName,
466  const bson::BSONObj &splitCondition,
467  const bson::BSONObj &splitEndCondition = _sdbStaticObject) = 0 ;
468  virtual INT32 splitAsync ( const CHAR *pSourceGroupName,
469  const CHAR *pTargetGroupName,
470  FLOAT64 percent,
471  SINT64 &taskID ) = 0 ;
472  virtual INT32 aggregate ( _sdbCursor **cursor,
473  std::vector<bson::BSONObj> &obj
474  ) = 0 ;
475  virtual INT32 aggregate ( sdbCursor &cursor,
476  std::vector<bson::BSONObj> &obj
477  ) = 0 ;
478  virtual INT32 getQueryMeta ( _sdbCursor **cursor,
479  const bson::BSONObj &condition = _sdbStaticObject,
480  const bson::BSONObj &orderBy = _sdbStaticObject,
481  const bson::BSONObj &hint = _sdbStaticObject,
482  INT64 numToSkip = 0,
483  INT64 numToReturn = -1
484  ) = 0 ;
485  virtual INT32 getQueryMeta ( sdbCursor &cursor,
486  const bson::BSONObj &condition = _sdbStaticObject,
487  const bson::BSONObj &orderBy = _sdbStaticObject,
488  const bson::BSONObj &hint = _sdbStaticObject,
489  INT64 numToSkip = 0,
490  INT64 numToReturn = -1
491  ) = 0 ;
492  virtual INT32 attachCollection ( const CHAR *subClFullName,
493  const bson::BSONObj &options) = 0 ;
494  virtual INT32 detachCollection ( const CHAR *subClFullName) = 0 ;
495 
496  virtual INT32 alterCollection ( const bson::BSONObj &options ) = 0 ;
498  virtual INT32 explain ( sdbCursor &cursor,
499  const bson::BSONObj &condition = _sdbStaticObject,
500  const bson::BSONObj &select = _sdbStaticObject,
501  const bson::BSONObj &orderBy = _sdbStaticObject,
502  const bson::BSONObj &hint = _sdbStaticObject,
503  INT64 numToSkip = 0,
504  INT64 numToReturn = -1,
505  INT32 flag = 0,
506  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
507 
508  virtual INT32 explain ( _sdbCursor **cursor,
509  const bson::BSONObj &condition = _sdbStaticObject,
510  const bson::BSONObj &select = _sdbStaticObject,
511  const bson::BSONObj &orderBy = _sdbStaticObject,
512  const bson::BSONObj &hint = _sdbStaticObject,
513  INT64 numToSkip = 0,
514  INT64 numToReturn = -1,
515  INT32 flag = 0,
516  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
518  virtual INT32 createLob( sdbLob &lob, const bson::OID *oid = NULL ) = 0 ;
519 
520  virtual INT32 removeLob( const bson::OID &oid ) = 0 ;
521 
522  virtual INT32 truncateLob( const bson::OID &oid, INT64 length ) = 0 ;
523 
524  virtual INT32 openLob( sdbLob &lob, const bson::OID &oid,
525  SDB_LOB_OPEN_MODE mode = SDB_LOB_READ ) = 0 ;
526 
527  virtual INT32 listLobs( sdbCursor &cursor,
528  const bson::BSONObj &condition = _sdbStaticObject,
529  const bson::BSONObj &selected = _sdbStaticObject,
530  const bson::BSONObj &orderBy = _sdbStaticObject,
531  const bson::BSONObj &hint = _sdbStaticObject,
532  INT64 numToSkip = 0,
533  INT64 numToReturn = -1 ) = 0 ;
534 
535  virtual INT32 listLobs( _sdbCursor **cursor,
536  const bson::BSONObj &condition = _sdbStaticObject,
537  const bson::BSONObj &selected = _sdbStaticObject,
538  const bson::BSONObj &orderBy = _sdbStaticObject,
539  const bson::BSONObj &hint = _sdbStaticObject,
540  INT64 numToSkip = 0,
541  INT64 numToReturn = -1 ) = 0 ;
542 
543  virtual INT32 createLobID( bson::OID &oid, const CHAR *pTimeStamp = NULL ) = 0 ;
544 
545  virtual INT32 listLobPieces(
546  _sdbCursor **cursor,
547  const bson::BSONObj &condition = _sdbStaticObject,
548  const bson::BSONObj &selected = _sdbStaticObject,
549  const bson::BSONObj &orderBy = _sdbStaticObject,
550  const bson::BSONObj &hint = _sdbStaticObject,
551  INT64 numToSkip = 0,
552  INT64 numToReturn = -1 ) = 0 ;
553 
554  virtual INT32 listLobPieces(
555  sdbCursor &cursor,
556  const bson::BSONObj &condition = _sdbStaticObject,
557  const bson::BSONObj &selected = _sdbStaticObject,
558  const bson::BSONObj &orderBy = _sdbStaticObject,
559  const bson::BSONObj &hint = _sdbStaticObject,
560  INT64 numToSkip = 0,
561  INT64 numToReturn = -1 ) = 0 ;
562 
564  virtual INT32 truncate() = 0 ;
565 
567  virtual INT32 createIdIndex( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
568 
569  virtual INT32 dropIdIndex() = 0 ;
570 
571  virtual INT32 createAutoIncrement( const bson::BSONObj &options ) = 0;
572 
573  virtual INT32 createAutoIncrement( const std::vector<bson::BSONObj> &options ) = 0;
574 
575  virtual INT32 dropAutoIncrement( const CHAR* fieldName ) = 0;
576 
577  virtual INT32 dropAutoIncrement( const std::vector<const CHAR*> &fieldNames ) = 0;
578 
579  virtual INT32 pop ( const bson::BSONObj &option = _sdbStaticObject ) = 0 ;
580 
581  virtual INT32 enableSharding ( const bson::BSONObj & options ) = 0 ;
582 
583  virtual INT32 disableSharding () = 0 ;
584 
585  virtual INT32 enableCompression ( const bson::BSONObj & options = _sdbStaticObject ) = 0 ;
586 
587  virtual INT32 disableCompression () = 0 ;
588 
589  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
590 
591  virtual INT32 getDetail ( _sdbCursor **cursor ) = 0 ;
592 
593  virtual INT32 getDetail ( sdbCursor &cursor ) = 0 ;
594  } ;
595 
599  class DLLEXPORT sdbCollection
600  {
601  private :
606  sdbCollection ( const sdbCollection& other ) ;
607 
613  sdbCollection& operator=( const sdbCollection& ) ;
614  public :
621  _sdbCollection *pCollection ;
622 
627  {
628  pCollection = NULL ;
629  }
630 
635  {
636  if ( pCollection )
637  {
638  delete pCollection ;
639  }
640  }
641 
655  INT32 getCount ( SINT64 &count,
656  const bson::BSONObj &condition = _sdbStaticObject,
657  const bson::BSONObj &hint = _sdbStaticObject )
658  {
659  if ( !pCollection )
660  {
661  return SDB_NOT_CONNECTED ;
662  }
663  return pCollection->getCount ( count, condition, hint ) ;
664  }
665 
683  INT32 split ( const CHAR *pSourceGroupName,
684  const CHAR *pTargetGroupName,
685  const bson::BSONObj &splitCondition,
686  const bson::BSONObj &splitEndCondition = _sdbStaticObject)
687  {
688  if ( !pCollection )
689  {
690  return SDB_NOT_CONNECTED ;
691  }
692  return pCollection->split ( pSourceGroupName,
693  pTargetGroupName,
694  splitCondition,
695  splitEndCondition) ;
696  }
697 
709  INT32 split ( const CHAR *pSourceGroupName,
710  const CHAR *pTargetGroupName,
711  FLOAT64 percent )
712  {
713  if ( !pCollection )
714  {
715  return SDB_NOT_CONNECTED ;
716  }
717  return pCollection->split ( pSourceGroupName,
718  pTargetGroupName,
719  percent ) ;
720  }
721 
741  INT32 splitAsync ( SINT64 &taskID,
742  const CHAR *pSourceGroupName,
743  const CHAR *pTargetGroupName,
744  const bson::BSONObj &splitCondition,
745  const bson::BSONObj &splitEndCondition = _sdbStaticObject )
746  {
747  if ( !pCollection )
748  {
749  return SDB_NOT_CONNECTED ;
750  }
751  return pCollection->splitAsync ( taskID,
752  pSourceGroupName,
753  pTargetGroupName,
754  splitCondition,
755  splitEndCondition ) ;
756  }
757 
771  INT32 splitAsync ( const CHAR *pSourceGroupName,
772  const CHAR *pTargetGroupName,
773  FLOAT64 percent,
774  SINT64 &taskID )
775  {
776  if ( !pCollection )
777  {
778  return SDB_NOT_CONNECTED ;
779  }
780  return pCollection->splitAsync ( pSourceGroupName,
781  pTargetGroupName,
782  percent,
783  taskID ) ;
784  }
785 
805  INT32 alterCollection ( const bson::BSONObj &options )
806  {
807  if ( !pCollection )
808  {
809  return SDB_NOT_CONNECTED ;
810  }
811  return pCollection->alterCollection ( options ) ;
812  }
813 
836  INT32 insert ( const bson::BSONObj &obj, bson::OID *pId = NULL )
837  {
838  if ( !pCollection )
839  {
840  return SDB_NOT_CONNECTED ;
841  }
842  return pCollection->insert ( obj, pId ) ;
843  }
844 
886  INT32 insert ( const bson::BSONObj &obj,
887  INT32 flags,
888  bson::BSONObj *pResult = NULL )
889  {
890  if ( !pCollection )
891  {
892  return SDB_NOT_CONNECTED ;
893  }
894  return pCollection->insert ( obj, flags, pResult ) ;
895  }
896 
941  INT32 insert ( std::vector<bson::BSONObj> &objs,
942  INT32 flags = 0,
943  bson::BSONObj *pResult = NULL )
944  {
945  if ( !pCollection )
946  {
947  return SDB_NOT_CONNECTED ;
948  }
949  return pCollection->insert( objs, flags, pResult ) ;
950  }
951 
999  INT32 insert ( const bson::BSONObj objs[],
1000  INT32 size,
1001  INT32 flags = 0,
1002  bson::BSONObj *pResult = NULL )
1003  {
1004  if ( !pCollection )
1005  {
1006  return SDB_NOT_CONNECTED ;
1007  }
1008  return pCollection->insert ( objs, size, flags, pResult ) ;
1009  }
1010 
1038  INT32 bulkInsert ( SINT32 flags,
1039  std::vector<bson::BSONObj> &objs )
1040  {
1041  if ( !pCollection )
1042  {
1043  return SDB_NOT_CONNECTED ;
1044  }
1045  return pCollection->bulkInsert ( flags, objs ) ;
1046  }
1047 
1070  INT32 update ( const bson::BSONObj &rule,
1071  const bson::BSONObj &condition = _sdbStaticObject,
1072  const bson::BSONObj &hint = _sdbStaticObject,
1073  INT32 flag = 0,
1074  bson::BSONObj *pResult = NULL
1075  )
1076  {
1077  if ( !pCollection )
1078  {
1079  return SDB_NOT_CONNECTED ;
1080  }
1081  return pCollection->update ( rule, condition, hint, flag, pResult ) ;
1082  }
1083 
1107  INT32 upsert ( const bson::BSONObj &rule,
1108  const bson::BSONObj &condition = _sdbStaticObject,
1109  const bson::BSONObj &hint = _sdbStaticObject,
1110  const bson::BSONObj &setOnInsert = _sdbStaticObject,
1111  INT32 flag = 0,
1112  bson::BSONObj *pResult = NULL
1113  )
1114  {
1115  if ( !pCollection )
1116  {
1117  return SDB_NOT_CONNECTED ;
1118  }
1119  return pCollection->upsert ( rule, condition, hint, setOnInsert,
1120  flag, pResult ) ;
1121  }
1122 
1137  INT32 del ( const bson::BSONObj &condition = _sdbStaticObject,
1138  const bson::BSONObj &hint = _sdbStaticObject,
1139  INT32 flag = 0,
1140  bson::BSONObj *pResult = NULL
1141  )
1142  {
1143  if ( !pCollection )
1144  {
1145  return SDB_NOT_CONNECTED ;
1146  }
1147  return pCollection->del ( condition, hint, flag, pResult ) ;
1148  }
1149 
1150  /* \fn INT32 query ( _sdbCursor **cursor,
1151  const bson::BSONObj &condition,
1152  const bson::BSONObj &selected,
1153  const bson::BSONObj &orderBy,
1154  const bson::BSONObj &hint,
1155  INT64 numToSkip,
1156  INT64 numToReturn,
1157  INT32 flags
1158  )
1159  \brief Get the matching documents in current collection
1160  \param [in] condition The matching rule, return all the documents if not provided
1161  \param [in] selected The selective rule, return the whole document if not provided
1162  \param [in] orderBy The ordered rule, result set is unordered if not provided
1163  \param [in] hint Specified the index used to scan data. e.g. {"":"ageIndex"} means
1164  using index "ageIndex" to scan data(index scan);
1165  {"":null} means table scan. when hint is not provided,
1166  database automatically match the optimal index to scan data
1167  \param [in] numToSkip Skip the first numToSkip documents, default is 0
1168  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
1169  \param [in] flags The query flags, 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 flags
1170  \code
1171  QUERY_FORCE_HINT
1172  QUERY_PARALLED
1173  QUERY_WITH_RETURNDATA
1174  QUERY_FOR_UPDATE
1175  \endcode
1176  \param [out] cursor The cursor of current query
1177  \retval SDB_OK Operation Success
1178  \retval Others Operation Fail
1179  */
1180  INT32 query ( _sdbCursor **cursor,
1181  const bson::BSONObj &condition = _sdbStaticObject,
1182  const bson::BSONObj &selected = _sdbStaticObject,
1183  const bson::BSONObj &orderBy = _sdbStaticObject,
1184  const bson::BSONObj &hint = _sdbStaticObject,
1185  INT64 numToSkip = 0,
1186  INT64 numToReturn = -1,
1187  INT32 flags = 0
1188  )
1189  {
1190  if ( !pCollection )
1191  {
1192  return SDB_NOT_CONNECTED ;
1193  }
1194  return pCollection->query ( cursor, condition, selected, orderBy,
1195  hint, numToSkip, numToReturn, flags ) ;
1196  }
1197 
1228  INT32 query ( sdbCursor &cursor,
1229  const bson::BSONObj &condition = _sdbStaticObject,
1230  const bson::BSONObj &selected = _sdbStaticObject,
1231  const bson::BSONObj &orderBy = _sdbStaticObject,
1232  const bson::BSONObj &hint = _sdbStaticObject,
1233  INT64 numToSkip = 0,
1234  INT64 numToReturn = -1,
1235  INT32 flags = 0
1236  )
1237  {
1238  if ( !pCollection )
1239  {
1240  return SDB_NOT_CONNECTED ;
1241  }
1242  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1243  return pCollection->query ( cursor, condition, selected, orderBy,
1244  hint, numToSkip, numToReturn, flags ) ;
1245  }
1246 
1275  INT32 queryOne( bson::BSONObj &obj,
1276  const bson::BSONObj &condition = _sdbStaticObject,
1277  const bson::BSONObj &selected = _sdbStaticObject,
1278  const bson::BSONObj &orderBy = _sdbStaticObject,
1279  const bson::BSONObj &hint = _sdbStaticObject,
1280  INT64 numToSkip = 0,
1281  INT32 flag = 0 )
1282  {
1283  if ( !pCollection )
1284  {
1285  return SDB_NOT_CONNECTED ;
1286  }
1287  return pCollection->queryOne( obj, condition, selected, orderBy,
1288  hint, numToSkip, flag ) ;
1289  }
1290 
1326  INT32 queryAndUpdate ( sdbCursor &cursor,
1327  const bson::BSONObj &update,
1328  const bson::BSONObj &condition = _sdbStaticObject,
1329  const bson::BSONObj &selected = _sdbStaticObject,
1330  const bson::BSONObj &orderBy = _sdbStaticObject,
1331  const bson::BSONObj &hint = _sdbStaticObject,
1332  INT64 numToSkip = 0,
1333  INT64 numToReturn = -1,
1334  INT32 flag = 0,
1335  BOOLEAN returnNew = FALSE
1336  )
1337  {
1338  if ( !pCollection )
1339  {
1340  return SDB_NOT_CONNECTED ;
1341  }
1342  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1343  return pCollection->queryAndUpdate( &cursor.pCursor , update, condition,
1344  selected, orderBy, hint,
1345  numToSkip, numToReturn, flag, returnNew ) ;
1346  }
1347 
1378  INT32 queryAndRemove ( sdbCursor &cursor,
1379  const bson::BSONObj &condition = _sdbStaticObject,
1380  const bson::BSONObj &selected = _sdbStaticObject,
1381  const bson::BSONObj &orderBy = _sdbStaticObject,
1382  const bson::BSONObj &hint = _sdbStaticObject,
1383  INT64 numToSkip = 0,
1384  INT64 numToReturn = -1,
1385  INT32 flag = 0
1386  )
1387  {
1388  if ( !pCollection )
1389  {
1390  return SDB_NOT_CONNECTED ;
1391  }
1392  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1393  return pCollection->queryAndRemove( &cursor.pCursor , condition,
1394  selected, orderBy, hint,
1395  numToSkip, numToReturn, flag ) ;
1396  }
1397 
1414  INT32 createIndex ( const bson::BSONObj &indexDef,
1415  const CHAR *pIndexName,
1416  BOOLEAN isUnique,
1417  BOOLEAN isEnforced,
1418  INT32 sortBufferSize =
1419  SDB_INDEX_SORT_BUFFER_DEFAULT_SIZE )
1420  {
1421  if ( !pCollection )
1422  {
1423  return SDB_NOT_CONNECTED ;
1424  }
1425  return pCollection->createIndex ( indexDef, pIndexName, isUnique,
1426  isEnforced, sortBufferSize ) ;
1427  }
1428 
1447  INT32 createIndex ( const bson::BSONObj &indexDef,
1448  const CHAR *pIndexName,
1449  const bson::BSONObj &options )
1450  {
1451  if ( !pCollection )
1452  {
1453  return SDB_NOT_CONNECTED ;
1454  }
1455  return pCollection->createIndex ( indexDef, pIndexName, options ) ;
1456  }
1457 
1458  /* \fn INT32 getIndexes ( _sdbCursor **cursor,
1459  const CHAR *pIndexName )
1460  \brief Get all of or one of the indexes in current collection
1461  \param [in] pIndexName The index name, returns all of the indexes if this parameter is null
1462  \param [out] cursor The cursor of all the result for current query
1463  \retval SDB_OK Operation Success
1464  \retval Others Operation Fail
1465  */
1466  INT32 getIndexes ( _sdbCursor **cursor,
1467  const CHAR *pIndexName )
1468  {
1469  if ( !pCollection )
1470  {
1471  return SDB_NOT_CONNECTED ;
1472  }
1473  return pCollection->getIndexes ( cursor, pIndexName ) ;
1474  }
1475 
1485  INT32 getIndexes ( sdbCursor &cursor,
1486  const CHAR *pIndexName )
1487  {
1488  if ( !pCollection )
1489  {
1490  return SDB_NOT_CONNECTED ;
1491  }
1492  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1493  return pCollection->getIndexes ( cursor, pIndexName ) ;
1494  }
1495 
1502  INT32 getIndexes ( std::vector<bson::BSONObj> &infos )
1503  {
1504  if ( !pCollection )
1505  {
1506  return SDB_NOT_CONNECTED ;
1507  }
1508  return pCollection->getIndexes ( infos ) ;
1509  }
1510 
1518  INT32 getIndex ( const CHAR *pIndexName, bson::BSONObj &info )
1519  {
1520  if ( !pCollection )
1521  {
1522  return SDB_NOT_CONNECTED ;
1523  }
1524  return pCollection->getIndex ( pIndexName, info ) ;
1525  }
1526 
1533  INT32 dropIndex ( const CHAR *pIndexName )
1534  {
1535  if ( !pCollection )
1536  {
1537  return SDB_NOT_CONNECTED ;
1538  }
1539  return pCollection->dropIndex ( pIndexName ) ;
1540  }
1541 
1548  INT32 create ()
1549  {
1550  if ( !pCollection )
1551  {
1552  return SDB_NOT_CONNECTED ;
1553  }
1554  return pCollection->create () ;
1555  }
1556 
1563  INT32 drop ()
1564  {
1565  if ( !pCollection )
1566  {
1567  return SDB_NOT_CONNECTED ;
1568  }
1569  return pCollection->drop () ;
1570  }
1571 
1576  const CHAR *getCollectionName ()
1577  {
1578  if ( !pCollection )
1579  {
1580  return NULL ;
1581  }
1582  return pCollection->getCollectionName () ;
1583  }
1584 
1589  const CHAR *getCSName ()
1590  {
1591  if ( !pCollection )
1592  {
1593  return NULL ;
1594  }
1595  return pCollection->getCSName () ;
1596  }
1597 
1602  const CHAR *getFullName ()
1603  {
1604  if ( !pCollection )
1605  {
1606  return NULL ;
1607  }
1608  return pCollection->getFullName () ;
1609  }
1610 
1611  /* \fn INT32 aggregate ( _sdbCursor **cursor,
1612  std::vector<bson::BSONObj> &obj
1613  )
1614  \brief Execute aggregate operation in specified collection
1615  \param [in] obj The array of bson objects
1616  \param [out] cursor The cursor handle of result
1617  \retval SDB_OK Operation Success
1618  \retval Others Operation Fail
1619  */
1620  INT32 aggregate ( _sdbCursor **cursor,
1621  std::vector<bson::BSONObj> &obj
1622  )
1623  {
1624  if ( !pCollection )
1625  {
1626  return SDB_NOT_CONNECTED ;
1627  }
1628  return pCollection->aggregate ( cursor, obj ) ;
1629  }
1630 
1640  INT32 aggregate ( sdbCursor &cursor,
1641  std::vector<bson::BSONObj> &obj
1642  )
1643  {
1644  if ( !pCollection )
1645  {
1646  return SDB_NOT_CONNECTED ;
1647  }
1648  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1649  return pCollection->aggregate ( cursor, obj ) ;
1650  }
1651 
1652  /* \fn INT32 getQueryMeta ( _sdbCursor **cursor,
1653  const bson::BSONObj &condition = _sdbStaticObject,
1654  const bson::BSONObj &selected = _sdbStaticObject,
1655  const bson::BSONObj &orderBy = _sdbStaticObject,
1656  INT64 numToSkip = 0,
1657  INT64 numToReturn = -1 ) ;
1658  \brief Get the index blocks' or data blocks' infomation for concurrent query
1659  \param [in] condition The matching rule, return all the documents if not provided
1660  \param [in] orderBy The ordered rule, result set is unordered if not provided
1661  \param [in] hint Specified the index used to scan data. e.g. {"":"ageIndex"} means
1662  using index "ageIndex" to scan data(index scan);
1663  {"":null} means table scan. when hint is not provided,
1664  database automatically match the optimal index to scan data
1665  \param [in] numToSkip Skip the first numToSkip documents, default is 0
1666  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
1667  \param [out] cursor The cursor of current query
1668  \retval SDB_OK Operation Success
1669  \retval Others Operation Fail
1670  */
1671  INT32 getQueryMeta ( _sdbCursor **cursor,
1672  const bson::BSONObj &condition = _sdbStaticObject,
1673  const bson::BSONObj &orderBy = _sdbStaticObject,
1674  const bson::BSONObj &hint = _sdbStaticObject,
1675  INT64 numToSkip = 0,
1676  INT64 numToReturn = -1 )
1677  {
1678  if ( !pCollection )
1679  {
1680  return SDB_NOT_CONNECTED ;
1681  }
1682  return pCollection->getQueryMeta ( cursor, condition, orderBy,
1683  hint, numToSkip, numToReturn ) ;
1684  }
1685 
1706  INT32 getQueryMeta ( sdbCursor &cursor,
1707  const bson::BSONObj &condition = _sdbStaticObject,
1708  const bson::BSONObj &orderBy = _sdbStaticObject,
1709  const bson::BSONObj &hint = _sdbStaticObject,
1710  INT64 numToSkip = 0,
1711  INT64 numToReturn = -1 )
1712  {
1713  if ( !pCollection )
1714  {
1715  return SDB_NOT_CONNECTED ;
1716  }
1717  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1718  return pCollection->getQueryMeta ( cursor, condition, orderBy,
1719  hint, numToSkip, numToReturn ) ;
1720  }
1721 
1735  INT32 attachCollection ( const CHAR *subClFullName,
1736  const bson::BSONObj &options)
1737  {
1738  if ( !pCollection )
1739  {
1740  return SDB_NOT_CONNECTED ;
1741  }
1742  return pCollection->attachCollection ( subClFullName, options ) ;
1743  }
1744 
1751  INT32 detachCollection ( const CHAR *subClFullName)
1752  {
1753  if ( !pCollection )
1754  {
1755  return SDB_NOT_CONNECTED ;
1756  }
1757  return pCollection->detachCollection ( subClFullName ) ;
1758  }
1759 
1795  INT32 explain ( sdbCursor &cursor,
1796  const bson::BSONObj &condition = _sdbStaticObject,
1797  const bson::BSONObj &select = _sdbStaticObject,
1798  const bson::BSONObj &orderBy = _sdbStaticObject,
1799  const bson::BSONObj &hint = _sdbStaticObject,
1800  INT64 numToSkip = 0,
1801  INT64 numToReturn = -1,
1802  INT32 flag = 0,
1803  const bson::BSONObj &options = _sdbStaticObject )
1804  {
1805  if ( !pCollection )
1806  {
1807  return SDB_NOT_CONNECTED ;
1808  }
1809  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1810  return pCollection->explain( cursor, condition, select, orderBy, hint,
1811  numToSkip, numToReturn, flag, options ) ;
1812  }
1813 
1814  INT32 explain ( _sdbCursor **cursor,
1815  const bson::BSONObj &condition = _sdbStaticObject,
1816  const bson::BSONObj &select = _sdbStaticObject,
1817  const bson::BSONObj &orderBy = _sdbStaticObject,
1818  const bson::BSONObj &hint = _sdbStaticObject,
1819  INT64 numToSkip = 0,
1820  INT64 numToReturn = -1,
1821  INT32 flag = 0,
1822  const bson::BSONObj &options = _sdbStaticObject )
1823  {
1824  if ( !pCollection )
1825  {
1826  return SDB_NOT_CONNECTED ;
1827  }
1828  return pCollection->explain( cursor, condition, select, orderBy, hint,
1829  numToSkip, numToReturn, flag, options ) ;
1830  }
1831 
1840  INT32 createLob( sdbLob &lob, const bson::OID *oid = NULL )
1841  {
1842  if ( !pCollection )
1843  {
1844  return SDB_NOT_CONNECTED ;
1845  }
1846  return pCollection->createLob( lob, oid ) ;
1847  }
1848 
1855  INT32 removeLob( const bson::OID &oid )
1856  {
1857  if ( !pCollection )
1858  {
1859  return SDB_NOT_CONNECTED ;
1860  }
1861  return pCollection->removeLob( oid ) ;
1862  }
1863 
1871  INT32 truncateLob( const bson::OID &oid, INT64 length )
1872  {
1873  if ( !pCollection )
1874  {
1875  return SDB_NOT_CONNECTED ;
1876  }
1877  return pCollection->truncateLob( oid, length ) ;
1878  }
1879 
1889  INT32 openLob( sdbLob &lob, const bson::OID &oid,
1891  {
1892  if ( !pCollection )
1893  {
1894  return SDB_NOT_CONNECTED ;
1895  }
1896  return pCollection->openLob( lob, oid, mode ) ;
1897  }
1898 
1916  INT32 listLobs( sdbCursor &cursor,
1917  const bson::BSONObj &condition = _sdbStaticObject,
1918  const bson::BSONObj &selected = _sdbStaticObject,
1919  const bson::BSONObj &orderBy = _sdbStaticObject,
1920  const bson::BSONObj &hint = _sdbStaticObject,
1921  INT64 numToSkip = 0,
1922  INT64 numToReturn = -1 )
1923  {
1924  if ( !pCollection )
1925  {
1926  return SDB_NOT_CONNECTED ;
1927  }
1928  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1929  return pCollection->listLobs( cursor, condition, selected, orderBy,
1930  hint, numToSkip, numToReturn ) ;
1931  }
1932 
1933  INT32 listLobs( _sdbCursor **cursor,
1934  const bson::BSONObj &condition = _sdbStaticObject,
1935  const bson::BSONObj &selected = _sdbStaticObject,
1936  const bson::BSONObj &orderBy = _sdbStaticObject,
1937  const bson::BSONObj &hint = _sdbStaticObject,
1938  INT64 numToSkip = 0,
1939  INT64 numToReturn = -1 )
1940  {
1941  if ( !pCollection )
1942  {
1943  return SDB_NOT_CONNECTED ;
1944  }
1945  return pCollection->listLobs( cursor, condition, selected, orderBy,
1946  hint, numToSkip, numToReturn ) ;
1947  }
1948 
1957  INT32 createLobID( bson::OID &oid, const CHAR *pTimeStamp = NULL )
1958  {
1959  if ( !pCollection )
1960  {
1961  return SDB_NOT_CONNECTED ;
1962  }
1963  return pCollection->createLobID( oid, pTimeStamp ) ;
1964  }
1965 
1971  INT32 truncate()
1972  {
1973  if ( !pCollection )
1974  {
1975  return SDB_NOT_CONNECTED ;
1976  }
1977  return pCollection->truncate() ;
1978  }
1979 
1989  INT32 createIdIndex( const bson::BSONObj &options = _sdbStaticObject )
1990  {
1991  if ( !pCollection )
1992  {
1993  return SDB_NOT_CONNECTED ;
1994  }
1995  return pCollection->createIdIndex( options ) ;
1996  }
1997 
2004  INT32 dropIdIndex()
2005  {
2006  if ( !pCollection )
2007  {
2008  return SDB_NOT_CONNECTED ;
2009  }
2010  return pCollection->dropIdIndex() ;
2011  }
2012 
2030  INT32 createAutoIncrement ( const bson::BSONObj &options )
2031  {
2032  if ( !pCollection )
2033  {
2034  return SDB_NOT_CONNECTED ;
2035  }
2036  return pCollection->createAutoIncrement( options ) ;
2037  }
2038 
2045  INT32 createAutoIncrement ( const std::vector<bson::BSONObj> &options )
2046  {
2047  if ( !pCollection )
2048  {
2049  return SDB_NOT_CONNECTED ;
2050  }
2051  return pCollection->createAutoIncrement( options ) ;
2052  }
2053 
2060  INT32 dropAutoIncrement ( const CHAR * fieldName )
2061  {
2062  if ( !pCollection )
2063  {
2064  return SDB_NOT_CONNECTED ;
2065  }
2066  return pCollection->dropAutoIncrement( fieldName ) ;
2067  }
2068 
2075  INT32 dropAutoIncrement ( const std::vector<const CHAR*> &fieldNames )
2076  {
2077  if ( !pCollection )
2078  {
2079  return SDB_NOT_CONNECTED ;
2080  }
2081  return pCollection->dropAutoIncrement( fieldNames ) ;
2082  }
2083 
2097  INT32 enableSharding ( const bson::BSONObj & options = _sdbStaticObject )
2098  {
2099  if ( !pCollection )
2100  {
2101  return SDB_NOT_CONNECTED ;
2102  }
2103  return pCollection->enableSharding( options ) ;
2104  }
2105 
2111  INT32 disableSharding ()
2112  {
2113  if ( !pCollection )
2114  {
2115  return SDB_NOT_CONNECTED ;
2116  }
2117  return pCollection->disableSharding() ;
2118  }
2119 
2128  INT32 enableCompression ( const bson::BSONObj & options = _sdbStaticObject )
2129  {
2130  if ( !pCollection )
2131  {
2132  return SDB_NOT_CONNECTED ;
2133  }
2134  return pCollection->enableCompression( options ) ;
2135  }
2136 
2142  INT32 disableCompression ()
2143  {
2144  if ( !pCollection )
2145  {
2146  return SDB_NOT_CONNECTED ;
2147  }
2148  return pCollection->disableCompression() ;
2149  }
2150 
2171  INT32 setAttributes ( const bson::BSONObj &options )
2172  {
2173  if ( !pCollection )
2174  {
2175  return SDB_NOT_CONNECTED ;
2176  }
2177  return pCollection->setAttributes( options ) ;
2178  }
2179 
2180  /* \fn INT32 pop( const bson::BSONObj &option )
2181  \brief Pop records from a capped collection
2182  \param [in] option The pop options as follows:
2183 
2184  Direction : The direction to pop record. 1: pop forward. -1: pop backward.
2185  The default value is 1.
2186  \retval SDB_OK Operation Success
2187  \retval Others Operation Fail
2188  */
2189  INT32 pop ( const bson::BSONObj &option = _sdbStaticObject )
2190  {
2191  if ( !pCollection )
2192  {
2193  return SDB_NOT_CONNECTED ;
2194  }
2195  return pCollection->pop( option ) ;
2196  }
2197 
2198  INT32 listLobPieces( _sdbCursor **cursor,
2199  const bson::BSONObj &condition = _sdbStaticObject,
2200  const bson::BSONObj &selected = _sdbStaticObject,
2201  const bson::BSONObj &orderBy = _sdbStaticObject,
2202  const bson::BSONObj &hint = _sdbStaticObject,
2203  INT64 numToSkip = 0,
2204  INT64 numToReturn = -1 )
2205  {
2206  if( !pCollection )
2207  {
2208  return SDB_NOT_CONNECTED ;
2209  }
2210  return pCollection->listLobPieces( cursor, condition, selected,
2211  orderBy, hint, numToSkip,
2212  numToReturn ) ;
2213  }
2214 
2228  INT32 listLobPieces( sdbCursor &cursor,
2229  const bson::BSONObj &condition = _sdbStaticObject,
2230  const bson::BSONObj &selected = _sdbStaticObject,
2231  const bson::BSONObj &orderBy = _sdbStaticObject,
2232  const bson::BSONObj &hint = _sdbStaticObject,
2233  INT64 numToSkip = 0,
2234  INT64 numToReturn = -1 )
2235  {
2236  if( !pCollection )
2237  {
2238  return SDB_NOT_CONNECTED ;
2239  }
2240  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2241  return pCollection->listLobPieces( cursor, condition, selected,
2242  orderBy, hint, numToSkip,
2243  numToReturn ) ;
2244  }
2245 
2246  /* \fn INT32 getDetail ( _sdbCursor **cursor )
2247  \brief Get the detail of the collection.
2248  \param [out] cursor Return the all the info of current collection.
2249  \retval SDB_OK Operation Success
2250  \retval Others Operation Fail
2251  */
2252  INT32 getDetail ( _sdbCursor **cursor )
2253  {
2254  if ( !pCollection )
2255  {
2256  return SDB_NOT_CONNECTED ;
2257  }
2258  return pCollection->getDetail ( cursor ) ;
2259  }
2260 
2267  INT32 getDetail( sdbCursor &cursor )
2268  {
2269  if ( !pCollection)
2270  {
2271  return SDB_NOT_CONNECTED ;
2272  }
2273  return pCollection->getDetail( cursor ) ;
2274  }
2275  } ;
2276 
2281  {
2282  SDB_NODE_ALL = 0,
2283  SDB_NODE_ACTIVE,
2284  SDB_NODE_INACTIVE,
2285  SDB_NODE_UNKNOWN
2286  } ;
2287 
2291  typedef enum sdbNodeStatus sdbNodeStatus ;
2292 
2293  class DLLEXPORT _sdbNode
2294  {
2295  private :
2296  _sdbNode ( const _sdbNode& other ) ;
2297  _sdbNode& operator=( const _sdbNode& ) ;
2298  public :
2299  _sdbNode () {}
2300  virtual ~_sdbNode () {}
2301  // connect to the current node
2302  virtual INT32 connect ( _sdb **dbConn ) = 0 ;
2303  virtual INT32 connect ( sdb &dbConn ) = 0 ;
2304 
2305  // get status of the current node
2306  virtual sdbNodeStatus getStatus () = 0 ;
2307 
2308  // get host name of the current node
2309  virtual const CHAR *getHostName () = 0 ;
2310 
2311  // get service name of the current node
2312  virtual const CHAR *getServiceName () = 0 ;
2313 
2314  // get node name of the current node
2315  virtual const CHAR *getNodeName () = 0 ;
2316 
2317  // get node id of the current node
2318  virtual INT32 getNodeID( INT32 &nodeID ) const = 0 ;
2319 
2320  // stop the node
2321  virtual INT32 stop () = 0 ;
2322 
2323  // start the node
2324  virtual INT32 start () = 0 ;
2325 
2326  // modify config for the current node
2327 /* virtual INT32 modifyConfig ( std::map<std::string,std::string>
2328  &config ) = 0 ; */
2329  } ;
2330 
2337  class DLLEXPORT sdbNode
2338  {
2339  private :
2344  sdbNode ( const sdbNode& other ) ;
2345 
2351  sdbNode& operator=( const sdbNode& ) ;
2352  public :
2359  _sdbNode *pNode ;
2360 
2365  {
2366  pNode = NULL ;
2367  }
2368 
2373  {
2374  if ( pNode )
2375  {
2376  delete pNode ;
2377  }
2378  }
2379  /* \fn connect ( _sdb **dbConn )
2380  \brief Connect to the current node.
2381  \param [out] dbConn The database obj of current connection
2382  \retval SDB_OK Operation Success
2383  \retval Others Operation Fail
2384  */
2385  INT32 connect ( _sdb **dbConn )
2386  {
2387  if ( !pNode )
2388  {
2389  return SDB_NOT_CONNECTED ;
2390  }
2391  return pNode->connect ( dbConn ) ;
2392  }
2393 
2400  INT32 connect ( sdb &dbConn )
2401  {
2402  if ( !pNode )
2403  {
2404  return SDB_NOT_CONNECTED ;
2405  }
2406  // we can not use dbConn.pSDB here,
2407  // for sdb had not define yet.
2408  // RELEASE_INNER_HANDLE( dbConn.pSDB ) ;
2409  return pNode->connect ( dbConn ) ;
2410  }
2411 
2418  sdbNodeStatus getStatus ()
2419  {
2420  if ( !pNode )
2421  {
2422  return SDB_NODE_UNKNOWN ;
2423  }
2424  return pNode->getStatus () ;
2425  }
2426 
2431  const CHAR *getHostName ()
2432  {
2433  if ( !pNode )
2434  {
2435  return NULL ;
2436  }
2437  return pNode->getHostName () ;
2438  }
2439 
2444  const CHAR *getServiceName ()
2445  {
2446  if ( !pNode )
2447  {
2448  return NULL ;
2449  }
2450  return pNode->getServiceName () ;
2451  }
2452 
2457  const CHAR *getNodeName ()
2458  {
2459  if ( !pNode )
2460  {
2461  return NULL ;
2462  }
2463  return pNode->getNodeName () ;
2464  }
2465 
2470  INT32 getNodeID( INT32 &nodeID ) const
2471  {
2472  if ( !pNode )
2473  {
2474  return SDB_NOT_CONNECTED ;
2475  }
2476  return pNode->getNodeID( nodeID ) ;
2477  }
2478 
2484  INT32 stop ()
2485  {
2486  if ( !pNode )
2487  {
2488  return SDB_NOT_CONNECTED ;
2489  }
2490  return pNode->stop () ;
2491  }
2492 
2498  INT32 start ()
2499  {
2500  if ( !pNode )
2501  {
2502  return SDB_NOT_CONNECTED ;
2503  }
2504  return pNode->start () ;
2505  }
2506 /* INT32 modifyConfig ( std::map<std::string,std::string> &config )
2507  {
2508  if ( !pNode )
2509  {
2510  return NULL ;
2511  }
2512  return pNode->modifyConfig ( config ) ;
2513  }*/
2514  } ;
2515 
2516  class DLLEXPORT _sdbReplicaGroup
2517  {
2518  private :
2519  _sdbReplicaGroup ( const _sdbReplicaGroup& other ) ;
2520  _sdbReplicaGroup& operator=( const _sdbReplicaGroup& ) ;
2521  public :
2522  _sdbReplicaGroup () {}
2523  virtual ~_sdbReplicaGroup () {}
2524  // get number of logical nodes
2525  virtual INT32 getNodeNum ( sdbNodeStatus status, INT32 *num ) = 0 ;
2526 
2527  // get detailed information for the set
2528  virtual INT32 getDetail ( bson::BSONObj &result ) = 0 ;
2529 
2530  // get the master node
2531  virtual INT32 getMaster ( _sdbNode **node ) = 0 ;
2532  virtual INT32 getMaster ( sdbNode &node ) = 0 ;
2533 
2534  // get one of the slave node
2535  virtual INT32 getSlave ( _sdbNode **node,
2536  const vector<INT32>& positions = _sdbStaticVec ) = 0 ;
2537  virtual INT32 getSlave ( sdbNode &node,
2538  const vector<INT32>& positions = _sdbStaticVec ) = 0 ;
2539 
2540  // get a given node by name
2541  virtual INT32 getNode ( const CHAR *pNodeName,
2542  _sdbNode **node ) = 0 ;
2543  virtual INT32 getNode ( const CHAR *pNodeName,
2544  sdbNode &node ) = 0 ;
2545 
2546  // get a given node by host/service name
2547  virtual INT32 getNode ( const CHAR *pHostName,
2548  const CHAR *pServiceName,
2549  _sdbNode **node ) = 0 ;
2550  virtual INT32 getNode ( const CHAR *pHostName,
2551  const CHAR *pServiceName,
2552  sdbNode &node ) = 0 ;
2553 
2554  // create a new node in current replica group
2555  virtual INT32 createNode ( const CHAR *pHostName,
2556  const CHAR *pServiceName,
2557  const CHAR *pDatabasePath,
2558  std::map<std::string,std::string> &config )= 0;
2559 
2560  virtual INT32 createNode ( const CHAR *pHostName,
2561  const CHAR *pServiceName,
2562  const CHAR *pDatabasePath,
2563  const bson::BSONObj &options = _sdbStaticObject )= 0;
2564 
2565  // remove the specified node in current replica group
2566  virtual INT32 removeNode ( const CHAR *pHostName,
2567  const CHAR *pServiceName,
2568  const bson::BSONObj &configure = _sdbStaticObject ) = 0 ;
2569  // stop the replica group
2570  virtual INT32 stop () = 0 ;
2571 
2572  // start the replica group
2573  virtual INT32 start () = 0 ;
2574 
2575  // get the replica group name
2576  virtual const CHAR *getName () = 0 ;
2577 
2578  // whether the current replica group is catalog replica group or not
2579  virtual BOOLEAN isCatalog () = 0 ;
2580 
2581  // attach node
2582  virtual INT32 attachNode( const CHAR *pHostName,
2583  const CHAR *pSvcName,
2584  const bson::BSONObj &options ) = 0 ;
2585 
2586  // detach node
2587  virtual INT32 detachNode( const CHAR *pHostName,
2588  const CHAR *pSvcName,
2589  const bson::BSONObj &options ) = 0 ;
2590 
2591  // reelect primary node
2592  virtual INT32 reelect( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
2593  } ;
2594 
2598  class DLLEXPORT sdbReplicaGroup
2599  {
2600  private :
2601  sdbReplicaGroup ( const sdbReplicaGroup& other ) ;
2602  sdbReplicaGroup& operator=( const sdbReplicaGroup& ) ;
2603  public :
2610  _sdbReplicaGroup *pReplicaGroup ;
2611 
2616  {
2617  pReplicaGroup = NULL ;
2618  }
2619 
2624  {
2625  if ( pReplicaGroup )
2626  {
2627  delete pReplicaGroup ;
2628  }
2629  }
2630 
2645  INT32 getNodeNum ( sdbNodeStatus status, INT32 *num )
2646  {
2647  if ( !pReplicaGroup )
2648  {
2649  return SDB_NOT_CONNECTED ;
2650  }
2651  return pReplicaGroup->getNodeNum ( status, num ) ;
2652  }
2653 
2660  INT32 getDetail ( bson::BSONObj &result )
2661  {
2662  if ( !pReplicaGroup )
2663  {
2664  return SDB_NOT_CONNECTED ;
2665  }
2666  return pReplicaGroup->getDetail ( result ) ;
2667  }
2668 
2669  /* \fn INT32 getMaster ( _sdbNode **node )
2670  \brief Get the master node of the current replica group.
2671  \param [out] node The master node.If not exit,return null.
2672  \retval SDB_OK Operation Success
2673  \retval Others Operation Fail
2674  */
2675  INT32 getMaster ( _sdbNode **node )
2676  {
2677  if ( !pReplicaGroup )
2678  {
2679  return SDB_NOT_CONNECTED ;
2680  }
2681  return pReplicaGroup->getMaster ( node ) ;
2682  }
2683 
2690  INT32 getMaster ( sdbNode &node )
2691  {
2692  if ( !pReplicaGroup )
2693  {
2694  return SDB_NOT_CONNECTED ;
2695  }
2696  RELEASE_INNER_HANDLE( node.pNode ) ;
2697  return pReplicaGroup->getMaster ( node ) ;
2698  }
2699 
2700  /* \fn INT32 getSlave ( _sdbNode **node, const vector<INT32>& positions )
2701  \brief Get one of slave node of the current replica group,
2702  if no slave exists then get master
2703  \param [in] positions The positions of nodes
2704  \param [out] node The slave node
2705  \retval SDB_OK Operation Success
2706  \retval Others Operation Fail
2707  */
2708  INT32 getSlave ( _sdbNode **node,
2709  const vector<INT32>& positions = _sdbStaticVec )
2710  {
2711  if ( !pReplicaGroup )
2712  {
2713  return SDB_NOT_CONNECTED ;
2714  }
2715  return pReplicaGroup->getSlave ( node, positions ) ;
2716  }
2717 
2726  INT32 getSlave ( sdbNode &node,
2727  const vector<INT32>& positions = _sdbStaticVec )
2728  {
2729  if ( !pReplicaGroup )
2730  {
2731  return SDB_NOT_CONNECTED ;
2732  }
2733  RELEASE_INNER_HANDLE( node.pNode ) ;
2734  return pReplicaGroup->getSlave ( node, positions ) ;
2735  }
2736 
2737  /* \fn INT32 getNode ( const CHAR *pNodeName,
2738  _sdbNode **node )
2739  \brief Get specified node from current replica group.
2740  \param [in] pNodeName The name of the node, with the format of "hostname:port".
2741  \param [out] node The specified node
2742  \retval SDB_OK Operation Success
2743  \retval Others Operation Fail
2744  */
2745  INT32 getNode ( const CHAR *pNodeName,
2746  _sdbNode **node )
2747  {
2748  if ( !pReplicaGroup )
2749  {
2750  return SDB_NOT_CONNECTED ;
2751  }
2752  return pReplicaGroup->getNode ( pNodeName, node ) ;
2753  }
2754 
2763  INT32 getNode ( const CHAR *pNodeName,
2764  sdbNode &node )
2765  {
2766  if ( !pReplicaGroup )
2767  {
2768  return SDB_NOT_CONNECTED ;
2769  }
2770  RELEASE_INNER_HANDLE( node.pNode ) ;
2771  return pReplicaGroup->getNode ( pNodeName, node ) ;
2772  }
2773 
2774  INT32 getNode ( const CHAR *pHostName,
2775  const CHAR *pServiceName,
2776  _sdbNode **node )
2777  {
2778  if ( !pReplicaGroup )
2779  {
2780  return SDB_NOT_CONNECTED ;
2781  }
2782  return pReplicaGroup->getNode ( pHostName, pServiceName, node ) ;
2783  }
2784 
2795  INT32 getNode ( const CHAR *pHostName,
2796  const CHAR *pServiceName,
2797  sdbNode &node )
2798  {
2799  if ( !pReplicaGroup )
2800  {
2801  return SDB_NOT_CONNECTED ;
2802  }
2803  RELEASE_INNER_HANDLE( node.pNode ) ;
2804  return pReplicaGroup->getNode ( pHostName, pServiceName, node ) ;
2805  }
2806 
2820  INT32 createNode ( const CHAR *pHostName,
2821  const CHAR *pServiceName,
2822  const CHAR *pDatabasePath,
2823  std::map<std::string,std::string> &config )
2824  {
2825  if ( !pReplicaGroup )
2826  {
2827  return SDB_NOT_CONNECTED ;
2828  }
2829  return pReplicaGroup->createNode ( pHostName, pServiceName,
2830  pDatabasePath, config ) ;
2831  }
2832 
2845  INT32 createNode ( const CHAR *pHostName,
2846  const CHAR *pServiceName,
2847  const CHAR *pDatabasePath,
2848  const bson::BSONObj &options = _sdbStaticObject )
2849  {
2850  if ( !pReplicaGroup )
2851  {
2852  return SDB_NOT_CONNECTED ;
2853  }
2854  return pReplicaGroup->createNode ( pHostName, pServiceName,
2855  pDatabasePath, options ) ;
2856  }
2857 
2868  INT32 removeNode ( const CHAR *pHostName,
2869  const CHAR *pServiceName,
2870  const bson::BSONObj &configure = _sdbStaticObject )
2871  {
2872  if ( !pReplicaGroup )
2873  {
2874  return SDB_NOT_CONNECTED ;
2875  }
2876  return pReplicaGroup->removeNode ( pHostName, pServiceName,
2877  configure ) ;
2878  }
2884  INT32 stop ()
2885  {
2886  if ( !pReplicaGroup )
2887  {
2888  return SDB_NOT_CONNECTED ;
2889  }
2890  return pReplicaGroup->stop () ;
2891  }
2892 
2898  INT32 start ()
2899  {
2900  if ( !pReplicaGroup )
2901  {
2902  return SDB_NOT_CONNECTED ;
2903  }
2904  return pReplicaGroup->start () ;
2905  }
2906 
2911  const CHAR *getName ()
2912  {
2913  if ( !pReplicaGroup )
2914  {
2915  return NULL ;
2916  }
2917  return pReplicaGroup->getName() ;
2918  }
2919 
2925  BOOLEAN isCatalog ()
2926  {
2927  if ( !pReplicaGroup )
2928  {
2929  return FALSE ;
2930  }
2931  return pReplicaGroup->isCatalog() ;
2932  }
2933 
2948  INT32 attachNode( const CHAR *pHostName,
2949  const CHAR *pSvcName,
2950  const bson::BSONObj &options )
2951  {
2952  if ( !pReplicaGroup )
2953  {
2954  return SDB_NOT_CONNECTED ;
2955  }
2956  return pReplicaGroup->attachNode( pHostName, pSvcName, options ) ;
2957  }
2958 
2974  INT32 detachNode( const CHAR *pHostName,
2975  const CHAR *pSvcName,
2976  const bson::BSONObj &options )
2977  {
2978  if ( !pReplicaGroup )
2979  {
2980  return SDB_NOT_CONNECTED ;
2981  }
2982  return pReplicaGroup->detachNode( pHostName, pSvcName, options ) ;
2983  }
2984 
2993  INT32 reelect( const bson::BSONObj &options = _sdbStaticObject )
2994  {
2995  if( !pReplicaGroup )
2996  {
2997  return SDB_NOT_CONNECTED ;
2998  }
2999  return pReplicaGroup->reelect( options ) ;
3000  }
3001  } ;
3002 
3003  class DLLEXPORT _sdbCollectionSpace
3004  {
3005  private :
3006  _sdbCollectionSpace ( const _sdbCollectionSpace& other ) ;
3007  _sdbCollectionSpace& operator=( const _sdbCollectionSpace& ) ;
3008  public :
3009  _sdbCollectionSpace () {}
3010  virtual ~_sdbCollectionSpace () {}
3011  // get a collection object
3012  virtual INT32 getCollection ( const CHAR *pCollectionName,
3013  _sdbCollection **collection,
3014  BOOLEAN checkExist = TRUE ) = 0 ;
3015 
3016  virtual INT32 getCollection ( const CHAR *pCollectionName,
3017  sdbCollection &collection,
3018  BOOLEAN checkExist = TRUE ) = 0 ;
3019 
3020  // create a new collection object with options
3021  virtual INT32 createCollection ( const CHAR *pCollection,
3022  const bson::BSONObj &options,
3023  _sdbCollection **collection ) = 0 ;
3024 
3025  virtual INT32 createCollection ( const CHAR *pCollection,
3026  const bson::BSONObj &options,
3027  sdbCollection &collection ) = 0 ;
3028 
3029  // create a new collection object
3030  virtual INT32 createCollection ( const CHAR *pCollection,
3031  _sdbCollection **collection ) = 0 ;
3032 
3033  virtual INT32 createCollection ( const CHAR *pCollection,
3034  sdbCollection &collection ) = 0 ;
3035 
3036  // drop an existing collection
3037  virtual INT32 dropCollection ( const CHAR *pCollection ) = 0 ;
3038 
3039  // create a collection space with current collection space name
3040  virtual INT32 create () = 0 ;
3041  // drop a collection space with current collection space name
3042  virtual INT32 drop () = 0 ;
3043 
3044  // get the collectonSpace's name
3045  virtual const CHAR *getCSName () = 0 ;
3046 
3047  // rename collection
3048  virtual INT32 renameCollection( const CHAR* oldName, const CHAR* newName,
3049  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
3050 
3051  virtual INT32 alterCollectionSpace ( const bson::BSONObj & options ) = 0 ;
3052 
3053  virtual INT32 setDomain ( const bson::BSONObj & options ) = 0 ;
3054 
3055  virtual INT32 removeDomain () = 0 ;
3056 
3057  virtual INT32 enableCapped () = 0 ;
3058 
3059  virtual INT32 disableCapped () = 0 ;
3060 
3061  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
3062  } ;
3066  class DLLEXPORT sdbCollectionSpace
3067  {
3068  private :
3073  sdbCollectionSpace ( const sdbCollectionSpace& other ) ;
3074 
3080  sdbCollectionSpace& operator=( const sdbCollectionSpace& ) ;
3081  public :
3088  _sdbCollectionSpace *pCollectionSpace ;
3089 
3094  {
3095  pCollectionSpace = NULL ;
3096  }
3097 
3102  {
3103  if ( pCollectionSpace )
3104  {
3105  delete pCollectionSpace ;
3106  }
3107  }
3108 
3109  INT32 getCollection ( const CHAR *pCollectionName,
3110  _sdbCollection **collection,
3111  BOOLEAN checkExist = TRUE )
3112  {
3113  if ( !pCollectionSpace )
3114  {
3115  return SDB_NOT_CONNECTED ;
3116  }
3117  return pCollectionSpace->getCollection ( pCollectionName,
3118  collection, checkExist ) ;
3119  }
3120 
3131  INT32 getCollection ( const CHAR *pCollectionName,
3132  sdbCollection &collection,
3133  BOOLEAN checkExist = TRUE )
3134  {
3135  if ( !pCollectionSpace )
3136  {
3137  return SDB_NOT_CONNECTED ;
3138  }
3139  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3140  return pCollectionSpace->getCollection ( pCollectionName,
3141  collection,
3142  checkExist ) ;
3143  }
3144 
3145  INT32 createCollection ( const CHAR *pCollection,
3146  const bson::BSONObj &options,
3147  _sdbCollection **collection )
3148  {
3149  if ( !pCollectionSpace )
3150  {
3151  return SDB_NOT_CONNECTED ;
3152  }
3153  return pCollectionSpace->createCollection ( pCollection,
3154  options,
3155  collection ) ;
3156  }
3157 
3170  INT32 createCollection ( const CHAR *pCollection,
3171  const bson::BSONObj &options,
3172  sdbCollection &collection )
3173  {
3174  if ( !pCollectionSpace )
3175  {
3176  return SDB_NOT_CONNECTED ;
3177  }
3178  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3179  return pCollectionSpace->createCollection ( pCollection,
3180  options,
3181  collection ) ;
3182  }
3183 
3184  INT32 createCollection ( const CHAR *pCollection,
3185  _sdbCollection **collection )
3186  {
3187  if ( !pCollectionSpace )
3188  {
3189  return SDB_NOT_CONNECTED ;
3190  }
3191  return pCollectionSpace->createCollection ( pCollection,
3192  collection ) ;
3193  }
3194 
3204  INT32 createCollection ( const CHAR *pCollection,
3205  sdbCollection &collection )
3206  {
3207  if ( !pCollectionSpace )
3208  {
3209  return SDB_NOT_CONNECTED ;
3210  }
3211  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3212  return pCollectionSpace->createCollection ( pCollection,
3213  collection ) ;
3214  }
3215 
3222  INT32 dropCollection ( const CHAR *pCollection )
3223  {
3224  if ( !pCollectionSpace )
3225  {
3226  return SDB_NOT_CONNECTED ;
3227  }
3228  return pCollectionSpace->dropCollection ( pCollection ) ;
3229  }
3230 
3237  INT32 create ()
3238  {
3239  if ( !pCollectionSpace )
3240  {
3241  return SDB_NOT_CONNECTED ;
3242  }
3243  return pCollectionSpace->create () ;
3244  }
3245 
3252  INT32 drop ()
3253  {
3254  if ( !pCollectionSpace )
3255  {
3256  return SDB_NOT_CONNECTED ;
3257  }
3258  return pCollectionSpace->drop () ;
3259  }
3260 
3265  const CHAR *getCSName ()
3266  {
3267  if ( !pCollectionSpace )
3268  {
3269  return NULL ;
3270  }
3271  return pCollectionSpace->getCSName () ;
3272  }
3273 
3284  INT32 renameCollection( const CHAR* oldName, const CHAR* newName,
3285  const bson::BSONObj &options = _sdbStaticObject )
3286  {
3287  if( !pCollectionSpace )
3288  {
3289  return SDB_NOT_CONNECTED ;
3290  }
3291  return pCollectionSpace->renameCollection( oldName, newName, options ) ;
3292  }
3293 
3305  INT32 alterCollectionSpace ( const bson::BSONObj & options )
3306  {
3307  if ( NULL == pCollectionSpace )
3308  {
3309  return SDB_NOT_CONNECTED ;
3310  }
3311  return pCollectionSpace->alterCollectionSpace( options ) ;
3312  }
3313 
3323  INT32 setDomain ( const bson::BSONObj & options )
3324  {
3325  if ( NULL == pCollectionSpace )
3326  {
3327  return SDB_NOT_CONNECTED ;
3328  }
3329  return pCollectionSpace->setDomain( options ) ;
3330  }
3331 
3337  INT32 removeDomain ()
3338  {
3339  if ( NULL == pCollectionSpace )
3340  {
3341  return SDB_NOT_CONNECTED ;
3342  }
3343  return pCollectionSpace->removeDomain() ;
3344  }
3345 
3351  INT32 enableCapped ()
3352  {
3353  if ( NULL == pCollectionSpace )
3354  {
3355  return SDB_NOT_CONNECTED ;
3356  }
3357  return pCollectionSpace->enableCapped() ;
3358  }
3359 
3365  INT32 disableCapped ()
3366  {
3367  if ( NULL == pCollectionSpace )
3368  {
3369  return SDB_NOT_CONNECTED ;
3370  }
3371  return pCollectionSpace->disableCapped() ;
3372  }
3373 
3385  INT32 setAttributes ( const bson::BSONObj & options )
3386  {
3387  if ( NULL == pCollectionSpace )
3388  {
3389  return SDB_NOT_CONNECTED ;
3390  }
3391  return pCollectionSpace->setAttributes( options ) ;
3392  }
3393  } ;
3394 
3395  class DLLEXPORT _sdbDomain
3396  {
3397  private :
3398  _sdbDomain ( const _sdbDomain& other ) ; // non construction-copyable
3399  _sdbDomain& operator= ( const _sdbDomain& ) ; // non copyable
3400  public :
3401  _sdbDomain () {}
3402  virtual ~_sdbDomain () {}
3403 
3404  virtual const CHAR* getName () = 0 ;
3405 
3406  virtual INT32 alterDomain ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
3407 
3408  virtual INT32 listCollectionSpacesInDomain ( _sdbCursor **cursor ) = 0 ;
3409 
3410  virtual INT32 listCollectionSpacesInDomain ( sdbCursor &cursor ) = 0 ;
3411 
3412  virtual INT32 listCollectionsInDomain ( _sdbCursor **cursor ) = 0 ;
3413 
3414  virtual INT32 listCollectionsInDomain ( sdbCursor &cursor ) = 0 ;
3415 
3416  virtual INT32 listReplicaGroupInDomain( _sdbCursor **cursor ) = 0 ;
3417 
3418  virtual INT32 listReplicaGroupInDomain( sdbCursor &cursor ) = 0 ;
3419 
3420  virtual INT32 addGroups ( const bson::BSONObj & options ) = 0 ;
3421 
3422  virtual INT32 setGroups ( const bson::BSONObj & options ) = 0 ;
3423 
3424  virtual INT32 removeGroups ( const bson::BSONObj & options ) = 0 ;
3425 
3426  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
3427  } ;
3428 
3432  class DLLEXPORT sdbDomain
3433  {
3434  private :
3435  sdbDomain ( const sdbDomain& ) ; // non construction-copyable
3436  sdbDomain& operator= ( const sdbDomain& ) ; // non copyable
3437  public :
3438 
3445  _sdbDomain *pDomain ;
3446 
3450  sdbDomain() { pDomain = NULL ; }
3451 
3456  {
3457  if ( pDomain )
3458  {
3459  delete pDomain ;
3460  }
3461  }
3462 
3467  const CHAR *getName ()
3468  {
3469  if ( !pDomain )
3470  {
3471  return NULL ;
3472  }
3473  return pDomain->getName() ;
3474  }
3475 
3493  INT32 alterDomain ( const bson::BSONObj &options )
3494  {
3495  if ( !pDomain )
3496  {
3497  return SDB_NOT_CONNECTED ;
3498  }
3499  return pDomain->alterDomain ( options ) ;
3500  }
3501 
3512  INT32 addGroups ( const bson::BSONObj & options )
3513  {
3514  if ( NULL == pDomain )
3515  {
3516  return SDB_NOT_CONNECTED ;
3517  }
3518  return pDomain->addGroups( options ) ;
3519  }
3520 
3533  INT32 setGroups ( const bson::BSONObj & options )
3534  {
3535  if ( NULL == pDomain )
3536  {
3537  return SDB_NOT_CONNECTED ;
3538  }
3539  return pDomain->setGroups( options ) ;
3540  }
3541 
3553  INT32 removeGroups ( const bson::BSONObj & options )
3554  {
3555  if ( NULL == pDomain )
3556  {
3557  return SDB_NOT_CONNECTED ;
3558  }
3559  return pDomain->removeGroups( options ) ;
3560  }
3561 
3579  INT32 setAttributes ( const bson::BSONObj &options )
3580  {
3581  if ( !pDomain )
3582  {
3583  return SDB_NOT_CONNECTED ;
3584  }
3585  return pDomain->setAttributes( options ) ;
3586  }
3587 
3595  INT32 listCollectionSpacesInDomain ( sdbCursor &cursor )
3596  {
3597  if ( !pDomain )
3598  {
3599  return SDB_NOT_CONNECTED ;
3600  }
3601  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
3602  return pDomain->listCollectionSpacesInDomain ( cursor ) ;
3603  }
3604 
3605  INT32 listCollectionSpacesInDomain ( _sdbCursor **cursor )
3606  {
3607  if ( !pDomain )
3608  {
3609  return SDB_NOT_CONNECTED ;
3610  }
3611  return pDomain->listCollectionSpacesInDomain ( cursor ) ;
3612  }
3613 
3621  INT32 listCollectionsInDomain ( sdbCursor &cursor )
3622  {
3623  if ( !pDomain )
3624  {
3625  return SDB_NOT_CONNECTED ;
3626  }
3627  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
3628  return pDomain->listCollectionsInDomain ( cursor ) ;
3629  }
3630 
3638  INT32 listCollectionsInDomain ( _sdbCursor **cursor )
3639  {
3640  if ( !pDomain )
3641  {
3642  return SDB_NOT_CONNECTED ;
3643  }
3644  return pDomain->listCollectionsInDomain ( cursor ) ;
3645  }
3646 
3647  INT32 listReplicaGroupInDomain( _sdbCursor **cursor )
3648  {
3649  if ( !pDomain )
3650  {
3651  return SDB_NOT_CONNECTED ;
3652  }
3653  return pDomain->listReplicaGroupInDomain( cursor ) ;
3654  }
3655 
3662  INT32 listReplicaGroupInDomain( sdbCursor &cursor )
3663  {
3664  if ( !pDomain )
3665  {
3666  return SDB_NOT_CONNECTED ;
3667  }
3668  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
3669  return pDomain->listReplicaGroupInDomain( cursor ) ;
3670  }
3671  };
3672 
3673  class DLLEXPORT _sdbDataCenter
3674  {
3675  private :
3676  _sdbDataCenter ( const _sdbDataCenter& other ) ; // non construction-copyable
3677  _sdbDataCenter& operator= ( const _sdbDataCenter& ) ; // non copyable
3678 
3679  public :
3680  _sdbDataCenter () {}
3681  virtual ~_sdbDataCenter () {}
3682 
3683  public :
3684  virtual const CHAR *getName () = 0 ;
3685  virtual INT32 getDetail( bson::BSONObj &retInfo ) = 0 ;
3686  virtual INT32 activateDC() = 0 ;
3687  virtual INT32 deactivateDC() = 0 ;
3688  virtual INT32 enableReadOnly( BOOLEAN isReadOnly ) = 0 ;
3689  virtual INT32 createImage( const CHAR *pCataAddrList ) = 0 ;
3690  virtual INT32 removeImage() = 0 ;
3691  virtual INT32 enableImage() = 0 ;
3692  virtual INT32 disableImage() = 0 ;
3693  virtual INT32 attachGroups( const bson::BSONObj &info ) = 0 ;
3694  virtual INT32 detachGroups( const bson::BSONObj &info ) = 0 ;
3695 
3696  } ;
3697 
3698  /* \class sdbDataCenter
3699  \brief Database operation interfaces of data center.
3700  */
3701  class DLLEXPORT sdbDataCenter
3702  {
3703  private :
3704  sdbDataCenter ( const sdbDataCenter& ) ; // non construction-copyable
3705  sdbDataCenter& operator= ( const sdbDataCenter& ) ; // non copyable
3706 
3707  public :
3708 
3715  _sdbDataCenter *pDC ;
3716 
3720  sdbDataCenter() { pDC = NULL ; }
3721 
3725  ~sdbDataCenter()
3726  {
3727  if ( pDC )
3728  {
3729  delete pDC ;
3730  }
3731  }
3732 
3733  public :
3734 
3739  const CHAR *getName ()
3740  {
3741  if ( NULL == pDC )
3742  {
3743  return NULL ;
3744  }
3745  return pDC->getName() ;
3746  }
3747 
3754  INT32 getDetail( bson::BSONObj &retInfo )
3755  {
3756  if ( NULL == pDC )
3757  {
3758  return SDB_NOT_CONNECTED ;
3759  }
3760  return pDC->getDetail( retInfo ) ;
3761  }
3762 
3768  INT32 activateDC()
3769  {
3770  if ( NULL == pDC )
3771  {
3772  return SDB_NOT_CONNECTED ;
3773  }
3774  return pDC->activateDC() ;
3775  }
3776 
3782  INT32 deactivateDC()
3783  {
3784  if ( NULL == pDC )
3785  {
3786  return SDB_NOT_CONNECTED ;
3787  }
3788  return pDC->deactivateDC() ;
3789  }
3790 
3797  INT32 enableReadOnly( BOOLEAN isReadOnly )
3798  {
3799  if ( NULL == pDC )
3800  {
3801  return SDB_NOT_CONNECTED ;
3802  }
3803  return pDC->enableReadOnly( isReadOnly ) ;
3804  }
3805 
3813  INT32 createImage( const CHAR *pCataAddrList )
3814  {
3815  if ( NULL == pDC )
3816  {
3817  return SDB_NOT_CONNECTED ;
3818  }
3819  return pDC->createImage( pCataAddrList ) ;
3820  }
3821 
3827  INT32 removeImage()
3828  {
3829  if ( NULL == pDC )
3830  {
3831  return SDB_NOT_CONNECTED ;
3832  }
3833  return pDC->removeImage() ;
3834  }
3835 
3841  INT32 enableImage()
3842  {
3843  if ( NULL == pDC )
3844  {
3845  return SDB_NOT_CONNECTED ;
3846  }
3847  return pDC->enableImage() ;
3848  }
3849 
3855  INT32 disableImage()
3856  {
3857  if ( NULL == pDC )
3858  {
3859  return SDB_NOT_CONNECTED ;
3860  }
3861  return pDC->disableImage() ;
3862  }
3863 
3870  INT32 attachGroups( const bson::BSONObj &info )
3871  {
3872  if ( NULL == pDC )
3873  {
3874  return SDB_NOT_CONNECTED ;
3875  }
3876  return pDC->attachGroups( info ) ;
3877  }
3878 
3885  INT32 detachGroups( const bson::BSONObj &info )
3886  {
3887  if ( NULL == pDC )
3888  {
3889  return SDB_NOT_CONNECTED ;
3890  }
3891  return pDC->detachGroups( info ) ;
3892  }
3893 
3894  };
3895 
3896  class DLLEXPORT _sdbLob
3897  {
3898  private :
3899  _sdbLob ( const _sdbLob& other ) ; // non construction-copyable
3900  _sdbLob& operator= ( const _sdbLob& ) ; // non copyable
3901 
3902  public :
3903  _sdbLob () {}
3904 
3905  virtual ~_sdbLob () {}
3906 
3907  virtual INT32 close () = 0 ;
3908 
3909  virtual INT32 read ( UINT32 len, CHAR *buf, UINT32 *read ) = 0 ;
3910 
3911  virtual INT32 write ( const CHAR *buf, UINT32 len ) = 0 ;
3912 
3913  virtual INT32 seek ( SINT64 size, SDB_LOB_SEEK whence ) = 0 ;
3914 
3915  virtual INT32 lock( INT64 offset, INT64 length ) = 0 ;
3916 
3917  virtual INT32 lockAndSeek( INT64 offset, INT64 length ) = 0 ;
3918 
3919  virtual INT32 isClosed( BOOLEAN &flag ) = 0 ;
3920 
3921  virtual INT32 getOid( bson::OID &oid ) = 0 ;
3922 
3923  virtual INT32 getSize( SINT64 *size ) = 0 ;
3924 
3925  virtual INT32 getCreateTime ( UINT64 *millis ) = 0 ;
3926 
3927  virtual BOOLEAN isClosed() = 0 ;
3928 
3929  virtual bson::OID getOid() = 0 ;
3930 
3931  virtual SINT64 getSize() = 0 ;
3932 
3933  virtual UINT64 getCreateTime () = 0 ;
3934 
3935  virtual UINT64 getModificationTime() = 0 ;
3936 
3937  virtual INT32 getPiecesInfoNum() = 0 ;
3938 
3939  virtual bson::BSONArray getPiecesInfo() = 0 ;
3940 
3941  virtual BOOLEAN isEof() = 0 ;
3942 
3943  } ;
3944 
3948  class DLLEXPORT sdbLob
3949  {
3950  private :
3951  sdbLob ( const sdbLob& ) ; // non construction-copyable
3952  sdbLob& operator= ( const sdbLob& ) ; // non copyable
3953 
3954  public :
3955 
3962  _sdbLob *pLob ;
3966  sdbLob() { pLob = NULL ; }
3967 
3972  {
3973  if ( pLob )
3974  {
3975  delete pLob ;
3976  }
3977  }
3978 
3984  INT32 close ()
3985  {
3986  if ( !pLob )
3987  {
3988  return SDB_OK ;
3989  }
3990  return pLob->close() ;
3991  }
3992 
4001  INT32 read ( UINT32 len, CHAR *buf, UINT32 *read )
4002  {
4003  if ( !pLob )
4004  {
4005  return SDB_NOT_CONNECTED ;
4006  }
4007  return pLob->read( len, buf, read ) ;
4008  }
4009 
4017  INT32 write ( const CHAR *buf, UINT32 len )
4018  {
4019  if ( !pLob )
4020  {
4021  return SDB_NOT_CONNECTED ;
4022  }
4023  return pLob->write( buf, len ) ;
4024  }
4025 
4033  INT32 seek ( SINT64 size, SDB_LOB_SEEK whence )
4034  {
4035  if ( !pLob )
4036  {
4037  return SDB_NOT_CONNECTED ;
4038  }
4039  return pLob->seek( size, whence ) ;
4040  }
4041 
4049  INT32 lock ( INT64 offset, INT64 length )
4050  {
4051  if ( !pLob )
4052  {
4053  return SDB_NOT_CONNECTED ;
4054  }
4055  return pLob->lock( offset, length ) ;
4056  }
4057 
4065  INT32 lockAndSeek ( INT64 offset, INT64 length )
4066  {
4067  if ( !pLob )
4068  {
4069  return SDB_NOT_CONNECTED ;
4070  }
4071  return pLob->lockAndSeek( offset, length ) ;
4072  }
4073 
4081  INT32 isClosed( BOOLEAN &flag )
4082  {
4083  if ( !pLob )
4084  {
4085  return SDB_NOT_CONNECTED ;
4086  }
4087  return pLob->isClosed ( flag ) ;
4088  }
4089 
4094  BOOLEAN isClosed()
4095  {
4096  if ( !pLob )
4097  {
4098  return TRUE ;
4099  }
4100  return pLob->isClosed () ;
4101  }
4102 
4110  INT32 getOid ( bson::OID &oid )
4111  {
4112  if ( !pLob )
4113  {
4114  return SDB_NOT_CONNECTED ;
4115  }
4116  return pLob->getOid( oid ) ;
4117  }
4118 
4123  bson::OID getOid ()
4124  {
4125  if ( !pLob )
4126  {
4127  return bson::OID();
4128  }
4129  return pLob->getOid() ;
4130  }
4131 
4139  INT32 getSize ( SINT64 *size )
4140  {
4141  if ( !pLob )
4142  {
4143  return SDB_NOT_CONNECTED ;
4144  }
4145  return pLob->getSize( size ) ;
4146  }
4147 
4152  SINT64 getSize ()
4153  {
4154  if ( !pLob )
4155  {
4156  return -1 ;
4157  }
4158  return pLob->getSize();
4159  }
4160 
4168  INT32 getCreateTime ( UINT64 *millis )
4169  {
4170  if ( !pLob )
4171  {
4172  return SDB_NOT_CONNECTED ;
4173  }
4174  return pLob->getCreateTime( millis ) ;
4175  }
4176 
4181  UINT64 getCreateTime ()
4182  {
4183  if ( !pLob )
4184  {
4185  return -1 ;
4186  }
4187  return pLob->getCreateTime() ;
4188  }
4189 
4194  UINT64 getModificationTime ()
4195  {
4196  if ( !pLob )
4197  {
4198  return -1 ;
4199  }
4200  return pLob->getModificationTime() ;
4201  }
4202 
4207  INT32 getPiecesInfoNum()
4208  {
4209  if ( !pLob )
4210  {
4211  return -1 ;
4212  }
4213  return pLob->getPiecesInfoNum() ;
4214  }
4215 
4220  bson::BSONArray getPiecesInfo()
4221  {
4222  if ( !pLob )
4223  {
4224  return bson::BSONArray() ;
4225  }
4226  return pLob->getPiecesInfo() ;
4227  }
4228 
4233  BOOLEAN isEof()
4234  {
4235  if ( !pLob )
4236  {
4237  return TRUE ;
4238  }
4239  return pLob->isEof() ;
4240  }
4241 
4242  } ;
4243 
4244  class DLLEXPORT _sdbDataSource
4245  {
4246  private:
4247  _sdbDataSource( const _sdbDataSource& other ) ;
4248  _sdbDataSource& operator=( const _sdbDataSource& ) ;
4249  public:
4250  _sdbDataSource() {}
4251  virtual ~_sdbDataSource() {}
4252 
4253  virtual INT32 alterDataSource( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4254  virtual const CHAR *getDSName() = 0 ;
4255  } ;
4256 
4257  class DLLEXPORT sdbDataSource
4258  {
4259  private:
4260  sdbDataSource( const sdbDataSource& ) ;
4261  sdbDataSource& operator=(const sdbDataSource& ) ;
4262  public:
4263  _sdbDataSource *pDataSource ;
4264 
4265  sdbDataSource()
4266  {
4267  pDataSource = NULL ;
4268  }
4269 
4270  ~sdbDataSource()
4271  {
4272  if ( pDataSource )
4273  {
4274  delete pDataSource ;
4275  }
4276  }
4277 
4278  INT32 alterDataSource( const bson::BSONObj &options )
4279  {
4280  if ( !pDataSource )
4281  {
4282  return SDB_NOT_CONNECTED ;
4283  }
4284  return pDataSource->alterDataSource( options ) ;
4285  }
4286 
4287  const CHAR *getDSName()
4288  {
4289  if ( !pDataSource )
4290  {
4291  return NULL ;
4292  }
4293  return pDataSource->getDSName() ;
4294  }
4295  } ;
4296 
4297  class DLLEXPORT _sdb
4298  {
4299  private :
4300  _sdb ( const _sdb& other ) ; // non construction-copyable
4301  _sdb& operator=( const _sdb& ) ; // non copyable
4302  public :
4303  _sdb () {}
4304  virtual ~_sdb () {}
4305  virtual INT32 connect ( const CHAR *pHostName,
4306  UINT16 port
4307  ) = 0 ;
4308  virtual INT32 connect ( const CHAR *pHostName,
4309  UINT16 port,
4310  const CHAR *pUsrName,
4311  const CHAR *pPasswd ) = 0 ;
4312  virtual INT32 connect ( const CHAR *pHostName,
4313  const CHAR *pServiceName ) = 0 ;
4314  virtual INT32 connect ( const CHAR *pHostName,
4315  const CHAR *pServiceName,
4316  const CHAR *pUsrName,
4317  const CHAR *pPasswd ) = 0 ;
4318  virtual INT32 connect ( const CHAR **pConnAddrs,
4319  INT32 arrSize,
4320  const CHAR *pUsrName,
4321  const CHAR *pPasswd ) = 0 ;
4322  virtual INT32 connect ( const CHAR **pConnAddrs,
4323  INT32 arrSize,
4324  const CHAR *pUsrName,
4325  const CHAR *pToken,
4326  const CHAR *pCipherFile ) = 0 ;
4327 
4328  virtual void disconnect () = 0 ;
4329 
4330  virtual UINT64 getDbStartTime() = 0 ;
4331 
4332  virtual void getVersion( UINT8 &version, UINT8 &subVersion,
4333  UINT8 &fixVersion ) = 0 ;
4334 
4335  virtual INT32 createUsr( const CHAR *pUsrName,
4336  const CHAR *pPasswd,
4337  const bson::BSONObj &options = _sdbStaticObject
4338  ) = 0 ;
4339 
4340  virtual INT32 removeUsr( const CHAR *pUsrName,
4341  const CHAR *pPasswd ) = 0 ;
4342 
4343  virtual INT32 alterUsr( const CHAR *pUsrName,
4344  const CHAR *pAction,
4345  const bson::BSONObj &options ) = 0 ;
4346 
4347  virtual INT32 changeUsrPasswd( const CHAR *pUsrName,
4348  const CHAR *pOldPasswd,
4349  const CHAR *pNewPasswd ) = 0 ;
4350 
4351  virtual INT32 getSnapshot ( _sdbCursor **cursor,
4352  INT32 snapType,
4353  const bson::BSONObj &condition = _sdbStaticObject,
4354  const bson::BSONObj &selector = _sdbStaticObject,
4355  const bson::BSONObj &orderBy = _sdbStaticObject,
4356  const bson::BSONObj &hint = _sdbStaticObject,
4357  INT64 numToSkip = 0,
4358  INT64 numToReturn = -1
4359  ) = 0 ;
4360 
4361  virtual INT32 getSnapshot ( sdbCursor &cursor,
4362  INT32 snapType,
4363  const bson::BSONObj &condition = _sdbStaticObject,
4364  const bson::BSONObj &selector = _sdbStaticObject,
4365  const bson::BSONObj &orderBy = _sdbStaticObject,
4366  const bson::BSONObj &hint = _sdbStaticObject,
4367  INT64 numToSkip = 0,
4368  INT64 numToReturn = -1
4369  ) = 0 ;
4370 
4371  virtual INT32 resetSnapshot ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4372 
4373  virtual INT32 getList ( _sdbCursor **cursor,
4374  INT32 listType,
4375  const bson::BSONObj &condition = _sdbStaticObject,
4376  const bson::BSONObj &selector = _sdbStaticObject,
4377  const bson::BSONObj &orderBy = _sdbStaticObject,
4378  const bson::BSONObj &hint = _sdbStaticObject,
4379  INT64 numToSkip = 0,
4380  INT64 numToReturn = -1
4381  ) = 0 ;
4382  virtual INT32 getList ( sdbCursor &cursor,
4383  INT32 listType,
4384  const bson::BSONObj &condition = _sdbStaticObject,
4385  const bson::BSONObj &selector = _sdbStaticObject,
4386  const bson::BSONObj &orderBy = _sdbStaticObject,
4387  const bson::BSONObj &hint = _sdbStaticObject,
4388  INT64 numToSkip = 0,
4389  INT64 numToReturn = -1
4390  ) = 0 ;
4391 
4392  virtual INT32 getCollection ( const CHAR *pCollectionFullName,
4393  _sdbCollection **collection,
4394  BOOLEAN checkExist = TRUE
4395  ) = 0 ;
4396 
4397  virtual INT32 getCollection ( const CHAR *pCollectionFullName,
4398  sdbCollection &collection,
4399  BOOLEAN checkExist = TRUE
4400  ) = 0 ;
4401 
4402  virtual INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
4403  _sdbCollectionSpace **cs,
4404  BOOLEAN checkExist = TRUE
4405  ) = 0 ;
4406 
4407  virtual INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
4408  sdbCollectionSpace &cs,
4409  BOOLEAN checkExist = TRUE
4410  ) = 0 ;
4411 
4412  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
4413  INT32 iPageSize,
4414  _sdbCollectionSpace **cs
4415  ) = 0 ;
4416 
4417  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
4418  INT32 iPageSize,
4419  sdbCollectionSpace &cs
4420  ) = 0 ;
4421 
4422  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
4423  const bson::BSONObj &options,
4424  _sdbCollectionSpace **cs
4425  ) = 0 ;
4426 
4427  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
4428  const bson::BSONObj &options,
4429  sdbCollectionSpace &cs
4430  ) = 0 ;
4431 
4432  virtual INT32 dropCollectionSpace ( const CHAR *pCollectionSpaceName )
4433  = 0 ;
4434 
4435  virtual INT32 listCollectionSpaces ( _sdbCursor **result ) = 0 ;
4436 
4437  virtual INT32 listCollectionSpaces ( sdbCursor &result ) = 0 ;
4438 
4439  // list all collections in a given database
4440  virtual INT32 listCollections ( _sdbCursor **result ) = 0 ;
4441 
4442  virtual INT32 listCollections ( sdbCursor &result ) = 0 ;
4443 
4444  // list all the replica groups in the given database
4445  virtual INT32 listReplicaGroups ( _sdbCursor **result ) = 0 ;
4446 
4447  virtual INT32 listReplicaGroups ( sdbCursor &result ) = 0 ;
4448 
4449  virtual INT32 getReplicaGroup ( const CHAR *pName,
4450  _sdbReplicaGroup **result ) = 0 ;
4451 
4452  virtual INT32 getReplicaGroup ( const CHAR *pName,
4453  sdbReplicaGroup &result ) = 0 ;
4454 
4455  virtual INT32 getReplicaGroup ( INT32 id,
4456  _sdbReplicaGroup **result ) = 0 ;
4457 
4458  virtual INT32 getReplicaGroup ( INT32 id,
4459  sdbReplicaGroup &result ) = 0 ;
4460 
4461  virtual INT32 createReplicaGroup ( const CHAR *pName,
4462  _sdbReplicaGroup **replicaGroup ) = 0 ;
4463 
4464  virtual INT32 createReplicaGroup ( const CHAR *pName,
4465  sdbReplicaGroup &replicaGroup ) = 0 ;
4466 
4467  virtual INT32 removeReplicaGroup ( const CHAR *pName ) = 0 ;
4468 
4469  virtual INT32 createReplicaCataGroup ( const CHAR *pHostName,
4470  const CHAR *pServiceName,
4471  const CHAR *pDatabasePath,
4472  const bson::BSONObj &configure ) =0 ;
4473 
4474  virtual INT32 activateReplicaGroup ( const CHAR *pName,
4475  _sdbReplicaGroup **replicaGroup ) = 0 ;
4476  virtual INT32 activateReplicaGroup ( const CHAR *pName,
4477  sdbReplicaGroup &replicaGroup ) = 0 ;
4478 
4479  virtual INT32 execUpdate( const CHAR *sql,
4480  bson::BSONObj *pResult = NULL ) = 0 ;
4481 
4482  virtual INT32 exec( const CHAR *sql,
4483  _sdbCursor **result ) = 0 ;
4484 
4485  virtual INT32 exec( const CHAR *sql,
4486  sdbCursor &result ) = 0 ;
4487 
4488  virtual INT32 transactionBegin() = 0 ;
4489 
4490  virtual INT32 transactionCommit() = 0 ;
4491 
4492  virtual INT32 transactionRollback() = 0 ;
4493 
4494  virtual INT32 flushConfigure( const bson::BSONObj &options ) = 0 ;
4495  // stored procedure
4496  virtual INT32 crtJSProcedure ( const CHAR *code ) = 0 ;
4497  virtual INT32 rmProcedure( const CHAR *spName ) = 0 ;
4498  virtual INT32 listProcedures( _sdbCursor **cursor, const bson::BSONObj &condition ) = 0 ;
4499  virtual INT32 listProcedures( sdbCursor &cursor, const bson::BSONObj &condition ) = 0 ;
4500  virtual INT32 evalJS( const CHAR *code,
4501  SDB_SPD_RES_TYPE &type,
4502  _sdbCursor **cursor,
4503  bson::BSONObj &errmsg ) = 0 ;
4504  virtual INT32 evalJS( const CHAR *code,
4505  SDB_SPD_RES_TYPE &type,
4506  sdbCursor &cursor,
4507  bson::BSONObj &errmsg ) = 0 ;
4508 
4509  // bakup
4510  virtual INT32 backup ( const bson::BSONObj &options) = 0 ;
4511  virtual INT32 listBackup ( _sdbCursor **cursor,
4512  const bson::BSONObj &options,
4513  const bson::BSONObj &condition = _sdbStaticObject,
4514  const bson::BSONObj &selector = _sdbStaticObject,
4515  const bson::BSONObj &orderBy = _sdbStaticObject) = 0 ;
4516  virtual INT32 listBackup ( sdbCursor &cursor,
4517  const bson::BSONObj &options,
4518  const bson::BSONObj &condition = _sdbStaticObject,
4519  const bson::BSONObj &selector = _sdbStaticObject,
4520  const bson::BSONObj &orderBy = _sdbStaticObject) = 0 ;
4521  virtual INT32 removeBackup ( const bson::BSONObj &options ) = 0 ;
4522 
4523  // task
4524  virtual INT32 listTasks ( _sdbCursor **cursor,
4525  const bson::BSONObj &condition = _sdbStaticObject,
4526  const bson::BSONObj &selector = _sdbStaticObject,
4527  const bson::BSONObj &orderBy = _sdbStaticObject,
4528  const bson::BSONObj &hint = _sdbStaticObject) = 0 ;
4529 
4530 
4531  virtual INT32 listTasks ( sdbCursor &cursor,
4532  const bson::BSONObj &condition = _sdbStaticObject,
4533  const bson::BSONObj &selector = _sdbStaticObject,
4534  const bson::BSONObj &orderBy = _sdbStaticObject,
4535  const bson::BSONObj &hint = _sdbStaticObject) = 0 ;
4536 
4537  virtual INT32 waitTasks ( const SINT64 *taskIDs,
4538  SINT32 num ) = 0 ;
4539 
4540  virtual INT32 cancelTask ( SINT64 taskID,
4541  BOOLEAN isAsync ) = 0 ;
4542  // set session attribute
4543  virtual INT32 setSessionAttr ( const bson::BSONObj &options =
4544  _sdbStaticObject ) = 0 ;
4545  // get session attribute
4546  virtual INT32 getSessionAttr ( bson::BSONObj &result,
4547  BOOLEAN useCache = TRUE ) = 0 ;
4548 
4549  // close all cursor
4550  virtual INT32 closeAllCursors () = 0 ;
4551 
4552  // interrupt
4553  virtual INT32 interrupt() = 0 ;
4554  virtual INT32 interruptOperation() = 0 ;
4555 
4556  // connection is valid
4557  virtual INT32 isValid( BOOLEAN *result ) = 0 ;
4558  virtual BOOLEAN isValid() = 0 ;
4559 
4560  virtual BOOLEAN isClosed() = 0 ;
4561 
4562  // domain
4563  virtual INT32 createDomain ( const CHAR *pDomainName,
4564  const bson::BSONObj &options,
4565  _sdbDomain **domain ) = 0 ;
4566 
4567  virtual INT32 createDomain ( const CHAR *pDomainName,
4568  const bson::BSONObj &options,
4569  sdbDomain &domain ) = 0 ;
4570 
4571  virtual INT32 dropDomain ( const CHAR *pDomainName ) = 0 ;
4572 
4573  virtual INT32 getDomain ( const CHAR *pDomainName,
4574  _sdbDomain **domain ) = 0 ;
4575 
4576  virtual INT32 getDomain ( const CHAR *pDomainName,
4577  sdbDomain &domain ) = 0 ;
4578 
4579  virtual INT32 listDomains ( _sdbCursor **cursor,
4580  const bson::BSONObj &condition = _sdbStaticObject,
4581  const bson::BSONObj &selector = _sdbStaticObject,
4582  const bson::BSONObj &orderBy = _sdbStaticObject,
4583  const bson::BSONObj &hint = _sdbStaticObject
4584  ) = 0 ;
4585 
4586  virtual INT32 listDomains ( sdbCursor &cursor,
4587  const bson::BSONObj &condition = _sdbStaticObject,
4588  const bson::BSONObj &selector = _sdbStaticObject,
4589  const bson::BSONObj &orderBy = _sdbStaticObject,
4590  const bson::BSONObj &hint = _sdbStaticObject
4591  ) = 0 ;
4592  virtual INT32 getDC( _sdbDataCenter **dc ) = 0 ;
4593  virtual INT32 getDC( sdbDataCenter &dc ) = 0 ;
4594 
4595  static _sdb *getObj ( BOOLEAN useSSL = FALSE ) ;
4596 
4597  // get last alive time
4598  virtual UINT64 getLastAliveTime() const = 0 ;
4599 
4600  virtual INT32 syncDB(
4601  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4602 
4603  virtual INT32 analyze(
4604  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4605 
4606  virtual INT32 forceSession(
4607  SINT64 sessionID,
4608  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4609 
4610  virtual INT32 forceStepUp(
4611  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4612 
4613  virtual INT32 invalidateCache(
4614  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4615 
4616  virtual INT32 reloadConfig(
4617  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4618 
4619  virtual INT32 updateConfig ( const bson::BSONObj &configs = _sdbStaticObject,
4620  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4621 
4622  virtual INT32 deleteConfig ( const bson::BSONObj &configs = _sdbStaticObject,
4623  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4624 
4625  virtual INT32 setPDLevel( INT32 level,
4626  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4627 
4628  virtual INT32 msg( const CHAR* msg ) = 0 ;
4629 
4630  virtual INT32 loadCS( const CHAR* csName,
4631  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4632 
4633  virtual INT32 unloadCS( const CHAR* csName,
4634  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4635 
4636  virtual INT32 traceStart( UINT32 traceBufferSize,
4637  const CHAR* component = NULL,
4638  const CHAR* breakpoint = NULL,
4639  const vector<UINT32> &tidVec = _sdbStaticUINT32Vec ) = 0 ;
4640 
4641  virtual INT32 traceStart( UINT32 traceBufferSize,
4642  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4643 
4644  virtual INT32 traceStop( const CHAR* dumpFileName ) = 0 ;
4645 
4646  virtual INT32 traceResume() = 0 ;
4647 
4648  virtual INT32 traceStatus( _sdbCursor** cursor ) = 0 ;
4649 
4650  virtual INT32 traceStatus( sdbCursor& cursor ) = 0 ;
4651 
4652 
4653  virtual INT32 renameCollectionSpace( const CHAR* oldName,
4654  const CHAR* newName,
4655  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4656 
4657  virtual INT32 getLastErrorObj( bson::BSONObj &result ) = 0 ;
4658  virtual void cleanLastErrorObj() = 0 ;
4659 
4660  virtual INT32 getLastResultObj( bson::BSONObj &result,
4661  BOOLEAN getOwned = FALSE ) const = 0 ;
4662 
4663  virtual INT32 createDataSource( const CHAR *pDataSourceName,
4664  const CHAR *addresses,
4665  const CHAR *user = NULL,
4666  const CHAR *password = NULL,
4667  const CHAR *type = NULL,
4668  const bson::BSONObj *options = NULL,
4669  _sdbDataSource **dataSource = NULL
4670  ) = 0 ;
4671 
4672  virtual INT32 dropDataSource( const CHAR *pDataSourceName ) = 0 ;
4673 
4674  virtual INT32 getDataSource( const CHAR *pDataSourceName,
4675  _sdbDataSource **dataSource ) = 0 ;
4676 
4677  virtual INT32 getDataSource( const CHAR *pDataSourceName,
4678  sdbDataSource &dataSource ) = 0 ;
4679 
4680  virtual INT32 listDataSources( _sdbCursor** cursor,
4681  const bson::BSONObj &condition = _sdbStaticObject,
4682  const bson::BSONObj &selector = _sdbStaticObject,
4683  const bson::BSONObj &orderBy = _sdbStaticObject,
4684  const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
4685  virtual INT32 listDataSources( sdbCursor& cursor,
4686  const bson::BSONObj &condition = _sdbStaticObject,
4687  const bson::BSONObj &selector = _sdbStaticObject,
4688  const bson::BSONObj &orderBy = _sdbStaticObject,
4689  const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
4690  } ;
4693  typedef class _sdb _sdb ;
4697  class DLLEXPORT sdb
4698  {
4699  private:
4700  sdb ( const sdb& other ) ;
4701  sdb& operator=( const sdb& ) ;
4702  public :
4709  _sdb *pSDB ;
4710 
4715  sdb ( BOOLEAN useSSL = FALSE ) :
4716  pSDB ( _sdb::getObj( useSSL ) )
4717  {
4718  }
4719 
4723  ~sdb ()
4724  {
4725  if ( pSDB )
4726  {
4727  delete pSDB ;
4728  }
4729  }
4730 
4740  INT32 connect ( const CHAR *pHostName,
4741  UINT16 port
4742  )
4743  {
4744  if ( !pSDB )
4745  {
4746  return SDB_NOT_CONNECTED ;
4747  }
4748  return pSDB->connect ( pHostName, port ) ;
4749  }
4750 
4764  INT32 connect ( const CHAR *pHostName,
4765  UINT16 port,
4766  const CHAR *pUsrName,
4767  const CHAR *pPasswd
4768  )
4769  {
4770  if ( !pSDB )
4771  {
4772  return SDB_NOT_CONNECTED ;
4773  }
4774  return pSDB->connect ( pHostName, port,
4775  pUsrName, pPasswd ) ;
4776  }
4777 
4787  INT32 connect ( const CHAR *pHostName,
4788  const CHAR *pServiceName
4789  )
4790  {
4791  if ( !pSDB )
4792  {
4793  return SDB_NOT_CONNECTED ;
4794  }
4795  return pSDB->connect ( pHostName, pServiceName ) ;
4796  }
4797 
4811  INT32 connect ( const CHAR *pHostName,
4812  const CHAR *pServiceName,
4813  const CHAR *pUsrName,
4814  const CHAR *pPasswd )
4815  {
4816  if ( !pSDB )
4817  {
4818  return SDB_NOT_CONNECTED ;
4819  }
4820  return pSDB->connect ( pHostName, pServiceName,
4821  pUsrName, pPasswd ) ;
4822  }
4823 
4837  INT32 connect ( const CHAR **pConnAddrs,
4838  INT32 arrSize,
4839  const CHAR *pUsrName,
4840  const CHAR *pPasswd )
4841  {
4842  if ( !pSDB )
4843  {
4844  return SDB_NOT_CONNECTED ;
4845  }
4846  return pSDB->connect ( pConnAddrs, arrSize,
4847  pUsrName, pPasswd ) ;
4848  }
4849 
4865  INT32 connect ( const CHAR **pConnAddrs,
4866  INT32 arrSize,
4867  const CHAR *pUsrName,
4868  const CHAR *pToken,
4869  const CHAR *pCipherFile )
4870  {
4871  if ( !pSDB )
4872  {
4873  return SDB_NOT_CONNECTED ;
4874  }
4875  return pSDB->connect ( pConnAddrs, arrSize,
4876  pUsrName, pToken, pCipherFile ) ;
4877  }
4878 
4883  UINT64 getDbStartTime ()
4884  {
4885  if ( !pSDB )
4886  {
4887  return -1 ;
4888  }
4889  return pSDB->getDbStartTime() ;
4890  }
4891 
4901  void getVersion ( UINT8 &version, UINT8 &subVersion, UINT8 &fixVersion )
4902  {
4903  if ( !pSDB )
4904  {
4905  return ;
4906  }
4907  pSDB->getVersion( version, subVersion, fixVersion ) ;
4908  }
4909 
4932  INT32 createUsr( const CHAR *pUsrName,
4933  const CHAR *pPasswd,
4934  const bson::BSONObj &options = _sdbStaticObject )
4935  {
4936  if ( !pSDB )
4937  {
4938  return SDB_NOT_CONNECTED ;
4939  }
4940  return pSDB->createUsr( pUsrName, pPasswd, options ) ;
4941  }
4942 
4951  INT32 removeUsr( const CHAR *pUsrName,
4952  const CHAR *pPasswd )
4953  {
4954  if ( !pSDB )
4955  {
4956  return SDB_NOT_CONNECTED ;
4957  }
4958  return pSDB->removeUsr( pUsrName, pPasswd ) ;
4959  }
4960 
4973  INT32 alterUsr( const CHAR *pUsrName,
4974  const CHAR *pAction,
4975  const bson::BSONObj &options )
4976  {
4977  if ( !pSDB )
4978  {
4979  return SDB_NOT_CONNECTED ;
4980  }
4981  return pSDB->alterUsr( pUsrName, pAction, options ) ;
4982  }
4983 
4994  INT32 changeUsrPasswd( const CHAR *pUsrName,
4995  const CHAR *pOldPasswd,
4996  const CHAR *pNewPasswd )
4997  {
4998  if ( !pSDB )
4999  {
5000  return SDB_NOT_CONNECTED ;
5001  }
5002  return pSDB->changeUsrPasswd( pUsrName, pOldPasswd, pNewPasswd ) ;
5003  }
5004 
5008  void disconnect ()
5009  {
5010  if ( !pSDB )
5011  {
5012  return ;
5013  }
5014  pSDB->disconnect () ;
5015  }
5016 
5056  INT32 getSnapshot ( sdbCursor &cursor,
5057  INT32 snapType,
5058  const bson::BSONObj &condition = _sdbStaticObject,
5059  const bson::BSONObj &selector = _sdbStaticObject,
5060  const bson::BSONObj &orderBy = _sdbStaticObject,
5061  const bson::BSONObj &hint = _sdbStaticObject,
5062  INT64 numToSkip = 0,
5063  INT64 numToReturn = -1 )
5064  {
5065  if ( !pSDB )
5066  {
5067  return SDB_NOT_CONNECTED ;
5068  }
5069  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
5070  return pSDB->getSnapshot ( cursor, snapType, condition,
5071  selector, orderBy, hint,
5072  numToSkip, numToReturn ) ;
5073  }
5074 
5075  /* \fn INT32 getSnapshot ( _sdbCursor **cursor,
5076  INT32 snapType,
5077  const bson::BSONObj &condition,
5078  const bson::BSONObj &selector,
5079  const bson::BSONObj &orderBy,
5080  const bson::BSONObj &hint,
5081  INT64 numToSkip,
5082  INT64 numToReturn
5083  )
5084  \brief Get the snapshots of specified type.
5085  \param [in] snapType The snapshot type as below
5086 
5087  SDB_SNAP_CONTEXTS : Get the snapshot of all the contexts
5088  SDB_SNAP_CONTEXTS_CURRENT : Get the snapshot of current context
5089  SDB_SNAP_SESSIONS : Get the snapshot of all the sessions
5090  SDB_SNAP_SESSIONS_CURRENT : Get the snapshot of current session
5091  SDB_SNAP_COLLECTIONS : Get the snapshot of all the collections
5092  SDB_SNAP_COLLECTIONSPACES : Get the snapshot of all the collection spaces
5093  SDB_SNAP_DATABASE : Get the snapshot of the database
5094  SDB_SNAP_SYSTEM : Get the snapshot of the system
5095  SDB_SNAP_CATALOG : Get the snapshot of the catalog
5096  SDB_SNAP_TRANSACTIONS : Get snapshot of transactions in current session
5097  SDB_SNAP_TRANSACTIONS_CURRENT : Get snapshot of all the transactions
5098  SDB_SNAP_ACCESSPLANS : Get the snapshot of cached access plans
5099  SDB_SNAP_HEALTH : Get snapshot of node health detection
5100  SDB_SNAP_CONFIGS : Get snapshot of node configurations
5101  SDB_SNAP_SVCTASKS : Get snapshot of service task
5102  SDB_SNAP_SEQUENCES : Get the snapshot of sequences
5103 
5104  \param [in] condition The matching rule, match all the documents if not provided.
5105  \param [in] select The selective rule, return the whole document if not provided.
5106  \param [in] orderBy The ordered rule, result set is unordered if not provided.
5107  \param [in] hint The options provided for specific snapshot type.
5108  format:{ '$Options': { <options> } }
5109  \param [in] numToSkip Skip the first numToSkip documents, default is 0
5110  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
5111  \param [out] cursor The return cursor handle of query.
5112  \retval SDB_OK Operation Success
5113  \retval Others Operation Fail
5114  */
5115  INT32 getSnapshot ( _sdbCursor **cursor,
5116  INT32 snapType,
5117  const bson::BSONObj &condition = _sdbStaticObject,
5118  const bson::BSONObj &selector = _sdbStaticObject,
5119  const bson::BSONObj &orderBy = _sdbStaticObject,
5120  const bson::BSONObj &hint = _sdbStaticObject,
5121  INT64 numToSkip = 0,
5122  INT64 numToReturn = -1 )
5123  {
5124  if ( !pSDB )
5125  {
5126  return SDB_NOT_CONNECTED ;
5127  }
5128  return pSDB->getSnapshot ( cursor, snapType, condition,
5129  selector, orderBy, hint,
5130  numToSkip, numToReturn ) ;
5131  }
5132 
5155  INT32 resetSnapshot ( const bson::BSONObj &options = _sdbStaticObject )
5156  {
5157  if ( !pSDB )
5158  {
5159  return SDB_NOT_CONNECTED ;
5160  }
5161  return pSDB->resetSnapshot ( options ) ;
5162  }
5163 
5164  /* \fn INT32 getList ( _sdbCursor **cursor,
5165  INT32 listType,
5166  const bson::BSONObj &condition,
5167  const bson::BSONObj &selector,
5168  const bson::BSONObj &orderBy,
5169  const bson::BSONObj &hint,
5170  INT64 numToSkip,
5171  INT64 numToReturn
5172  )
5173  \brief Get the informations of specified type.
5174  \param [in] listType The list type as below
5175 
5176  SDB_LIST_CONTEXTS : Get all contexts list
5177  SDB_LIST_CONTEXTS_CURRENT : Get contexts list for the current session
5178  SDB_LIST_SESSIONS : Get all sessions list
5179  SDB_LIST_SESSIONS_CURRENT : Get the current session
5180  SDB_LIST_COLLECTIONS : Get all collections list
5181  SDB_LIST_COLLECTIONSPACES : Get all collecion spaces' list
5182  SDB_LIST_STORAGEUNITS : Get storage units list
5183  SDB_LIST_GROUPS : Get replicaGroup list ( only applicable in sharding env )
5184  SDB_LIST_STOREPROCEDURES : Get all the stored procedure list
5185  SDB_LIST_DOMAINS : Get all the domains list
5186  SDB_LIST_TASKS : Get all the running split tasks ( only applicable in sharding env )
5187  SDB_LIST_TRANSACTIONS : Get all the transactions information.
5188  SDB_LIST_TRANSACTIONS_CURRENT : Get the transactions information of current session.
5189  SDB_LIST_SVCTASKS : Get all the schedule task informations
5190  SDB_LIST_SEQUENCES : Get all the sequence informations
5191  SDB_LIST_USERS : Get all the user informations
5192 
5193  \param [in] condition The matching rule, match all the documents if null.
5194  \param [in] select The selective rule, return the whole document if null.
5195  \param [in] orderBy The ordered rule, never sort if null.
5196  \param [in] hint The options provided for specific list type. Reserved.
5197  \param [in] numToSkip Skip the first numToSkip documents.
5198  \param [in] numToReturn Only return numToReturn documents. -1 means return
5199  all matched results.
5200  \param [out] cursor The return cursor handle of query.
5201  \retval SDB_OK Operation Success
5202  \retval Others Operation Fail
5203  */
5204  INT32 getList ( _sdbCursor **cursor,
5205  INT32 listType,
5206  const bson::BSONObj &condition = _sdbStaticObject,
5207  const bson::BSONObj &selector = _sdbStaticObject,
5208  const bson::BSONObj &orderBy = _sdbStaticObject,
5209  const bson::BSONObj &hint = _sdbStaticObject,
5210  INT64 numToSkip = 0,
5211  INT64 numToReturn = -1
5212  )
5213  {
5214  if ( !pSDB )
5215  {
5216  return SDB_NOT_CONNECTED ;
5217  }
5218  return pSDB->getList ( cursor, listType,
5219  condition, selector, orderBy, hint,
5220  numToSkip, numToReturn ) ;
5221  }
5222 
5263  INT32 getList ( sdbCursor &cursor,
5264  INT32 listType,
5265  const bson::BSONObj &condition = _sdbStaticObject,
5266  const bson::BSONObj &selector = _sdbStaticObject,
5267  const bson::BSONObj &orderBy = _sdbStaticObject,
5268  const bson::BSONObj &hint = _sdbStaticObject,
5269  INT64 numToSkip = 0,
5270  INT64 numToReturn = -1
5271  )
5272  {
5273  if ( !pSDB )
5274  {
5275  return SDB_NOT_CONNECTED ;
5276  }
5277  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
5278  return pSDB->getList ( cursor, listType,
5279  condition, selector, orderBy, hint,
5280  numToSkip, numToReturn ) ;
5281  }
5282 
5283  INT32 getCollection ( const CHAR *pCollectionFullName,
5284  _sdbCollection **collection,
5285  BOOLEAN checkExist = TRUE
5286  )
5287  {
5288  if ( !pSDB )
5289  {
5290  return SDB_NOT_CONNECTED ;
5291  }
5292  return pSDB->getCollection ( pCollectionFullName,
5293  collection, checkExist ) ;
5294  }
5295 
5306  INT32 getCollection ( const CHAR *pCollectionFullName,
5307  sdbCollection &collection,
5308  BOOLEAN checkExist = TRUE
5309  )
5310  {
5311  if ( !pSDB )
5312  {
5313  return SDB_NOT_CONNECTED ;
5314  }
5315  RELEASE_INNER_HANDLE( collection.pCollection ) ;
5316  return pSDB->getCollection ( pCollectionFullName,
5317  collection,
5318  checkExist ) ;
5319  }
5320 
5321  INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
5322  _sdbCollectionSpace **cs,
5323  BOOLEAN checkExist = TRUE
5324  )
5325  {
5326  if ( !pSDB )
5327  {
5328  return SDB_NOT_CONNECTED ;
5329  }
5330  return pSDB->getCollectionSpace ( pCollectionSpaceName,
5331  cs, checkExist ) ;
5332  }
5333 
5344  INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
5345  sdbCollectionSpace &cs,
5346  BOOLEAN checkExist = TRUE
5347  )
5348  {
5349  if ( !pSDB )
5350  {
5351  return SDB_NOT_CONNECTED ;
5352  }
5354  return pSDB->getCollectionSpace ( pCollectionSpaceName,
5355  cs, checkExist ) ;
5356  }
5357 
5358  /* \fn INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5359  INT32 iPageSize,
5360  _sdbCollectionSpace **cs
5361  )
5362  \brief Create collection space with specified pagesize.
5363  \param [in] pCollectionSpaceName The name of collection space.
5364  \param [in] iPageSize The Page Size as below
5365 
5366  SDB_PAGESIZE_4K
5367  SDB_PAGESIZE_8K
5368  SDB_PAGESIZE_16K
5369  SDB_PAGESIZE_32K
5370  SDB_PAGESIZE_64K
5371  SDB_PAGESIZE_DEFAULT
5372  \param [out] cs The return collection space handle of creation.
5373  \retval SDB_OK Operation Success
5374  \retval Others Operation Fail
5375  */
5376  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5377  INT32 iPageSize,
5378  _sdbCollectionSpace **cs
5379  )
5380  {
5381  if ( !pSDB )
5382  {
5383  return SDB_NOT_CONNECTED ;
5384  }
5385  return pSDB->createCollectionSpace ( pCollectionSpaceName,
5386  iPageSize,
5387  cs ) ;
5388  }
5389 
5408  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5409  INT32 iPageSize,
5410  sdbCollectionSpace &cs
5411  )
5412  {
5413  if ( !pSDB )
5414  {
5415  return SDB_NOT_CONNECTED ;
5416  }
5418  return pSDB->createCollectionSpace ( pCollectionSpaceName,
5419  iPageSize, cs ) ;
5420  }
5421 
5422  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5423  const bson::BSONObj &options,
5424  _sdbCollectionSpace **cs
5425  )
5426  {
5427  if ( !pSDB )
5428  {
5429  return SDB_NOT_CONNECTED ;
5430  }
5431  return pSDB->createCollectionSpace ( pCollectionSpaceName,
5432  options, cs ) ;
5433  }
5434 
5449  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5450  const bson::BSONObj &options,
5451  sdbCollectionSpace &cs
5452  )
5453  {
5454  if ( !pSDB )
5455  {
5456  return SDB_NOT_CONNECTED ;
5457  }
5459  return pSDB->createCollectionSpace ( pCollectionSpaceName,
5460  options, cs ) ;
5461  }
5462 
5469  INT32 dropCollectionSpace ( const CHAR *pCollectionSpaceName )
5470  {
5471  if ( !pSDB )
5472  {
5473  return SDB_NOT_CONNECTED ;
5474  }
5475  return pSDB->dropCollectionSpace ( pCollectionSpaceName ) ;
5476  }
5477 
5478  INT32 listCollectionSpaces ( _sdbCursor **result )
5479  {
5480  if ( !pSDB )
5481  {
5482  return SDB_NOT_CONNECTED ;
5483  }
5484  return pSDB->listCollectionSpaces ( result ) ;
5485  }
5486 
5493  INT32 listCollectionSpaces ( sdbCursor &cursor )
5494  {
5495  if ( !pSDB )
5496  {
5497  return SDB_NOT_CONNECTED ;
5498  }
5499  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
5500  return pSDB->listCollectionSpaces ( cursor ) ;
5501  }
5502 
5503  /* \fn INT32 listCollections ( _sdbCursor **result )
5504  \brief list all collections in current database.
5505  \param [out] result The return cursor handle of query.
5506  \retval SDB_OK Operation Success
5507  \retval Others Operation Fail
5508  */
5509  INT32 listCollections ( _sdbCursor **result )
5510  {
5511  if ( !pSDB )
5512  {
5513  return SDB_NOT_CONNECTED ;
5514  }
5515  return pSDB->listCollections ( result ) ;
5516  }
5517 
5524  INT32 listCollections ( sdbCursor &cursor )
5525  {
5526  if ( !pSDB )
5527  {
5528  return SDB_NOT_CONNECTED ;
5529  }
5530  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
5531  return pSDB->listCollections ( cursor ) ;
5532  }
5533 
5534  /* \fn INT32 listReplicaGroups ( _sdbCursor **result )
5535  \brief List all replica groups of current database.
5536  \param [out] result The return cursor handle of query.
5537  \retval SDB_OK Operation Success
5538  \retval Others Operation Fail
5539  */
5540  INT32 listReplicaGroups ( _sdbCursor **result )
5541  {
5542  if ( !pSDB )
5543  {
5544  return SDB_NOT_CONNECTED ;
5545  }
5546  return pSDB->listReplicaGroups ( result ) ;
5547  }
5548 
5549 
5556  INT32 listReplicaGroups ( sdbCursor &cursor )
5557  {
5558  if ( !pSDB )
5559  {
5560  return SDB_NOT_CONNECTED ;
5561  }
5562  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
5563  return pSDB->listReplicaGroups ( cursor ) ;
5564  }
5565 
5566  /* \fn INT32 getReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **result )
5567  \brief Get the specified replica group.
5568  \param [in] pName The name of replica group.
5569  \param [out] result The sdbReplicaGroup object.
5570  \retval SDB_OK Operation Success
5571  \retval Others Operation Fail
5572  */
5573  INT32 getReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **result )
5574  {
5575  if ( !pSDB )
5576  {
5577  return SDB_NOT_CONNECTED ;
5578  }
5579  return pSDB->getReplicaGroup ( pName, result ) ;
5580  }
5581 
5582 
5590  INT32 getReplicaGroup ( const CHAR *pName, sdbReplicaGroup &group )
5591  {
5592  if ( !pSDB )
5593  {
5594  return SDB_NOT_CONNECTED ;
5595  }
5597  return pSDB->getReplicaGroup ( pName, group ) ;
5598  }
5599 
5600  /* \fn INT32 getReplicaGroup ( INT32 id, _sdbReplicaGroup **result )
5601  \brief Get the specified replica group.
5602  \param [in] id The id of replica group.
5603  \param [out] result The _sdbReplicaGroup object.
5604  \retval SDB_OK Operation Success
5605  \retval Others Operation Fail
5606  */
5607  INT32 getReplicaGroup ( INT32 id, _sdbReplicaGroup **result )
5608  {
5609  if ( !pSDB )
5610  {
5611  return SDB_NOT_CONNECTED ;
5612  }
5613  return pSDB->getReplicaGroup ( id, result ) ;
5614  }
5615 
5623  INT32 getReplicaGroup ( INT32 id, sdbReplicaGroup &group )
5624  {
5625  if ( !pSDB )
5626  {
5627  return SDB_NOT_CONNECTED ;
5628  }
5630  return pSDB->getReplicaGroup ( id, group ) ;
5631  }
5632 
5633  /* \fn INT32 createReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
5634  \brief Create the specified replica group.
5635  \param [in] pName The name of the replica group.
5636  \param [out] replicaGroup The return _sdbReplicaGroup object.
5637  \retval SDB_OK Operation Success
5638  \retval Others Operation Fail
5639  */
5640  INT32 createReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
5641  {
5642  if ( !pSDB )
5643  {
5644  return SDB_NOT_CONNECTED ;
5645  }
5646  return pSDB->createReplicaGroup ( pName, replicaGroup ) ;
5647  }
5648 
5656  INT32 createReplicaGroup ( const CHAR *pName, sdbReplicaGroup &group )
5657  {
5658  if ( !pSDB )
5659  {
5660  return SDB_NOT_CONNECTED ;
5661  }
5663  return pSDB->createReplicaGroup ( pName, group ) ;
5664  }
5665 
5672  INT32 removeReplicaGroup ( const CHAR *pName )
5673  {
5674  if ( !pSDB )
5675  {
5676  return SDB_NOT_CONNECTED ;
5677  }
5678  return pSDB->removeReplicaGroup ( pName ) ;
5679  }
5680 
5693  INT32 createReplicaCataGroup ( const CHAR *pHostName,
5694  const CHAR *pServiceName,
5695  const CHAR *pDatabasePath,
5696  const bson::BSONObj &configure )
5697  {
5698  if ( !pSDB )
5699  {
5700  return SDB_NOT_CONNECTED ;
5701  }
5702  return pSDB->createReplicaCataGroup ( pHostName, pServiceName,
5703  pDatabasePath, configure ) ;
5704  }
5705 
5706  INT32 activateReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
5707  {
5708  if ( !pSDB )
5709  {
5710  return SDB_NOT_CONNECTED ;
5711  }
5712  return pSDB->activateReplicaGroup ( pName, replicaGroup ) ;
5713  }
5714 
5722  INT32 activateReplicaGroup ( const CHAR *pName, sdbReplicaGroup &replicaGroup )
5723  {
5724  if ( !pSDB )
5725  {
5726  return SDB_NOT_CONNECTED ;
5727  }
5728  RELEASE_INNER_HANDLE( replicaGroup.pReplicaGroup ) ;
5729  return pSDB->activateReplicaGroup ( pName, replicaGroup ) ;
5730  }
5731 
5739  INT32 execUpdate( const CHAR *sql, bson::BSONObj *pResult = NULL )
5740  {
5741  if ( !pSDB )
5742  {
5743  return SDB_NOT_CONNECTED ;
5744  }
5745  return pSDB->execUpdate( sql, pResult ) ;
5746  }
5747 
5748  /* \fn INT32 exec( const CHAR *sql,
5749  _sdbCursor **result )
5750  \brief Executing SQL command.
5751  \param [in] sql The SQL command.
5752  \param [out] result The return cursor handle of matching documents.
5753  \retval SDB_OK Operation Success
5754  \retval Others Operation Fail
5755  */
5756  INT32 exec( const CHAR *sql,
5757  _sdbCursor **result )
5758  {
5759  if ( !pSDB )
5760  {
5761  return SDB_NOT_CONNECTED ;
5762  }
5763  return pSDB->exec( sql, result ) ;
5764  }
5765 
5774  INT32 exec( const CHAR *sql,
5775  sdbCursor &cursor )
5776  {
5777  if ( !pSDB )
5778  {
5779  return SDB_NOT_CONNECTED ;
5780  }
5781  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
5782  return pSDB->exec( sql, cursor ) ;
5783  }
5784 
5790  INT32 transactionBegin()
5791  {
5792  if ( !pSDB )
5793  {
5794  return SDB_NOT_CONNECTED ;
5795  }
5796  return pSDB->transactionBegin() ;
5797  }
5798 
5804  INT32 transactionCommit()
5805  {
5806  if ( !pSDB )
5807  {
5808  return SDB_NOT_CONNECTED ;
5809  }
5810  return pSDB->transactionCommit() ;
5811  }
5812 
5818  INT32 transactionRollback()
5819  {
5820  if ( !pSDB )
5821  {
5822  return SDB_NOT_CONNECTED ;
5823  }
5824  return pSDB->transactionRollback() ;
5825  }
5835  INT32 flushConfigure( const bson::BSONObj &options )
5836  {
5837  if ( !pSDB )
5838  {
5839  return SDB_NOT_CONNECTED ;
5840  }
5841  return pSDB->flushConfigure( options ) ;
5842  }
5843 
5850  INT32 crtJSProcedure ( const CHAR *code )
5851  {
5852  if ( !pSDB )
5853  {
5854  return SDB_NOT_CONNECTED ;
5855  }
5856  return pSDB->crtJSProcedure( code ) ;
5857  }
5858 
5865  INT32 rmProcedure( const CHAR *spName )
5866  {
5867  if ( !pSDB )
5868  {
5869  return SDB_NOT_CONNECTED ;
5870  }
5871  return pSDB->rmProcedure( spName ) ;
5872  }
5873 
5874  INT32 listProcedures( _sdbCursor **cursor, const bson::BSONObj &condition )
5875  {
5876  if ( !pSDB )
5877  {
5878  return SDB_NOT_CONNECTED ;
5879  }
5880  return pSDB->listProcedures( cursor, condition ) ;
5881  }
5882 
5890  INT32 listProcedures( sdbCursor &cursor, const bson::BSONObj &condition )
5891  {
5892  if ( !pSDB )
5893  {
5894  return SDB_NOT_CONNECTED ;
5895  }
5896  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
5897  return pSDB->listProcedures( cursor, condition ) ;
5898  }
5899 
5900  INT32 evalJS( const CHAR *code,
5901  SDB_SPD_RES_TYPE &type,
5902  _sdbCursor **cursor,
5903  bson::BSONObj &errmsg )
5904  {
5905  if ( !pSDB )
5906  {
5907  return SDB_NOT_CONNECTED ;
5908  }
5909  return pSDB->evalJS( code, type, cursor, errmsg ) ;
5910  }
5911 
5924  INT32 evalJS( const CHAR *code, SDB_SPD_RES_TYPE &type,
5925  sdbCursor &cursor,
5926  bson::BSONObj &errmsg )
5927  {
5928  if ( !pSDB )
5929  {
5930  return SDB_NOT_CONNECTED ;
5931  }
5932  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
5933  return pSDB->evalJS( code, type, cursor, errmsg ) ;
5934  }
5935 
5955  INT32 backupOffline ( const bson::BSONObj &options)
5956  {
5957  return backup( options ) ;
5958  }
5959 
5978  INT32 backup ( const bson::BSONObj &options)
5979  {
5980  if ( !pSDB )
5981  {
5982  return SDB_NOT_CONNECTED ;
5983  }
5984  return pSDB->backup( options ) ;
5985  }
5986 
5987 
5988  INT32 listBackup ( _sdbCursor **cursor,
5989  const bson::BSONObj &options,
5990  const bson::BSONObj &condition = _sdbStaticObject,
5991  const bson::BSONObj &selector = _sdbStaticObject,
5992  const bson::BSONObj &orderBy = _sdbStaticObject)
5993  {
5994  if ( !pSDB )
5995  {
5996  return SDB_NOT_CONNECTED ;
5997  }
5998  return pSDB->listBackup( cursor, options, condition, selector, orderBy ) ;
5999  }
6000 
6023  INT32 listBackup ( sdbCursor &cursor,
6024  const bson::BSONObj &options,
6025  const bson::BSONObj &condition = _sdbStaticObject,
6026  const bson::BSONObj &selector = _sdbStaticObject,
6027  const bson::BSONObj &orderBy = _sdbStaticObject)
6028  {
6029  if ( !pSDB )
6030  {
6031  return SDB_NOT_CONNECTED ;
6032  }
6033  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6034  return pSDB->listBackup( cursor, options, condition, selector, orderBy ) ;
6035  }
6036 
6051  INT32 removeBackup ( const bson::BSONObj &options)
6052  {
6053  if ( !pSDB )
6054  {
6055  return SDB_NOT_CONNECTED ;
6056  }
6057  return pSDB->removeBackup( options ) ;
6058  }
6059 
6060  INT32 listTasks ( _sdbCursor **cursor,
6061  const bson::BSONObj &condition = _sdbStaticObject,
6062  const bson::BSONObj &selector = _sdbStaticObject,
6063  const bson::BSONObj &orderBy = _sdbStaticObject,
6064  const bson::BSONObj &hint = _sdbStaticObject)
6065  {
6066  if ( !pSDB )
6067  {
6068  return SDB_NOT_CONNECTED ;
6069  }
6070  return pSDB->listTasks ( cursor,
6071  condition,
6072  selector,
6073  orderBy,
6074  hint ) ;
6075  }
6093  INT32 listTasks ( sdbCursor &cursor,
6094  const bson::BSONObj &condition = _sdbStaticObject,
6095  const bson::BSONObj &selector = _sdbStaticObject,
6096  const bson::BSONObj &orderBy = _sdbStaticObject,
6097  const bson::BSONObj &hint = _sdbStaticObject)
6098  {
6099  if ( !pSDB )
6100  {
6101  return SDB_NOT_CONNECTED ;
6102  }
6103  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6104  return pSDB->listTasks ( cursor,
6105  condition,
6106  selector,
6107  orderBy,
6108  hint ) ;
6109  }
6110 
6119  INT32 waitTasks ( const SINT64 *taskIDs,
6120  SINT32 num )
6121  {
6122  if ( !pSDB )
6123  {
6124  return SDB_NOT_CONNECTED ;
6125  }
6126  return pSDB->waitTasks ( taskIDs,
6127  num ) ;
6128  }
6129 
6139  INT32 cancelTask ( SINT64 taskID,
6140  BOOLEAN isAsync )
6141  {
6142  if ( !pSDB )
6143  {
6144  return SDB_NOT_CONNECTED ;
6145  }
6146  return pSDB->cancelTask ( taskID,
6147  isAsync ) ;
6148  }
6149 
6160  INT32 setSessionAttr ( const bson::BSONObj &options = _sdbStaticObject )
6161  {
6162  if ( !pSDB )
6163  {
6164  return SDB_NOT_CONNECTED ;
6165  }
6166  return pSDB->setSessionAttr ( options ) ;
6167  }
6168 
6177  INT32 getSessionAttr ( bson::BSONObj & result,
6178  BOOLEAN useCache = TRUE )
6179  {
6180  if ( !pSDB )
6181  {
6182  return SDB_NOT_CONNECTED ;
6183  }
6184  return pSDB->getSessionAttr( result, useCache ) ;
6185  }
6186 
6193  INT32 closeAllCursors ()
6194  {
6195  return interrupt() ;
6196  }
6197 
6204  INT32 interrupt()
6205  {
6206  if ( !pSDB )
6207  {
6208  return SDB_NOT_CONNECTED ;
6209  }
6210  return pSDB->interrupt () ;
6211  }
6212 
6221  INT32 interruptOperation()
6222  {
6223  if ( !pSDB )
6224  {
6225  return SDB_NOT_CONNECTED ;
6226  }
6227  return pSDB->interruptOperation () ;
6228  }
6229 
6237  INT32 isValid ( BOOLEAN *result )
6238  {
6239  if ( !pSDB )
6240  {
6241  return SDB_NOT_CONNECTED ;
6242  }
6243  return pSDB->isValid ( result ) ;
6244  }
6245 
6250  BOOLEAN isValid ()
6251  {
6252  if ( !pSDB )
6253  {
6254  return FALSE ;
6255  }
6256  return pSDB->isValid () ;
6257  }
6258 
6263  BOOLEAN isClosed()
6264  {
6265  if (!pSDB)
6266  {
6267  return TRUE ;
6268  }
6269  return pSDB->isClosed() ;
6270  }
6271 
6290  INT32 createDomain ( const CHAR *pDomainName,
6291  const bson::BSONObj &options,
6292  sdbDomain &domain )
6293  {
6294  if ( !pSDB )
6295  {
6296  return SDB_NOT_CONNECTED ;
6297  }
6298  RELEASE_INNER_HANDLE( domain.pDomain ) ;
6299  return pSDB->createDomain ( pDomainName, options, domain ) ;
6300  }
6301 
6302  INT32 createDomain ( const CHAR *pDomainName,
6303  const bson::BSONObj &options,
6304  _sdbDomain **domain )
6305  {
6306  if ( !pSDB )
6307  {
6308  return SDB_NOT_CONNECTED ;
6309  }
6310  return pSDB->createDomain ( pDomainName, options, domain ) ;
6311  }
6312 
6319  INT32 dropDomain ( const CHAR *pDomainName )
6320  {
6321  if ( !pSDB )
6322  {
6323  return SDB_NOT_CONNECTED ;
6324  }
6325  return pSDB->dropDomain ( pDomainName ) ;
6326  }
6327 
6328  INT32 getDomain ( const CHAR *pDomainName,
6329  _sdbDomain **domain )
6330  {
6331  if ( !pSDB )
6332  {
6333  return SDB_NOT_CONNECTED ;
6334  }
6335  return pSDB->getDomain ( pDomainName, domain ) ;
6336  }
6337 
6346  INT32 getDomain ( const CHAR *pDomainName,
6347  sdbDomain &domain )
6348  {
6349  if ( !pSDB )
6350  {
6351  return SDB_NOT_CONNECTED ;
6352  }
6353  RELEASE_INNER_HANDLE( domain.pDomain ) ;
6354  return pSDB->getDomain ( pDomainName, domain ) ;
6355  }
6356 
6357  INT32 listDomains ( _sdbCursor **cursor,
6358  const bson::BSONObj &condition = _sdbStaticObject,
6359  const bson::BSONObj &selector = _sdbStaticObject,
6360  const bson::BSONObj &orderBy = _sdbStaticObject,
6361  const bson::BSONObj &hint = _sdbStaticObject )
6362  {
6363  if ( !pSDB )
6364  {
6365  return SDB_NOT_CONNECTED ;
6366  }
6367  return pSDB->listDomains ( cursor, condition, selector, orderBy, hint ) ;
6368  }
6369 
6387  INT32 listDomains ( sdbCursor &cursor,
6388  const bson::BSONObj &condition = _sdbStaticObject,
6389  const bson::BSONObj &selector = _sdbStaticObject,
6390  const bson::BSONObj &orderBy = _sdbStaticObject,
6391  const bson::BSONObj &hint = _sdbStaticObject )
6392  {
6393  if ( !pSDB )
6394  {
6395  return SDB_NOT_CONNECTED ;
6396  }
6397  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6398  return pSDB->listDomains ( cursor, condition, selector, orderBy, hint ) ;
6399  }
6400 
6401  /* \fn INT32 getDC( sdbDataCenter &dc )
6402  \brief Get current data center.
6403  \retval SDB_OK Operation Success
6404  \retval Others Operation Fail
6405  */
6406  INT32 getDC( sdbDataCenter &dc )
6407  {
6408  if ( !pSDB )
6409  {
6410  return SDB_NOT_CONNECTED ;
6411  }
6412  RELEASE_INNER_HANDLE( dc.pDC ) ;
6413  return pSDB->getDC ( dc ) ;
6414  }
6415 
6416  /* \fn INT32 getDC( _sdbDataCenter **dc )
6417  \brief Get current data center.
6418  \retval SDB_OK Operation Success
6419  \retval Others Operation Fail
6420  */
6421  INT32 getDC( _sdbDataCenter **dc )
6422  {
6423  if ( !pSDB )
6424  {
6425  return SDB_NOT_CONNECTED ;
6426  }
6427  return pSDB->getDC ( dc ) ;
6428  }
6429 
6435  UINT64 getLastAliveTime() const { return pSDB->getLastAliveTime(); }
6436 
6459  INT32 syncDB( const bson::BSONObj &options = _sdbStaticObject )
6460  {
6461  if ( !pSDB )
6462  {
6463  return SDB_NOT_CONNECTED ;
6464  }
6465  return pSDB->syncDB ( options ) ;
6466  }
6467 
6494  INT32 analyze ( const bson::BSONObj &options = _sdbStaticObject )
6495  {
6496  if ( !pSDB )
6497  {
6498  return SDB_NOT_CONNECTED ;
6499  }
6500  return pSDB->analyze ( options ) ;
6501  }
6502 
6518  INT32 forceSession( SINT64 sessionID,
6519  const bson::BSONObj &options = _sdbStaticObject )
6520  {
6521  if( !pSDB )
6522  {
6523  return SDB_NOT_CONNECTED ;
6524  }
6525  return pSDB->forceSession( sessionID, options ) ;
6526  }
6527 
6542  INT32 forceStepUp( const bson::BSONObj &options = _sdbStaticObject )
6543  {
6544  if( !pSDB )
6545  {
6546  return SDB_NOT_CONNECTED ;
6547  }
6548  return pSDB->forceStepUp( options ) ;
6549  }
6550 
6563  INT32 invalidateCache( const bson::BSONObj &options = _sdbStaticObject )
6564  {
6565  if( !pSDB )
6566  {
6567  return SDB_NOT_CONNECTED ;
6568  }
6569  return pSDB->invalidateCache( options ) ;
6570  }
6571 
6585  INT32 reloadConfig( const bson::BSONObj &options = _sdbStaticObject )
6586  {
6587  if( !pSDB )
6588  {
6589  return SDB_NOT_CONNECTED ;
6590  }
6591  return pSDB->reloadConfig( options ) ;
6592  }
6593 
6610  INT32 updateConfig( const bson::BSONObj &configs = _sdbStaticObject,
6611  const bson::BSONObj &options = _sdbStaticObject )
6612  {
6613  if( !pSDB )
6614  {
6615  return SDB_NOT_CONNECTED ;
6616  }
6617  return pSDB->updateConfig( configs, options ) ;
6618  }
6619 
6636  INT32 deleteConfig( const bson::BSONObj &configs = _sdbStaticObject,
6637  const bson::BSONObj &options = _sdbStaticObject )
6638  {
6639  if( !pSDB )
6640  {
6641  return SDB_NOT_CONNECTED ;
6642  }
6643  return pSDB->deleteConfig( configs, options ) ;
6644  }
6645 
6668  INT32 setPDLevel( INT32 level,
6669  const bson::BSONObj &options = _sdbStaticObject )
6670  {
6671  if( !pSDB )
6672  {
6673  return SDB_NOT_CONNECTED ;
6674  }
6675  return pSDB->setPDLevel( level, options ) ;
6676  }
6677 
6678  INT32 msg( const CHAR* msg )
6679  {
6680  if( !pSDB )
6681  {
6682  return SDB_NOT_CONNECTED ;
6683  }
6684  return pSDB->msg( msg ) ;
6685  }
6686 
6702  INT32 loadCS( const CHAR* csName,
6703  const bson::BSONObj &options = _sdbStaticObject )
6704  {
6705  if( !pSDB )
6706  {
6707  return SDB_NOT_CONNECTED ;
6708  }
6709  return pSDB->loadCS( csName, options ) ;
6710  }
6711 
6727  INT32 unloadCS( const CHAR* csName,
6728  const bson::BSONObj &options = _sdbStaticObject )
6729  {
6730  if( !pSDB )
6731  {
6732  return SDB_NOT_CONNECTED ;
6733  }
6734  return pSDB->unloadCS( csName, options ) ;
6735  }
6736 
6749  INT32 traceStart( UINT32 traceBufferSize,
6750  const CHAR* component = NULL,
6751  const CHAR* breakpoint = NULL,
6752  const vector<UINT32> &tidVec = _sdbStaticUINT32Vec )
6753  {
6754  if( !pSDB )
6755  {
6756  return SDB_NOT_CONNECTED ;
6757  }
6758  return pSDB->traceStart( traceBufferSize, component,
6759  breakpoint, tidVec ) ;
6760  }
6761 
6781  INT32 traceStart( UINT32 traceBufferSize,
6782  const bson::BSONObj &options )
6783  {
6784  if( !pSDB )
6785  {
6786  return SDB_NOT_CONNECTED ;
6787  }
6788  return pSDB->traceStart( traceBufferSize, options ) ;
6789  }
6790 
6799  INT32 traceStop( const CHAR* dumpFileName )
6800  {
6801  if( !pSDB )
6802  {
6803  return SDB_NOT_CONNECTED ;
6804  }
6805  return pSDB->traceStop( dumpFileName ) ;
6806  }
6807 
6813  INT32 traceResume()
6814  {
6815  if( !pSDB )
6816  {
6817  return SDB_NOT_CONNECTED ;
6818  }
6819  return pSDB->traceResume() ;
6820  }
6821 
6828  INT32 traceStatus( sdbCursor& cursor )
6829  {
6830  if( !pSDB )
6831  {
6832  return SDB_NOT_CONNECTED ;
6833  }
6834  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6835  return pSDB->traceStatus( cursor ) ;
6836  }
6837 
6838  INT32 traceStatus( _sdbCursor** cursor )
6839  {
6840  if( !pSDB )
6841  {
6842  return SDB_NOT_CONNECTED ;
6843  }
6844  return pSDB->traceStatus( cursor ) ;
6845  }
6846 
6857  INT32 renameCollectionSpace( const CHAR* oldName,
6858  const CHAR* newName,
6859  const bson::BSONObj &options = _sdbStaticObject )
6860  {
6861  if( !pSDB )
6862  {
6863  return SDB_NOT_CONNECTED ;
6864  }
6865  return pSDB->renameCollectionSpace( oldName, newName, options ) ;
6866  }
6867 
6879  INT32 getLastErrorObj( bson::BSONObj &errObj )
6880  {
6881  if( !pSDB )
6882  {
6883  return SDB_NOT_CONNECTED ;
6884  }
6885  return pSDB->getLastErrorObj( errObj ) ;
6886  }
6887 
6891  void cleanLastErrorObj()
6892  {
6893  if( !pSDB )
6894  {
6895  return ;
6896  }
6897  return pSDB->cleanLastErrorObj() ;
6898  }
6899 
6910  INT32 getLastResultObj( bson::BSONObj &result,
6911  BOOLEAN getOwned = FALSE ) const
6912  {
6913  if( !pSDB )
6914  {
6915  return SDB_NOT_CONNECTED ;
6916  }
6917  return pSDB->getLastResultObj( result, getOwned ) ;
6918  }
6919 
6920  INT32 createDataSource( const CHAR *pDataSourceName,
6921  const CHAR *addresses,
6922  const CHAR *user = NULL,
6923  const CHAR *password = NULL,
6924  const CHAR *type = NULL,
6925  const bson::BSONObj *options = NULL,
6926  _sdbDataSource **dataSource = NULL )
6927  {
6928  if ( !pSDB )
6929  {
6930  return SDB_NOT_CONNECTED ;
6931  }
6932  return pSDB->createDataSource( pDataSourceName, addresses, user,
6933  password, type, options, dataSource ) ;
6934  }
6935 
6936  INT32 dropDataSource( const CHAR *pDataSourceName )
6937  {
6938  if ( !pSDB )
6939  {
6940  return SDB_NOT_CONNECTED ;
6941  }
6942  return pSDB->dropDataSource( pDataSourceName ) ;
6943  }
6944 
6945  INT32 getDataSource( const CHAR *pDataSourceName,
6946  _sdbDataSource **dataSource )
6947  {
6948  if ( !pSDB )
6949  {
6950  return SDB_NOT_CONNECTED ;
6951  }
6952  return pSDB->getDataSource( pDataSourceName, dataSource ) ;
6953  }
6954 
6955  INT32 getDataSource( const CHAR *pDataSourceName,
6956  sdbDataSource &dataSource )
6957  {
6958  if ( !pSDB )
6959  {
6960  return SDB_NOT_CONNECTED ;
6961  }
6962  RELEASE_INNER_HANDLE( dataSource.pDataSource ) ;
6963  return pSDB->getDataSource( pDataSourceName, dataSource ) ;
6964  }
6965 
6966 
6967  INT32 listDataSources( _sdbCursor** cursor,
6968  const bson::BSONObj &condition = _sdbStaticObject,
6969  const bson::BSONObj &selector = _sdbStaticObject,
6970  const bson::BSONObj &orderBy = _sdbStaticObject,
6971  const bson::BSONObj &hint = _sdbStaticObject )
6972  {
6973  if ( !pSDB )
6974  {
6975  return SDB_NOT_CONNECTED ;
6976  }
6977  return pSDB->listDataSources( cursor, condition, selector, orderBy, hint ) ;
6978  }
6979 
6980  INT32 listDataSources( sdbCursor& cursor,
6981  const bson::BSONObj &condition = _sdbStaticObject,
6982  const bson::BSONObj &selector = _sdbStaticObject,
6983  const bson::BSONObj &orderBy = _sdbStaticObject,
6984  const bson::BSONObj &hint = _sdbStaticObject )
6985  {
6986  if ( !pSDB )
6987  {
6988  return SDB_NOT_CONNECTED ;
6989  }
6990  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6991  return pSDB->listDataSources( cursor, condition, selector, orderBy, hint ) ;
6992  }
6993  } ;
6994 
6998  typedef class sdb sdb ;
6999 
7006  SDB_EXPORT INT32 initClient( sdbClientConf* config ) ;
7007 
7008 }
7009 
7010 #endif