"(SELECT " + (DebugConfig.enableMailboxGroup ? "?, " : "") + "?, type, NULL, ?, ?, ?, date, size, ?, blob_digest," + " unread, flags, tags, sender, subject, metadata, ?, ?, ? FROM " + table + " WHERE " + (DebugConfig.enableMailboxGroup ? "mailbox_id = ? AND " : "") + "id = ?)");
"(SELECT " + (DebugConfig.enableMailboxGroup ? "?, " : "") + " ?, type, NULL, ?, ?, ?, date, size, ?, blob_digest," + " unread, flags, tags, sender, subject, metadata, ?, ?, ? FROM " + table + " WHERE " + IN_THIS_MAILBOX_AND + "id = ?)");
    public static void icopy(MailItem source, UnderlyingData data)    throws ServiceException {        Mailbox mbox = source.getMailbox();        if (data == null || data.id <= 0 || data.folderId <= 0 || data.parentId == 0 || data.indexId == 0)            throw ServiceException.FAILURE("invalid data for DB item i-copy", null);        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        try {            String table = getMailItemTableName(mbox);            stmt = conn.prepareStatement("INSERT INTO " + table +                    "(" +                    (DebugConfig.enableMailboxGroup ? "mailbox_id, " : "") +                    "id, type, parent_id, folder_id, index_id, imap_id, date, size, volume_id, blob_digest," +                    " unread, flags, tags, sender, subject, metadata, mod_metadata, change_date, mod_content) " +                    "(SELECT " +                    (DebugConfig.enableMailboxGroup ? "?, " : "") +                    "?, type, NULL, ?, ?, ?, date, size, ?, blob_digest," +                    " unread, flags, tags, sender, subject, metadata, ?, ?, ? FROM " + table + " WHERE " +                    (DebugConfig.enableMailboxGroup ? "mailbox_id = ? AND " : "") +                    "id = ?)");            int mboxId = mbox.getId();            int pos = 1;            if (DebugConfig.enableMailboxGroup)                stmt.setInt(pos++, mboxId);            stmt.setInt(pos++, data.id);                       // ID            stmt.setInt(pos++, data.folderId);                 // FOLDER_ID            stmt.setInt(pos++, data.indexId);                  // INDEX_ID            stmt.setInt(pos++, data.imapId);                   // IMAP_ID            if (data.volumeId >= 0)                stmt.setShort(pos++, data.volumeId);           // VOLUME_ID            else                stmt.setNull(pos++, Types.TINYINT);            //   or, no VOLUME_ID            stmt.setInt(pos++, mbox.getOperationChangeID());   // MOD_METADATA            stmt.setInt(pos++, mbox.getOperationTimestamp());  // CHANGE_DATE            stmt.setInt(pos++, mbox.getOperationChangeID());   // MOD_CONTENT            if (DebugConfig.enableMailboxGroup)                stmt.setInt(pos++, mboxId);            stmt.setInt(pos++, source.getId());            int num = stmt.executeUpdate();            if (num != 1)                throw ServiceException.FAILURE("failed to create object", null);        } catch (SQLException e) {            // catch item_id uniqueness constraint violation and return failure            if (e.getErrorCode() == Db.Error.DUPLICATE_ROW)                throw MailServiceException.ALREADY_EXISTS(data.id, e);            else                throw ServiceException.FAILURE("i-copying " + MailItem.getNameForType(source.getType()) + ": " + source.getId(), e);        } finally {            DbPool.closeStatement(stmt);        }    }