1
0
Fork 0

fix processing of AQL index hints when upgrading (#9138)

This commit is contained in:
Jan 2019-05-30 04:28:19 +02:00 committed by Frank Celler
parent 773f3c8422
commit c3d1d24b27
2 changed files with 23 additions and 12 deletions

View File

@ -23,8 +23,11 @@
#include "IndexHint.h" #include "IndexHint.h"
#include <velocypack/Builder.h>
#include <velocypack/Iterator.h> #include <velocypack/Iterator.h>
#include <velocypack/Slice.h>
#include <velocypack/StringRef.h> #include <velocypack/StringRef.h>
#include <velocypack/velocypack-aliases.h>
#include "Aql/AstNode.h" #include "Aql/AstNode.h"
#include "Basics/StaticStrings.h" #include "Basics/StaticStrings.h"
@ -125,11 +128,18 @@ IndexHint::IndexHint(AstNode const* node)
} }
IndexHint::IndexHint(VPackSlice const& slice) IndexHint::IndexHint(VPackSlice const& slice)
: _type{::fromTypeName( : IndexHint() {
basics::VelocyPackHelper::getStringValue(slice.get(::FieldContainer),
::FieldType, ""))}, // read index hint from slice
_forced{basics::VelocyPackHelper::getBooleanValue(slice.get(::FieldContainer), // index hints were introduced in version 3.5. in previous versions they
::FieldForced, false)} { // are not available, so we need to be careful when reading them
VPackSlice s = slice.get(::FieldContainer);
if (s.isObject()) {
_type = ::fromTypeName(
basics::VelocyPackHelper::getStringValue(s, ::FieldType, ""));
_forced = basics::VelocyPackHelper::getBooleanValue(s, ::FieldForced, false);
}
if (_type != HintType::Illegal && _type != HintType::None) { if (_type != HintType::Illegal && _type != HintType::None) {
VPackSlice container = slice.get(::FieldContainer); VPackSlice container = slice.get(::FieldContainer);
TRI_ASSERT(container.isObject()); TRI_ASSERT(container.isObject());

View File

@ -26,13 +26,14 @@
#include <iosfwd> #include <iosfwd>
#include <velocypack/Builder.h>
#include <velocypack/Slice.h>
#include <velocypack/velocypack-aliases.h>
#include "Aql/AstNode.h" #include "Aql/AstNode.h"
namespace arangodb { namespace arangodb {
namespace velocypack {
class Builder;
class Slice;
}
namespace aql { namespace aql {
/// @brief container for index hint information /// @brief container for index hint information
@ -43,20 +44,20 @@ class IndexHint {
public: public:
explicit IndexHint(); explicit IndexHint();
explicit IndexHint(AstNode const* node); explicit IndexHint(AstNode const* node);
explicit IndexHint(VPackSlice const& slice); explicit IndexHint(arangodb::velocypack::Slice const& slice);
public: public:
HintType type() const; HintType type() const;
bool isForced() const; bool isForced() const;
std::vector<std::string> const& hint() const; std::vector<std::string> const& hint() const;
void toVelocyPack(VPackBuilder& builder) const; void toVelocyPack(arangodb::velocypack::Builder& builder) const;
std::string typeName() const; std::string typeName() const;
std::string toString() const; std::string toString() const;
private: private:
HintType _type; HintType _type;
bool const _forced; bool _forced;
// actual hint is a recursive structure, with the data type determined by the // actual hint is a recursive structure, with the data type determined by the
// _type above; in the case of a nested IndexHint, the value of isForced() is // _type above; in the case of a nested IndexHint, the value of isForced() is