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 represent whether insert return detail result
70 #define FLG_INSERT_RETURNNUM 0x00000002
71 
72 #define FLG_INSERT_REPLACEONDUP 0x00000004
73 
74 #define FLG_INSERT_RETURN_OID 0x10000000
75 
76 // client socket timeout value
77 // since client and server may not sit in the same network, we need
78 // to set this value bigger than engine socket timeout
79 // this value is in millisec
80 // set to 10 seconds timeout
81 #define SDB_CLIENT_SOCKET_TIMEOUT_DFT 10000
82 
84 #define sdbReplicaNode sdbNode
85 
87 #define QUERY_FORCE_HINT 0x00000080
88 
89 #define QUERY_PARALLED 0x00000100
90 
91 #define QUERY_WITH_RETURNDATA 0x00000200
92 
93 #define QUERY_PREPARE_MORE 0x00004000
94 
95 #define QUERY_KEEP_SHARDINGKEY_IN_UPDATE 0x00008000
96 
100 #define QUERY_FOR_UPDATE 0x00010000
101 
105 #define QUERY_FOR_SHARE 0x00040000
106 
107 
109 #define UPDATE_KEEP_SHARDINGKEY QUERY_KEEP_SHARDINGKEY_IN_UPDATE
110 
111 #define UPDATE_ONE 0x00000002
112 // The flag represent whether update return detail result
113 #define UPDATE_RETURNNUM 0x00000004
114 
116 #define FLG_DELETE_ONE 0x00000002
117 // The flag represent whether update return detail result
118 #define FLG_DELETE_RETURNNUM 0x00000004
119 
120 #define SDB_INDEX_SORT_BUFFER_DEFAULT_SIZE 64
121 
123 {
124  SDB_LOB_CREATEONLY = 0x00000001,
125  SDB_LOB_READ = 0x00000004,
126  SDB_LOB_WRITE = 0x00000008,
127  SDB_LOB_SHAREREAD = 0x00000040
128 } ;
133 
135 {
139 } ;
144 
148 namespace sdbclient
149 {
150  const static bson::BSONObj _sdbStaticObject ;
151  const static bson::OID _sdbStaticOid ;
152  const static std::vector<INT32> _sdbStaticVec ;
153  const static std::vector<UINT32> _sdbStaticUINT32Vec ;
154  class _sdbCursor ;
155  class _sdbCollection ;
156  class sdb ;
157  class _sdb ;
158  class _sdbLob ;
159  class sdbLob ;
160 
162  typedef void (*ERROR_ON_REPLY_FUNC)( const CHAR *pErrorObj,
163  UINT32 objSize,
164  INT32 flag,
165  const CHAR *pDescription,
166  const CHAR *pDetail ) ;
167 
172  SDB_EXPORT void sdbSetErrorOnReplyCallback( ERROR_ON_REPLY_FUNC func ) ;
173 
174  class DLLEXPORT _sdbCursor
175  {
176  private :
177  _sdbCursor ( const _sdbCursor& other ) ;
178  _sdbCursor& operator=( const _sdbCursor& ) ;
179  public :
180  _sdbCursor () {}
181  virtual ~_sdbCursor () {}
182  virtual INT32 next ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE ) = 0 ;
183  virtual INT32 current ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE ) = 0 ;
184  virtual INT32 close () = 0 ;
185  virtual INT32 advance ( const bson::BSONObj &option,
186  bson::BSONObj *pResult = NULL ) = 0 ;
187  } ;
188 
192  class DLLEXPORT sdbCursor
193  {
194  private :
195  sdbCursor ( const sdbCursor& other ) ;
196  sdbCursor& operator=( const sdbCursor& ) ;
197  public :
204  _sdbCursor *pCursor ;
205 
210  {
211  pCursor = NULL ;
212  }
213 
218  {
219  if ( pCursor )
220  {
221  delete pCursor ;
222  }
223  }
224 
241  INT32 next ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE )
242  {
243  if ( !pCursor )
244  {
245  return SDB_NOT_CONNECTED ;
246  }
247  return pCursor->next ( obj, getOwned ) ;
248  }
249 
266  INT32 current ( bson::BSONObj &obj, BOOLEAN getOwned = TRUE )
267  {
268  if ( !pCursor )
269  {
270  return SDB_NOT_CONNECTED ;
271  }
272  return pCursor->current ( obj, getOwned ) ;
273  }
274 
282  INT32 advance ( const bson::BSONObj &option, bson::BSONObj *pResult = NULL )
283  {
284  if ( !pCursor )
285  {
286  return SDB_NOT_CONNECTED ;
287  }
288  return pCursor->advance( option, pResult ) ;
289  }
290 
296  INT32 close ()
297  {
298  if ( !pCursor )
299  {
300  return SDB_OK ;
301  }
302  return pCursor->close () ;
303  }
304  } ;
305 
306  class DLLEXPORT _sdbCollection
307  {
308  private :
309  _sdbCollection ( const _sdbCollection& other ) ;
310  _sdbCollection& operator=( const _sdbCollection& ) ;
311  public :
312  _sdbCollection () {}
313  virtual ~_sdbCollection () {}
314  // get the total number of records for a given condition, if the condition
315  // is NULL then match all records in the collection
316  virtual INT32 getCount ( SINT64 &count,
317  const bson::BSONObj &condition = _sdbStaticObject,
318  const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
319  // insert a bson object into current collection
320  // given:
321  // object ( required )
322  // returns id as the pointer pointing to _id bson element
323  virtual INT32 insert ( const bson::BSONObj &obj, bson::OID *id = NULL ) = 0 ;
324  virtual INT32 insert ( const bson::BSONObj &obj,
325  INT32 flags,
326  bson::BSONObj *pResult = NULL ) = 0 ;
327  virtual INT32 insert ( const bson::BSONObj &obj,
328  const bson::BSONObj &hint,
329  INT32 flags,
330  bson::BSONObj *pResult = NULL ) = 0 ;
331  virtual INT32 insert ( std::vector<bson::BSONObj> &objs,
332  INT32 flags = 0,
333  bson::BSONObj *pResult = NULL ) = 0 ;
334  virtual INT32 insert ( std::vector<bson::BSONObj> &objs,
335  const bson::BSONObj &hint,
336  INT32 flags = 0,
337  bson::BSONObj *pResult = NULL ) = 0 ;
338  virtual INT32 insert ( const bson::BSONObj objs[],
339  INT32 size,
340  INT32 flags = 0,
341  bson::BSONObj *pResult = NULL ) = 0 ;
342  virtual INT32 bulkInsert ( SINT32 flags,
343  std::vector<bson::BSONObj> &obj
344  ) = 0 ;
345  // update bson object from current collection
346  // given:
347  // update rule ( required )
348  // update condition ( optional )
349  // hint ( optional )
350  // flag ( optional )
351  // pResult ( optional )
352  virtual INT32 update ( const bson::BSONObj &rule,
353  const bson::BSONObj &condition = _sdbStaticObject,
354  const bson::BSONObj &hint = _sdbStaticObject,
355  INT32 flag = 0,
356  bson::BSONObj *pResult = NULL
357  ) = 0 ;
358 
359  // update bson object from current collection, if there's nothing match
360  // then insert an record that modified from empty BSON object
361  // given:
362  // update rule ( required )
363  // update condition ( optional )
364  // hint ( optional )
365  // setOnInsert ( optional )
366  // flag ( optional )
367  // pResult ( optional )
368  virtual INT32 upsert ( const bson::BSONObj &rule,
369  const bson::BSONObj &condition = _sdbStaticObject,
370  const bson::BSONObj &hint = _sdbStaticObject,
371  const bson::BSONObj &setOnInsert = _sdbStaticObject,
372  INT32 flag = 0,
373  bson::BSONObj *pResult = NULL
374  ) = 0 ;
375 
376  // delete bson objects from current collection
377  // given:
378  // delete condition ( optional )
379  // hint ( optional )
380  // flag ( optional )
381  // pResult ( optional )
382  virtual INT32 del ( const bson::BSONObj &condition = _sdbStaticObject,
383  const bson::BSONObj &hint = _sdbStaticObject,
384  INT32 flag = 0,
385  bson::BSONObj *pResult = NULL
386  ) = 0 ;
387 
388  // query objects from current collection
389  // given:
390  // query condition ( optional )
391  // query selected def ( optional )
392  // query orderby ( optional )
393  // hint ( optional )
394  // output: _sdbCursor ( required )
395  virtual INT32 query ( _sdbCursor **cursor,
396  const bson::BSONObj &condition = _sdbStaticObject,
397  const bson::BSONObj &selected = _sdbStaticObject,
398  const bson::BSONObj &orderBy = _sdbStaticObject,
399  const bson::BSONObj &hint = _sdbStaticObject,
400  INT64 numToSkip = 0,
401  INT64 numToReturn = -1,
402  INT32 flags = 0
403  ) = 0 ;
404 
405  virtual INT32 query ( sdbCursor &cursor,
406  const bson::BSONObj &condition = _sdbStaticObject,
407  const bson::BSONObj &selected = _sdbStaticObject,
408  const bson::BSONObj &orderBy = _sdbStaticObject,
409  const bson::BSONObj &hint = _sdbStaticObject,
410  INT64 numToSkip = 0,
411  INT64 numToReturn = -1,
412  INT32 flags = 0
413  ) = 0 ;
414 
415  virtual INT32 queryOne( bson::BSONObj &obj,
416  const bson::BSONObj &condition = _sdbStaticObject,
417  const bson::BSONObj &selected = _sdbStaticObject,
418  const bson::BSONObj &orderBy = _sdbStaticObject,
419  const bson::BSONObj &hint = _sdbStaticObject,
420  INT64 numToSkip = 0,
421  INT32 flags = 0 ) = 0 ;
422 
423  // query objects from current collection and update
424  // given:
425  // update rule ( required )
426  // query condition ( optional )
427  // query selected def ( optional )
428  // query orderby ( optional )
429  // hint ( optional )
430  // flags( optional )
431  // returnNew ( optioinal )
432  // output: sdbCursor ( required )
433  virtual INT32 queryAndUpdate ( _sdbCursor **cursor,
434  const bson::BSONObj &update,
435  const bson::BSONObj &condition = _sdbStaticObject,
436  const bson::BSONObj &selected = _sdbStaticObject,
437  const bson::BSONObj &orderBy = _sdbStaticObject,
438  const bson::BSONObj &hint = _sdbStaticObject,
439  INT64 numToSkip = 0,
440  INT64 numToReturn = -1,
441  INT32 flag = 0,
442  BOOLEAN returnNew = FALSE
443  ) = 0 ;
444 
445  // query objects from current collection and remove
446  // given:
447  // query condition ( optional )
448  // query selected def ( optional )
449  // query orderby ( optional )
450  // hint ( optional )
451  // flags( optional )
452  // output: sdbCursor ( required )
453  virtual INT32 queryAndRemove ( _sdbCursor **cursor,
454  const bson::BSONObj &condition = _sdbStaticObject,
455  const bson::BSONObj &selected = _sdbStaticObject,
456  const bson::BSONObj &orderBy = _sdbStaticObject,
457  const bson::BSONObj &hint = _sdbStaticObject,
458  INT64 numToSkip = 0,
459  INT64 numToReturn = -1,
460  INT32 flag = 0
461  ) = 0 ;
462 
463  //virtual INT32 rename ( const CHAR *pNewName ) = 0 ;
464  // create an index for the current collection
465  // given:
466  // index definition ( required )
467  // index name ( required )
468  // uniqueness ( required )
469  // enforceness ( required )
470  virtual INT32 createIndex ( const bson::BSONObj &indexDef,
471  const CHAR *pName,
472  BOOLEAN isUnique,
473  BOOLEAN isEnforced,
474  INT32 sortBufferSize ) = 0 ;
475  virtual INT32 createIndex ( const bson::BSONObj &indexDef,
476  const CHAR *pName,
477  const bson::BSONObj &indexAttr = _sdbStaticObject,
478  const bson::BSONObj &option = _sdbStaticObject
479  ) = 0 ;
480  virtual INT32 createIndexAsync ( SINT64 &taskID,
481  const bson::BSONObj &indexDef,
482  const CHAR *pName,
483  const bson::BSONObj &indexAttr = _sdbStaticObject,
484  const bson::BSONObj &option = _sdbStaticObject
485  ) = 0 ;
486  virtual INT32 snapshotIndexes ( _sdbCursor **cursor,
487  const bson::BSONObj &condition = _sdbStaticObject,
488  const bson::BSONObj &selector = _sdbStaticObject,
489  const bson::BSONObj &orderby = _sdbStaticObject,
490  const bson::BSONObj &hint = _sdbStaticObject,
491  INT64 numToSkip = 0,
492  INT64 numToReturn = -1 ) = 0 ;
493  virtual INT32 getIndexes ( _sdbCursor **cursor,
494  const CHAR *pName ) = 0 ;
495  virtual INT32 getIndexes ( sdbCursor &cursor,
496  const CHAR *pIndexName ) = 0 ;
497  virtual INT32 getIndexes ( std::vector<bson::BSONObj> &infos ) = 0 ;
498  virtual INT32 getIndex ( const CHAR *pIndexName, bson::BSONObj &info ) = 0 ;
499  virtual INT32 dropIndex ( const CHAR *pIndexName ) = 0 ;
500  virtual INT32 dropIndexAsync ( SINT64 &taskID,
501  const CHAR *pIndexName ) = 0 ;
502  virtual INT32 copyIndex ( const CHAR *subClFullName,
503  const CHAR *pIndexName ) = 0 ;
504  virtual INT32 copyIndexAsync ( SINT64 &taskID,
505  const CHAR *subClFullName,
506  const CHAR *pIndexName ) = 0 ;
507  virtual INT32 create () = 0 ;
508  virtual INT32 drop () = 0 ;
509  virtual const CHAR *getCollectionName () = 0 ;
510  virtual const CHAR *getCSName () = 0 ;
511  virtual const CHAR *getFullName () = 0 ;
512  virtual INT32 split ( const CHAR *pSourceGroupName,
513  const CHAR *pTargetGroupName,
514  const bson::BSONObj &splitConditon,
515  const bson::BSONObj &splitEndCondition = _sdbStaticObject) = 0 ;
516  virtual INT32 split ( const CHAR *pSourceGroupName,
517  const CHAR *pTargetGroupName,
518  FLOAT64 percent ) = 0 ;
519  virtual INT32 splitAsync ( SINT64 &taskID,
520  const CHAR *pSourceGroupName,
521  const CHAR *pTargetGroupName,
522  const bson::BSONObj &splitCondition,
523  const bson::BSONObj &splitEndCondition = _sdbStaticObject) = 0 ;
524  virtual INT32 splitAsync ( const CHAR *pSourceGroupName,
525  const CHAR *pTargetGroupName,
526  FLOAT64 percent,
527  SINT64 &taskID ) = 0 ;
528  virtual INT32 aggregate ( _sdbCursor **cursor,
529  std::vector<bson::BSONObj> &obj
530  ) = 0 ;
531  virtual INT32 aggregate ( sdbCursor &cursor,
532  std::vector<bson::BSONObj> &obj
533  ) = 0 ;
534  virtual INT32 getQueryMeta ( _sdbCursor **cursor,
535  const bson::BSONObj &condition = _sdbStaticObject,
536  const bson::BSONObj &orderBy = _sdbStaticObject,
537  const bson::BSONObj &hint = _sdbStaticObject,
538  INT64 numToSkip = 0,
539  INT64 numToReturn = -1
540  ) = 0 ;
541  virtual INT32 getQueryMeta ( sdbCursor &cursor,
542  const bson::BSONObj &condition = _sdbStaticObject,
543  const bson::BSONObj &orderBy = _sdbStaticObject,
544  const bson::BSONObj &hint = _sdbStaticObject,
545  INT64 numToSkip = 0,
546  INT64 numToReturn = -1
547  ) = 0 ;
548  virtual INT32 attachCollection ( const CHAR *subClFullName,
549  const bson::BSONObj &options) = 0 ;
550  virtual INT32 detachCollection ( const CHAR *subClFullName) = 0 ;
551 
552  virtual INT32 alterCollection ( const bson::BSONObj &options ) = 0 ;
554  virtual INT32 explain ( sdbCursor &cursor,
555  const bson::BSONObj &condition = _sdbStaticObject,
556  const bson::BSONObj &select = _sdbStaticObject,
557  const bson::BSONObj &orderBy = _sdbStaticObject,
558  const bson::BSONObj &hint = _sdbStaticObject,
559  INT64 numToSkip = 0,
560  INT64 numToReturn = -1,
561  INT32 flag = 0,
562  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
563 
564  virtual INT32 explain ( _sdbCursor **cursor,
565  const bson::BSONObj &condition = _sdbStaticObject,
566  const bson::BSONObj &select = _sdbStaticObject,
567  const bson::BSONObj &orderBy = _sdbStaticObject,
568  const bson::BSONObj &hint = _sdbStaticObject,
569  INT64 numToSkip = 0,
570  INT64 numToReturn = -1,
571  INT32 flag = 0,
572  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
574  virtual INT32 createLob( sdbLob &lob, const bson::OID *oid = NULL ) = 0 ;
575 
576  virtual INT32 removeLob( const bson::OID &oid ) = 0 ;
577 
578  virtual INT32 truncateLob( const bson::OID &oid, INT64 length ) = 0 ;
579 
580  virtual INT32 openLob( sdbLob &lob, const bson::OID &oid,
581  SDB_LOB_OPEN_MODE mode = SDB_LOB_READ ) = 0 ;
582 
583  virtual INT32 openLob( sdbLob &lob, const bson::OID &oid,
584  INT32 mode ) = 0 ;
585 
586  virtual INT32 listLobs( sdbCursor &cursor,
587  const bson::BSONObj &condition = _sdbStaticObject,
588  const bson::BSONObj &selected = _sdbStaticObject,
589  const bson::BSONObj &orderBy = _sdbStaticObject,
590  const bson::BSONObj &hint = _sdbStaticObject,
591  INT64 numToSkip = 0,
592  INT64 numToReturn = -1 ) = 0 ;
593 
594  virtual INT32 listLobs( _sdbCursor **cursor,
595  const bson::BSONObj &condition = _sdbStaticObject,
596  const bson::BSONObj &selected = _sdbStaticObject,
597  const bson::BSONObj &orderBy = _sdbStaticObject,
598  const bson::BSONObj &hint = _sdbStaticObject,
599  INT64 numToSkip = 0,
600  INT64 numToReturn = -1 ) = 0 ;
601 
602  virtual INT32 createLobID( bson::OID &oid, const CHAR *pTimeStamp = NULL ) = 0 ;
603 
604  virtual INT32 listLobPieces(
605  _sdbCursor **cursor,
606  const bson::BSONObj &condition = _sdbStaticObject,
607  const bson::BSONObj &selected = _sdbStaticObject,
608  const bson::BSONObj &orderBy = _sdbStaticObject,
609  const bson::BSONObj &hint = _sdbStaticObject,
610  INT64 numToSkip = 0,
611  INT64 numToReturn = -1 ) = 0 ;
612 
613  virtual INT32 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 
623  virtual INT32 truncate( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
624 
626  virtual INT32 createIdIndex( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
627 
628  virtual INT32 dropIdIndex() = 0 ;
629 
630  virtual INT32 createAutoIncrement( const bson::BSONObj &options ) = 0;
631 
632  virtual INT32 createAutoIncrement( const std::vector<bson::BSONObj> &options ) = 0;
633 
634  virtual INT32 dropAutoIncrement( const CHAR *fieldName ) = 0;
635 
636  virtual INT32 dropAutoIncrement( const std::vector<const CHAR*> &fieldNames ) = 0;
637 
638  virtual INT32 pop ( const bson::BSONObj &option = _sdbStaticObject ) = 0 ;
639 
640  virtual INT32 enableSharding ( const bson::BSONObj &options ) = 0 ;
641 
642  virtual INT32 disableSharding () = 0 ;
643 
644  virtual INT32 enableCompression ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
645 
646  virtual INT32 disableCompression () = 0 ;
647 
648  virtual INT32 setAttributes ( const bson::BSONObj &options ) = 0 ;
649 
650  virtual INT32 getDetail ( _sdbCursor **cursor ) = 0 ;
651 
652  virtual INT32 getDetail ( sdbCursor &cursor ) = 0 ;
653 
654  virtual INT32 getIndexStat ( const CHAR *pIndexName, bson::BSONObj &result ) = 0 ;
655 
656  virtual void setVersion( INT32 clVersion ) = 0;
657  virtual INT32 getVersion() = 0;
658  } ;
659 
663  class DLLEXPORT sdbCollection
664  {
665  private :
670  sdbCollection ( const sdbCollection& other ) ;
671 
677  sdbCollection& operator=( const sdbCollection& ) ;
678  public :
685  _sdbCollection *pCollection ;
686 
691  {
692  pCollection = NULL ;
693  }
694 
699  {
700  if ( pCollection )
701  {
702  delete pCollection ;
703  }
704  }
705 
719  INT32 getCount ( SINT64 &count,
720  const bson::BSONObj &condition = _sdbStaticObject,
721  const bson::BSONObj &hint = _sdbStaticObject )
722  {
723  if ( !pCollection )
724  {
725  return SDB_NOT_CONNECTED ;
726  }
727  return pCollection->getCount ( count, condition, hint ) ;
728  }
729 
747  INT32 split ( const CHAR *pSourceGroupName,
748  const CHAR *pTargetGroupName,
749  const bson::BSONObj &splitCondition,
750  const bson::BSONObj &splitEndCondition = _sdbStaticObject)
751  {
752  if ( !pCollection )
753  {
754  return SDB_NOT_CONNECTED ;
755  }
756  return pCollection->split ( pSourceGroupName,
757  pTargetGroupName,
758  splitCondition,
759  splitEndCondition) ;
760  }
761 
773  INT32 split ( const CHAR *pSourceGroupName,
774  const CHAR *pTargetGroupName,
775  FLOAT64 percent )
776  {
777  if ( !pCollection )
778  {
779  return SDB_NOT_CONNECTED ;
780  }
781  return pCollection->split ( pSourceGroupName,
782  pTargetGroupName,
783  percent ) ;
784  }
785 
805  INT32 splitAsync ( SINT64 &taskID,
806  const CHAR *pSourceGroupName,
807  const CHAR *pTargetGroupName,
808  const bson::BSONObj &splitCondition,
809  const bson::BSONObj &splitEndCondition = _sdbStaticObject )
810  {
811  if ( !pCollection )
812  {
813  return SDB_NOT_CONNECTED ;
814  }
815  return pCollection->splitAsync ( taskID,
816  pSourceGroupName,
817  pTargetGroupName,
818  splitCondition,
819  splitEndCondition ) ;
820  }
821 
835  INT32 splitAsync ( const CHAR *pSourceGroupName,
836  const CHAR *pTargetGroupName,
837  FLOAT64 percent,
838  SINT64 &taskID )
839  {
840  if ( !pCollection )
841  {
842  return SDB_NOT_CONNECTED ;
843  }
844  return pCollection->splitAsync ( pSourceGroupName,
845  pTargetGroupName,
846  percent,
847  taskID ) ;
848  }
849 
869  INT32 alterCollection ( const bson::BSONObj &options )
870  {
871  if ( !pCollection )
872  {
873  return SDB_NOT_CONNECTED ;
874  }
875  return pCollection->alterCollection ( options ) ;
876  }
877 
900  INT32 insert ( const bson::BSONObj &obj, bson::OID *pId = NULL )
901  {
902  if ( !pCollection )
903  {
904  return SDB_NOT_CONNECTED ;
905  }
906  return pCollection->insert ( obj, pId ) ;
907  }
908 
953  INT32 insert ( const bson::BSONObj &obj,
954  INT32 flags,
955  bson::BSONObj *pResult = NULL )
956  {
957  if ( !pCollection )
958  {
959  return SDB_NOT_CONNECTED ;
960  }
961  return pCollection->insert ( obj, flags, pResult ) ;
962  }
963 
1011  INT32 insert ( const bson::BSONObj &obj,
1012  const bson::BSONObj &hint,
1013  INT32 flags,
1014  bson::BSONObj *pResult = NULL )
1015  {
1016  if ( !pCollection )
1017  {
1018  return SDB_NOT_CONNECTED ;
1019  }
1020  return pCollection->insert ( obj, hint, flags, pResult ) ;
1021  }
1022 
1070  INT32 insert ( std::vector<bson::BSONObj> &objs,
1071  INT32 flags = 0,
1072  bson::BSONObj *pResult = NULL )
1073  {
1074  if ( !pCollection )
1075  {
1076  return SDB_NOT_CONNECTED ;
1077  }
1078  return pCollection->insert( objs, flags, pResult ) ;
1079  }
1080 
1131  INT32 insert ( std::vector<bson::BSONObj> &objs,
1132  const bson::BSONObj &hint,
1133  INT32 flags = 0,
1134  bson::BSONObj *pResult = NULL )
1135  {
1136  if ( !pCollection )
1137  {
1138  return SDB_NOT_CONNECTED ;
1139  }
1140  return pCollection->insert( objs, hint, flags, pResult ) ;
1141  }
1142 
1192  INT32 insert ( const bson::BSONObj objs[],
1193  INT32 size,
1194  INT32 flags = 0,
1195  bson::BSONObj *pResult = NULL )
1196  {
1197  if ( !pCollection )
1198  {
1199  return SDB_NOT_CONNECTED ;
1200  }
1201  return pCollection->insert ( objs, size, flags, pResult ) ;
1202  }
1203 
1231  INT32 bulkInsert ( SINT32 flags,
1232  std::vector<bson::BSONObj> &objs )
1233  {
1234  if ( !pCollection )
1235  {
1236  return SDB_NOT_CONNECTED ;
1237  }
1238  return pCollection->bulkInsert ( flags, objs ) ;
1239  }
1240 
1273  INT32 update ( const bson::BSONObj &rule,
1274  const bson::BSONObj &condition = _sdbStaticObject,
1275  const bson::BSONObj &hint = _sdbStaticObject,
1276  INT32 flag = 0,
1277  bson::BSONObj *pResult = NULL
1278  )
1279  {
1280  if ( !pCollection )
1281  {
1282  return SDB_NOT_CONNECTED ;
1283  }
1284  return pCollection->update ( rule, condition, hint, flag, pResult ) ;
1285  }
1286 
1320  INT32 upsert ( const bson::BSONObj &rule,
1321  const bson::BSONObj &condition = _sdbStaticObject,
1322  const bson::BSONObj &hint = _sdbStaticObject,
1323  const bson::BSONObj &setOnInsert = _sdbStaticObject,
1324  INT32 flag = 0,
1325  bson::BSONObj *pResult = NULL
1326  )
1327  {
1328  if ( !pCollection )
1329  {
1330  return SDB_NOT_CONNECTED ;
1331  }
1332  return pCollection->upsert ( rule, condition, hint, setOnInsert,
1333  flag, pResult ) ;
1334  }
1335 
1357  INT32 del ( const bson::BSONObj &condition = _sdbStaticObject,
1358  const bson::BSONObj &hint = _sdbStaticObject,
1359  INT32 flag = 0,
1360  bson::BSONObj *pResult = NULL
1361  )
1362  {
1363  if ( !pCollection )
1364  {
1365  return SDB_NOT_CONNECTED ;
1366  }
1367  return pCollection->del ( condition, hint, flag, pResult ) ;
1368  }
1369 
1370  /* \fn INT32 query ( _sdbCursor **cursor,
1371  const bson::BSONObj &condition,
1372  const bson::BSONObj &selected,
1373  const bson::BSONObj &orderBy,
1374  const bson::BSONObj &hint,
1375  INT64 numToSkip,
1376  INT64 numToReturn,
1377  INT32 flags
1378  )
1379  \brief Get the matching documents in current collection
1380  \param [in] condition The matching rule, return all the documents if not provided
1381  \param [in] selected The selective rule, return the whole document if not provided
1382  \param [in] orderBy The ordered rule, result set is unordered if not provided
1383  \param [in] hint Specified the index used to scan data. e.g. {"":"ageIndex"} means
1384  using index "ageIndex" to scan data(index scan);
1385  {"":null} means table scan. when hint is not provided,
1386  database automatically match the optimal index to scan data
1387  \param [in] numToSkip Skip the first numToSkip documents, default is 0
1388  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
1389  \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
1390  \code
1391  QUERY_FORCE_HINT
1392  QUERY_PARALLED
1393  QUERY_WITH_RETURNDATA
1394  QUERY_FOR_UPDATE
1395  \endcode
1396  \param [out] cursor The cursor of current query
1397  \retval SDB_OK Operation Success
1398  \retval Others Operation Fail
1399  */
1400  INT32 query ( _sdbCursor **cursor,
1401  const bson::BSONObj &condition = _sdbStaticObject,
1402  const bson::BSONObj &selected = _sdbStaticObject,
1403  const bson::BSONObj &orderBy = _sdbStaticObject,
1404  const bson::BSONObj &hint = _sdbStaticObject,
1405  INT64 numToSkip = 0,
1406  INT64 numToReturn = -1,
1407  INT32 flags = 0
1408  )
1409  {
1410  if ( !pCollection )
1411  {
1412  return SDB_NOT_CONNECTED ;
1413  }
1414  return pCollection->query ( cursor, condition, selected, orderBy,
1415  hint, numToSkip, numToReturn, flags ) ;
1416  }
1417 
1448  INT32 query ( sdbCursor &cursor,
1449  const bson::BSONObj &condition = _sdbStaticObject,
1450  const bson::BSONObj &selected = _sdbStaticObject,
1451  const bson::BSONObj &orderBy = _sdbStaticObject,
1452  const bson::BSONObj &hint = _sdbStaticObject,
1453  INT64 numToSkip = 0,
1454  INT64 numToReturn = -1,
1455  INT32 flags = 0
1456  )
1457  {
1458  if ( !pCollection )
1459  {
1460  return SDB_NOT_CONNECTED ;
1461  }
1462  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1463  return pCollection->query ( cursor, condition, selected, orderBy,
1464  hint, numToSkip, numToReturn, flags ) ;
1465  }
1466 
1495  INT32 queryOne( bson::BSONObj &obj,
1496  const bson::BSONObj &condition = _sdbStaticObject,
1497  const bson::BSONObj &selected = _sdbStaticObject,
1498  const bson::BSONObj &orderBy = _sdbStaticObject,
1499  const bson::BSONObj &hint = _sdbStaticObject,
1500  INT64 numToSkip = 0,
1501  INT32 flag = 0 )
1502  {
1503  if ( !pCollection )
1504  {
1505  return SDB_NOT_CONNECTED ;
1506  }
1507  return pCollection->queryOne( obj, condition, selected, orderBy,
1508  hint, numToSkip, flag ) ;
1509  }
1510 
1546  INT32 queryAndUpdate ( sdbCursor &cursor,
1547  const bson::BSONObj &update,
1548  const bson::BSONObj &condition = _sdbStaticObject,
1549  const bson::BSONObj &selected = _sdbStaticObject,
1550  const bson::BSONObj &orderBy = _sdbStaticObject,
1551  const bson::BSONObj &hint = _sdbStaticObject,
1552  INT64 numToSkip = 0,
1553  INT64 numToReturn = -1,
1554  INT32 flag = 0,
1555  BOOLEAN returnNew = FALSE
1556  )
1557  {
1558  if ( !pCollection )
1559  {
1560  return SDB_NOT_CONNECTED ;
1561  }
1562  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1563  return pCollection->queryAndUpdate( &cursor.pCursor , update, condition,
1564  selected, orderBy, hint,
1565  numToSkip, numToReturn, flag, returnNew ) ;
1566  }
1567 
1598  INT32 queryAndRemove ( sdbCursor &cursor,
1599  const bson::BSONObj &condition = _sdbStaticObject,
1600  const bson::BSONObj &selected = _sdbStaticObject,
1601  const bson::BSONObj &orderBy = _sdbStaticObject,
1602  const bson::BSONObj &hint = _sdbStaticObject,
1603  INT64 numToSkip = 0,
1604  INT64 numToReturn = -1,
1605  INT32 flag = 0
1606  )
1607  {
1608  if ( !pCollection )
1609  {
1610  return SDB_NOT_CONNECTED ;
1611  }
1612  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1613  return pCollection->queryAndRemove( &cursor.pCursor , condition,
1614  selected, orderBy, hint,
1615  numToSkip, numToReturn, flag ) ;
1616  }
1617 
1634  INT32 createIndex ( const bson::BSONObj &indexDef,
1635  const CHAR *pIndexName,
1636  BOOLEAN isUnique,
1637  BOOLEAN isEnforced,
1638  INT32 sortBufferSize =
1639  SDB_INDEX_SORT_BUFFER_DEFAULT_SIZE )
1640  {
1641  if ( !pCollection )
1642  {
1643  return SDB_NOT_CONNECTED ;
1644  }
1645  return pCollection->createIndex ( indexDef, pIndexName, isUnique,
1646  isEnforced, sortBufferSize ) ;
1647  }
1648 
1675  INT32 createIndex ( const bson::BSONObj &indexDef,
1676  const CHAR *pIndexName,
1677  const bson::BSONObj &indexAttr = _sdbStaticObject,
1678  const bson::BSONObj &option = _sdbStaticObject )
1679  {
1680  if ( !pCollection )
1681  return SDB_NOT_CONNECTED ;
1682  return pCollection->createIndex ( indexDef, pIndexName,
1683  indexAttr, option ) ;
1684  }
1685 
1709  INT32 createIndexAsync ( SINT64 &taskID,
1710  const bson::BSONObj &indexDef,
1711  const CHAR *pIndexName,
1712  const bson::BSONObj &indexAttr = _sdbStaticObject,
1713  const bson::BSONObj &option = _sdbStaticObject )
1714  {
1715  if ( !pCollection )
1716  {
1717  return SDB_NOT_CONNECTED ;
1718  }
1719  return pCollection->createIndexAsync ( taskID, indexDef, pIndexName,
1720  indexAttr, option ) ;
1721  }
1722 
1723  /* \fn INT32 snapshotIndexes ( _sdbCursor **cursor,
1724  const bson::BSONObj &condition = _sdbStaticObject,
1725  const bson::BSONObj &selector = _sdbStaticObject,
1726  const bson::BSONObj &orderby = _sdbStaticObject,
1727  const bson::BSONObj &hint = _sdbStaticObject,
1728  INT64 numToSkip = 0,
1729  INT64 numToReturn = -1 )
1730  \brief Snapshot all of or one of the indexes in current collection
1731  \param [out] cursor The cursor of all the result for current query
1732  \param [in] condition The matching rule, match all the documents if not provided.
1733  \param [in] select The selective rule, return the whole document if not provided.
1734  \param [in] orderBy The ordered rule, result set is unordered if not provided.
1735  \param [in] hint The options provided for specific snapshot type
1736  \param [in] numToSkip Skip the first numToSkip documents, default is 0
1737  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
1738  \retval SDB_OK Operation Success
1739  \retval Others Operation Fail
1740  */
1741  INT32 snapshotIndexes ( _sdbCursor **cursor,
1742  const bson::BSONObj &condition = _sdbStaticObject,
1743  const bson::BSONObj &selector = _sdbStaticObject,
1744  const bson::BSONObj &orderby = _sdbStaticObject,
1745  const bson::BSONObj &hint = _sdbStaticObject,
1746  INT64 numToSkip = 0,
1747  INT64 numToReturn = -1 )
1748  {
1749  if ( !pCollection )
1750  {
1751  return SDB_NOT_CONNECTED ;
1752  }
1753  return pCollection->snapshotIndexes ( cursor, condition,
1754  selector, orderby, hint,
1755  numToSkip, numToReturn ) ;
1756  }
1757 
1758  /* \fn INT32 getIndexes ( _sdbCursor **cursor,
1759  const CHAR *pIndexName )
1760  \brief Get all of or one of the indexes in current collection
1761  \param [in] pIndexName The index name, returns all of the indexes if this parameter is null
1762  \param [out] cursor The cursor of all the result for current query
1763  \retval SDB_OK Operation Success
1764  \retval Others Operation Fail
1765  */
1766  INT32 getIndexes ( _sdbCursor **cursor,
1767  const CHAR *pIndexName )
1768  {
1769  if ( !pCollection )
1770  {
1771  return SDB_NOT_CONNECTED ;
1772  }
1773  return pCollection->getIndexes ( cursor, pIndexName ) ;
1774  }
1775 
1785  INT32 getIndexes ( sdbCursor &cursor,
1786  const CHAR *pIndexName )
1787  {
1788  if ( !pCollection )
1789  {
1790  return SDB_NOT_CONNECTED ;
1791  }
1792  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1793  return pCollection->getIndexes ( cursor, pIndexName ) ;
1794  }
1795 
1802  INT32 getIndexes ( std::vector<bson::BSONObj> &infos )
1803  {
1804  if ( !pCollection )
1805  {
1806  return SDB_NOT_CONNECTED ;
1807  }
1808  return pCollection->getIndexes ( infos ) ;
1809  }
1810 
1818  INT32 getIndex ( const CHAR *pIndexName, bson::BSONObj &info )
1819  {
1820  if ( !pCollection )
1821  {
1822  return SDB_NOT_CONNECTED ;
1823  }
1824  return pCollection->getIndex ( pIndexName, info ) ;
1825  }
1826 
1833  INT32 dropIndex ( const CHAR *pIndexName )
1834  {
1835  if ( !pCollection )
1836  {
1837  return SDB_NOT_CONNECTED ;
1838  }
1839  return pCollection->dropIndex ( pIndexName ) ;
1840  }
1841 
1850  INT32 dropIndexAsync ( SINT64 &taskID, const CHAR *pIndexName )
1851  {
1852  if ( !pCollection )
1853  return SDB_NOT_CONNECTED ;
1854  return pCollection->dropIndexAsync ( taskID, pIndexName ) ;
1855  }
1856 
1865  INT32 copyIndex ( const CHAR *subClFullName, const CHAR *pIndexName )
1866  {
1867  if ( !pCollection )
1868  return SDB_NOT_CONNECTED ;
1869  return pCollection->copyIndex ( subClFullName, pIndexName ) ;
1870  }
1871 
1882  INT32 copyIndexAsync ( SINT64 &taskID, const CHAR *subClFullName,
1883  const CHAR *pIndexName )
1884  {
1885  if ( !pCollection )
1886  return SDB_NOT_CONNECTED ;
1887  return pCollection->copyIndexAsync ( taskID, subClFullName,
1888  pIndexName ) ;
1889  }
1890 
1897  INT32 create ()
1898  {
1899  if ( !pCollection )
1900  {
1901  return SDB_NOT_CONNECTED ;
1902  }
1903  return pCollection->create () ;
1904  }
1905 
1912  INT32 drop ()
1913  {
1914  if ( !pCollection )
1915  {
1916  return SDB_NOT_CONNECTED ;
1917  }
1918  return pCollection->drop () ;
1919  }
1920 
1925  const CHAR *getCollectionName ()
1926  {
1927  if ( !pCollection )
1928  {
1929  return NULL ;
1930  }
1931  return pCollection->getCollectionName () ;
1932  }
1933 
1938  const CHAR *getCSName ()
1939  {
1940  if ( !pCollection )
1941  {
1942  return NULL ;
1943  }
1944  return pCollection->getCSName () ;
1945  }
1946 
1951  const CHAR *getFullName ()
1952  {
1953  if ( !pCollection )
1954  {
1955  return NULL ;
1956  }
1957  return pCollection->getFullName () ;
1958  }
1959 
1960  /* \fn INT32 aggregate ( _sdbCursor **cursor,
1961  std::vector<bson::BSONObj> &obj
1962  )
1963  \brief Execute aggregate operation in specified collection
1964  \param [in] obj The array of bson objects
1965  \param [out] cursor The cursor handle of result
1966  \retval SDB_OK Operation Success
1967  \retval Others Operation Fail
1968  */
1969  INT32 aggregate ( _sdbCursor **cursor,
1970  std::vector<bson::BSONObj> &obj
1971  )
1972  {
1973  if ( !pCollection )
1974  {
1975  return SDB_NOT_CONNECTED ;
1976  }
1977  return pCollection->aggregate ( cursor, obj ) ;
1978  }
1979 
1989  INT32 aggregate ( sdbCursor &cursor,
1990  std::vector<bson::BSONObj> &obj
1991  )
1992  {
1993  if ( !pCollection )
1994  {
1995  return SDB_NOT_CONNECTED ;
1996  }
1997  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
1998  return pCollection->aggregate ( cursor, obj ) ;
1999  }
2000 
2001  /* \fn INT32 getQueryMeta ( _sdbCursor **cursor,
2002  const bson::BSONObj &condition = _sdbStaticObject,
2003  const bson::BSONObj &selected = _sdbStaticObject,
2004  const bson::BSONObj &orderBy = _sdbStaticObject,
2005  INT64 numToSkip = 0,
2006  INT64 numToReturn = -1 ) ;
2007  \brief Get the index blocks' or data blocks' infomation for concurrent query
2008  \param [in] condition The matching rule, return all the documents if not provided
2009  \param [in] orderBy The ordered rule, result set is unordered if not provided
2010  \param [in] hint Specified the index used to scan data. e.g. {"":"ageIndex"} means
2011  using index "ageIndex" to scan data(index scan);
2012  {"":null} means table scan. when hint is not provided,
2013  database automatically match the optimal index to scan data
2014  \param [in] numToSkip Skip the first numToSkip documents, default is 0
2015  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
2016  \param [out] cursor The cursor of current query
2017  \retval SDB_OK Operation Success
2018  \retval Others Operation Fail
2019  */
2020  INT32 getQueryMeta ( _sdbCursor **cursor,
2021  const bson::BSONObj &condition = _sdbStaticObject,
2022  const bson::BSONObj &orderBy = _sdbStaticObject,
2023  const bson::BSONObj &hint = _sdbStaticObject,
2024  INT64 numToSkip = 0,
2025  INT64 numToReturn = -1 )
2026  {
2027  if ( !pCollection )
2028  {
2029  return SDB_NOT_CONNECTED ;
2030  }
2031  return pCollection->getQueryMeta ( cursor, condition, orderBy,
2032  hint, numToSkip, numToReturn ) ;
2033  }
2034 
2055  INT32 getQueryMeta ( sdbCursor &cursor,
2056  const bson::BSONObj &condition = _sdbStaticObject,
2057  const bson::BSONObj &orderBy = _sdbStaticObject,
2058  const bson::BSONObj &hint = _sdbStaticObject,
2059  INT64 numToSkip = 0,
2060  INT64 numToReturn = -1 )
2061  {
2062  if ( !pCollection )
2063  {
2064  return SDB_NOT_CONNECTED ;
2065  }
2066  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2067  return pCollection->getQueryMeta ( cursor, condition, orderBy,
2068  hint, numToSkip, numToReturn ) ;
2069  }
2070 
2084  INT32 attachCollection ( const CHAR *subClFullName,
2085  const bson::BSONObj &options )
2086  {
2087  if ( !pCollection )
2088  {
2089  return SDB_NOT_CONNECTED ;
2090  }
2091  return pCollection->attachCollection ( subClFullName, options ) ;
2092  }
2093 
2100  INT32 detachCollection ( const CHAR *subClFullName )
2101  {
2102  if ( !pCollection )
2103  {
2104  return SDB_NOT_CONNECTED ;
2105  }
2106  return pCollection->detachCollection ( subClFullName ) ;
2107  }
2108 
2144  INT32 explain ( sdbCursor &cursor,
2145  const bson::BSONObj &condition = _sdbStaticObject,
2146  const bson::BSONObj &select = _sdbStaticObject,
2147  const bson::BSONObj &orderBy = _sdbStaticObject,
2148  const bson::BSONObj &hint = _sdbStaticObject,
2149  INT64 numToSkip = 0,
2150  INT64 numToReturn = -1,
2151  INT32 flag = 0,
2152  const bson::BSONObj &options = _sdbStaticObject )
2153  {
2154  if ( !pCollection )
2155  {
2156  return SDB_NOT_CONNECTED ;
2157  }
2158  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2159  return pCollection->explain( cursor, condition, select, orderBy, hint,
2160  numToSkip, numToReturn, flag, options ) ;
2161  }
2162 
2163  INT32 explain ( _sdbCursor **cursor,
2164  const bson::BSONObj &condition = _sdbStaticObject,
2165  const bson::BSONObj &select = _sdbStaticObject,
2166  const bson::BSONObj &orderBy = _sdbStaticObject,
2167  const bson::BSONObj &hint = _sdbStaticObject,
2168  INT64 numToSkip = 0,
2169  INT64 numToReturn = -1,
2170  INT32 flag = 0,
2171  const bson::BSONObj &options = _sdbStaticObject )
2172  {
2173  if ( !pCollection )
2174  {
2175  return SDB_NOT_CONNECTED ;
2176  }
2177  return pCollection->explain( cursor, condition, select, orderBy, hint,
2178  numToSkip, numToReturn, flag, options ) ;
2179  }
2180 
2189  INT32 createLob( sdbLob &lob, const bson::OID *oid = NULL )
2190  {
2191  if ( !pCollection )
2192  {
2193  return SDB_NOT_CONNECTED ;
2194  }
2195  return pCollection->createLob( lob, oid ) ;
2196  }
2197 
2204  INT32 removeLob( const bson::OID &oid )
2205  {
2206  if ( !pCollection )
2207  {
2208  return SDB_NOT_CONNECTED ;
2209  }
2210  return pCollection->removeLob( oid ) ;
2211  }
2212 
2220  INT32 truncateLob( const bson::OID &oid, INT64 length )
2221  {
2222  if ( !pCollection )
2223  {
2224  return SDB_NOT_CONNECTED ;
2225  }
2226  return pCollection->truncateLob( oid, length ) ;
2227  }
2228 
2238  INT32 openLob( sdbLob &lob, const bson::OID &oid,
2240  {
2241  if ( !pCollection )
2242  {
2243  return SDB_NOT_CONNECTED ;
2244  }
2245  return pCollection->openLob( lob, oid, mode ) ;
2246  }
2247 
2257  INT32 openLob( sdbLob &lob, const bson::OID &oid, INT32 mode )
2258  {
2259  if ( !pCollection )
2260  {
2261  return SDB_NOT_CONNECTED ;
2262  }
2263  return pCollection->openLob( lob, oid, mode ) ;
2264  }
2265 
2283  INT32 listLobs( sdbCursor &cursor,
2284  const bson::BSONObj &condition = _sdbStaticObject,
2285  const bson::BSONObj &selected = _sdbStaticObject,
2286  const bson::BSONObj &orderBy = _sdbStaticObject,
2287  const bson::BSONObj &hint = _sdbStaticObject,
2288  INT64 numToSkip = 0,
2289  INT64 numToReturn = -1 )
2290  {
2291  if ( !pCollection )
2292  {
2293  return SDB_NOT_CONNECTED ;
2294  }
2295  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2296  return pCollection->listLobs( cursor, condition, selected, orderBy,
2297  hint, numToSkip, numToReturn ) ;
2298  }
2299 
2300  INT32 listLobs( _sdbCursor **cursor,
2301  const bson::BSONObj &condition = _sdbStaticObject,
2302  const bson::BSONObj &selected = _sdbStaticObject,
2303  const bson::BSONObj &orderBy = _sdbStaticObject,
2304  const bson::BSONObj &hint = _sdbStaticObject,
2305  INT64 numToSkip = 0,
2306  INT64 numToReturn = -1 )
2307  {
2308  if ( !pCollection )
2309  {
2310  return SDB_NOT_CONNECTED ;
2311  }
2312  return pCollection->listLobs( cursor, condition, selected, orderBy,
2313  hint, numToSkip, numToReturn ) ;
2314  }
2315 
2324  INT32 createLobID( bson::OID &oid, const CHAR *pTimeStamp = NULL )
2325  {
2326  if ( !pCollection )
2327  {
2328  return SDB_NOT_CONNECTED ;
2329  }
2330  return pCollection->createLobID( oid, pTimeStamp ) ;
2331  }
2332 
2340  INT32 truncate( const bson::BSONObj &options = _sdbStaticObject )
2341  {
2342  if ( !pCollection )
2343  {
2344  return SDB_NOT_CONNECTED ;
2345  }
2346  return pCollection->truncate( options ) ;
2347  }
2348 
2358  INT32 createIdIndex( const bson::BSONObj &options = _sdbStaticObject )
2359  {
2360  if ( !pCollection )
2361  {
2362  return SDB_NOT_CONNECTED ;
2363  }
2364  return pCollection->createIdIndex( options ) ;
2365  }
2366 
2373  INT32 dropIdIndex()
2374  {
2375  if ( !pCollection )
2376  {
2377  return SDB_NOT_CONNECTED ;
2378  }
2379  return pCollection->dropIdIndex() ;
2380  }
2381 
2399  INT32 createAutoIncrement ( const bson::BSONObj &options )
2400  {
2401  if ( !pCollection )
2402  {
2403  return SDB_NOT_CONNECTED ;
2404  }
2405  return pCollection->createAutoIncrement( options ) ;
2406  }
2407 
2414  INT32 createAutoIncrement ( const std::vector<bson::BSONObj> &options )
2415  {
2416  if ( !pCollection )
2417  {
2418  return SDB_NOT_CONNECTED ;
2419  }
2420  return pCollection->createAutoIncrement( options ) ;
2421  }
2422 
2429  INT32 dropAutoIncrement ( const CHAR * fieldName )
2430  {
2431  if ( !pCollection )
2432  {
2433  return SDB_NOT_CONNECTED ;
2434  }
2435  return pCollection->dropAutoIncrement( fieldName ) ;
2436  }
2437 
2444  INT32 dropAutoIncrement ( const std::vector<const CHAR*> &fieldNames )
2445  {
2446  if ( !pCollection )
2447  {
2448  return SDB_NOT_CONNECTED ;
2449  }
2450  return pCollection->dropAutoIncrement( fieldNames ) ;
2451  }
2452 
2466  INT32 enableSharding ( const bson::BSONObj & options = _sdbStaticObject )
2467  {
2468  if ( !pCollection )
2469  {
2470  return SDB_NOT_CONNECTED ;
2471  }
2472  return pCollection->enableSharding( options ) ;
2473  }
2474 
2480  INT32 disableSharding ()
2481  {
2482  if ( !pCollection )
2483  {
2484  return SDB_NOT_CONNECTED ;
2485  }
2486  return pCollection->disableSharding() ;
2487  }
2488 
2497  INT32 enableCompression ( const bson::BSONObj & options = _sdbStaticObject )
2498  {
2499  if ( !pCollection )
2500  {
2501  return SDB_NOT_CONNECTED ;
2502  }
2503  return pCollection->enableCompression( options ) ;
2504  }
2505 
2511  INT32 disableCompression ()
2512  {
2513  if ( !pCollection )
2514  {
2515  return SDB_NOT_CONNECTED ;
2516  }
2517  return pCollection->disableCompression() ;
2518  }
2519 
2540  INT32 setAttributes ( const bson::BSONObj &options )
2541  {
2542  if ( !pCollection )
2543  {
2544  return SDB_NOT_CONNECTED ;
2545  }
2546  return pCollection->setAttributes( options ) ;
2547  }
2548 
2549  /* \fn INT32 pop( const bson::BSONObj &option )
2550  \brief Pop records from a capped collection
2551  \param [in] option The pop options as follows:
2552 
2553  Direction : The direction to pop record. 1: pop forward. -1: pop backward.
2554  The default value is 1.
2555  \retval SDB_OK Operation Success
2556  \retval Others Operation Fail
2557  */
2558  INT32 pop ( const bson::BSONObj &option = _sdbStaticObject )
2559  {
2560  if ( !pCollection )
2561  {
2562  return SDB_NOT_CONNECTED ;
2563  }
2564  return pCollection->pop( option ) ;
2565  }
2566 
2567  INT32 listLobPieces( _sdbCursor **cursor,
2568  const bson::BSONObj &condition = _sdbStaticObject,
2569  const bson::BSONObj &selected = _sdbStaticObject,
2570  const bson::BSONObj &orderBy = _sdbStaticObject,
2571  const bson::BSONObj &hint = _sdbStaticObject,
2572  INT64 numToSkip = 0,
2573  INT64 numToReturn = -1 )
2574  {
2575  if( !pCollection )
2576  {
2577  return SDB_NOT_CONNECTED ;
2578  }
2579  return pCollection->listLobPieces( cursor, condition, selected,
2580  orderBy, hint, numToSkip,
2581  numToReturn ) ;
2582  }
2583 
2597  INT32 listLobPieces( sdbCursor &cursor,
2598  const bson::BSONObj &condition = _sdbStaticObject,
2599  const bson::BSONObj &selected = _sdbStaticObject,
2600  const bson::BSONObj &orderBy = _sdbStaticObject,
2601  const bson::BSONObj &hint = _sdbStaticObject,
2602  INT64 numToSkip = 0,
2603  INT64 numToReturn = -1 )
2604  {
2605  if( !pCollection )
2606  {
2607  return SDB_NOT_CONNECTED ;
2608  }
2609  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
2610  return pCollection->listLobPieces( cursor, condition, selected,
2611  orderBy, hint, numToSkip,
2612  numToReturn ) ;
2613  }
2614 
2615  /* \fn INT32 getDetail ( _sdbCursor **cursor )
2616  \brief Get the detail of the collection.
2617  \param [out] cursor Return the all the info of current collection.
2618  \retval SDB_OK Operation Success
2619  \retval Others Operation Fail
2620  */
2621  INT32 getDetail ( _sdbCursor **cursor )
2622  {
2623  if ( !pCollection )
2624  {
2625  return SDB_NOT_CONNECTED ;
2626  }
2627  return pCollection->getDetail ( cursor ) ;
2628  }
2629 
2636  INT32 getDetail( sdbCursor &cursor )
2637  {
2638  if ( !pCollection)
2639  {
2640  return SDB_NOT_CONNECTED ;
2641  }
2642  return pCollection->getDetail( cursor ) ;
2643  }
2644 
2645  /* \fn INT32 getIndexStat ( const CHAR *pIndexName, bson::BSONObj &result )
2646  \brief Get the statistics of the index.
2647  \param [in] pIndexName The name of the index.
2648  \param [out] result The statistics of index.
2649  \retval SDB_OK Operation Success
2650  \retval Others Operation Fail
2651  */
2652  INT32 getIndexStat( const CHAR *pIndexName, bson::BSONObj &result )
2653  {
2654  if ( !pCollection)
2655  {
2656  return SDB_NOT_CONNECTED ;
2657  }
2658  return pCollection->getIndexStat( pIndexName, result ) ;
2659  }
2660 
2661  /* \fn void setVersion ( INT32 clVersion )
2662  \brief set version to collection.
2663  \param [in] clVersion The collection version.
2664  */
2665  void setVersion( INT32 clVersion )
2666  {
2667  pCollection->setVersion( clVersion ) ;
2668  }
2669  /* \fn INT32 getVersion ()
2670  \brief get version from collection.
2671  \retval collection version.
2672  */
2673  INT32 getVersion()
2674  {
2675  return pCollection->getVersion() ;
2676  }
2677  } ;
2678 
2683  {
2684  SDB_NODE_ALL = 0,
2685  SDB_NODE_ACTIVE,
2686  SDB_NODE_INACTIVE,
2687  SDB_NODE_UNKNOWN
2688  } ;
2689 
2693  typedef enum sdbNodeStatus sdbNodeStatus ;
2694 
2695  class DLLEXPORT _sdbNode
2696  {
2697  private :
2698  _sdbNode ( const _sdbNode& other ) ;
2699  _sdbNode& operator=( const _sdbNode& ) ;
2700  public :
2701  _sdbNode () {}
2702  virtual ~_sdbNode () {}
2703  // connect to the current node
2704  virtual INT32 connect ( _sdb **dbConn ) = 0 ;
2705  virtual INT32 connect ( sdb &dbConn ) = 0 ;
2706 
2707  // get status of the current node
2708  virtual sdbNodeStatus getStatus () = 0 ;
2709 
2710  // get host name of the current node
2711  virtual const CHAR *getHostName () = 0 ;
2712 
2713  // get service name of the current node
2714  virtual const CHAR *getServiceName () = 0 ;
2715 
2716  // get node name of the current node
2717  virtual const CHAR *getNodeName () = 0 ;
2718 
2719  // get node id of the current node
2720  virtual INT32 getNodeID( INT32 &nodeID ) const = 0 ;
2721 
2722  // stop the node
2723  virtual INT32 stop () = 0 ;
2724 
2725  // start the node
2726  virtual INT32 start () = 0 ;
2727 
2728  // modify config for the current node
2729 /* virtual INT32 modifyConfig ( std::map<std::string,std::string>
2730  &config ) = 0 ; */
2731  } ;
2732 
2739  class DLLEXPORT sdbNode
2740  {
2741  private :
2746  sdbNode ( const sdbNode& other ) ;
2747 
2753  sdbNode& operator=( const sdbNode& ) ;
2754  public :
2761  _sdbNode *pNode ;
2762 
2767  {
2768  pNode = NULL ;
2769  }
2770 
2775  {
2776  if ( pNode )
2777  {
2778  delete pNode ;
2779  }
2780  }
2781 
2782  INT32 connect ( _sdb **dbConn )
2783  {
2784  if ( !pNode )
2785  {
2786  return SDB_NOT_CONNECTED ;
2787  }
2788  return pNode->connect ( dbConn ) ;
2789  }
2790 
2798  INT32 connect ( sdb &dbConn )
2799  {
2800  if ( !pNode )
2801  {
2802  return SDB_NOT_CONNECTED ;
2803  }
2804  // we can not use dbConn.pSDB here,
2805  // for sdb had not define yet.
2806  // RELEASE_INNER_HANDLE( dbConn.pSDB ) ;
2807  return pNode->connect ( dbConn ) ;
2808  }
2809 
2816  sdbNodeStatus getStatus ()
2817  {
2818  if ( !pNode )
2819  {
2820  return SDB_NODE_UNKNOWN ;
2821  }
2822  return pNode->getStatus () ;
2823  }
2824 
2829  const CHAR *getHostName ()
2830  {
2831  if ( !pNode )
2832  {
2833  return NULL ;
2834  }
2835  return pNode->getHostName () ;
2836  }
2837 
2842  const CHAR *getServiceName ()
2843  {
2844  if ( !pNode )
2845  {
2846  return NULL ;
2847  }
2848  return pNode->getServiceName () ;
2849  }
2850 
2855  const CHAR *getNodeName ()
2856  {
2857  if ( !pNode )
2858  {
2859  return NULL ;
2860  }
2861  return pNode->getNodeName () ;
2862  }
2863 
2868  INT32 getNodeID( INT32 &nodeID ) const
2869  {
2870  if ( !pNode )
2871  {
2872  return SDB_NOT_CONNECTED ;
2873  }
2874  return pNode->getNodeID( nodeID ) ;
2875  }
2876 
2882  INT32 stop ()
2883  {
2884  if ( !pNode )
2885  {
2886  return SDB_NOT_CONNECTED ;
2887  }
2888  return pNode->stop () ;
2889  }
2890 
2896  INT32 start ()
2897  {
2898  if ( !pNode )
2899  {
2900  return SDB_NOT_CONNECTED ;
2901  }
2902  return pNode->start () ;
2903  }
2904 /* INT32 modifyConfig ( std::map<std::string,std::string> &config )
2905  {
2906  if ( !pNode )
2907  {
2908  return NULL ;
2909  }
2910  return pNode->modifyConfig ( config ) ;
2911  }*/
2912  } ;
2913 
2914  class DLLEXPORT _sdbReplicaGroup
2915  {
2916  private :
2917  _sdbReplicaGroup ( const _sdbReplicaGroup& other ) ;
2918  _sdbReplicaGroup& operator=( const _sdbReplicaGroup& ) ;
2919  public :
2920  _sdbReplicaGroup () {}
2921  virtual ~_sdbReplicaGroup () {}
2922  // get number of logical nodes
2923  virtual INT32 getNodeNum ( sdbNodeStatus status, INT32 *num ) = 0 ;
2924 
2925  // get detailed information for the set
2926  virtual INT32 getDetail ( bson::BSONObj &result ) = 0 ;
2927 
2928  // get the master node
2929  virtual INT32 getMaster ( _sdbNode **node ) = 0 ;
2930  virtual INT32 getMaster ( sdbNode &node ) = 0 ;
2931 
2932  // get one of the slave node
2933  virtual INT32 getSlave ( _sdbNode **node,
2934  const vector<INT32>& positions = _sdbStaticVec ) = 0 ;
2935  virtual INT32 getSlave ( sdbNode &node,
2936  const vector<INT32>& positions = _sdbStaticVec ) = 0 ;
2937 
2938  // get a given node by name
2939  virtual INT32 getNode ( const CHAR *pNodeName,
2940  _sdbNode **node ) = 0 ;
2941  virtual INT32 getNode ( const CHAR *pNodeName,
2942  sdbNode &node ) = 0 ;
2943 
2944  // get a given node by host/service name
2945  virtual INT32 getNode ( const CHAR *pHostName,
2946  const CHAR *pServiceName,
2947  _sdbNode **node ) = 0 ;
2948  virtual INT32 getNode ( const CHAR *pHostName,
2949  const CHAR *pServiceName,
2950  sdbNode &node ) = 0 ;
2951 
2952  // create a new node in current replica group
2953  virtual INT32 createNode ( const CHAR *pHostName,
2954  const CHAR *pServiceName,
2955  const CHAR *pDatabasePath,
2956  std::map<std::string,std::string> &config )= 0;
2957 
2958  virtual INT32 createNode ( const CHAR *pHostName,
2959  const CHAR *pServiceName,
2960  const CHAR *pDatabasePath,
2961  const bson::BSONObj &options = _sdbStaticObject )= 0;
2962 
2963  // remove the specified node in current replica group
2964  virtual INT32 removeNode ( const CHAR *pHostName,
2965  const CHAR *pServiceName,
2966  const bson::BSONObj &configure = _sdbStaticObject ) = 0 ;
2967  // stop the replica group
2968  virtual INT32 stop () = 0 ;
2969 
2970  // start the replica group
2971  virtual INT32 start () = 0 ;
2972 
2973  // get the replica group name
2974  virtual const CHAR *getName () = 0 ;
2975 
2976  // whether the current replica group is catalog replica group or not
2977  virtual BOOLEAN isCatalog () = 0 ;
2978 
2979  // attach node
2980  virtual INT32 attachNode( const CHAR *pHostName,
2981  const CHAR *pSvcName,
2982  const bson::BSONObj &options ) = 0 ;
2983 
2984  // detach node
2985  virtual INT32 detachNode( const CHAR *pHostName,
2986  const CHAR *pSvcName,
2987  const bson::BSONObj &options ) = 0 ;
2988 
2989  // reelect primary node
2990  virtual INT32 reelect( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
2991  } ;
2992 
2996  class DLLEXPORT sdbReplicaGroup
2997  {
2998  private :
2999  sdbReplicaGroup ( const sdbReplicaGroup& other ) ;
3000  sdbReplicaGroup& operator=( const sdbReplicaGroup& ) ;
3001  public :
3008  _sdbReplicaGroup *pReplicaGroup ;
3009 
3014  {
3015  pReplicaGroup = NULL ;
3016  }
3017 
3022  {
3023  if ( pReplicaGroup )
3024  {
3025  delete pReplicaGroup ;
3026  }
3027  }
3028 
3043  INT32 getNodeNum ( sdbNodeStatus status, INT32 *num )
3044  {
3045  if ( !pReplicaGroup )
3046  {
3047  return SDB_NOT_CONNECTED ;
3048  }
3049  return pReplicaGroup->getNodeNum ( status, num ) ;
3050  }
3051 
3058  INT32 getDetail ( bson::BSONObj &result )
3059  {
3060  if ( !pReplicaGroup )
3061  {
3062  return SDB_NOT_CONNECTED ;
3063  }
3064  return pReplicaGroup->getDetail ( result ) ;
3065  }
3066 
3067  /* \fn INT32 getMaster ( _sdbNode **node )
3068  \brief Get the master node of the current replica group.
3069  \param [out] node The master node.If not exit,return null.
3070  \retval SDB_OK Operation Success
3071  \retval Others Operation Fail
3072  */
3073  INT32 getMaster ( _sdbNode **node )
3074  {
3075  if ( !pReplicaGroup )
3076  {
3077  return SDB_NOT_CONNECTED ;
3078  }
3079  return pReplicaGroup->getMaster ( node ) ;
3080  }
3081 
3088  INT32 getMaster ( sdbNode &node )
3089  {
3090  if ( !pReplicaGroup )
3091  {
3092  return SDB_NOT_CONNECTED ;
3093  }
3094  RELEASE_INNER_HANDLE( node.pNode ) ;
3095  return pReplicaGroup->getMaster ( node ) ;
3096  }
3097 
3098  /* \fn INT32 getSlave ( _sdbNode **node, const vector<INT32>& positions )
3099  \brief Get one of slave node of the current replica group,
3100  if no slave exists then get master
3101  \param [in] positions The positions of nodes
3102  \param [out] node The slave node
3103  \retval SDB_OK Operation Success
3104  \retval Others Operation Fail
3105  */
3106  INT32 getSlave ( _sdbNode **node,
3107  const vector<INT32>& positions = _sdbStaticVec )
3108  {
3109  if ( !pReplicaGroup )
3110  {
3111  return SDB_NOT_CONNECTED ;
3112  }
3113  return pReplicaGroup->getSlave ( node, positions ) ;
3114  }
3115 
3124  INT32 getSlave ( sdbNode &node,
3125  const vector<INT32>& positions = _sdbStaticVec )
3126  {
3127  if ( !pReplicaGroup )
3128  {
3129  return SDB_NOT_CONNECTED ;
3130  }
3131  RELEASE_INNER_HANDLE( node.pNode ) ;
3132  return pReplicaGroup->getSlave ( node, positions ) ;
3133  }
3134 
3135  /* \fn INT32 getNode ( const CHAR *pNodeName,
3136  _sdbNode **node )
3137  \brief Get specified node from current replica group.
3138  \param [in] pNodeName The name of the node, with the format of "hostname:port".
3139  \param [out] node The specified node
3140  \retval SDB_OK Operation Success
3141  \retval Others Operation Fail
3142  */
3143  INT32 getNode ( const CHAR *pNodeName,
3144  _sdbNode **node )
3145  {
3146  if ( !pReplicaGroup )
3147  {
3148  return SDB_NOT_CONNECTED ;
3149  }
3150  return pReplicaGroup->getNode ( pNodeName, node ) ;
3151  }
3152 
3161  INT32 getNode ( const CHAR *pNodeName,
3162  sdbNode &node )
3163  {
3164  if ( !pReplicaGroup )
3165  {
3166  return SDB_NOT_CONNECTED ;
3167  }
3168  RELEASE_INNER_HANDLE( node.pNode ) ;
3169  return pReplicaGroup->getNode ( pNodeName, node ) ;
3170  }
3171 
3172  INT32 getNode ( const CHAR *pHostName,
3173  const CHAR *pServiceName,
3174  _sdbNode **node )
3175  {
3176  if ( !pReplicaGroup )
3177  {
3178  return SDB_NOT_CONNECTED ;
3179  }
3180  return pReplicaGroup->getNode ( pHostName, pServiceName, node ) ;
3181  }
3182 
3193  INT32 getNode ( const CHAR *pHostName,
3194  const CHAR *pServiceName,
3195  sdbNode &node )
3196  {
3197  if ( !pReplicaGroup )
3198  {
3199  return SDB_NOT_CONNECTED ;
3200  }
3201  RELEASE_INNER_HANDLE( node.pNode ) ;
3202  return pReplicaGroup->getNode ( pHostName, pServiceName, node ) ;
3203  }
3204 
3218  INT32 createNode ( const CHAR *pHostName,
3219  const CHAR *pServiceName,
3220  const CHAR *pDatabasePath,
3221  std::map<std::string,std::string> &config )
3222  {
3223  if ( !pReplicaGroup )
3224  {
3225  return SDB_NOT_CONNECTED ;
3226  }
3227  return pReplicaGroup->createNode ( pHostName, pServiceName,
3228  pDatabasePath, config ) ;
3229  }
3230 
3243  INT32 createNode ( const CHAR *pHostName,
3244  const CHAR *pServiceName,
3245  const CHAR *pDatabasePath,
3246  const bson::BSONObj &options = _sdbStaticObject )
3247  {
3248  if ( !pReplicaGroup )
3249  {
3250  return SDB_NOT_CONNECTED ;
3251  }
3252  return pReplicaGroup->createNode ( pHostName, pServiceName,
3253  pDatabasePath, options ) ;
3254  }
3255 
3266  INT32 removeNode ( const CHAR *pHostName,
3267  const CHAR *pServiceName,
3268  const bson::BSONObj &configure = _sdbStaticObject )
3269  {
3270  if ( !pReplicaGroup )
3271  {
3272  return SDB_NOT_CONNECTED ;
3273  }
3274  return pReplicaGroup->removeNode ( pHostName, pServiceName,
3275  configure ) ;
3276  }
3282  INT32 stop ()
3283  {
3284  if ( !pReplicaGroup )
3285  {
3286  return SDB_NOT_CONNECTED ;
3287  }
3288  return pReplicaGroup->stop () ;
3289  }
3290 
3296  INT32 start ()
3297  {
3298  if ( !pReplicaGroup )
3299  {
3300  return SDB_NOT_CONNECTED ;
3301  }
3302  return pReplicaGroup->start () ;
3303  }
3304 
3309  const CHAR *getName ()
3310  {
3311  if ( !pReplicaGroup )
3312  {
3313  return NULL ;
3314  }
3315  return pReplicaGroup->getName() ;
3316  }
3317 
3323  BOOLEAN isCatalog ()
3324  {
3325  if ( !pReplicaGroup )
3326  {
3327  return FALSE ;
3328  }
3329  return pReplicaGroup->isCatalog() ;
3330  }
3331 
3346  INT32 attachNode( const CHAR *pHostName,
3347  const CHAR *pSvcName,
3348  const bson::BSONObj &options )
3349  {
3350  if ( !pReplicaGroup )
3351  {
3352  return SDB_NOT_CONNECTED ;
3353  }
3354  return pReplicaGroup->attachNode( pHostName, pSvcName, options ) ;
3355  }
3356 
3372  INT32 detachNode( const CHAR *pHostName,
3373  const CHAR *pSvcName,
3374  const bson::BSONObj &options )
3375  {
3376  if ( !pReplicaGroup )
3377  {
3378  return SDB_NOT_CONNECTED ;
3379  }
3380  return pReplicaGroup->detachNode( pHostName, pSvcName, options ) ;
3381  }
3382 
3391  INT32 reelect( const bson::BSONObj &options = _sdbStaticObject )
3392  {
3393  if( !pReplicaGroup )
3394  {
3395  return SDB_NOT_CONNECTED ;
3396  }
3397  return pReplicaGroup->reelect( options ) ;
3398  }
3399  } ;
3400 
3401  class DLLEXPORT _sdbCollectionSpace
3402  {
3403  private :
3404  _sdbCollectionSpace ( const _sdbCollectionSpace& other ) ;
3405  _sdbCollectionSpace& operator=( const _sdbCollectionSpace& ) ;
3406  public :
3407  _sdbCollectionSpace () {}
3408  virtual ~_sdbCollectionSpace () {}
3409  // get a collection object
3410  virtual INT32 getCollection ( const CHAR *pCollectionName,
3411  _sdbCollection **collection,
3412  BOOLEAN checkExist = TRUE ) = 0 ;
3413 
3414  virtual INT32 getCollection ( const CHAR *pCollectionName,
3415  sdbCollection &collection,
3416  BOOLEAN checkExist = TRUE ) = 0 ;
3417 
3418  // create a new collection object with options
3419  virtual INT32 createCollection ( const CHAR *pCollection,
3420  const bson::BSONObj &options,
3421  _sdbCollection **collection ) = 0 ;
3422 
3423  virtual INT32 createCollection ( const CHAR *pCollection,
3424  const bson::BSONObj &options,
3425  sdbCollection &collection ) = 0 ;
3426 
3427  // create a new collection object
3428  virtual INT32 createCollection ( const CHAR *pCollection,
3429  _sdbCollection **collection ) = 0 ;
3430 
3431  virtual INT32 createCollection ( const CHAR *pCollection,
3432  sdbCollection &collection ) = 0 ;
3433 
3434  // drop an existing collection with options
3435  virtual INT32 dropCollection( const CHAR *pCollection,
3436  const bson::BSONObj &options ) = 0 ;
3437 
3438  virtual INT32 listCollections ( _sdbCursor **cursor ) = 0 ;
3439 
3440  virtual INT32 listCollections ( sdbCursor &cursor ) = 0 ;
3441 
3442  // create a collection space with current collection space name
3443  virtual INT32 create () = 0 ;
3444  // drop a collection space with current collection space name
3445  virtual INT32 drop () = 0 ;
3446 
3447  // get the collectonSpace's name
3448  virtual const CHAR *getCSName () = 0 ;
3449 
3450  // rename collection
3451  virtual INT32 renameCollection( const CHAR* oldName, const CHAR* newName,
3452  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
3453 
3454  virtual INT32 alterCollectionSpace ( const bson::BSONObj & options ) = 0 ;
3455 
3456  virtual INT32 setDomain ( const bson::BSONObj & options ) = 0 ;
3457 
3458  virtual INT32 getDomainName ( CHAR *result, INT32 resultLen ) = 0 ;
3459 
3460  virtual INT32 removeDomain () = 0 ;
3461 
3462  virtual INT32 enableCapped () = 0 ;
3463 
3464  virtual INT32 disableCapped () = 0 ;
3465 
3466  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
3467  } ;
3471  class DLLEXPORT sdbCollectionSpace
3472  {
3473  private :
3478  sdbCollectionSpace ( const sdbCollectionSpace& other ) ;
3479 
3485  sdbCollectionSpace& operator=( const sdbCollectionSpace& ) ;
3486  public :
3493  _sdbCollectionSpace *pCollectionSpace ;
3494 
3499  {
3500  pCollectionSpace = NULL ;
3501  }
3502 
3507  {
3508  if ( pCollectionSpace )
3509  {
3510  delete pCollectionSpace ;
3511  }
3512  }
3513 
3514  INT32 getCollection ( const CHAR *pCollectionName,
3515  _sdbCollection **collection,
3516  BOOLEAN checkExist = TRUE )
3517  {
3518  if ( !pCollectionSpace )
3519  {
3520  return SDB_NOT_CONNECTED ;
3521  }
3522  return pCollectionSpace->getCollection ( pCollectionName,
3523  collection, checkExist ) ;
3524  }
3525 
3536  INT32 getCollection ( const CHAR *pCollectionName,
3537  sdbCollection &collection,
3538  BOOLEAN checkExist = TRUE )
3539  {
3540  if ( !pCollectionSpace )
3541  {
3542  return SDB_NOT_CONNECTED ;
3543  }
3544  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3545  return pCollectionSpace->getCollection ( pCollectionName,
3546  collection,
3547  checkExist ) ;
3548  }
3549 
3550  INT32 createCollection ( const CHAR *pCollection,
3551  const bson::BSONObj &options,
3552  _sdbCollection **collection )
3553  {
3554  if ( !pCollectionSpace )
3555  {
3556  return SDB_NOT_CONNECTED ;
3557  }
3558  return pCollectionSpace->createCollection ( pCollection,
3559  options,
3560  collection ) ;
3561  }
3562 
3575  INT32 createCollection ( const CHAR *pCollection,
3576  const bson::BSONObj &options,
3577  sdbCollection &collection )
3578  {
3579  if ( !pCollectionSpace )
3580  {
3581  return SDB_NOT_CONNECTED ;
3582  }
3583  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3584  return pCollectionSpace->createCollection ( pCollection,
3585  options,
3586  collection ) ;
3587  }
3588 
3589  INT32 createCollection ( const CHAR *pCollection,
3590  _sdbCollection **collection )
3591  {
3592  if ( !pCollectionSpace )
3593  {
3594  return SDB_NOT_CONNECTED ;
3595  }
3596  return pCollectionSpace->createCollection ( pCollection,
3597  collection ) ;
3598  }
3599 
3609  INT32 createCollection ( const CHAR *pCollection,
3610  sdbCollection &collection )
3611  {
3612  if ( !pCollectionSpace )
3613  {
3614  return SDB_NOT_CONNECTED ;
3615  }
3616  RELEASE_INNER_HANDLE( collection.pCollection ) ;
3617  return pCollectionSpace->createCollection ( pCollection,
3618  collection ) ;
3619  }
3620 
3630  INT32 dropCollection( const CHAR *pCollection,
3631  const bson::BSONObj &options = _sdbStaticObject )
3632  {
3633  if ( !pCollectionSpace )
3634  {
3635  return SDB_NOT_CONNECTED ;
3636  }
3637  return pCollectionSpace->dropCollection( pCollection, options ) ;
3638  }
3639 
3646  INT32 listCollections ( _sdbCursor **cursor )
3647  {
3648  if ( !pCollectionSpace )
3649  {
3650  return SDB_NOT_CONNECTED ;
3651  }
3652  return pCollectionSpace->listCollections( cursor ) ;
3653  }
3654 
3661  INT32 listCollections ( sdbCursor &cursor )
3662  {
3663  if ( !pCollectionSpace )
3664  {
3665  return SDB_NOT_CONNECTED ;
3666  }
3667  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
3668  return pCollectionSpace->listCollections( cursor ) ;
3669  }
3670 
3677  INT32 create ()
3678  {
3679  if ( !pCollectionSpace )
3680  {
3681  return SDB_NOT_CONNECTED ;
3682  }
3683  return pCollectionSpace->create () ;
3684  }
3685 
3692  INT32 drop ()
3693  {
3694  if ( !pCollectionSpace )
3695  {
3696  return SDB_NOT_CONNECTED ;
3697  }
3698  return pCollectionSpace->drop () ;
3699  }
3700 
3705  const CHAR *getCSName ()
3706  {
3707  if ( !pCollectionSpace )
3708  {
3709  return NULL ;
3710  }
3711  return pCollectionSpace->getCSName () ;
3712  }
3713 
3724  INT32 renameCollection( const CHAR* oldName, const CHAR* newName,
3725  const bson::BSONObj &options = _sdbStaticObject )
3726  {
3727  if( !pCollectionSpace )
3728  {
3729  return SDB_NOT_CONNECTED ;
3730  }
3731  return pCollectionSpace->renameCollection( oldName, newName, options ) ;
3732  }
3733 
3745  INT32 alterCollectionSpace ( const bson::BSONObj & options )
3746  {
3747  if ( NULL == pCollectionSpace )
3748  {
3749  return SDB_NOT_CONNECTED ;
3750  }
3751  return pCollectionSpace->alterCollectionSpace( options ) ;
3752  }
3753 
3763  INT32 setDomain ( const bson::BSONObj & options )
3764  {
3765  if ( NULL == pCollectionSpace )
3766  {
3767  return SDB_NOT_CONNECTED ;
3768  }
3769  return pCollectionSpace->setDomain( options ) ;
3770  }
3771 
3779  INT32 getDomainName ( CHAR *result, INT32 resultLen )
3780  {
3781  if ( !pCollectionSpace )
3782  {
3783  return SDB_NOT_CONNECTED ;
3784  }
3785  return pCollectionSpace->getDomainName( result, resultLen ) ;
3786  }
3787 
3793  INT32 removeDomain ()
3794  {
3795  if ( NULL == pCollectionSpace )
3796  {
3797  return SDB_NOT_CONNECTED ;
3798  }
3799  return pCollectionSpace->removeDomain() ;
3800  }
3801 
3807  INT32 enableCapped ()
3808  {
3809  if ( NULL == pCollectionSpace )
3810  {
3811  return SDB_NOT_CONNECTED ;
3812  }
3813  return pCollectionSpace->enableCapped() ;
3814  }
3815 
3821  INT32 disableCapped ()
3822  {
3823  if ( NULL == pCollectionSpace )
3824  {
3825  return SDB_NOT_CONNECTED ;
3826  }
3827  return pCollectionSpace->disableCapped() ;
3828  }
3829 
3841  INT32 setAttributes ( const bson::BSONObj & options )
3842  {
3843  if ( NULL == pCollectionSpace )
3844  {
3845  return SDB_NOT_CONNECTED ;
3846  }
3847  return pCollectionSpace->setAttributes( options ) ;
3848  }
3849  } ;
3850 
3851  class DLLEXPORT _sdbDomain
3852  {
3853  private :
3854  _sdbDomain ( const _sdbDomain& other ) ; // non construction-copyable
3855  _sdbDomain& operator= ( const _sdbDomain& ) ; // non copyable
3856  public :
3857  _sdbDomain () {}
3858  virtual ~_sdbDomain () {}
3859 
3860  virtual const CHAR* getName () = 0 ;
3861 
3862  virtual INT32 alterDomain ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
3863 
3864  virtual INT32 listCollectionSpacesInDomain ( _sdbCursor **cursor ) = 0 ;
3865 
3866  virtual INT32 listCollectionSpacesInDomain ( sdbCursor &cursor ) = 0 ;
3867 
3868  virtual INT32 listCollectionsInDomain ( _sdbCursor **cursor ) = 0 ;
3869 
3870  virtual INT32 listCollectionsInDomain ( sdbCursor &cursor ) = 0 ;
3871 
3872  virtual INT32 listReplicaGroupInDomain( _sdbCursor **cursor ) = 0 ;
3873 
3874  virtual INT32 listReplicaGroupInDomain( sdbCursor &cursor ) = 0 ;
3875 
3876  virtual INT32 addGroups ( const bson::BSONObj & options ) = 0 ;
3877 
3878  virtual INT32 setGroups ( const bson::BSONObj & options ) = 0 ;
3879 
3880  virtual INT32 removeGroups ( const bson::BSONObj & options ) = 0 ;
3881 
3882  virtual INT32 setAttributes ( const bson::BSONObj & options ) = 0 ;
3883  } ;
3884 
3888  class DLLEXPORT sdbDomain
3889  {
3890  private :
3891  sdbDomain ( const sdbDomain& ) ; // non construction-copyable
3892  sdbDomain& operator= ( const sdbDomain& ) ; // non copyable
3893  public :
3894 
3901  _sdbDomain *pDomain ;
3902 
3906  sdbDomain() { pDomain = NULL ; }
3907 
3912  {
3913  if ( pDomain )
3914  {
3915  delete pDomain ;
3916  }
3917  }
3918 
3923  const CHAR *getName ()
3924  {
3925  if ( !pDomain )
3926  {
3927  return NULL ;
3928  }
3929  return pDomain->getName() ;
3930  }
3931 
3949  INT32 alterDomain ( const bson::BSONObj &options )
3950  {
3951  if ( !pDomain )
3952  {
3953  return SDB_NOT_CONNECTED ;
3954  }
3955  return pDomain->alterDomain ( options ) ;
3956  }
3957 
3968  INT32 addGroups ( const bson::BSONObj & options )
3969  {
3970  if ( NULL == pDomain )
3971  {
3972  return SDB_NOT_CONNECTED ;
3973  }
3974  return pDomain->addGroups( options ) ;
3975  }
3976 
3989  INT32 setGroups ( const bson::BSONObj & options )
3990  {
3991  if ( NULL == pDomain )
3992  {
3993  return SDB_NOT_CONNECTED ;
3994  }
3995  return pDomain->setGroups( options ) ;
3996  }
3997 
4009  INT32 removeGroups ( const bson::BSONObj & options )
4010  {
4011  if ( NULL == pDomain )
4012  {
4013  return SDB_NOT_CONNECTED ;
4014  }
4015  return pDomain->removeGroups( options ) ;
4016  }
4017 
4035  INT32 setAttributes ( const bson::BSONObj &options )
4036  {
4037  if ( !pDomain )
4038  {
4039  return SDB_NOT_CONNECTED ;
4040  }
4041  return pDomain->setAttributes( options ) ;
4042  }
4043 
4051  INT32 listCollectionSpacesInDomain ( sdbCursor &cursor )
4052  {
4053  if ( !pDomain )
4054  {
4055  return SDB_NOT_CONNECTED ;
4056  }
4057  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4058  return pDomain->listCollectionSpacesInDomain ( cursor ) ;
4059  }
4060 
4061  INT32 listCollectionSpacesInDomain ( _sdbCursor **cursor )
4062  {
4063  if ( !pDomain )
4064  {
4065  return SDB_NOT_CONNECTED ;
4066  }
4067  return pDomain->listCollectionSpacesInDomain ( cursor ) ;
4068  }
4069 
4077  INT32 listCollectionsInDomain ( sdbCursor &cursor )
4078  {
4079  if ( !pDomain )
4080  {
4081  return SDB_NOT_CONNECTED ;
4082  }
4083  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4084  return pDomain->listCollectionsInDomain ( cursor ) ;
4085  }
4086 
4094  INT32 listCollectionsInDomain ( _sdbCursor **cursor )
4095  {
4096  if ( !pDomain )
4097  {
4098  return SDB_NOT_CONNECTED ;
4099  }
4100  return pDomain->listCollectionsInDomain ( cursor ) ;
4101  }
4102 
4103  INT32 listReplicaGroupInDomain( _sdbCursor **cursor )
4104  {
4105  if ( !pDomain )
4106  {
4107  return SDB_NOT_CONNECTED ;
4108  }
4109  return pDomain->listReplicaGroupInDomain( cursor ) ;
4110  }
4111 
4118  INT32 listReplicaGroupInDomain( sdbCursor &cursor )
4119  {
4120  if ( !pDomain )
4121  {
4122  return SDB_NOT_CONNECTED ;
4123  }
4124  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
4125  return pDomain->listReplicaGroupInDomain( cursor ) ;
4126  }
4127  };
4128 
4129  class DLLEXPORT _sdbDataCenter
4130  {
4131  private :
4132  _sdbDataCenter ( const _sdbDataCenter& other ) ; // non construction-copyable
4133  _sdbDataCenter& operator= ( const _sdbDataCenter& ) ; // non copyable
4134 
4135  public :
4136  _sdbDataCenter () {}
4137  virtual ~_sdbDataCenter () {}
4138 
4139  public :
4140  virtual const CHAR *getName () = 0 ;
4141  virtual INT32 getDetail( bson::BSONObj &retInfo ) = 0 ;
4142  virtual INT32 activateDC() = 0 ;
4143  virtual INT32 deactivateDC() = 0 ;
4144  virtual INT32 enableReadOnly( BOOLEAN isReadOnly ) = 0 ;
4145  virtual INT32 createImage( const CHAR *pCataAddrList ) = 0 ;
4146  virtual INT32 removeImage() = 0 ;
4147  virtual INT32 enableImage() = 0 ;
4148  virtual INT32 disableImage() = 0 ;
4149  virtual INT32 attachGroups( const bson::BSONObj &info ) = 0 ;
4150  virtual INT32 detachGroups( const bson::BSONObj &info ) = 0 ;
4151 
4152  } ;
4153 
4154  /* \class sdbDataCenter
4155  \brief Database operation interfaces of data center.
4156  */
4157  class DLLEXPORT sdbDataCenter
4158  {
4159  private :
4160  sdbDataCenter ( const sdbDataCenter& ) ; // non construction-copyable
4161  sdbDataCenter& operator= ( const sdbDataCenter& ) ; // non copyable
4162 
4163  public :
4164 
4171  _sdbDataCenter *pDC ;
4172 
4176  sdbDataCenter() { pDC = NULL ; }
4177 
4181  ~sdbDataCenter()
4182  {
4183  if ( pDC )
4184  {
4185  delete pDC ;
4186  }
4187  }
4188 
4189  public :
4190 
4195  const CHAR *getName ()
4196  {
4197  if ( NULL == pDC )
4198  {
4199  return NULL ;
4200  }
4201  return pDC->getName() ;
4202  }
4203 
4210  INT32 getDetail( bson::BSONObj &retInfo )
4211  {
4212  if ( NULL == pDC )
4213  {
4214  return SDB_NOT_CONNECTED ;
4215  }
4216  return pDC->getDetail( retInfo ) ;
4217  }
4218 
4224  INT32 activateDC()
4225  {
4226  if ( NULL == pDC )
4227  {
4228  return SDB_NOT_CONNECTED ;
4229  }
4230  return pDC->activateDC() ;
4231  }
4232 
4238  INT32 deactivateDC()
4239  {
4240  if ( NULL == pDC )
4241  {
4242  return SDB_NOT_CONNECTED ;
4243  }
4244  return pDC->deactivateDC() ;
4245  }
4246 
4253  INT32 enableReadOnly( BOOLEAN isReadOnly )
4254  {
4255  if ( NULL == pDC )
4256  {
4257  return SDB_NOT_CONNECTED ;
4258  }
4259  return pDC->enableReadOnly( isReadOnly ) ;
4260  }
4261 
4269  INT32 createImage( const CHAR *pCataAddrList )
4270  {
4271  if ( NULL == pDC )
4272  {
4273  return SDB_NOT_CONNECTED ;
4274  }
4275  return pDC->createImage( pCataAddrList ) ;
4276  }
4277 
4283  INT32 removeImage()
4284  {
4285  if ( NULL == pDC )
4286  {
4287  return SDB_NOT_CONNECTED ;
4288  }
4289  return pDC->removeImage() ;
4290  }
4291 
4297  INT32 enableImage()
4298  {
4299  if ( NULL == pDC )
4300  {
4301  return SDB_NOT_CONNECTED ;
4302  }
4303  return pDC->enableImage() ;
4304  }
4305 
4311  INT32 disableImage()
4312  {
4313  if ( NULL == pDC )
4314  {
4315  return SDB_NOT_CONNECTED ;
4316  }
4317  return pDC->disableImage() ;
4318  }
4319 
4326  INT32 attachGroups( const bson::BSONObj &info )
4327  {
4328  if ( NULL == pDC )
4329  {
4330  return SDB_NOT_CONNECTED ;
4331  }
4332  return pDC->attachGroups( info ) ;
4333  }
4334 
4341  INT32 detachGroups( const bson::BSONObj &info )
4342  {
4343  if ( NULL == pDC )
4344  {
4345  return SDB_NOT_CONNECTED ;
4346  }
4347  return pDC->detachGroups( info ) ;
4348  }
4349 
4350  };
4351 
4352  class DLLEXPORT _sdbRecycleBin
4353  {
4354  private :
4355  _sdbRecycleBin ( const _sdbRecycleBin& other ) ; // non construction-copyable
4356  _sdbRecycleBin& operator= ( const _sdbRecycleBin& ) ; // non copyable
4357 
4358  public :
4359  _sdbRecycleBin () {}
4360  virtual ~_sdbRecycleBin () {}
4361 
4362  public :
4363  virtual INT32 getDetail( bson::BSONObj &retInfo ) = 0 ;
4364  virtual INT32 enable() = 0 ;
4365  virtual INT32 disable() = 0 ;
4366  virtual INT32 setAttributes( const bson::BSONObj &options ) = 0 ;
4367  virtual INT32 alter( const bson::BSONObj &options ) = 0 ;
4368  virtual INT32 returnItem( const CHAR *recycleName,
4369  const bson::BSONObj &options = _sdbStaticObject,
4370  bson::BSONObj *result = NULL ) = 0 ;
4371  virtual INT32 returnItemToName( const CHAR *recycleName,
4372  const CHAR *returnName,
4373  const bson::BSONObj &options = _sdbStaticObject,
4374  bson::BSONObj *result = NULL ) = 0 ;
4375  virtual INT32 dropItem( const CHAR *recycleName,
4376  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4377  virtual INT32 dropAll( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
4378  virtual INT32 list( _sdbCursor **cursor,
4379  const bson::BSONObj &condition = _sdbStaticObject,
4380  const bson::BSONObj &selector = _sdbStaticObject,
4381  const bson::BSONObj &orderBy = _sdbStaticObject,
4382  const bson::BSONObj &hint = _sdbStaticObject,
4383  INT64 numToSkip = 0,
4384  INT64 numToReturn = -1 ) = 0 ;
4385  virtual INT32 list( sdbCursor &cursor,
4386  const bson::BSONObj &condition = _sdbStaticObject,
4387  const bson::BSONObj &selector = _sdbStaticObject,
4388  const bson::BSONObj &orderBy = _sdbStaticObject,
4389  const bson::BSONObj &hint = _sdbStaticObject,
4390  INT64 numToSkip = 0,
4391  INT64 numToReturn = -1 ) = 0 ;
4392  virtual INT32 snapshot( _sdbCursor **cursor,
4393  const bson::BSONObj &condition = _sdbStaticObject,
4394  const bson::BSONObj &selector = _sdbStaticObject,
4395  const bson::BSONObj &orderBy = _sdbStaticObject,
4396  const bson::BSONObj &hint = _sdbStaticObject,
4397  INT64 numToSkip = 0,
4398  INT64 numToReturn = -1 ) = 0 ;
4399  virtual INT32 snapshot( sdbCursor &cursor,
4400  const bson::BSONObj &condition = _sdbStaticObject,
4401  const bson::BSONObj &selector = _sdbStaticObject,
4402  const bson::BSONObj &orderBy = _sdbStaticObject,
4403  const bson::BSONObj &hint = _sdbStaticObject,
4404  INT64 numToSkip = 0,
4405  INT64 numToReturn = -1 ) = 0 ;
4406  virtual INT32 getCount( INT64 &count,
4407  const bson::BSONObj &condition = _sdbStaticObject ) = 0 ;
4408  } ;
4409 
4410  /* \class sdbRecycleBin
4411  \brief Database operation interfaces of recycle bin.
4412  */
4413  class DLLEXPORT sdbRecycleBin
4414  {
4415  private :
4416  sdbRecycleBin( const sdbRecycleBin & ) ; // non construction-copyable
4417  sdbRecycleBin &operator =( const sdbRecycleBin & ) ; // non copyable
4418 
4419  public :
4420 
4427  _sdbRecycleBin *pRecycleBin ;
4428 
4432  sdbRecycleBin() { pRecycleBin = NULL ; }
4433 
4437  ~sdbRecycleBin()
4438  {
4439  if ( pRecycleBin )
4440  {
4441  delete pRecycleBin ;
4442  }
4443  }
4444 
4445  public :
4446 
4453  INT32 getDetail( bson::BSONObj &retInfo )
4454  {
4455  if ( NULL == pRecycleBin )
4456  {
4457  return SDB_NOT_CONNECTED ;
4458  }
4459  return pRecycleBin->getDetail( retInfo ) ;
4460  }
4461 
4467  INT32 enable()
4468  {
4469  if ( NULL == pRecycleBin )
4470  {
4471  return SDB_NOT_CONNECTED ;
4472  }
4473  return pRecycleBin->enable() ;
4474  }
4475 
4481  INT32 disable()
4482  {
4483  if ( NULL == pRecycleBin )
4484  {
4485  return SDB_NOT_CONNECTED ;
4486  }
4487  return pRecycleBin->disable() ;
4488  }
4489 
4503  INT32 setAttributes( const bson::BSONObj &options )
4504  {
4505  if ( NULL == pRecycleBin )
4506  {
4507  return SDB_NOT_CONNECTED ;
4508  }
4509  return pRecycleBin->setAttributes( options ) ;
4510  }
4511 
4525  INT32 alter( const bson::BSONObj &options )
4526  {
4527  if ( NULL == pRecycleBin )
4528  {
4529  return SDB_NOT_CONNECTED ;
4530  }
4531  return pRecycleBin->alter( options ) ;
4532  }
4533 
4544  INT32 returnItem( const CHAR *recycleName,
4545  const bson::BSONObj &options = _sdbStaticObject,
4546  bson::BSONObj *result = NULL )
4547  {
4548  if ( NULL == pRecycleBin )
4549  {
4550  return SDB_NOT_CONNECTED ;
4551  }
4552  return pRecycleBin->returnItem( recycleName, options, result ) ;
4553  }
4554 
4567  INT32 returnItemToName( const CHAR *recycleName,
4568  const CHAR *returnName,
4569  const bson::BSONObj &options = _sdbStaticObject,
4570  bson::BSONObj *result = NULL )
4571  {
4572  if ( NULL == pRecycleBin )
4573  {
4574  return SDB_NOT_CONNECTED ;
4575  }
4576  return pRecycleBin->returnItemToName( recycleName,
4577  returnName,
4578  options,
4579  result ) ;
4580  }
4581 
4589  INT32 dropItem( const CHAR *recycleName,
4590  const bson::BSONObj &options = _sdbStaticObject )
4591  {
4592  if ( NULL == pRecycleBin )
4593  {
4594  return SDB_NOT_CONNECTED ;
4595  }
4596  return pRecycleBin->dropItem( recycleName, options ) ;
4597  }
4598 
4605  INT32 dropAll( const bson::BSONObj &options = _sdbStaticObject )
4606  {
4607  if ( NULL == pRecycleBin )
4608  {
4609  return SDB_NOT_CONNECTED ;
4610  }
4611  return pRecycleBin->dropAll( options ) ;
4612  }
4613 
4633  INT32 list( _sdbCursor **cursor,
4634  const bson::BSONObj &condition = _sdbStaticObject,
4635  const bson::BSONObj &selector = _sdbStaticObject,
4636  const bson::BSONObj &orderBy = _sdbStaticObject,
4637  const bson::BSONObj &hint = _sdbStaticObject,
4638  INT64 numToSkip = 0,
4639  INT64 numToReturn = -1 )
4640  {
4641  if ( NULL == pRecycleBin )
4642  {
4643  return SDB_NOT_CONNECTED ;
4644  }
4645  return pRecycleBin->list( cursor,
4646  condition,
4647  selector,
4648  orderBy,
4649  hint,
4650  numToSkip,
4651  numToReturn ) ;
4652  }
4653 
4673  INT32 list( sdbCursor &cursor,
4674  const bson::BSONObj &condition = _sdbStaticObject,
4675  const bson::BSONObj &selector = _sdbStaticObject,
4676  const bson::BSONObj &orderBy = _sdbStaticObject,
4677  const bson::BSONObj &hint = _sdbStaticObject,
4678  INT64 numToSkip = 0,
4679  INT64 numToReturn = -1 )
4680  {
4681  if ( NULL == pRecycleBin )
4682  {
4683  return SDB_NOT_CONNECTED ;
4684  }
4685  return pRecycleBin->list( cursor,
4686  condition,
4687  selector,
4688  orderBy,
4689  hint,
4690  numToSkip,
4691  numToReturn ) ;
4692  }
4693 
4713  INT32 snapshot( _sdbCursor **cursor,
4714  const bson::BSONObj &condition = _sdbStaticObject,
4715  const bson::BSONObj &selector = _sdbStaticObject,
4716  const bson::BSONObj &orderBy = _sdbStaticObject,
4717  const bson::BSONObj &hint = _sdbStaticObject,
4718  INT64 numToSkip = 0,
4719  INT64 numToReturn = -1 )
4720  {
4721  if ( NULL == pRecycleBin )
4722  {
4723  return SDB_NOT_CONNECTED ;
4724  }
4725  return pRecycleBin->snapshot( cursor,
4726  condition,
4727  selector,
4728  orderBy,
4729  hint,
4730  numToSkip,
4731  numToReturn ) ;
4732  }
4733 
4753  INT32 snapshot( sdbCursor &cursor,
4754  const bson::BSONObj &condition = _sdbStaticObject,
4755  const bson::BSONObj &selector = _sdbStaticObject,
4756  const bson::BSONObj &orderBy = _sdbStaticObject,
4757  const bson::BSONObj &hint = _sdbStaticObject,
4758  INT64 numToSkip = 0,
4759  INT64 numToReturn = -1 )
4760  {
4761  if ( NULL == pRecycleBin )
4762  {
4763  return SDB_NOT_CONNECTED ;
4764  }
4765  return pRecycleBin->snapshot( cursor,
4766  condition,
4767  selector,
4768  orderBy,
4769  hint,
4770  numToSkip,
4771  numToReturn ) ;
4772  }
4773 
4782  INT32 getCount( INT64 &count,
4783  const bson::BSONObj &condition = _sdbStaticObject )
4784  {
4785  if ( NULL == pRecycleBin )
4786  {
4787  return SDB_NOT_CONNECTED ;
4788  }
4789  return pRecycleBin->getCount( count, condition ) ;
4790  }
4791  } ;
4792 
4793  class DLLEXPORT _sdbLob
4794  {
4795  private :
4796  _sdbLob ( const _sdbLob& other ) ; // non construction-copyable
4797  _sdbLob& operator= ( const _sdbLob& ) ; // non copyable
4798 
4799  public :
4800  _sdbLob () {}
4801 
4802  virtual ~_sdbLob () {}
4803 
4804  virtual INT32 close () = 0 ;
4805 
4806  virtual INT32 read ( UINT32 len, CHAR *buf, UINT32 *read ) = 0 ;
4807 
4808  virtual INT32 write ( const CHAR *buf, UINT32 len ) = 0 ;
4809 
4810  virtual INT32 seek ( SINT64 size, SDB_LOB_SEEK whence ) = 0 ;
4811 
4812  virtual INT32 lock( INT64 offset, INT64 length ) = 0 ;
4813 
4814  virtual INT32 lockAndSeek( INT64 offset, INT64 length ) = 0 ;
4815 
4816  virtual INT32 isClosed( BOOLEAN &flag ) = 0 ;
4817 
4818  virtual INT32 getOid( bson::OID &oid ) = 0 ;
4819 
4820  virtual INT32 getSize( SINT64 *size ) = 0 ;
4821 
4822  virtual INT32 getCreateTime ( UINT64 *millis ) = 0 ;
4823 
4824  virtual BOOLEAN isClosed() = 0 ;
4825 
4826  virtual bson::OID getOid() = 0 ;
4827 
4828  virtual SINT64 getSize() = 0 ;
4829 
4830  virtual UINT64 getCreateTime () = 0 ;
4831 
4832  virtual UINT64 getModificationTime() = 0 ;
4833 
4834  virtual INT32 getPiecesInfoNum() = 0 ;
4835 
4836  virtual bson::BSONArray getPiecesInfo() = 0 ;
4837 
4838  virtual BOOLEAN isEof() = 0 ;
4839 
4840  virtual INT32 getRunTimeDetail( bson::BSONObj &detail ) = 0 ;
4841 
4842  } ;
4843 
4847  class DLLEXPORT sdbLob
4848  {
4849  private :
4850  sdbLob ( const sdbLob& ) ; // non construction-copyable
4851  sdbLob& operator= ( const sdbLob& ) ; // non copyable
4852 
4853  public :
4854 
4861  _sdbLob *pLob ;
4865  sdbLob() { pLob = NULL ; }
4866 
4871  {
4872  if ( pLob )
4873  {
4874  delete pLob ;
4875  }
4876  }
4877 
4883  INT32 close ()
4884  {
4885  if ( !pLob )
4886  {
4887  return SDB_OK ;
4888  }
4889  return pLob->close() ;
4890  }
4891 
4900  INT32 read ( UINT32 len, CHAR *buf, UINT32 *read )
4901  {
4902  if ( !pLob )
4903  {
4904  return SDB_NOT_CONNECTED ;
4905  }
4906  return pLob->read( len, buf, read ) ;
4907  }
4908 
4916  INT32 write ( const CHAR *buf, UINT32 len )
4917  {
4918  if ( !pLob )
4919  {
4920  return SDB_NOT_CONNECTED ;
4921  }
4922  return pLob->write( buf, len ) ;
4923  }
4924 
4932  INT32 seek ( SINT64 size, SDB_LOB_SEEK whence )
4933  {
4934  if ( !pLob )
4935  {
4936  return SDB_NOT_CONNECTED ;
4937  }
4938  return pLob->seek( size, whence ) ;
4939  }
4940 
4948  INT32 lock ( INT64 offset, INT64 length )
4949  {
4950  if ( !pLob )
4951  {
4952  return SDB_NOT_CONNECTED ;
4953  }
4954  return pLob->lock( offset, length ) ;
4955  }
4956 
4964  INT32 lockAndSeek ( INT64 offset, INT64 length )
4965  {
4966  if ( !pLob )
4967  {
4968  return SDB_NOT_CONNECTED ;
4969  }
4970  return pLob->lockAndSeek( offset, length ) ;
4971  }
4972 
4980  INT32 isClosed( BOOLEAN &flag )
4981  {
4982  if ( !pLob )
4983  {
4984  return SDB_NOT_CONNECTED ;
4985  }
4986  return pLob->isClosed ( flag ) ;
4987  }
4988 
4993  BOOLEAN isClosed()
4994  {
4995  if ( !pLob )
4996  {
4997  return TRUE ;
4998  }
4999  return pLob->isClosed () ;
5000  }
5001 
5009  INT32 getOid ( bson::OID &oid )
5010  {
5011  if ( !pLob )
5012  {
5013  return SDB_NOT_CONNECTED ;
5014  }
5015  return pLob->getOid( oid ) ;
5016  }
5017 
5022  bson::OID getOid ()
5023  {
5024  if ( !pLob )
5025  {
5026  return bson::OID();
5027  }
5028  return pLob->getOid() ;
5029  }
5030 
5038  INT32 getSize ( SINT64 *size )
5039  {
5040  if ( !pLob )
5041  {
5042  return SDB_NOT_CONNECTED ;
5043  }
5044  return pLob->getSize( size ) ;
5045  }
5046 
5051  SINT64 getSize ()
5052  {
5053  if ( !pLob )
5054  {
5055  return -1 ;
5056  }
5057  return pLob->getSize();
5058  }
5059 
5067  INT32 getCreateTime ( UINT64 *millis )
5068  {
5069  if ( !pLob )
5070  {
5071  return SDB_NOT_CONNECTED ;
5072  }
5073  return pLob->getCreateTime( millis ) ;
5074  }
5075 
5080  UINT64 getCreateTime ()
5081  {
5082  if ( !pLob )
5083  {
5084  return -1 ;
5085  }
5086  return pLob->getCreateTime() ;
5087  }
5088 
5093  UINT64 getModificationTime ()
5094  {
5095  if ( !pLob )
5096  {
5097  return -1 ;
5098  }
5099  return pLob->getModificationTime() ;
5100  }
5101 
5106  INT32 getPiecesInfoNum()
5107  {
5108  if ( !pLob )
5109  {
5110  return -1 ;
5111  }
5112  return pLob->getPiecesInfoNum() ;
5113  }
5114 
5119  bson::BSONArray getPiecesInfo()
5120  {
5121  if ( !pLob )
5122  {
5123  return bson::BSONArray() ;
5124  }
5125  return pLob->getPiecesInfo() ;
5126  }
5127 
5132  BOOLEAN isEof()
5133  {
5134  if ( !pLob )
5135  {
5136  return TRUE ;
5137  }
5138  return pLob->isEof() ;
5139  }
5140 
5146  INT32 getRunTimeDetail( bson::BSONObj &detail )
5147  {
5148  if ( !pLob )
5149  {
5150  return -1 ;
5151  }
5152  return pLob->getRunTimeDetail( detail ) ;
5153  }
5154 
5155  } ;
5156 
5157  class DLLEXPORT _sdbSequence
5158  {
5159  private :
5160  _sdbSequence ( const _sdbSequence& other ) ;
5161  _sdbSequence& operator=( const _sdbSequence& ) ;
5162  public :
5163  _sdbSequence () {}
5164  virtual ~_sdbSequence () {}
5165 
5166  virtual INT32 setAttributes ( const bson::BSONObj &options ) = 0 ;
5167 
5168  virtual INT32 getNextValue ( INT64 &value ) = 0 ;
5169 
5170  virtual INT32 getCurrentValue ( INT64 &value ) = 0 ;
5171 
5172  virtual INT32 setCurrentValue ( const INT64 value ) = 0 ;
5173 
5174  virtual INT32 fetch( const INT32 fetchNum,
5175  INT64 &nextValue,
5176  INT32 &returnNum,
5177  INT32 &Increment ) = 0 ;
5178 
5179  virtual INT32 restart( const INT64 startValue ) = 0 ;
5180  } ;
5181 
5185  class DLLEXPORT sdbSequence
5186  {
5187  private :
5192  sdbSequence ( const sdbSequence& other ) ;
5193 
5199  sdbSequence& operator=( const sdbSequence& ) ;
5200  public :
5207  _sdbSequence *pSequence ;
5208 
5213  {
5214  pSequence = NULL ;
5215  }
5216 
5221  {
5222  if ( pSequence )
5223  {
5224  delete pSequence ;
5225  }
5226  }
5227 
5244  INT32 setAttributes ( const bson::BSONObj & options )
5245  {
5246  if ( NULL == pSequence )
5247  {
5248  return SDB_NOT_CONNECTED ;
5249  }
5250  return pSequence->setAttributes( options ) ;
5251  }
5252 
5259  INT32 getNextValue( INT64 &value )
5260  {
5261  if ( NULL == pSequence )
5262  {
5263  return SDB_NOT_CONNECTED ;
5264  }
5265  return pSequence->getNextValue( value ) ;
5266  }
5267 
5274  INT32 getCurrentValue( INT64 &value )
5275  {
5276  if ( NULL == pSequence )
5277  {
5278  return SDB_NOT_CONNECTED ;
5279  }
5280  return pSequence->getCurrentValue( value ) ;
5281  }
5282 
5289  INT32 setCurrentValue( const INT64 value )
5290  {
5291  if ( NULL == pSequence )
5292  {
5293  return SDB_NOT_CONNECTED ;
5294  }
5295  return pSequence->setCurrentValue( value ) ;
5296  }
5297 
5308  INT32 fetch( const INT32 fetchNum, INT64 &nextValue,
5309  INT32 &returnNum, INT32 &increment )
5310  {
5311  if ( NULL == pSequence )
5312  {
5313  return SDB_NOT_CONNECTED ;
5314  }
5315  return pSequence->fetch( fetchNum, nextValue, returnNum, increment ) ;
5316  }
5317 
5324  INT32 restart( const INT64 startValue )
5325  {
5326  if ( NULL == pSequence )
5327  {
5328  return SDB_NOT_CONNECTED ;
5329  }
5330  return pSequence->restart( startValue ) ;
5331  }
5332  } ;
5333 
5334  class DLLEXPORT _sdbDataSource
5335  {
5336  private:
5337  _sdbDataSource( const _sdbDataSource& other ) ;
5338  _sdbDataSource& operator=( const _sdbDataSource& ) ;
5339  public:
5340  _sdbDataSource() {}
5341  virtual ~_sdbDataSource() {}
5342 
5343  virtual INT32 alterDataSource( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5344  virtual const CHAR *getName() = 0 ;
5345  } ;
5346 
5350  class DLLEXPORT sdbDataSource
5351  {
5352  private:
5353  sdbDataSource( const sdbDataSource& ) ;
5354  sdbDataSource& operator=(const sdbDataSource& ) ;
5355  public:
5356  _sdbDataSource *pDataSource ;
5357 
5358  sdbDataSource()
5359  {
5360  pDataSource = NULL ;
5361  }
5362 
5363  ~sdbDataSource()
5364  {
5365  if ( pDataSource )
5366  {
5367  delete pDataSource ;
5368  }
5369  }
5370 
5411  INT32 alterDataSource( const bson::BSONObj &options )
5412  {
5413  if ( !pDataSource )
5414  {
5415  return SDB_NOT_CONNECTED ;
5416  }
5417  return pDataSource->alterDataSource( options ) ;
5418  }
5419 
5424  const CHAR *getName()
5425  {
5426  if ( !pDataSource )
5427  {
5428  return NULL ;
5429  }
5430  return pDataSource->getName() ;
5431  }
5432  } ;
5433 
5434  class DLLEXPORT _sdb
5435  {
5436  private :
5437  _sdb ( const _sdb& other ) ; // non construction-copyable
5438  _sdb& operator=( const _sdb& ) ; // non copyable
5439  public :
5440  _sdb () {}
5441  virtual ~_sdb () {}
5442  virtual INT32 connect ( const CHAR *pHostName,
5443  UINT16 port
5444  ) = 0 ;
5445  virtual INT32 connect ( const CHAR *pHostName,
5446  UINT16 port,
5447  const CHAR *pUsrName,
5448  const CHAR *pPasswd ) = 0 ;
5449  virtual INT32 connect ( const CHAR *pHostName,
5450  const CHAR *pServiceName ) = 0 ;
5451  virtual INT32 connect ( const CHAR *pHostName,
5452  const CHAR *pServiceName,
5453  const CHAR *pUsrName,
5454  const CHAR *pPasswd ) = 0 ;
5455  virtual INT32 connect ( const CHAR **pConnAddrs,
5456  INT32 arrSize,
5457  const CHAR *pUsrName,
5458  const CHAR *pPasswd ) = 0 ;
5459  virtual INT32 connect ( const CHAR **pConnAddrs,
5460  INT32 arrSize,
5461  const CHAR *pUsrName,
5462  const CHAR *pToken,
5463  const CHAR *pCipherFile ) = 0 ;
5464 
5465  virtual void disconnect () = 0 ;
5466 
5467  virtual UINT64 getDbStartTime() = 0 ;
5468 
5469  virtual const CHAR *getAddress() = 0 ;
5470 
5471  virtual void getVersion( UINT8 &version, UINT8 &subVersion,
5472  UINT8 &fixVersion ) = 0 ;
5473 
5474  virtual INT32 createUsr( const CHAR *pUsrName,
5475  const CHAR *pPasswd,
5476  const bson::BSONObj &options = _sdbStaticObject
5477  ) = 0 ;
5478 
5479  virtual INT32 removeUsr( const CHAR *pUsrName,
5480  const CHAR *pPasswd ) = 0 ;
5481 
5482  virtual INT32 alterUsr( const CHAR *pUsrName,
5483  const CHAR *pAction,
5484  const bson::BSONObj &options ) = 0 ;
5485 
5486  virtual INT32 changeUsrPasswd( const CHAR *pUsrName,
5487  const CHAR *pOldPasswd,
5488  const CHAR *pNewPasswd ) = 0 ;
5489 
5490  virtual INT32 getSnapshot ( _sdbCursor **cursor,
5491  INT32 snapType,
5492  const bson::BSONObj &condition = _sdbStaticObject,
5493  const bson::BSONObj &selector = _sdbStaticObject,
5494  const bson::BSONObj &orderBy = _sdbStaticObject,
5495  const bson::BSONObj &hint = _sdbStaticObject,
5496  INT64 numToSkip = 0,
5497  INT64 numToReturn = -1
5498  ) = 0 ;
5499 
5500  virtual INT32 getSnapshot ( sdbCursor &cursor,
5501  INT32 snapType,
5502  const bson::BSONObj &condition = _sdbStaticObject,
5503  const bson::BSONObj &selector = _sdbStaticObject,
5504  const bson::BSONObj &orderBy = _sdbStaticObject,
5505  const bson::BSONObj &hint = _sdbStaticObject,
5506  INT64 numToSkip = 0,
5507  INT64 numToReturn = -1
5508  ) = 0 ;
5509 
5510  virtual INT32 resetSnapshot ( const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5511 
5512  virtual INT32 getList ( _sdbCursor **cursor,
5513  INT32 listType,
5514  const bson::BSONObj &condition = _sdbStaticObject,
5515  const bson::BSONObj &selector = _sdbStaticObject,
5516  const bson::BSONObj &orderBy = _sdbStaticObject,
5517  const bson::BSONObj &hint = _sdbStaticObject,
5518  INT64 numToSkip = 0,
5519  INT64 numToReturn = -1
5520  ) = 0 ;
5521  virtual INT32 getList ( sdbCursor &cursor,
5522  INT32 listType,
5523  const bson::BSONObj &condition = _sdbStaticObject,
5524  const bson::BSONObj &selector = _sdbStaticObject,
5525  const bson::BSONObj &orderBy = _sdbStaticObject,
5526  const bson::BSONObj &hint = _sdbStaticObject,
5527  INT64 numToSkip = 0,
5528  INT64 numToReturn = -1
5529  ) = 0 ;
5530 
5531  virtual INT32 getCollection ( const CHAR *pCollectionFullName,
5532  _sdbCollection **collection,
5533  BOOLEAN checkExist = TRUE
5534  ) = 0 ;
5535 
5536  virtual INT32 getCollection ( const CHAR *pCollectionFullName,
5537  sdbCollection &collection,
5538  BOOLEAN checkExist = TRUE
5539  ) = 0 ;
5540 
5541  virtual INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
5542  _sdbCollectionSpace **cs,
5543  BOOLEAN checkExist = TRUE
5544  ) = 0 ;
5545 
5546  virtual INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
5547  sdbCollectionSpace &cs,
5548  BOOLEAN checkExist = TRUE
5549  ) = 0 ;
5550 
5551  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5552  INT32 iPageSize,
5553  _sdbCollectionSpace **cs
5554  ) = 0 ;
5555 
5556  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5557  INT32 iPageSize,
5558  sdbCollectionSpace &cs
5559  ) = 0 ;
5560 
5561  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5562  const bson::BSONObj &options,
5563  _sdbCollectionSpace **cs
5564  ) = 0 ;
5565 
5566  virtual INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
5567  const bson::BSONObj &options,
5568  sdbCollectionSpace &cs
5569  ) = 0 ;
5570 
5571  virtual INT32 dropCollectionSpace (
5572  const CHAR *pCollectionSpaceName,
5573  const bson::BSONObj &options = _sdbStaticObject
5574  ) = 0 ;
5575 
5576  virtual INT32 listCollectionSpaces ( _sdbCursor **result ) = 0 ;
5577 
5578  virtual INT32 listCollectionSpaces ( sdbCursor &result ) = 0 ;
5579 
5580  // list all collections in a given database
5581  virtual INT32 listCollections ( _sdbCursor **result ) = 0 ;
5582 
5583  virtual INT32 listCollections ( sdbCursor &result ) = 0 ;
5584 
5585  // list all the replica groups in the given database
5586  virtual INT32 listReplicaGroups ( _sdbCursor **result ) = 0 ;
5587 
5588  virtual INT32 listReplicaGroups ( sdbCursor &result ) = 0 ;
5589 
5590  virtual INT32 getReplicaGroup ( const CHAR *pName,
5591  _sdbReplicaGroup **result ) = 0 ;
5592 
5593  virtual INT32 getReplicaGroup ( const CHAR *pName,
5594  sdbReplicaGroup &result ) = 0 ;
5595 
5596  virtual INT32 getReplicaGroup ( INT32 id,
5597  _sdbReplicaGroup **result ) = 0 ;
5598 
5599  virtual INT32 getReplicaGroup ( INT32 id,
5600  sdbReplicaGroup &result ) = 0 ;
5601 
5602  virtual INT32 createReplicaGroup ( const CHAR *pName,
5603  _sdbReplicaGroup **replicaGroup ) = 0 ;
5604 
5605  virtual INT32 createReplicaGroup ( const CHAR *pName,
5606  sdbReplicaGroup &replicaGroup ) = 0 ;
5607 
5608  virtual INT32 removeReplicaGroup ( const CHAR *pName ) = 0 ;
5609 
5610  virtual INT32 createReplicaCataGroup ( const CHAR *pHostName,
5611  const CHAR *pServiceName,
5612  const CHAR *pDatabasePath,
5613  const bson::BSONObj &configure ) =0 ;
5614 
5615  virtual INT32 activateReplicaGroup ( const CHAR *pName,
5616  _sdbReplicaGroup **replicaGroup ) = 0 ;
5617  virtual INT32 activateReplicaGroup ( const CHAR *pName,
5618  sdbReplicaGroup &replicaGroup ) = 0 ;
5619 
5620  virtual INT32 execUpdate( const CHAR *sql,
5621  bson::BSONObj *pResult = NULL ) = 0 ;
5622 
5623  virtual INT32 exec( const CHAR *sql,
5624  _sdbCursor **result ) = 0 ;
5625 
5626  virtual INT32 exec( const CHAR *sql,
5627  sdbCursor &result ) = 0 ;
5628 
5629  virtual INT32 transactionBegin() = 0 ;
5630 
5631  virtual INT32 transactionCommit( const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
5632 
5633  virtual INT32 transactionRollback() = 0 ;
5634 
5635  virtual INT32 flushConfigure( const bson::BSONObj &options ) = 0 ;
5636  // stored procedure
5637  virtual INT32 crtJSProcedure ( const CHAR *code ) = 0 ;
5638  virtual INT32 rmProcedure( const CHAR *spName ) = 0 ;
5639  virtual INT32 listProcedures( _sdbCursor **cursor, const bson::BSONObj &condition ) = 0 ;
5640  virtual INT32 listProcedures( sdbCursor &cursor, const bson::BSONObj &condition ) = 0 ;
5641  virtual INT32 evalJS( const CHAR *code,
5642  SDB_SPD_RES_TYPE &type,
5643  _sdbCursor **cursor,
5644  bson::BSONObj &errmsg ) = 0 ;
5645  virtual INT32 evalJS( const CHAR *code,
5646  SDB_SPD_RES_TYPE &type,
5647  sdbCursor &cursor,
5648  bson::BSONObj &errmsg ) = 0 ;
5649 
5650  // bakup
5651  virtual INT32 backup ( const bson::BSONObj &options) = 0 ;
5652  virtual INT32 listBackup ( _sdbCursor **cursor,
5653  const bson::BSONObj &options,
5654  const bson::BSONObj &condition = _sdbStaticObject,
5655  const bson::BSONObj &selector = _sdbStaticObject,
5656  const bson::BSONObj &orderBy = _sdbStaticObject) = 0 ;
5657  virtual INT32 listBackup ( sdbCursor &cursor,
5658  const bson::BSONObj &options,
5659  const bson::BSONObj &condition = _sdbStaticObject,
5660  const bson::BSONObj &selector = _sdbStaticObject,
5661  const bson::BSONObj &orderBy = _sdbStaticObject) = 0 ;
5662  virtual INT32 removeBackup ( const bson::BSONObj &options ) = 0 ;
5663 
5664  // task
5665  virtual INT32 listTasks ( _sdbCursor **cursor,
5666  const bson::BSONObj &condition = _sdbStaticObject,
5667  const bson::BSONObj &selector = _sdbStaticObject,
5668  const bson::BSONObj &orderBy = _sdbStaticObject,
5669  const bson::BSONObj &hint = _sdbStaticObject) = 0 ;
5670 
5671 
5672  virtual INT32 listTasks ( sdbCursor &cursor,
5673  const bson::BSONObj &condition = _sdbStaticObject,
5674  const bson::BSONObj &selector = _sdbStaticObject,
5675  const bson::BSONObj &orderBy = _sdbStaticObject,
5676  const bson::BSONObj &hint = _sdbStaticObject) = 0 ;
5677 
5678  virtual INT32 waitTasks ( const SINT64 *taskIDs,
5679  SINT32 num ) = 0 ;
5680 
5681  virtual INT32 cancelTask ( SINT64 taskID,
5682  BOOLEAN isAsync ) = 0 ;
5683  // set session attribute
5684  virtual INT32 setSessionAttr ( const bson::BSONObj &options =
5685  _sdbStaticObject ) = 0 ;
5686  // get session attribute
5687  virtual INT32 getSessionAttr ( bson::BSONObj &result,
5688  BOOLEAN useCache = TRUE ) = 0 ;
5689 
5690  // close all cursor
5691  virtual INT32 closeAllCursors () = 0 ;
5692 
5693  // interrupt
5694  virtual INT32 interrupt() = 0 ;
5695  virtual INT32 interruptOperation() = 0 ;
5696 
5697  // connection is valid
5698  virtual INT32 isValid( BOOLEAN *result ) = 0 ;
5699  virtual BOOLEAN isValid() = 0 ;
5700 
5701  virtual BOOLEAN isClosed() = 0 ;
5702 
5703  // domain
5704  virtual INT32 createDomain ( const CHAR *pDomainName,
5705  const bson::BSONObj &options,
5706  _sdbDomain **domain ) = 0 ;
5707 
5708  virtual INT32 createDomain ( const CHAR *pDomainName,
5709  const bson::BSONObj &options,
5710  sdbDomain &domain ) = 0 ;
5711 
5712  virtual INT32 dropDomain ( const CHAR *pDomainName ) = 0 ;
5713 
5714  virtual INT32 getDomain ( const CHAR *pDomainName,
5715  _sdbDomain **domain ) = 0 ;
5716 
5717  virtual INT32 getDomain ( const CHAR *pDomainName,
5718  sdbDomain &domain ) = 0 ;
5719 
5720  virtual INT32 listDomains ( _sdbCursor **cursor,
5721  const bson::BSONObj &condition = _sdbStaticObject,
5722  const bson::BSONObj &selector = _sdbStaticObject,
5723  const bson::BSONObj &orderBy = _sdbStaticObject,
5724  const bson::BSONObj &hint = _sdbStaticObject
5725  ) = 0 ;
5726 
5727  virtual INT32 listDomains ( sdbCursor &cursor,
5728  const bson::BSONObj &condition = _sdbStaticObject,
5729  const bson::BSONObj &selector = _sdbStaticObject,
5730  const bson::BSONObj &orderBy = _sdbStaticObject,
5731  const bson::BSONObj &hint = _sdbStaticObject
5732  ) = 0 ;
5733  virtual INT32 getDC( _sdbDataCenter **dc ) = 0 ;
5734  virtual INT32 getDC( sdbDataCenter &dc ) = 0 ;
5735 
5736  virtual INT32 getRecycleBin( _sdbRecycleBin **recycleBin ) = 0 ;
5737  virtual INT32 getRecycleBin( sdbRecycleBin &recycleBin ) = 0 ;
5738 
5739  static _sdb *getObj ( BOOLEAN useSSL = FALSE ) ;
5740 
5741  // get last alive time
5742  virtual UINT64 getLastAliveTime() const = 0 ;
5743 
5744  virtual INT32 syncDB(
5745  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5746 
5747  virtual INT32 analyze(
5748  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5749 
5750  virtual INT32 forceSession(
5751  SINT64 sessionID,
5752  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5753 
5754  virtual INT32 forceStepUp(
5755  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5756 
5757  virtual INT32 invalidateCache(
5758  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5759 
5760  virtual INT32 reloadConfig(
5761  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5762 
5763  virtual INT32 updateConfig ( const bson::BSONObj &configs = _sdbStaticObject,
5764  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5765 
5766  virtual INT32 deleteConfig ( const bson::BSONObj &configs = _sdbStaticObject,
5767  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5768 
5769  virtual INT32 setPDLevel( INT32 level,
5770  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5771 
5772  virtual INT32 msg( const CHAR* msg ) = 0 ;
5773 
5774  virtual INT32 loadCS( const CHAR* csName,
5775  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5776 
5777  virtual INT32 unloadCS( const CHAR* csName,
5778  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5779 
5780  virtual INT32 traceStart( UINT32 traceBufferSize,
5781  const CHAR* component = NULL,
5782  const CHAR* breakpoint = NULL,
5783  const vector<UINT32> &tidVec = _sdbStaticUINT32Vec ) = 0 ;
5784 
5785  virtual INT32 traceStart( UINT32 traceBufferSize,
5786  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5787 
5788  virtual INT32 traceStop( const CHAR* dumpFileName ) = 0 ;
5789 
5790  virtual INT32 traceResume() = 0 ;
5791 
5792  virtual INT32 traceStatus( _sdbCursor** cursor ) = 0 ;
5793 
5794  virtual INT32 traceStatus( sdbCursor& cursor ) = 0 ;
5795 
5796 
5797  virtual INT32 renameCollectionSpace( const CHAR* oldName,
5798  const CHAR* newName,
5799  const bson::BSONObj &options = _sdbStaticObject ) = 0 ;
5800 
5801  virtual INT32 getLastErrorObj( bson::BSONObj &result ) = 0 ;
5802  virtual void cleanLastErrorObj() = 0 ;
5803 
5804  virtual INT32 getLastResultObj( bson::BSONObj &result,
5805  BOOLEAN getOwned = FALSE ) const = 0 ;
5806 
5807  // create a new sequence object
5808  virtual INT32 createSequence( const CHAR *pSequenceName,
5809  const bson::BSONObj &options,
5810  _sdbSequence **sequence ) = 0 ;
5811 
5812  virtual INT32 createSequence( const CHAR *pSequenceName,
5813  const bson::BSONObj &options,
5814  sdbSequence &sequence ) = 0 ;
5815 
5816  virtual INT32 createSequence( const CHAR *pSequenceName,
5817  sdbSequence &sequence ) = 0 ;
5818 
5819  // get a sequence object
5820  virtual INT32 getSequence( const CHAR *pSequenceName,
5821  _sdbSequence **sequence ) = 0 ;
5822 
5823  virtual INT32 getSequence( const CHAR *pSequenceName,
5824  sdbSequence &sequence ) = 0 ;
5825 
5826  virtual INT32 renameSequence( const CHAR *pOldName,
5827  const CHAR *pNewName ) = 0 ;
5828 
5829  virtual INT32 dropSequence( const CHAR *pSequenceName ) = 0 ;
5830 
5831  virtual INT32 createDataSource( _sdbDataSource **dataSource,
5832  const CHAR *pDataSourceName,
5833  const CHAR *addresses,
5834  const CHAR *user = NULL,
5835  const CHAR *password = NULL,
5836  const CHAR *type = NULL,
5837  const bson::BSONObj *options = NULL
5838  ) = 0 ;
5839 
5840  virtual INT32 dropDataSource( const CHAR *pDataSourceName ) = 0 ;
5841 
5842  virtual INT32 getDataSource( const CHAR *pDataSourceName,
5843  _sdbDataSource **dataSource ) = 0 ;
5844 
5845  virtual INT32 listDataSources( _sdbCursor** cursor,
5846  const bson::BSONObj &condition = _sdbStaticObject,
5847  const bson::BSONObj &selector = _sdbStaticObject,
5848  const bson::BSONObj &orderBy = _sdbStaticObject,
5849  const bson::BSONObj &hint = _sdbStaticObject ) = 0 ;
5850  } ;
5853  typedef class _sdb _sdb ;
5857  class DLLEXPORT sdb
5858  {
5859  private:
5860  sdb ( const sdb& other ) ;
5861  sdb& operator=( const sdb& ) ;
5862  public :
5869  _sdb *pSDB ;
5870 
5875  sdb ( BOOLEAN useSSL = FALSE ) :
5876  pSDB ( _sdb::getObj( useSSL ) )
5877  {
5878  }
5879 
5883  ~sdb ()
5884  {
5885  if ( pSDB )
5886  {
5887  delete pSDB ;
5888  }
5889  }
5890 
5900  INT32 connect ( const CHAR *pHostName,
5901  UINT16 port
5902  )
5903  {
5904  if ( !pSDB )
5905  {
5906  return SDB_NOT_CONNECTED ;
5907  }
5908  return pSDB->connect ( pHostName, port ) ;
5909  }
5910 
5924  INT32 connect ( const CHAR *pHostName,
5925  UINT16 port,
5926  const CHAR *pUsrName,
5927  const CHAR *pPasswd
5928  )
5929  {
5930  if ( !pSDB )
5931  {
5932  return SDB_NOT_CONNECTED ;
5933  }
5934  return pSDB->connect ( pHostName, port,
5935  pUsrName, pPasswd ) ;
5936  }
5937 
5947  INT32 connect ( const CHAR *pHostName,
5948  const CHAR *pServiceName
5949  )
5950  {
5951  if ( !pSDB )
5952  {
5953  return SDB_NOT_CONNECTED ;
5954  }
5955  return pSDB->connect ( pHostName, pServiceName ) ;
5956  }
5957 
5971  INT32 connect ( const CHAR *pHostName,
5972  const CHAR *pServiceName,
5973  const CHAR *pUsrName,
5974  const CHAR *pPasswd )
5975  {
5976  if ( !pSDB )
5977  {
5978  return SDB_NOT_CONNECTED ;
5979  }
5980  return pSDB->connect ( pHostName, pServiceName,
5981  pUsrName, pPasswd ) ;
5982  }
5983 
5997  INT32 connect ( const CHAR **pConnAddrs,
5998  INT32 arrSize,
5999  const CHAR *pUsrName,
6000  const CHAR *pPasswd )
6001  {
6002  if ( !pSDB )
6003  {
6004  return SDB_NOT_CONNECTED ;
6005  }
6006  return pSDB->connect ( pConnAddrs, arrSize,
6007  pUsrName, pPasswd ) ;
6008  }
6009 
6025  INT32 connect ( const CHAR **pConnAddrs,
6026  INT32 arrSize,
6027  const CHAR *pUsrName,
6028  const CHAR *pToken,
6029  const CHAR *pCipherFile )
6030  {
6031  if ( !pSDB )
6032  {
6033  return SDB_NOT_CONNECTED ;
6034  }
6035  return pSDB->connect ( pConnAddrs, arrSize,
6036  pUsrName, pToken, pCipherFile ) ;
6037  }
6038 
6043  UINT64 getDbStartTime ()
6044  {
6045  if ( !pSDB )
6046  {
6047  return -1 ;
6048  }
6049  return pSDB->getDbStartTime() ;
6050  }
6051 
6056  const CHAR *getAddress ()
6057  {
6058  if ( !pSDB )
6059  {
6060  return NULL ;
6061  }
6062  return pSDB->getAddress () ;
6063  }
6064 
6065 
6075  void getVersion ( UINT8 &version, UINT8 &subVersion, UINT8 &fixVersion )
6076  {
6077  if ( !pSDB )
6078  {
6079  return ;
6080  }
6081  pSDB->getVersion( version, subVersion, fixVersion ) ;
6082  }
6083 
6106  INT32 createUsr( const CHAR *pUsrName,
6107  const CHAR *pPasswd,
6108  const bson::BSONObj &options = _sdbStaticObject )
6109  {
6110  if ( !pSDB )
6111  {
6112  return SDB_NOT_CONNECTED ;
6113  }
6114  return pSDB->createUsr( pUsrName, pPasswd, options ) ;
6115  }
6116 
6125  INT32 removeUsr( const CHAR *pUsrName,
6126  const CHAR *pPasswd )
6127  {
6128  if ( !pSDB )
6129  {
6130  return SDB_NOT_CONNECTED ;
6131  }
6132  return pSDB->removeUsr( pUsrName, pPasswd ) ;
6133  }
6134 
6147  INT32 alterUsr( const CHAR *pUsrName,
6148  const CHAR *pAction,
6149  const bson::BSONObj &options )
6150  {
6151  if ( !pSDB )
6152  {
6153  return SDB_NOT_CONNECTED ;
6154  }
6155  return pSDB->alterUsr( pUsrName, pAction, options ) ;
6156  }
6157 
6168  INT32 changeUsrPasswd( const CHAR *pUsrName,
6169  const CHAR *pOldPasswd,
6170  const CHAR *pNewPasswd )
6171  {
6172  if ( !pSDB )
6173  {
6174  return SDB_NOT_CONNECTED ;
6175  }
6176  return pSDB->changeUsrPasswd( pUsrName, pOldPasswd, pNewPasswd ) ;
6177  }
6178 
6182  void disconnect ()
6183  {
6184  if ( !pSDB )
6185  {
6186  return ;
6187  }
6188  pSDB->disconnect () ;
6189  }
6190 
6232  INT32 getSnapshot ( sdbCursor &cursor,
6233  INT32 snapType,
6234  const bson::BSONObj &condition = _sdbStaticObject,
6235  const bson::BSONObj &selector = _sdbStaticObject,
6236  const bson::BSONObj &orderBy = _sdbStaticObject,
6237  const bson::BSONObj &hint = _sdbStaticObject,
6238  INT64 numToSkip = 0,
6239  INT64 numToReturn = -1 )
6240  {
6241  if ( !pSDB )
6242  {
6243  return SDB_NOT_CONNECTED ;
6244  }
6245  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6246  return pSDB->getSnapshot ( cursor, snapType, condition,
6247  selector, orderBy, hint,
6248  numToSkip, numToReturn ) ;
6249  }
6250 
6251  /* \fn INT32 getSnapshot ( _sdbCursor **cursor,
6252  INT32 snapType,
6253  const bson::BSONObj &condition,
6254  const bson::BSONObj &selector,
6255  const bson::BSONObj &orderBy,
6256  const bson::BSONObj &hint,
6257  INT64 numToSkip,
6258  INT64 numToReturn
6259  )
6260  \brief Get the snapshots of specified type.
6261  \param [in] snapType The snapshot type as below
6262 
6263  SDB_SNAP_CONTEXTS : Get the snapshot of all the contexts
6264  SDB_SNAP_CONTEXTS_CURRENT : Get the snapshot of current context
6265  SDB_SNAP_SESSIONS : Get the snapshot of all the sessions
6266  SDB_SNAP_SESSIONS_CURRENT : Get the snapshot of current session
6267  SDB_SNAP_COLLECTIONS : Get the snapshot of all the collections
6268  SDB_SNAP_COLLECTIONSPACES : Get the snapshot of all the collection spaces
6269  SDB_SNAP_DATABASE : Get the snapshot of the database
6270  SDB_SNAP_SYSTEM : Get the snapshot of the system
6271  SDB_SNAP_CATALOG : Get the snapshot of the catalog
6272  SDB_SNAP_TRANSACTIONS : Get snapshot of transactions in current session
6273  SDB_SNAP_TRANSACTIONS_CURRENT : Get snapshot of all the transactions
6274  SDB_SNAP_ACCESSPLANS : Get the snapshot of cached access plans
6275  SDB_SNAP_HEALTH : Get snapshot of node health detection
6276  SDB_SNAP_CONFIGS : Get snapshot of node configurations
6277  SDB_SNAP_SVCTASKS : Get snapshot of service task
6278  SDB_SNAP_SEQUENCES : Get the snapshot of sequences
6279  SDB_SNAP_INDEXSTATS : Get the snapshot of index statistics
6280  SDB_SNAP_RECYCLEBIN : Get the snapshot of items in recycle bin
6281 
6282  \param [in] condition The matching rule, match all the documents if not provided.
6283  \param [in] select The selective rule, return the whole document if not provided.
6284  \param [in] orderBy The ordered rule, result set is unordered if not provided.
6285  \param [in] hint The options provided for specific snapshot type.
6286  format:{ '$Options': { <options> } }
6287  \param [in] numToSkip Skip the first numToSkip documents, default is 0
6288  \param [in] numToReturn Only return numToReturn documents, default is -1 for returning all results
6289  \param [out] cursor The return cursor handle of query.
6290  \retval SDB_OK Operation Success
6291  \retval Others Operation Fail
6292  */
6293  INT32 getSnapshot ( _sdbCursor **cursor,
6294  INT32 snapType,
6295  const bson::BSONObj &condition = _sdbStaticObject,
6296  const bson::BSONObj &selector = _sdbStaticObject,
6297  const bson::BSONObj &orderBy = _sdbStaticObject,
6298  const bson::BSONObj &hint = _sdbStaticObject,
6299  INT64 numToSkip = 0,
6300  INT64 numToReturn = -1 )
6301  {
6302  if ( !pSDB )
6303  {
6304  return SDB_NOT_CONNECTED ;
6305  }
6306  return pSDB->getSnapshot ( cursor, snapType, condition,
6307  selector, orderBy, hint,
6308  numToSkip, numToReturn ) ;
6309  }
6310 
6333  INT32 resetSnapshot ( const bson::BSONObj &options = _sdbStaticObject )
6334  {
6335  if ( !pSDB )
6336  {
6337  return SDB_NOT_CONNECTED ;
6338  }
6339  return pSDB->resetSnapshot ( options ) ;
6340  }
6341 
6342  INT32 getList ( _sdbCursor **cursor,
6343  INT32 listType,
6344  const bson::BSONObj &condition = _sdbStaticObject,
6345  const bson::BSONObj &selector = _sdbStaticObject,
6346  const bson::BSONObj &orderBy = _sdbStaticObject,
6347  const bson::BSONObj &hint = _sdbStaticObject,
6348  INT64 numToSkip = 0,
6349  INT64 numToReturn = -1
6350  )
6351  {
6352  if ( !pSDB )
6353  {
6354  return SDB_NOT_CONNECTED ;
6355  }
6356  return pSDB->getList ( cursor, listType,
6357  condition, selector, orderBy, hint,
6358  numToSkip, numToReturn ) ;
6359  }
6360 
6403  INT32 getList ( sdbCursor &cursor,
6404  INT32 listType,
6405  const bson::BSONObj &condition = _sdbStaticObject,
6406  const bson::BSONObj &selector = _sdbStaticObject,
6407  const bson::BSONObj &orderBy = _sdbStaticObject,
6408  const bson::BSONObj &hint = _sdbStaticObject,
6409  INT64 numToSkip = 0,
6410  INT64 numToReturn = -1
6411  )
6412  {
6413  if ( !pSDB )
6414  {
6415  return SDB_NOT_CONNECTED ;
6416  }
6417  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6418  return pSDB->getList ( cursor, listType,
6419  condition, selector, orderBy, hint,
6420  numToSkip, numToReturn ) ;
6421  }
6422 
6423  INT32 getCollection ( const CHAR *pCollectionFullName,
6424  _sdbCollection **collection,
6425  BOOLEAN checkExist = TRUE
6426  )
6427  {
6428  if ( !pSDB )
6429  {
6430  return SDB_NOT_CONNECTED ;
6431  }
6432  return pSDB->getCollection ( pCollectionFullName,
6433  collection, checkExist ) ;
6434  }
6435 
6446  INT32 getCollection ( const CHAR *pCollectionFullName,
6447  sdbCollection &collection,
6448  BOOLEAN checkExist = TRUE
6449  )
6450  {
6451  if ( !pSDB )
6452  {
6453  return SDB_NOT_CONNECTED ;
6454  }
6455  RELEASE_INNER_HANDLE( collection.pCollection ) ;
6456  return pSDB->getCollection ( pCollectionFullName,
6457  collection,
6458  checkExist ) ;
6459  }
6460 
6461  INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
6462  _sdbCollectionSpace **cs,
6463  BOOLEAN checkExist = TRUE
6464  )
6465  {
6466  if ( !pSDB )
6467  {
6468  return SDB_NOT_CONNECTED ;
6469  }
6470  return pSDB->getCollectionSpace ( pCollectionSpaceName,
6471  cs, checkExist ) ;
6472  }
6473 
6484  INT32 getCollectionSpace ( const CHAR *pCollectionSpaceName,
6485  sdbCollectionSpace &cs,
6486  BOOLEAN checkExist = TRUE
6487  )
6488  {
6489  if ( !pSDB )
6490  {
6491  return SDB_NOT_CONNECTED ;
6492  }
6494  return pSDB->getCollectionSpace ( pCollectionSpaceName,
6495  cs, checkExist ) ;
6496  }
6497 
6498  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6499  INT32 iPageSize,
6500  _sdbCollectionSpace **cs
6501  )
6502  {
6503  if ( !pSDB )
6504  {
6505  return SDB_NOT_CONNECTED ;
6506  }
6507  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6508  iPageSize,
6509  cs ) ;
6510  }
6511 
6530  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6531  INT32 iPageSize,
6532  sdbCollectionSpace &cs
6533  )
6534  {
6535  if ( !pSDB )
6536  {
6537  return SDB_NOT_CONNECTED ;
6538  }
6540  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6541  iPageSize, cs ) ;
6542  }
6543 
6544  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6545  const bson::BSONObj &options,
6546  _sdbCollectionSpace **cs
6547  )
6548  {
6549  if ( !pSDB )
6550  {
6551  return SDB_NOT_CONNECTED ;
6552  }
6553  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6554  options, cs ) ;
6555  }
6556 
6574  INT32 createCollectionSpace ( const CHAR *pCollectionSpaceName,
6575  const bson::BSONObj &options,
6576  sdbCollectionSpace &cs
6577  )
6578  {
6579  if ( !pSDB )
6580  {
6581  return SDB_NOT_CONNECTED ;
6582  }
6584  return pSDB->createCollectionSpace ( pCollectionSpaceName,
6585  options, cs ) ;
6586  }
6587 
6596  INT32 dropCollectionSpace (
6597  const CHAR *pCollectionSpaceName,
6598  const bson::BSONObj &options = _sdbStaticObject )
6599  {
6600  if ( !pSDB )
6601  {
6602  return SDB_NOT_CONNECTED ;
6603  }
6604 
6605  return pSDB->dropCollectionSpace ( pCollectionSpaceName, options ) ;
6606  }
6607 
6608  INT32 listCollectionSpaces ( _sdbCursor **result )
6609  {
6610  if ( !pSDB )
6611  {
6612  return SDB_NOT_CONNECTED ;
6613  }
6614  return pSDB->listCollectionSpaces ( result ) ;
6615  }
6616 
6623  INT32 listCollectionSpaces ( sdbCursor &cursor )
6624  {
6625  if ( !pSDB )
6626  {
6627  return SDB_NOT_CONNECTED ;
6628  }
6629  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6630  return pSDB->listCollectionSpaces ( cursor ) ;
6631  }
6632 
6633  /* \fn INT32 listCollections ( _sdbCursor **result )
6634  \brief list all collections in current database.
6635  \param [out] result The return cursor handle of query.
6636  \retval SDB_OK Operation Success
6637  \retval Others Operation Fail
6638  */
6639  INT32 listCollections ( _sdbCursor **result )
6640  {
6641  if ( !pSDB )
6642  {
6643  return SDB_NOT_CONNECTED ;
6644  }
6645  return pSDB->listCollections ( result ) ;
6646  }
6647 
6654  INT32 listCollections ( sdbCursor &cursor )
6655  {
6656  if ( !pSDB )
6657  {
6658  return SDB_NOT_CONNECTED ;
6659  }
6660  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6661  return pSDB->listCollections ( cursor ) ;
6662  }
6663 
6664  /* \fn INT32 listReplicaGroups ( _sdbCursor **result )
6665  \brief List all replica groups of current database.
6666  \param [out] result The return cursor handle of query.
6667  \retval SDB_OK Operation Success
6668  \retval Others Operation Fail
6669  */
6670  INT32 listReplicaGroups ( _sdbCursor **result )
6671  {
6672  if ( !pSDB )
6673  {
6674  return SDB_NOT_CONNECTED ;
6675  }
6676  return pSDB->listReplicaGroups ( result ) ;
6677  }
6678 
6679 
6686  INT32 listReplicaGroups ( sdbCursor &cursor )
6687  {
6688  if ( !pSDB )
6689  {
6690  return SDB_NOT_CONNECTED ;
6691  }
6692  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6693  return pSDB->listReplicaGroups ( cursor ) ;
6694  }
6695 
6696  /* \fn INT32 getReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **result )
6697  \brief Get the specified replica group.
6698  \param [in] pName The name of replica group.
6699  \param [out] result The sdbReplicaGroup object.
6700  \retval SDB_OK Operation Success
6701  \retval Others Operation Fail
6702  */
6703  INT32 getReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **result )
6704  {
6705  if ( !pSDB )
6706  {
6707  return SDB_NOT_CONNECTED ;
6708  }
6709  return pSDB->getReplicaGroup ( pName, result ) ;
6710  }
6711 
6712 
6720  INT32 getReplicaGroup ( const CHAR *pName, sdbReplicaGroup &group )
6721  {
6722  if ( !pSDB )
6723  {
6724  return SDB_NOT_CONNECTED ;
6725  }
6727  return pSDB->getReplicaGroup ( pName, group ) ;
6728  }
6729 
6730  /* \fn INT32 getReplicaGroup ( INT32 id, _sdbReplicaGroup **result )
6731  \brief Get the specified replica group.
6732  \param [in] id The id of replica group.
6733  \param [out] result The _sdbReplicaGroup object.
6734  \retval SDB_OK Operation Success
6735  \retval Others Operation Fail
6736  */
6737  INT32 getReplicaGroup ( INT32 id, _sdbReplicaGroup **result )
6738  {
6739  if ( !pSDB )
6740  {
6741  return SDB_NOT_CONNECTED ;
6742  }
6743  return pSDB->getReplicaGroup ( id, result ) ;
6744  }
6745 
6753  INT32 getReplicaGroup ( INT32 id, sdbReplicaGroup &group )
6754  {
6755  if ( !pSDB )
6756  {
6757  return SDB_NOT_CONNECTED ;
6758  }
6760  return pSDB->getReplicaGroup ( id, group ) ;
6761  }
6762 
6763  /* \fn INT32 createReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
6764  \brief Create the specified replica group.
6765  \param [in] pName The name of the replica group.
6766  \param [out] replicaGroup The return _sdbReplicaGroup object.
6767  \retval SDB_OK Operation Success
6768  \retval Others Operation Fail
6769  */
6770  INT32 createReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
6771  {
6772  if ( !pSDB )
6773  {
6774  return SDB_NOT_CONNECTED ;
6775  }
6776  return pSDB->createReplicaGroup ( pName, replicaGroup ) ;
6777  }
6778 
6786  INT32 createReplicaGroup ( const CHAR *pName, sdbReplicaGroup &group )
6787  {
6788  if ( !pSDB )
6789  {
6790  return SDB_NOT_CONNECTED ;
6791  }
6793  return pSDB->createReplicaGroup ( pName, group ) ;
6794  }
6795 
6802  INT32 removeReplicaGroup ( const CHAR *pName )
6803  {
6804  if ( !pSDB )
6805  {
6806  return SDB_NOT_CONNECTED ;
6807  }
6808  return pSDB->removeReplicaGroup ( pName ) ;
6809  }
6810 
6823  INT32 createReplicaCataGroup ( const CHAR *pHostName,
6824  const CHAR *pServiceName,
6825  const CHAR *pDatabasePath,
6826  const bson::BSONObj &configure )
6827  {
6828  if ( !pSDB )
6829  {
6830  return SDB_NOT_CONNECTED ;
6831  }
6832  return pSDB->createReplicaCataGroup ( pHostName, pServiceName,
6833  pDatabasePath, configure ) ;
6834  }
6835 
6836  INT32 activateReplicaGroup ( const CHAR *pName, _sdbReplicaGroup **replicaGroup )
6837  {
6838  if ( !pSDB )
6839  {
6840  return SDB_NOT_CONNECTED ;
6841  }
6842  return pSDB->activateReplicaGroup ( pName, replicaGroup ) ;
6843  }
6844 
6852  INT32 activateReplicaGroup ( const CHAR *pName, sdbReplicaGroup &replicaGroup )
6853  {
6854  if ( !pSDB )
6855  {
6856  return SDB_NOT_CONNECTED ;
6857  }
6858  RELEASE_INNER_HANDLE( replicaGroup.pReplicaGroup ) ;
6859  return pSDB->activateReplicaGroup ( pName, replicaGroup ) ;
6860  }
6861 
6869  INT32 execUpdate( const CHAR *sql, bson::BSONObj *pResult = NULL )
6870  {
6871  if ( !pSDB )
6872  {
6873  return SDB_NOT_CONNECTED ;
6874  }
6875  return pSDB->execUpdate( sql, pResult ) ;
6876  }
6877 
6878  /* \fn INT32 exec( const CHAR *sql,
6879  _sdbCursor **result )
6880  \brief Executing SQL command.
6881  \param [in] sql The SQL command.
6882  \param [out] result The return cursor handle of matching documents.
6883  \retval SDB_OK Operation Success
6884  \retval Others Operation Fail
6885  */
6886  INT32 exec( const CHAR *sql,
6887  _sdbCursor **result )
6888  {
6889  if ( !pSDB )
6890  {
6891  return SDB_NOT_CONNECTED ;
6892  }
6893  return pSDB->exec( sql, result ) ;
6894  }
6895 
6904  INT32 exec( const CHAR *sql,
6905  sdbCursor &cursor )
6906  {
6907  if ( !pSDB )
6908  {
6909  return SDB_NOT_CONNECTED ;
6910  }
6911  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
6912  return pSDB->exec( sql, cursor ) ;
6913  }
6914 
6920  INT32 transactionBegin()
6921  {
6922  if ( !pSDB )
6923  {
6924  return SDB_NOT_CONNECTED ;
6925  }
6926  return pSDB->transactionBegin() ;
6927  }
6928 
6936  INT32 transactionCommit( const bson::BSONObj &hint = _sdbStaticObject )
6937  {
6938  if ( !pSDB )
6939  {
6940  return SDB_NOT_CONNECTED ;
6941  }
6942  return pSDB->transactionCommit( hint ) ;
6943  }
6944 
6950  INT32 transactionRollback()
6951  {
6952  if ( !pSDB )
6953  {
6954  return SDB_NOT_CONNECTED ;
6955  }
6956  return pSDB->transactionRollback() ;
6957  }
6967  INT32 flushConfigure( const bson::BSONObj &options )
6968  {
6969  if ( !pSDB )
6970  {
6971  return SDB_NOT_CONNECTED ;
6972  }
6973  return pSDB->flushConfigure( options ) ;
6974  }
6975 
6982  INT32 crtJSProcedure ( const CHAR *code )
6983  {
6984  if ( !pSDB )
6985  {
6986  return SDB_NOT_CONNECTED ;
6987  }
6988  return pSDB->crtJSProcedure( code ) ;
6989  }
6990 
6997  INT32 rmProcedure( const CHAR *spName )
6998  {
6999  if ( !pSDB )
7000  {
7001  return SDB_NOT_CONNECTED ;
7002  }
7003  return pSDB->rmProcedure( spName ) ;
7004  }
7005 
7006  INT32 listProcedures( _sdbCursor **cursor, const bson::BSONObj &condition )
7007  {
7008  if ( !pSDB )
7009  {
7010  return SDB_NOT_CONNECTED ;
7011  }
7012  return pSDB->listProcedures( cursor, condition ) ;
7013  }
7014 
7022  INT32 listProcedures( sdbCursor &cursor, const bson::BSONObj &condition )
7023  {
7024  if ( !pSDB )
7025  {
7026  return SDB_NOT_CONNECTED ;
7027  }
7028  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7029  return pSDB->listProcedures( cursor, condition ) ;
7030  }
7031 
7032  INT32 evalJS( const CHAR *code,
7033  SDB_SPD_RES_TYPE &type,
7034  _sdbCursor **cursor,
7035  bson::BSONObj &errmsg )
7036  {
7037  if ( !pSDB )
7038  {
7039  return SDB_NOT_CONNECTED ;
7040  }
7041  return pSDB->evalJS( code, type, cursor, errmsg ) ;
7042  }
7043 
7056  INT32 evalJS( const CHAR *code, SDB_SPD_RES_TYPE &type,
7057  sdbCursor &cursor,
7058  bson::BSONObj &errmsg )
7059  {
7060  if ( !pSDB )
7061  {
7062  return SDB_NOT_CONNECTED ;
7063  }
7064  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7065  return pSDB->evalJS( code, type, cursor, errmsg ) ;
7066  }
7067 
7087  INT32 backupOffline ( const bson::BSONObj &options)
7088  {
7089  return backup( options ) ;
7090  }
7091 
7110  INT32 backup ( const bson::BSONObj &options)
7111  {
7112  if ( !pSDB )
7113  {
7114  return SDB_NOT_CONNECTED ;
7115  }
7116  return pSDB->backup( options ) ;
7117  }
7118 
7119 
7120  INT32 listBackup ( _sdbCursor **cursor,
7121  const bson::BSONObj &options,
7122  const bson::BSONObj &condition = _sdbStaticObject,
7123  const bson::BSONObj &selector = _sdbStaticObject,
7124  const bson::BSONObj &orderBy = _sdbStaticObject)
7125  {
7126  if ( !pSDB )
7127  {
7128  return SDB_NOT_CONNECTED ;
7129  }
7130  return pSDB->listBackup( cursor, options, condition, selector, orderBy ) ;
7131  }
7132 
7155  INT32 listBackup ( sdbCursor &cursor,
7156  const bson::BSONObj &options,
7157  const bson::BSONObj &condition = _sdbStaticObject,
7158  const bson::BSONObj &selector = _sdbStaticObject,
7159  const bson::BSONObj &orderBy = _sdbStaticObject)
7160  {
7161  if ( !pSDB )
7162  {
7163  return SDB_NOT_CONNECTED ;
7164  }
7165  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7166  return pSDB->listBackup( cursor, options, condition, selector, orderBy ) ;
7167  }
7168 
7183  INT32 removeBackup ( const bson::BSONObj &options)
7184  {
7185  if ( !pSDB )
7186  {
7187  return SDB_NOT_CONNECTED ;
7188  }
7189  return pSDB->removeBackup( options ) ;
7190  }
7191 
7192  INT32 listTasks ( _sdbCursor **cursor,
7193  const bson::BSONObj &condition = _sdbStaticObject,
7194  const bson::BSONObj &selector = _sdbStaticObject,
7195  const bson::BSONObj &orderBy = _sdbStaticObject,
7196  const bson::BSONObj &hint = _sdbStaticObject)
7197  {
7198  if ( !pSDB )
7199  {
7200  return SDB_NOT_CONNECTED ;
7201  }
7202  return pSDB->listTasks ( cursor,
7203  condition,
7204  selector,
7205  orderBy,
7206  hint ) ;
7207  }
7225  INT32 listTasks ( sdbCursor &cursor,
7226  const bson::BSONObj &condition = _sdbStaticObject,
7227  const bson::BSONObj &selector = _sdbStaticObject,
7228  const bson::BSONObj &orderBy = _sdbStaticObject,
7229  const bson::BSONObj &hint = _sdbStaticObject)
7230  {
7231  if ( !pSDB )
7232  {
7233  return SDB_NOT_CONNECTED ;
7234  }
7235  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7236  return pSDB->listTasks ( cursor,
7237  condition,
7238  selector,
7239  orderBy,
7240  hint ) ;
7241  }
7242 
7251  INT32 waitTasks ( const SINT64 *taskIDs,
7252  SINT32 num )
7253  {
7254  if ( !pSDB )
7255  {
7256  return SDB_NOT_CONNECTED ;
7257  }
7258  return pSDB->waitTasks ( taskIDs,
7259  num ) ;
7260  }
7261 
7271  INT32 cancelTask ( SINT64 taskID,
7272  BOOLEAN isAsync )
7273  {
7274  if ( !pSDB )
7275  {
7276  return SDB_NOT_CONNECTED ;
7277  }
7278  return pSDB->cancelTask ( taskID,
7279  isAsync ) ;
7280  }
7281 
7292  INT32 setSessionAttr ( const bson::BSONObj &options = _sdbStaticObject )
7293  {
7294  if ( !pSDB )
7295  {
7296  return SDB_NOT_CONNECTED ;
7297  }
7298  return pSDB->setSessionAttr ( options ) ;
7299  }
7300 
7309  INT32 getSessionAttr ( bson::BSONObj & result,
7310  BOOLEAN useCache = TRUE )
7311  {
7312  if ( !pSDB )
7313  {
7314  return SDB_NOT_CONNECTED ;
7315  }
7316  return pSDB->getSessionAttr( result, useCache ) ;
7317  }
7318 
7325  INT32 closeAllCursors ()
7326  {
7327  return interrupt() ;
7328  }
7329 
7336  INT32 interrupt()
7337  {
7338  if ( !pSDB )
7339  {
7340  return SDB_NOT_CONNECTED ;
7341  }
7342  return pSDB->interrupt () ;
7343  }
7344 
7353  INT32 interruptOperation()
7354  {
7355  if ( !pSDB )
7356  {
7357  return SDB_NOT_CONNECTED ;
7358  }
7359  return pSDB->interruptOperation () ;
7360  }
7361 
7369  INT32 isValid ( BOOLEAN *result )
7370  {
7371  if ( !pSDB )
7372  {
7373  return SDB_NOT_CONNECTED ;
7374  }
7375  return pSDB->isValid ( result ) ;
7376  }
7377 
7382  BOOLEAN isValid ()
7383  {
7384  if ( !pSDB )
7385  {
7386  return FALSE ;
7387  }
7388  return pSDB->isValid () ;
7389  }
7390 
7395  BOOLEAN isClosed()
7396  {
7397  if (!pSDB)
7398  {
7399  return TRUE ;
7400  }
7401  return pSDB->isClosed() ;
7402  }
7403 
7422  INT32 createDomain ( const CHAR *pDomainName,
7423  const bson::BSONObj &options,
7424  sdbDomain &domain )
7425  {
7426  if ( !pSDB )
7427  {
7428  return SDB_NOT_CONNECTED ;
7429  }
7430  RELEASE_INNER_HANDLE( domain.pDomain ) ;
7431  return pSDB->createDomain ( pDomainName, options, domain ) ;
7432  }
7433 
7434  INT32 createDomain ( const CHAR *pDomainName,
7435  const bson::BSONObj &options,
7436  _sdbDomain **domain )
7437  {
7438  if ( !pSDB )
7439  {
7440  return SDB_NOT_CONNECTED ;
7441  }
7442  return pSDB->createDomain ( pDomainName, options, domain ) ;
7443  }
7444 
7451  INT32 dropDomain ( const CHAR *pDomainName )
7452  {
7453  if ( !pSDB )
7454  {
7455  return SDB_NOT_CONNECTED ;
7456  }
7457  return pSDB->dropDomain ( pDomainName ) ;
7458  }
7459 
7460  INT32 getDomain ( const CHAR *pDomainName,
7461  _sdbDomain **domain )
7462  {
7463  if ( !pSDB )
7464  {
7465  return SDB_NOT_CONNECTED ;
7466  }
7467  return pSDB->getDomain ( pDomainName, domain ) ;
7468  }
7469 
7478  INT32 getDomain ( const CHAR *pDomainName,
7479  sdbDomain &domain )
7480  {
7481  if ( !pSDB )
7482  {
7483  return SDB_NOT_CONNECTED ;
7484  }
7485  RELEASE_INNER_HANDLE( domain.pDomain ) ;
7486  return pSDB->getDomain ( pDomainName, domain ) ;
7487  }
7488 
7489  INT32 listDomains ( _sdbCursor **cursor,
7490  const bson::BSONObj &condition = _sdbStaticObject,
7491  const bson::BSONObj &selector = _sdbStaticObject,
7492  const bson::BSONObj &orderBy = _sdbStaticObject,
7493  const bson::BSONObj &hint = _sdbStaticObject )
7494  {
7495  if ( !pSDB )
7496  {
7497  return SDB_NOT_CONNECTED ;
7498  }
7499  return pSDB->listDomains ( cursor, condition, selector, orderBy, hint ) ;
7500  }
7501 
7519  INT32 listDomains ( sdbCursor &cursor,
7520  const bson::BSONObj &condition = _sdbStaticObject,
7521  const bson::BSONObj &selector = _sdbStaticObject,
7522  const bson::BSONObj &orderBy = _sdbStaticObject,
7523  const bson::BSONObj &hint = _sdbStaticObject )
7524  {
7525  if ( !pSDB )
7526  {
7527  return SDB_NOT_CONNECTED ;
7528  }
7529  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7530  return pSDB->listDomains ( cursor, condition, selector, orderBy, hint ) ;
7531  }
7532 
7533  /* \fn INT32 getDC( sdbDataCenter &dc )
7534  \brief Get current data center.
7535  \retval SDB_OK Operation Success
7536  \retval Others Operation Fail
7537  */
7538  INT32 getDC( sdbDataCenter &dc )
7539  {
7540  if ( !pSDB )
7541  {
7542  return SDB_NOT_CONNECTED ;
7543  }
7544  RELEASE_INNER_HANDLE( dc.pDC ) ;
7545  return pSDB->getDC ( dc ) ;
7546  }
7547 
7548  /* \fn INT32 getDC( _sdbDataCenter **dc )
7549  \brief Get current data center.
7550  \retval SDB_OK Operation Success
7551  \retval Others Operation Fail
7552  */
7553  INT32 getDC( _sdbDataCenter **dc )
7554  {
7555  if ( !pSDB )
7556  {
7557  return SDB_NOT_CONNECTED ;
7558  }
7559  return pSDB->getDC ( dc ) ;
7560  }
7561 
7562  /* \fn INT32 getRecycleBin( sdbRecycleBin &recycleBin )
7563  \brief Get current recycle bin.
7564  \retval SDB_OK Operation Success
7565  \retval Others Operation Fail
7566  */
7567  INT32 getRecycleBin( sdbRecycleBin &recycleBin )
7568  {
7569  if ( !pSDB )
7570  {
7571  return SDB_NOT_CONNECTED ;
7572  }
7573  RELEASE_INNER_HANDLE( recycleBin.pRecycleBin ) ;
7574  return pSDB->getRecycleBin( recycleBin ) ;
7575  }
7576 
7577  /* \fn INT32 getRecycleBin( _sdbRecycleBin **recycleBin )
7578  \brief Get current recycle bin.
7579  \retval SDB_OK Operation Success
7580  \retval Others Operation Fail
7581  */
7582  INT32 getRecycleBin( _sdbRecycleBin **recycleBin )
7583  {
7584  if ( !pSDB )
7585  {
7586  return SDB_NOT_CONNECTED ;
7587  }
7588  return pSDB->getRecycleBin( recycleBin ) ;
7589  }
7590 
7596  UINT64 getLastAliveTime() const { return pSDB->getLastAliveTime(); }
7597 
7620  INT32 syncDB( const bson::BSONObj &options = _sdbStaticObject )
7621  {
7622  if ( !pSDB )
7623  {
7624  return SDB_NOT_CONNECTED ;
7625  }
7626  return pSDB->syncDB ( options ) ;
7627  }
7628 
7655  INT32 analyze ( const bson::BSONObj &options = _sdbStaticObject )
7656  {
7657  if ( !pSDB )
7658  {
7659  return SDB_NOT_CONNECTED ;
7660  }
7661  return pSDB->analyze ( options ) ;
7662  }
7663 
7679  INT32 forceSession( SINT64 sessionID,
7680  const bson::BSONObj &options = _sdbStaticObject )
7681  {
7682  if( !pSDB )
7683  {
7684  return SDB_NOT_CONNECTED ;
7685  }
7686  return pSDB->forceSession( sessionID, options ) ;
7687  }
7688 
7703  INT32 forceStepUp( const bson::BSONObj &options = _sdbStaticObject )
7704  {
7705  if( !pSDB )
7706  {
7707  return SDB_NOT_CONNECTED ;
7708  }
7709  return pSDB->forceStepUp( options ) ;
7710  }
7711 
7724  INT32 invalidateCache( const bson::BSONObj &options = _sdbStaticObject )
7725  {
7726  if( !pSDB )
7727  {
7728  return SDB_NOT_CONNECTED ;
7729  }
7730  return pSDB->invalidateCache( options ) ;
7731  }
7732 
7746  INT32 reloadConfig( const bson::BSONObj &options = _sdbStaticObject )
7747  {
7748  if( !pSDB )
7749  {
7750  return SDB_NOT_CONNECTED ;
7751  }
7752  return pSDB->reloadConfig( options ) ;
7753  }
7754 
7771  INT32 updateConfig( const bson::BSONObj &configs = _sdbStaticObject,
7772  const bson::BSONObj &options = _sdbStaticObject )
7773  {
7774  if( !pSDB )
7775  {
7776  return SDB_NOT_CONNECTED ;
7777  }
7778  return pSDB->updateConfig( configs, options ) ;
7779  }
7780 
7797  INT32 deleteConfig( const bson::BSONObj &configs = _sdbStaticObject,
7798  const bson::BSONObj &options = _sdbStaticObject )
7799  {
7800  if( !pSDB )
7801  {
7802  return SDB_NOT_CONNECTED ;
7803  }
7804  return pSDB->deleteConfig( configs, options ) ;
7805  }
7806 
7829  INT32 setPDLevel( INT32 level,
7830  const bson::BSONObj &options = _sdbStaticObject )
7831  {
7832  if( !pSDB )
7833  {
7834  return SDB_NOT_CONNECTED ;
7835  }
7836  return pSDB->setPDLevel( level, options ) ;
7837  }
7838 
7839  INT32 msg( const CHAR* msg )
7840  {
7841  if( !pSDB )
7842  {
7843  return SDB_NOT_CONNECTED ;
7844  }
7845  return pSDB->msg( msg ) ;
7846  }
7847 
7863  INT32 loadCS( const CHAR* csName,
7864  const bson::BSONObj &options = _sdbStaticObject )
7865  {
7866  if( !pSDB )
7867  {
7868  return SDB_NOT_CONNECTED ;
7869  }
7870  return pSDB->loadCS( csName, options ) ;
7871  }
7872 
7888  INT32 unloadCS( const CHAR* csName,
7889  const bson::BSONObj &options = _sdbStaticObject )
7890  {
7891  if( !pSDB )
7892  {
7893  return SDB_NOT_CONNECTED ;
7894  }
7895  return pSDB->unloadCS( csName, options ) ;
7896  }
7897 
7910  INT32 traceStart( UINT32 traceBufferSize,
7911  const CHAR* component = NULL,
7912  const CHAR* breakpoint = NULL,
7913  const vector<UINT32> &tidVec = _sdbStaticUINT32Vec )
7914  {
7915  if( !pSDB )
7916  {
7917  return SDB_NOT_CONNECTED ;
7918  }
7919  return pSDB->traceStart( traceBufferSize, component,
7920  breakpoint, tidVec ) ;
7921  }
7922 
7942  INT32 traceStart( UINT32 traceBufferSize,
7943  const bson::BSONObj &options )
7944  {
7945  if( !pSDB )
7946  {
7947  return SDB_NOT_CONNECTED ;
7948  }
7949  return pSDB->traceStart( traceBufferSize, options ) ;
7950  }
7951 
7960  INT32 traceStop( const CHAR* dumpFileName )
7961  {
7962  if( !pSDB )
7963  {
7964  return SDB_NOT_CONNECTED ;
7965  }
7966  return pSDB->traceStop( dumpFileName ) ;
7967  }
7968 
7974  INT32 traceResume()
7975  {
7976  if( !pSDB )
7977  {
7978  return SDB_NOT_CONNECTED ;
7979  }
7980  return pSDB->traceResume() ;
7981  }
7982 
7989  INT32 traceStatus( sdbCursor& cursor )
7990  {
7991  if( !pSDB )
7992  {
7993  return SDB_NOT_CONNECTED ;
7994  }
7995  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
7996  return pSDB->traceStatus( cursor ) ;
7997  }
7998 
7999  INT32 traceStatus( _sdbCursor** cursor )
8000  {
8001  if( !pSDB )
8002  {
8003  return SDB_NOT_CONNECTED ;
8004  }
8005  return pSDB->traceStatus( cursor ) ;
8006  }
8007 
8018  INT32 renameCollectionSpace( const CHAR* oldName,
8019  const CHAR* newName,
8020  const bson::BSONObj &options = _sdbStaticObject )
8021  {
8022  if( !pSDB )
8023  {
8024  return SDB_NOT_CONNECTED ;
8025  }
8026  return pSDB->renameCollectionSpace( oldName, newName, options ) ;
8027  }
8028 
8040  INT32 getLastErrorObj( bson::BSONObj &errObj )
8041  {
8042  if( !pSDB )
8043  {
8044  return SDB_NOT_CONNECTED ;
8045  }
8046  return pSDB->getLastErrorObj( errObj ) ;
8047  }
8048 
8052  void cleanLastErrorObj()
8053  {
8054  if( !pSDB )
8055  {
8056  return ;
8057  }
8058  return pSDB->cleanLastErrorObj() ;
8059  }
8060 
8071  INT32 getLastResultObj( bson::BSONObj &result,
8072  BOOLEAN getOwned = FALSE ) const
8073  {
8074  if( !pSDB )
8075  {
8076  return SDB_NOT_CONNECTED ;
8077  }
8078  return pSDB->getLastResultObj( result, getOwned ) ;
8079  }
8080 
8100  INT32 createSequence( const CHAR *pSequenceName,
8101  const bson::BSONObj &options,
8102  _sdbSequence **sequence )
8103  {
8104  if( !pSDB )
8105  {
8106  return SDB_NOT_CONNECTED ;
8107  }
8108  return pSDB->createSequence( pSequenceName, options, sequence ) ;
8109  }
8110 
8130  INT32 createSequence( const CHAR *pSequenceName,
8131  const bson::BSONObj &options,
8132  sdbSequence &sequence )
8133  {
8134  if( !pSDB )
8135  {
8136  return SDB_NOT_CONNECTED ;
8137  }
8138  return pSDB->createSequence( pSequenceName, options, sequence ) ;
8139  }
8140 
8149  INT32 createSequence( const CHAR *pSequenceName,
8150  sdbSequence &sequence )
8151  {
8152  if( !pSDB )
8153  {
8154  return SDB_NOT_CONNECTED ;
8155  }
8156  return pSDB->createSequence( pSequenceName, sequence ) ;
8157  }
8158 
8167  INT32 getSequence( const CHAR *pSequenceName,
8168  _sdbSequence **sequence )
8169  {
8170  if( !pSDB )
8171  {
8172  return SDB_NOT_CONNECTED ;
8173  }
8174  return pSDB->getSequence( pSequenceName, sequence ) ;
8175  }
8176 
8185  INT32 getSequence( const CHAR *pSequenceName,
8186  sdbSequence &sequence )
8187  {
8188  if( !pSDB )
8189  {
8190  return SDB_NOT_CONNECTED ;
8191  }
8192  return pSDB->getSequence( pSequenceName, sequence ) ;
8193  }
8194 
8202  INT32 renameSequence( const CHAR *pOldName, const CHAR *pNewName )
8203  {
8204  if( !pSDB )
8205  {
8206  return SDB_NOT_CONNECTED ;
8207  }
8208  return pSDB->renameSequence( pOldName, pNewName ) ;
8209  }
8210 
8217  INT32 dropSequence( const CHAR *pSequenceName )
8218  {
8219  if( !pSDB )
8220  {
8221  return SDB_NOT_CONNECTED ;
8222  }
8223  return pSDB->dropSequence( pSequenceName ) ;
8224  }
8225 
8274  INT32 createDataSource( sdbDataSource &dataSource,
8275  const CHAR *pDataSourceName,
8276  const CHAR *addresses,
8277  const CHAR *user = NULL,
8278  const CHAR *password = NULL,
8279  const CHAR *type = NULL,
8280  const bson::BSONObj *options = NULL )
8281  {
8282  if ( !pSDB )
8283  {
8284  return SDB_NOT_CONNECTED ;
8285  }
8286  RELEASE_INNER_HANDLE( dataSource.pDataSource ) ;
8287  return pSDB->createDataSource( &dataSource.pDataSource, pDataSourceName, addresses,
8288  user, password, type, options ) ;
8289  }
8290 
8297  INT32 dropDataSource( const CHAR *pDataSourceName )
8298  {
8299  if ( !pSDB )
8300  {
8301  return SDB_NOT_CONNECTED ;
8302  }
8303  return pSDB->dropDataSource( pDataSourceName ) ;
8304  }
8305 
8314  INT32 getDataSource( const CHAR *pDataSourceName,
8315  sdbDataSource &dataSource )
8316  {
8317  if ( !pSDB )
8318  {
8319  return SDB_NOT_CONNECTED ;
8320  }
8321  RELEASE_INNER_HANDLE( dataSource.pDataSource ) ;
8322  return pSDB->getDataSource( pDataSourceName, &dataSource.pDataSource ) ;
8323  }
8324 
8339  INT32 listDataSources( sdbCursor& cursor,
8340  const bson::BSONObj &condition = _sdbStaticObject,
8341  const bson::BSONObj &selector = _sdbStaticObject,
8342  const bson::BSONObj &orderBy = _sdbStaticObject,
8343  const bson::BSONObj &hint = _sdbStaticObject )
8344  {
8345  if ( !pSDB )
8346  {
8347  return SDB_NOT_CONNECTED ;
8348  }
8349  RELEASE_INNER_HANDLE( cursor.pCursor ) ;
8350  return pSDB->listDataSources( &cursor.pCursor, condition, selector, orderBy, hint ) ;
8351  }
8352  } ;
8353 
8357  typedef class sdb sdb ;
8358 
8365  SDB_EXPORT INT32 initClient( sdbClientConf* config ) ;
8366 
8367 }
8368 
8369 #endif