public MetaRecord(DbObject obj) { id = obj.getId(); objectType = obj.getType(); sql = obj.getCreateSQL(); }
/** * Update an object in the system table. * * @param session the session * @param obj the database object */ public void updateMeta(ServerSession session, DbObject obj) { // lockMeta(session); int id = obj.getId(); removeMeta(session, id); addMeta(session, obj); }
/** * Add an object to the database. * * @param session the session * @param obj the object to add */ public void addDatabaseObject(ServerSession session, DbObject obj) { int id = obj.getId(); if (id > 0 && !starting) { checkWritingAllowed(); } DbObjectType type = obj.getType(); synchronized (getLock(type)) { Map<String, DbObject> map = getMap(type); String name = obj.getName(); if (SysProperties.CHECK && map.get(name) != null) { DbException.throwInternalError("object already exists"); } // lockMeta(session); addMeta(session, obj); map.put(name, obj); } }
int id = obj.getId();
private void addMeta(ServerSession session, DbObject obj) { int id = obj.getId(); if (id > 0 && !starting && !obj.isTemporary()) { Row r = meta.getTemplateRow(); MetaRecord rec = new MetaRecord(obj); rec.setRecord(r); synchronized (objectIds) { objectIds.set(id); } // if (SysProperties.CHECK) { // verifyMetaLocked(session); // } meta.addRow(session, r); } }
/** * Remove the object from the database. * * @param session the session * @param obj the object to remove */ public void removeDatabaseObject(ServerSession session, DbObject obj) { checkWritingAllowed(); String objName = obj.getName(); DbObjectType type = obj.getType(); synchronized (getLock(type)) { Map<String, DbObject> map = getMap(type); if (SysProperties.CHECK && !map.containsKey(objName)) { DbException.throwInternalError("not found: " + objName); } Comment comment = findComment(obj); // lockMeta(session); if (comment != null) { removeDatabaseObject(session, comment); } int id = obj.getId(); obj.removeChildrenAndResources(session); map.remove(objName); removeMeta(session, id); } }