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 10 seconds timeout
90 #define SDB_CLIENT_SOCKET_TIMEOUT_DFT 10000
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, const bson::OID *oid = NULL ) = 0 ;
584 
585  virtual INT32 removeLob( const bson::OID &oid ) = 0 ;
586 
587  virtual INT32 truncateLob( const bson::OID &oid, INT64 length ) = 0 ;
588 
589  virtual INT32 openLob( sdbLob &lob, const bson::OID &oid,
590  SDB_LOB_OPEN_MODE mode = SDB_LOB_READ ) = 0 ;
591 
592  virtual INT32 openLob( sdbLob &lob, const bson::OID &oid,
593  INT32 mode ) = 0 ;
594 
595  virtual INT32 listLobs( sdbCursor &cursor,
596  const bson::BSONObj &condition = _sdbStaticObject,
597  const bson::BSONObj &selected = _sdbStaticObject,
598  const bson::BSONObj &orderBy = _sdbStaticObject,
599  const bson::BSONObj &hint = _sdbStaticObject,
600  INT64 numToSkip = 0,
601  INT64 numToReturn = -1 ) = 0 ;
602 
603  virtual INT32 listLobs( _sdbCursor **cursor,
604  const bson::BSONObj &condition = _sdbStaticObject,
605  const bson::BSONObj &selected = _sdbStaticObject,
606  const bson::BSONObj &orderBy = _sdbStaticObject,
607  const bson::BSONObj &hint = _sdbStaticObject,
608  INT64 numToSkip = 0,
609  INT64 numToReturn = -1 ) = 0 ;
610 
611  virtual INT32 createLobID( bson::OID &oid, const CHAR *pTimeStamp = NULL ) = 0 ;
612 
613  virtual INT32 listLobPieces(
614  _sdbCursor **cursor,
615  const bson::BSONObj &condition = _sdbStaticObject,
616  const bson::BSONObj &selected = _sdbStaticObject,
617  const bson::BSONObj &orderBy = _sdbStaticObject,
618  const bson::BSONObj &hint = _sdbStaticObject,
619  INT64 numToSkip = 0,
620  INT64 numToReturn = -1 ) = 0 ;
621 
622  virtual INT32 listLobPieces(
623  sdbCursor &cursor,
624  const bson::BSONObj &condition = _sdbStaticObject,
625  const bson::BSONObj &selected = _sdbStaticObject,
626  const bson::BSONObj &orderBy = _sdbStaticObject,
627  const bson::BSONObj &hint = _sdbStaticObject,
628  INT64 numToSkip = 0,
629  INT64 numToReturn = -1 ) = 0 ;
630 
632  virtual INT32 truncate( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
633 
635  virtual INT32 createIdIndex( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
636 
637  virtual INT32 dropIdIndex() = 0 ;
638 
639  virtual INT32 createAutoIncrement( const bson::BSONObj &options ) = 0;
640 
641  virtual INT32 createAutoIncrement( const std::vector<bson::BSONObj> &options ) = 0;
642 
643  virtual INT32 dropAutoIncrement( const CHAR *fieldName ) = 0;
644 
645  virtual INT32 dropAutoIncrement( const std::vector<const CHAR*> &fieldNames ) = 0;
646 
647  virtual INT32 pop ( const bson::BSONObj &option = _sdbStaticObject ) = 0 ;
648 
649  virtual INT32 enableSharding ( const bson::BSONObj &options ) = 0 ;
650 
651  virtual INT32 disableSharding () = 0 ;
652 
653  virtual INT32 enableCompression ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
654 
655  virtual INT32 disableCompression () = 0 ;
656 
657  virtual INT32 setAttributes ( const bson::BSONObj &options ) = 0 ;
658 
659  virtual INT32 getDetail ( _sdbCursor **cursor ) = 0 ;
660 
661  virtual INT32 getDetail ( sdbCursor &cursor ) = 0 ;
662 
663  virtual INT32 getCollectionStat ( bson::BSONObj &result ) = 0 ;
664 
665  virtual INT32 getIndexStat ( const CHAR *pIndexName,
666  bson::BSONObj &result,
667  BOOLEAN detail = FALSE ) = 0 ;
668 
669  virtual void setVersion( INT32 clVersion ) = 0;
670  virtual INT32 getVersion() = 0;
671  } ;
672 
676  class DLLEXPORT sdbCollection
677  {
678  private :
683  sdbCollection ( const sdbCollection& other ) ;
684 
690  sdbCollection& operator=( const sdbCollection& ) ;
691  public :
698  _sdbCollection *pCollection ;
699 
704  {
705  pCollection = NULL ;
706  }
707 
712  {
713  if ( pCollection )
714  {
715  delete pCollection ;
716  }
717  }
718 
732  INT32 getCount ( SINT64 &count,
733  const bson::BSONObj &condition = _sdbStaticObject,
734  const bson::BSONObj &hint = _sdbStaticObject )
735  {
736  if ( !pCollection )
737  {
738  return SDB_NOT_CONNECTED ;
739  }
740  return pCollection->getCount ( count, condition, hint ) ;
741  }
742 
760  INT32 split ( const CHAR *pSourceGroupName,
761  const CHAR *pTargetGroupName,
762  const bson::BSONObj &splitCondition,
763  const bson::BSONObj &splitEndCondition = _sdbStaticObject)
764  {
765  if ( !pCollection )
766  {
767  return SDB_NOT_CONNECTED ;
768  }
769  return pCollection->split ( pSourceGroupName,
770  pTargetGroupName,
771  splitCondition,
772  splitEndCondition) ;
773  }
774 
786  INT32 split ( const CHAR *pSourceGroupName,
787  const CHAR *pTargetGroupName,
788  FLOAT64 percent )
789  {
790  if ( !pCollection )
791  {
792  return SDB_NOT_CONNECTED ;
793  }
794  return pCollection->split ( pSourceGroupName,
795  pTargetGroupName,
796  percent ) ;
797  }
798 
818  INT32 splitAsync ( SINT64 &taskID,
819  const CHAR *pSourceGroupName,
820  const CHAR *pTargetGroupName,
821  const bson::BSONObj &splitCondition,
822  const bson::BSONObj &splitEndCondition = _sdbStaticObject )
823  {
824  if ( !pCollection )
825  {
826  return SDB_NOT_CONNECTED ;
827  }
828  return pCollection->splitAsync ( taskID,
829  pSourceGroupName,
830  pTargetGroupName,
831  splitCondition,
832  splitEndCondition ) ;
833  }
834 
848  INT32 splitAsync ( const CHAR *pSourceGroupName,
849  const CHAR *pTargetGroupName,
850  FLOAT64 percent,
851  SINT64 &taskID )
852  {
853  if ( !pCollection )
854  {
855  return SDB_NOT_CONNECTED ;
856  }
857  return pCollection->splitAsync ( pSourceGroupName,
858  pTargetGroupName,
859  percent,
860  taskID ) ;
861  }
862 
889  INT32 alterCollection ( const bson::BSONObj &options )
890  {
891  if ( !pCollection )
892  {
893  return SDB_NOT_CONNECTED ;
894  }
895  return pCollection->alterCollection ( options ) ;
896  }
897 
920  INT32 insert ( const bson::BSONObj &obj, bson::OID *pId = NULL )
921  {
922  if ( !pCollection )
923  {
924  return SDB_NOT_CONNECTED ;
925  }
926  return pCollection->insert ( obj, pId ) ;
927  }
928 
975  INT32 insert ( const bson::BSONObj &obj,
976  INT32 flags,
977  bson::BSONObj *pResult = NULL )
978  {
979  if ( !pCollection )
980  {
981  return SDB_NOT_CONNECTED ;
982  }
983  return pCollection->insert ( obj, flags, pResult ) ;
984  }
985 
1042  INT32 insert ( const bson::BSONObj &obj,
1043  const bson::BSONObj &hint,
1044  INT32 flags,
1045  bson::BSONObj *pResult = NULL )
1046  {
1047  if ( !pCollection )
1048  {
1049  return SDB_NOT_CONNECTED ;
1050  }
1051  return pCollection->insert ( obj, hint, flags, pResult ) ;
1052  }
1053 
1103  INT32 insert ( std::vector<bson::BSONObj> &objs,
1104  INT32 flags = 0,
1105  bson::BSONObj *pResult = NULL )
1106  {
1107  if ( !pCollection )
1108  {
1109  return SDB_NOT_CONNECTED ;
1110  }
1111  return pCollection->insert( objs, flags, pResult ) ;
1112  }
1113 
1168  INT32 insert ( std::vector<bson::BSONObj> &objs,
1169  const bson::BSONObj &hint,
1170  INT32 flags = 0,
1171  bson::BSONObj *pResult = NULL )
1172  {
1173  if ( !pCollection )
1174  {
1175  return SDB_NOT_CONNECTED ;
1176  }
1177  return pCollection->insert( objs, hint, flags, pResult ) ;
1178  }
1179 
1231  INT32 insert ( const bson::BSONObj objs[],
1232  INT32 size,
1233  INT32 flags = 0,
1234  bson::BSONObj *pResult = NULL )
1235  {
1236  if ( !pCollection )
1237  {
1238  return SDB_NOT_CONNECTED ;
1239  }
1240  return pCollection->insert ( objs, size, flags, pResult ) ;
1241  }
1242 
1270  INT32 bulkInsert ( SINT32 flags,
1271  std::vector<bson::BSONObj> &objs )
1272  {
1273  if ( !pCollection )
1274  {
1275  return SDB_NOT_CONNECTED ;
1276  }
1277  return pCollection->bulkInsert ( flags, objs ) ;
1278  }
1279 
1312  INT32 update ( const bson::BSONObj &rule,
1313  const bson::BSONObj &condition = _sdbStaticObject,
1314  const bson::BSONObj &hint = _sdbStaticObject,
1315  INT32 flag = 0,
1316  bson::BSONObj *pResult = NULL
1317  )
1318  {
1319  if ( !pCollection )
1320  {
1321  return SDB_NOT_CONNECTED ;
1322  }
1323  return pCollection->update ( rule, condition, hint, flag, pResult ) ;
1324  }
1325 
1359  INT32 upsert ( const bson::BSONObj &rule,
1360  const bson::BSONObj &condition = _sdbStaticObject,
1361  const bson::BSONObj &hint = _sdbStaticObject,
1362  const bson::BSONObj &setOnInsert = _sdbStaticObject,
1363  INT32 flag = 0,
1364  bson::BSONObj *pResult = NULL
1365  )
1366  {
1367  if ( !pCollection )
1368  {
1369  return SDB_NOT_CONNECTED ;
1370  }
1371  return pCollection->upsert ( rule, condition, hint, setOnInsert,
1372  flag, pResult ) ;
1373  }
1374 
1396  INT32 del ( const bson::BSONObj &condition = _sdbStaticObject,
1397  const bson::BSONObj &hint = _sdbStaticObject,
1398  INT32 flag = 0,
1399  bson::BSONObj *pResult = NULL
1400  )
1401  {
1402  if ( !pCollection )
1403  {
1404  return SDB_NOT_CONNECTED ;
1405  }
1406  return pCollection->del ( condition, hint, flag, pResult ) ;
1407  }
1408 
1409  /* \fn INT32 query ( _sdbCursor **cursor,
1410  const bson::BSONObj &condition,
1411  const bson::BSONObj &selected,
1412  const bson::BSONObj &orderBy,
1413  const bson::BSONObj &hint,
1414  INT64 numToSkip,
1415  INT64 numToReturn,
1416  INT32 flags
1417  )
1418  \brief Get the matching documents in current collection
1419  \param [in] condition The matching rule, return all the documents if not provided
1420  \param [in] selected The selective rule, return the whole document if not provided
1421  \param [in] orderBy The ordered rule, result set is unordered if not provided
1422  \param [in] hint Specified the index used to scan data. e.g. {"":"ageIndex"} means
1423  using index "ageIndex" to scan data(index scan);
1424  {"":null} means table scan. when hint is not provided,
1425  database automatically match the optimal index to scan data
1426  \param [in] numToSkip Skip the first numToSkip documents, default is 0
1427  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
1428  \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
1429  \code
1430  QUERY_FORCE_HINT
1431  QUERY_PARALLED
1432  QUERY_WITH_RETURNDATA
1433  QUERY_FOR_UPDATE
1434  \endcode
1435  \param [out] cursor The cursor of current query
1436  \retval SDB_OK Operation Success
1437  \retval Others Operation Fail
1438  */
1439  INT32 query ( _sdbCursor **cursor,
1440  const bson::BSONObj &condition = _sdbStaticObject,
1441  const bson::BSONObj &selected = _sdbStaticObject,
1442  const bson::BSONObj &orderBy = _sdbStaticObject,
1443  const bson::BSONObj &hint = _sdbStaticObject,
1444  INT64 numToSkip = 0,
1445  INT64 numToReturn = -1,
1446  INT32 flags = 0
1447  )
1448  {
1449  if ( !pCollection )
1450  {
1451  return SDB_NOT_CONNECTED ;
1452  }
1453  return pCollection->query ( cursor, condition, selected, orderBy,
1454  hint, numToSkip, numToReturn, flags ) ;
1455  }
1456 
1487  INT32 query ( sdbCursor &cursor,
1488  const bson::BSONObj &condition = _sdbStaticObject,
1489  const bson::BSONObj &selected = _sdbStaticObject,
1490  const bson::BSONObj &orderBy = _sdbStaticObject,
1491  const bson::BSONObj &hint = _sdbStaticObject,
1492  INT64 numToSkip = 0,
1493  INT64 numToReturn = -1,
1494  INT32 flags = 0
1495  )
1496  {
1497  if ( !pCollection )
1498  {
1499  return SDB_NOT_CONNECTED ;
1500  }
1501  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1502  return pCollection->query ( cursor, condition, selected, orderBy,
1503  hint, numToSkip, numToReturn, flags ) ;
1504  }
1505 
1534  INT32 queryOne( bson::BSONObj &obj,
1535  const bson::BSONObj &condition = _sdbStaticObject,
1536  const bson::BSONObj &selected = _sdbStaticObject,
1537  const bson::BSONObj &orderBy = _sdbStaticObject,
1538  const bson::BSONObj &hint = _sdbStaticObject,
1539  INT64 numToSkip = 0,
1540  INT32 flag = 0 )
1541  {
1542  if ( !pCollection )
1543  {
1544  return SDB_NOT_CONNECTED ;
1545  }
1546  return pCollection->queryOne( obj, condition, selected, orderBy,
1547  hint, numToSkip, flag ) ;
1548  }
1549 
1585  INT32 queryAndUpdate ( sdbCursor &cursor,
1586  const bson::BSONObj &update,
1587  const bson::BSONObj &condition = _sdbStaticObject,
1588  const bson::BSONObj &selected = _sdbStaticObject,
1589  const bson::BSONObj &orderBy = _sdbStaticObject,
1590  const bson::BSONObj &hint = _sdbStaticObject,
1591  INT64 numToSkip = 0,
1592  INT64 numToReturn = -1,
1593  INT32 flag = 0,
1594  BOOLEAN returnNew = FALSE
1595  )
1596  {
1597  if ( !pCollection )
1598  {
1599  return SDB_NOT_CONNECTED ;
1600  }
1601  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1602  return pCollection->queryAndUpdate( &cursor.pCursor , update, condition,
1603  selected, orderBy, hint,
1604  numToSkip, numToReturn, flag, returnNew ) ;
1605  }
1606 
1637  INT32 queryAndRemove ( sdbCursor &cursor,
1638  const bson::BSONObj &condition = _sdbStaticObject,
1639  const bson::BSONObj &selected = _sdbStaticObject,
1640  const bson::BSONObj &orderBy = _sdbStaticObject,
1641  const bson::BSONObj &hint = _sdbStaticObject,
1642  INT64 numToSkip = 0,
1643  INT64 numToReturn = -1,
1644  INT32 flag = 0
1645  )
1646  {
1647  if ( !pCollection )
1648  {
1649  return SDB_NOT_CONNECTED ;
1650  }
1651  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1652  return pCollection->queryAndRemove( &cursor.pCursor , condition,
1653  selected, orderBy, hint,
1654  numToSkip, numToReturn, flag ) ;
1655  }
1656 
1673  INT32 createIndex ( const bson::BSONObj &indexDef,
1674  const CHAR *pIndexName,
1675  BOOLEAN isUnique,
1676  BOOLEAN isEnforced,
1677  INT32 sortBufferSize =
1678  SDB_INDEX_SORT_BUFFER_DEFAULT_SIZE )
1679  {
1680  if ( !pCollection )
1681  {
1682  return SDB_NOT_CONNECTED ;
1683  }
1684  return pCollection->createIndex ( indexDef, pIndexName, isUnique,
1685  isEnforced, sortBufferSize ) ;
1686  }
1687 
1714  INT32 createIndex ( const bson::BSONObj &indexDef,
1715  const CHAR *pIndexName,
1716  const bson::BSONObj &indexAttr = _sdbStaticObject,
1717  const bson::BSONObj &option = _sdbStaticObject )
1718  {
1719  if ( !pCollection )
1720  return SDB_NOT_CONNECTED ;
1721  return pCollection->createIndex ( indexDef, pIndexName,
1722  indexAttr, option ) ;
1723  }
1724 
1748  INT32 createIndexAsync ( SINT64 &taskID,
1749  const bson::BSONObj &indexDef,
1750  const CHAR *pIndexName,
1751  const bson::BSONObj &indexAttr = _sdbStaticObject,
1752  const bson::BSONObj &option = _sdbStaticObject )
1753  {
1754  if ( !pCollection )
1755  {
1756  return SDB_NOT_CONNECTED ;
1757  }
1758  return pCollection->createIndexAsync ( taskID, indexDef, pIndexName,
1759  indexAttr, option ) ;
1760  }
1761 
1762  /* \fn INT32 snapshotIndexes ( _sdbCursor **cursor,
1763  const bson::BSONObj &condition = _sdbStaticObject,
1764  const bson::BSONObj &selector = _sdbStaticObject,
1765  const bson::BSONObj &orderby = _sdbStaticObject,
1766  const bson::BSONObj &hint = _sdbStaticObject,
1767  INT64 numToSkip = 0,
1768  INT64 numToReturn = -1 )
1769  \brief Snapshot all of or one of the indexes in current collection
1770  \param [out] cursor The cursor of all the result for current query
1771  \param [in] condition The matching rule, match all the documents if not provided.
1772  \param [in] select The selective rule, return the whole document if not provided.
1773  \param [in] orderBy The ordered rule, result set is unordered if not provided.
1774  \param [in] hint The options provided for specific snapshot type
1775  \param [in] numToSkip Skip the first numToSkip documents, default is 0
1776  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
1777  \retval SDB_OK Operation Success
1778  \retval Others Operation Fail
1779  */
1780  INT32 snapshotIndexes ( _sdbCursor **cursor,
1781  const bson::BSONObj &condition = _sdbStaticObject,
1782  const bson::BSONObj &selector = _sdbStaticObject,
1783  const bson::BSONObj &orderby = _sdbStaticObject,
1784  const bson::BSONObj &hint = _sdbStaticObject,
1785  INT64 numToSkip = 0,
1786  INT64 numToReturn = -1 )
1787  {
1788  if ( !pCollection )
1789  {
1790  return SDB_NOT_CONNECTED ;
1791  }
1792  return pCollection->snapshotIndexes ( cursor, condition,
1793  selector, orderby, hint,
1794  numToSkip, numToReturn ) ;
1795  }
1796 
1797  /* \fn INT32 getIndexes ( _sdbCursor **cursor,
1798  const CHAR *pIndexName )
1799  \brief Get all of or one of the indexes in current collection
1800  \param [in] pIndexName The index name, returns all of the indexes if this parameter is null
1801  \param [out] cursor The cursor of all the result for current query
1802  \retval SDB_OK Operation Success
1803  \retval Others Operation Fail
1804  */
1805  INT32 getIndexes ( _sdbCursor **cursor,
1806  const CHAR *pIndexName )
1807  {
1808  if ( !pCollection )
1809  {
1810  return SDB_NOT_CONNECTED ;
1811  }
1812  return pCollection->getIndexes ( cursor, pIndexName ) ;
1813  }
1814 
1824  INT32 getIndexes ( sdbCursor &cursor,
1825  const CHAR *pIndexName )
1826  {
1827  if ( !pCollection )
1828  {
1829  return SDB_NOT_CONNECTED ;
1830  }
1831  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1832  return pCollection->getIndexes ( cursor, pIndexName ) ;
1833  }
1834 
1841  INT32 getIndexes ( std::vector<bson::BSONObj> &infos )
1842  {
1843  if ( !pCollection )
1844  {
1845  return SDB_NOT_CONNECTED ;
1846  }
1847  return pCollection->getIndexes ( infos ) ;
1848  }
1849 
1857  INT32 getIndex ( const CHAR *pIndexName, bson::BSONObj &info )
1858  {
1859  if ( !pCollection )
1860  {
1861  return SDB_NOT_CONNECTED ;
1862  }
1863  return pCollection->getIndex ( pIndexName, info ) ;
1864  }
1865 
1872  INT32 dropIndex ( const CHAR *pIndexName )
1873  {
1874  if ( !pCollection )
1875  {
1876  return SDB_NOT_CONNECTED ;
1877  }
1878  return pCollection->dropIndex ( pIndexName ) ;
1879  }
1880 
1889  INT32 dropIndexAsync ( SINT64 &taskID, const CHAR *pIndexName )
1890  {
1891  if ( !pCollection )
1892  return SDB_NOT_CONNECTED ;
1893  return pCollection->dropIndexAsync ( taskID, pIndexName ) ;
1894  }
1895 
1904  INT32 copyIndex ( const CHAR *subClFullName, const CHAR *pIndexName )
1905  {
1906  if ( !pCollection )
1907  return SDB_NOT_CONNECTED ;
1908  return pCollection->copyIndex ( subClFullName, pIndexName ) ;
1909  }
1910 
1921  INT32 copyIndexAsync ( SINT64 &taskID, const CHAR *subClFullName,
1922  const CHAR *pIndexName )
1923  {
1924  if ( !pCollection )
1925  return SDB_NOT_CONNECTED ;
1926  return pCollection->copyIndexAsync ( taskID, subClFullName,
1927  pIndexName ) ;
1928  }
1929 
1936  INT32 create ()
1937  {
1938  if ( !pCollection )
1939  {
1940  return SDB_NOT_CONNECTED ;
1941  }
1942  return pCollection->create () ;
1943  }
1944 
1951  INT32 drop ()
1952  {
1953  if ( !pCollection )
1954  {
1955  return SDB_NOT_CONNECTED ;
1956  }
1957  return pCollection->drop () ;
1958  }
1959 
1964  const CHAR *getCollectionName ()
1965  {
1966  if ( !pCollection )
1967  {
1968  return NULL ;
1969  }
1970  return pCollection->getCollectionName () ;
1971  }
1972 
1977  const CHAR *getCSName ()
1978  {
1979  if ( !pCollection )
1980  {
1981  return NULL ;
1982  }
1983  return pCollection->getCSName () ;
1984  }
1985 
1990  const CHAR *getFullName ()
1991  {
1992  if ( !pCollection )
1993  {
1994  return NULL ;
1995  }
1996  return pCollection->getFullName () ;
1997  }
1998 
1999  /* \fn INT32 aggregate ( _sdbCursor **cursor,
2000  std::vector<bson::BSONObj> &obj
2001  )
2002  \brief Execute aggregate operation in specified collection
2003  \param [in] obj The array of bson objects
2004  \param [out] cursor The cursor handle of result
2005  \retval SDB_OK Operation Success
2006  \retval Others Operation Fail
2007  */
2008  INT32 aggregate ( _sdbCursor **cursor,
2009  std::vector<bson::BSONObj> &obj
2010  )
2011  {
2012  if ( !pCollection )
2013  {
2014  return SDB_NOT_CONNECTED ;
2015  }
2016  return pCollection->aggregate ( cursor, obj ) ;
2017  }
2018 
2028  INT32 aggregate ( sdbCursor &cursor,
2029  std::vector<bson::BSONObj> &obj
2030  )
2031  {
2032  if ( !pCollection )
2033  {
2034  return SDB_NOT_CONNECTED ;
2035  }
2036  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2037  return pCollection->aggregate ( cursor, obj ) ;
2038  }
2039 
2040  /* \fn INT32 getQueryMeta ( _sdbCursor **cursor,
2041  const bson::BSONObj &condition = _sdbStaticObject,
2042  const bson::BSONObj &selected = _sdbStaticObject,
2043  const bson::BSONObj &orderBy = _sdbStaticObject,
2044  INT64 numToSkip = 0,
2045  INT64 numToReturn = -1 ) ;
2046  \brief Get the index blocks' or data blocks' infomation for concurrent query
2047  \param [in] condition The matching rule, return all the documents if not provided
2048  \param [in] orderBy The ordered rule, result set is unordered if not provided
2049  \param [in] hint Specified the index used to scan data. e.g. {"":"ageIndex"} means
2050  using index "ageIndex" to scan data(index scan);
2051  {"":null} means table scan. when hint is not provided,
2052  database automatically match the optimal index to scan data
2053  \param [in] numToSkip Skip the first numToSkip documents, default is 0
2054  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
2055  \param [out] cursor The cursor of current query
2056  \retval SDB_OK Operation Success
2057  \retval Others Operation Fail
2058  */
2059  INT32 getQueryMeta ( _sdbCursor **cursor,
2060  const bson::BSONObj &condition = _sdbStaticObject,
2061  const bson::BSONObj &orderBy = _sdbStaticObject,
2062  const bson::BSONObj &hint = _sdbStaticObject,
2063  INT64 numToSkip = 0,
2064  INT64 numToReturn = -1 )
2065  {
2066  if ( !pCollection )
2067  {
2068  return SDB_NOT_CONNECTED ;
2069  }
2070  return pCollection->getQueryMeta ( cursor, condition, orderBy,
2071  hint, numToSkip, numToReturn ) ;
2072  }
2073 
2094  INT32 getQueryMeta ( sdbCursor &cursor,
2095  const bson::BSONObj &condition = _sdbStaticObject,
2096  const bson::BSONObj &orderBy = _sdbStaticObject,
2097  const bson::BSONObj &hint = _sdbStaticObject,
2098  INT64 numToSkip = 0,
2099  INT64 numToReturn = -1 )
2100  {
2101  if ( !pCollection )
2102  {
2103  return SDB_NOT_CONNECTED ;
2104  }
2105  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2106  return pCollection->getQueryMeta ( cursor, condition, orderBy,
2107  hint, numToSkip, numToReturn ) ;
2108  }
2109 
2123  INT32 attachCollection ( const CHAR *subClFullName,
2124  const bson::BSONObj &options )
2125  {
2126  if ( !pCollection )
2127  {
2128  return SDB_NOT_CONNECTED ;
2129  }
2130  return pCollection->attachCollection ( subClFullName, options ) ;
2131  }
2132 
2139  INT32 detachCollection ( const CHAR *subClFullName )
2140  {
2141  if ( !pCollection )
2142  {
2143  return SDB_NOT_CONNECTED ;
2144  }
2145  return pCollection->detachCollection ( subClFullName ) ;
2146  }
2147 
2183  INT32 explain ( sdbCursor &cursor,
2184  const bson::BSONObj &condition = _sdbStaticObject,
2185  const bson::BSONObj &select = _sdbStaticObject,
2186  const bson::BSONObj &orderBy = _sdbStaticObject,
2187  const bson::BSONObj &hint = _sdbStaticObject,
2188  INT64 numToSkip = 0,
2189  INT64 numToReturn = -1,
2190  INT32 flag = 0,
2191  const bson::BSONObj &options = _sdbStaticObject )
2192  {
2193  if ( !pCollection )
2194  {
2195  return SDB_NOT_CONNECTED ;
2196  }
2197  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2198  return pCollection->explain( cursor, condition, select, orderBy, hint,
2199  numToSkip, numToReturn, flag, options ) ;
2200  }
2201 
2202  INT32 explain ( _sdbCursor **cursor,
2203  const bson::BSONObj &condition = _sdbStaticObject,
2204  const bson::BSONObj &select = _sdbStaticObject,
2205  const bson::BSONObj &orderBy = _sdbStaticObject,
2206  const bson::BSONObj &hint = _sdbStaticObject,
2207  INT64 numToSkip = 0,
2208  INT64 numToReturn = -1,
2209  INT32 flag = 0,
2210  const bson::BSONObj &options = _sdbStaticObject )
2211  {
2212  if ( !pCollection )
2213  {
2214  return SDB_NOT_CONNECTED ;
2215  }
2216  return pCollection->explain( cursor, condition, select, orderBy, hint,
2217  numToSkip, numToReturn, flag, options ) ;
2218  }
2219 
2228  INT32 createLob( sdbLob &lob, const bson::OID *oid = NULL )
2229  {
2230  if ( !pCollection )
2231  {
2232  return SDB_NOT_CONNECTED ;
2233  }
2234  return pCollection->createLob( lob, oid ) ;
2235  }
2236 
2243  INT32 removeLob( const bson::OID &oid )
2244  {
2245  if ( !pCollection )
2246  {
2247  return SDB_NOT_CONNECTED ;
2248  }
2249  return pCollection->removeLob( oid ) ;
2250  }
2251 
2259  INT32 truncateLob( const bson::OID &oid, INT64 length )
2260  {
2261  if ( !pCollection )
2262  {
2263  return SDB_NOT_CONNECTED ;
2264  }
2265  return pCollection->truncateLob( oid, length ) ;
2266  }
2267 
2277  INT32 openLob( sdbLob &lob, const bson::OID &oid,
2279  {
2280  if ( !pCollection )
2281  {
2282  return SDB_NOT_CONNECTED ;
2283  }
2284  return pCollection->openLob( lob, oid, mode ) ;
2285  }
2286 
2296  INT32 openLob( sdbLob &lob, const bson::OID &oid, INT32 mode )
2297  {
2298  if ( !pCollection )
2299  {
2300  return SDB_NOT_CONNECTED ;
2301  }
2302  return pCollection->openLob( lob, oid, mode ) ;
2303  }
2304 
2322  INT32 listLobs( sdbCursor &cursor,
2323  const bson::BSONObj &condition = _sdbStaticObject,
2324  const bson::BSONObj &selected = _sdbStaticObject,
2325  const bson::BSONObj &orderBy = _sdbStaticObject,
2326  const bson::BSONObj &hint = _sdbStaticObject,
2327  INT64 numToSkip = 0,
2328  INT64 numToReturn = -1 )
2329  {
2330  if ( !pCollection )
2331  {
2332  return SDB_NOT_CONNECTED ;
2333  }
2334  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2335  return pCollection->listLobs( cursor, condition, selected, orderBy,
2336  hint, numToSkip, numToReturn ) ;
2337  }
2338 
2339  INT32 listLobs( _sdbCursor **cursor,
2340  const bson::BSONObj &condition = _sdbStaticObject,
2341  const bson::BSONObj &selected = _sdbStaticObject,
2342  const bson::BSONObj &orderBy = _sdbStaticObject,
2343  const bson::BSONObj &hint = _sdbStaticObject,
2344  INT64 numToSkip = 0,
2345  INT64 numToReturn = -1 )
2346  {
2347  if ( !pCollection )
2348  {
2349  return SDB_NOT_CONNECTED ;
2350  }
2351  return pCollection->listLobs( cursor, condition, selected, orderBy,
2352  hint, numToSkip, numToReturn ) ;
2353  }
2354 
2363  INT32 createLobID( bson::OID &oid, const CHAR *pTimeStamp = NULL )
2364  {
2365  if ( !pCollection )
2366  {
2367  return SDB_NOT_CONNECTED ;
2368  }
2369  return pCollection->createLobID( oid, pTimeStamp ) ;
2370  }
2371 
2379  INT32 truncate( const bson::BSONObj &options = _sdbStaticObject )
2380  {
2381  if ( !pCollection )
2382  {
2383  return SDB_NOT_CONNECTED ;
2384  }
2385  return pCollection->truncate( options ) ;
2386  }
2387 
2397  INT32 createIdIndex( const bson::BSONObj &options = _sdbStaticObject )
2398  {
2399  if ( !pCollection )
2400  {
2401  return SDB_NOT_CONNECTED ;
2402  }
2403  return pCollection->createIdIndex( options ) ;
2404  }
2405 
2412  INT32 dropIdIndex()
2413  {
2414  if ( !pCollection )
2415  {
2416  return SDB_NOT_CONNECTED ;
2417  }
2418  return pCollection->dropIdIndex() ;
2419  }
2420 
2438  INT32 createAutoIncrement ( const bson::BSONObj &options )
2439  {
2440  if ( !pCollection )
2441  {
2442  return SDB_NOT_CONNECTED ;
2443  }
2444  return pCollection->createAutoIncrement( options ) ;
2445  }
2446 
2453  INT32 createAutoIncrement ( const std::vector<bson::BSONObj> &options )
2454  {
2455  if ( !pCollection )
2456  {
2457  return SDB_NOT_CONNECTED ;
2458  }
2459  return pCollection->createAutoIncrement( options ) ;
2460  }
2461 
2468  INT32 dropAutoIncrement ( const CHAR * fieldName )
2469  {
2470  if ( !pCollection )
2471  {
2472  return SDB_NOT_CONNECTED ;
2473  }
2474  return pCollection->dropAutoIncrement( fieldName ) ;
2475  }
2476 
2483  INT32 dropAutoIncrement ( const std::vector<const CHAR*> &fieldNames )
2484  {
2485  if ( !pCollection )
2486  {
2487  return SDB_NOT_CONNECTED ;
2488  }
2489  return pCollection->dropAutoIncrement( fieldNames ) ;
2490  }
2491 
2505  INT32 enableSharding ( const bson::BSONObj & options = _sdbStaticObject )
2506  {
2507  if ( !pCollection )
2508  {
2509  return SDB_NOT_CONNECTED ;
2510  }
2511  return pCollection->enableSharding( options ) ;
2512  }
2513 
2519  INT32 disableSharding ()
2520  {
2521  if ( !pCollection )
2522  {
2523  return SDB_NOT_CONNECTED ;
2524  }
2525  return pCollection->disableSharding() ;
2526  }
2527 
2536  INT32 enableCompression ( const bson::BSONObj & options = _sdbStaticObject )
2537  {
2538  if ( !pCollection )
2539  {
2540  return SDB_NOT_CONNECTED ;
2541  }
2542  return pCollection->enableCompression( options ) ;
2543  }
2544 
2550  INT32 disableCompression ()
2551  {
2552  if ( !pCollection )
2553  {
2554  return SDB_NOT_CONNECTED ;
2555  }
2556  return pCollection->disableCompression() ;
2557  }
2558 
2579  INT32 setAttributes ( const bson::BSONObj &options )
2580  {
2581  if ( !pCollection )
2582  {
2583  return SDB_NOT_CONNECTED ;
2584  }
2585  return pCollection->setAttributes( options ) ;
2586  }
2587 
2588  /* \fn INT32 pop( const bson::BSONObj &option )
2589  \brief Pop records from a capped collection
2590  \param [in] option The pop options as follows:
2591 
2592  Direction : The direction to pop record. 1: pop forward. -1: pop backward.
2593  The default value is 1.
2594  \retval SDB_OK Operation Success
2595  \retval Others Operation Fail
2596  */
2597  INT32 pop ( const bson::BSONObj &option = _sdbStaticObject )
2598  {
2599  if ( !pCollection )
2600  {
2601  return SDB_NOT_CONNECTED ;
2602  }
2603  return pCollection->pop( option ) ;
2604  }
2605 
2606  INT32 listLobPieces( _sdbCursor **cursor,
2607  const bson::BSONObj &condition = _sdbStaticObject,
2608  const bson::BSONObj &selected = _sdbStaticObject,
2609  const bson::BSONObj &orderBy = _sdbStaticObject,
2610  const bson::BSONObj &hint = _sdbStaticObject,
2611  INT64 numToSkip = 0,
2612  INT64 numToReturn = -1 )
2613  {
2614  if( !pCollection )
2615  {
2616  return SDB_NOT_CONNECTED ;
2617  }
2618  return pCollection->listLobPieces( cursor, condition, selected,
2619  orderBy, hint, numToSkip,
2620  numToReturn ) ;
2621  }
2622 
2636  INT32 listLobPieces( sdbCursor &cursor,
2637  const bson::BSONObj &condition = _sdbStaticObject,
2638  const bson::BSONObj &selected = _sdbStaticObject,
2639  const bson::BSONObj &orderBy = _sdbStaticObject,
2640  const bson::BSONObj &hint = _sdbStaticObject,
2641  INT64 numToSkip = 0,
2642  INT64 numToReturn = -1 )
2643  {
2644  if( !pCollection )
2645  {
2646  return SDB_NOT_CONNECTED ;
2647  }
2648  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2649  return pCollection->listLobPieces( cursor, condition, selected,
2650  orderBy, hint, numToSkip,
2651  numToReturn ) ;
2652  }
2653 
2654  /* \fn INT32 getDetail ( _sdbCursor **cursor )
2655  \brief Get the detail of the collection.
2656  \param [out] cursor Return the all the info of current collection.
2657  \retval SDB_OK Operation Success
2658  \retval Others Operation Fail
2659  */
2660  INT32 getDetail ( _sdbCursor **cursor )
2661  {
2662  if ( !pCollection )
2663  {
2664  return SDB_NOT_CONNECTED ;
2665  }
2666  return pCollection->getDetail ( cursor ) ;
2667  }
2668 
2675  INT32 getDetail( sdbCursor &cursor )
2676  {
2677  if ( !pCollection)
2678  {
2679  return SDB_NOT_CONNECTED ;
2680  }
2681  return pCollection->getDetail( cursor ) ;
2682  }
2683 
2690  INT32 getCollectionStat( bson::BSONObj &result )
2691  {
2692  if( !pCollection )
2693  {
2694  return SDB_NOT_CONNECTED ;
2695  }
2696  return pCollection->getCollectionStat( result ) ;
2697  }
2698 
2708  INT32 getIndexStat( const CHAR *pIndexName, bson::BSONObj &result,
2709  BOOLEAN detail = FALSE )
2710  {
2711  if ( !pCollection )
2712  {
2713  return SDB_NOT_CONNECTED ;
2714  }
2715  return pCollection->getIndexStat( pIndexName, result, detail ) ;
2716  }
2717 
2718  /* \fn void setVersion ( INT32 clVersion )
2719  \brief set version to collection.
2720  \param [in] clVersion The collection version.
2721  */
2722  void setVersion( INT32 clVersion )
2723  {
2724  pCollection->setVersion( clVersion ) ;
2725  }
2726  /* \fn INT32 getVersion ()
2727  \brief get version from collection.
2728  \retval collection version.
2729  */
2730  INT32 getVersion()
2731  {
2732  return pCollection->getVersion() ;
2733  }
2734  } ;
2735 
2740  {
2741  SDB_NODE_ALL = 0,
2742  SDB_NODE_ACTIVE,
2743  SDB_NODE_INACTIVE,
2744  SDB_NODE_UNKNOWN
2745  } ;
2746 
2750  typedef enum sdbNodeStatus sdbNodeStatus ;
2751 
2752  class DLLEXPORT _sdbNode
2753  {
2754  private :
2755  _sdbNode ( const _sdbNode& other ) ;
2756  _sdbNode& operator=( const _sdbNode& ) ;
2757  public :
2758  _sdbNode () {}
2759  virtual ~_sdbNode () {}
2760  // connect to the current node
2761  virtual INT32 connect ( _sdb **dbConn ) = 0 ;
2762  virtual INT32 connect ( sdb &dbConn ) = 0 ;
2763 
2764  // get status of the current node
2765  virtual sdbNodeStatus getStatus () = 0 ;
2766 
2767  // get host name of the current node
2768  virtual const CHAR *getHostName () = 0 ;
2769 
2770  // get service name of the current node
2771  virtual const CHAR *getServiceName () = 0 ;
2772 
2773  // get node name of the current node
2774  virtual const CHAR *getNodeName () = 0 ;
2775 
2776  // get node id of the current node
2777  virtual INT32 getNodeID( INT32 &nodeID ) const = 0 ;
2778 
2779  // stop the node
2780  virtual INT32 stop () = 0 ;
2781 
2782  // start the node
2783  virtual INT32 start () = 0 ;
2784 
2785  // modify config for the current node
2786 /* virtual INT32 modifyConfig ( std::map<std::string,std::string>
2787  &config ) = 0 ; */
2788  } ;
2789 
2796  class DLLEXPORT sdbNode
2797  {
2798  private :
2803  sdbNode ( const sdbNode& other ) ;
2804 
2810  sdbNode& operator=( const sdbNode& ) ;
2811  public :
2818  _sdbNode *pNode ;
2819 
2824  {
2825  pNode = NULL ;
2826  }
2827 
2832  {
2833  if ( pNode )
2834  {
2835  delete pNode ;
2836  }
2837  }
2838 
2839  INT32 connect ( _sdb **dbConn )
2840  {
2841  if ( !pNode )
2842  {
2843  return SDB_NOT_CONNECTED ;
2844  }
2845  return pNode->connect ( dbConn ) ;
2846  }
2847 
2855  INT32 connect ( sdb &dbConn )
2856  {
2857  if ( !pNode )
2858  {
2859  return SDB_NOT_CONNECTED ;
2860  }
2861  // we can not use dbConn.pSDB here,
2862  // for sdb had not define yet.
2863  // RELEASE_INNER_HANDLE( dbConn.pSDB ) ;
2864  return pNode->connect ( dbConn ) ;
2865  }
2866 
2873  sdbNodeStatus getStatus ()
2874  {
2875  if ( !pNode )
2876  {
2877  return SDB_NODE_UNKNOWN ;
2878  }
2879  return pNode->getStatus () ;
2880  }
2881 
2886  const CHAR *getHostName ()
2887  {
2888  if ( !pNode )
2889  {
2890  return NULL ;
2891  }
2892  return pNode->getHostName () ;
2893  }
2894 
2899  const CHAR *getServiceName ()
2900  {
2901  if ( !pNode )
2902  {
2903  return NULL ;
2904  }
2905  return pNode->getServiceName () ;
2906  }
2907 
2912  const CHAR *getNodeName ()
2913  {
2914  if ( !pNode )
2915  {
2916  return NULL ;
2917  }
2918  return pNode->getNodeName () ;
2919  }
2920 
2925  INT32 getNodeID( INT32 &nodeID ) const
2926  {
2927  if ( !pNode )
2928  {
2929  return SDB_NOT_CONNECTED ;
2930  }
2931  return pNode->getNodeID( nodeID ) ;
2932  }
2933 
2939  INT32 stop ()
2940  {
2941  if ( !pNode )
2942  {
2943  return SDB_NOT_CONNECTED ;
2944  }
2945  return pNode->stop () ;
2946  }
2947 
2953  INT32 start ()
2954  {
2955  if ( !pNode )
2956  {
2957  return SDB_NOT_CONNECTED ;
2958  }
2959  return pNode->start () ;
2960  }
2961 /* INT32 modifyConfig ( std::map<std::string,std::string> &config )
2962  {
2963  if ( !pNode )
2964  {
2965  return NULL ;
2966  }
2967  return pNode->modifyConfig ( config ) ;
2968  }*/
2969  } ;
2970 
2971  class DLLEXPORT _sdbReplicaGroup
2972  {
2973  private :
2974  _sdbReplicaGroup ( const _sdbReplicaGroup& other ) ;
2975  _sdbReplicaGroup& operator=( const _sdbReplicaGroup& ) ;
2976  public :
2977  _sdbReplicaGroup () {}
2978  virtual ~_sdbReplicaGroup () {}
2979  // get number of logical nodes
2980  virtual INT32 getNodeNum ( sdbNodeStatus status, INT32 *num ) = 0 ;
2981 
2982  // get detailed information for the set
2983  virtual INT32 getDetail ( bson::BSONObj &result ) = 0 ;
2984 
2985  // get the master node
2986  virtual INT32 getMaster ( _sdbNode **node ) = 0 ;
2987  virtual INT32 getMaster ( sdbNode &node ) = 0 ;
2988 
2989  // get one of the slave node
2990  virtual INT32 getSlave ( _sdbNode **node,
2991  const vector<INT32>& positions = _sdbStaticVec ) = 0 ;
2992  virtual INT32 getSlave ( sdbNode &node,
2993  const vector<INT32>& positions = _sdbStaticVec ) = 0 ;
2994 
2995  // get a given node by name
2996  virtual INT32 getNode ( const CHAR *pNodeName,
2997  _sdbNode **node ) = 0 ;
2998  virtual INT32 getNode ( const CHAR *pNodeName,
2999  sdbNode &node ) = 0 ;
3000 
3001  // get a given node by host/service name
3002  virtual INT32 getNode ( const CHAR *pHostName,
3003  const CHAR *pServiceName,
3004  _sdbNode **node ) = 0 ;
3005  virtual INT32 getNode ( const CHAR *pHostName,
3006  const CHAR *pServiceName,
3007  sdbNode &node ) = 0 ;
3008 
3009  // create a new node in current replica group
3010  virtual INT32 createNode ( const CHAR *pHostName,
3011  const CHAR *pServiceName,
3012  const CHAR *pDatabasePath,
3013  std::map<std::string,std::string> &config )= 0;
3014 
3015  virtual INT32 createNode ( const CHAR *pHostName,
3016  const CHAR *pServiceName,
3017  const CHAR *pDatabasePath,
3018  const bson::BSONObj &options = _sdbStaticObject )= 0;
3019 
3020  // remove the specified node in current replica group
3021  virtual INT32 removeNode ( const CHAR *pHostName,
3022  const CHAR *pServiceName,
3023  const bson::BSONObj &configure = _sdbStaticObject ) = 0 ;
3024  // stop the replica group
3025  virtual INT32 stop () = 0 ;
3026 
3027  // start the replica group
3028  virtual INT32 start () = 0 ;
3029 
3030  // get the replica group name
3031  virtual const CHAR *getName () = 0 ;
3032 
3033  // whether the current replica group is catalog replica group or not
3034  virtual BOOLEAN isCatalog () = 0 ;
3035 
3036  // attach node
3037  virtual INT32 attachNode( const CHAR *pHostName,
3038  const CHAR *pSvcName,
3039  const bson::BSONObj &options ) = 0 ;
3040 
3041  // detach node
3042  virtual INT32 detachNode( const CHAR *pHostName,
3043  const CHAR *pSvcName,
3044  const bson::BSONObj &options ) = 0 ;
3045 
3046  // reelect primary node
3047  virtual INT32 reelect( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
3048  } ;
3049 
3053  class DLLEXPORT sdbReplicaGroup
3054  {
3055  private :
3056  sdbReplicaGroup ( const sdbReplicaGroup& other ) ;
3057  sdbReplicaGroup& operator=( const sdbReplicaGroup& ) ;
3058  public :
3065  _sdbReplicaGroup *pReplicaGroup ;
3066 
3071  {
3072  pReplicaGroup = NULL ;
3073  }
3074 
3079  {
3080  if ( pReplicaGroup )
3081  {
3082  delete pReplicaGroup ;
3083  }
3084  }
3085 
3100  INT32 getNodeNum ( sdbNodeStatus status, INT32 *num )
3101  {
3102  if ( !pReplicaGroup )
3103  {
3104  return SDB_NOT_CONNECTED ;
3105  }
3106  return pReplicaGroup->getNodeNum ( status, num ) ;
3107  }
3108 
3115  INT32 getDetail ( bson::BSONObj &result )
3116  {
3117  if ( !pReplicaGroup )
3118  {
3119  return SDB_NOT_CONNECTED ;
3120  }
3121  return pReplicaGroup->getDetail ( result ) ;
3122  }
3123 
3124  /* \fn INT32 getMaster ( _sdbNode **node )
3125  \brief Get the master node of the current replica group.
3126  \param [out] node The master node.If not exit,return null.
3127  \retval SDB_OK Operation Success
3128  \retval Others Operation Fail
3129  */
3130  INT32 getMaster ( _sdbNode **node )
3131  {
3132  if ( !pReplicaGroup )
3133  {
3134  return SDB_NOT_CONNECTED ;
3135  }
3136  return pReplicaGroup->getMaster ( node ) ;
3137  }
3138 
3145  INT32 getMaster ( sdbNode &node )
3146  {
3147  if ( !pReplicaGroup )
3148  {
3149  return SDB_NOT_CONNECTED ;
3150  }
3151  RELEASE_INNER_HANDLE( node.pNode ) ;
3152  return pReplicaGroup->getMaster ( node ) ;
3153  }
3154 
3155  /* \fn INT32 getSlave ( _sdbNode **node, const vector<INT32>& positions )
3156  \brief Get one of slave node of the current replica group,
3157  if no slave exists then get master
3158  \param [in] positions The positions of nodes
3159  \param [out] node The slave node
3160  \retval SDB_OK Operation Success
3161  \retval Others Operation Fail
3162  */
3163  INT32 getSlave ( _sdbNode **node,
3164  const vector<INT32>& positions = _sdbStaticVec )
3165  {
3166  if ( !pReplicaGroup )
3167  {
3168  return SDB_NOT_CONNECTED ;
3169  }
3170  return pReplicaGroup->getSlave ( node, positions ) ;
3171  }
3172 
3181  INT32 getSlave ( sdbNode &node,
3182  const vector<INT32>& positions = _sdbStaticVec )
3183  {
3184  if ( !pReplicaGroup )
3185  {
3186  return SDB_NOT_CONNECTED ;
3187  }
3188  RELEASE_INNER_HANDLE( node.pNode ) ;
3189  return pReplicaGroup->getSlave ( node, positions ) ;
3190  }
3191 
3192  /* \fn INT32 getNode ( const CHAR *pNodeName,
3193  _sdbNode **node )
3194  \brief Get specified node from current replica group.
3195  \param [in] pNodeName The name of the node, with the format of "hostname:port".
3196  \param [out] node The specified node
3197  \retval SDB_OK Operation Success
3198  \retval Others Operation Fail
3199  */
3200  INT32 getNode ( const CHAR *pNodeName,
3201  _sdbNode **node )
3202  {
3203  if ( !pReplicaGroup )
3204  {
3205  return SDB_NOT_CONNECTED ;
3206  }
3207  return pReplicaGroup->getNode ( pNodeName, node ) ;
3208  }
3209 
3218  INT32 getNode ( const CHAR *pNodeName,
3219  sdbNode &node )
3220  {
3221  if ( !pReplicaGroup )
3222  {
3223  return SDB_NOT_CONNECTED ;
3224  }
3225  RELEASE_INNER_HANDLE( node.pNode ) ;
3226  return pReplicaGroup->getNode ( pNodeName, node ) ;
3227  }
3228 
3229  INT32 getNode ( const CHAR *pHostName,
3230  const CHAR *pServiceName,
3231  _sdbNode **node )
3232  {
3233  if ( !pReplicaGroup )
3234  {
3235  return SDB_NOT_CONNECTED ;
3236  }
3237  return pReplicaGroup->getNode ( pHostName, pServiceName, node ) ;
3238  }
3239 
3250  INT32 getNode ( const CHAR *pHostName,
3251  const CHAR *pServiceName,
3252  sdbNode &node )
3253  {
3254  if ( !pReplicaGroup )
3255  {
3256  return SDB_NOT_CONNECTED ;
3257  }
3258  RELEASE_INNER_HANDLE( node.pNode ) ;
3259  return pReplicaGroup->getNode ( pHostName, pServiceName, node ) ;
3260  }
3261 
3275  INT32 createNode ( const CHAR *pHostName,
3276  const CHAR *pServiceName,
3277  const CHAR *pDatabasePath,
3278  std::map<std::string,std::string> &config )
3279  {
3280  if ( !pReplicaGroup )
3281  {
3282  return SDB_NOT_CONNECTED ;
3283  }
3284  return pReplicaGroup->createNode ( pHostName, pServiceName,
3285  pDatabasePath, config ) ;
3286  }
3287 
3300  INT32 createNode ( const CHAR *pHostName,
3301  const CHAR *pServiceName,
3302  const CHAR *pDatabasePath,
3303  const bson::BSONObj &options = _sdbStaticObject )
3304  {
3305  if ( !pReplicaGroup )
3306  {
3307  return SDB_NOT_CONNECTED ;
3308  }
3309  return pReplicaGroup->createNode ( pHostName, pServiceName,
3310  pDatabasePath, options ) ;
3311  }
3312 
3323  INT32 removeNode ( const CHAR *pHostName,
3324  const CHAR *pServiceName,
3325  const bson::BSONObj &configure = _sdbStaticObject )
3326  {
3327  if ( !pReplicaGroup )
3328  {
3329  return SDB_NOT_CONNECTED ;
3330  }
3331  return pReplicaGroup->removeNode ( pHostName, pServiceName,
3332  configure ) ;
3333  }
3339  INT32 stop ()
3340  {
3341  if ( !pReplicaGroup )
3342  {
3343  return SDB_NOT_CONNECTED ;
3344  }
3345  return pReplicaGroup->stop () ;
3346  }
3347 
3353  INT32 start ()
3354  {
3355  if ( !pReplicaGroup )
3356  {
3357  return SDB_NOT_CONNECTED ;
3358  }
3359  return pReplicaGroup->start () ;
3360  }
3361 
3366  const CHAR *getName ()
3367  {
3368  if ( !pReplicaGroup )
3369  {
3370  return NULL ;
3371  }
3372  return pReplicaGroup->getName() ;
3373  }
3374 
3380  BOOLEAN isCatalog ()
3381  {
3382  if ( !pReplicaGroup )
3383  {
3384  return FALSE ;
3385  }
3386  return pReplicaGroup->isCatalog() ;
3387  }
3388 
3403  INT32 attachNode( const CHAR *pHostName,
3404  const CHAR *pSvcName,
3405  const bson::BSONObj &options )
3406  {
3407  if ( !pReplicaGroup )
3408  {
3409  return SDB_NOT_CONNECTED ;
3410  }
3411  return pReplicaGroup->attachNode( pHostName, pSvcName, options ) ;
3412  }
3413 
3429  INT32 detachNode( const CHAR *pHostName,
3430  const CHAR *pSvcName,
3431  const bson::BSONObj &options )
3432  {
3433  if ( !pReplicaGroup )
3434  {
3435  return SDB_NOT_CONNECTED ;
3436  }
3437  return pReplicaGroup->detachNode( pHostName, pSvcName, options ) ;
3438  }
3439 
3448  INT32 reelect( const bson::BSONObj &options = _sdbStaticObject )
3449  {
3450  if( !pReplicaGroup )
3451  {
3452  return SDB_NOT_CONNECTED ;
3453  }
3454  return pReplicaGroup->reelect( options ) ;
3455  }
3456  } ;
3457 
3458  class DLLEXPORT _sdbCollectionSpace
3459  {
3460  private :
3461  _sdbCollectionSpace ( const _sdbCollectionSpace& other ) ;
3462  _sdbCollectionSpace& operator=( const _sdbCollectionSpace& ) ;
3463  public :
3464  _sdbCollectionSpace () {}
3465  virtual ~_sdbCollectionSpace () {}
3466  // get a collection object
3467  virtual INT32 getCollection ( const CHAR *pCollectionName,
3468  _sdbCollection **collection,
3469  BOOLEAN checkExist = TRUE ) = 0 ;
3470 
3471  virtual INT32 getCollection ( const CHAR *pCollectionName,
3472  sdbCollection &collection,
3473  BOOLEAN checkExist = TRUE ) = 0 ;
3474 
3475  // create a new collection object with options
3476  virtual INT32 createCollection ( const CHAR *pCollection,
3477  const bson::BSONObj &options,
3478  _sdbCollection **collection ) = 0 ;
3479 
3480  virtual INT32 createCollection ( const CHAR *pCollection,
3481  const bson::BSONObj &options,
3482  sdbCollection &collection ) = 0 ;
3483 
3484  // create a new collection object
3485  virtual INT32 createCollection ( const CHAR *pCollection,
3486  _sdbCollection **collection ) = 0 ;
3487 
3488  virtual INT32 createCollection ( const CHAR *pCollection,
3489  sdbCollection &collection ) = 0 ;
3490 
3491  // drop an existing collection with options
3492  virtual INT32 dropCollection( const CHAR *pCollection,
3493  const bson::BSONObj &options ) = 0 ;
3494 
3495  virtual INT32 listCollections ( _sdbCursor **cursor ) = 0 ;
3496 
3497  virtual INT32 listCollections ( sdbCursor &cursor ) = 0 ;
3498 
3499  // create a collection space with current collection space name
3500  virtual INT32 create () = 0 ;
3501  // drop a collection space with current collection space name
3502  virtual INT32 drop () = 0 ;
3503 
3504  // get the collectonSpace's name
3505  virtual const CHAR *getCSName () = 0 ;
3506 
3507  // rename collection
3508  virtual INT32 renameCollection( const CHAR* oldName, const CHAR* newName,
3509  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
3510 
3511  virtual INT32 alterCollectionSpace ( const bson::BSONObj & options ) = 0 ;
3512 
3513  virtual INT32 setDomain ( const bson::BSONObj & options ) = 0 ;
3514 
3515  virtual INT32 getDomainName ( CHAR *result, INT32 resultLen ) = 0 ;
3516 
3517  virtual INT32 removeDomain () = 0 ;
3518 
3519  virtual INT32 enableCapped () = 0 ;
3520 
3521  virtual INT32 disableCapped () = 0 ;
3522 
3523  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
3524  } ;
3528  class DLLEXPORT sdbCollectionSpace
3529  {
3530  private :
3535  sdbCollectionSpace ( const sdbCollectionSpace& other ) ;
3536 
3542  sdbCollectionSpace& operator=( const sdbCollectionSpace& ) ;
3543  public :
3550  _sdbCollectionSpace *pCollectionSpace ;
3551 
3556  {
3557  pCollectionSpace = NULL ;
3558  }
3559 
3564  {
3565  if ( pCollectionSpace )
3566  {
3567  delete pCollectionSpace ;
3568  }
3569  }
3570 
3571  INT32 getCollection ( const CHAR *pCollectionName,
3572  _sdbCollection **collection,
3573  BOOLEAN checkExist = TRUE )
3574  {
3575  if ( !pCollectionSpace )
3576  {
3577  return SDB_NOT_CONNECTED ;
3578  }
3579  return pCollectionSpace->getCollection ( pCollectionName,
3580  collection, checkExist ) ;
3581  }
3582 
3593  INT32 getCollection ( const CHAR *pCollectionName,
3594  sdbCollection &collection,
3595  BOOLEAN checkExist = TRUE )
3596  {
3597  if ( !pCollectionSpace )
3598  {
3599  return SDB_NOT_CONNECTED ;
3600  }
3601  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3602  return pCollectionSpace->getCollection ( pCollectionName,
3603  collection,
3604  checkExist ) ;
3605  }
3606 
3607  INT32 createCollection ( const CHAR *pCollection,
3608  const bson::BSONObj &options,
3609  _sdbCollection **collection )
3610  {
3611  if ( !pCollectionSpace )
3612  {
3613  return SDB_NOT_CONNECTED ;
3614  }
3615  return pCollectionSpace->createCollection ( pCollection,
3616  options,
3617  collection ) ;
3618  }
3619 
3657  INT32 createCollection ( const CHAR *pCollection,
3658  const bson::BSONObj &options,
3659  sdbCollection &collection )
3660  {
3661  if ( !pCollectionSpace )
3662  {
3663  return SDB_NOT_CONNECTED ;
3664  }
3665  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3666  return pCollectionSpace->createCollection ( pCollection,
3667  options,
3668  collection ) ;
3669  }
3670 
3671  INT32 createCollection ( const CHAR *pCollection,
3672  _sdbCollection **collection )
3673  {
3674  if ( !pCollectionSpace )
3675  {
3676  return SDB_NOT_CONNECTED ;
3677  }
3678  return pCollectionSpace->createCollection ( pCollection,
3679  collection ) ;
3680  }
3681 
3691  INT32 createCollection ( const CHAR *pCollection,
3692  sdbCollection &collection )
3693  {
3694  if ( !pCollectionSpace )
3695  {
3696  return SDB_NOT_CONNECTED ;
3697  }
3698  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3699  return pCollectionSpace->createCollection ( pCollection,
3700  collection ) ;
3701  }
3702 
3712  INT32 dropCollection( const CHAR *pCollection,
3713  const bson::BSONObj &options = _sdbStaticObject )
3714  {
3715  if ( !pCollectionSpace )
3716  {
3717  return SDB_NOT_CONNECTED ;
3718  }
3719  return pCollectionSpace->dropCollection( pCollection, options ) ;
3720  }
3721 
3728  INT32 listCollections ( _sdbCursor **cursor )
3729  {
3730  if ( !pCollectionSpace )
3731  {
3732  return SDB_NOT_CONNECTED ;
3733  }
3734  return pCollectionSpace->listCollections( cursor ) ;
3735  }
3736 
3743  INT32 listCollections ( sdbCursor &cursor )
3744  {
3745  if ( !pCollectionSpace )
3746  {
3747  return SDB_NOT_CONNECTED ;
3748  }
3749  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
3750  return pCollectionSpace->listCollections( cursor ) ;
3751  }
3752 
3759  INT32 create ()
3760  {
3761  if ( !pCollectionSpace )
3762  {
3763  return SDB_NOT_CONNECTED ;
3764  }
3765  return pCollectionSpace->create () ;
3766  }
3767 
3774  INT32 drop ()
3775  {
3776  if ( !pCollectionSpace )
3777  {
3778  return SDB_NOT_CONNECTED ;
3779  }
3780  return pCollectionSpace->drop () ;
3781  }
3782 
3787  const CHAR *getCSName ()
3788  {
3789  if ( !pCollectionSpace )
3790  {
3791  return NULL ;
3792  }
3793  return pCollectionSpace->getCSName () ;
3794  }
3795 
3806  INT32 renameCollection( const CHAR* oldName, const CHAR* newName,
3807  const bson::BSONObj &options = _sdbStaticObject )
3808  {
3809  if( !pCollectionSpace )
3810  {
3811  return SDB_NOT_CONNECTED ;
3812  }
3813  return pCollectionSpace->renameCollection( oldName, newName, options ) ;
3814  }
3815 
3827  INT32 alterCollectionSpace ( const bson::BSONObj & options )
3828  {
3829  if ( NULL == pCollectionSpace )
3830  {
3831  return SDB_NOT_CONNECTED ;
3832  }
3833  return pCollectionSpace->alterCollectionSpace( options ) ;
3834  }
3835 
3845  INT32 setDomain ( const bson::BSONObj & options )
3846  {
3847  if ( NULL == pCollectionSpace )
3848  {
3849  return SDB_NOT_CONNECTED ;
3850  }
3851  return pCollectionSpace->setDomain( options ) ;
3852  }
3853 
3861  INT32 getDomainName ( CHAR *result, INT32 resultLen )
3862  {
3863  if ( !pCollectionSpace )
3864  {
3865  return SDB_NOT_CONNECTED ;
3866  }
3867  return pCollectionSpace->getDomainName( result, resultLen ) ;
3868  }
3869 
3875  INT32 removeDomain ()
3876  {
3877  if ( NULL == pCollectionSpace )
3878  {
3879  return SDB_NOT_CONNECTED ;
3880  }
3881  return pCollectionSpace->removeDomain() ;
3882  }
3883 
3889  INT32 enableCapped ()
3890  {
3891  if ( NULL == pCollectionSpace )
3892  {
3893  return SDB_NOT_CONNECTED ;
3894  }
3895  return pCollectionSpace->enableCapped() ;
3896  }
3897 
3903  INT32 disableCapped ()
3904  {
3905  if ( NULL == pCollectionSpace )
3906  {
3907  return SDB_NOT_CONNECTED ;
3908  }
3909  return pCollectionSpace->disableCapped() ;
3910  }
3911 
3923  INT32 setAttributes ( const bson::BSONObj & options )
3924  {
3925  if ( NULL == pCollectionSpace )
3926  {
3927  return SDB_NOT_CONNECTED ;
3928  }
3929  return pCollectionSpace->setAttributes( options ) ;
3930  }
3931  } ;
3932 
3933  class DLLEXPORT _sdbDomain
3934  {
3935  private :
3936  _sdbDomain ( const _sdbDomain& other ) ; // non construction-copyable
3937  _sdbDomain& operator= ( const _sdbDomain& ) ; // non copyable
3938  public :
3939  _sdbDomain () {}
3940  virtual ~_sdbDomain () {}
3941 
3942  virtual const CHAR* getName () = 0 ;
3943 
3944  virtual INT32 alterDomain ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
3945 
3946  virtual INT32 listCollectionSpacesInDomain ( _sdbCursor **cursor ) = 0 ;
3947 
3948  virtual INT32 listCollectionSpacesInDomain ( sdbCursor &cursor ) = 0 ;
3949 
3950  virtual INT32 listCollectionsInDomain ( _sdbCursor **cursor ) = 0 ;
3951 
3952  virtual INT32 listCollectionsInDomain ( sdbCursor &cursor ) = 0 ;
3953 
3954  virtual INT32 listReplicaGroupInDomain( _sdbCursor **cursor ) = 0 ;
3955 
3956  virtual INT32 listReplicaGroupInDomain( sdbCursor &cursor ) = 0 ;
3957 
3958  virtual INT32 addGroups ( const bson::BSONObj & options ) = 0 ;
3959 
3960  virtual INT32 setGroups ( const bson::BSONObj & options ) = 0 ;
3961 
3962  virtual INT32 removeGroups ( const bson::BSONObj & options ) = 0 ;
3963 
3964  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
3965  } ;
3966 
3970  class DLLEXPORT sdbDomain
3971  {
3972  private :
3973  sdbDomain ( const sdbDomain& ) ; // non construction-copyable
3974  sdbDomain& operator= ( const sdbDomain& ) ; // non copyable
3975  public :
3976 
3983  _sdbDomain *pDomain ;
3984 
3988  sdbDomain() { pDomain = NULL ; }
3989 
3994  {
3995  if ( pDomain )
3996  {
3997  delete pDomain ;
3998  }
3999  }
4000 
4005  const CHAR *getName ()
4006  {
4007  if ( !pDomain )
4008  {
4009  return NULL ;
4010  }
4011  return pDomain->getName() ;
4012  }
4013 
4031  INT32 alterDomain ( const bson::BSONObj &options )
4032  {
4033  if ( !pDomain )
4034  {
4035  return SDB_NOT_CONNECTED ;
4036  }
4037  return pDomain->alterDomain ( options ) ;
4038  }
4039 
4050  INT32 addGroups ( const bson::BSONObj & options )
4051  {
4052  if ( NULL == pDomain )
4053  {
4054  return SDB_NOT_CONNECTED ;
4055  }
4056  return pDomain->addGroups( options ) ;
4057  }
4058 
4071  INT32 setGroups ( const bson::BSONObj & options )
4072  {
4073  if ( NULL == pDomain )
4074  {
4075  return SDB_NOT_CONNECTED ;
4076  }
4077  return pDomain->setGroups( options ) ;
4078  }
4079 
4091  INT32 removeGroups ( const bson::BSONObj & options )
4092  {
4093  if ( NULL == pDomain )
4094  {
4095  return SDB_NOT_CONNECTED ;
4096  }
4097  return pDomain->removeGroups( options ) ;
4098  }
4099 
4117  INT32 setAttributes ( const bson::BSONObj &options )
4118  {
4119  if ( !pDomain )
4120  {
4121  return SDB_NOT_CONNECTED ;
4122  }
4123  return pDomain->setAttributes( options ) ;
4124  }
4125 
4133  INT32 listCollectionSpacesInDomain ( sdbCursor &cursor )
4134  {
4135  if ( !pDomain )
4136  {
4137  return SDB_NOT_CONNECTED ;
4138  }
4139  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4140  return pDomain->listCollectionSpacesInDomain ( cursor ) ;
4141  }
4142 
4143  INT32 listCollectionSpacesInDomain ( _sdbCursor **cursor )
4144  {
4145  if ( !pDomain )
4146  {
4147  return SDB_NOT_CONNECTED ;
4148  }
4149  return pDomain->listCollectionSpacesInDomain ( cursor ) ;
4150  }
4151 
4159  INT32 listCollectionsInDomain ( sdbCursor &cursor )
4160  {
4161  if ( !pDomain )
4162  {
4163  return SDB_NOT_CONNECTED ;
4164  }
4165  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4166  return pDomain->listCollectionsInDomain ( cursor ) ;
4167  }
4168 
4176  INT32 listCollectionsInDomain ( _sdbCursor **cursor )
4177  {
4178  if ( !pDomain )
4179  {
4180  return SDB_NOT_CONNECTED ;
4181  }
4182  return pDomain->listCollectionsInDomain ( cursor ) ;
4183  }
4184 
4185  INT32 listReplicaGroupInDomain( _sdbCursor **cursor )
4186  {
4187  if ( !pDomain )
4188  {
4189  return SDB_NOT_CONNECTED ;
4190  }
4191  return pDomain->listReplicaGroupInDomain( cursor ) ;
4192  }
4193 
4200  INT32 listReplicaGroupInDomain( sdbCursor &cursor )
4201  {
4202  if ( !pDomain )
4203  {
4204  return SDB_NOT_CONNECTED ;
4205  }
4206  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4207  return pDomain->listReplicaGroupInDomain( cursor ) ;
4208  }
4209  };
4210 
4211  class DLLEXPORT _sdbDataCenter
4212  {
4213  private :
4214  _sdbDataCenter ( const _sdbDataCenter& other ) ; // non construction-copyable
4215  _sdbDataCenter& operator= ( const _sdbDataCenter& ) ; // non copyable
4216 
4217  public :
4218  _sdbDataCenter () {}
4219  virtual ~_sdbDataCenter () {}
4220 
4221  public :
4222  virtual const CHAR *getName () = 0 ;
4223  virtual INT32 getDetail( bson::BSONObj &retInfo ) = 0 ;
4224  virtual INT32 activateDC() = 0 ;
4225  virtual INT32 deactivateDC() = 0 ;
4226  virtual INT32 enableReadOnly( BOOLEAN isReadOnly ) = 0 ;
4227  virtual INT32 createImage( const CHAR *pCataAddrList ) = 0 ;
4228  virtual INT32 removeImage() = 0 ;
4229  virtual INT32 enableImage() = 0 ;
4230  virtual INT32 disableImage() = 0 ;
4231  virtual INT32 attachGroups( const bson::BSONObj &info ) = 0 ;
4232  virtual INT32 detachGroups( const bson::BSONObj &info ) = 0 ;
4233 
4234  } ;
4235 
4236  /* \class sdbDataCenter
4237  \brief Database operation interfaces of data center.
4238  */
4239  class DLLEXPORT sdbDataCenter
4240  {
4241  private :
4242  sdbDataCenter ( const sdbDataCenter& ) ; // non construction-copyable
4243  sdbDataCenter& operator= ( const sdbDataCenter& ) ; // non copyable
4244 
4245  public :
4246 
4253  _sdbDataCenter *pDC ;
4254 
4258  sdbDataCenter() { pDC = NULL ; }
4259 
4263  ~sdbDataCenter()
4264  {
4265  if ( pDC )
4266  {
4267  delete pDC ;
4268  }
4269  }
4270 
4271  public :
4272 
4277  const CHAR *getName ()
4278  {
4279  if ( NULL == pDC )
4280  {
4281  return NULL ;
4282  }
4283  return pDC->getName() ;
4284  }
4285 
4292  INT32 getDetail( bson::BSONObj &retInfo )
4293  {
4294  if ( NULL == pDC )
4295  {
4296  return SDB_NOT_CONNECTED ;
4297  }
4298  return pDC->getDetail( retInfo ) ;
4299  }
4300 
4306  INT32 activateDC()
4307  {
4308  if ( NULL == pDC )
4309  {
4310  return SDB_NOT_CONNECTED ;
4311  }
4312  return pDC->activateDC() ;
4313  }
4314 
4320  INT32 deactivateDC()
4321  {
4322  if ( NULL == pDC )
4323  {
4324  return SDB_NOT_CONNECTED ;
4325  }
4326  return pDC->deactivateDC() ;
4327  }
4328 
4335  INT32 enableReadOnly( BOOLEAN isReadOnly )
4336  {
4337  if ( NULL == pDC )
4338  {
4339  return SDB_NOT_CONNECTED ;
4340  }
4341  return pDC->enableReadOnly( isReadOnly ) ;
4342  }
4343 
4351  INT32 createImage( const CHAR *pCataAddrList )
4352  {
4353  if ( NULL == pDC )
4354  {
4355  return SDB_NOT_CONNECTED ;
4356  }
4357  return pDC->createImage( pCataAddrList ) ;
4358  }
4359 
4365  INT32 removeImage()
4366  {
4367  if ( NULL == pDC )
4368  {
4369  return SDB_NOT_CONNECTED ;
4370  }
4371  return pDC->removeImage() ;
4372  }
4373 
4379  INT32 enableImage()
4380  {
4381  if ( NULL == pDC )
4382  {
4383  return SDB_NOT_CONNECTED ;
4384  }
4385  return pDC->enableImage() ;
4386  }
4387 
4393  INT32 disableImage()
4394  {
4395  if ( NULL == pDC )
4396  {
4397  return SDB_NOT_CONNECTED ;
4398  }
4399  return pDC->disableImage() ;
4400  }
4401 
4408  INT32 attachGroups( const bson::BSONObj &info )
4409  {
4410  if ( NULL == pDC )
4411  {
4412  return SDB_NOT_CONNECTED ;
4413  }
4414  return pDC->attachGroups( info ) ;
4415  }
4416 
4423  INT32 detachGroups( const bson::BSONObj &info )
4424  {
4425  if ( NULL == pDC )
4426  {
4427  return SDB_NOT_CONNECTED ;
4428  }
4429  return pDC->detachGroups( info ) ;
4430  }
4431 
4432  };
4433 
4434  class DLLEXPORT _sdbRecycleBin
4435  {
4436  private :
4437  _sdbRecycleBin ( const _sdbRecycleBin& other ) ; // non construction-copyable
4438  _sdbRecycleBin& operator= ( const _sdbRecycleBin& ) ; // non copyable
4439 
4440  public :
4441  _sdbRecycleBin () {}
4442  virtual ~_sdbRecycleBin () {}
4443 
4444  public :
4445  virtual INT32 getDetail( bson::BSONObj &retInfo ) = 0 ;
4446  virtual INT32 enable() = 0 ;
4447  virtual INT32 disable() = 0 ;
4448  virtual INT32 setAttributes( const bson::BSONObj &options ) = 0 ;
4449  virtual INT32 alter( const bson::BSONObj &options ) = 0 ;
4450  virtual INT32 returnItem( const CHAR *recycleName,
4451  const bson::BSONObj &options = _sdbStaticObject,
4452  bson::BSONObj *result = NULL ) = 0 ;
4453  virtual INT32 returnItemToName( const CHAR *recycleName,
4454  const CHAR *returnName,
4455  const bson::BSONObj &options = _sdbStaticObject,
4456  bson::BSONObj *result = NULL ) = 0 ;
4457  virtual INT32 dropItem( const CHAR *recycleName,
4458  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4459  virtual INT32 dropAll( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4460  virtual INT32 list( _sdbCursor **cursor,
4461  const bson::BSONObj &condition = _sdbStaticObject,
4462  const bson::BSONObj &selector = _sdbStaticObject,
4463  const bson::BSONObj &orderBy = _sdbStaticObject,
4464  const bson::BSONObj &hint = _sdbStaticObject,
4465  INT64 numToSkip = 0,
4466  INT64 numToReturn = -1 ) = 0 ;
4467  virtual INT32 list( sdbCursor &cursor,
4468  const bson::BSONObj &condition = _sdbStaticObject,
4469  const bson::BSONObj &selector = _sdbStaticObject,
4470  const bson::BSONObj &orderBy = _sdbStaticObject,
4471  const bson::BSONObj &hint = _sdbStaticObject,
4472  INT64 numToSkip = 0,
4473  INT64 numToReturn = -1 ) = 0 ;
4474  virtual INT32 snapshot( _sdbCursor **cursor,
4475  const bson::BSONObj &condition = _sdbStaticObject,
4476  const bson::BSONObj &selector = _sdbStaticObject,
4477  const bson::BSONObj &orderBy = _sdbStaticObject,
4478  const bson::BSONObj &hint = _sdbStaticObject,
4479  INT64 numToSkip = 0,
4480  INT64 numToReturn = -1 ) = 0 ;
4481  virtual INT32 snapshot( sdbCursor &cursor,
4482  const bson::BSONObj &condition = _sdbStaticObject,
4483  const bson::BSONObj &selector = _sdbStaticObject,
4484  const bson::BSONObj &orderBy = _sdbStaticObject,
4485  const bson::BSONObj &hint = _sdbStaticObject,
4486  INT64 numToSkip = 0,
4487  INT64 numToReturn = -1 ) = 0 ;
4488  virtual INT32 getCount( INT64 &count,
4489  const bson::BSONObj &condition = _sdbStaticObject ) = 0 ;
4490  } ;
4491 
4492  /* \class sdbRecycleBin
4493  \brief Database operation interfaces of recycle bin.
4494  */
4495  class DLLEXPORT sdbRecycleBin
4496  {
4497  private :
4498  sdbRecycleBin( const sdbRecycleBin & ) ; // non construction-copyable
4499  sdbRecycleBin &operator =( const sdbRecycleBin & ) ; // non copyable
4500 
4501  public :
4502 
4509  _sdbRecycleBin *pRecycleBin ;
4510 
4514  sdbRecycleBin() { pRecycleBin = NULL ; }
4515 
4519  ~sdbRecycleBin()
4520  {
4521  if ( pRecycleBin )
4522  {
4523  delete pRecycleBin ;
4524  }
4525  }
4526 
4527  public :
4528 
4535  INT32 getDetail( bson::BSONObj &retInfo )
4536  {
4537  if ( NULL == pRecycleBin )
4538  {
4539  return SDB_NOT_CONNECTED ;
4540  }
4541  return pRecycleBin->getDetail( retInfo ) ;
4542  }
4543 
4549  INT32 enable()
4550  {
4551  if ( NULL == pRecycleBin )
4552  {
4553  return SDB_NOT_CONNECTED ;
4554  }
4555  return pRecycleBin->enable() ;
4556  }
4557 
4563  INT32 disable()
4564  {
4565  if ( NULL == pRecycleBin )
4566  {
4567  return SDB_NOT_CONNECTED ;
4568  }
4569  return pRecycleBin->disable() ;
4570  }
4571 
4585  INT32 setAttributes( const bson::BSONObj &options )
4586  {
4587  if ( NULL == pRecycleBin )
4588  {
4589  return SDB_NOT_CONNECTED ;
4590  }
4591  return pRecycleBin->setAttributes( options ) ;
4592  }
4593 
4607  INT32 alter( const bson::BSONObj &options )
4608  {
4609  if ( NULL == pRecycleBin )
4610  {
4611  return SDB_NOT_CONNECTED ;
4612  }
4613  return pRecycleBin->alter( options ) ;
4614  }
4615 
4626  INT32 returnItem( const CHAR *recycleName,
4627  const bson::BSONObj &options = _sdbStaticObject,
4628  bson::BSONObj *result = NULL )
4629  {
4630  if ( NULL == pRecycleBin )
4631  {
4632  return SDB_NOT_CONNECTED ;
4633  }
4634  return pRecycleBin->returnItem( recycleName, options, result ) ;
4635  }
4636 
4649  INT32 returnItemToName( const CHAR *recycleName,
4650  const CHAR *returnName,
4651  const bson::BSONObj &options = _sdbStaticObject,
4652  bson::BSONObj *result = NULL )
4653  {
4654  if ( NULL == pRecycleBin )
4655  {
4656  return SDB_NOT_CONNECTED ;
4657  }
4658  return pRecycleBin->returnItemToName( recycleName,
4659  returnName,
4660  options,
4661  result ) ;
4662  }
4663 
4671  INT32 dropItem( const CHAR *recycleName,
4672  const bson::BSONObj &options = _sdbStaticObject )
4673  {
4674  if ( NULL == pRecycleBin )
4675  {
4676  return SDB_NOT_CONNECTED ;
4677  }
4678  return pRecycleBin->dropItem( recycleName, options ) ;
4679  }
4680 
4687  INT32 dropAll( const bson::BSONObj &options = _sdbStaticObject )
4688  {
4689  if ( NULL == pRecycleBin )
4690  {
4691  return SDB_NOT_CONNECTED ;
4692  }
4693  return pRecycleBin->dropAll( options ) ;
4694  }
4695 
4715  INT32 list( _sdbCursor **cursor,
4716  const bson::BSONObj &condition = _sdbStaticObject,
4717  const bson::BSONObj &selector = _sdbStaticObject,
4718  const bson::BSONObj &orderBy = _sdbStaticObject,
4719  const bson::BSONObj &hint = _sdbStaticObject,
4720  INT64 numToSkip = 0,
4721  INT64 numToReturn = -1 )
4722  {
4723  if ( NULL == pRecycleBin )
4724  {
4725  return SDB_NOT_CONNECTED ;
4726  }
4727  return pRecycleBin->list( cursor,
4728  condition,
4729  selector,
4730  orderBy,
4731  hint,
4732  numToSkip,
4733  numToReturn ) ;
4734  }
4735 
4755  INT32 list( sdbCursor &cursor,
4756  const bson::BSONObj &condition = _sdbStaticObject,
4757  const bson::BSONObj &selector = _sdbStaticObject,
4758  const bson::BSONObj &orderBy = _sdbStaticObject,
4759  const bson::BSONObj &hint = _sdbStaticObject,
4760  INT64 numToSkip = 0,
4761  INT64 numToReturn = -1 )
4762  {
4763  if ( NULL == pRecycleBin )
4764  {
4765  return SDB_NOT_CONNECTED ;
4766  }
4767  return pRecycleBin->list( cursor,
4768  condition,
4769  selector,
4770  orderBy,
4771  hint,
4772  numToSkip,
4773  numToReturn ) ;
4774  }
4775 
4795  INT32 snapshot( _sdbCursor **cursor,
4796  const bson::BSONObj &condition = _sdbStaticObject,
4797  const bson::BSONObj &selector = _sdbStaticObject,
4798  const bson::BSONObj &orderBy = _sdbStaticObject,
4799  const bson::BSONObj &hint = _sdbStaticObject,
4800  INT64 numToSkip = 0,
4801  INT64 numToReturn = -1 )
4802  {
4803  if ( NULL == pRecycleBin )
4804  {
4805  return SDB_NOT_CONNECTED ;
4806  }
4807  return pRecycleBin->snapshot( cursor,
4808  condition,
4809  selector,
4810  orderBy,
4811  hint,
4812  numToSkip,
4813  numToReturn ) ;
4814  }
4815 
4835  INT32 snapshot( sdbCursor &cursor,
4836  const bson::BSONObj &condition = _sdbStaticObject,
4837  const bson::BSONObj &selector = _sdbStaticObject,
4838  const bson::BSONObj &orderBy = _sdbStaticObject,
4839  const bson::BSONObj &hint = _sdbStaticObject,
4840  INT64 numToSkip = 0,
4841  INT64 numToReturn = -1 )
4842  {
4843  if ( NULL == pRecycleBin )
4844  {
4845  return SDB_NOT_CONNECTED ;
4846  }
4847  return pRecycleBin->snapshot( cursor,
4848  condition,
4849  selector,
4850  orderBy,
4851  hint,
4852  numToSkip,
4853  numToReturn ) ;
4854  }
4855 
4864  INT32 getCount( INT64 &count,
4865  const bson::BSONObj &condition = _sdbStaticObject )
4866  {
4867  if ( NULL == pRecycleBin )
4868  {
4869  return SDB_NOT_CONNECTED ;
4870  }
4871  return pRecycleBin->getCount( count, condition ) ;
4872  }
4873  } ;
4874 
4875  class DLLEXPORT _sdbLob
4876  {
4877  private :
4878  _sdbLob ( const _sdbLob& other ) ; // non construction-copyable
4879  _sdbLob& operator= ( const _sdbLob& ) ; // non copyable
4880 
4881  public :
4882  _sdbLob () {}
4883 
4884  virtual ~_sdbLob () {}
4885 
4886  virtual INT32 close () = 0 ;
4887 
4888  virtual INT32 read ( UINT32 len, CHAR *buf, UINT32 *read ) = 0 ;
4889 
4890  virtual INT32 write ( const CHAR *buf, UINT32 len ) = 0 ;
4891 
4892  virtual INT32 seek ( SINT64 size, SDB_LOB_SEEK whence ) = 0 ;
4893 
4894  virtual INT32 lock( INT64 offset, INT64 length ) = 0 ;
4895 
4896  virtual INT32 lockAndSeek( INT64 offset, INT64 length ) = 0 ;
4897 
4898  virtual INT32 isClosed( BOOLEAN &flag ) = 0 ;
4899 
4900  virtual INT32 getOid( bson::OID &oid ) = 0 ;
4901 
4902  virtual INT32 getSize( SINT64 *size ) = 0 ;
4903 
4904  virtual INT32 getCreateTime ( UINT64 *millis ) = 0 ;
4905 
4906  virtual BOOLEAN isClosed() = 0 ;
4907 
4908  virtual bson::OID getOid() = 0 ;
4909 
4910  virtual SINT64 getSize() = 0 ;
4911 
4912  virtual UINT64 getCreateTime () = 0 ;
4913 
4914  virtual UINT64 getModificationTime() = 0 ;
4915 
4916  virtual INT32 getPiecesInfoNum() = 0 ;
4917 
4918  virtual bson::BSONArray getPiecesInfo() = 0 ;
4919 
4920  virtual BOOLEAN isEof() = 0 ;
4921 
4922  virtual INT32 getRunTimeDetail( bson::BSONObj &detail ) = 0 ;
4923 
4924  } ;
4925 
4929  class DLLEXPORT sdbLob
4930  {
4931  private :
4932  sdbLob ( const sdbLob& ) ; // non construction-copyable
4933  sdbLob& operator= ( const sdbLob& ) ; // non copyable
4934 
4935  public :
4936 
4943  _sdbLob *pLob ;
4947  sdbLob() { pLob = NULL ; }
4948 
4953  {
4954  if ( pLob )
4955  {
4956  delete pLob ;
4957  }
4958  }
4959 
4965  INT32 close ()
4966  {
4967  if ( !pLob )
4968  {
4969  return SDB_OK ;
4970  }
4971  return pLob->close() ;
4972  }
4973 
4982  INT32 read ( UINT32 len, CHAR *buf, UINT32 *read )
4983  {
4984  if ( !pLob )
4985  {
4986  return SDB_NOT_CONNECTED ;
4987  }
4988  return pLob->read( len, buf, read ) ;
4989  }
4990 
4998  INT32 write ( const CHAR *buf, UINT32 len )
4999  {
5000  if ( !pLob )
5001  {
5002  return SDB_NOT_CONNECTED ;
5003  }
5004  return pLob->write( buf, len ) ;
5005  }
5006 
5014  INT32 seek ( SINT64 size, SDB_LOB_SEEK whence )
5015  {
5016  if ( !pLob )
5017  {
5018  return SDB_NOT_CONNECTED ;
5019  }
5020  return pLob->seek( size, whence ) ;
5021  }
5022 
5030  INT32 lock ( INT64 offset, INT64 length )
5031  {
5032  if ( !pLob )
5033  {
5034  return SDB_NOT_CONNECTED ;
5035  }
5036  return pLob->lock( offset, length ) ;
5037  }
5038 
5046  INT32 lockAndSeek ( INT64 offset, INT64 length )
5047  {
5048  if ( !pLob )
5049  {
5050  return SDB_NOT_CONNECTED ;
5051  }
5052  return pLob->lockAndSeek( offset, length ) ;
5053  }
5054 
5062  INT32 isClosed( BOOLEAN &flag )
5063  {
5064  if ( !pLob )
5065  {
5066  return SDB_NOT_CONNECTED ;
5067  }
5068  return pLob->isClosed ( flag ) ;
5069  }
5070 
5075  BOOLEAN isClosed()
5076  {
5077  if ( !pLob )
5078  {
5079  return TRUE ;
5080  }
5081  return pLob->isClosed () ;
5082  }
5083 
5091  INT32 getOid ( bson::OID &oid )
5092  {
5093  if ( !pLob )
5094  {
5095  return SDB_NOT_CONNECTED ;
5096  }
5097  return pLob->getOid( oid ) ;
5098  }
5099 
5104  bson::OID getOid ()
5105  {
5106  if ( !pLob )
5107  {
5108  return bson::OID();
5109  }
5110  return pLob->getOid() ;
5111  }
5112 
5120  INT32 getSize ( SINT64 *size )
5121  {
5122  if ( !pLob )
5123  {
5124  return SDB_NOT_CONNECTED ;
5125  }
5126  return pLob->getSize( size ) ;
5127  }
5128 
5133  SINT64 getSize ()
5134  {
5135  if ( !pLob )
5136  {
5137  return -1 ;
5138  }
5139  return pLob->getSize();
5140  }
5141 
5149  INT32 getCreateTime ( UINT64 *millis )
5150  {
5151  if ( !pLob )
5152  {
5153  return SDB_NOT_CONNECTED ;
5154  }
5155  return pLob->getCreateTime( millis ) ;
5156  }
5157 
5162  UINT64 getCreateTime ()
5163  {
5164  if ( !pLob )
5165  {
5166  return -1 ;
5167  }
5168  return pLob->getCreateTime() ;
5169  }
5170 
5175  UINT64 getModificationTime ()
5176  {
5177  if ( !pLob )
5178  {
5179  return -1 ;
5180  }
5181  return pLob->getModificationTime() ;
5182  }
5183 
5188  INT32 getPiecesInfoNum()
5189  {
5190  if ( !pLob )
5191  {
5192  return -1 ;
5193  }
5194  return pLob->getPiecesInfoNum() ;
5195  }
5196 
5201  bson::BSONArray getPiecesInfo()
5202  {
5203  if ( !pLob )
5204  {
5205  return bson::BSONArray() ;
5206  }
5207  return pLob->getPiecesInfo() ;
5208  }
5209 
5214  BOOLEAN isEof()
5215  {
5216  if ( !pLob )
5217  {
5218  return TRUE ;
5219  }
5220  return pLob->isEof() ;
5221  }
5222 
5228  INT32 getRunTimeDetail( bson::BSONObj &detail )
5229  {
5230  if ( !pLob )
5231  {
5232  return -1 ;
5233  }
5234  return pLob->getRunTimeDetail( detail ) ;
5235  }
5236 
5237  } ;
5238 
5239  class DLLEXPORT _sdbSequence
5240  {
5241  private :
5242  _sdbSequence ( const _sdbSequence& other ) ;
5243  _sdbSequence& operator=( const _sdbSequence& ) ;
5244  public :
5245  _sdbSequence () {}
5246  virtual ~_sdbSequence () {}
5247 
5248  virtual INT32 setAttributes ( const bson::BSONObj &options ) = 0 ;
5249 
5250  virtual INT32 getNextValue ( INT64 &value ) = 0 ;
5251 
5252  virtual INT32 getCurrentValue ( INT64 &value ) = 0 ;
5253 
5254  virtual INT32 setCurrentValue ( const INT64 value ) = 0 ;
5255 
5256  virtual INT32 fetch( const INT32 fetchNum,
5257  INT64 &nextValue,
5258  INT32 &returnNum,
5259  INT32 &Increment ) = 0 ;
5260 
5261  virtual INT32 restart( const INT64 startValue ) = 0 ;
5262  } ;
5263 
5267  class DLLEXPORT sdbSequence
5268  {
5269  private :
5274  sdbSequence ( const sdbSequence& other ) ;
5275 
5281  sdbSequence& operator=( const sdbSequence& ) ;
5282  public :
5289  _sdbSequence *pSequence ;
5290 
5295  {
5296  pSequence = NULL ;
5297  }
5298 
5303  {
5304  if ( pSequence )
5305  {
5306  delete pSequence ;
5307  }
5308  }
5309 
5326  INT32 setAttributes ( const bson::BSONObj & options )
5327  {
5328  if ( NULL == pSequence )
5329  {
5330  return SDB_NOT_CONNECTED ;
5331  }
5332  return pSequence->setAttributes( options ) ;
5333  }
5334 
5341  INT32 getNextValue( INT64 &value )
5342  {
5343  if ( NULL == pSequence )
5344  {
5345  return SDB_NOT_CONNECTED ;
5346  }
5347  return pSequence->getNextValue( value ) ;
5348  }
5349 
5356  INT32 getCurrentValue( INT64 &value )
5357  {
5358  if ( NULL == pSequence )
5359  {
5360  return SDB_NOT_CONNECTED ;
5361  }
5362  return pSequence->getCurrentValue( value ) ;
5363  }
5364 
5371  INT32 setCurrentValue( const INT64 value )
5372  {
5373  if ( NULL == pSequence )
5374  {
5375  return SDB_NOT_CONNECTED ;
5376  }
5377  return pSequence->setCurrentValue( value ) ;
5378  }
5379 
5390  INT32 fetch( const INT32 fetchNum, INT64 &nextValue,
5391  INT32 &returnNum, INT32 &increment )
5392  {
5393  if ( NULL == pSequence )
5394  {
5395  return SDB_NOT_CONNECTED ;
5396  }
5397  return pSequence->fetch( fetchNum, nextValue, returnNum, increment ) ;
5398  }
5399 
5406  INT32 restart( const INT64 startValue )
5407  {
5408  if ( NULL == pSequence )
5409  {
5410  return SDB_NOT_CONNECTED ;
5411  }
5412  return pSequence->restart( startValue ) ;
5413  }
5414  } ;
5415 
5416  class DLLEXPORT _sdbDataSource
5417  {
5418  private:
5419  _sdbDataSource( const _sdbDataSource& other ) ;
5420  _sdbDataSource& operator=( const _sdbDataSource& ) ;
5421  public:
5422  _sdbDataSource() {}
5423  virtual ~_sdbDataSource() {}
5424 
5425  virtual INT32 alterDataSource( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5426  virtual const CHAR *getName() = 0 ;
5427  } ;
5428 
5432  class DLLEXPORT sdbDataSource
5433  {
5434  private:
5435  sdbDataSource( const sdbDataSource& ) ;
5436  sdbDataSource& operator=(const sdbDataSource& ) ;
5437  public:
5438  _sdbDataSource *pDataSource ;
5439 
5440  sdbDataSource()
5441  {
5442  pDataSource = NULL ;
5443  }
5444 
5445  ~sdbDataSource()
5446  {
5447  if ( pDataSource )
5448  {
5449  delete pDataSource ;
5450  }
5451  }
5452 
5493  INT32 alterDataSource( const bson::BSONObj &options )
5494  {
5495  if ( !pDataSource )
5496  {
5497  return SDB_NOT_CONNECTED ;
5498  }
5499  return pDataSource->alterDataSource( options ) ;
5500  }
5501 
5506  const CHAR *getName()
5507  {
5508  if ( !pDataSource )
5509  {
5510  return NULL ;
5511  }
5512  return pDataSource->getName() ;
5513  }
5514  } ;
5515 
5516  class DLLEXPORT _sdb
5517  {
5518  private :
5519  _sdb ( const _sdb& other ) ; // non construction-copyable
5520  _sdb& operator=( const _sdb& ) ; // non copyable
5521  public :
5522  _sdb () {}
5523  virtual ~_sdb () {}
5524  virtual INT32 connect ( const CHAR *pHostName,
5525  UINT16 port
5526  ) = 0 ;
5527  virtual INT32 connect ( const CHAR *pHostName,
5528  UINT16 port,
5529  const CHAR *pUsrName,
5530  const CHAR *pPasswd ) = 0 ;
5531  virtual INT32 connect ( const CHAR *pHostName,
5532  const CHAR *pServiceName ) = 0 ;
5533  virtual INT32 connect ( const CHAR *pHostName,
5534  const CHAR *pServiceName,
5535  const CHAR *pUsrName,
5536  const CHAR *pPasswd ) = 0 ;
5537  virtual INT32 connect ( const CHAR **pConnAddrs,
5538  INT32 arrSize,
5539  const CHAR *pUsrName,
5540  const CHAR *pPasswd ) = 0 ;
5541  virtual INT32 connect ( const CHAR **pConnAddrs,
5542  INT32 arrSize,
5543  const CHAR *pUsrName,
5544  const CHAR *pToken,
5545  const CHAR *pCipherFile ) = 0 ;
5546 
5547  virtual void disconnect () = 0 ;
5548 
5549  virtual UINT64 getDbStartTime() = 0 ;
5550 
5551  virtual const CHAR *getAddress() = 0 ;
5552 
5553  virtual void getVersion( UINT8 &version, UINT8 &subVersion,
5554  UINT8 &fixVersion ) = 0 ;
5555 
5556  virtual INT32 createUsr( const CHAR *pUsrName,
5557  const CHAR *pPasswd,
5558  const bson::BSONObj &options = _sdbStaticObject
5559  ) = 0 ;
5560 
5561  virtual INT32 removeUsr( const CHAR *pUsrName,
5562  const CHAR *pPasswd ) = 0 ;
5563 
5564  virtual INT32 alterUsr( const CHAR *pUsrName,
5565  const CHAR *pAction,
5566  const bson::BSONObj &options ) = 0 ;
5567 
5568  virtual INT32 changeUsrPasswd( const CHAR *pUsrName,
5569  const CHAR *pOldPasswd,
5570  const CHAR *pNewPasswd ) = 0 ;
5571 
5572  virtual INT32 getSnapshot ( _sdbCursor **cursor,
5573  INT32 snapType,
5574  const bson::BSONObj &condition = _sdbStaticObject,
5575  const bson::BSONObj &selector = _sdbStaticObject,
5576  const bson::BSONObj &orderBy = _sdbStaticObject,
5577  const bson::BSONObj &hint = _sdbStaticObject,
5578  INT64 numToSkip = 0,
5579  INT64 numToReturn = -1
5580  ) = 0 ;
5581 
5582  virtual INT32 getSnapshot ( sdbCursor &cursor,
5583  INT32 snapType,
5584  const bson::BSONObj &condition = _sdbStaticObject,
5585  const bson::BSONObj &selector = _sdbStaticObject,
5586  const bson::BSONObj &orderBy = _sdbStaticObject,
5587  const bson::BSONObj &hint = _sdbStaticObject,
5588  INT64 numToSkip = 0,
5589  INT64 numToReturn = -1
5590  ) = 0 ;
5591 
5592  virtual INT32 resetSnapshot ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5593 
5594  virtual INT32 getList ( _sdbCursor **cursor,
5595  INT32 listType,
5596  const bson::BSONObj &condition = _sdbStaticObject,
5597  const bson::BSONObj &selector = _sdbStaticObject,
5598  const bson::BSONObj &orderBy = _sdbStaticObject,
5599  const bson::BSONObj &hint = _sdbStaticObject,
5600  INT64 numToSkip = 0,
5601  INT64 numToReturn = -1
5602  ) = 0 ;
5603  virtual INT32 getList ( sdbCursor &cursor,
5604  INT32 listType,
5605  const bson::BSONObj &condition = _sdbStaticObject,
5606  const bson::BSONObj &selector = _sdbStaticObject,
5607  const bson::BSONObj &orderBy = _sdbStaticObject,
5608  const bson::BSONObj &hint = _sdbStaticObject,
5609  INT64 numToSkip = 0,
5610  INT64 numToReturn = -1
5611  ) = 0 ;
5612 
5613  virtual INT32 getCollection ( const CHAR *pCollectionFullName,
5614  _sdbCollection **collection,
5615  BOOLEAN checkExist = TRUE
5616  ) = 0 ;
5617 
5618  virtual INT32 getCollection ( const CHAR *pCollectionFullName,
5619  sdbCollection &collection,
5620  BOOLEAN checkExist = TRUE
5621  ) = 0 ;
5622 
5623  virtual INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
5624  _sdbCollectionSpace **cs,
5625  BOOLEAN checkExist = TRUE
5626  ) = 0 ;
5627 
5628  virtual INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
5629  sdbCollectionSpace &cs,
5630  BOOLEAN checkExist = TRUE
5631  ) = 0 ;
5632 
5633  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5634  INT32 iPageSize,
5635  _sdbCollectionSpace **cs
5636  ) = 0 ;
5637 
5638  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5639  INT32 iPageSize,
5640  sdbCollectionSpace &cs
5641  ) = 0 ;
5642 
5643  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5644  const bson::BSONObj &options,
5645  _sdbCollectionSpace **cs
5646  ) = 0 ;
5647 
5648  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5649  const bson::BSONObj &options,
5650  sdbCollectionSpace &cs
5651  ) = 0 ;
5652 
5653  virtual INT32 dropCollectionSpace (
5654  const CHAR *pCollectionSpaceName,
5655  const bson::BSONObj &options = _sdbStaticObject
5656  ) = 0 ;
5657 
5658  virtual INT32 listCollectionSpaces ( _sdbCursor **result ) = 0 ;
5659 
5660  virtual INT32 listCollectionSpaces ( sdbCursor &result ) = 0 ;
5661 
5662  // list all collections in a given database
5663  virtual INT32 listCollections ( _sdbCursor **result ) = 0 ;
5664 
5665  virtual INT32 listCollections ( sdbCursor &result ) = 0 ;
5666 
5667  // list all the replica groups in the given database
5668  virtual INT32 listReplicaGroups ( _sdbCursor **result ) = 0 ;
5669 
5670  virtual INT32 listReplicaGroups ( sdbCursor &result ) = 0 ;
5671 
5672  virtual INT32 getReplicaGroup ( const CHAR *pName,
5673  _sdbReplicaGroup **result ) = 0 ;
5674 
5675  virtual INT32 getReplicaGroup ( const CHAR *pName,
5676  sdbReplicaGroup &result ) = 0 ;
5677 
5678  virtual INT32 getReplicaGroup ( INT32 id,
5679  _sdbReplicaGroup **result ) = 0 ;
5680 
5681  virtual INT32 getReplicaGroup ( INT32 id,
5682  sdbReplicaGroup &result ) = 0 ;
5683 
5684  virtual INT32 createReplicaGroup ( const CHAR *pName,
5685  _sdbReplicaGroup **replicaGroup ) = 0 ;
5686 
5687  virtual INT32 createReplicaGroup ( const CHAR *pName,
5688  sdbReplicaGroup &replicaGroup ) = 0 ;
5689 
5690  virtual INT32 removeReplicaGroup ( const CHAR *pName ) = 0 ;
5691 
5692  virtual INT32 createReplicaCataGroup ( const CHAR *pHostName,
5693  const CHAR *pServiceName,
5694  const CHAR *pDatabasePath,
5695  const bson::BSONObj &configure ) =0 ;
5696 
5697  virtual INT32 activateReplicaGroup ( const CHAR *pName,
5698  _sdbReplicaGroup **replicaGroup ) = 0 ;
5699  virtual INT32 activateReplicaGroup ( const CHAR *pName,
5700  sdbReplicaGroup &replicaGroup ) = 0 ;
5701 
5702  virtual INT32 execUpdate( const CHAR *sql,
5703  bson::BSONObj *pResult = NULL ) = 0 ;
5704 
5705  virtual INT32 exec( const CHAR *sql,
5706  _sdbCursor **result ) = 0 ;
5707 
5708  virtual INT32 exec( const CHAR *sql,
5709  sdbCursor &result ) = 0 ;
5710 
5711  virtual INT32 transactionBegin() = 0 ;
5712 
5713  virtual INT32 transactionCommit( const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
5714 
5715  virtual INT32 transactionRollback() = 0 ;
5716 
5717  virtual INT32 flushConfigure( const bson::BSONObj &options ) = 0 ;
5718  // stored procedure
5719  virtual INT32 crtJSProcedure ( const CHAR *code ) = 0 ;
5720  virtual INT32 rmProcedure( const CHAR *spName ) = 0 ;
5721  virtual INT32 listProcedures( _sdbCursor **cursor, const bson::BSONObj &condition ) = 0 ;
5722  virtual INT32 listProcedures( sdbCursor &cursor, const bson::BSONObj &condition ) = 0 ;
5723  virtual INT32 evalJS( const CHAR *code,
5724  SDB_SPD_RES_TYPE &type,
5725  _sdbCursor **cursor,
5726  bson::BSONObj &errmsg ) = 0 ;
5727  virtual INT32 evalJS( const CHAR *code,
5728  SDB_SPD_RES_TYPE &type,
5729  sdbCursor &cursor,
5730  bson::BSONObj &errmsg ) = 0 ;
5731 
5732  // bakup
5733  virtual INT32 backup ( const bson::BSONObj &options) = 0 ;
5734  virtual INT32 listBackup ( _sdbCursor **cursor,
5735  const bson::BSONObj &options,
5736  const bson::BSONObj &condition = _sdbStaticObject,
5737  const bson::BSONObj &selector = _sdbStaticObject,
5738  const bson::BSONObj &orderBy = _sdbStaticObject) = 0 ;
5739  virtual INT32 listBackup ( sdbCursor &cursor,
5740  const bson::BSONObj &options,
5741  const bson::BSONObj &condition = _sdbStaticObject,
5742  const bson::BSONObj &selector = _sdbStaticObject,
5743  const bson::BSONObj &orderBy = _sdbStaticObject) = 0 ;
5744  virtual INT32 removeBackup ( const bson::BSONObj &options ) = 0 ;
5745 
5746  // task
5747  virtual INT32 listTasks ( _sdbCursor **cursor,
5748  const bson::BSONObj &condition = _sdbStaticObject,
5749  const bson::BSONObj &selector = _sdbStaticObject,
5750  const bson::BSONObj &orderBy = _sdbStaticObject,
5751  const bson::BSONObj &hint = _sdbStaticObject) = 0 ;
5752 
5753 
5754  virtual INT32 listTasks ( sdbCursor &cursor,
5755  const bson::BSONObj &condition = _sdbStaticObject,
5756  const bson::BSONObj &selector = _sdbStaticObject,
5757  const bson::BSONObj &orderBy = _sdbStaticObject,
5758  const bson::BSONObj &hint = _sdbStaticObject) = 0 ;
5759 
5760  virtual INT32 waitTasks ( const SINT64 *taskIDs,
5761  SINT32 num ) = 0 ;
5762 
5763  virtual INT32 cancelTask ( SINT64 taskID,
5764  BOOLEAN isAsync ) = 0 ;
5765  // set session attribute
5766  virtual INT32 setSessionAttr ( const bson::BSONObj &options =
5767  _sdbStaticObject ) = 0 ;
5768  // get session attribute
5769  virtual INT32 getSessionAttr ( bson::BSONObj &result,
5770  BOOLEAN useCache = TRUE ) = 0 ;
5771 
5772  // close all cursor
5773  virtual INT32 closeAllCursors () = 0 ;
5774 
5775  // interrupt
5776  virtual INT32 interrupt() = 0 ;
5777  virtual INT32 interruptOperation() = 0 ;
5778 
5779  // connection is valid
5780  virtual INT32 isValid( BOOLEAN *result ) = 0 ;
5781  virtual BOOLEAN isValid() = 0 ;
5782 
5783  virtual BOOLEAN isClosed() = 0 ;
5784 
5785  // domain
5786  virtual INT32 createDomain ( const CHAR *pDomainName,
5787  const bson::BSONObj &options,
5788  _sdbDomain **domain ) = 0 ;
5789 
5790  virtual INT32 createDomain ( const CHAR *pDomainName,
5791  const bson::BSONObj &options,
5792  sdbDomain &domain ) = 0 ;
5793 
5794  virtual INT32 dropDomain ( const CHAR *pDomainName ) = 0 ;
5795 
5796  virtual INT32 getDomain ( const CHAR *pDomainName,
5797  _sdbDomain **domain ) = 0 ;
5798 
5799  virtual INT32 getDomain ( const CHAR *pDomainName,
5800  sdbDomain &domain ) = 0 ;
5801 
5802  virtual INT32 listDomains ( _sdbCursor **cursor,
5803  const bson::BSONObj &condition = _sdbStaticObject,
5804  const bson::BSONObj &selector = _sdbStaticObject,
5805  const bson::BSONObj &orderBy = _sdbStaticObject,
5806  const bson::BSONObj &hint = _sdbStaticObject
5807  ) = 0 ;
5808 
5809  virtual INT32 listDomains ( sdbCursor &cursor,
5810  const bson::BSONObj &condition = _sdbStaticObject,
5811  const bson::BSONObj &selector = _sdbStaticObject,
5812  const bson::BSONObj &orderBy = _sdbStaticObject,
5813  const bson::BSONObj &hint = _sdbStaticObject
5814  ) = 0 ;
5815  virtual INT32 getDC( _sdbDataCenter **dc ) = 0 ;
5816  virtual INT32 getDC( sdbDataCenter &dc ) = 0 ;
5817 
5818  virtual INT32 getRecycleBin( _sdbRecycleBin **recycleBin ) = 0 ;
5819  virtual INT32 getRecycleBin( sdbRecycleBin &recycleBin ) = 0 ;
5820 
5821  static _sdb *getObj ( BOOLEAN useSSL = FALSE ) ;
5822 
5823  // get last alive time
5824  virtual UINT64 getLastAliveTime() const = 0 ;
5825 
5826  virtual INT32 syncDB(
5827  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5828 
5829  virtual INT32 analyze(
5830  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5831 
5832  virtual INT32 forceSession(
5833  SINT64 sessionID,
5834  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5835 
5836  virtual INT32 forceStepUp(
5837  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5838 
5839  virtual INT32 invalidateCache(
5840  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5841 
5842  virtual INT32 reloadConfig(
5843  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5844 
5845  virtual INT32 updateConfig ( const bson::BSONObj &configs = _sdbStaticObject,
5846  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5847 
5848  virtual INT32 deleteConfig ( const bson::BSONObj &configs = _sdbStaticObject,
5849  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5850 
5851  virtual INT32 setPDLevel( INT32 level,
5852  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5853 
5854  virtual INT32 msg( const CHAR* msg ) = 0 ;
5855 
5856  virtual INT32 loadCS( const CHAR* csName,
5857  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5858 
5859  virtual INT32 unloadCS( const CHAR* csName,
5860  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5861 
5862  virtual INT32 traceStart( UINT32 traceBufferSize,
5863  const CHAR* component = NULL,
5864  const CHAR* breakpoint = NULL,
5865  const vector<UINT32> &tidVec = _sdbStaticUINT32Vec ) = 0 ;
5866 
5867  virtual INT32 traceStart( UINT32 traceBufferSize,
5868  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5869 
5870  virtual INT32 traceStop( const CHAR* dumpFileName ) = 0 ;
5871 
5872  virtual INT32 traceResume() = 0 ;
5873 
5874  virtual INT32 traceStatus( _sdbCursor** cursor ) = 0 ;
5875 
5876  virtual INT32 traceStatus( sdbCursor& cursor ) = 0 ;
5877 
5878 
5879  virtual INT32 renameCollectionSpace( const CHAR* oldName,
5880  const CHAR* newName,
5881  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5882 
5883  virtual INT32 getLastErrorObj( bson::BSONObj &result ) = 0 ;
5884  virtual void cleanLastErrorObj() = 0 ;
5885 
5886  virtual INT32 getLastResultObj( bson::BSONObj &result,
5887  BOOLEAN getOwned = FALSE ) const = 0 ;
5888 
5889  // create a new sequence object
5890  virtual INT32 createSequence( const CHAR *pSequenceName,
5891  const bson::BSONObj &options,
5892  _sdbSequence **sequence ) = 0 ;
5893 
5894  virtual INT32 createSequence( const CHAR *pSequenceName,
5895  const bson::BSONObj &options,
5896  sdbSequence &sequence ) = 0 ;
5897 
5898  virtual INT32 createSequence( const CHAR *pSequenceName,
5899  sdbSequence &sequence ) = 0 ;
5900 
5901  // get a sequence object
5902  virtual INT32 getSequence( const CHAR *pSequenceName,
5903  _sdbSequence **sequence ) = 0 ;
5904 
5905  virtual INT32 getSequence( const CHAR *pSequenceName,
5906  sdbSequence &sequence ) = 0 ;
5907 
5908  virtual INT32 renameSequence( const CHAR *pOldName,
5909  const CHAR *pNewName ) = 0 ;
5910 
5911  virtual INT32 dropSequence( const CHAR *pSequenceName ) = 0 ;
5912 
5913  virtual INT32 createDataSource( _sdbDataSource **dataSource,
5914  const CHAR *pDataSourceName,
5915  const CHAR *addresses,
5916  const CHAR *user = NULL,
5917  const CHAR *password = NULL,
5918  const CHAR *type = NULL,
5919  const bson::BSONObj *options = NULL
5920  ) = 0 ;
5921 
5922  virtual INT32 dropDataSource( const CHAR *pDataSourceName ) = 0 ;
5923 
5924  virtual INT32 getDataSource( const CHAR *pDataSourceName,
5925  _sdbDataSource **dataSource ) = 0 ;
5926 
5927  virtual INT32 listDataSources( _sdbCursor** cursor,
5928  const bson::BSONObj &condition = _sdbStaticObject,
5929  const bson::BSONObj &selector = _sdbStaticObject,
5930  const bson::BSONObj &orderBy = _sdbStaticObject,
5931  const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
5932  } ;
5935  typedef class _sdb _sdb ;
5939  class DLLEXPORT sdb
5940  {
5941  private:
5942  sdb ( const sdb& other ) ;
5943  sdb& operator=( const sdb& ) ;
5944  public :
5951  _sdb *pSDB ;
5952 
5957  sdb ( BOOLEAN useSSL = FALSE ) :
5958  pSDB ( _sdb::getObj( useSSL ) )
5959  {
5960  }
5961 
5965  ~sdb ()
5966  {
5967  if ( pSDB )
5968  {
5969  delete pSDB ;
5970  }
5971  }
5972 
5982  INT32 connect ( const CHAR *pHostName,
5983  UINT16 port
5984  )
5985  {
5986  if ( !pSDB )
5987  {
5988  return SDB_NOT_CONNECTED ;
5989  }
5990  return pSDB->connect ( pHostName, port ) ;
5991  }
5992 
6006  INT32 connect ( const CHAR *pHostName,
6007  UINT16 port,
6008  const CHAR *pUsrName,
6009  const CHAR *pPasswd
6010  )
6011  {
6012  if ( !pSDB )
6013  {
6014  return SDB_NOT_CONNECTED ;
6015  }
6016  return pSDB->connect ( pHostName, port,
6017  pUsrName, pPasswd ) ;
6018  }
6019 
6029  INT32 connect ( const CHAR *pHostName,
6030  const CHAR *pServiceName
6031  )
6032  {
6033  if ( !pSDB )
6034  {
6035  return SDB_NOT_CONNECTED ;
6036  }
6037  return pSDB->connect ( pHostName, pServiceName ) ;
6038  }
6039 
6053  INT32 connect ( const CHAR *pHostName,
6054  const CHAR *pServiceName,
6055  const CHAR *pUsrName,
6056  const CHAR *pPasswd )
6057  {
6058  if ( !pSDB )
6059  {
6060  return SDB_NOT_CONNECTED ;
6061  }
6062  return pSDB->connect ( pHostName, pServiceName,
6063  pUsrName, pPasswd ) ;
6064  }
6065 
6079  INT32 connect ( const CHAR **pConnAddrs,
6080  INT32 arrSize,
6081  const CHAR *pUsrName,
6082  const CHAR *pPasswd )
6083  {
6084  if ( !pSDB )
6085  {
6086  return SDB_NOT_CONNECTED ;
6087  }
6088  return pSDB->connect ( pConnAddrs, arrSize,
6089  pUsrName, pPasswd ) ;
6090  }
6091 
6107  INT32 connect ( const CHAR **pConnAddrs,
6108  INT32 arrSize,
6109  const CHAR *pUsrName,
6110  const CHAR *pToken,
6111  const CHAR *pCipherFile )
6112  {
6113  if ( !pSDB )
6114  {
6115  return SDB_NOT_CONNECTED ;
6116  }
6117  return pSDB->connect ( pConnAddrs, arrSize,
6118  pUsrName, pToken, pCipherFile ) ;
6119  }
6120 
6125  UINT64 getDbStartTime ()
6126  {
6127  if ( !pSDB )
6128  {
6129  return -1 ;
6130  }
6131  return pSDB->getDbStartTime() ;
6132  }
6133 
6138  const CHAR *getAddress ()
6139  {
6140  if ( !pSDB )
6141  {
6142  return NULL ;
6143  }
6144  return pSDB->getAddress () ;
6145  }
6146 
6147 
6157  void getVersion ( UINT8 &version, UINT8 &subVersion, UINT8 &fixVersion )
6158  {
6159  if ( !pSDB )
6160  {
6161  return ;
6162  }
6163  pSDB->getVersion( version, subVersion, fixVersion ) ;
6164  }
6165 
6194  INT32 createUsr( const CHAR *pUsrName,
6195  const CHAR *pPasswd,
6196  const bson::BSONObj &options = _sdbStaticObject )
6197  {
6198  if ( !pSDB )
6199  {
6200  return SDB_NOT_CONNECTED ;
6201  }
6202  return pSDB->createUsr( pUsrName, pPasswd, options ) ;
6203  }
6204 
6213  INT32 removeUsr( const CHAR *pUsrName,
6214  const CHAR *pPasswd )
6215  {
6216  if ( !pSDB )
6217  {
6218  return SDB_NOT_CONNECTED ;
6219  }
6220  return pSDB->removeUsr( pUsrName, pPasswd ) ;
6221  }
6222 
6235  INT32 alterUsr( const CHAR *pUsrName,
6236  const CHAR *pAction,
6237  const bson::BSONObj &options )
6238  {
6239  if ( !pSDB )
6240  {
6241  return SDB_NOT_CONNECTED ;
6242  }
6243  return pSDB->alterUsr( pUsrName, pAction, options ) ;
6244  }
6245 
6256  INT32 changeUsrPasswd( const CHAR *pUsrName,
6257  const CHAR *pOldPasswd,
6258  const CHAR *pNewPasswd )
6259  {
6260  if ( !pSDB )
6261  {
6262  return SDB_NOT_CONNECTED ;
6263  }
6264  return pSDB->changeUsrPasswd( pUsrName, pOldPasswd, pNewPasswd ) ;
6265  }
6266 
6270  void disconnect ()
6271  {
6272  if ( !pSDB )
6273  {
6274  return ;
6275  }
6276  pSDB->disconnect () ;
6277  }
6278 
6320  INT32 getSnapshot ( sdbCursor &cursor,
6321  INT32 snapType,
6322  const bson::BSONObj &condition = _sdbStaticObject,
6323  const bson::BSONObj &selector = _sdbStaticObject,
6324  const bson::BSONObj &orderBy = _sdbStaticObject,
6325  const bson::BSONObj &hint = _sdbStaticObject,
6326  INT64 numToSkip = 0,
6327  INT64 numToReturn = -1 )
6328  {
6329  if ( !pSDB )
6330  {
6331  return SDB_NOT_CONNECTED ;
6332  }
6333  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6334  return pSDB->getSnapshot ( cursor, snapType, condition,
6335  selector, orderBy, hint,
6336  numToSkip, numToReturn ) ;
6337  }
6338 
6339  /* \fn INT32 getSnapshot ( _sdbCursor **cursor,
6340  INT32 snapType,
6341  const bson::BSONObj &condition,
6342  const bson::BSONObj &selector,
6343  const bson::BSONObj &orderBy,
6344  const bson::BSONObj &hint,
6345  INT64 numToSkip,
6346  INT64 numToReturn
6347  )
6348  \brief Get the snapshots of specified type.
6349  \param [in] snapType The snapshot type as below
6350 
6351  SDB_SNAP_CONTEXTS : Get the snapshot of all the contexts
6352  SDB_SNAP_CONTEXTS_CURRENT : Get the snapshot of current context
6353  SDB_SNAP_SESSIONS : Get the snapshot of all the sessions
6354  SDB_SNAP_SESSIONS_CURRENT : Get the snapshot of current session
6355  SDB_SNAP_COLLECTIONS : Get the snapshot of all the collections
6356  SDB_SNAP_COLLECTIONSPACES : Get the snapshot of all the collection spaces
6357  SDB_SNAP_DATABASE : Get the snapshot of the database
6358  SDB_SNAP_SYSTEM : Get the snapshot of the system
6359  SDB_SNAP_CATALOG : Get the snapshot of the catalog
6360  SDB_SNAP_TRANSACTIONS : Get snapshot of transactions in current session
6361  SDB_SNAP_TRANSACTIONS_CURRENT : Get snapshot of all the transactions
6362  SDB_SNAP_ACCESSPLANS : Get the snapshot of cached access plans
6363  SDB_SNAP_HEALTH : Get snapshot of node health detection
6364  SDB_SNAP_CONFIGS : Get snapshot of node configurations
6365  SDB_SNAP_SVCTASKS : Get snapshot of service task
6366  SDB_SNAP_SEQUENCES : Get the snapshot of sequences
6367  SDB_SNAP_INDEXSTATS : Get the snapshot of index statistics
6368  SDB_SNAP_RECYCLEBIN : Get the snapshot of items in recycle bin
6369 
6370  \param [in] condition The matching rule, match all the documents if not provided.
6371  \param [in] select The selective rule, return the whole document if not provided.
6372  \param [in] orderBy The ordered rule, result set is unordered if not provided.
6373  \param [in] hint The options provided for specific snapshot type.
6374  format:{ '$Options': { <options> } }
6375  \param [in] numToSkip Skip the first numToSkip documents, default is 0
6376  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
6377  \param [out] cursor The return cursor handle of query.
6378  \retval SDB_OK Operation Success
6379  \retval Others Operation Fail
6380  */
6381  INT32 getSnapshot ( _sdbCursor **cursor,
6382  INT32 snapType,
6383  const bson::BSONObj &condition = _sdbStaticObject,
6384  const bson::BSONObj &selector = _sdbStaticObject,
6385  const bson::BSONObj &orderBy = _sdbStaticObject,
6386  const bson::BSONObj &hint = _sdbStaticObject,
6387  INT64 numToSkip = 0,
6388  INT64 numToReturn = -1 )
6389  {
6390  if ( !pSDB )
6391  {
6392  return SDB_NOT_CONNECTED ;
6393  }
6394  return pSDB->getSnapshot ( cursor, snapType, condition,
6395  selector, orderBy, hint,
6396  numToSkip, numToReturn ) ;
6397  }
6398 
6421  INT32 resetSnapshot ( const bson::BSONObj &options = _sdbStaticObject )
6422  {
6423  if ( !pSDB )
6424  {
6425  return SDB_NOT_CONNECTED ;
6426  }
6427  return pSDB->resetSnapshot ( options ) ;
6428  }
6429 
6430  INT32 getList ( _sdbCursor **cursor,
6431  INT32 listType,
6432  const bson::BSONObj &condition = _sdbStaticObject,
6433  const bson::BSONObj &selector = _sdbStaticObject,
6434  const bson::BSONObj &orderBy = _sdbStaticObject,
6435  const bson::BSONObj &hint = _sdbStaticObject,
6436  INT64 numToSkip = 0,
6437  INT64 numToReturn = -1
6438  )
6439  {
6440  if ( !pSDB )
6441  {
6442  return SDB_NOT_CONNECTED ;
6443  }
6444  return pSDB->getList ( cursor, listType,
6445  condition, selector, orderBy, hint,
6446  numToSkip, numToReturn ) ;
6447  }
6448 
6491  INT32 getList ( sdbCursor &cursor,
6492  INT32 listType,
6493  const bson::BSONObj &condition = _sdbStaticObject,
6494  const bson::BSONObj &selector = _sdbStaticObject,
6495  const bson::BSONObj &orderBy = _sdbStaticObject,
6496  const bson::BSONObj &hint = _sdbStaticObject,
6497  INT64 numToSkip = 0,
6498  INT64 numToReturn = -1
6499  )
6500  {
6501  if ( !pSDB )
6502  {
6503  return SDB_NOT_CONNECTED ;
6504  }
6505  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6506  return pSDB->getList ( cursor, listType,
6507  condition, selector, orderBy, hint,
6508  numToSkip, numToReturn ) ;
6509  }
6510 
6511  INT32 getCollection ( const CHAR *pCollectionFullName,
6512  _sdbCollection **collection,
6513  BOOLEAN checkExist = TRUE
6514  )
6515  {
6516  if ( !pSDB )
6517  {
6518  return SDB_NOT_CONNECTED ;
6519  }
6520  return pSDB->getCollection ( pCollectionFullName,
6521  collection, checkExist ) ;
6522  }
6523 
6534  INT32 getCollection ( const CHAR *pCollectionFullName,
6535  sdbCollection &collection,
6536  BOOLEAN checkExist = TRUE
6537  )
6538  {
6539  if ( !pSDB )
6540  {
6541  return SDB_NOT_CONNECTED ;
6542  }
6543  RELEASE_INNER_HANDLE( collection.pCollection ) ;
6544  return pSDB->getCollection ( pCollectionFullName,
6545  collection,
6546  checkExist ) ;
6547  }
6548 
6549  INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
6550  _sdbCollectionSpace **cs,
6551  BOOLEAN checkExist = TRUE
6552  )
6553  {
6554  if ( !pSDB )
6555  {
6556  return SDB_NOT_CONNECTED ;
6557  }
6558  return pSDB->getCollectionSpace ( pCollectionSpaceName,
6559  cs, checkExist ) ;
6560  }
6561 
6572  INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
6573  sdbCollectionSpace &cs,
6574  BOOLEAN checkExist = TRUE
6575  )
6576  {
6577  if ( !pSDB )
6578  {
6579  return SDB_NOT_CONNECTED ;
6580  }
6582  return pSDB->getCollectionSpace ( pCollectionSpaceName,
6583  cs, checkExist ) ;
6584  }
6585 
6586  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6587  INT32 iPageSize,
6588  _sdbCollectionSpace **cs
6589  )
6590  {
6591  if ( !pSDB )
6592  {
6593  return SDB_NOT_CONNECTED ;
6594  }
6595  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6596  iPageSize,
6597  cs ) ;
6598  }
6599 
6618  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6619  INT32 iPageSize,
6620  sdbCollectionSpace &cs
6621  )
6622  {
6623  if ( !pSDB )
6624  {
6625  return SDB_NOT_CONNECTED ;
6626  }
6628  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6629  iPageSize, cs ) ;
6630  }
6631 
6632  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6633  const bson::BSONObj &options,
6634  _sdbCollectionSpace **cs
6635  )
6636  {
6637  if ( !pSDB )
6638  {
6639  return SDB_NOT_CONNECTED ;
6640  }
6641  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6642  options, cs ) ;
6643  }
6644 
6662  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6663  const bson::BSONObj &options,
6664  sdbCollectionSpace &cs
6665  )
6666  {
6667  if ( !pSDB )
6668  {
6669  return SDB_NOT_CONNECTED ;
6670  }
6672  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6673  options, cs ) ;
6674  }
6675 
6684  INT32 dropCollectionSpace (
6685  const CHAR *pCollectionSpaceName,
6686  const bson::BSONObj &options = _sdbStaticObject )
6687  {
6688  if ( !pSDB )
6689  {
6690  return SDB_NOT_CONNECTED ;
6691  }
6692 
6693  return pSDB->dropCollectionSpace ( pCollectionSpaceName, options ) ;
6694  }
6695 
6696  INT32 listCollectionSpaces ( _sdbCursor **result )
6697  {
6698  if ( !pSDB )
6699  {
6700  return SDB_NOT_CONNECTED ;
6701  }
6702  return pSDB->listCollectionSpaces ( result ) ;
6703  }
6704 
6711  INT32 listCollectionSpaces ( sdbCursor &cursor )
6712  {
6713  if ( !pSDB )
6714  {
6715  return SDB_NOT_CONNECTED ;
6716  }
6717  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6718  return pSDB->listCollectionSpaces ( cursor ) ;
6719  }
6720 
6721  /* \fn INT32 listCollections ( _sdbCursor **result )
6722  \brief list all collections in current database.
6723  \param [out] result The return cursor handle of query.
6724  \retval SDB_OK Operation Success
6725  \retval Others Operation Fail
6726  */
6727  INT32 listCollections ( _sdbCursor **result )
6728  {
6729  if ( !pSDB )
6730  {
6731  return SDB_NOT_CONNECTED ;
6732  }
6733  return pSDB->listCollections ( result ) ;
6734  }
6735 
6742  INT32 listCollections ( sdbCursor &cursor )
6743  {
6744  if ( !pSDB )
6745  {
6746  return SDB_NOT_CONNECTED ;
6747  }
6748  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6749  return pSDB->listCollections ( cursor ) ;
6750  }
6751 
6752  /* \fn INT32 listReplicaGroups ( _sdbCursor **result )
6753  \brief List all replica groups of current database.
6754  \param [out] result The return cursor handle of query.
6755  \retval SDB_OK Operation Success
6756  \retval Others Operation Fail
6757  */
6758  INT32 listReplicaGroups ( _sdbCursor **result )
6759  {
6760  if ( !pSDB )
6761  {
6762  return SDB_NOT_CONNECTED ;
6763  }
6764  return pSDB->listReplicaGroups ( result ) ;
6765  }
6766 
6767 
6774  INT32 listReplicaGroups ( sdbCursor &cursor )
6775  {
6776  if ( !pSDB )
6777  {
6778  return SDB_NOT_CONNECTED ;
6779  }
6780  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6781  return pSDB->listReplicaGroups ( cursor ) ;
6782  }
6783 
6784  /* \fn INT32 getReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **result )
6785  \brief Get the specified replica group.
6786  \param [in] pName The name of replica group.
6787  \param [out] result The sdbReplicaGroup object.
6788  \retval SDB_OK Operation Success
6789  \retval Others Operation Fail
6790  */
6791  INT32 getReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **result )
6792  {
6793  if ( !pSDB )
6794  {
6795  return SDB_NOT_CONNECTED ;
6796  }
6797  return pSDB->getReplicaGroup ( pName, result ) ;
6798  }
6799 
6800 
6808  INT32 getReplicaGroup ( const CHAR *pName, sdbReplicaGroup &group )
6809  {
6810  if ( !pSDB )
6811  {
6812  return SDB_NOT_CONNECTED ;
6813  }
6815  return pSDB->getReplicaGroup ( pName, group ) ;
6816  }
6817 
6818  /* \fn INT32 getReplicaGroup ( INT32 id, _sdbReplicaGroup **result )
6819  \brief Get the specified replica group.
6820  \param [in] id The id of replica group.
6821  \param [out] result The _sdbReplicaGroup object.
6822  \retval SDB_OK Operation Success
6823  \retval Others Operation Fail
6824  */
6825  INT32 getReplicaGroup ( INT32 id, _sdbReplicaGroup **result )
6826  {
6827  if ( !pSDB )
6828  {
6829  return SDB_NOT_CONNECTED ;
6830  }
6831  return pSDB->getReplicaGroup ( id, result ) ;
6832  }
6833 
6841  INT32 getReplicaGroup ( INT32 id, sdbReplicaGroup &group )
6842  {
6843  if ( !pSDB )
6844  {
6845  return SDB_NOT_CONNECTED ;
6846  }
6848  return pSDB->getReplicaGroup ( id, group ) ;
6849  }
6850 
6851  /* \fn INT32 createReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
6852  \brief Create the specified replica group.
6853  \param [in] pName The name of the replica group.
6854  \param [out] replicaGroup The return _sdbReplicaGroup object.
6855  \retval SDB_OK Operation Success
6856  \retval Others Operation Fail
6857  */
6858  INT32 createReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
6859  {
6860  if ( !pSDB )
6861  {
6862  return SDB_NOT_CONNECTED ;
6863  }
6864  return pSDB->createReplicaGroup ( pName, replicaGroup ) ;
6865  }
6866 
6874  INT32 createReplicaGroup ( const CHAR *pName, sdbReplicaGroup &group )
6875  {
6876  if ( !pSDB )
6877  {
6878  return SDB_NOT_CONNECTED ;
6879  }
6881  return pSDB->createReplicaGroup ( pName, group ) ;
6882  }
6883 
6890  INT32 removeReplicaGroup ( const CHAR *pName )
6891  {
6892  if ( !pSDB )
6893  {
6894  return SDB_NOT_CONNECTED ;
6895  }
6896  return pSDB->removeReplicaGroup ( pName ) ;
6897  }
6898 
6911  INT32 createReplicaCataGroup ( const CHAR *pHostName,
6912  const CHAR *pServiceName,
6913  const CHAR *pDatabasePath,
6914  const bson::BSONObj &configure )
6915  {
6916  if ( !pSDB )
6917  {
6918  return SDB_NOT_CONNECTED ;
6919  }
6920  return pSDB->createReplicaCataGroup ( pHostName, pServiceName,
6921  pDatabasePath, configure ) ;
6922  }
6923 
6924  INT32 activateReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
6925  {
6926  if ( !pSDB )
6927  {
6928  return SDB_NOT_CONNECTED ;
6929  }
6930  return pSDB->activateReplicaGroup ( pName, replicaGroup ) ;
6931  }
6932 
6940  INT32 activateReplicaGroup ( const CHAR *pName, sdbReplicaGroup &replicaGroup )
6941  {
6942  if ( !pSDB )
6943  {
6944  return SDB_NOT_CONNECTED ;
6945  }
6946  RELEASE_INNER_HANDLE( replicaGroup.pReplicaGroup ) ;
6947  return pSDB->activateReplicaGroup ( pName, replicaGroup ) ;
6948  }
6949 
6957  INT32 execUpdate( const CHAR *sql, bson::BSONObj *pResult = NULL )
6958  {
6959  if ( !pSDB )
6960  {
6961  return SDB_NOT_CONNECTED ;
6962  }
6963  return pSDB->execUpdate( sql, pResult ) ;
6964  }
6965 
6966  /* \fn INT32 exec( const CHAR *sql,
6967  _sdbCursor **result )
6968  \brief Executing SQL command.
6969  \param [in] sql The SQL command.
6970  \param [out] result The return cursor handle of matching documents.
6971  \retval SDB_OK Operation Success
6972  \retval Others Operation Fail
6973  */
6974  INT32 exec( const CHAR *sql,
6975  _sdbCursor **result )
6976  {
6977  if ( !pSDB )
6978  {
6979  return SDB_NOT_CONNECTED ;
6980  }
6981  return pSDB->exec( sql, result ) ;
6982  }
6983 
6992  INT32 exec( const CHAR *sql,
6993  sdbCursor &cursor )
6994  {
6995  if ( !pSDB )
6996  {
6997  return SDB_NOT_CONNECTED ;
6998  }
6999  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7000  return pSDB->exec( sql, cursor ) ;
7001  }
7002 
7008  INT32 transactionBegin()
7009  {
7010  if ( !pSDB )
7011  {
7012  return SDB_NOT_CONNECTED ;
7013  }
7014  return pSDB->transactionBegin() ;
7015  }
7016 
7024  INT32 transactionCommit( const bson::BSONObj &hint = _sdbStaticObject )
7025  {
7026  if ( !pSDB )
7027  {
7028  return SDB_NOT_CONNECTED ;
7029  }
7030  return pSDB->transactionCommit( hint ) ;
7031  }
7032 
7038  INT32 transactionRollback()
7039  {
7040  if ( !pSDB )
7041  {
7042  return SDB_NOT_CONNECTED ;
7043  }
7044  return pSDB->transactionRollback() ;
7045  }
7055  INT32 flushConfigure( const bson::BSONObj &options )
7056  {
7057  if ( !pSDB )
7058  {
7059  return SDB_NOT_CONNECTED ;
7060  }
7061  return pSDB->flushConfigure( options ) ;
7062  }
7063 
7070  INT32 crtJSProcedure ( const CHAR *code )
7071  {
7072  if ( !pSDB )
7073  {
7074  return SDB_NOT_CONNECTED ;
7075  }
7076  return pSDB->crtJSProcedure( code ) ;
7077  }
7078 
7085  INT32 rmProcedure( const CHAR *spName )
7086  {
7087  if ( !pSDB )
7088  {
7089  return SDB_NOT_CONNECTED ;
7090  }
7091  return pSDB->rmProcedure( spName ) ;
7092  }
7093 
7094  INT32 listProcedures( _sdbCursor **cursor, const bson::BSONObj &condition )
7095  {
7096  if ( !pSDB )
7097  {
7098  return SDB_NOT_CONNECTED ;
7099  }
7100  return pSDB->listProcedures( cursor, condition ) ;
7101  }
7102 
7110  INT32 listProcedures( sdbCursor &cursor, const bson::BSONObj &condition )
7111  {
7112  if ( !pSDB )
7113  {
7114  return SDB_NOT_CONNECTED ;
7115  }
7116  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7117  return pSDB->listProcedures( cursor, condition ) ;
7118  }
7119 
7120  INT32 evalJS( const CHAR *code,
7121  SDB_SPD_RES_TYPE &type,
7122  _sdbCursor **cursor,
7123  bson::BSONObj &errmsg )
7124  {
7125  if ( !pSDB )
7126  {
7127  return SDB_NOT_CONNECTED ;
7128  }
7129  return pSDB->evalJS( code, type, cursor, errmsg ) ;
7130  }
7131 
7144  INT32 evalJS( const CHAR *code, SDB_SPD_RES_TYPE &type,
7145  sdbCursor &cursor,
7146  bson::BSONObj &errmsg )
7147  {
7148  if ( !pSDB )
7149  {
7150  return SDB_NOT_CONNECTED ;
7151  }
7152  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7153  return pSDB->evalJS( code, type, cursor, errmsg ) ;
7154  }
7155 
7175  INT32 backupOffline ( const bson::BSONObj &options)
7176  {
7177  return backup( options ) ;
7178  }
7179 
7198  INT32 backup ( const bson::BSONObj &options)
7199  {
7200  if ( !pSDB )
7201  {
7202  return SDB_NOT_CONNECTED ;
7203  }
7204  return pSDB->backup( options ) ;
7205  }
7206 
7207 
7208  INT32 listBackup ( _sdbCursor **cursor,
7209  const bson::BSONObj &options,
7210  const bson::BSONObj &condition = _sdbStaticObject,
7211  const bson::BSONObj &selector = _sdbStaticObject,
7212  const bson::BSONObj &orderBy = _sdbStaticObject)
7213  {
7214  if ( !pSDB )
7215  {
7216  return SDB_NOT_CONNECTED ;
7217  }
7218  return pSDB->listBackup( cursor, options, condition, selector, orderBy ) ;
7219  }
7220 
7243  INT32 listBackup ( sdbCursor &cursor,
7244  const bson::BSONObj &options,
7245  const bson::BSONObj &condition = _sdbStaticObject,
7246  const bson::BSONObj &selector = _sdbStaticObject,
7247  const bson::BSONObj &orderBy = _sdbStaticObject)
7248  {
7249  if ( !pSDB )
7250  {
7251  return SDB_NOT_CONNECTED ;
7252  }
7253  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7254  return pSDB->listBackup( cursor, options, condition, selector, orderBy ) ;
7255  }
7256 
7271  INT32 removeBackup ( const bson::BSONObj &options)
7272  {
7273  if ( !pSDB )
7274  {
7275  return SDB_NOT_CONNECTED ;
7276  }
7277  return pSDB->removeBackup( options ) ;
7278  }
7279 
7280  INT32 listTasks ( _sdbCursor **cursor,
7281  const bson::BSONObj &condition = _sdbStaticObject,
7282  const bson::BSONObj &selector = _sdbStaticObject,
7283  const bson::BSONObj &orderBy = _sdbStaticObject,
7284  const bson::BSONObj &hint = _sdbStaticObject)
7285  {
7286  if ( !pSDB )
7287  {
7288  return SDB_NOT_CONNECTED ;
7289  }
7290  return pSDB->listTasks ( cursor,
7291  condition,
7292  selector,
7293  orderBy,
7294  hint ) ;
7295  }
7313  INT32 listTasks ( sdbCursor &cursor,
7314  const bson::BSONObj &condition = _sdbStaticObject,
7315  const bson::BSONObj &selector = _sdbStaticObject,
7316  const bson::BSONObj &orderBy = _sdbStaticObject,
7317  const bson::BSONObj &hint = _sdbStaticObject)
7318  {
7319  if ( !pSDB )
7320  {
7321  return SDB_NOT_CONNECTED ;
7322  }
7323  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7324  return pSDB->listTasks ( cursor,
7325  condition,
7326  selector,
7327  orderBy,
7328  hint ) ;
7329  }
7330 
7339  INT32 waitTasks ( const SINT64 *taskIDs,
7340  SINT32 num )
7341  {
7342  if ( !pSDB )
7343  {
7344  return SDB_NOT_CONNECTED ;
7345  }
7346  return pSDB->waitTasks ( taskIDs,
7347  num ) ;
7348  }
7349 
7359  INT32 cancelTask ( SINT64 taskID,
7360  BOOLEAN isAsync )
7361  {
7362  if ( !pSDB )
7363  {
7364  return SDB_NOT_CONNECTED ;
7365  }
7366  return pSDB->cancelTask ( taskID,
7367  isAsync ) ;
7368  }
7369 
7380  INT32 setSessionAttr ( const bson::BSONObj &options = _sdbStaticObject )
7381  {
7382  if ( !pSDB )
7383  {
7384  return SDB_NOT_CONNECTED ;
7385  }
7386  return pSDB->setSessionAttr ( options ) ;
7387  }
7388 
7397  INT32 getSessionAttr ( bson::BSONObj & result,
7398  BOOLEAN useCache = TRUE )
7399  {
7400  if ( !pSDB )
7401  {
7402  return SDB_NOT_CONNECTED ;
7403  }
7404  return pSDB->getSessionAttr( result, useCache ) ;
7405  }
7406 
7413  INT32 closeAllCursors ()
7414  {
7415  return interrupt() ;
7416  }
7417 
7424  INT32 interrupt()
7425  {
7426  if ( !pSDB )
7427  {
7428  return SDB_NOT_CONNECTED ;
7429  }
7430  return pSDB->interrupt () ;
7431  }
7432 
7441  INT32 interruptOperation()
7442  {
7443  if ( !pSDB )
7444  {
7445  return SDB_NOT_CONNECTED ;
7446  }
7447  return pSDB->interruptOperation () ;
7448  }
7449 
7457  INT32 isValid ( BOOLEAN *result )
7458  {
7459  if ( !pSDB )
7460  {
7461  return SDB_NOT_CONNECTED ;
7462  }
7463  return pSDB->isValid ( result ) ;
7464  }
7465 
7470  BOOLEAN isValid ()
7471  {
7472  if ( !pSDB )
7473  {
7474  return FALSE ;
7475  }
7476  return pSDB->isValid () ;
7477  }
7478 
7483  BOOLEAN isClosed()
7484  {
7485  if (!pSDB)
7486  {
7487  return TRUE ;
7488  }
7489  return pSDB->isClosed() ;
7490  }
7491 
7510  INT32 createDomain ( const CHAR *pDomainName,
7511  const bson::BSONObj &options,
7512  sdbDomain &domain )
7513  {
7514  if ( !pSDB )
7515  {
7516  return SDB_NOT_CONNECTED ;
7517  }
7518  RELEASE_INNER_HANDLE( domain.pDomain ) ;
7519  return pSDB->createDomain ( pDomainName, options, domain ) ;
7520  }
7521 
7522  INT32 createDomain ( const CHAR *pDomainName,
7523  const bson::BSONObj &options,
7524  _sdbDomain **domain )
7525  {
7526  if ( !pSDB )
7527  {
7528  return SDB_NOT_CONNECTED ;
7529  }
7530  return pSDB->createDomain ( pDomainName, options, domain ) ;
7531  }
7532 
7539  INT32 dropDomain ( const CHAR *pDomainName )
7540  {
7541  if ( !pSDB )
7542  {
7543  return SDB_NOT_CONNECTED ;
7544  }
7545  return pSDB->dropDomain ( pDomainName ) ;
7546  }
7547 
7548  INT32 getDomain ( const CHAR *pDomainName,
7549  _sdbDomain **domain )
7550  {
7551  if ( !pSDB )
7552  {
7553  return SDB_NOT_CONNECTED ;
7554  }
7555  return pSDB->getDomain ( pDomainName, domain ) ;
7556  }
7557 
7566  INT32 getDomain ( const CHAR *pDomainName,
7567  sdbDomain &domain )
7568  {
7569  if ( !pSDB )
7570  {
7571  return SDB_NOT_CONNECTED ;
7572  }
7573  RELEASE_INNER_HANDLE( domain.pDomain ) ;
7574  return pSDB->getDomain ( pDomainName, domain ) ;
7575  }
7576 
7577  INT32 listDomains ( _sdbCursor **cursor,
7578  const bson::BSONObj &condition = _sdbStaticObject,
7579  const bson::BSONObj &selector = _sdbStaticObject,
7580  const bson::BSONObj &orderBy = _sdbStaticObject,
7581  const bson::BSONObj &hint = _sdbStaticObject )
7582  {
7583  if ( !pSDB )
7584  {
7585  return SDB_NOT_CONNECTED ;
7586  }
7587  return pSDB->listDomains ( cursor, condition, selector, orderBy, hint ) ;
7588  }
7589 
7607  INT32 listDomains ( sdbCursor &cursor,
7608  const bson::BSONObj &condition = _sdbStaticObject,
7609  const bson::BSONObj &selector = _sdbStaticObject,
7610  const bson::BSONObj &orderBy = _sdbStaticObject,
7611  const bson::BSONObj &hint = _sdbStaticObject )
7612  {
7613  if ( !pSDB )
7614  {
7615  return SDB_NOT_CONNECTED ;
7616  }
7617  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7618  return pSDB->listDomains ( cursor, condition, selector, orderBy, hint ) ;
7619  }
7620 
7621  /* \fn INT32 getDC( sdbDataCenter &dc )
7622  \brief Get current data center.
7623  \retval SDB_OK Operation Success
7624  \retval Others Operation Fail
7625  */
7626  INT32 getDC( sdbDataCenter &dc )
7627  {
7628  if ( !pSDB )
7629  {
7630  return SDB_NOT_CONNECTED ;
7631  }
7632  RELEASE_INNER_HANDLE( dc.pDC ) ;
7633  return pSDB->getDC ( dc ) ;
7634  }
7635 
7636  /* \fn INT32 getDC( _sdbDataCenter **dc )
7637  \brief Get current data center.
7638  \retval SDB_OK Operation Success
7639  \retval Others Operation Fail
7640  */
7641  INT32 getDC( _sdbDataCenter **dc )
7642  {
7643  if ( !pSDB )
7644  {
7645  return SDB_NOT_CONNECTED ;
7646  }
7647  return pSDB->getDC ( dc ) ;
7648  }
7649 
7650  /* \fn INT32 getRecycleBin( sdbRecycleBin &recycleBin )
7651  \brief Get current recycle bin.
7652  \retval SDB_OK Operation Success
7653  \retval Others Operation Fail
7654  */
7655  INT32 getRecycleBin( sdbRecycleBin &recycleBin )
7656  {
7657  if ( !pSDB )
7658  {
7659  return SDB_NOT_CONNECTED ;
7660  }
7661  RELEASE_INNER_HANDLE( recycleBin.pRecycleBin ) ;
7662  return pSDB->getRecycleBin( recycleBin ) ;
7663  }
7664 
7665  /* \fn INT32 getRecycleBin( _sdbRecycleBin **recycleBin )
7666  \brief Get current recycle bin.
7667  \retval SDB_OK Operation Success
7668  \retval Others Operation Fail
7669  */
7670  INT32 getRecycleBin( _sdbRecycleBin **recycleBin )
7671  {
7672  if ( !pSDB )
7673  {
7674  return SDB_NOT_CONNECTED ;
7675  }
7676  return pSDB->getRecycleBin( recycleBin ) ;
7677  }
7678 
7684  UINT64 getLastAliveTime() const { return pSDB->getLastAliveTime(); }
7685 
7708  INT32 syncDB( const bson::BSONObj &options = _sdbStaticObject )
7709  {
7710  if ( !pSDB )
7711  {
7712  return SDB_NOT_CONNECTED ;
7713  }
7714  return pSDB->syncDB ( options ) ;
7715  }
7716 
7743  INT32 analyze ( const bson::BSONObj &options = _sdbStaticObject )
7744  {
7745  if ( !pSDB )
7746  {
7747  return SDB_NOT_CONNECTED ;
7748  }
7749  return pSDB->analyze ( options ) ;
7750  }
7751 
7767  INT32 forceSession( SINT64 sessionID,
7768  const bson::BSONObj &options = _sdbStaticObject )
7769  {
7770  if( !pSDB )
7771  {
7772  return SDB_NOT_CONNECTED ;
7773  }
7774  return pSDB->forceSession( sessionID, options ) ;
7775  }
7776 
7791  INT32 forceStepUp( const bson::BSONObj &options = _sdbStaticObject )
7792  {
7793  if( !pSDB )
7794  {
7795  return SDB_NOT_CONNECTED ;
7796  }
7797  return pSDB->forceStepUp( options ) ;
7798  }
7799 
7812  INT32 invalidateCache( const bson::BSONObj &options = _sdbStaticObject )
7813  {
7814  if( !pSDB )
7815  {
7816  return SDB_NOT_CONNECTED ;
7817  }
7818  return pSDB->invalidateCache( options ) ;
7819  }
7820 
7834  INT32 reloadConfig( const bson::BSONObj &options = _sdbStaticObject )
7835  {
7836  if( !pSDB )
7837  {
7838  return SDB_NOT_CONNECTED ;
7839  }
7840  return pSDB->reloadConfig( options ) ;
7841  }
7842 
7859  INT32 updateConfig( const bson::BSONObj &configs = _sdbStaticObject,
7860  const bson::BSONObj &options = _sdbStaticObject )
7861  {
7862  if( !pSDB )
7863  {
7864  return SDB_NOT_CONNECTED ;
7865  }
7866  return pSDB->updateConfig( configs, options ) ;
7867  }
7868 
7885  INT32 deleteConfig( const bson::BSONObj &configs = _sdbStaticObject,
7886  const bson::BSONObj &options = _sdbStaticObject )
7887  {
7888  if( !pSDB )
7889  {
7890  return SDB_NOT_CONNECTED ;
7891  }
7892  return pSDB->deleteConfig( configs, options ) ;
7893  }
7894 
7917  INT32 setPDLevel( INT32 level,
7918  const bson::BSONObj &options = _sdbStaticObject )
7919  {
7920  if( !pSDB )
7921  {
7922  return SDB_NOT_CONNECTED ;
7923  }
7924  return pSDB->setPDLevel( level, options ) ;
7925  }
7926 
7927  INT32 msg( const CHAR* msg )
7928  {
7929  if( !pSDB )
7930  {
7931  return SDB_NOT_CONNECTED ;
7932  }
7933  return pSDB->msg( msg ) ;
7934  }
7935 
7951  INT32 loadCS( const CHAR* csName,
7952  const bson::BSONObj &options = _sdbStaticObject )
7953  {
7954  if( !pSDB )
7955  {
7956  return SDB_NOT_CONNECTED ;
7957  }
7958  return pSDB->loadCS( csName, options ) ;
7959  }
7960 
7976  INT32 unloadCS( const CHAR* csName,
7977  const bson::BSONObj &options = _sdbStaticObject )
7978  {
7979  if( !pSDB )
7980  {
7981  return SDB_NOT_CONNECTED ;
7982  }
7983  return pSDB->unloadCS( csName, options ) ;
7984  }
7985 
7998  INT32 traceStart( UINT32 traceBufferSize,
7999  const CHAR* component = NULL,
8000  const CHAR* breakpoint = NULL,
8001  const vector<UINT32> &tidVec = _sdbStaticUINT32Vec )
8002  {
8003  if( !pSDB )
8004  {
8005  return SDB_NOT_CONNECTED ;
8006  }
8007  return pSDB->traceStart( traceBufferSize, component,
8008  breakpoint, tidVec ) ;
8009  }
8010 
8030  INT32 traceStart( UINT32 traceBufferSize,
8031  const bson::BSONObj &options )
8032  {
8033  if( !pSDB )
8034  {
8035  return SDB_NOT_CONNECTED ;
8036  }
8037  return pSDB->traceStart( traceBufferSize, options ) ;
8038  }
8039 
8048  INT32 traceStop( const CHAR* dumpFileName )
8049  {
8050  if( !pSDB )
8051  {
8052  return SDB_NOT_CONNECTED ;
8053  }
8054  return pSDB->traceStop( dumpFileName ) ;
8055  }
8056 
8062  INT32 traceResume()
8063  {
8064  if( !pSDB )
8065  {
8066  return SDB_NOT_CONNECTED ;
8067  }
8068  return pSDB->traceResume() ;
8069  }
8070 
8077  INT32 traceStatus( sdbCursor& cursor )
8078  {
8079  if( !pSDB )
8080  {
8081  return SDB_NOT_CONNECTED ;
8082  }
8083  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
8084  return pSDB->traceStatus( cursor ) ;
8085  }
8086 
8087  INT32 traceStatus( _sdbCursor** cursor )
8088  {
8089  if( !pSDB )
8090  {
8091  return SDB_NOT_CONNECTED ;
8092  }
8093  return pSDB->traceStatus( cursor ) ;
8094  }
8095 
8106  INT32 renameCollectionSpace( const CHAR* oldName,
8107  const CHAR* newName,
8108  const bson::BSONObj &options = _sdbStaticObject )
8109  {
8110  if( !pSDB )
8111  {
8112  return SDB_NOT_CONNECTED ;
8113  }
8114  return pSDB->renameCollectionSpace( oldName, newName, options ) ;
8115  }
8116 
8128  INT32 getLastErrorObj( bson::BSONObj &errObj )
8129  {
8130  if( !pSDB )
8131  {
8132  return SDB_NOT_CONNECTED ;
8133  }
8134  return pSDB->getLastErrorObj( errObj ) ;
8135  }
8136 
8140  void cleanLastErrorObj()
8141  {
8142  if( !pSDB )
8143  {
8144  return ;
8145  }
8146  return pSDB->cleanLastErrorObj() ;
8147  }
8148 
8159  INT32 getLastResultObj( bson::BSONObj &result,
8160  BOOLEAN getOwned = FALSE ) const
8161  {
8162  if( !pSDB )
8163  {
8164  return SDB_NOT_CONNECTED ;
8165  }
8166  return pSDB->getLastResultObj( result, getOwned ) ;
8167  }
8168 
8188  INT32 createSequence( const CHAR *pSequenceName,
8189  const bson::BSONObj &options,
8190  _sdbSequence **sequence )
8191  {
8192  if( !pSDB )
8193  {
8194  return SDB_NOT_CONNECTED ;
8195  }
8196  return pSDB->createSequence( pSequenceName, options, sequence ) ;
8197  }
8198 
8218  INT32 createSequence( const CHAR *pSequenceName,
8219  const bson::BSONObj &options,
8220  sdbSequence &sequence )
8221  {
8222  if( !pSDB )
8223  {
8224  return SDB_NOT_CONNECTED ;
8225  }
8226  return pSDB->createSequence( pSequenceName, options, sequence ) ;
8227  }
8228 
8237  INT32 createSequence( const CHAR *pSequenceName,
8238  sdbSequence &sequence )
8239  {
8240  if( !pSDB )
8241  {
8242  return SDB_NOT_CONNECTED ;
8243  }
8244  return pSDB->createSequence( pSequenceName, sequence ) ;
8245  }
8246 
8255  INT32 getSequence( const CHAR *pSequenceName,
8256  _sdbSequence **sequence )
8257  {
8258  if( !pSDB )
8259  {
8260  return SDB_NOT_CONNECTED ;
8261  }
8262  return pSDB->getSequence( pSequenceName, sequence ) ;
8263  }
8264 
8273  INT32 getSequence( const CHAR *pSequenceName,
8274  sdbSequence &sequence )
8275  {
8276  if( !pSDB )
8277  {
8278  return SDB_NOT_CONNECTED ;
8279  }
8280  return pSDB->getSequence( pSequenceName, sequence ) ;
8281  }
8282 
8290  INT32 renameSequence( const CHAR *pOldName, const CHAR *pNewName )
8291  {
8292  if( !pSDB )
8293  {
8294  return SDB_NOT_CONNECTED ;
8295  }
8296  return pSDB->renameSequence( pOldName, pNewName ) ;
8297  }
8298 
8305  INT32 dropSequence( const CHAR *pSequenceName )
8306  {
8307  if( !pSDB )
8308  {
8309  return SDB_NOT_CONNECTED ;
8310  }
8311  return pSDB->dropSequence( pSequenceName ) ;
8312  }
8313 
8362  INT32 createDataSource( sdbDataSource &dataSource,
8363  const CHAR *pDataSourceName,
8364  const CHAR *addresses,
8365  const CHAR *user = NULL,
8366  const CHAR *password = NULL,
8367  const CHAR *type = NULL,
8368  const bson::BSONObj *options = NULL )
8369  {
8370  if ( !pSDB )
8371  {
8372  return SDB_NOT_CONNECTED ;
8373  }
8374  RELEASE_INNER_HANDLE( dataSource.pDataSource ) ;
8375  return pSDB->createDataSource( &dataSource.pDataSource, pDataSourceName, addresses,
8376  user, password, type, options ) ;
8377  }
8378 
8385  INT32 dropDataSource( const CHAR *pDataSourceName )
8386  {
8387  if ( !pSDB )
8388  {
8389  return SDB_NOT_CONNECTED ;
8390  }
8391  return pSDB->dropDataSource( pDataSourceName ) ;
8392  }
8393 
8402  INT32 getDataSource( const CHAR *pDataSourceName,
8403  sdbDataSource &dataSource )
8404  {
8405  if ( !pSDB )
8406  {
8407  return SDB_NOT_CONNECTED ;
8408  }
8409  RELEASE_INNER_HANDLE( dataSource.pDataSource ) ;
8410  return pSDB->getDataSource( pDataSourceName, &dataSource.pDataSource ) ;
8411  }
8412 
8427  INT32 listDataSources( sdbCursor& cursor,
8428  const bson::BSONObj &condition = _sdbStaticObject,
8429  const bson::BSONObj &selector = _sdbStaticObject,
8430  const bson::BSONObj &orderBy = _sdbStaticObject,
8431  const bson::BSONObj &hint = _sdbStaticObject )
8432  {
8433  if ( !pSDB )
8434  {
8435  return SDB_NOT_CONNECTED ;
8436  }
8437  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
8438  return pSDB->listDataSources( &cursor.pCursor, condition, selector, orderBy, hint ) ;
8439  }
8440  } ;
8441 
8445  typedef class sdb sdb ;
8446 
8453  SDB_EXPORT INT32 initClient( sdbClientConf* config ) ;
8454 
8455 }
8456 
8457 #endif