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 // The flag represents whether insert return detail result
70 #define FLG_INSERT_RETURNNUM 0x00000002
71 
72 #define FLG_INSERT_REPLACEONDUP 0x00000004
73 
74 #define FLG_INSERT_UPDATEONDUP 0x00000008
75 
76 // #define FLG_INSERT_HAS_ID_FIELD 0x00000010
78 #define FLG_INSERT_CONTONDUP_ID 0x00000020
79 
81 #define FLG_INSERT_REPLACEONDUP_ID 0x00000040
82 
83 #define FLG_INSERT_RETURN_OID 0x10000000
84 
85 // client socket timeout value
86 // since client and server may not sit in the same network, we need
87 // to set this value bigger than engine socket timeout
88 // this value is in millisec
89 // set to 1 second timeout
90 #define SDB_CLIENT_SOCKET_TIMEOUT_DFT 1000
91 
93 #define sdbReplicaNode sdbNode
94 
96 #define QUERY_FORCE_HINT 0x00000080
97 
98 #define QUERY_PARALLED 0x00000100
99 
100 #define QUERY_WITH_RETURNDATA 0x00000200
101 
102 #define QUERY_PREPARE_MORE 0x00004000
103 
104 #define QUERY_KEEP_SHARDINGKEY_IN_UPDATE 0x00008000
105 
109 #define QUERY_FOR_UPDATE 0x00010000
110 
114 #define QUERY_FOR_SHARE 0x00040000
115 
116 
118 #define UPDATE_KEEP_SHARDINGKEY QUERY_KEEP_SHARDINGKEY_IN_UPDATE
119 
120 #define UPDATE_ONE 0x00000002
121 // The flag represent whether update return detail result
122 #define UPDATE_RETURNNUM 0x00000004
123 
125 #define FLG_DELETE_ONE 0x00000002
126 // The flag represent whether update return detail result
127 #define FLG_DELETE_RETURNNUM 0x00000004
128 
129 #define SDB_INDEX_SORT_BUFFER_DEFAULT_SIZE 64
130 
132 {
133  SDB_LOB_CREATEONLY = 0x00000001,
134  SDB_LOB_READ = 0x00000004,
135  SDB_LOB_WRITE = 0x00000008,
136  SDB_LOB_SHAREREAD = 0x00000040
137 } ;
142 
144 {
148 } ;
153 
157 namespace sdbclient
158 {
159  const static bson::BSONObj _sdbStaticObject ;
160  const static bson::OID _sdbStaticOid ;
161  const static std::vector<INT32> _sdbStaticVec ;
162  const static std::vector<UINT32> _sdbStaticUINT32Vec ;
163  class _sdbCursor ;
164  class _sdbCollection ;
165  class sdb ;
166  class _sdb ;
167  class _sdbLob ;
168  class sdbLob ;
169 
171  typedef void (*ERROR_ON_REPLY_FUNC)( const CHAR *pErrorObj,
172  UINT32 objSize,
173  INT32 flag,
174  const CHAR *pDescription,
175  const CHAR *pDetail ) ;
176 
181  SDB_EXPORT void sdbSetErrorOnReplyCallback( ERROR_ON_REPLY_FUNC func ) ;
182 
183  class DLLEXPORT _sdbCursor
184  {
185  private :
186  _sdbCursor ( const _sdbCursor& other ) ;
187  _sdbCursor& operator=( const _sdbCursor& ) ;
188  public :
189  _sdbCursor () {}
190  virtual ~_sdbCursor () {}
191  virtual INT32 next ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE ) = 0 ;
192  virtual INT32 current ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE ) = 0 ;
193  virtual INT32 close () = 0 ;
194  virtual INT32 advance ( const bson::BSONObj &option,
195  bson::BSONObj *pResult = NULL ) = 0 ;
196  } ;
197 
201  class DLLEXPORT sdbCursor
202  {
203  private :
204  sdbCursor ( const sdbCursor& other ) ;
205  sdbCursor& operator=( const sdbCursor& ) ;
206  public :
213  _sdbCursor *pCursor ;
214 
219  {
220  pCursor = NULL ;
221  }
222 
227  {
228  if ( pCursor )
229  {
230  delete pCursor ;
231  }
232  }
233 
250  INT32 next ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE )
251  {
252  if ( !pCursor )
253  {
254  return SDB_NOT_CONNECTED ;
255  }
256  return pCursor->next ( obj, getOwned ) ;
257  }
258 
275  INT32 current ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE )
276  {
277  if ( !pCursor )
278  {
279  return SDB_NOT_CONNECTED ;
280  }
281  return pCursor->current ( obj, getOwned ) ;
282  }
283 
291  INT32 advance ( const bson::BSONObj &option, bson::BSONObj *pResult = NULL )
292  {
293  if ( !pCursor )
294  {
295  return SDB_NOT_CONNECTED ;
296  }
297  return pCursor->advance( option, pResult ) ;
298  }
299 
305  INT32 close ()
306  {
307  if ( !pCursor )
308  {
309  return SDB_OK ;
310  }
311  return pCursor->close () ;
312  }
313  } ;
314 
315  class DLLEXPORT _sdbCollection
316  {
317  private :
318  _sdbCollection ( const _sdbCollection& other ) ;
319  _sdbCollection& operator=( const _sdbCollection& ) ;
320  public :
321  _sdbCollection () {}
322  virtual ~_sdbCollection () {}
323  // get the total number of records for a given condition, if the condition
324  // is NULL then match all records in the collection
325  virtual INT32 getCount ( SINT64 &count,
326  const bson::BSONObj &condition = _sdbStaticObject,
327  const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
328  // insert a bson object into current collection
329  // given:
330  // object ( required )
331  // returns id as the pointer pointing to _id bson element
332  virtual INT32 insert ( const bson::BSONObj &obj, bson::OID *id = NULL ) = 0 ;
333  virtual INT32 insert ( const bson::BSONObj &obj,
334  INT32 flags,
335  bson::BSONObj *pResult = NULL ) = 0 ;
336  virtual INT32 insert ( const bson::BSONObj &obj,
337  const bson::BSONObj &hint,
338  INT32 flags,
339  bson::BSONObj *pResult = NULL ) = 0 ;
340  virtual INT32 insert ( std::vector<bson::BSONObj> &objs,
341  INT32 flags = 0,
342  bson::BSONObj *pResult = NULL ) = 0 ;
343  virtual INT32 insert ( std::vector<bson::BSONObj> &objs,
344  const bson::BSONObj &hint,
345  INT32 flags = 0,
346  bson::BSONObj *pResult = NULL ) = 0 ;
347  virtual INT32 insert ( const bson::BSONObj objs[],
348  INT32 size,
349  INT32 flags = 0,
350  bson::BSONObj *pResult = NULL ) = 0 ;
351  virtual INT32 bulkInsert ( SINT32 flags,
352  std::vector<bson::BSONObj> &obj
353  ) = 0 ;
354  // update bson object from current collection
355  // given:
356  // update rule ( required )
357  // update condition ( optional )
358  // hint ( optional )
359  // flag ( optional )
360  // pResult ( optional )
361  virtual INT32 update ( const bson::BSONObj &rule,
362  const bson::BSONObj &condition = _sdbStaticObject,
363  const bson::BSONObj &hint = _sdbStaticObject,
364  INT32 flag = 0,
365  bson::BSONObj *pResult = NULL
366  ) = 0 ;
367 
368  // update bson object from current collection, if there's nothing match
369  // then insert an record that modified from empty BSON object
370  // given:
371  // update rule ( required )
372  // update condition ( optional )
373  // hint ( optional )
374  // setOnInsert ( optional )
375  // flag ( optional )
376  // pResult ( optional )
377  virtual INT32 upsert ( const bson::BSONObj &rule,
378  const bson::BSONObj &condition = _sdbStaticObject,
379  const bson::BSONObj &hint = _sdbStaticObject,
380  const bson::BSONObj &setOnInsert = _sdbStaticObject,
381  INT32 flag = 0,
382  bson::BSONObj *pResult = NULL
383  ) = 0 ;
384 
385  // delete bson objects from current collection
386  // given:
387  // delete condition ( optional )
388  // hint ( optional )
389  // flag ( optional )
390  // pResult ( optional )
391  virtual INT32 del ( const bson::BSONObj &condition = _sdbStaticObject,
392  const bson::BSONObj &hint = _sdbStaticObject,
393  INT32 flag = 0,
394  bson::BSONObj *pResult = NULL
395  ) = 0 ;
396 
397  // query objects from current collection
398  // given:
399  // query condition ( optional )
400  // query selected def ( optional )
401  // query orderby ( optional )
402  // hint ( optional )
403  // output: _sdbCursor ( required )
404  virtual INT32 query ( _sdbCursor **cursor,
405  const bson::BSONObj &condition = _sdbStaticObject,
406  const bson::BSONObj &selected = _sdbStaticObject,
407  const bson::BSONObj &orderBy = _sdbStaticObject,
408  const bson::BSONObj &hint = _sdbStaticObject,
409  INT64 numToSkip = 0,
410  INT64 numToReturn = -1,
411  INT32 flags = 0
412  ) = 0 ;
413 
414  virtual INT32 query ( sdbCursor &cursor,
415  const bson::BSONObj &condition = _sdbStaticObject,
416  const bson::BSONObj &selected = _sdbStaticObject,
417  const bson::BSONObj &orderBy = _sdbStaticObject,
418  const bson::BSONObj &hint = _sdbStaticObject,
419  INT64 numToSkip = 0,
420  INT64 numToReturn = -1,
421  INT32 flags = 0
422  ) = 0 ;
423 
424  virtual INT32 queryOne( bson::BSONObj &obj,
425  const bson::BSONObj &condition = _sdbStaticObject,
426  const bson::BSONObj &selected = _sdbStaticObject,
427  const bson::BSONObj &orderBy = _sdbStaticObject,
428  const bson::BSONObj &hint = _sdbStaticObject,
429  INT64 numToSkip = 0,
430  INT32 flags = 0 ) = 0 ;
431 
432  // query objects from current collection and update
433  // given:
434  // update rule ( required )
435  // query condition ( optional )
436  // query selected def ( optional )
437  // query orderby ( optional )
438  // hint ( optional )
439  // flags( optional )
440  // returnNew ( optioinal )
441  // output: sdbCursor ( required )
442  virtual INT32 queryAndUpdate ( _sdbCursor **cursor,
443  const bson::BSONObj &update,
444  const bson::BSONObj &condition = _sdbStaticObject,
445  const bson::BSONObj &selected = _sdbStaticObject,
446  const bson::BSONObj &orderBy = _sdbStaticObject,
447  const bson::BSONObj &hint = _sdbStaticObject,
448  INT64 numToSkip = 0,
449  INT64 numToReturn = -1,
450  INT32 flag = 0,
451  BOOLEAN returnNew = FALSE
452  ) = 0 ;
453 
454  // query objects from current collection and remove
455  // given:
456  // query condition ( optional )
457  // query selected def ( optional )
458  // query orderby ( optional )
459  // hint ( optional )
460  // flags( optional )
461  // output: sdbCursor ( required )
462  virtual INT32 queryAndRemove ( _sdbCursor **cursor,
463  const bson::BSONObj &condition = _sdbStaticObject,
464  const bson::BSONObj &selected = _sdbStaticObject,
465  const bson::BSONObj &orderBy = _sdbStaticObject,
466  const bson::BSONObj &hint = _sdbStaticObject,
467  INT64 numToSkip = 0,
468  INT64 numToReturn = -1,
469  INT32 flag = 0
470  ) = 0 ;
471 
472  //virtual INT32 rename ( const CHAR *pNewName ) = 0 ;
473  // create an index for the current collection
474  // given:
475  // index definition ( required )
476  // index name ( required )
477  // uniqueness ( required )
478  // enforceness ( required )
479  virtual INT32 createIndex ( const bson::BSONObj &indexDef,
480  const CHAR *pName,
481  BOOLEAN isUnique,
482  BOOLEAN isEnforced,
483  INT32 sortBufferSize ) = 0 ;
484  virtual INT32 createIndex ( const bson::BSONObj &indexDef,
485  const CHAR *pName,
486  const bson::BSONObj &indexAttr = _sdbStaticObject,
487  const bson::BSONObj &option = _sdbStaticObject
488  ) = 0 ;
489  virtual INT32 createIndexAsync ( SINT64 &taskID,
490  const bson::BSONObj &indexDef,
491  const CHAR *pName,
492  const bson::BSONObj &indexAttr = _sdbStaticObject,
493  const bson::BSONObj &option = _sdbStaticObject
494  ) = 0 ;
495  virtual INT32 snapshotIndexes ( _sdbCursor **cursor,
496  const bson::BSONObj &condition = _sdbStaticObject,
497  const bson::BSONObj &selector = _sdbStaticObject,
498  const bson::BSONObj &orderby = _sdbStaticObject,
499  const bson::BSONObj &hint = _sdbStaticObject,
500  INT64 numToSkip = 0,
501  INT64 numToReturn = -1 ) = 0 ;
502  virtual INT32 getIndexes ( _sdbCursor **cursor,
503  const CHAR *pName ) = 0 ;
504  virtual INT32 getIndexes ( sdbCursor &cursor,
505  const CHAR *pIndexName ) = 0 ;
506  virtual INT32 getIndexes ( std::vector<bson::BSONObj> &infos ) = 0 ;
507  virtual INT32 getIndex ( const CHAR *pIndexName, bson::BSONObj &info ) = 0 ;
508  virtual INT32 dropIndex ( const CHAR *pIndexName ) = 0 ;
509  virtual INT32 dropIndexAsync ( SINT64 &taskID,
510  const CHAR *pIndexName ) = 0 ;
511  virtual INT32 copyIndex ( const CHAR *subClFullName,
512  const CHAR *pIndexName ) = 0 ;
513  virtual INT32 copyIndexAsync ( SINT64 &taskID,
514  const CHAR *subClFullName,
515  const CHAR *pIndexName ) = 0 ;
516  virtual INT32 create () = 0 ;
517  virtual INT32 drop () = 0 ;
518  virtual const CHAR *getCollectionName () = 0 ;
519  virtual const CHAR *getCSName () = 0 ;
520  virtual const CHAR *getFullName () = 0 ;
521  virtual INT32 split ( const CHAR *pSourceGroupName,
522  const CHAR *pTargetGroupName,
523  const bson::BSONObj &splitConditon,
524  const bson::BSONObj &splitEndCondition = _sdbStaticObject) = 0 ;
525  virtual INT32 split ( const CHAR *pSourceGroupName,
526  const CHAR *pTargetGroupName,
527  FLOAT64 percent ) = 0 ;
528  virtual INT32 splitAsync ( SINT64 &taskID,
529  const CHAR *pSourceGroupName,
530  const CHAR *pTargetGroupName,
531  const bson::BSONObj &splitCondition,
532  const bson::BSONObj &splitEndCondition = _sdbStaticObject) = 0 ;
533  virtual INT32 splitAsync ( const CHAR *pSourceGroupName,
534  const CHAR *pTargetGroupName,
535  FLOAT64 percent,
536  SINT64 &taskID ) = 0 ;
537  virtual INT32 aggregate ( _sdbCursor **cursor,
538  std::vector<bson::BSONObj> &obj
539  ) = 0 ;
540  virtual INT32 aggregate ( sdbCursor &cursor,
541  std::vector<bson::BSONObj> &obj
542  ) = 0 ;
543  virtual INT32 getQueryMeta ( _sdbCursor **cursor,
544  const bson::BSONObj &condition = _sdbStaticObject,
545  const bson::BSONObj &orderBy = _sdbStaticObject,
546  const bson::BSONObj &hint = _sdbStaticObject,
547  INT64 numToSkip = 0,
548  INT64 numToReturn = -1
549  ) = 0 ;
550  virtual INT32 getQueryMeta ( sdbCursor &cursor,
551  const bson::BSONObj &condition = _sdbStaticObject,
552  const bson::BSONObj &orderBy = _sdbStaticObject,
553  const bson::BSONObj &hint = _sdbStaticObject,
554  INT64 numToSkip = 0,
555  INT64 numToReturn = -1
556  ) = 0 ;
557  virtual INT32 attachCollection ( const CHAR *subClFullName,
558  const bson::BSONObj &options) = 0 ;
559  virtual INT32 detachCollection ( const CHAR *subClFullName) = 0 ;
560 
561  virtual INT32 alterCollection ( const bson::BSONObj &options ) = 0 ;
563  virtual INT32 explain ( sdbCursor &cursor,
564  const bson::BSONObj &condition = _sdbStaticObject,
565  const bson::BSONObj &select = _sdbStaticObject,
566  const bson::BSONObj &orderBy = _sdbStaticObject,
567  const bson::BSONObj &hint = _sdbStaticObject,
568  INT64 numToSkip = 0,
569  INT64 numToReturn = -1,
570  INT32 flag = 0,
571  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
572 
573  virtual INT32 explain ( _sdbCursor **cursor,
574  const bson::BSONObj &condition = _sdbStaticObject,
575  const bson::BSONObj &select = _sdbStaticObject,
576  const bson::BSONObj &orderBy = _sdbStaticObject,
577  const bson::BSONObj &hint = _sdbStaticObject,
578  INT64 numToSkip = 0,
579  INT64 numToReturn = -1,
580  INT32 flag = 0,
581  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
583  virtual INT32 createLob( sdbLob &lob,
584  const bson::OID *oid = NULL,
585  const bson::BSONObj &userObj = _sdbStaticObject ) = 0 ;
586 
587  virtual INT32 removeLob( const bson::OID &oid ) = 0 ;
588 
589  virtual INT32 truncateLob( const bson::OID &oid, INT64 length ) = 0 ;
590 
591  virtual INT32 openLob( sdbLob &lob, const bson::OID &oid,
592  SDB_LOB_OPEN_MODE mode = SDB_LOB_READ ) = 0 ;
593 
594  virtual INT32 openLob( sdbLob &lob, const bson::OID &oid,
595  INT32 mode ) = 0 ;
596 
597  virtual INT32 listLobs( sdbCursor &cursor,
598  const bson::BSONObj &condition = _sdbStaticObject,
599  const bson::BSONObj &selected = _sdbStaticObject,
600  const bson::BSONObj &orderBy = _sdbStaticObject,
601  const bson::BSONObj &hint = _sdbStaticObject,
602  INT64 numToSkip = 0,
603  INT64 numToReturn = -1 ) = 0 ;
604 
605  virtual INT32 listLobs( _sdbCursor **cursor,
606  const bson::BSONObj &condition = _sdbStaticObject,
607  const bson::BSONObj &selected = _sdbStaticObject,
608  const bson::BSONObj &orderBy = _sdbStaticObject,
609  const bson::BSONObj &hint = _sdbStaticObject,
610  INT64 numToSkip = 0,
611  INT64 numToReturn = -1 ) = 0 ;
612 
613  virtual INT32 createLobID( bson::OID &oid, const CHAR *pTimeStamp = NULL ) = 0 ;
614 
615  virtual INT32 lobExplain( const bson::OID &oid,
616  bson::BSONObj &result,
617  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
618 
619  virtual INT32 listLobPieces(
620  _sdbCursor **cursor,
621  const bson::BSONObj &condition = _sdbStaticObject,
622  const bson::BSONObj &selected = _sdbStaticObject,
623  const bson::BSONObj &orderBy = _sdbStaticObject,
624  const bson::BSONObj &hint = _sdbStaticObject,
625  INT64 numToSkip = 0,
626  INT64 numToReturn = -1 ) = 0 ;
627 
628  virtual INT32 listLobPieces(
629  sdbCursor &cursor,
630  const bson::BSONObj &condition = _sdbStaticObject,
631  const bson::BSONObj &selected = _sdbStaticObject,
632  const bson::BSONObj &orderBy = _sdbStaticObject,
633  const bson::BSONObj &hint = _sdbStaticObject,
634  INT64 numToSkip = 0,
635  INT64 numToReturn = -1 ) = 0 ;
636 
638  virtual INT32 truncate( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
639 
641  virtual INT32 createIdIndex( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
642 
643  virtual INT32 dropIdIndex() = 0 ;
644 
645  virtual INT32 createAutoIncrement( const bson::BSONObj &options ) = 0;
646 
647  virtual INT32 createAutoIncrement( const std::vector<bson::BSONObj> &options ) = 0;
648 
649  virtual INT32 dropAutoIncrement( const CHAR *fieldName ) = 0;
650 
651  virtual INT32 dropAutoIncrement( const std::vector<const CHAR*> &fieldNames ) = 0;
652 
653  virtual INT32 pop ( const bson::BSONObj &option = _sdbStaticObject ) = 0 ;
654 
655  virtual INT32 enableSharding ( const bson::BSONObj &options ) = 0 ;
656 
657  virtual INT32 disableSharding () = 0 ;
658 
659  virtual INT32 enableCompression ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
660 
661  virtual INT32 disableCompression () = 0 ;
662 
663  virtual INT32 setAttributes ( const bson::BSONObj &options ) = 0 ;
664 
665  virtual INT32 getDetail ( _sdbCursor **cursor,
666  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
667 
668  virtual INT32 getDetail ( sdbCursor &cursor,
669  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
670 
671  virtual INT32 getCollectionStat ( bson::BSONObj &result ) = 0 ;
672 
673  virtual INT32 getIndexStat ( const CHAR *pIndexName,
674  bson::BSONObj &result,
675  BOOLEAN detail = FALSE ) = 0 ;
676 
677  virtual void setVersion( INT32 clVersion ) = 0;
678  virtual INT32 getVersion() = 0;
679  virtual INT32 setConsistencyStrategy( INT32 value ) = 0 ;
680  } ;
681 
685  class DLLEXPORT sdbCollection
686  {
687  private :
692  sdbCollection ( const sdbCollection& other ) ;
693 
699  sdbCollection& operator=( const sdbCollection& ) ;
700  public :
707  _sdbCollection *pCollection ;
708 
713  {
714  pCollection = NULL ;
715  }
716 
721  {
722  if ( pCollection )
723  {
724  delete pCollection ;
725  }
726  }
727 
741  INT32 getCount ( SINT64 &count,
742  const bson::BSONObj &condition = _sdbStaticObject,
743  const bson::BSONObj &hint = _sdbStaticObject )
744  {
745  if ( !pCollection )
746  {
747  return SDB_NOT_CONNECTED ;
748  }
749  return pCollection->getCount ( count, condition, hint ) ;
750  }
751 
769  INT32 split ( const CHAR *pSourceGroupName,
770  const CHAR *pTargetGroupName,
771  const bson::BSONObj &splitCondition,
772  const bson::BSONObj &splitEndCondition = _sdbStaticObject)
773  {
774  if ( !pCollection )
775  {
776  return SDB_NOT_CONNECTED ;
777  }
778  return pCollection->split ( pSourceGroupName,
779  pTargetGroupName,
780  splitCondition,
781  splitEndCondition) ;
782  }
783 
795  INT32 split ( const CHAR *pSourceGroupName,
796  const CHAR *pTargetGroupName,
797  FLOAT64 percent )
798  {
799  if ( !pCollection )
800  {
801  return SDB_NOT_CONNECTED ;
802  }
803  return pCollection->split ( pSourceGroupName,
804  pTargetGroupName,
805  percent ) ;
806  }
807 
827  INT32 splitAsync ( SINT64 &taskID,
828  const CHAR *pSourceGroupName,
829  const CHAR *pTargetGroupName,
830  const bson::BSONObj &splitCondition,
831  const bson::BSONObj &splitEndCondition = _sdbStaticObject )
832  {
833  if ( !pCollection )
834  {
835  return SDB_NOT_CONNECTED ;
836  }
837  return pCollection->splitAsync ( taskID,
838  pSourceGroupName,
839  pTargetGroupName,
840  splitCondition,
841  splitEndCondition ) ;
842  }
843 
857  INT32 splitAsync ( const CHAR *pSourceGroupName,
858  const CHAR *pTargetGroupName,
859  FLOAT64 percent,
860  SINT64 &taskID )
861  {
862  if ( !pCollection )
863  {
864  return SDB_NOT_CONNECTED ;
865  }
866  return pCollection->splitAsync ( pSourceGroupName,
867  pTargetGroupName,
868  percent,
869  taskID ) ;
870  }
871 
898  INT32 alterCollection ( const bson::BSONObj &options )
899  {
900  if ( !pCollection )
901  {
902  return SDB_NOT_CONNECTED ;
903  }
904  return pCollection->alterCollection ( options ) ;
905  }
906 
929  INT32 insert ( const bson::BSONObj &obj, bson::OID *pId = NULL )
930  {
931  if ( !pCollection )
932  {
933  return SDB_NOT_CONNECTED ;
934  }
935  return pCollection->insert ( obj, pId ) ;
936  }
937 
984  INT32 insert ( const bson::BSONObj &obj,
985  INT32 flags,
986  bson::BSONObj *pResult = NULL )
987  {
988  if ( !pCollection )
989  {
990  return SDB_NOT_CONNECTED ;
991  }
992  return pCollection->insert ( obj, flags, pResult ) ;
993  }
994 
1051  INT32 insert ( const bson::BSONObj &obj,
1052  const bson::BSONObj &hint,
1053  INT32 flags,
1054  bson::BSONObj *pResult = NULL )
1055  {
1056  if ( !pCollection )
1057  {
1058  return SDB_NOT_CONNECTED ;
1059  }
1060  return pCollection->insert ( obj, hint, flags, pResult ) ;
1061  }
1062 
1112  INT32 insert ( std::vector<bson::BSONObj> &objs,
1113  INT32 flags = 0,
1114  bson::BSONObj *pResult = NULL )
1115  {
1116  if ( !pCollection )
1117  {
1118  return SDB_NOT_CONNECTED ;
1119  }
1120  return pCollection->insert( objs, flags, pResult ) ;
1121  }
1122 
1177  INT32 insert ( std::vector<bson::BSONObj> &objs,
1178  const bson::BSONObj &hint,
1179  INT32 flags = 0,
1180  bson::BSONObj *pResult = NULL )
1181  {
1182  if ( !pCollection )
1183  {
1184  return SDB_NOT_CONNECTED ;
1185  }
1186  return pCollection->insert( objs, hint, flags, pResult ) ;
1187  }
1188 
1240  INT32 insert ( const bson::BSONObj objs[],
1241  INT32 size,
1242  INT32 flags = 0,
1243  bson::BSONObj *pResult = NULL )
1244  {
1245  if ( !pCollection )
1246  {
1247  return SDB_NOT_CONNECTED ;
1248  }
1249  return pCollection->insert ( objs, size, flags, pResult ) ;
1250  }
1251 
1279  INT32 bulkInsert ( SINT32 flags,
1280  std::vector<bson::BSONObj> &objs )
1281  {
1282  if ( !pCollection )
1283  {
1284  return SDB_NOT_CONNECTED ;
1285  }
1286  return pCollection->bulkInsert ( flags, objs ) ;
1287  }
1288 
1321  INT32 update ( const bson::BSONObj &rule,
1322  const bson::BSONObj &condition = _sdbStaticObject,
1323  const bson::BSONObj &hint = _sdbStaticObject,
1324  INT32 flag = 0,
1325  bson::BSONObj *pResult = NULL
1326  )
1327  {
1328  if ( !pCollection )
1329  {
1330  return SDB_NOT_CONNECTED ;
1331  }
1332  return pCollection->update ( rule, condition, hint, flag, pResult ) ;
1333  }
1334 
1368  INT32 upsert ( const bson::BSONObj &rule,
1369  const bson::BSONObj &condition = _sdbStaticObject,
1370  const bson::BSONObj &hint = _sdbStaticObject,
1371  const bson::BSONObj &setOnInsert = _sdbStaticObject,
1372  INT32 flag = 0,
1373  bson::BSONObj *pResult = NULL
1374  )
1375  {
1376  if ( !pCollection )
1377  {
1378  return SDB_NOT_CONNECTED ;
1379  }
1380  return pCollection->upsert ( rule, condition, hint, setOnInsert,
1381  flag, pResult ) ;
1382  }
1383 
1405  INT32 del ( const bson::BSONObj &condition = _sdbStaticObject,
1406  const bson::BSONObj &hint = _sdbStaticObject,
1407  INT32 flag = 0,
1408  bson::BSONObj *pResult = NULL
1409  )
1410  {
1411  if ( !pCollection )
1412  {
1413  return SDB_NOT_CONNECTED ;
1414  }
1415  return pCollection->del ( condition, hint, flag, pResult ) ;
1416  }
1417 
1418  /* \fn INT32 query ( _sdbCursor **cursor,
1419  const bson::BSONObj &condition,
1420  const bson::BSONObj &selected,
1421  const bson::BSONObj &orderBy,
1422  const bson::BSONObj &hint,
1423  INT64 numToSkip,
1424  INT64 numToReturn,
1425  INT32 flags
1426  )
1427  \brief Get the matching documents in current collection
1428  \param [in] condition The matching rule, return all the documents if not provided
1429  \param [in] selected The selective rule, return the whole document if not provided
1430  \param [in] orderBy The ordered rule, result set is unordered if not provided
1431  \param [in] hint Specified the index used to scan data. e.g. {"":"ageIndex"} means
1432  using index "ageIndex" to scan data(index scan);
1433  {"":null} means table scan. when hint is not provided,
1434  database automatically match the optimal index to scan data
1435  \param [in] numToSkip Skip the first numToSkip documents, default is 0
1436  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
1437  \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
1438  \code
1439  QUERY_FORCE_HINT
1440  QUERY_PARALLED
1441  QUERY_WITH_RETURNDATA
1442  QUERY_FOR_UPDATE
1443  \endcode
1444  \param [out] cursor The cursor of current query
1445  \retval SDB_OK Operation Success
1446  \retval Others Operation Fail
1447  */
1448  INT32 query ( _sdbCursor **cursor,
1449  const bson::BSONObj &condition = _sdbStaticObject,
1450  const bson::BSONObj &selected = _sdbStaticObject,
1451  const bson::BSONObj &orderBy = _sdbStaticObject,
1452  const bson::BSONObj &hint = _sdbStaticObject,
1453  INT64 numToSkip = 0,
1454  INT64 numToReturn = -1,
1455  INT32 flags = 0
1456  )
1457  {
1458  if ( !pCollection )
1459  {
1460  return SDB_NOT_CONNECTED ;
1461  }
1462  return pCollection->query ( cursor, condition, selected, orderBy,
1463  hint, numToSkip, numToReturn, flags ) ;
1464  }
1465 
1496  INT32 query ( sdbCursor &cursor,
1497  const bson::BSONObj &condition = _sdbStaticObject,
1498  const bson::BSONObj &selected = _sdbStaticObject,
1499  const bson::BSONObj &orderBy = _sdbStaticObject,
1500  const bson::BSONObj &hint = _sdbStaticObject,
1501  INT64 numToSkip = 0,
1502  INT64 numToReturn = -1,
1503  INT32 flags = 0
1504  )
1505  {
1506  if ( !pCollection )
1507  {
1508  return SDB_NOT_CONNECTED ;
1509  }
1510  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1511  return pCollection->query ( cursor, condition, selected, orderBy,
1512  hint, numToSkip, numToReturn, flags ) ;
1513  }
1514 
1543  INT32 queryOne( bson::BSONObj &obj,
1544  const bson::BSONObj &condition = _sdbStaticObject,
1545  const bson::BSONObj &selected = _sdbStaticObject,
1546  const bson::BSONObj &orderBy = _sdbStaticObject,
1547  const bson::BSONObj &hint = _sdbStaticObject,
1548  INT64 numToSkip = 0,
1549  INT32 flag = 0 )
1550  {
1551  if ( !pCollection )
1552  {
1553  return SDB_NOT_CONNECTED ;
1554  }
1555  return pCollection->queryOne( obj, condition, selected, orderBy,
1556  hint, numToSkip, flag ) ;
1557  }
1558 
1594  INT32 queryAndUpdate ( sdbCursor &cursor,
1595  const bson::BSONObj &update,
1596  const bson::BSONObj &condition = _sdbStaticObject,
1597  const bson::BSONObj &selected = _sdbStaticObject,
1598  const bson::BSONObj &orderBy = _sdbStaticObject,
1599  const bson::BSONObj &hint = _sdbStaticObject,
1600  INT64 numToSkip = 0,
1601  INT64 numToReturn = -1,
1602  INT32 flag = 0,
1603  BOOLEAN returnNew = FALSE
1604  )
1605  {
1606  if ( !pCollection )
1607  {
1608  return SDB_NOT_CONNECTED ;
1609  }
1610  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1611  return pCollection->queryAndUpdate( &cursor.pCursor , update, condition,
1612  selected, orderBy, hint,
1613  numToSkip, numToReturn, flag, returnNew ) ;
1614  }
1615 
1646  INT32 queryAndRemove ( sdbCursor &cursor,
1647  const bson::BSONObj &condition = _sdbStaticObject,
1648  const bson::BSONObj &selected = _sdbStaticObject,
1649  const bson::BSONObj &orderBy = _sdbStaticObject,
1650  const bson::BSONObj &hint = _sdbStaticObject,
1651  INT64 numToSkip = 0,
1652  INT64 numToReturn = -1,
1653  INT32 flag = 0
1654  )
1655  {
1656  if ( !pCollection )
1657  {
1658  return SDB_NOT_CONNECTED ;
1659  }
1660  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1661  return pCollection->queryAndRemove( &cursor.pCursor , condition,
1662  selected, orderBy, hint,
1663  numToSkip, numToReturn, flag ) ;
1664  }
1665 
1682  INT32 createIndex ( const bson::BSONObj &indexDef,
1683  const CHAR *pIndexName,
1684  BOOLEAN isUnique,
1685  BOOLEAN isEnforced,
1686  INT32 sortBufferSize =
1687  SDB_INDEX_SORT_BUFFER_DEFAULT_SIZE )
1688  {
1689  if ( !pCollection )
1690  {
1691  return SDB_NOT_CONNECTED ;
1692  }
1693  return pCollection->createIndex ( indexDef, pIndexName, isUnique,
1694  isEnforced, sortBufferSize ) ;
1695  }
1696 
1723  INT32 createIndex ( const bson::BSONObj &indexDef,
1724  const CHAR *pIndexName,
1725  const bson::BSONObj &indexAttr = _sdbStaticObject,
1726  const bson::BSONObj &option = _sdbStaticObject )
1727  {
1728  if ( !pCollection )
1729  return SDB_NOT_CONNECTED ;
1730  return pCollection->createIndex ( indexDef, pIndexName,
1731  indexAttr, option ) ;
1732  }
1733 
1757  INT32 createIndexAsync ( SINT64 &taskID,
1758  const bson::BSONObj &indexDef,
1759  const CHAR *pIndexName,
1760  const bson::BSONObj &indexAttr = _sdbStaticObject,
1761  const bson::BSONObj &option = _sdbStaticObject )
1762  {
1763  if ( !pCollection )
1764  {
1765  return SDB_NOT_CONNECTED ;
1766  }
1767  return pCollection->createIndexAsync ( taskID, indexDef, pIndexName,
1768  indexAttr, option ) ;
1769  }
1770 
1771  /* \fn INT32 snapshotIndexes ( _sdbCursor **cursor,
1772  const bson::BSONObj &condition = _sdbStaticObject,
1773  const bson::BSONObj &selector = _sdbStaticObject,
1774  const bson::BSONObj &orderby = _sdbStaticObject,
1775  const bson::BSONObj &hint = _sdbStaticObject,
1776  INT64 numToSkip = 0,
1777  INT64 numToReturn = -1 )
1778  \brief Snapshot all of or one of the indexes in current collection
1779  \param [out] cursor The cursor of all the result for current query
1780  \param [in] condition The matching rule, match all the documents if not provided.
1781  \param [in] select The selective rule, return the whole document if not provided.
1782  \param [in] orderBy The ordered rule, result set is unordered if not provided.
1783  \param [in] hint The options provided for specific snapshot type
1784  \param [in] numToSkip Skip the first numToSkip documents, default is 0
1785  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
1786  \retval SDB_OK Operation Success
1787  \retval Others Operation Fail
1788  */
1789  INT32 snapshotIndexes ( _sdbCursor **cursor,
1790  const bson::BSONObj &condition = _sdbStaticObject,
1791  const bson::BSONObj &selector = _sdbStaticObject,
1792  const bson::BSONObj &orderby = _sdbStaticObject,
1793  const bson::BSONObj &hint = _sdbStaticObject,
1794  INT64 numToSkip = 0,
1795  INT64 numToReturn = -1 )
1796  {
1797  if ( !pCollection )
1798  {
1799  return SDB_NOT_CONNECTED ;
1800  }
1801  return pCollection->snapshotIndexes ( cursor, condition,
1802  selector, orderby, hint,
1803  numToSkip, numToReturn ) ;
1804  }
1805 
1806  /* \fn INT32 getIndexes ( _sdbCursor **cursor,
1807  const CHAR *pIndexName )
1808  \brief Get all of or one of the indexes in current collection
1809  \param [in] pIndexName The index name, returns all of the indexes if this parameter is null
1810  \param [out] cursor The cursor of all the result for current query
1811  \retval SDB_OK Operation Success
1812  \retval Others Operation Fail
1813  */
1814  INT32 getIndexes ( _sdbCursor **cursor,
1815  const CHAR *pIndexName )
1816  {
1817  if ( !pCollection )
1818  {
1819  return SDB_NOT_CONNECTED ;
1820  }
1821  return pCollection->getIndexes ( cursor, pIndexName ) ;
1822  }
1823 
1833  INT32 getIndexes ( sdbCursor &cursor,
1834  const CHAR *pIndexName )
1835  {
1836  if ( !pCollection )
1837  {
1838  return SDB_NOT_CONNECTED ;
1839  }
1840  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1841  return pCollection->getIndexes ( cursor, pIndexName ) ;
1842  }
1843 
1850  INT32 getIndexes ( std::vector<bson::BSONObj> &infos )
1851  {
1852  if ( !pCollection )
1853  {
1854  return SDB_NOT_CONNECTED ;
1855  }
1856  return pCollection->getIndexes ( infos ) ;
1857  }
1858 
1866  INT32 getIndex ( const CHAR *pIndexName, bson::BSONObj &info )
1867  {
1868  if ( !pCollection )
1869  {
1870  return SDB_NOT_CONNECTED ;
1871  }
1872  return pCollection->getIndex ( pIndexName, info ) ;
1873  }
1874 
1881  INT32 dropIndex ( const CHAR *pIndexName )
1882  {
1883  if ( !pCollection )
1884  {
1885  return SDB_NOT_CONNECTED ;
1886  }
1887  return pCollection->dropIndex ( pIndexName ) ;
1888  }
1889 
1898  INT32 dropIndexAsync ( SINT64 &taskID, const CHAR *pIndexName )
1899  {
1900  if ( !pCollection )
1901  return SDB_NOT_CONNECTED ;
1902  return pCollection->dropIndexAsync ( taskID, pIndexName ) ;
1903  }
1904 
1913  INT32 copyIndex ( const CHAR *subClFullName, const CHAR *pIndexName )
1914  {
1915  if ( !pCollection )
1916  return SDB_NOT_CONNECTED ;
1917  return pCollection->copyIndex ( subClFullName, pIndexName ) ;
1918  }
1919 
1930  INT32 copyIndexAsync ( SINT64 &taskID, const CHAR *subClFullName,
1931  const CHAR *pIndexName )
1932  {
1933  if ( !pCollection )
1934  return SDB_NOT_CONNECTED ;
1935  return pCollection->copyIndexAsync ( taskID, subClFullName,
1936  pIndexName ) ;
1937  }
1938 
1945  INT32 create ()
1946  {
1947  if ( !pCollection )
1948  {
1949  return SDB_NOT_CONNECTED ;
1950  }
1951  return pCollection->create () ;
1952  }
1953 
1960  INT32 drop ()
1961  {
1962  if ( !pCollection )
1963  {
1964  return SDB_NOT_CONNECTED ;
1965  }
1966  return pCollection->drop () ;
1967  }
1968 
1973  const CHAR *getCollectionName ()
1974  {
1975  if ( !pCollection )
1976  {
1977  return NULL ;
1978  }
1979  return pCollection->getCollectionName () ;
1980  }
1981 
1986  const CHAR *getCSName ()
1987  {
1988  if ( !pCollection )
1989  {
1990  return NULL ;
1991  }
1992  return pCollection->getCSName () ;
1993  }
1994 
1999  const CHAR *getFullName ()
2000  {
2001  if ( !pCollection )
2002  {
2003  return NULL ;
2004  }
2005  return pCollection->getFullName () ;
2006  }
2007 
2008  /* \fn INT32 aggregate ( _sdbCursor **cursor,
2009  std::vector<bson::BSONObj> &obj
2010  )
2011  \brief Execute aggregate operation in specified collection
2012  \param [in] obj The array of bson objects
2013  \param [out] cursor The cursor handle of result
2014  \retval SDB_OK Operation Success
2015  \retval Others Operation Fail
2016  */
2017  INT32 aggregate ( _sdbCursor **cursor,
2018  std::vector<bson::BSONObj> &obj
2019  )
2020  {
2021  if ( !pCollection )
2022  {
2023  return SDB_NOT_CONNECTED ;
2024  }
2025  return pCollection->aggregate ( cursor, obj ) ;
2026  }
2027 
2037  INT32 aggregate ( sdbCursor &cursor,
2038  std::vector<bson::BSONObj> &obj
2039  )
2040  {
2041  if ( !pCollection )
2042  {
2043  return SDB_NOT_CONNECTED ;
2044  }
2045  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2046  return pCollection->aggregate ( cursor, obj ) ;
2047  }
2048 
2049  /* \fn INT32 getQueryMeta ( _sdbCursor **cursor,
2050  const bson::BSONObj &condition = _sdbStaticObject,
2051  const bson::BSONObj &selected = _sdbStaticObject,
2052  const bson::BSONObj &orderBy = _sdbStaticObject,
2053  INT64 numToSkip = 0,
2054  INT64 numToReturn = -1 ) ;
2055  \brief Get the index blocks' or data blocks' infomation for concurrent query
2056  \param [in] condition The matching rule, return all the documents if not provided
2057  \param [in] orderBy The ordered rule, result set is unordered if not provided
2058  \param [in] hint Specified the index used to scan data. e.g. {"":"ageIndex"} means
2059  using index "ageIndex" to scan data(index scan);
2060  {"":null} means table scan. when hint is not provided,
2061  database automatically match the optimal index to scan data
2062  \param [in] numToSkip Skip the first numToSkip documents, default is 0
2063  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
2064  \param [out] cursor The cursor of current query
2065  \retval SDB_OK Operation Success
2066  \retval Others Operation Fail
2067  */
2068  INT32 getQueryMeta ( _sdbCursor **cursor,
2069  const bson::BSONObj &condition = _sdbStaticObject,
2070  const bson::BSONObj &orderBy = _sdbStaticObject,
2071  const bson::BSONObj &hint = _sdbStaticObject,
2072  INT64 numToSkip = 0,
2073  INT64 numToReturn = -1 )
2074  {
2075  if ( !pCollection )
2076  {
2077  return SDB_NOT_CONNECTED ;
2078  }
2079  return pCollection->getQueryMeta ( cursor, condition, orderBy,
2080  hint, numToSkip, numToReturn ) ;
2081  }
2082 
2103  INT32 getQueryMeta ( sdbCursor &cursor,
2104  const bson::BSONObj &condition = _sdbStaticObject,
2105  const bson::BSONObj &orderBy = _sdbStaticObject,
2106  const bson::BSONObj &hint = _sdbStaticObject,
2107  INT64 numToSkip = 0,
2108  INT64 numToReturn = -1 )
2109  {
2110  if ( !pCollection )
2111  {
2112  return SDB_NOT_CONNECTED ;
2113  }
2114  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2115  return pCollection->getQueryMeta ( cursor, condition, orderBy,
2116  hint, numToSkip, numToReturn ) ;
2117  }
2118 
2132  INT32 attachCollection ( const CHAR *subClFullName,
2133  const bson::BSONObj &options )
2134  {
2135  if ( !pCollection )
2136  {
2137  return SDB_NOT_CONNECTED ;
2138  }
2139  return pCollection->attachCollection ( subClFullName, options ) ;
2140  }
2141 
2148  INT32 detachCollection ( const CHAR *subClFullName )
2149  {
2150  if ( !pCollection )
2151  {
2152  return SDB_NOT_CONNECTED ;
2153  }
2154  return pCollection->detachCollection ( subClFullName ) ;
2155  }
2156 
2192  INT32 explain ( sdbCursor &cursor,
2193  const bson::BSONObj &condition = _sdbStaticObject,
2194  const bson::BSONObj &select = _sdbStaticObject,
2195  const bson::BSONObj &orderBy = _sdbStaticObject,
2196  const bson::BSONObj &hint = _sdbStaticObject,
2197  INT64 numToSkip = 0,
2198  INT64 numToReturn = -1,
2199  INT32 flag = 0,
2200  const bson::BSONObj &options = _sdbStaticObject )
2201  {
2202  if ( !pCollection )
2203  {
2204  return SDB_NOT_CONNECTED ;
2205  }
2206  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2207  return pCollection->explain( cursor, condition, select, orderBy, hint,
2208  numToSkip, numToReturn, flag, options ) ;
2209  }
2210 
2211  INT32 explain ( _sdbCursor **cursor,
2212  const bson::BSONObj &condition = _sdbStaticObject,
2213  const bson::BSONObj &select = _sdbStaticObject,
2214  const bson::BSONObj &orderBy = _sdbStaticObject,
2215  const bson::BSONObj &hint = _sdbStaticObject,
2216  INT64 numToSkip = 0,
2217  INT64 numToReturn = -1,
2218  INT32 flag = 0,
2219  const bson::BSONObj &options = _sdbStaticObject )
2220  {
2221  if ( !pCollection )
2222  {
2223  return SDB_NOT_CONNECTED ;
2224  }
2225  return pCollection->explain( cursor, condition, select, orderBy, hint,
2226  numToSkip, numToReturn, flag, options ) ;
2227  }
2228 
2238  INT32 createLob( sdbLob &lob,
2239  const bson::OID *oid = NULL,
2240  const bson::BSONObj &userObj = _sdbStaticObject )
2241  {
2242  if ( !pCollection )
2243  {
2244  return SDB_NOT_CONNECTED ;
2245  }
2246  return pCollection->createLob( lob, oid, userObj ) ;
2247  }
2248 
2255  INT32 removeLob( const bson::OID &oid )
2256  {
2257  if ( !pCollection )
2258  {
2259  return SDB_NOT_CONNECTED ;
2260  }
2261  return pCollection->removeLob( oid ) ;
2262  }
2263 
2271  INT32 truncateLob( const bson::OID &oid, INT64 length )
2272  {
2273  if ( !pCollection )
2274  {
2275  return SDB_NOT_CONNECTED ;
2276  }
2277  return pCollection->truncateLob( oid, length ) ;
2278  }
2279 
2289  INT32 openLob( sdbLob &lob, const bson::OID &oid,
2291  {
2292  if ( !pCollection )
2293  {
2294  return SDB_NOT_CONNECTED ;
2295  }
2296  return pCollection->openLob( lob, oid, mode ) ;
2297  }
2298 
2308  INT32 openLob( sdbLob &lob, const bson::OID &oid, INT32 mode )
2309  {
2310  if ( !pCollection )
2311  {
2312  return SDB_NOT_CONNECTED ;
2313  }
2314  return pCollection->openLob( lob, oid, mode ) ;
2315  }
2316 
2334  INT32 listLobs( sdbCursor &cursor,
2335  const bson::BSONObj &condition = _sdbStaticObject,
2336  const bson::BSONObj &selected = _sdbStaticObject,
2337  const bson::BSONObj &orderBy = _sdbStaticObject,
2338  const bson::BSONObj &hint = _sdbStaticObject,
2339  INT64 numToSkip = 0,
2340  INT64 numToReturn = -1 )
2341  {
2342  if ( !pCollection )
2343  {
2344  return SDB_NOT_CONNECTED ;
2345  }
2346  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2347  return pCollection->listLobs( cursor, condition, selected, orderBy,
2348  hint, numToSkip, numToReturn ) ;
2349  }
2350 
2351  INT32 listLobs( _sdbCursor **cursor,
2352  const bson::BSONObj &condition = _sdbStaticObject,
2353  const bson::BSONObj &selected = _sdbStaticObject,
2354  const bson::BSONObj &orderBy = _sdbStaticObject,
2355  const bson::BSONObj &hint = _sdbStaticObject,
2356  INT64 numToSkip = 0,
2357  INT64 numToReturn = -1 )
2358  {
2359  if ( !pCollection )
2360  {
2361  return SDB_NOT_CONNECTED ;
2362  }
2363  return pCollection->listLobs( cursor, condition, selected, orderBy,
2364  hint, numToSkip, numToReturn ) ;
2365  }
2366 
2375  INT32 createLobID( bson::OID &oid, const CHAR *pTimeStamp = NULL )
2376  {
2377  if ( !pCollection )
2378  {
2379  return SDB_NOT_CONNECTED ;
2380  }
2381  return pCollection->createLobID( oid, pTimeStamp ) ;
2382  }
2383 
2393  INT32 lobExplain( const bson::OID &oid,
2394  bson::BSONObj &result,
2395  const bson::BSONObj &options = _sdbStaticObject )
2396  {
2397  if ( !pCollection )
2398  {
2399  return SDB_NOT_CONNECTED ;
2400  }
2401  return pCollection->lobExplain( oid, result, options ) ;
2402  }
2403 
2411  INT32 truncate( const bson::BSONObj &options = _sdbStaticObject )
2412  {
2413  if ( !pCollection )
2414  {
2415  return SDB_NOT_CONNECTED ;
2416  }
2417  return pCollection->truncate( options ) ;
2418  }
2419 
2429  INT32 createIdIndex( const bson::BSONObj &options = _sdbStaticObject )
2430  {
2431  if ( !pCollection )
2432  {
2433  return SDB_NOT_CONNECTED ;
2434  }
2435  return pCollection->createIdIndex( options ) ;
2436  }
2437 
2444  INT32 dropIdIndex()
2445  {
2446  if ( !pCollection )
2447  {
2448  return SDB_NOT_CONNECTED ;
2449  }
2450  return pCollection->dropIdIndex() ;
2451  }
2452 
2470  INT32 createAutoIncrement ( const bson::BSONObj &options )
2471  {
2472  if ( !pCollection )
2473  {
2474  return SDB_NOT_CONNECTED ;
2475  }
2476  return pCollection->createAutoIncrement( options ) ;
2477  }
2478 
2485  INT32 createAutoIncrement ( const std::vector<bson::BSONObj> &options )
2486  {
2487  if ( !pCollection )
2488  {
2489  return SDB_NOT_CONNECTED ;
2490  }
2491  return pCollection->createAutoIncrement( options ) ;
2492  }
2493 
2500  INT32 dropAutoIncrement ( const CHAR * fieldName )
2501  {
2502  if ( !pCollection )
2503  {
2504  return SDB_NOT_CONNECTED ;
2505  }
2506  return pCollection->dropAutoIncrement( fieldName ) ;
2507  }
2508 
2515  INT32 dropAutoIncrement ( const std::vector<const CHAR*> &fieldNames )
2516  {
2517  if ( !pCollection )
2518  {
2519  return SDB_NOT_CONNECTED ;
2520  }
2521  return pCollection->dropAutoIncrement( fieldNames ) ;
2522  }
2523 
2537  INT32 enableSharding ( const bson::BSONObj & options = _sdbStaticObject )
2538  {
2539  if ( !pCollection )
2540  {
2541  return SDB_NOT_CONNECTED ;
2542  }
2543  return pCollection->enableSharding( options ) ;
2544  }
2545 
2551  INT32 disableSharding ()
2552  {
2553  if ( !pCollection )
2554  {
2555  return SDB_NOT_CONNECTED ;
2556  }
2557  return pCollection->disableSharding() ;
2558  }
2559 
2568  INT32 enableCompression ( const bson::BSONObj & options = _sdbStaticObject )
2569  {
2570  if ( !pCollection )
2571  {
2572  return SDB_NOT_CONNECTED ;
2573  }
2574  return pCollection->enableCompression( options ) ;
2575  }
2576 
2582  INT32 disableCompression ()
2583  {
2584  if ( !pCollection )
2585  {
2586  return SDB_NOT_CONNECTED ;
2587  }
2588  return pCollection->disableCompression() ;
2589  }
2590 
2611  INT32 setAttributes ( const bson::BSONObj &options )
2612  {
2613  if ( !pCollection )
2614  {
2615  return SDB_NOT_CONNECTED ;
2616  }
2617  return pCollection->setAttributes( options ) ;
2618  }
2619 
2620  /* \fn INT32 pop( const bson::BSONObj &option )
2621  \brief Pop records from a capped collection
2622  \param [in] option The pop options as follows:
2623 
2624  Direction : The direction to pop record. 1: pop forward. -1: pop backward.
2625  The default value is 1.
2626  \retval SDB_OK Operation Success
2627  \retval Others Operation Fail
2628  */
2629  INT32 pop ( const bson::BSONObj &option = _sdbStaticObject )
2630  {
2631  if ( !pCollection )
2632  {
2633  return SDB_NOT_CONNECTED ;
2634  }
2635  return pCollection->pop( option ) ;
2636  }
2637 
2638  INT32 listLobPieces( _sdbCursor **cursor,
2639  const bson::BSONObj &condition = _sdbStaticObject,
2640  const bson::BSONObj &selected = _sdbStaticObject,
2641  const bson::BSONObj &orderBy = _sdbStaticObject,
2642  const bson::BSONObj &hint = _sdbStaticObject,
2643  INT64 numToSkip = 0,
2644  INT64 numToReturn = -1 )
2645  {
2646  if( !pCollection )
2647  {
2648  return SDB_NOT_CONNECTED ;
2649  }
2650  return pCollection->listLobPieces( cursor, condition, selected,
2651  orderBy, hint, numToSkip,
2652  numToReturn ) ;
2653  }
2654 
2668  INT32 listLobPieces( sdbCursor &cursor,
2669  const bson::BSONObj &condition = _sdbStaticObject,
2670  const bson::BSONObj &selected = _sdbStaticObject,
2671  const bson::BSONObj &orderBy = _sdbStaticObject,
2672  const bson::BSONObj &hint = _sdbStaticObject,
2673  INT64 numToSkip = 0,
2674  INT64 numToReturn = -1 )
2675  {
2676  if( !pCollection )
2677  {
2678  return SDB_NOT_CONNECTED ;
2679  }
2680  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2681  return pCollection->listLobPieces( cursor, condition, selected,
2682  orderBy, hint, numToSkip,
2683  numToReturn ) ;
2684  }
2685 
2686  /* \fn INT32 getDetail ( _sdbCursor **cursor, const bson::BSONObj &options )
2687  \brief Get the detail of the collection.
2688  \param [in] options The options, ex: { Aggr : true }
2689  \param [out] cursor Return the all the info of current collection.
2690  \retval SDB_OK Operation Success
2691  \retval Others Operation Fail
2692  */
2693  INT32 getDetail ( _sdbCursor **cursor, const bson::BSONObj &options = _sdbStaticObject )
2694  {
2695  if ( !pCollection )
2696  {
2697  return SDB_NOT_CONNECTED ;
2698  }
2699  return pCollection->getDetail ( cursor, options ) ;
2700  }
2701 
2709  INT32 getDetail( sdbCursor &cursor, const bson::BSONObj &options = _sdbStaticObject )
2710  {
2711  if ( !pCollection)
2712  {
2713  return SDB_NOT_CONNECTED ;
2714  }
2715  return pCollection->getDetail( cursor, options ) ;
2716  }
2717 
2724  INT32 getCollectionStat( bson::BSONObj &result )
2725  {
2726  if( !pCollection )
2727  {
2728  return SDB_NOT_CONNECTED ;
2729  }
2730  return pCollection->getCollectionStat( result ) ;
2731  }
2732 
2742  INT32 getIndexStat( const CHAR *pIndexName, bson::BSONObj &result,
2743  BOOLEAN detail = FALSE )
2744  {
2745  if ( !pCollection )
2746  {
2747  return SDB_NOT_CONNECTED ;
2748  }
2749  return pCollection->getIndexStat( pIndexName, result, detail ) ;
2750  }
2751 
2752  /* \fn void setVersion ( INT32 clVersion )
2753  \brief set version to collection.
2754  \param [in] clVersion The collection version.
2755  */
2756  void setVersion( INT32 clVersion )
2757  {
2758  pCollection->setVersion( clVersion ) ;
2759  }
2760  /* \fn INT32 getVersion ()
2761  \brief get version from collection.
2762  \retval collection version.
2763  */
2764  INT32 getVersion()
2765  {
2766  return pCollection->getVersion() ;
2767  }
2768  /* \fn INT32 setConsistencyStrategy ()
2769  \brief set consistency strategy from collection.
2770  \param [in] value The consistency strategy of collection.
2771  \retval SDB_OK Operation Success
2772  \retval Others Operation Fail
2773  */
2774  INT32 setConsistencyStrategy( INT32 value )
2775  {
2776  return pCollection->setConsistencyStrategy( value ) ;
2777  }
2778  } ;
2779 
2784  {
2785  SDB_NODE_ALL = 0,
2786  SDB_NODE_ACTIVE,
2787  SDB_NODE_INACTIVE,
2788  SDB_NODE_UNKNOWN
2789  } ;
2790 
2794  typedef enum sdbNodeStatus sdbNodeStatus ;
2795 
2796  class DLLEXPORT _sdbNode
2797  {
2798  private :
2799  _sdbNode ( const _sdbNode& other ) ;
2800  _sdbNode& operator=( const _sdbNode& ) ;
2801  public :
2802  _sdbNode () {}
2803  virtual ~_sdbNode () {}
2804  // connect to the current node
2805  virtual INT32 connect ( _sdb **dbConn ) = 0 ;
2806  virtual INT32 connect ( sdb &dbConn ) = 0 ;
2807 
2808  // get status of the current node
2809  virtual sdbNodeStatus getStatus () = 0 ;
2810 
2811  // get host name of the current node
2812  virtual const CHAR *getHostName () = 0 ;
2813 
2814  // get service name of the current node
2815  virtual const CHAR *getServiceName () = 0 ;
2816 
2817  // get node name of the current node
2818  virtual const CHAR *getNodeName () = 0 ;
2819 
2820  // get node id of the current node
2821  virtual INT32 getNodeID( INT32 &nodeID ) const = 0 ;
2822 
2823  // stop the node
2824  virtual INT32 stop () = 0 ;
2825 
2826  // start the node
2827  virtual INT32 start () = 0 ;
2828 
2829  virtual INT32 setLocation ( const CHAR *pLocation ) = 0 ;
2830 
2831  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
2832 
2833  // modify config for the current node
2834 /* virtual INT32 modifyConfig ( std::map<std::string,std::string>
2835  &config ) = 0 ; */
2836  } ;
2837 
2844  class DLLEXPORT sdbNode
2845  {
2846  private :
2851  sdbNode ( const sdbNode& other ) ;
2852 
2858  sdbNode& operator=( const sdbNode& ) ;
2859  public :
2866  _sdbNode *pNode ;
2867 
2872  {
2873  pNode = NULL ;
2874  }
2875 
2880  {
2881  if ( pNode )
2882  {
2883  delete pNode ;
2884  }
2885  }
2886 
2887  INT32 connect ( _sdb **dbConn )
2888  {
2889  if ( !pNode )
2890  {
2891  return SDB_NOT_CONNECTED ;
2892  }
2893  return pNode->connect ( dbConn ) ;
2894  }
2895 
2903  INT32 connect ( sdb &dbConn )
2904  {
2905  if ( !pNode )
2906  {
2907  return SDB_NOT_CONNECTED ;
2908  }
2909  // we can not use dbConn.pSDB here,
2910  // for sdb had not define yet.
2911  // RELEASE_INNER_HANDLE( dbConn.pSDB ) ;
2912  return pNode->connect ( dbConn ) ;
2913  }
2914 
2921  sdbNodeStatus getStatus ()
2922  {
2923  if ( !pNode )
2924  {
2925  return SDB_NODE_UNKNOWN ;
2926  }
2927  return pNode->getStatus () ;
2928  }
2929 
2934  const CHAR *getHostName ()
2935  {
2936  if ( !pNode )
2937  {
2938  return NULL ;
2939  }
2940  return pNode->getHostName () ;
2941  }
2942 
2947  const CHAR *getServiceName ()
2948  {
2949  if ( !pNode )
2950  {
2951  return NULL ;
2952  }
2953  return pNode->getServiceName () ;
2954  }
2955 
2960  const CHAR *getNodeName ()
2961  {
2962  if ( !pNode )
2963  {
2964  return NULL ;
2965  }
2966  return pNode->getNodeName () ;
2967  }
2968 
2973  INT32 getNodeID( INT32 &nodeID ) const
2974  {
2975  if ( !pNode )
2976  {
2977  return SDB_NOT_CONNECTED ;
2978  }
2979  return pNode->getNodeID( nodeID ) ;
2980  }
2981 
2987  INT32 stop ()
2988  {
2989  if ( !pNode )
2990  {
2991  return SDB_NOT_CONNECTED ;
2992  }
2993  return pNode->stop () ;
2994  }
2995 
3001  INT32 start ()
3002  {
3003  if ( !pNode )
3004  {
3005  return SDB_NOT_CONNECTED ;
3006  }
3007  return pNode->start () ;
3008  }
3009 
3020  INT32 setLocation ( const CHAR *pLocation )
3021  {
3022  if ( !pNode )
3023  {
3024  return SDB_NOT_CONNECTED ;
3025  }
3026  return pNode->setLocation( pLocation ) ;
3027  }
3028 
3038  INT32 setAttributes ( const bson::BSONObj & options )
3039  {
3040  if ( !pNode )
3041  {
3042  return SDB_NOT_CONNECTED ;
3043  }
3044  return pNode->setAttributes( options ) ;
3045  }
3046 
3047 /* INT32 modifyConfig ( std::map<std::string,std::string> &config )
3048  {
3049  if ( !pNode )
3050  {
3051  return NULL ;
3052  }
3053  return pNode->modifyConfig ( config ) ;
3054  }*/
3055  } ;
3056 
3057  class DLLEXPORT _sdbReplicaGroup
3058  {
3059  private :
3060  _sdbReplicaGroup ( const _sdbReplicaGroup& other ) ;
3061  _sdbReplicaGroup& operator=( const _sdbReplicaGroup& ) ;
3062  public :
3063  _sdbReplicaGroup () {}
3064  virtual ~_sdbReplicaGroup () {}
3065  // get number of logical nodes
3066  virtual INT32 getNodeNum ( sdbNodeStatus status, INT32 *num ) = 0 ;
3067 
3068  // get detailed information for the set
3069  virtual INT32 getDetail ( bson::BSONObj &result ) = 0 ;
3070 
3071  // get the master node
3072  virtual INT32 getMaster ( _sdbNode **node ) = 0 ;
3073  virtual INT32 getMaster ( sdbNode &node ) = 0 ;
3074 
3075  // get one of the slave node
3076  virtual INT32 getSlave ( _sdbNode **node,
3077  const vector<INT32>& positions = _sdbStaticVec ) = 0 ;
3078  virtual INT32 getSlave ( sdbNode &node,
3079  const vector<INT32>& positions = _sdbStaticVec ) = 0 ;
3080 
3081  // get a given node by name
3082  virtual INT32 getNode ( const CHAR *pNodeName,
3083  _sdbNode **node ) = 0 ;
3084  virtual INT32 getNode ( const CHAR *pNodeName,
3085  sdbNode &node ) = 0 ;
3086 
3087  // get a given node by host/service name
3088  virtual INT32 getNode ( const CHAR *pHostName,
3089  const CHAR *pServiceName,
3090  _sdbNode **node ) = 0 ;
3091  virtual INT32 getNode ( const CHAR *pHostName,
3092  const CHAR *pServiceName,
3093  sdbNode &node ) = 0 ;
3094 
3095  // create a new node in current replica group
3096  virtual INT32 createNode ( const CHAR *pHostName,
3097  const CHAR *pServiceName,
3098  const CHAR *pDatabasePath,
3099  std::map<std::string,std::string> &config,
3100  _sdbNode **ppNode = NULL ) = 0 ;
3101 
3102  virtual INT32 createNode ( const CHAR *pHostName,
3103  const CHAR *pServiceName,
3104  const CHAR *pDatabasePath,
3105  const bson::BSONObj &options = _sdbStaticObject,
3106  _sdbNode **ppNode = NULL ) = 0 ;
3107 
3108  // remove the specified node in current replica group
3109  virtual INT32 removeNode ( const CHAR *pHostName,
3110  const CHAR *pServiceName,
3111  const bson::BSONObj &configure = _sdbStaticObject ) = 0 ;
3112  // stop the replica group
3113  virtual INT32 stop () = 0 ;
3114 
3115  // start the replica group
3116  virtual INT32 start () = 0 ;
3117 
3118  // get the replica group name
3119  virtual const CHAR *getName () = 0 ;
3120 
3121  // whether the current replica group is catalog replica group or not
3122  virtual BOOLEAN isCatalog () = 0 ;
3123 
3124  // attach node
3125  virtual INT32 attachNode( const CHAR *pHostName,
3126  const CHAR *pSvcName,
3127  const bson::BSONObj &options ) = 0 ;
3128 
3129  // detach node
3130  virtual INT32 detachNode( const CHAR *pHostName,
3131  const CHAR *pSvcName,
3132  const bson::BSONObj &options ) = 0 ;
3133 
3134  // reelect primary node
3135  virtual INT32 reelect( const bson::BSONObj &options = _sdbStaticObject,
3136  bson::BSONObj *pResult = NULL ) = 0 ;
3137 
3138  // reelect location primary node
3139  virtual INT32 reelectLocation( const CHAR* pLocation,
3140  const bson::BSONObj &options = _sdbStaticObject,
3141  bson::BSONObj *pResult = NULL ) = 0 ;
3142 
3143  // set active location in replica group
3144  virtual INT32 setActiveLocation ( const CHAR *pActiveLocation ) = 0 ;
3145 
3146  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
3147 
3148  // start critical mode
3149  virtual INT32 startCriticalMode( const bson::BSONObj &options ) = 0 ;
3150 
3151  // stop critical mode
3152  virtual INT32 stopCriticalMode() = 0 ;
3153 
3154  // start maintenance mode
3155  virtual INT32 startMaintenanceMode( const bson::BSONObj &options ) = 0 ;
3156 
3157  // stop maintenance mode
3158  virtual INT32 stopMaintenanceMode( const bson::BSONObj &options ) = 0 ;
3159  } ;
3160 
3164  class DLLEXPORT sdbReplicaGroup
3165  {
3166  private :
3167  sdbReplicaGroup ( const sdbReplicaGroup& other ) ;
3168  sdbReplicaGroup& operator=( const sdbReplicaGroup& ) ;
3169  public :
3176  _sdbReplicaGroup *pReplicaGroup ;
3177 
3182  {
3183  pReplicaGroup = NULL ;
3184  }
3185 
3190  {
3191  if ( pReplicaGroup )
3192  {
3193  delete pReplicaGroup ;
3194  }
3195  }
3196 
3211  INT32 getNodeNum ( sdbNodeStatus status, INT32 *num )
3212  {
3213  if ( !pReplicaGroup )
3214  {
3215  return SDB_NOT_CONNECTED ;
3216  }
3217  return pReplicaGroup->getNodeNum ( status, num ) ;
3218  }
3219 
3226  INT32 getDetail ( bson::BSONObj &result )
3227  {
3228  if ( !pReplicaGroup )
3229  {
3230  return SDB_NOT_CONNECTED ;
3231  }
3232  return pReplicaGroup->getDetail ( result ) ;
3233  }
3234 
3235  /* \fn INT32 getMaster ( _sdbNode **node )
3236  \brief Get the master node of the current replica group.
3237  \param [out] node The master node.If not exit,return null.
3238  \retval SDB_OK Operation Success
3239  \retval Others Operation Fail
3240  */
3241  INT32 getMaster ( _sdbNode **node )
3242  {
3243  if ( !pReplicaGroup )
3244  {
3245  return SDB_NOT_CONNECTED ;
3246  }
3247  return pReplicaGroup->getMaster ( node ) ;
3248  }
3249 
3256  INT32 getMaster ( sdbNode &node )
3257  {
3258  if ( !pReplicaGroup )
3259  {
3260  return SDB_NOT_CONNECTED ;
3261  }
3262  RELEASE_INNER_HANDLE( node.pNode ) ;
3263  return pReplicaGroup->getMaster ( node ) ;
3264  }
3265 
3266  /* \fn INT32 getSlave ( _sdbNode **node, const vector<INT32>& positions )
3267  \brief Get one of slave node of the current replica group,
3268  if no slave exists then get master
3269  \param [in] positions The positions of nodes
3270  \param [out] node The slave node
3271  \retval SDB_OK Operation Success
3272  \retval Others Operation Fail
3273  */
3274  INT32 getSlave ( _sdbNode **node,
3275  const vector<INT32>& positions = _sdbStaticVec )
3276  {
3277  if ( !pReplicaGroup )
3278  {
3279  return SDB_NOT_CONNECTED ;
3280  }
3281  return pReplicaGroup->getSlave ( node, positions ) ;
3282  }
3283 
3292  INT32 getSlave ( sdbNode &node,
3293  const vector<INT32>& positions = _sdbStaticVec )
3294  {
3295  if ( !pReplicaGroup )
3296  {
3297  return SDB_NOT_CONNECTED ;
3298  }
3299  RELEASE_INNER_HANDLE( node.pNode ) ;
3300  return pReplicaGroup->getSlave ( node, positions ) ;
3301  }
3302 
3303  /* \fn INT32 getNode ( const CHAR *pNodeName,
3304  _sdbNode **node )
3305  \brief Get specified node from current replica group.
3306  \param [in] pNodeName The name of the node, with the format of "hostname:port".
3307  \param [out] node The specified node
3308  \retval SDB_OK Operation Success
3309  \retval Others Operation Fail
3310  */
3311  INT32 getNode ( const CHAR *pNodeName,
3312  _sdbNode **node )
3313  {
3314  if ( !pReplicaGroup )
3315  {
3316  return SDB_NOT_CONNECTED ;
3317  }
3318  return pReplicaGroup->getNode ( pNodeName, node ) ;
3319  }
3320 
3329  INT32 getNode ( const CHAR *pNodeName,
3330  sdbNode &node )
3331  {
3332  if ( !pReplicaGroup )
3333  {
3334  return SDB_NOT_CONNECTED ;
3335  }
3336  RELEASE_INNER_HANDLE( node.pNode ) ;
3337  return pReplicaGroup->getNode ( pNodeName, node ) ;
3338  }
3339 
3340  INT32 getNode ( const CHAR *pHostName,
3341  const CHAR *pServiceName,
3342  _sdbNode **node )
3343  {
3344  if ( !pReplicaGroup )
3345  {
3346  return SDB_NOT_CONNECTED ;
3347  }
3348  return pReplicaGroup->getNode ( pHostName, pServiceName, node ) ;
3349  }
3350 
3361  INT32 getNode ( const CHAR *pHostName,
3362  const CHAR *pServiceName,
3363  sdbNode &node )
3364  {
3365  if ( !pReplicaGroup )
3366  {
3367  return SDB_NOT_CONNECTED ;
3368  }
3369  RELEASE_INNER_HANDLE( node.pNode ) ;
3370  return pReplicaGroup->getNode ( pHostName, pServiceName, node ) ;
3371  }
3372 
3386  INT32 createNode ( const CHAR *pHostName,
3387  const CHAR *pServiceName,
3388  const CHAR *pDatabasePath,
3389  std::map<std::string,std::string> &config,
3390  _sdbNode **pNode = NULL )
3391  {
3392  if ( !pReplicaGroup )
3393  {
3394  return SDB_NOT_CONNECTED ;
3395  }
3396  return pReplicaGroup->createNode ( pHostName, pServiceName,
3397  pDatabasePath, config, pNode ) ;
3398  }
3399 
3412  INT32 createNode ( const CHAR *pHostName,
3413  const CHAR *pServiceName,
3414  const CHAR *pDatabasePath,
3415  const bson::BSONObj &options = _sdbStaticObject,
3416  _sdbNode **pNode = NULL )
3417  {
3418  if ( !pReplicaGroup )
3419  {
3420  return SDB_NOT_CONNECTED ;
3421  }
3422  return pReplicaGroup->createNode ( pHostName, pServiceName,
3423  pDatabasePath, options, pNode ) ;
3424  }
3425 
3436  INT32 removeNode ( const CHAR *pHostName,
3437  const CHAR *pServiceName,
3438  const bson::BSONObj &configure = _sdbStaticObject )
3439  {
3440  if ( !pReplicaGroup )
3441  {
3442  return SDB_NOT_CONNECTED ;
3443  }
3444  return pReplicaGroup->removeNode ( pHostName, pServiceName,
3445  configure ) ;
3446  }
3452  INT32 stop ()
3453  {
3454  if ( !pReplicaGroup )
3455  {
3456  return SDB_NOT_CONNECTED ;
3457  }
3458  return pReplicaGroup->stop () ;
3459  }
3460 
3466  INT32 start ()
3467  {
3468  if ( !pReplicaGroup )
3469  {
3470  return SDB_NOT_CONNECTED ;
3471  }
3472  return pReplicaGroup->start () ;
3473  }
3474 
3479  const CHAR *getName ()
3480  {
3481  if ( !pReplicaGroup )
3482  {
3483  return NULL ;
3484  }
3485  return pReplicaGroup->getName() ;
3486  }
3487 
3493  BOOLEAN isCatalog ()
3494  {
3495  if ( !pReplicaGroup )
3496  {
3497  return FALSE ;
3498  }
3499  return pReplicaGroup->isCatalog() ;
3500  }
3501 
3516  INT32 attachNode( const CHAR *pHostName,
3517  const CHAR *pSvcName,
3518  const bson::BSONObj &options )
3519  {
3520  if ( !pReplicaGroup )
3521  {
3522  return SDB_NOT_CONNECTED ;
3523  }
3524  return pReplicaGroup->attachNode( pHostName, pSvcName, options ) ;
3525  }
3526 
3542  INT32 detachNode( const CHAR *pHostName,
3543  const CHAR *pSvcName,
3544  const bson::BSONObj &options )
3545  {
3546  if ( !pReplicaGroup )
3547  {
3548  return SDB_NOT_CONNECTED ;
3549  }
3550  return pReplicaGroup->detachNode( pHostName, pSvcName, options ) ;
3551  }
3552 
3562  INT32 reelect( const bson::BSONObj &options = _sdbStaticObject,
3563  bson::BSONObj *pResult = NULL )
3564  {
3565  if( !pReplicaGroup )
3566  {
3567  return SDB_NOT_CONNECTED ;
3568  }
3569  return pReplicaGroup->reelect( options, pResult ) ;
3570  }
3571 
3580  INT32 reelectLocation( const CHAR* pLocation,
3581  const bson::BSONObj &options = _sdbStaticObject,
3582  bson::BSONObj *pResult = NULL )
3583  {
3584  if( !pReplicaGroup )
3585  {
3586  return SDB_NOT_CONNECTED ;
3587  }
3588  return pReplicaGroup->reelectLocation( pLocation, options, pResult ) ;
3589  }
3590 
3591 
3602  INT32 setActiveLocation ( const CHAR *pActiveLocation )
3603  {
3604  if ( !pReplicaGroup )
3605  {
3606  return SDB_NOT_CONNECTED ;
3607  }
3608  return pReplicaGroup->setActiveLocation( pActiveLocation ) ;
3609  }
3610 
3621  INT32 setAttributes ( const bson::BSONObj & options )
3622  {
3623  if ( !pReplicaGroup )
3624  {
3625  return SDB_NOT_CONNECTED ;
3626  }
3627  return pReplicaGroup->setAttributes( options ) ;
3628  }
3629 
3643  INT32 startCriticalMode( const bson::BSONObj &options )
3644  {
3645  if ( !pReplicaGroup )
3646  {
3647  return SDB_NOT_CONNECTED ;
3648  }
3649  return pReplicaGroup->startCriticalMode( options ) ;
3650  }
3651 
3657  INT32 stopCriticalMode()
3658  {
3659  if ( !pReplicaGroup )
3660  {
3661  return SDB_NOT_CONNECTED ;
3662  }
3663  return pReplicaGroup->stopCriticalMode () ;
3664  }
3665 
3678  INT32 startMaintenanceMode( const bson::BSONObj &options )
3679  {
3680  if ( !pReplicaGroup )
3681  {
3682  return SDB_NOT_CONNECTED ;
3683  }
3684  return pReplicaGroup->startMaintenanceMode( options ) ;
3685  }
3686 
3697  INT32 stopMaintenanceMode( const bson::BSONObj &options )
3698  {
3699  if ( !pReplicaGroup )
3700  {
3701  return SDB_NOT_CONNECTED ;
3702  }
3703  return pReplicaGroup->stopMaintenanceMode ( options ) ;
3704  }
3705  } ;
3706 
3707  class DLLEXPORT _sdbCollectionSpace
3708  {
3709  private :
3710  _sdbCollectionSpace ( const _sdbCollectionSpace& other ) ;
3711  _sdbCollectionSpace& operator=( const _sdbCollectionSpace& ) ;
3712  public :
3713  _sdbCollectionSpace () {}
3714  virtual ~_sdbCollectionSpace () {}
3715  // get a collection object
3716  virtual INT32 getCollection ( const CHAR *pCollectionName,
3717  _sdbCollection **collection,
3718  BOOLEAN checkExist = TRUE ) = 0 ;
3719 
3720  virtual INT32 getCollection ( const CHAR *pCollectionName,
3721  sdbCollection &collection,
3722  BOOLEAN checkExist = TRUE ) = 0 ;
3723 
3724  // create a new collection object with options
3725  virtual INT32 createCollection ( const CHAR *pCollection,
3726  const bson::BSONObj &options,
3727  _sdbCollection **collection ) = 0 ;
3728 
3729  virtual INT32 createCollection ( const CHAR *pCollection,
3730  const bson::BSONObj &options,
3731  sdbCollection &collection ) = 0 ;
3732 
3733  // create a new collection object
3734  virtual INT32 createCollection ( const CHAR *pCollection,
3735  _sdbCollection **collection ) = 0 ;
3736 
3737  virtual INT32 createCollection ( const CHAR *pCollection,
3738  sdbCollection &collection ) = 0 ;
3739 
3740  // drop an existing collection with options
3741  virtual INT32 dropCollection( const CHAR *pCollection,
3742  const bson::BSONObj &options ) = 0 ;
3743 
3744  virtual INT32 listCollections ( _sdbCursor **cursor ) = 0 ;
3745 
3746  virtual INT32 listCollections ( sdbCursor &cursor ) = 0 ;
3747 
3748  // create a collection space with current collection space name
3749  virtual INT32 create () = 0 ;
3750  // drop a collection space with current collection space name
3751  virtual INT32 drop () = 0 ;
3752 
3753  // get the collectonSpace's name
3754  virtual const CHAR *getCSName () = 0 ;
3755 
3756  // rename collection
3757  virtual INT32 renameCollection( const CHAR* oldName, const CHAR* newName,
3758  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
3759 
3760  virtual INT32 alterCollectionSpace ( const bson::BSONObj & options ) = 0 ;
3761 
3762  virtual INT32 setDomain ( const bson::BSONObj & options ) = 0 ;
3763 
3764  virtual INT32 getDomainName ( CHAR *result, INT32 resultLen ) = 0 ;
3765 
3766  virtual INT32 removeDomain () = 0 ;
3767 
3768  virtual INT32 enableCapped () = 0 ;
3769 
3770  virtual INT32 disableCapped () = 0 ;
3771 
3772  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
3773  } ;
3777  class DLLEXPORT sdbCollectionSpace
3778  {
3779  private :
3784  sdbCollectionSpace ( const sdbCollectionSpace& other ) ;
3785 
3791  sdbCollectionSpace& operator=( const sdbCollectionSpace& ) ;
3792  public :
3799  _sdbCollectionSpace *pCollectionSpace ;
3800 
3805  {
3806  pCollectionSpace = NULL ;
3807  }
3808 
3813  {
3814  if ( pCollectionSpace )
3815  {
3816  delete pCollectionSpace ;
3817  }
3818  }
3819 
3820  INT32 getCollection ( const CHAR *pCollectionName,
3821  _sdbCollection **collection,
3822  BOOLEAN checkExist = TRUE )
3823  {
3824  if ( !pCollectionSpace )
3825  {
3826  return SDB_NOT_CONNECTED ;
3827  }
3828  return pCollectionSpace->getCollection ( pCollectionName,
3829  collection, checkExist ) ;
3830  }
3831 
3842  INT32 getCollection ( const CHAR *pCollectionName,
3843  sdbCollection &collection,
3844  BOOLEAN checkExist = TRUE )
3845  {
3846  if ( !pCollectionSpace )
3847  {
3848  return SDB_NOT_CONNECTED ;
3849  }
3850  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3851  return pCollectionSpace->getCollection ( pCollectionName,
3852  collection,
3853  checkExist ) ;
3854  }
3855 
3856  INT32 createCollection ( const CHAR *pCollection,
3857  const bson::BSONObj &options,
3858  _sdbCollection **collection )
3859  {
3860  if ( !pCollectionSpace )
3861  {
3862  return SDB_NOT_CONNECTED ;
3863  }
3864  return pCollectionSpace->createCollection ( pCollection,
3865  options,
3866  collection ) ;
3867  }
3868 
3906  INT32 createCollection ( const CHAR *pCollection,
3907  const bson::BSONObj &options,
3908  sdbCollection &collection )
3909  {
3910  if ( !pCollectionSpace )
3911  {
3912  return SDB_NOT_CONNECTED ;
3913  }
3914  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3915  return pCollectionSpace->createCollection ( pCollection,
3916  options,
3917  collection ) ;
3918  }
3919 
3920  INT32 createCollection ( const CHAR *pCollection,
3921  _sdbCollection **collection )
3922  {
3923  if ( !pCollectionSpace )
3924  {
3925  return SDB_NOT_CONNECTED ;
3926  }
3927  return pCollectionSpace->createCollection ( pCollection,
3928  collection ) ;
3929  }
3930 
3940  INT32 createCollection ( const CHAR *pCollection,
3941  sdbCollection &collection )
3942  {
3943  if ( !pCollectionSpace )
3944  {
3945  return SDB_NOT_CONNECTED ;
3946  }
3947  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3948  return pCollectionSpace->createCollection ( pCollection,
3949  collection ) ;
3950  }
3951 
3961  INT32 dropCollection( const CHAR *pCollection,
3962  const bson::BSONObj &options = _sdbStaticObject )
3963  {
3964  if ( !pCollectionSpace )
3965  {
3966  return SDB_NOT_CONNECTED ;
3967  }
3968  return pCollectionSpace->dropCollection( pCollection, options ) ;
3969  }
3970 
3977  INT32 listCollections ( _sdbCursor **cursor )
3978  {
3979  if ( !pCollectionSpace )
3980  {
3981  return SDB_NOT_CONNECTED ;
3982  }
3983  return pCollectionSpace->listCollections( cursor ) ;
3984  }
3985 
3992  INT32 listCollections ( sdbCursor &cursor )
3993  {
3994  if ( !pCollectionSpace )
3995  {
3996  return SDB_NOT_CONNECTED ;
3997  }
3998  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
3999  return pCollectionSpace->listCollections( cursor ) ;
4000  }
4001 
4008  INT32 create ()
4009  {
4010  if ( !pCollectionSpace )
4011  {
4012  return SDB_NOT_CONNECTED ;
4013  }
4014  return pCollectionSpace->create () ;
4015  }
4016 
4023  INT32 drop ()
4024  {
4025  if ( !pCollectionSpace )
4026  {
4027  return SDB_NOT_CONNECTED ;
4028  }
4029  return pCollectionSpace->drop () ;
4030  }
4031 
4036  const CHAR *getCSName ()
4037  {
4038  if ( !pCollectionSpace )
4039  {
4040  return NULL ;
4041  }
4042  return pCollectionSpace->getCSName () ;
4043  }
4044 
4055  INT32 renameCollection( const CHAR* oldName, const CHAR* newName,
4056  const bson::BSONObj &options = _sdbStaticObject )
4057  {
4058  if( !pCollectionSpace )
4059  {
4060  return SDB_NOT_CONNECTED ;
4061  }
4062  return pCollectionSpace->renameCollection( oldName, newName, options ) ;
4063  }
4064 
4076  INT32 alterCollectionSpace ( const bson::BSONObj & options )
4077  {
4078  if ( NULL == pCollectionSpace )
4079  {
4080  return SDB_NOT_CONNECTED ;
4081  }
4082  return pCollectionSpace->alterCollectionSpace( options ) ;
4083  }
4084 
4094  INT32 setDomain ( const bson::BSONObj & options )
4095  {
4096  if ( NULL == pCollectionSpace )
4097  {
4098  return SDB_NOT_CONNECTED ;
4099  }
4100  return pCollectionSpace->setDomain( options ) ;
4101  }
4102 
4110  INT32 getDomainName ( CHAR *result, INT32 resultLen )
4111  {
4112  if ( !pCollectionSpace )
4113  {
4114  return SDB_NOT_CONNECTED ;
4115  }
4116  return pCollectionSpace->getDomainName( result, resultLen ) ;
4117  }
4118 
4124  INT32 removeDomain ()
4125  {
4126  if ( NULL == pCollectionSpace )
4127  {
4128  return SDB_NOT_CONNECTED ;
4129  }
4130  return pCollectionSpace->removeDomain() ;
4131  }
4132 
4138  INT32 enableCapped ()
4139  {
4140  if ( NULL == pCollectionSpace )
4141  {
4142  return SDB_NOT_CONNECTED ;
4143  }
4144  return pCollectionSpace->enableCapped() ;
4145  }
4146 
4152  INT32 disableCapped ()
4153  {
4154  if ( NULL == pCollectionSpace )
4155  {
4156  return SDB_NOT_CONNECTED ;
4157  }
4158  return pCollectionSpace->disableCapped() ;
4159  }
4160 
4172  INT32 setAttributes ( const bson::BSONObj & options )
4173  {
4174  if ( NULL == pCollectionSpace )
4175  {
4176  return SDB_NOT_CONNECTED ;
4177  }
4178  return pCollectionSpace->setAttributes( options ) ;
4179  }
4180  } ;
4181 
4182  class DLLEXPORT _sdbDomain
4183  {
4184  private :
4185  _sdbDomain ( const _sdbDomain& other ) ; // non construction-copyable
4186  _sdbDomain& operator= ( const _sdbDomain& ) ; // non copyable
4187  public :
4188  _sdbDomain () {}
4189  virtual ~_sdbDomain () {}
4190 
4191  virtual const CHAR* getName () = 0 ;
4192 
4193  virtual INT32 alterDomain ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4194 
4195  virtual INT32 listCollectionSpacesInDomain ( _sdbCursor **cursor ) = 0 ;
4196 
4197  virtual INT32 listCollectionSpacesInDomain ( sdbCursor &cursor ) = 0 ;
4198 
4199  virtual INT32 listCollectionsInDomain ( _sdbCursor **cursor ) = 0 ;
4200 
4201  virtual INT32 listCollectionsInDomain ( sdbCursor &cursor ) = 0 ;
4202 
4203  virtual INT32 listReplicaGroupInDomain( _sdbCursor **cursor ) = 0 ;
4204 
4205  virtual INT32 listReplicaGroupInDomain( sdbCursor &cursor ) = 0 ;
4206 
4207  virtual INT32 addGroups ( const bson::BSONObj & options ) = 0 ;
4208 
4209  virtual INT32 setGroups ( const bson::BSONObj & options ) = 0 ;
4210 
4211  virtual INT32 setActiveLocation ( const CHAR *pActiveLocation ) = 0 ;
4212 
4213  virtual INT32 setLocation ( const CHAR * pHostName, const CHAR * pLocation ) = 0 ;
4214 
4215  virtual INT32 removeGroups ( const bson::BSONObj & options ) = 0 ;
4216 
4217  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
4218  } ;
4219 
4223  class DLLEXPORT sdbDomain
4224  {
4225  private :
4226  sdbDomain ( const sdbDomain& ) ; // non construction-copyable
4227  sdbDomain& operator= ( const sdbDomain& ) ; // non copyable
4228  public :
4229 
4236  _sdbDomain *pDomain ;
4237 
4241  sdbDomain() { pDomain = NULL ; }
4242 
4247  {
4248  if ( pDomain )
4249  {
4250  delete pDomain ;
4251  }
4252  }
4253 
4258  const CHAR *getName ()
4259  {
4260  if ( !pDomain )
4261  {
4262  return NULL ;
4263  }
4264  return pDomain->getName() ;
4265  }
4266 
4284  INT32 alterDomain ( const bson::BSONObj &options )
4285  {
4286  if ( !pDomain )
4287  {
4288  return SDB_NOT_CONNECTED ;
4289  }
4290  return pDomain->alterDomain ( options ) ;
4291  }
4292 
4303  INT32 addGroups ( const bson::BSONObj & options )
4304  {
4305  if ( NULL == pDomain )
4306  {
4307  return SDB_NOT_CONNECTED ;
4308  }
4309  return pDomain->addGroups( options ) ;
4310  }
4311 
4324  INT32 setGroups ( const bson::BSONObj & options )
4325  {
4326  if ( NULL == pDomain )
4327  {
4328  return SDB_NOT_CONNECTED ;
4329  }
4330  return pDomain->setGroups( options ) ;
4331  }
4332 
4343  INT32 setActiveLocation ( const CHAR *pActiveLocation )
4344  {
4345  if ( NULL == pDomain )
4346  {
4347  return SDB_NOT_CONNECTED ;
4348  }
4349  return pDomain->setActiveLocation( pActiveLocation ) ;
4350  }
4351 
4364  INT32 setLocation ( const CHAR * pHostName, const CHAR * pLocation )
4365  {
4366  if ( NULL == pDomain )
4367  {
4368  return SDB_NOT_CONNECTED ;
4369  }
4370  return pDomain->setLocation( pHostName, pLocation ) ;
4371  }
4372 
4373 
4385  INT32 removeGroups ( const bson::BSONObj & options )
4386  {
4387  if ( NULL == pDomain )
4388  {
4389  return SDB_NOT_CONNECTED ;
4390  }
4391  return pDomain->removeGroups( options ) ;
4392  }
4393 
4411  INT32 setAttributes ( const bson::BSONObj &options )
4412  {
4413  if ( !pDomain )
4414  {
4415  return SDB_NOT_CONNECTED ;
4416  }
4417  return pDomain->setAttributes( options ) ;
4418  }
4419 
4427  INT32 listCollectionSpacesInDomain ( sdbCursor &cursor )
4428  {
4429  if ( !pDomain )
4430  {
4431  return SDB_NOT_CONNECTED ;
4432  }
4433  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4434  return pDomain->listCollectionSpacesInDomain ( cursor ) ;
4435  }
4436 
4437  INT32 listCollectionSpacesInDomain ( _sdbCursor **cursor )
4438  {
4439  if ( !pDomain )
4440  {
4441  return SDB_NOT_CONNECTED ;
4442  }
4443  return pDomain->listCollectionSpacesInDomain ( cursor ) ;
4444  }
4445 
4453  INT32 listCollectionsInDomain ( sdbCursor &cursor )
4454  {
4455  if ( !pDomain )
4456  {
4457  return SDB_NOT_CONNECTED ;
4458  }
4459  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4460  return pDomain->listCollectionsInDomain ( cursor ) ;
4461  }
4462 
4470  INT32 listCollectionsInDomain ( _sdbCursor **cursor )
4471  {
4472  if ( !pDomain )
4473  {
4474  return SDB_NOT_CONNECTED ;
4475  }
4476  return pDomain->listCollectionsInDomain ( cursor ) ;
4477  }
4478 
4479  INT32 listReplicaGroupInDomain( _sdbCursor **cursor )
4480  {
4481  if ( !pDomain )
4482  {
4483  return SDB_NOT_CONNECTED ;
4484  }
4485  return pDomain->listReplicaGroupInDomain( cursor ) ;
4486  }
4487 
4494  INT32 listReplicaGroupInDomain( sdbCursor &cursor )
4495  {
4496  if ( !pDomain )
4497  {
4498  return SDB_NOT_CONNECTED ;
4499  }
4500  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4501  return pDomain->listReplicaGroupInDomain( cursor ) ;
4502  }
4503  };
4504 
4505  class DLLEXPORT _sdbDataCenter
4506  {
4507  private :
4508  _sdbDataCenter ( const _sdbDataCenter& other ) ; // non construction-copyable
4509  _sdbDataCenter& operator= ( const _sdbDataCenter& ) ; // non copyable
4510 
4511  public :
4512  _sdbDataCenter () {}
4513  virtual ~_sdbDataCenter () {}
4514 
4515  public :
4516  virtual const CHAR *getName () = 0 ;
4517  virtual INT32 getDetail( bson::BSONObj &retInfo ) = 0 ;
4518  virtual INT32 activateDC() = 0 ;
4519  virtual INT32 deactivateDC() = 0 ;
4520  virtual INT32 enableReadOnly( BOOLEAN isReadOnly ) = 0 ;
4522  virtual INT32 setActiveLocation ( const CHAR *pActiveLocation,
4523  bson::BSONObj &result,
4524  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4525  virtual INT32 setLocation ( const CHAR * pHostName, const CHAR * pLocation,
4526  bson::BSONObj &result,
4527  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4528  virtual INT32 startMaintenanceMode( const bson::BSONObj &options, bson::BSONObj &result ) = 0 ;
4529  virtual INT32 stopMaintenanceMode( const bson::BSONObj &options, bson::BSONObj &result ) = 0 ;
4530  virtual INT32 startCriticalMode( const bson::BSONObj &options, bson::BSONObj &result ) = 0 ;
4531  virtual INT32 stopCriticalMode( const bson::BSONObj &options, bson::BSONObj &result ) = 0 ;
4532  } ;
4533 
4534  /* \class sdbDataCenter
4535  \brief Database operation interfaces of data center.
4536  */
4537  class DLLEXPORT sdbDataCenter
4538  {
4539  private :
4540  sdbDataCenter ( const sdbDataCenter& ) ; // non construction-copyable
4541  sdbDataCenter& operator= ( const sdbDataCenter& ) ; // non copyable
4542 
4543  public :
4544 
4551  _sdbDataCenter *pDC ;
4552 
4556  sdbDataCenter() { pDC = NULL ; }
4557 
4561  ~sdbDataCenter()
4562  {
4563  if ( pDC )
4564  {
4565  delete pDC ;
4566  }
4567  }
4568 
4569 
4570  public :
4571 
4576  const CHAR *getName ()
4577  {
4578  if ( NULL == pDC )
4579  {
4580  return NULL ;
4581  }
4582  return pDC->getName() ;
4583  }
4584 
4591  INT32 getDetail( bson::BSONObj &retInfo )
4592  {
4593  if ( NULL == pDC )
4594  {
4595  return SDB_NOT_CONNECTED ;
4596  }
4597  return pDC->getDetail( retInfo ) ;
4598  }
4599 
4605  INT32 activateDC()
4606  {
4607  if ( NULL == pDC )
4608  {
4609  return SDB_NOT_CONNECTED ;
4610  }
4611  return pDC->activateDC() ;
4612  }
4613 
4619  INT32 deactivateDC()
4620  {
4621  if ( NULL == pDC )
4622  {
4623  return SDB_NOT_CONNECTED ;
4624  }
4625  return pDC->deactivateDC() ;
4626  }
4627 
4634  INT32 enableReadOnly( BOOLEAN isReadOnly )
4635  {
4636  if ( NULL == pDC )
4637  {
4638  return SDB_NOT_CONNECTED ;
4639  }
4640  return pDC->enableReadOnly( isReadOnly ) ;
4641  }
4642 
4658  INT32 setActiveLocation ( const CHAR *pActiveLocation, bson::BSONObj &result,
4659  const bson::BSONObj &options = _sdbStaticObject )
4660  {
4661  if ( NULL == pDC )
4662  {
4663  return SDB_NOT_CONNECTED ;
4664  }
4665  return pDC->setActiveLocation( pActiveLocation, result, options ) ;
4666  }
4667 
4686  INT32 setLocation ( const CHAR * pHostName, const CHAR * pLocation,
4687  bson::BSONObj &result,
4688  const bson::BSONObj &options = _sdbStaticObject )
4689  {
4690  if ( NULL == pDC )
4691  {
4692  return SDB_NOT_CONNECTED ;
4693  }
4694  return pDC->setLocation( pHostName, pLocation, result, options ) ;
4695  }
4696 
4710  INT32 startMaintenanceMode( const bson::BSONObj &options, bson::BSONObj &result )
4711  {
4712  if ( !pDC )
4713  {
4714  return SDB_NOT_CONNECTED ;
4715  }
4716  return pDC->startMaintenanceMode( options, result ) ;
4717  }
4718 
4730  INT32 stopMaintenanceMode( const bson::BSONObj &options, bson::BSONObj &result )
4731  {
4732  if ( !pDC )
4733  {
4734  return SDB_NOT_CONNECTED ;
4735  }
4736  return pDC->stopMaintenanceMode ( options, result ) ;
4737  }
4738 
4752  INT32 startCriticalMode( const bson::BSONObj &options, bson::BSONObj &result )
4753  {
4754  if ( !pDC )
4755  {
4756  return SDB_NOT_CONNECTED ;
4757  }
4758  return pDC->startCriticalMode( options, result ) ;
4759  }
4760 
4768  INT32 stopCriticalMode( const bson::BSONObj &options, bson::BSONObj &result )
4769  {
4770  if ( !pDC )
4771  {
4772  return SDB_NOT_CONNECTED ;
4773  }
4774  return pDC->stopCriticalMode ( options, result ) ;
4775  }
4776 
4777  };
4778 
4779  class DLLEXPORT _sdbRecycleBin
4780  {
4781  private :
4782  _sdbRecycleBin ( const _sdbRecycleBin& other ) ; // non construction-copyable
4783  _sdbRecycleBin& operator= ( const _sdbRecycleBin& ) ; // non copyable
4784 
4785  public :
4786  _sdbRecycleBin () {}
4787  virtual ~_sdbRecycleBin () {}
4788 
4789  public :
4790  virtual INT32 getDetail( bson::BSONObj &retInfo ) = 0 ;
4791  virtual INT32 enable() = 0 ;
4792  virtual INT32 disable() = 0 ;
4793  virtual INT32 setAttributes( const bson::BSONObj &options ) = 0 ;
4794  virtual INT32 alter( const bson::BSONObj &options ) = 0 ;
4795  virtual INT32 returnItem( const CHAR *recycleName,
4796  const bson::BSONObj &options = _sdbStaticObject,
4797  bson::BSONObj *result = NULL ) = 0 ;
4798  virtual INT32 returnItemToName( const CHAR *recycleName,
4799  const CHAR *returnName,
4800  const bson::BSONObj &options = _sdbStaticObject,
4801  bson::BSONObj *result = NULL ) = 0 ;
4802  virtual INT32 dropItem( const CHAR *recycleName,
4803  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4804  virtual INT32 dropAll( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4805  virtual INT32 list( _sdbCursor **cursor,
4806  const bson::BSONObj &condition = _sdbStaticObject,
4807  const bson::BSONObj &selector = _sdbStaticObject,
4808  const bson::BSONObj &orderBy = _sdbStaticObject,
4809  const bson::BSONObj &hint = _sdbStaticObject,
4810  INT64 numToSkip = 0,
4811  INT64 numToReturn = -1 ) = 0 ;
4812  virtual INT32 list( sdbCursor &cursor,
4813  const bson::BSONObj &condition = _sdbStaticObject,
4814  const bson::BSONObj &selector = _sdbStaticObject,
4815  const bson::BSONObj &orderBy = _sdbStaticObject,
4816  const bson::BSONObj &hint = _sdbStaticObject,
4817  INT64 numToSkip = 0,
4818  INT64 numToReturn = -1 ) = 0 ;
4819  virtual INT32 snapshot( _sdbCursor **cursor,
4820  const bson::BSONObj &condition = _sdbStaticObject,
4821  const bson::BSONObj &selector = _sdbStaticObject,
4822  const bson::BSONObj &orderBy = _sdbStaticObject,
4823  const bson::BSONObj &hint = _sdbStaticObject,
4824  INT64 numToSkip = 0,
4825  INT64 numToReturn = -1 ) = 0 ;
4826  virtual INT32 snapshot( sdbCursor &cursor,
4827  const bson::BSONObj &condition = _sdbStaticObject,
4828  const bson::BSONObj &selector = _sdbStaticObject,
4829  const bson::BSONObj &orderBy = _sdbStaticObject,
4830  const bson::BSONObj &hint = _sdbStaticObject,
4831  INT64 numToSkip = 0,
4832  INT64 numToReturn = -1 ) = 0 ;
4833  virtual INT32 getCount( INT64 &count,
4834  const bson::BSONObj &condition = _sdbStaticObject ) = 0 ;
4835  } ;
4836 
4837  /* \class sdbRecycleBin
4838  \brief Database operation interfaces of recycle bin.
4839  */
4840  class DLLEXPORT sdbRecycleBin
4841  {
4842  private :
4843  sdbRecycleBin( const sdbRecycleBin & ) ; // non construction-copyable
4844  sdbRecycleBin &operator =( const sdbRecycleBin & ) ; // non copyable
4845 
4846  public :
4847 
4854  _sdbRecycleBin *pRecycleBin ;
4855 
4859  sdbRecycleBin() { pRecycleBin = NULL ; }
4860 
4864  ~sdbRecycleBin()
4865  {
4866  if ( pRecycleBin )
4867  {
4868  delete pRecycleBin ;
4869  }
4870  }
4871 
4872  public :
4873 
4880  INT32 getDetail( bson::BSONObj &retInfo )
4881  {
4882  if ( NULL == pRecycleBin )
4883  {
4884  return SDB_NOT_CONNECTED ;
4885  }
4886  return pRecycleBin->getDetail( retInfo ) ;
4887  }
4888 
4894  INT32 enable()
4895  {
4896  if ( NULL == pRecycleBin )
4897  {
4898  return SDB_NOT_CONNECTED ;
4899  }
4900  return pRecycleBin->enable() ;
4901  }
4902 
4908  INT32 disable()
4909  {
4910  if ( NULL == pRecycleBin )
4911  {
4912  return SDB_NOT_CONNECTED ;
4913  }
4914  return pRecycleBin->disable() ;
4915  }
4916 
4930  INT32 setAttributes( const bson::BSONObj &options )
4931  {
4932  if ( NULL == pRecycleBin )
4933  {
4934  return SDB_NOT_CONNECTED ;
4935  }
4936  return pRecycleBin->setAttributes( options ) ;
4937  }
4938 
4952  INT32 alter( const bson::BSONObj &options )
4953  {
4954  if ( NULL == pRecycleBin )
4955  {
4956  return SDB_NOT_CONNECTED ;
4957  }
4958  return pRecycleBin->alter( options ) ;
4959  }
4960 
4971  INT32 returnItem( const CHAR *recycleName,
4972  const bson::BSONObj &options = _sdbStaticObject,
4973  bson::BSONObj *result = NULL )
4974  {
4975  if ( NULL == pRecycleBin )
4976  {
4977  return SDB_NOT_CONNECTED ;
4978  }
4979  return pRecycleBin->returnItem( recycleName, options, result ) ;
4980  }
4981 
4994  INT32 returnItemToName( const CHAR *recycleName,
4995  const CHAR *returnName,
4996  const bson::BSONObj &options = _sdbStaticObject,
4997  bson::BSONObj *result = NULL )
4998  {
4999  if ( NULL == pRecycleBin )
5000  {
5001  return SDB_NOT_CONNECTED ;
5002  }
5003  return pRecycleBin->returnItemToName( recycleName,
5004  returnName,
5005  options,
5006  result ) ;
5007  }
5008 
5016  INT32 dropItem( const CHAR *recycleName,
5017  const bson::BSONObj &options = _sdbStaticObject )
5018  {
5019  if ( NULL == pRecycleBin )
5020  {
5021  return SDB_NOT_CONNECTED ;
5022  }
5023  return pRecycleBin->dropItem( recycleName, options ) ;
5024  }
5025 
5032  INT32 dropAll( const bson::BSONObj &options = _sdbStaticObject )
5033  {
5034  if ( NULL == pRecycleBin )
5035  {
5036  return SDB_NOT_CONNECTED ;
5037  }
5038  return pRecycleBin->dropAll( options ) ;
5039  }
5040 
5060  INT32 list( _sdbCursor **cursor,
5061  const bson::BSONObj &condition = _sdbStaticObject,
5062  const bson::BSONObj &selector = _sdbStaticObject,
5063  const bson::BSONObj &orderBy = _sdbStaticObject,
5064  const bson::BSONObj &hint = _sdbStaticObject,
5065  INT64 numToSkip = 0,
5066  INT64 numToReturn = -1 )
5067  {
5068  if ( NULL == pRecycleBin )
5069  {
5070  return SDB_NOT_CONNECTED ;
5071  }
5072  return pRecycleBin->list( cursor,
5073  condition,
5074  selector,
5075  orderBy,
5076  hint,
5077  numToSkip,
5078  numToReturn ) ;
5079  }
5080 
5100  INT32 list( sdbCursor &cursor,
5101  const bson::BSONObj &condition = _sdbStaticObject,
5102  const bson::BSONObj &selector = _sdbStaticObject,
5103  const bson::BSONObj &orderBy = _sdbStaticObject,
5104  const bson::BSONObj &hint = _sdbStaticObject,
5105  INT64 numToSkip = 0,
5106  INT64 numToReturn = -1 )
5107  {
5108  if ( NULL == pRecycleBin )
5109  {
5110  return SDB_NOT_CONNECTED ;
5111  }
5112  return pRecycleBin->list( cursor,
5113  condition,
5114  selector,
5115  orderBy,
5116  hint,
5117  numToSkip,
5118  numToReturn ) ;
5119  }
5120 
5140  INT32 snapshot( _sdbCursor **cursor,
5141  const bson::BSONObj &condition = _sdbStaticObject,
5142  const bson::BSONObj &selector = _sdbStaticObject,
5143  const bson::BSONObj &orderBy = _sdbStaticObject,
5144  const bson::BSONObj &hint = _sdbStaticObject,
5145  INT64 numToSkip = 0,
5146  INT64 numToReturn = -1 )
5147  {
5148  if ( NULL == pRecycleBin )
5149  {
5150  return SDB_NOT_CONNECTED ;
5151  }
5152  return pRecycleBin->snapshot( cursor,
5153  condition,
5154  selector,
5155  orderBy,
5156  hint,
5157  numToSkip,
5158  numToReturn ) ;
5159  }
5160 
5180  INT32 snapshot( sdbCursor &cursor,
5181  const bson::BSONObj &condition = _sdbStaticObject,
5182  const bson::BSONObj &selector = _sdbStaticObject,
5183  const bson::BSONObj &orderBy = _sdbStaticObject,
5184  const bson::BSONObj &hint = _sdbStaticObject,
5185  INT64 numToSkip = 0,
5186  INT64 numToReturn = -1 )
5187  {
5188  if ( NULL == pRecycleBin )
5189  {
5190  return SDB_NOT_CONNECTED ;
5191  }
5192  return pRecycleBin->snapshot( cursor,
5193  condition,
5194  selector,
5195  orderBy,
5196  hint,
5197  numToSkip,
5198  numToReturn ) ;
5199  }
5200 
5209  INT32 getCount( INT64 &count,
5210  const bson::BSONObj &condition = _sdbStaticObject )
5211  {
5212  if ( NULL == pRecycleBin )
5213  {
5214  return SDB_NOT_CONNECTED ;
5215  }
5216  return pRecycleBin->getCount( count, condition ) ;
5217  }
5218  } ;
5219 
5220  class DLLEXPORT _sdbLob
5221  {
5222  private :
5223  _sdbLob ( const _sdbLob& other ) ; // non construction-copyable
5224  _sdbLob& operator= ( const _sdbLob& ) ; // non copyable
5225 
5226  public :
5227  _sdbLob () {}
5228 
5229  virtual ~_sdbLob () {}
5230 
5231  virtual INT32 close () = 0 ;
5232 
5233  virtual INT32 read ( UINT32 len, CHAR *buf, UINT32 *read ) = 0 ;
5234 
5235  virtual INT32 write ( const CHAR *buf, UINT32 len ) = 0 ;
5236 
5237  virtual INT32 seek ( SINT64 size, SDB_LOB_SEEK whence ) = 0 ;
5238 
5239  virtual INT32 lock( INT64 offset, INT64 length ) = 0 ;
5240 
5241  virtual INT32 lockAndSeek( INT64 offset, INT64 length ) = 0 ;
5242 
5243  virtual INT32 isClosed( BOOLEAN &flag ) = 0 ;
5244 
5245  virtual INT32 getOid( bson::OID &oid ) = 0 ;
5246 
5247  virtual INT32 getSize( SINT64 *size ) = 0 ;
5248 
5249  virtual INT32 getCreateTime ( UINT64 *millis ) = 0 ;
5250 
5251  virtual BOOLEAN isClosed() = 0 ;
5252 
5253  virtual bson::OID getOid() = 0 ;
5254 
5255  virtual SINT64 getSize() = 0 ;
5256 
5257  virtual UINT64 getCreateTime () = 0 ;
5258 
5259  virtual UINT64 getModificationTime() = 0 ;
5260 
5261  virtual INT32 getPiecesInfoNum() = 0 ;
5262 
5263  virtual bson::BSONArray getPiecesInfo() = 0 ;
5264 
5265  virtual BOOLEAN isEof() = 0 ;
5266 
5267  virtual INT32 getRunTimeDetail( bson::BSONObj &detail,
5268  const bson::BSONObj &option = _sdbStaticObject ) = 0 ;
5269 
5270  } ;
5271 
5275  class DLLEXPORT sdbLob
5276  {
5277  private :
5278  sdbLob ( const sdbLob& ) ; // non construction-copyable
5279  sdbLob& operator= ( const sdbLob& ) ; // non copyable
5280 
5281  public :
5282 
5289  _sdbLob *pLob ;
5293  sdbLob() { pLob = NULL ; }
5294 
5299  {
5300  if ( pLob )
5301  {
5302  delete pLob ;
5303  }
5304  }
5305 
5311  INT32 close ()
5312  {
5313  if ( !pLob )
5314  {
5315  return SDB_OK ;
5316  }
5317  return pLob->close() ;
5318  }
5319 
5328  INT32 read ( UINT32 len, CHAR *buf, UINT32 *read )
5329  {
5330  if ( !pLob )
5331  {
5332  return SDB_NOT_CONNECTED ;
5333  }
5334  return pLob->read( len, buf, read ) ;
5335  }
5336 
5344  INT32 write ( const CHAR *buf, UINT32 len )
5345  {
5346  if ( !pLob )
5347  {
5348  return SDB_NOT_CONNECTED ;
5349  }
5350  return pLob->write( buf, len ) ;
5351  }
5352 
5360  INT32 seek ( SINT64 size, SDB_LOB_SEEK whence )
5361  {
5362  if ( !pLob )
5363  {
5364  return SDB_NOT_CONNECTED ;
5365  }
5366  return pLob->seek( size, whence ) ;
5367  }
5368 
5376  INT32 lock ( INT64 offset, INT64 length )
5377  {
5378  if ( !pLob )
5379  {
5380  return SDB_NOT_CONNECTED ;
5381  }
5382  return pLob->lock( offset, length ) ;
5383  }
5384 
5392  INT32 lockAndSeek ( INT64 offset, INT64 length )
5393  {
5394  if ( !pLob )
5395  {
5396  return SDB_NOT_CONNECTED ;
5397  }
5398  return pLob->lockAndSeek( offset, length ) ;
5399  }
5400 
5408  INT32 isClosed( BOOLEAN &flag )
5409  {
5410  if ( !pLob )
5411  {
5412  return SDB_NOT_CONNECTED ;
5413  }
5414  return pLob->isClosed ( flag ) ;
5415  }
5416 
5421  BOOLEAN isClosed()
5422  {
5423  if ( !pLob )
5424  {
5425  return TRUE ;
5426  }
5427  return pLob->isClosed () ;
5428  }
5429 
5437  INT32 getOid ( bson::OID &oid )
5438  {
5439  if ( !pLob )
5440  {
5441  return SDB_NOT_CONNECTED ;
5442  }
5443  return pLob->getOid( oid ) ;
5444  }
5445 
5450  bson::OID getOid ()
5451  {
5452  if ( !pLob )
5453  {
5454  return bson::OID();
5455  }
5456  return pLob->getOid() ;
5457  }
5458 
5466  INT32 getSize ( SINT64 *size )
5467  {
5468  if ( !pLob )
5469  {
5470  return SDB_NOT_CONNECTED ;
5471  }
5472  return pLob->getSize( size ) ;
5473  }
5474 
5479  SINT64 getSize ()
5480  {
5481  if ( !pLob )
5482  {
5483  return -1 ;
5484  }
5485  return pLob->getSize();
5486  }
5487 
5495  INT32 getCreateTime ( UINT64 *millis )
5496  {
5497  if ( !pLob )
5498  {
5499  return SDB_NOT_CONNECTED ;
5500  }
5501  return pLob->getCreateTime( millis ) ;
5502  }
5503 
5508  UINT64 getCreateTime ()
5509  {
5510  if ( !pLob )
5511  {
5512  return -1 ;
5513  }
5514  return pLob->getCreateTime() ;
5515  }
5516 
5521  UINT64 getModificationTime ()
5522  {
5523  if ( !pLob )
5524  {
5525  return -1 ;
5526  }
5527  return pLob->getModificationTime() ;
5528  }
5529 
5534  INT32 getPiecesInfoNum()
5535  {
5536  if ( !pLob )
5537  {
5538  return -1 ;
5539  }
5540  return pLob->getPiecesInfoNum() ;
5541  }
5542 
5547  bson::BSONArray getPiecesInfo()
5548  {
5549  if ( !pLob )
5550  {
5551  return bson::BSONArray() ;
5552  }
5553  return pLob->getPiecesInfo() ;
5554  }
5555 
5560  BOOLEAN isEof()
5561  {
5562  if ( !pLob )
5563  {
5564  return TRUE ;
5565  }
5566  return pLob->isEof() ;
5567  }
5568 
5574  INT32 getRunTimeDetail( bson::BSONObj &detail,
5575  const bson::BSONObj &option = _sdbStaticObject )
5576  {
5577  if ( !pLob )
5578  {
5579  return -1 ;
5580  }
5581  return pLob->getRunTimeDetail( detail, option ) ;
5582  }
5583 
5584  } ;
5585 
5586  class DLLEXPORT _sdbSequence
5587  {
5588  private :
5589  _sdbSequence ( const _sdbSequence& other ) ;
5590  _sdbSequence& operator=( const _sdbSequence& ) ;
5591  public :
5592  _sdbSequence () {}
5593  virtual ~_sdbSequence () {}
5594 
5595  virtual INT32 setAttributes ( const bson::BSONObj &options ) = 0 ;
5596 
5597  virtual INT32 getNextValue ( INT64 &value ) = 0 ;
5598 
5599  virtual INT32 getCurrentValue ( INT64 &value ) = 0 ;
5600 
5601  virtual INT32 setCurrentValue ( const INT64 value ) = 0 ;
5602 
5603  virtual INT32 fetch( const INT32 fetchNum,
5604  INT64 &nextValue,
5605  INT32 &returnNum,
5606  INT32 &Increment ) = 0 ;
5607 
5608  virtual INT32 restart( const INT64 startValue ) = 0 ;
5609  } ;
5610 
5614  class DLLEXPORT sdbSequence
5615  {
5616  private :
5621  sdbSequence ( const sdbSequence& other ) ;
5622 
5628  sdbSequence& operator=( const sdbSequence& ) ;
5629  public :
5636  _sdbSequence *pSequence ;
5637 
5642  {
5643  pSequence = NULL ;
5644  }
5645 
5650  {
5651  if ( pSequence )
5652  {
5653  delete pSequence ;
5654  }
5655  }
5656 
5673  INT32 setAttributes ( const bson::BSONObj & options )
5674  {
5675  if ( NULL == pSequence )
5676  {
5677  return SDB_NOT_CONNECTED ;
5678  }
5679  return pSequence->setAttributes( options ) ;
5680  }
5681 
5688  INT32 getNextValue( INT64 &value )
5689  {
5690  if ( NULL == pSequence )
5691  {
5692  return SDB_NOT_CONNECTED ;
5693  }
5694  return pSequence->getNextValue( value ) ;
5695  }
5696 
5703  INT32 getCurrentValue( INT64 &value )
5704  {
5705  if ( NULL == pSequence )
5706  {
5707  return SDB_NOT_CONNECTED ;
5708  }
5709  return pSequence->getCurrentValue( value ) ;
5710  }
5711 
5718  INT32 setCurrentValue( const INT64 value )
5719  {
5720  if ( NULL == pSequence )
5721  {
5722  return SDB_NOT_CONNECTED ;
5723  }
5724  return pSequence->setCurrentValue( value ) ;
5725  }
5726 
5737  INT32 fetch( const INT32 fetchNum, INT64 &nextValue,
5738  INT32 &returnNum, INT32 &increment )
5739  {
5740  if ( NULL == pSequence )
5741  {
5742  return SDB_NOT_CONNECTED ;
5743  }
5744  return pSequence->fetch( fetchNum, nextValue, returnNum, increment ) ;
5745  }
5746 
5753  INT32 restart( const INT64 startValue )
5754  {
5755  if ( NULL == pSequence )
5756  {
5757  return SDB_NOT_CONNECTED ;
5758  }
5759  return pSequence->restart( startValue ) ;
5760  }
5761  } ;
5762 
5763  class DLLEXPORT _sdbDataSource
5764  {
5765  private:
5766  _sdbDataSource( const _sdbDataSource& other ) ;
5767  _sdbDataSource& operator=( const _sdbDataSource& ) ;
5768  public:
5769  _sdbDataSource() {}
5770  virtual ~_sdbDataSource() {}
5771 
5772  virtual INT32 alterDataSource( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5773  virtual const CHAR *getName() = 0 ;
5774  } ;
5775 
5779  class DLLEXPORT sdbDataSource
5780  {
5781  private:
5782  sdbDataSource( const sdbDataSource& ) ;
5783  sdbDataSource& operator=(const sdbDataSource& ) ;
5784  public:
5785  _sdbDataSource *pDataSource ;
5786 
5787  sdbDataSource()
5788  {
5789  pDataSource = NULL ;
5790  }
5791 
5792  ~sdbDataSource()
5793  {
5794  if ( pDataSource )
5795  {
5796  delete pDataSource ;
5797  }
5798  }
5799 
5840  INT32 alterDataSource( const bson::BSONObj &options )
5841  {
5842  if ( !pDataSource )
5843  {
5844  return SDB_NOT_CONNECTED ;
5845  }
5846  return pDataSource->alterDataSource( options ) ;
5847  }
5848 
5853  const CHAR *getName()
5854  {
5855  if ( !pDataSource )
5856  {
5857  return NULL ;
5858  }
5859  return pDataSource->getName() ;
5860  }
5861  } ;
5862 
5863  class DLLEXPORT _sdb
5864  {
5865  private :
5866  _sdb ( const _sdb& other ) ; // non construction-copyable
5867  _sdb& operator=( const _sdb& ) ; // non copyable
5868  public :
5869  _sdb () {}
5870  virtual ~_sdb () {}
5871  virtual INT32 connect ( const CHAR *pHostName,
5872  UINT16 port
5873  ) = 0 ;
5874  virtual INT32 connect ( const CHAR *pHostName,
5875  UINT16 port,
5876  const CHAR *pUsrName,
5877  const CHAR *pPasswd ) = 0 ;
5878  virtual INT32 connect ( const CHAR *pHostName,
5879  const CHAR *pServiceName ) = 0 ;
5880  virtual INT32 connect ( const CHAR *pHostName,
5881  const CHAR *pServiceName,
5882  const CHAR *pUsrName,
5883  const CHAR *pPasswd ) = 0 ;
5884  virtual INT32 connect ( const CHAR **pConnAddrs,
5885  INT32 arrSize,
5886  const CHAR *pUsrName,
5887  const CHAR *pPasswd ) = 0 ;
5888  virtual INT32 connect ( const CHAR **pConnAddrs,
5889  INT32 arrSize,
5890  const CHAR *pUsrName,
5891  const CHAR *pToken,
5892  const CHAR *pCipherFile ) = 0 ;
5893 
5894  virtual void disconnect () = 0 ;
5895 
5896  virtual UINT64 getDbStartTime() = 0 ;
5897 
5898  virtual const CHAR *getAddress() = 0 ;
5899 
5900  virtual void getVersion( UINT8 &version, UINT8 &subVersion,
5901  UINT8 &fixVersion ) = 0 ;
5902 
5903  virtual INT32 createUsr( const CHAR *pUsrName,
5904  const CHAR *pPasswd,
5905  const bson::BSONObj &options = _sdbStaticObject
5906  ) = 0 ;
5907 
5908  virtual INT32 removeUsr( const CHAR *pUsrName,
5909  const CHAR *pPasswd ) = 0 ;
5910 
5911  virtual INT32 alterUsr( const CHAR *pUsrName,
5912  const CHAR *pAction,
5913  const bson::BSONObj &options ) = 0 ;
5914 
5915  virtual INT32 changeUsrPasswd( const CHAR *pUsrName,
5916  const CHAR *pOldPasswd,
5917  const CHAR *pNewPasswd ) = 0 ;
5918 
5919  virtual INT32 getSnapshot ( _sdbCursor **cursor,
5920  INT32 snapType,
5921  const bson::BSONObj &condition = _sdbStaticObject,
5922  const bson::BSONObj &selector = _sdbStaticObject,
5923  const bson::BSONObj &orderBy = _sdbStaticObject,
5924  const bson::BSONObj &hint = _sdbStaticObject,
5925  INT64 numToSkip = 0,
5926  INT64 numToReturn = -1
5927  ) = 0 ;
5928 
5929  virtual INT32 getSnapshot ( sdbCursor &cursor,
5930  INT32 snapType,
5931  const bson::BSONObj &condition = _sdbStaticObject,
5932  const bson::BSONObj &selector = _sdbStaticObject,
5933  const bson::BSONObj &orderBy = _sdbStaticObject,
5934  const bson::BSONObj &hint = _sdbStaticObject,
5935  INT64 numToSkip = 0,
5936  INT64 numToReturn = -1
5937  ) = 0 ;
5938 
5939  virtual INT32 resetSnapshot ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5940 
5941  virtual INT32 getList ( _sdbCursor **cursor,
5942  INT32 listType,
5943  const bson::BSONObj &condition = _sdbStaticObject,
5944  const bson::BSONObj &selector = _sdbStaticObject,
5945  const bson::BSONObj &orderBy = _sdbStaticObject,
5946  const bson::BSONObj &hint = _sdbStaticObject,
5947  INT64 numToSkip = 0,
5948  INT64 numToReturn = -1
5949  ) = 0 ;
5950  virtual INT32 getList ( sdbCursor &cursor,
5951  INT32 listType,
5952  const bson::BSONObj &condition = _sdbStaticObject,
5953  const bson::BSONObj &selector = _sdbStaticObject,
5954  const bson::BSONObj &orderBy = _sdbStaticObject,
5955  const bson::BSONObj &hint = _sdbStaticObject,
5956  INT64 numToSkip = 0,
5957  INT64 numToReturn = -1
5958  ) = 0 ;
5959 
5960  virtual INT32 getCollection ( const CHAR *pCollectionFullName,
5961  _sdbCollection **collection,
5962  BOOLEAN checkExist = TRUE
5963  ) = 0 ;
5964 
5965  virtual INT32 getCollection ( const CHAR *pCollectionFullName,
5966  sdbCollection &collection,
5967  BOOLEAN checkExist = TRUE
5968  ) = 0 ;
5969 
5970  virtual INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
5971  _sdbCollectionSpace **cs,
5972  BOOLEAN checkExist = TRUE
5973  ) = 0 ;
5974 
5975  virtual INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
5976  sdbCollectionSpace &cs,
5977  BOOLEAN checkExist = TRUE
5978  ) = 0 ;
5979 
5980  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5981  INT32 iPageSize,
5982  _sdbCollectionSpace **cs
5983  ) = 0 ;
5984 
5985  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5986  INT32 iPageSize,
5987  sdbCollectionSpace &cs
5988  ) = 0 ;
5989 
5990  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5991  const bson::BSONObj &options,
5992  _sdbCollectionSpace **cs
5993  ) = 0 ;
5994 
5995  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5996  const bson::BSONObj &options,
5997  sdbCollectionSpace &cs
5998  ) = 0 ;
5999 
6000  virtual INT32 dropCollectionSpace (
6001  const CHAR *pCollectionSpaceName,
6002  const bson::BSONObj &options = _sdbStaticObject
6003  ) = 0 ;
6004 
6005  virtual INT32 listCollectionSpaces ( _sdbCursor **result ) = 0 ;
6006 
6007  virtual INT32 listCollectionSpaces ( sdbCursor &result ) = 0 ;
6008 
6009  // list all collections in a given database
6010  virtual INT32 listCollections ( _sdbCursor **result ) = 0 ;
6011 
6012  virtual INT32 listCollections ( sdbCursor &result ) = 0 ;
6013 
6014  // list all the replica groups in the given database
6015  virtual INT32 listReplicaGroups ( _sdbCursor **result ) = 0 ;
6016 
6017  virtual INT32 listReplicaGroups ( sdbCursor &result ) = 0 ;
6018 
6019  virtual INT32 getReplicaGroup ( const CHAR *pName,
6020  _sdbReplicaGroup **result ) = 0 ;
6021 
6022  virtual INT32 getReplicaGroup ( const CHAR *pName,
6023  sdbReplicaGroup &result ) = 0 ;
6024 
6025  virtual INT32 getReplicaGroup ( INT32 id,
6026  _sdbReplicaGroup **result ) = 0 ;
6027 
6028  virtual INT32 getReplicaGroup ( INT32 id,
6029  sdbReplicaGroup &result ) = 0 ;
6030 
6031  virtual INT32 createReplicaGroup ( const CHAR *pName,
6032  _sdbReplicaGroup **replicaGroup ) = 0 ;
6033 
6034  virtual INT32 createReplicaGroup ( const CHAR *pName,
6035  sdbReplicaGroup &replicaGroup ) = 0 ;
6036 
6037  virtual INT32 removeReplicaGroup ( const CHAR *pName ) = 0 ;
6038 
6039  virtual INT32 createReplicaCataGroup ( const CHAR *pHostName,
6040  const CHAR *pServiceName,
6041  const CHAR *pDatabasePath,
6042  const bson::BSONObj &configure ) =0 ;
6043 
6044  virtual INT32 activateReplicaGroup ( const CHAR *pName,
6045  _sdbReplicaGroup **replicaGroup ) = 0 ;
6046  virtual INT32 activateReplicaGroup ( const CHAR *pName,
6047  sdbReplicaGroup &replicaGroup ) = 0 ;
6048 
6049  virtual INT32 execUpdate( const CHAR *sql,
6050  bson::BSONObj *pResult = NULL ) = 0 ;
6051 
6052  virtual INT32 exec( const CHAR *sql,
6053  _sdbCursor **result ) = 0 ;
6054 
6055  virtual INT32 exec( const CHAR *sql,
6056  sdbCursor &result ) = 0 ;
6057 
6058  virtual INT32 transactionBegin() = 0 ;
6059 
6060  virtual INT32 transactionCommit( const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
6061 
6062  virtual INT32 transactionRollback() = 0 ;
6063 
6064  virtual INT32 flushConfigure( const bson::BSONObj &options ) = 0 ;
6065  // stored procedure
6066  virtual INT32 crtJSProcedure ( const CHAR *code ) = 0 ;
6067  virtual INT32 rmProcedure( const CHAR *spName ) = 0 ;
6068  virtual INT32 listProcedures( _sdbCursor **cursor, const bson::BSONObj &condition ) = 0 ;
6069  virtual INT32 listProcedures( sdbCursor &cursor, const bson::BSONObj &condition ) = 0 ;
6070  virtual INT32 evalJS( const CHAR *code,
6071  SDB_SPD_RES_TYPE &type,
6072  _sdbCursor **cursor,
6073  bson::BSONObj &errmsg ) = 0 ;
6074  virtual INT32 evalJS( const CHAR *code,
6075  SDB_SPD_RES_TYPE &type,
6076  sdbCursor &cursor,
6077  bson::BSONObj &errmsg ) = 0 ;
6078 
6079  // bakup
6080  virtual INT32 backup ( const bson::BSONObj &options) = 0 ;
6081  virtual INT32 listBackup ( _sdbCursor **cursor,
6082  const bson::BSONObj &options,
6083  const bson::BSONObj &condition = _sdbStaticObject,
6084  const bson::BSONObj &selector = _sdbStaticObject,
6085  const bson::BSONObj &orderBy = _sdbStaticObject) = 0 ;
6086  virtual INT32 listBackup ( sdbCursor &cursor,
6087  const bson::BSONObj &options,
6088  const bson::BSONObj &condition = _sdbStaticObject,
6089  const bson::BSONObj &selector = _sdbStaticObject,
6090  const bson::BSONObj &orderBy = _sdbStaticObject) = 0 ;
6091  virtual INT32 removeBackup ( const bson::BSONObj &options ) = 0 ;
6092 
6093  // task
6094  virtual INT32 listTasks ( _sdbCursor **cursor,
6095  const bson::BSONObj &condition = _sdbStaticObject,
6096  const bson::BSONObj &selector = _sdbStaticObject,
6097  const bson::BSONObj &orderBy = _sdbStaticObject,
6098  const bson::BSONObj &hint = _sdbStaticObject) = 0 ;
6099 
6100 
6101  virtual INT32 listTasks ( sdbCursor &cursor,
6102  const bson::BSONObj &condition = _sdbStaticObject,
6103  const bson::BSONObj &selector = _sdbStaticObject,
6104  const bson::BSONObj &orderBy = _sdbStaticObject,
6105  const bson::BSONObj &hint = _sdbStaticObject) = 0 ;
6106 
6107  virtual INT32 waitTasks ( const SINT64 *taskIDs,
6108  SINT32 num ) = 0 ;
6109 
6110  virtual INT32 cancelTask ( SINT64 taskID,
6111  BOOLEAN isAsync ) = 0 ;
6112  // set session attribute
6113  virtual INT32 setSessionAttr ( const bson::BSONObj &options =
6114  _sdbStaticObject ) = 0 ;
6115  // get session attribute
6116  virtual INT32 getSessionAttr ( bson::BSONObj &result,
6117  BOOLEAN useCache = TRUE ) = 0 ;
6118 
6119  // close all cursor
6120  virtual INT32 closeAllCursors () = 0 ;
6121 
6122  // interrupt
6123  virtual INT32 interrupt() = 0 ;
6124  virtual INT32 interruptOperation() = 0 ;
6125 
6126  // connection is valid
6127  virtual INT32 isValid( BOOLEAN *result ) = 0 ;
6128  virtual BOOLEAN isValid() = 0 ;
6129 
6130  virtual BOOLEAN isClosed() = 0 ;
6131 
6132  // domain
6133  virtual INT32 createDomain ( const CHAR *pDomainName,
6134  const bson::BSONObj &options,
6135  _sdbDomain **domain ) = 0 ;
6136 
6137  virtual INT32 createDomain ( const CHAR *pDomainName,
6138  const bson::BSONObj &options,
6139  sdbDomain &domain ) = 0 ;
6140 
6141  virtual INT32 dropDomain ( const CHAR *pDomainName ) = 0 ;
6142 
6143  virtual INT32 getDomain ( const CHAR *pDomainName,
6144  _sdbDomain **domain ) = 0 ;
6145 
6146  virtual INT32 getDomain ( const CHAR *pDomainName,
6147  sdbDomain &domain ) = 0 ;
6148 
6149  virtual INT32 listDomains ( _sdbCursor **cursor,
6150  const bson::BSONObj &condition = _sdbStaticObject,
6151  const bson::BSONObj &selector = _sdbStaticObject,
6152  const bson::BSONObj &orderBy = _sdbStaticObject,
6153  const bson::BSONObj &hint = _sdbStaticObject
6154  ) = 0 ;
6155 
6156  virtual INT32 listDomains ( sdbCursor &cursor,
6157  const bson::BSONObj &condition = _sdbStaticObject,
6158  const bson::BSONObj &selector = _sdbStaticObject,
6159  const bson::BSONObj &orderBy = _sdbStaticObject,
6160  const bson::BSONObj &hint = _sdbStaticObject
6161  ) = 0 ;
6162  virtual INT32 getDC( _sdbDataCenter **dc ) = 0 ;
6163  virtual INT32 getDC( sdbDataCenter &dc ) = 0 ;
6164 
6165  virtual INT32 getRecycleBin( _sdbRecycleBin **recycleBin ) = 0 ;
6166  virtual INT32 getRecycleBin( sdbRecycleBin &recycleBin ) = 0 ;
6167 
6168  static _sdb *getObj ( BOOLEAN useSSL = FALSE ) ;
6169 
6170  // get last alive time
6171  virtual UINT64 getLastAliveTime() const = 0 ;
6172 
6173  virtual INT32 syncDB(
6174  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6175 
6176  virtual INT32 analyze(
6177  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6178 
6179  virtual INT32 forceSession(
6180  SINT64 sessionID,
6181  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6182 
6183  virtual INT32 forceStepUp(
6184  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6185 
6186  virtual INT32 invalidateCache(
6187  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6188 
6189  virtual INT32 reloadConfig(
6190  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6191 
6192  virtual INT32 updateConfig ( const bson::BSONObj &configs = _sdbStaticObject,
6193  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6194 
6195  virtual INT32 deleteConfig ( const bson::BSONObj &configs = _sdbStaticObject,
6196  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6197 
6198  virtual INT32 setPDLevel( INT32 level,
6199  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6200 
6201  virtual INT32 memTrim( const CHAR *maskStr = "",
6202  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6203 
6204  virtual INT32 msg( const CHAR* msg ) = 0 ;
6205 
6206  virtual INT32 loadCS( const CHAR* csName,
6207  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6208 
6209  virtual INT32 unloadCS( const CHAR* csName,
6210  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6211 
6212  virtual INT32 traceStart( UINT32 traceBufferSize,
6213  const CHAR* component = NULL,
6214  const CHAR* breakpoint = NULL,
6215  const vector<UINT32> &tidVec = _sdbStaticUINT32Vec ) = 0 ;
6216 
6217  virtual INT32 traceStart( UINT32 traceBufferSize,
6218  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6219 
6220  virtual INT32 traceStop( const CHAR* dumpFileName ) = 0 ;
6221 
6222  virtual INT32 traceResume() = 0 ;
6223 
6224  virtual INT32 traceStatus( _sdbCursor** cursor ) = 0 ;
6225 
6226  virtual INT32 traceStatus( sdbCursor& cursor ) = 0 ;
6227 
6228 
6229  virtual INT32 renameCollectionSpace( const CHAR* oldName,
6230  const CHAR* newName,
6231  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
6232 
6233  virtual INT32 getLastErrorObj( bson::BSONObj &result ) = 0 ;
6234  virtual void cleanLastErrorObj() = 0 ;
6235 
6236  virtual INT32 getLastResultObj( bson::BSONObj &result,
6237  BOOLEAN getOwned = FALSE ) const = 0 ;
6238 
6239  // create a new sequence object
6240  virtual INT32 createSequence( const CHAR *pSequenceName,
6241  const bson::BSONObj &options,
6242  _sdbSequence **sequence ) = 0 ;
6243 
6244  virtual INT32 createSequence( const CHAR *pSequenceName,
6245  const bson::BSONObj &options,
6246  sdbSequence &sequence ) = 0 ;
6247 
6248  virtual INT32 createSequence( const CHAR *pSequenceName,
6249  sdbSequence &sequence ) = 0 ;
6250 
6251  // get a sequence object
6252  virtual INT32 getSequence( const CHAR *pSequenceName,
6253  _sdbSequence **sequence ) = 0 ;
6254 
6255  virtual INT32 getSequence( const CHAR *pSequenceName,
6256  sdbSequence &sequence ) = 0 ;
6257 
6258  virtual INT32 renameSequence( const CHAR *pOldName,
6259  const CHAR *pNewName ) = 0 ;
6260 
6261  virtual INT32 dropSequence( const CHAR *pSequenceName ) = 0 ;
6262 
6263  virtual INT32 createDataSource( _sdbDataSource **dataSource,
6264  const CHAR *pDataSourceName,
6265  const CHAR *addresses,
6266  const CHAR *user = NULL,
6267  const CHAR *password = NULL,
6268  const CHAR *type = NULL,
6269  const bson::BSONObj *options = NULL
6270  ) = 0 ;
6271 
6272  virtual INT32 dropDataSource( const CHAR *pDataSourceName ) = 0 ;
6273 
6274  virtual INT32 getDataSource( const CHAR *pDataSourceName,
6275  _sdbDataSource **dataSource ) = 0 ;
6276 
6277  virtual INT32 listDataSources( _sdbCursor** cursor,
6278  const bson::BSONObj &condition = _sdbStaticObject,
6279  const bson::BSONObj &selector = _sdbStaticObject,
6280  const bson::BSONObj &orderBy = _sdbStaticObject,
6281  const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
6282 
6283  virtual INT32 createRole( const bson::BSONObj &role) = 0;
6284 
6285  virtual INT32 dropRole( const CHAR *pRoleName ) = 0;
6286 
6287  virtual INT32 getRole( const CHAR *pRoleName,
6288  const bson::BSONObj &options,
6289  bson::BSONObj &role ) = 0;
6290 
6291  virtual INT32 listRoles( _sdbCursor **result, const bson::BSONObj &options ) = 0;
6292 
6293  virtual INT32 updateRole( const CHAR *pRoleName,
6294  const bson::BSONObj &role ) = 0;
6295 
6296  virtual INT32 grantPrivilegesToRole( const CHAR *pRoleName,
6297  const bson::BSONObj &privileges ) = 0;
6298 
6299  virtual INT32 revokePrivilegesFromRole( const CHAR *pRoleName,
6300  const bson::BSONObj &privileges ) = 0;
6301 
6302  virtual INT32 grantRolesToRole( const CHAR *pRoleName,
6303  const bson::BSONObj &roles ) = 0;
6304 
6305  virtual INT32 revokeRolesFromRole( const CHAR *pRoleName,
6306  const bson::BSONObj &roles ) = 0;
6307 
6308  virtual INT32 grantRolesToUser( const CHAR *pUsrName,
6309  const bson::BSONObj &roles ) = 0;
6310 
6311  virtual INT32 revokeRolesFromUser( const CHAR *pUsrName,
6312  const bson::BSONObj &roles ) = 0;
6313 
6314  virtual INT32 getUser( const CHAR *pUserName,
6315  const bson::BSONObj &options,
6316  bson::BSONObj &user ) = 0;
6317 
6318  virtual INT32 invalidateUserCache( const CHAR *pUserName = NULL,
6319  const bson::BSONObj &options = _sdbStaticObject ) = 0;
6320 
6321  virtual INT32 invalidateFsCache( const bson::BSONObj &options = _sdbStaticObject,
6322  const CHAR *pExpiredTime = NULL ) = 0;
6323 
6324  virtual void enableClientQueryID() = 0 ;
6325 
6326  virtual void incQueryID() = 0 ;
6327 
6328  virtual UINT32 getQueryIDStr( CHAR *pStr, UINT32 strlen ) = 0 ;
6329  } ;
6332  typedef class _sdb _sdb ;
6336  class DLLEXPORT sdb
6337  {
6338  private:
6339  sdb ( const sdb& other ) ;
6340  sdb& operator=( const sdb& ) ;
6341  public :
6348  _sdb *pSDB ;
6349 
6354  sdb ( BOOLEAN useSSL = FALSE ) :
6355  pSDB ( _sdb::getObj( useSSL ) )
6356  {
6357  }
6358 
6362  ~sdb ()
6363  {
6364  if ( pSDB )
6365  {
6366  delete pSDB ;
6367  }
6368  }
6369 
6379  INT32 connect ( const CHAR *pHostName,
6380  UINT16 port
6381  )
6382  {
6383  if ( !pSDB )
6384  {
6385  return SDB_NOT_CONNECTED ;
6386  }
6387  return pSDB->connect ( pHostName, port ) ;
6388  }
6389 
6403  INT32 connect ( const CHAR *pHostName,
6404  UINT16 port,
6405  const CHAR *pUsrName,
6406  const CHAR *pPasswd
6407  )
6408  {
6409  if ( !pSDB )
6410  {
6411  return SDB_NOT_CONNECTED ;
6412  }
6413  return pSDB->connect ( pHostName, port,
6414  pUsrName, pPasswd ) ;
6415  }
6416 
6426  INT32 connect ( const CHAR *pHostName,
6427  const CHAR *pServiceName
6428  )
6429  {
6430  if ( !pSDB )
6431  {
6432  return SDB_NOT_CONNECTED ;
6433  }
6434  return pSDB->connect ( pHostName, pServiceName ) ;
6435  }
6436 
6450  INT32 connect ( const CHAR *pHostName,
6451  const CHAR *pServiceName,
6452  const CHAR *pUsrName,
6453  const CHAR *pPasswd )
6454  {
6455  if ( !pSDB )
6456  {
6457  return SDB_NOT_CONNECTED ;
6458  }
6459  return pSDB->connect ( pHostName, pServiceName,
6460  pUsrName, pPasswd ) ;
6461  }
6462 
6476  INT32 connect ( const CHAR **pConnAddrs,
6477  INT32 arrSize,
6478  const CHAR *pUsrName,
6479  const CHAR *pPasswd )
6480  {
6481  if ( !pSDB )
6482  {
6483  return SDB_NOT_CONNECTED ;
6484  }
6485  return pSDB->connect ( pConnAddrs, arrSize,
6486  pUsrName, pPasswd ) ;
6487  }
6488 
6504  INT32 connect ( const CHAR **pConnAddrs,
6505  INT32 arrSize,
6506  const CHAR *pUsrName,
6507  const CHAR *pToken,
6508  const CHAR *pCipherFile )
6509  {
6510  if ( !pSDB )
6511  {
6512  return SDB_NOT_CONNECTED ;
6513  }
6514  return pSDB->connect ( pConnAddrs, arrSize,
6515  pUsrName, pToken, pCipherFile ) ;
6516  }
6517 
6522  UINT64 getDbStartTime ()
6523  {
6524  if ( !pSDB )
6525  {
6526  return -1 ;
6527  }
6528  return pSDB->getDbStartTime() ;
6529  }
6530 
6535  const CHAR *getAddress ()
6536  {
6537  if ( !pSDB )
6538  {
6539  return NULL ;
6540  }
6541  return pSDB->getAddress () ;
6542  }
6543 
6544 
6554  void getVersion ( UINT8 &version, UINT8 &subVersion, UINT8 &fixVersion )
6555  {
6556  if ( !pSDB )
6557  {
6558  return ;
6559  }
6560  pSDB->getVersion( version, subVersion, fixVersion ) ;
6561  }
6562 
6591  INT32 createUsr( const CHAR *pUsrName,
6592  const CHAR *pPasswd,
6593  const bson::BSONObj &options = _sdbStaticObject )
6594  {
6595  if ( !pSDB )
6596  {
6597  return SDB_NOT_CONNECTED ;
6598  }
6599  return pSDB->createUsr( pUsrName, pPasswd, options ) ;
6600  }
6601 
6610  INT32 removeUsr( const CHAR *pUsrName,
6611  const CHAR *pPasswd )
6612  {
6613  if ( !pSDB )
6614  {
6615  return SDB_NOT_CONNECTED ;
6616  }
6617  return pSDB->removeUsr( pUsrName, pPasswd ) ;
6618  }
6619 
6632  INT32 alterUsr( const CHAR *pUsrName,
6633  const CHAR *pAction,
6634  const bson::BSONObj &options )
6635  {
6636  if ( !pSDB )
6637  {
6638  return SDB_NOT_CONNECTED ;
6639  }
6640  return pSDB->alterUsr( pUsrName, pAction, options ) ;
6641  }
6642 
6653  INT32 changeUsrPasswd( const CHAR *pUsrName,
6654  const CHAR *pOldPasswd,
6655  const CHAR *pNewPasswd )
6656  {
6657  if ( !pSDB )
6658  {
6659  return SDB_NOT_CONNECTED ;
6660  }
6661  return pSDB->changeUsrPasswd( pUsrName, pOldPasswd, pNewPasswd ) ;
6662  }
6663 
6667  void disconnect ()
6668  {
6669  if ( !pSDB )
6670  {
6671  return ;
6672  }
6673  pSDB->disconnect () ;
6674  }
6675 
6717  INT32 getSnapshot ( sdbCursor &cursor,
6718  INT32 snapType,
6719  const bson::BSONObj &condition = _sdbStaticObject,
6720  const bson::BSONObj &selector = _sdbStaticObject,
6721  const bson::BSONObj &orderBy = _sdbStaticObject,
6722  const bson::BSONObj &hint = _sdbStaticObject,
6723  INT64 numToSkip = 0,
6724  INT64 numToReturn = -1 )
6725  {
6726  if ( !pSDB )
6727  {
6728  return SDB_NOT_CONNECTED ;
6729  }
6730  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6731  return pSDB->getSnapshot ( cursor, snapType, condition,
6732  selector, orderBy, hint,
6733  numToSkip, numToReturn ) ;
6734  }
6735 
6736  /* \fn INT32 getSnapshot ( _sdbCursor **cursor,
6737  INT32 snapType,
6738  const bson::BSONObj &condition,
6739  const bson::BSONObj &selector,
6740  const bson::BSONObj &orderBy,
6741  const bson::BSONObj &hint,
6742  INT64 numToSkip,
6743  INT64 numToReturn
6744  )
6745  \brief Get the snapshots of specified type.
6746  \param [in] snapType The snapshot type as below
6747 
6748  SDB_SNAP_CONTEXTS : Get the snapshot of all the contexts
6749  SDB_SNAP_CONTEXTS_CURRENT : Get the snapshot of current context
6750  SDB_SNAP_SESSIONS : Get the snapshot of all the sessions
6751  SDB_SNAP_SESSIONS_CURRENT : Get the snapshot of current session
6752  SDB_SNAP_COLLECTIONS : Get the snapshot of all the collections
6753  SDB_SNAP_COLLECTIONSPACES : Get the snapshot of all the collection spaces
6754  SDB_SNAP_DATABASE : Get the snapshot of the database
6755  SDB_SNAP_SYSTEM : Get the snapshot of the system
6756  SDB_SNAP_CATALOG : Get the snapshot of the catalog
6757  SDB_SNAP_TRANSACTIONS : Get snapshot of transactions in current session
6758  SDB_SNAP_TRANSACTIONS_CURRENT : Get snapshot of all the transactions
6759  SDB_SNAP_ACCESSPLANS : Get the snapshot of cached access plans
6760  SDB_SNAP_HEALTH : Get snapshot of node health detection
6761  SDB_SNAP_CONFIGS : Get snapshot of node configurations
6762  SDB_SNAP_SVCTASKS : Get snapshot of service task
6763  SDB_SNAP_SEQUENCES : Get the snapshot of sequences
6764  SDB_SNAP_INDEXSTATS : Get the snapshot of index statistics
6765  SDB_SNAP_RECYCLEBIN : Get the snapshot of items in recycle bin
6766 
6767  \param [in] condition The matching rule, match all the documents if not provided.
6768  \param [in] select The selective rule, return the whole document if not provided.
6769  \param [in] orderBy The ordered rule, result set is unordered if not provided.
6770  \param [in] hint The options provided for specific snapshot type.
6771  format:{ '$Options': { <options> } }
6772  \param [in] numToSkip Skip the first numToSkip documents, default is 0
6773  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
6774  \param [out] cursor The return cursor handle of query.
6775  \retval SDB_OK Operation Success
6776  \retval Others Operation Fail
6777  */
6778  INT32 getSnapshot ( _sdbCursor **cursor,
6779  INT32 snapType,
6780  const bson::BSONObj &condition = _sdbStaticObject,
6781  const bson::BSONObj &selector = _sdbStaticObject,
6782  const bson::BSONObj &orderBy = _sdbStaticObject,
6783  const bson::BSONObj &hint = _sdbStaticObject,
6784  INT64 numToSkip = 0,
6785  INT64 numToReturn = -1 )
6786  {
6787  if ( !pSDB )
6788  {
6789  return SDB_NOT_CONNECTED ;
6790  }
6791  return pSDB->getSnapshot ( cursor, snapType, condition,
6792  selector, orderBy, hint,
6793  numToSkip, numToReturn ) ;
6794  }
6795 
6818  INT32 resetSnapshot ( const bson::BSONObj &options = _sdbStaticObject )
6819  {
6820  if ( !pSDB )
6821  {
6822  return SDB_NOT_CONNECTED ;
6823  }
6824  return pSDB->resetSnapshot ( options ) ;
6825  }
6826 
6827  INT32 getList ( _sdbCursor **cursor,
6828  INT32 listType,
6829  const bson::BSONObj &condition = _sdbStaticObject,
6830  const bson::BSONObj &selector = _sdbStaticObject,
6831  const bson::BSONObj &orderBy = _sdbStaticObject,
6832  const bson::BSONObj &hint = _sdbStaticObject,
6833  INT64 numToSkip = 0,
6834  INT64 numToReturn = -1
6835  )
6836  {
6837  if ( !pSDB )
6838  {
6839  return SDB_NOT_CONNECTED ;
6840  }
6841  return pSDB->getList ( cursor, listType,
6842  condition, selector, orderBy, hint,
6843  numToSkip, numToReturn ) ;
6844  }
6845 
6888  INT32 getList ( sdbCursor &cursor,
6889  INT32 listType,
6890  const bson::BSONObj &condition = _sdbStaticObject,
6891  const bson::BSONObj &selector = _sdbStaticObject,
6892  const bson::BSONObj &orderBy = _sdbStaticObject,
6893  const bson::BSONObj &hint = _sdbStaticObject,
6894  INT64 numToSkip = 0,
6895  INT64 numToReturn = -1
6896  )
6897  {
6898  if ( !pSDB )
6899  {
6900  return SDB_NOT_CONNECTED ;
6901  }
6902  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6903  return pSDB->getList ( cursor, listType,
6904  condition, selector, orderBy, hint,
6905  numToSkip, numToReturn ) ;
6906  }
6907 
6908  INT32 getCollection ( const CHAR *pCollectionFullName,
6909  _sdbCollection **collection,
6910  BOOLEAN checkExist = TRUE
6911  )
6912  {
6913  if ( !pSDB )
6914  {
6915  return SDB_NOT_CONNECTED ;
6916  }
6917  return pSDB->getCollection ( pCollectionFullName,
6918  collection, checkExist ) ;
6919  }
6920 
6931  INT32 getCollection ( const CHAR *pCollectionFullName,
6932  sdbCollection &collection,
6933  BOOLEAN checkExist = TRUE
6934  )
6935  {
6936  if ( !pSDB )
6937  {
6938  return SDB_NOT_CONNECTED ;
6939  }
6940  RELEASE_INNER_HANDLE( collection.pCollection ) ;
6941  return pSDB->getCollection ( pCollectionFullName,
6942  collection,
6943  checkExist ) ;
6944  }
6945 
6946  INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
6947  _sdbCollectionSpace **cs,
6948  BOOLEAN checkExist = TRUE
6949  )
6950  {
6951  if ( !pSDB )
6952  {
6953  return SDB_NOT_CONNECTED ;
6954  }
6955  return pSDB->getCollectionSpace ( pCollectionSpaceName,
6956  cs, checkExist ) ;
6957  }
6958 
6969  INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
6970  sdbCollectionSpace &cs,
6971  BOOLEAN checkExist = TRUE
6972  )
6973  {
6974  if ( !pSDB )
6975  {
6976  return SDB_NOT_CONNECTED ;
6977  }
6979  return pSDB->getCollectionSpace ( pCollectionSpaceName,
6980  cs, checkExist ) ;
6981  }
6982 
6983  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6984  INT32 iPageSize,
6985  _sdbCollectionSpace **cs
6986  )
6987  {
6988  if ( !pSDB )
6989  {
6990  return SDB_NOT_CONNECTED ;
6991  }
6992  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6993  iPageSize,
6994  cs ) ;
6995  }
6996 
7015  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
7016  INT32 iPageSize,
7017  sdbCollectionSpace &cs
7018  )
7019  {
7020  if ( !pSDB )
7021  {
7022  return SDB_NOT_CONNECTED ;
7023  }
7025  return pSDB->createCollectionSpace ( pCollectionSpaceName,
7026  iPageSize, cs ) ;
7027  }
7028 
7029  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
7030  const bson::BSONObj &options,
7031  _sdbCollectionSpace **cs
7032  )
7033  {
7034  if ( !pSDB )
7035  {
7036  return SDB_NOT_CONNECTED ;
7037  }
7038  return pSDB->createCollectionSpace ( pCollectionSpaceName,
7039  options, cs ) ;
7040  }
7041 
7059  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
7060  const bson::BSONObj &options,
7061  sdbCollectionSpace &cs
7062  )
7063  {
7064  if ( !pSDB )
7065  {
7066  return SDB_NOT_CONNECTED ;
7067  }
7069  return pSDB->createCollectionSpace ( pCollectionSpaceName,
7070  options, cs ) ;
7071  }
7072 
7081  INT32 dropCollectionSpace (
7082  const CHAR *pCollectionSpaceName,
7083  const bson::BSONObj &options = _sdbStaticObject )
7084  {
7085  if ( !pSDB )
7086  {
7087  return SDB_NOT_CONNECTED ;
7088  }
7089 
7090  return pSDB->dropCollectionSpace ( pCollectionSpaceName, options ) ;
7091  }
7092 
7093  INT32 listCollectionSpaces ( _sdbCursor **result )
7094  {
7095  if ( !pSDB )
7096  {
7097  return SDB_NOT_CONNECTED ;
7098  }
7099  return pSDB->listCollectionSpaces ( result ) ;
7100  }
7101 
7108  INT32 listCollectionSpaces ( sdbCursor &cursor )
7109  {
7110  if ( !pSDB )
7111  {
7112  return SDB_NOT_CONNECTED ;
7113  }
7114  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7115  return pSDB->listCollectionSpaces ( cursor ) ;
7116  }
7117 
7118  /* \fn INT32 listCollections ( _sdbCursor **result )
7119  \brief list all collections in current database.
7120  \param [out] result The return cursor handle of query.
7121  \retval SDB_OK Operation Success
7122  \retval Others Operation Fail
7123  */
7124  INT32 listCollections ( _sdbCursor **result )
7125  {
7126  if ( !pSDB )
7127  {
7128  return SDB_NOT_CONNECTED ;
7129  }
7130  return pSDB->listCollections ( result ) ;
7131  }
7132 
7139  INT32 listCollections ( sdbCursor &cursor )
7140  {
7141  if ( !pSDB )
7142  {
7143  return SDB_NOT_CONNECTED ;
7144  }
7145  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7146  return pSDB->listCollections ( cursor ) ;
7147  }
7148 
7149  /* \fn INT32 listReplicaGroups ( _sdbCursor **result )
7150  \brief List all replica groups of current database.
7151  \param [out] result The return cursor handle of query.
7152  \retval SDB_OK Operation Success
7153  \retval Others Operation Fail
7154  */
7155  INT32 listReplicaGroups ( _sdbCursor **result )
7156  {
7157  if ( !pSDB )
7158  {
7159  return SDB_NOT_CONNECTED ;
7160  }
7161  return pSDB->listReplicaGroups ( result ) ;
7162  }
7163 
7164 
7171  INT32 listReplicaGroups ( sdbCursor &cursor )
7172  {
7173  if ( !pSDB )
7174  {
7175  return SDB_NOT_CONNECTED ;
7176  }
7177  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7178  return pSDB->listReplicaGroups ( cursor ) ;
7179  }
7180 
7181  /* \fn INT32 getReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **result )
7182  \brief Get the specified replica group.
7183  \param [in] pName The name of replica group.
7184  \param [out] result The sdbReplicaGroup object.
7185  \retval SDB_OK Operation Success
7186  \retval Others Operation Fail
7187  */
7188  INT32 getReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **result )
7189  {
7190  if ( !pSDB )
7191  {
7192  return SDB_NOT_CONNECTED ;
7193  }
7194  return pSDB->getReplicaGroup ( pName, result ) ;
7195  }
7196 
7197 
7205  INT32 getReplicaGroup ( const CHAR *pName, sdbReplicaGroup &group )
7206  {
7207  if ( !pSDB )
7208  {
7209  return SDB_NOT_CONNECTED ;
7210  }
7212  return pSDB->getReplicaGroup ( pName, group ) ;
7213  }
7214 
7215  /* \fn INT32 getReplicaGroup ( INT32 id, _sdbReplicaGroup **result )
7216  \brief Get the specified replica group.
7217  \param [in] id The id of replica group.
7218  \param [out] result The _sdbReplicaGroup object.
7219  \retval SDB_OK Operation Success
7220  \retval Others Operation Fail
7221  */
7222  INT32 getReplicaGroup ( INT32 id, _sdbReplicaGroup **result )
7223  {
7224  if ( !pSDB )
7225  {
7226  return SDB_NOT_CONNECTED ;
7227  }
7228  return pSDB->getReplicaGroup ( id, result ) ;
7229  }
7230 
7238  INT32 getReplicaGroup ( INT32 id, sdbReplicaGroup &group )
7239  {
7240  if ( !pSDB )
7241  {
7242  return SDB_NOT_CONNECTED ;
7243  }
7245  return pSDB->getReplicaGroup ( id, group ) ;
7246  }
7247 
7248  /* \fn INT32 createReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
7249  \brief Create the specified replica group.
7250  \param [in] pName The name of the replica group.
7251  \param [out] replicaGroup The return _sdbReplicaGroup object.
7252  \retval SDB_OK Operation Success
7253  \retval Others Operation Fail
7254  */
7255  INT32 createReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
7256  {
7257  if ( !pSDB )
7258  {
7259  return SDB_NOT_CONNECTED ;
7260  }
7261  return pSDB->createReplicaGroup ( pName, replicaGroup ) ;
7262  }
7263 
7271  INT32 createReplicaGroup ( const CHAR *pName, sdbReplicaGroup &group )
7272  {
7273  if ( !pSDB )
7274  {
7275  return SDB_NOT_CONNECTED ;
7276  }
7278  return pSDB->createReplicaGroup ( pName, group ) ;
7279  }
7280 
7287  INT32 removeReplicaGroup ( const CHAR *pName )
7288  {
7289  if ( !pSDB )
7290  {
7291  return SDB_NOT_CONNECTED ;
7292  }
7293  return pSDB->removeReplicaGroup ( pName ) ;
7294  }
7295 
7308  INT32 createReplicaCataGroup ( const CHAR *pHostName,
7309  const CHAR *pServiceName,
7310  const CHAR *pDatabasePath,
7311  const bson::BSONObj &configure )
7312  {
7313  if ( !pSDB )
7314  {
7315  return SDB_NOT_CONNECTED ;
7316  }
7317  return pSDB->createReplicaCataGroup ( pHostName, pServiceName,
7318  pDatabasePath, configure ) ;
7319  }
7320 
7321  INT32 activateReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
7322  {
7323  if ( !pSDB )
7324  {
7325  return SDB_NOT_CONNECTED ;
7326  }
7327  return pSDB->activateReplicaGroup ( pName, replicaGroup ) ;
7328  }
7329 
7337  INT32 activateReplicaGroup ( const CHAR *pName, sdbReplicaGroup &replicaGroup )
7338  {
7339  if ( !pSDB )
7340  {
7341  return SDB_NOT_CONNECTED ;
7342  }
7343  RELEASE_INNER_HANDLE( replicaGroup.pReplicaGroup ) ;
7344  return pSDB->activateReplicaGroup ( pName, replicaGroup ) ;
7345  }
7346 
7354  INT32 execUpdate( const CHAR *sql, bson::BSONObj *pResult = NULL )
7355  {
7356  if ( !pSDB )
7357  {
7358  return SDB_NOT_CONNECTED ;
7359  }
7360  return pSDB->execUpdate( sql, pResult ) ;
7361  }
7362 
7363  /* \fn INT32 exec( const CHAR *sql,
7364  _sdbCursor **result )
7365  \brief Executing SQL command.
7366  \param [in] sql The SQL command.
7367  \param [out] result The return cursor handle of matching documents.
7368  \retval SDB_OK Operation Success
7369  \retval Others Operation Fail
7370  */
7371  INT32 exec( const CHAR *sql,
7372  _sdbCursor **result )
7373  {
7374  if ( !pSDB )
7375  {
7376  return SDB_NOT_CONNECTED ;
7377  }
7378  return pSDB->exec( sql, result ) ;
7379  }
7380 
7389  INT32 exec( const CHAR *sql,
7390  sdbCursor &cursor )
7391  {
7392  if ( !pSDB )
7393  {
7394  return SDB_NOT_CONNECTED ;
7395  }
7396  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7397  return pSDB->exec( sql, cursor ) ;
7398  }
7399 
7405  INT32 transactionBegin()
7406  {
7407  if ( !pSDB )
7408  {
7409  return SDB_NOT_CONNECTED ;
7410  }
7411  return pSDB->transactionBegin() ;
7412  }
7413 
7421  INT32 transactionCommit( const bson::BSONObj &hint = _sdbStaticObject )
7422  {
7423  if ( !pSDB )
7424  {
7425  return SDB_NOT_CONNECTED ;
7426  }
7427  return pSDB->transactionCommit( hint ) ;
7428  }
7429 
7435  INT32 transactionRollback()
7436  {
7437  if ( !pSDB )
7438  {
7439  return SDB_NOT_CONNECTED ;
7440  }
7441  return pSDB->transactionRollback() ;
7442  }
7452  INT32 flushConfigure( const bson::BSONObj &options )
7453  {
7454  if ( !pSDB )
7455  {
7456  return SDB_NOT_CONNECTED ;
7457  }
7458  return pSDB->flushConfigure( options ) ;
7459  }
7460 
7467  INT32 crtJSProcedure ( const CHAR *code )
7468  {
7469  if ( !pSDB )
7470  {
7471  return SDB_NOT_CONNECTED ;
7472  }
7473  return pSDB->crtJSProcedure( code ) ;
7474  }
7475 
7482  INT32 rmProcedure( const CHAR *spName )
7483  {
7484  if ( !pSDB )
7485  {
7486  return SDB_NOT_CONNECTED ;
7487  }
7488  return pSDB->rmProcedure( spName ) ;
7489  }
7490 
7491  INT32 listProcedures( _sdbCursor **cursor, const bson::BSONObj &condition )
7492  {
7493  if ( !pSDB )
7494  {
7495  return SDB_NOT_CONNECTED ;
7496  }
7497  return pSDB->listProcedures( cursor, condition ) ;
7498  }
7499 
7507  INT32 listProcedures( sdbCursor &cursor, const bson::BSONObj &condition )
7508  {
7509  if ( !pSDB )
7510  {
7511  return SDB_NOT_CONNECTED ;
7512  }
7513  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7514  return pSDB->listProcedures( cursor, condition ) ;
7515  }
7516 
7517  INT32 evalJS( const CHAR *code,
7518  SDB_SPD_RES_TYPE &type,
7519  _sdbCursor **cursor,
7520  bson::BSONObj &errmsg )
7521  {
7522  if ( !pSDB )
7523  {
7524  return SDB_NOT_CONNECTED ;
7525  }
7526  return pSDB->evalJS( code, type, cursor, errmsg ) ;
7527  }
7528 
7541  INT32 evalJS( const CHAR *code, SDB_SPD_RES_TYPE &type,
7542  sdbCursor &cursor,
7543  bson::BSONObj &errmsg )
7544  {
7545  if ( !pSDB )
7546  {
7547  return SDB_NOT_CONNECTED ;
7548  }
7549  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7550  return pSDB->evalJS( code, type, cursor, errmsg ) ;
7551  }
7552 
7572  INT32 backupOffline ( const bson::BSONObj &options)
7573  {
7574  return backup( options ) ;
7575  }
7576 
7595  INT32 backup ( const bson::BSONObj &options)
7596  {
7597  if ( !pSDB )
7598  {
7599  return SDB_NOT_CONNECTED ;
7600  }
7601  return pSDB->backup( options ) ;
7602  }
7603 
7604 
7605  INT32 listBackup ( _sdbCursor **cursor,
7606  const bson::BSONObj &options,
7607  const bson::BSONObj &condition = _sdbStaticObject,
7608  const bson::BSONObj &selector = _sdbStaticObject,
7609  const bson::BSONObj &orderBy = _sdbStaticObject)
7610  {
7611  if ( !pSDB )
7612  {
7613  return SDB_NOT_CONNECTED ;
7614  }
7615  return pSDB->listBackup( cursor, options, condition, selector, orderBy ) ;
7616  }
7617 
7640  INT32 listBackup ( sdbCursor &cursor,
7641  const bson::BSONObj &options,
7642  const bson::BSONObj &condition = _sdbStaticObject,
7643  const bson::BSONObj &selector = _sdbStaticObject,
7644  const bson::BSONObj &orderBy = _sdbStaticObject)
7645  {
7646  if ( !pSDB )
7647  {
7648  return SDB_NOT_CONNECTED ;
7649  }
7650  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7651  return pSDB->listBackup( cursor, options, condition, selector, orderBy ) ;
7652  }
7653 
7668  INT32 removeBackup ( const bson::BSONObj &options)
7669  {
7670  if ( !pSDB )
7671  {
7672  return SDB_NOT_CONNECTED ;
7673  }
7674  return pSDB->removeBackup( options ) ;
7675  }
7676 
7677  INT32 listTasks ( _sdbCursor **cursor,
7678  const bson::BSONObj &condition = _sdbStaticObject,
7679  const bson::BSONObj &selector = _sdbStaticObject,
7680  const bson::BSONObj &orderBy = _sdbStaticObject,
7681  const bson::BSONObj &hint = _sdbStaticObject)
7682  {
7683  if ( !pSDB )
7684  {
7685  return SDB_NOT_CONNECTED ;
7686  }
7687  return pSDB->listTasks ( cursor,
7688  condition,
7689  selector,
7690  orderBy,
7691  hint ) ;
7692  }
7710  INT32 listTasks ( sdbCursor &cursor,
7711  const bson::BSONObj &condition = _sdbStaticObject,
7712  const bson::BSONObj &selector = _sdbStaticObject,
7713  const bson::BSONObj &orderBy = _sdbStaticObject,
7714  const bson::BSONObj &hint = _sdbStaticObject)
7715  {
7716  if ( !pSDB )
7717  {
7718  return SDB_NOT_CONNECTED ;
7719  }
7720  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7721  return pSDB->listTasks ( cursor,
7722  condition,
7723  selector,
7724  orderBy,
7725  hint ) ;
7726  }
7727 
7736  INT32 waitTasks ( const SINT64 *taskIDs,
7737  SINT32 num )
7738  {
7739  if ( !pSDB )
7740  {
7741  return SDB_NOT_CONNECTED ;
7742  }
7743  return pSDB->waitTasks ( taskIDs,
7744  num ) ;
7745  }
7746 
7756  INT32 cancelTask ( SINT64 taskID,
7757  BOOLEAN isAsync )
7758  {
7759  if ( !pSDB )
7760  {
7761  return SDB_NOT_CONNECTED ;
7762  }
7763  return pSDB->cancelTask ( taskID,
7764  isAsync ) ;
7765  }
7766 
7777  INT32 setSessionAttr ( const bson::BSONObj &options = _sdbStaticObject )
7778  {
7779  if ( !pSDB )
7780  {
7781  return SDB_NOT_CONNECTED ;
7782  }
7783  return pSDB->setSessionAttr ( options ) ;
7784  }
7785 
7794  INT32 getSessionAttr ( bson::BSONObj & result,
7795  BOOLEAN useCache = TRUE )
7796  {
7797  if ( !pSDB )
7798  {
7799  return SDB_NOT_CONNECTED ;
7800  }
7801  return pSDB->getSessionAttr( result, useCache ) ;
7802  }
7803 
7810  INT32 closeAllCursors ()
7811  {
7812  return interrupt() ;
7813  }
7814 
7821  INT32 interrupt()
7822  {
7823  if ( !pSDB )
7824  {
7825  return SDB_NOT_CONNECTED ;
7826  }
7827  return pSDB->interrupt () ;
7828  }
7829 
7838  INT32 interruptOperation()
7839  {
7840  if ( !pSDB )
7841  {
7842  return SDB_NOT_CONNECTED ;
7843  }
7844  return pSDB->interruptOperation () ;
7845  }
7846 
7854  INT32 isValid ( BOOLEAN *result )
7855  {
7856  if ( !pSDB )
7857  {
7858  return SDB_NOT_CONNECTED ;
7859  }
7860  return pSDB->isValid ( result ) ;
7861  }
7862 
7867  BOOLEAN isValid ()
7868  {
7869  if ( !pSDB )
7870  {
7871  return FALSE ;
7872  }
7873  return pSDB->isValid () ;
7874  }
7875 
7880  BOOLEAN isClosed()
7881  {
7882  if (!pSDB)
7883  {
7884  return TRUE ;
7885  }
7886  return pSDB->isClosed() ;
7887  }
7888 
7907  INT32 createDomain ( const CHAR *pDomainName,
7908  const bson::BSONObj &options,
7909  sdbDomain &domain )
7910  {
7911  if ( !pSDB )
7912  {
7913  return SDB_NOT_CONNECTED ;
7914  }
7915  RELEASE_INNER_HANDLE( domain.pDomain ) ;
7916  return pSDB->createDomain ( pDomainName, options, domain ) ;
7917  }
7918 
7919  INT32 createDomain ( const CHAR *pDomainName,
7920  const bson::BSONObj &options,
7921  _sdbDomain **domain )
7922  {
7923  if ( !pSDB )
7924  {
7925  return SDB_NOT_CONNECTED ;
7926  }
7927  return pSDB->createDomain ( pDomainName, options, domain ) ;
7928  }
7929 
7936  INT32 dropDomain ( const CHAR *pDomainName )
7937  {
7938  if ( !pSDB )
7939  {
7940  return SDB_NOT_CONNECTED ;
7941  }
7942  return pSDB->dropDomain ( pDomainName ) ;
7943  }
7944 
7945  INT32 getDomain ( const CHAR *pDomainName,
7946  _sdbDomain **domain )
7947  {
7948  if ( !pSDB )
7949  {
7950  return SDB_NOT_CONNECTED ;
7951  }
7952  return pSDB->getDomain ( pDomainName, domain ) ;
7953  }
7954 
7963  INT32 getDomain ( const CHAR *pDomainName,
7964  sdbDomain &domain )
7965  {
7966  if ( !pSDB )
7967  {
7968  return SDB_NOT_CONNECTED ;
7969  }
7970  RELEASE_INNER_HANDLE( domain.pDomain ) ;
7971  return pSDB->getDomain ( pDomainName, domain ) ;
7972  }
7973 
7974  INT32 listDomains ( _sdbCursor **cursor,
7975  const bson::BSONObj &condition = _sdbStaticObject,
7976  const bson::BSONObj &selector = _sdbStaticObject,
7977  const bson::BSONObj &orderBy = _sdbStaticObject,
7978  const bson::BSONObj &hint = _sdbStaticObject )
7979  {
7980  if ( !pSDB )
7981  {
7982  return SDB_NOT_CONNECTED ;
7983  }
7984  return pSDB->listDomains ( cursor, condition, selector, orderBy, hint ) ;
7985  }
7986 
8004  INT32 listDomains ( sdbCursor &cursor,
8005  const bson::BSONObj &condition = _sdbStaticObject,
8006  const bson::BSONObj &selector = _sdbStaticObject,
8007  const bson::BSONObj &orderBy = _sdbStaticObject,
8008  const bson::BSONObj &hint = _sdbStaticObject )
8009  {
8010  if ( !pSDB )
8011  {
8012  return SDB_NOT_CONNECTED ;
8013  }
8014  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
8015  return pSDB->listDomains ( cursor, condition, selector, orderBy, hint ) ;
8016  }
8017 
8018  /* \fn INT32 getDC( sdbDataCenter &dc )
8019  \brief Get current data center.
8020  \retval SDB_OK Operation Success
8021  \retval Others Operation Fail
8022  */
8023  INT32 getDC( sdbDataCenter &dc )
8024  {
8025  if ( !pSDB )
8026  {
8027  return SDB_NOT_CONNECTED ;
8028  }
8029  RELEASE_INNER_HANDLE( dc.pDC ) ;
8030  return pSDB->getDC ( dc ) ;
8031  }
8032 
8033  /* \fn INT32 getDC( _sdbDataCenter **dc )
8034  \brief Get current data center.
8035  \retval SDB_OK Operation Success
8036  \retval Others Operation Fail
8037  */
8038  INT32 getDC( _sdbDataCenter **dc )
8039  {
8040  if ( !pSDB )
8041  {
8042  return SDB_NOT_CONNECTED ;
8043  }
8044  return pSDB->getDC ( dc ) ;
8045  }
8046 
8047  /* \fn INT32 getRecycleBin( sdbRecycleBin &recycleBin )
8048  \brief Get current recycle bin.
8049  \retval SDB_OK Operation Success
8050  \retval Others Operation Fail
8051  */
8052  INT32 getRecycleBin( sdbRecycleBin &recycleBin )
8053  {
8054  if ( !pSDB )
8055  {
8056  return SDB_NOT_CONNECTED ;
8057  }
8058  RELEASE_INNER_HANDLE( recycleBin.pRecycleBin ) ;
8059  return pSDB->getRecycleBin( recycleBin ) ;
8060  }
8061 
8062  /* \fn INT32 getRecycleBin( _sdbRecycleBin **recycleBin )
8063  \brief Get current recycle bin.
8064  \retval SDB_OK Operation Success
8065  \retval Others Operation Fail
8066  */
8067  INT32 getRecycleBin( _sdbRecycleBin **recycleBin )
8068  {
8069  if ( !pSDB )
8070  {
8071  return SDB_NOT_CONNECTED ;
8072  }
8073  return pSDB->getRecycleBin( recycleBin ) ;
8074  }
8075 
8081  UINT64 getLastAliveTime() const { return pSDB->getLastAliveTime(); }
8082 
8105  INT32 syncDB( const bson::BSONObj &options = _sdbStaticObject )
8106  {
8107  if ( !pSDB )
8108  {
8109  return SDB_NOT_CONNECTED ;
8110  }
8111  return pSDB->syncDB ( options ) ;
8112  }
8113 
8140  INT32 analyze ( const bson::BSONObj &options = _sdbStaticObject )
8141  {
8142  if ( !pSDB )
8143  {
8144  return SDB_NOT_CONNECTED ;
8145  }
8146  return pSDB->analyze ( options ) ;
8147  }
8148 
8164  INT32 forceSession( SINT64 sessionID,
8165  const bson::BSONObj &options = _sdbStaticObject )
8166  {
8167  if( !pSDB )
8168  {
8169  return SDB_NOT_CONNECTED ;
8170  }
8171  return pSDB->forceSession( sessionID, options ) ;
8172  }
8173 
8188  INT32 forceStepUp( const bson::BSONObj &options = _sdbStaticObject )
8189  {
8190  if( !pSDB )
8191  {
8192  return SDB_NOT_CONNECTED ;
8193  }
8194  return pSDB->forceStepUp( options ) ;
8195  }
8196 
8209  INT32 invalidateCache( const bson::BSONObj &options = _sdbStaticObject )
8210  {
8211  if( !pSDB )
8212  {
8213  return SDB_NOT_CONNECTED ;
8214  }
8215  return pSDB->invalidateCache( options ) ;
8216  }
8217 
8231  INT32 reloadConfig( const bson::BSONObj &options = _sdbStaticObject )
8232  {
8233  if( !pSDB )
8234  {
8235  return SDB_NOT_CONNECTED ;
8236  }
8237  return pSDB->reloadConfig( options ) ;
8238  }
8239 
8256  INT32 updateConfig( const bson::BSONObj &configs = _sdbStaticObject,
8257  const bson::BSONObj &options = _sdbStaticObject )
8258  {
8259  if( !pSDB )
8260  {
8261  return SDB_NOT_CONNECTED ;
8262  }
8263  return pSDB->updateConfig( configs, options ) ;
8264  }
8265 
8282  INT32 deleteConfig( const bson::BSONObj &configs = _sdbStaticObject,
8283  const bson::BSONObj &options = _sdbStaticObject )
8284  {
8285  if( !pSDB )
8286  {
8287  return SDB_NOT_CONNECTED ;
8288  }
8289  return pSDB->deleteConfig( configs, options ) ;
8290  }
8291 
8314  INT32 setPDLevel( INT32 level,
8315  const bson::BSONObj &options = _sdbStaticObject )
8316  {
8317  if( !pSDB )
8318  {
8319  return SDB_NOT_CONNECTED ;
8320  }
8321  return pSDB->setPDLevel( level, options ) ;
8322  }
8323 
8339  INT32 memTrim( const CHAR *maskStr = "",
8340  const bson::BSONObj &options = _sdbStaticObject )
8341  {
8342  if( !pSDB )
8343  {
8344  return SDB_NOT_CONNECTED ;
8345  }
8346  return pSDB->memTrim( maskStr, options ) ;
8347  }
8348 
8349  INT32 msg( const CHAR* msg )
8350  {
8351  if( !pSDB )
8352  {
8353  return SDB_NOT_CONNECTED ;
8354  }
8355  return pSDB->msg( msg ) ;
8356  }
8357 
8373  INT32 loadCS( const CHAR* csName,
8374  const bson::BSONObj &options = _sdbStaticObject )
8375  {
8376  if( !pSDB )
8377  {
8378  return SDB_NOT_CONNECTED ;
8379  }
8380  return pSDB->loadCS( csName, options ) ;
8381  }
8382 
8398  INT32 unloadCS( const CHAR* csName,
8399  const bson::BSONObj &options = _sdbStaticObject )
8400  {
8401  if( !pSDB )
8402  {
8403  return SDB_NOT_CONNECTED ;
8404  }
8405  return pSDB->unloadCS( csName, options ) ;
8406  }
8407 
8420  INT32 traceStart( UINT32 traceBufferSize,
8421  const CHAR* component = NULL,
8422  const CHAR* breakpoint = NULL,
8423  const vector<UINT32> &tidVec = _sdbStaticUINT32Vec )
8424  {
8425  if( !pSDB )
8426  {
8427  return SDB_NOT_CONNECTED ;
8428  }
8429  return pSDB->traceStart( traceBufferSize, component,
8430  breakpoint, tidVec ) ;
8431  }
8432 
8452  INT32 traceStart( UINT32 traceBufferSize,
8453  const bson::BSONObj &options )
8454  {
8455  if( !pSDB )
8456  {
8457  return SDB_NOT_CONNECTED ;
8458  }
8459  return pSDB->traceStart( traceBufferSize, options ) ;
8460  }
8461 
8470  INT32 traceStop( const CHAR* dumpFileName )
8471  {
8472  if( !pSDB )
8473  {
8474  return SDB_NOT_CONNECTED ;
8475  }
8476  return pSDB->traceStop( dumpFileName ) ;
8477  }
8478 
8484  INT32 traceResume()
8485  {
8486  if( !pSDB )
8487  {
8488  return SDB_NOT_CONNECTED ;
8489  }
8490  return pSDB->traceResume() ;
8491  }
8492 
8499  INT32 traceStatus( sdbCursor& cursor )
8500  {
8501  if( !pSDB )
8502  {
8503  return SDB_NOT_CONNECTED ;
8504  }
8505  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
8506  return pSDB->traceStatus( cursor ) ;
8507  }
8508 
8509  INT32 traceStatus( _sdbCursor** cursor )
8510  {
8511  if( !pSDB )
8512  {
8513  return SDB_NOT_CONNECTED ;
8514  }
8515  return pSDB->traceStatus( cursor ) ;
8516  }
8517 
8528  INT32 renameCollectionSpace( const CHAR* oldName,
8529  const CHAR* newName,
8530  const bson::BSONObj &options = _sdbStaticObject )
8531  {
8532  if( !pSDB )
8533  {
8534  return SDB_NOT_CONNECTED ;
8535  }
8536  return pSDB->renameCollectionSpace( oldName, newName, options ) ;
8537  }
8538 
8550  INT32 getLastErrorObj( bson::BSONObj &errObj )
8551  {
8552  if( !pSDB )
8553  {
8554  return SDB_NOT_CONNECTED ;
8555  }
8556  return pSDB->getLastErrorObj( errObj ) ;
8557  }
8558 
8562  void cleanLastErrorObj()
8563  {
8564  if( !pSDB )
8565  {
8566  return ;
8567  }
8568  return pSDB->cleanLastErrorObj() ;
8569  }
8570 
8581  INT32 getLastResultObj( bson::BSONObj &result,
8582  BOOLEAN getOwned = FALSE ) const
8583  {
8584  if( !pSDB )
8585  {
8586  return SDB_NOT_CONNECTED ;
8587  }
8588  return pSDB->getLastResultObj( result, getOwned ) ;
8589  }
8590 
8610  INT32 createSequence( const CHAR *pSequenceName,
8611  const bson::BSONObj &options,
8612  _sdbSequence **sequence )
8613  {
8614  if( !pSDB )
8615  {
8616  return SDB_NOT_CONNECTED ;
8617  }
8618  return pSDB->createSequence( pSequenceName, options, sequence ) ;
8619  }
8620 
8640  INT32 createSequence( const CHAR *pSequenceName,
8641  const bson::BSONObj &options,
8642  sdbSequence &sequence )
8643  {
8644  if( !pSDB )
8645  {
8646  return SDB_NOT_CONNECTED ;
8647  }
8648  return pSDB->createSequence( pSequenceName, options, sequence ) ;
8649  }
8650 
8659  INT32 createSequence( const CHAR *pSequenceName,
8660  sdbSequence &sequence )
8661  {
8662  if( !pSDB )
8663  {
8664  return SDB_NOT_CONNECTED ;
8665  }
8666  return pSDB->createSequence( pSequenceName, sequence ) ;
8667  }
8668 
8677  INT32 getSequence( const CHAR *pSequenceName,
8678  _sdbSequence **sequence )
8679  {
8680  if( !pSDB )
8681  {
8682  return SDB_NOT_CONNECTED ;
8683  }
8684  return pSDB->getSequence( pSequenceName, sequence ) ;
8685  }
8686 
8695  INT32 getSequence( const CHAR *pSequenceName,
8696  sdbSequence &sequence )
8697  {
8698  if( !pSDB )
8699  {
8700  return SDB_NOT_CONNECTED ;
8701  }
8702  return pSDB->getSequence( pSequenceName, sequence ) ;
8703  }
8704 
8712  INT32 renameSequence( const CHAR *pOldName, const CHAR *pNewName )
8713  {
8714  if( !pSDB )
8715  {
8716  return SDB_NOT_CONNECTED ;
8717  }
8718  return pSDB->renameSequence( pOldName, pNewName ) ;
8719  }
8720 
8727  INT32 dropSequence( const CHAR *pSequenceName )
8728  {
8729  if( !pSDB )
8730  {
8731  return SDB_NOT_CONNECTED ;
8732  }
8733  return pSDB->dropSequence( pSequenceName ) ;
8734  }
8735 
8784  INT32 createDataSource( sdbDataSource &dataSource,
8785  const CHAR *pDataSourceName,
8786  const CHAR *addresses,
8787  const CHAR *user = NULL,
8788  const CHAR *password = NULL,
8789  const CHAR *type = NULL,
8790  const bson::BSONObj *options = NULL )
8791  {
8792  if ( !pSDB )
8793  {
8794  return SDB_NOT_CONNECTED ;
8795  }
8796  RELEASE_INNER_HANDLE( dataSource.pDataSource ) ;
8797  return pSDB->createDataSource( &dataSource.pDataSource, pDataSourceName, addresses,
8798  user, password, type, options ) ;
8799  }
8800 
8807  INT32 dropDataSource( const CHAR *pDataSourceName )
8808  {
8809  if ( !pSDB )
8810  {
8811  return SDB_NOT_CONNECTED ;
8812  }
8813  return pSDB->dropDataSource( pDataSourceName ) ;
8814  }
8815 
8824  INT32 getDataSource( const CHAR *pDataSourceName,
8825  sdbDataSource &dataSource )
8826  {
8827  if ( !pSDB )
8828  {
8829  return SDB_NOT_CONNECTED ;
8830  }
8831  RELEASE_INNER_HANDLE( dataSource.pDataSource ) ;
8832  return pSDB->getDataSource( pDataSourceName, &dataSource.pDataSource ) ;
8833  }
8834 
8849  INT32 listDataSources( sdbCursor& cursor,
8850  const bson::BSONObj &condition = _sdbStaticObject,
8851  const bson::BSONObj &selector = _sdbStaticObject,
8852  const bson::BSONObj &orderBy = _sdbStaticObject,
8853  const bson::BSONObj &hint = _sdbStaticObject )
8854  {
8855  if ( !pSDB )
8856  {
8857  return SDB_NOT_CONNECTED ;
8858  }
8859  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
8860  return pSDB->listDataSources( &cursor.pCursor, condition, selector, orderBy, hint ) ;
8861  }
8862 
8869  INT32 createRole( const bson::BSONObj &role )
8870  {
8871  if ( !pSDB )
8872  {
8873  return SDB_NOT_CONNECTED ;
8874  }
8875  return pSDB->createRole( role ) ;
8876  }
8877 
8884  INT32 dropRole( const CHAR *pRoleName )
8885  {
8886  if ( !pSDB )
8887  {
8888  return SDB_NOT_CONNECTED ;
8889  }
8890  return pSDB->dropRole( pRoleName ) ;
8891  }
8892 
8906  INT32 getRole( const CHAR *pRoleName,
8907  const bson::BSONObj &options,
8908  bson::BSONObj &role )
8909  {
8910  if ( !pSDB )
8911  {
8912  return SDB_NOT_CONNECTED ;
8913  }
8914  return pSDB->getRole( pRoleName, options, role ) ;
8915  }
8916 
8929  INT32 listRoles( sdbCursor &cursor, const bson::BSONObj &options )
8930  {
8931  if ( !pSDB )
8932  {
8933  return SDB_NOT_CONNECTED ;
8934  }
8935  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
8936  return pSDB->listRoles( &cursor.pCursor, options ) ;
8937  }
8938 
8947  INT32 updateRole( const CHAR *pRoleName,
8948  const bson::BSONObj &role )
8949  {
8950  if ( !pSDB )
8951  {
8952  return SDB_NOT_CONNECTED ;
8953  }
8954  return pSDB->updateRole( pRoleName, role ) ;
8955  }
8956 
8965  INT32 grantPrivilegesToRole( const CHAR *pRoleName,
8966  const bson::BSONObj &privileges )
8967  {
8968  if ( !pSDB )
8969  {
8970  return SDB_NOT_CONNECTED ;
8971  }
8972  return pSDB->grantPrivilegesToRole( pRoleName, privileges ) ;
8973  }
8974 
8983  INT32 revokePrivilegesFromRole( const CHAR *pRoleName,
8984  const bson::BSONObj &privileges )
8985  {
8986  if ( !pSDB )
8987  {
8988  return SDB_NOT_CONNECTED ;
8989  }
8990  return pSDB->revokePrivilegesFromRole( pRoleName, privileges ) ;
8991  }
8992 
9001  INT32 grantRolesToRole( const CHAR *pRoleName,
9002  const bson::BSONObj &roles )
9003  {
9004  if ( !pSDB )
9005  {
9006  return SDB_NOT_CONNECTED ;
9007  }
9008  return pSDB->grantRolesToRole( pRoleName, roles ) ;
9009  }
9010 
9019  INT32 revokeRolesFromRole( const CHAR *pRoleName,
9020  const bson::BSONObj &roles )
9021  {
9022  if ( !pSDB )
9023  {
9024  return SDB_NOT_CONNECTED ;
9025  }
9026  return pSDB->revokeRolesFromRole( pRoleName, roles ) ;
9027  }
9028 
9037  INT32 grantRolesToUser( const CHAR *pUserName,
9038  const bson::BSONObj &privileges )
9039  {
9040  if ( !pSDB )
9041  {
9042  return SDB_NOT_CONNECTED ;
9043  }
9044  return pSDB->grantRolesToUser( pUserName, privileges ) ;
9045  }
9046 
9055  INT32 revokeRolesFromUser( const CHAR *pUserName,
9056  const bson::BSONObj &privileges )
9057  {
9058  if ( !pSDB )
9059  {
9060  return SDB_NOT_CONNECTED ;
9061  }
9062  return pSDB->revokeRolesFromUser( pUserName, privileges ) ;
9063  }
9064 
9076  INT32 getUser( const CHAR *pRoleName,
9077  const bson::BSONObj &options,
9078  bson::BSONObj &role )
9079  {
9080  if ( !pSDB )
9081  {
9082  return SDB_NOT_CONNECTED ;
9083  }
9084  return pSDB->getUser( pRoleName, options, role ) ;
9085  }
9086 
9102  INT32 invalidateUserCache( const CHAR *pUserName = NULL,
9103  const bson::BSONObj &options = _sdbStaticObject )
9104  {
9105  if ( !pSDB )
9106  {
9107  return SDB_NOT_CONNECTED ;
9108  }
9109  return pSDB->invalidateUserCache( pUserName, options ) ;
9110  }
9111 
9130  INT32 invalidateFsCache( const bson::BSONObj &options = _sdbStaticObject,
9131  const CHAR *pExpiredTime = NULL )
9132  {
9133  if ( !pSDB )
9134  {
9135  return SDB_NOT_CONNECTED ;
9136  }
9137  return pSDB->invalidateFsCache( options, pExpiredTime ) ;
9138  }
9139 
9140  /* \fn void enableClientQueryID()
9141  \brief client maintains query ID to monitor client operations.
9142  */
9143  void enableClientQueryID()
9144  {
9145  if ( pSDB )
9146  {
9147  pSDB->enableClientQueryID() ;
9148  }
9149  }
9150 
9151  /* \fn void incQueryID()
9152  \brief increase query ID manually.
9153  */
9154  void incQueryID()
9155  {
9156  if ( pSDB )
9157  {
9158  pSDB->incQueryID() ;
9159  }
9160  }
9161 
9162  /* \fn UINT32 getQueryIDStr( CHAR *pStr, UINT32 strlen )
9163  \brief get current query ID string.
9164  \retval written string length
9165  */
9166  UINT32 getQueryIDStr( CHAR *pStr, UINT32 strlen )
9167  {
9168  if ( pSDB )
9169  {
9170  return pSDB->getQueryIDStr( pStr, strlen ) ;
9171  }
9172  else
9173  {
9174  return 0 ;
9175  }
9176  }
9177 
9178  } ;
9179 
9183  typedef class sdb sdb ;
9184 
9191  SDB_EXPORT INT32 initClient( sdbClientConf* config ) ;
9192 
9193 }
9194 
9195 #endif