LIB_EXPORT rc_t CC VDBManagerOpenTableRead ( const VDBManager *self, const VTable **tbl, const VSchema *schema, const char *path, ... ) { rc_t rc; va_list args; va_start ( args, path ); rc = VDBManagerVOpenTableRead ( self, tbl, schema, path, args ); va_end ( args ); return rc; }
/* OpenRead * open an existing table * * "tbl" [ OUT ] - return parameter for table * * "spec" [ IN ] - NUL terminated UTF-8 string giving path * to table. */ static rc_t CC SRAMgrVOpenAltTableRead ( const SRAMgr *self, const SRATable **rslt, const char *altname, const char *spec, va_list args ) { rc_t rc; if ( rslt == NULL ) rc = RC ( rcSRA, rcTable, rcOpening, rcParam, rcNull ); else { if ( self == NULL ) rc = RC ( rcSRA, rcMgr, rcAccessing, rcSelf, rcNull ); else if ( spec == NULL ) rc = RC ( rcSRA, rcTable, rcOpening, rcName, rcNull ); else if ( spec [ 0 ] == 0 ) rc = RC ( rcSRA, rcTable, rcOpening, rcName, rcEmpty ); else { SRATable *tbl = calloc ( 1, sizeof *tbl ); if ( tbl == NULL ) rc = RC ( rcSRA, rcTable, rcConstructing, rcMemory, rcExhausted ); else { VSchema *schema = NULL; rc = VDBManagerMakeSRASchema(self -> vmgr, & schema); if ( rc == 0 ) { va_list args_copy; va_copy ( args_copy, args ); rc = VDBManagerVOpenTableRead ( self -> vmgr, & tbl -> vtbl, schema, spec, args ); if ( rc != 0 && GetRCObject ( rc ) == (enum RCObject)rcTable && GetRCState ( rc ) == rcIncorrect ) { const VDatabase *db; rc_t rc2 = VDBManagerVOpenDBRead ( self -> vmgr, & db, schema, spec, args_copy ); if ( rc2 == 0 ) { rc2 = VDatabaseOpenTableRead ( db, & tbl -> vtbl, "%s", altname ); if ( rc2 == 0 ) rc = 0; VDatabaseRelease ( db ); } } va_end ( args_copy ); VSchemaRelease(schema); if ( rc == 0 ) { rc = VTableOpenMetadataRead ( tbl -> vtbl, & tbl -> meta ); if ( rc == 0 ) { rc = KMetadataVersion ( tbl -> meta, & tbl -> metavers ); if ( rc == 0 ) { rc = VTableCreateCursorRead ( tbl -> vtbl, & tbl -> curs ); if ( rc == 0 ) { tbl -> mode = self -> mode; tbl -> read_only = true; KRefcountInit ( & tbl -> refcount, 1, "SRATable", "OpenTableRead", spec ); rc = SRATableFillOut ( tbl, false ); if ( rc == 0 ) { * rslt = tbl; return 0; } } } } } } SRATableWhack ( tbl ); } } * rslt = NULL; } return rc; }