1
0
Fork 0

Merge branch 'devel' of github.com:arangodb/ArangoDB into JHMH

This commit is contained in:
Wilfried Goesgens 2015-11-11 11:05:06 +01:00
commit 2d5d2d881e
42 changed files with 903 additions and 506 deletions

24
3rdParty/Makefile.v8 vendored
View File

@ -51,8 +51,8 @@ if ENABLE_V8_DEBUG
CXX="$(CXX)" \ CXX="$(CXX)" \
CXX.host="$(CXX)" \ CXX.host="$(CXX)" \
LINK="$(CXX)" \ LINK="$(CXX)" \
CFLAGS="-O0 -ggdb -fsigned-char -march=armv6 $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS)" \ CFLAGS="-O0 -ggdb -fsigned-char -march=armv6 $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
CXXFLAGS="-O0 -ggdb -fsigned-char -march=armv6 $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS)" \ CXXFLAGS="-O0 -ggdb -fsigned-char -march=armv6 $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
LDFLAGS="-march=armv6" \ LDFLAGS="-march=armv6" \
debug=on v8_optimized_debug=0 v8_enable_backtrace=on \ debug=on v8_optimized_debug=0 v8_enable_backtrace=on \
library=static strictaliasing=off snapshot=off werror=no hardfp=on @V8_TARGET@ library=static strictaliasing=off snapshot=off werror=no hardfp=on @V8_TARGET@
@ -65,8 +65,8 @@ else
CXX="$(CXX)" \ CXX="$(CXX)" \
CXX.host="$(CXX)" \ CXX.host="$(CXX)" \
LINK="$(CXX)" \ LINK="$(CXX)" \
CFLAGS="-O2 -g -fsigned-char -march=armv6 $(GOLD_V8_FLAGS)" \ CFLAGS="-O2 -g -fsigned-char -march=armv6 $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
CXXFLAGS="-O2 -g -fsigned-char -march=armv6 $(GOLD_V8_FLAGS)" \ CXXFLAGS="-O2 -g -fsigned-char -march=armv6 $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
LDFLAGS="-march=armv6" \ LDFLAGS="-march=armv6" \
library=static strictaliasing=off snapshot=off werror=no hardfp=on @V8_TARGET@ library=static strictaliasing=off snapshot=off werror=no hardfp=on @V8_TARGET@
endif endif
@ -86,8 +86,8 @@ if ENABLE_V8_DEBUG
CXX="$(CXX)" \ CXX="$(CXX)" \
CXX.host="$(CXX)" \ CXX.host="$(CXX)" \
LINK="$(CXX)" \ LINK="$(CXX)" \
CFLAGS="-O0 -ggdb -fsigned-char -march=armv7 $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS)" \ CFLAGS="-O0 -ggdb -fsigned-char -march=armv7 $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
CXXFLAGS="-O0 -ggdb -fsigned-char -march=armv7 $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS)" \ CXXFLAGS="-O0 -ggdb -fsigned-char -march=armv7 $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
LDFLAGS="-march=armv7" \ LDFLAGS="-march=armv7" \
debug=on v8_optimized_debug=0 v8_enable_backtrace=on \ debug=on v8_optimized_debug=0 v8_enable_backtrace=on \
library=static strictaliasing=off snapshot=off werror=no @V8_TARGET@ library=static strictaliasing=off snapshot=off werror=no @V8_TARGET@
@ -100,8 +100,8 @@ else
CXX="$(CXX)" \ CXX="$(CXX)" \
CXX.host="$(CXX)" \ CXX.host="$(CXX)" \
LINK="$(CXX)" \ LINK="$(CXX)" \
CFLAGS="-O2 -g -fsigned-char -march=armv7 $(GOLD_V8_FLAGS)" \ CFLAGS="-O2 -g -fsigned-char -march=armv7 $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
CXXFLAGS="-O2 -g -fsigned-char -march=armv7 $(GOLD_V8_FLAGS)" \ CXXFLAGS="-O2 -g -fsigned-char -march=armv7 $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
LDFLAGS="-march=armv7" \ LDFLAGS="-march=armv7" \
library=static strictaliasing=off snapshot=off werror=no @V8_TARGET@ library=static strictaliasing=off snapshot=off werror=no @V8_TARGET@
endif endif
@ -160,8 +160,8 @@ if ENABLE_V8_DEBUG
CXX="$(CXX)" \ CXX="$(CXX)" \
CXX.host="$(CXX)" \ CXX.host="$(CXX)" \
LINK="$(CXX)" \ LINK="$(CXX)" \
CFLAGS="-O0 -ggdb $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS)" \ CFLAGS="-O0 -ggdb $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
CXXFLAGS="-O0 -ggdb $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS)" \ CXXFLAGS="-O0 -ggdb $(DEBUG_V8_FLAGS) $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
debug=on v8_optimized_debug=0 v8_enable_backtrace=on \ debug=on v8_optimized_debug=0 v8_enable_backtrace=on \
library=static strictaliasing=off snapshot=off werror=no @V8_TARGET@ library=static strictaliasing=off snapshot=off werror=no @V8_TARGET@
else # ! ENABLE_V8_DEBUG else # ! ENABLE_V8_DEBUG
@ -173,8 +173,8 @@ else # ! ENABLE_V8_DEBUG
CXX="$(CXX)" \ CXX="$(CXX)" \
CXX.host="$(CXX)" \ CXX.host="$(CXX)" \
LINK="$(CXX)" \ LINK="$(CXX)" \
CFLAGS="-O3 -fomit-frame-pointer -g $(GOLD_V8_FLAGS)" \ CFLAGS="-O3 -fomit-frame-pointer -g $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
CXXFLAGS="-O3 -fomit-frame-pointer -g $(GOLD_V8_FLAGS)" \ CXXFLAGS="-O3 -fomit-frame-pointer -g $(GOLD_V8_FLAGS) $(STDLIB_FLAGS)" \
library=static strictaliasing=off snapshot=off werror=no @V8_TARGET@ library=static strictaliasing=off snapshot=off werror=no @V8_TARGET@
endif # ENABLE_V8_DEBUG endif # ENABLE_V8_DEBUG
endif # ENABLE_DARWIN endif # ENABLE_DARWIN

View File

@ -58,6 +58,7 @@ extern "C" {
int linenoiseHistoryLoad(const char* filename); int linenoiseHistoryLoad(const char* filename);
void linenoiseHistoryFree(void); void linenoiseHistoryFree(void);
void linenoiseClearScreen(void); void linenoiseClearScreen(void);
int linenoiseInstallWindowChangeHandler(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -130,7 +130,7 @@ using namespace linenoise_ng;
typedef unsigned char char8_t; typedef unsigned char char8_t;
ConversionResult copyString8to32 (char32_t* dst, size_t dstSize, size_t& dstCount, const char* src) { static ConversionResult copyString8to32 (char32_t* dst, size_t dstSize, size_t& dstCount, const char* src) {
const UTF8* sourceStart = reinterpret_cast<const UTF8*>(src); const UTF8* sourceStart = reinterpret_cast<const UTF8*>(src);
const UTF8* sourceEnd = sourceStart + strlen(src); const UTF8* sourceEnd = sourceStart + strlen(src);
UTF32* targetStart = reinterpret_cast<UTF32*>(dst); UTF32* targetStart = reinterpret_cast<UTF32*>(dst);
@ -149,11 +149,11 @@ ConversionResult copyString8to32 (char32_t* dst, size_t dstSize, size_t& dstCoun
return res; return res;
} }
ConversionResult copyString8to32 (char32_t* dst, size_t dstSize, size_t& dstCount, const char8_t* src) { static ConversionResult copyString8to32 (char32_t* dst, size_t dstSize, size_t& dstCount, const char8_t* src) {
return copyString8to32(dst, dstSize, dstCount, reinterpret_cast<const char*>(src)); return copyString8to32(dst, dstSize, dstCount, reinterpret_cast<const char*>(src));
} }
size_t strlen32 (const char32_t* str) { static size_t strlen32 (const char32_t* str) {
const char32_t* ptr = str; const char32_t* ptr = str;
while (*ptr) { while (*ptr) {
@ -163,15 +163,16 @@ size_t strlen32 (const char32_t* str) {
return ptr - str; return ptr - str;
} }
size_t strlen8 (const char8_t* str) { static size_t strlen8 (const char8_t* str) {
return strlen(reinterpret_cast<const char*>(str)); return strlen(reinterpret_cast<const char*>(str));
} }
char8_t* strdup8 (const char* src) { static char8_t* strdup8 (const char* src) {
return reinterpret_cast<char8_t*>(strdup(src)); return reinterpret_cast<char8_t*>(strdup(src));
} }
void copyString32to16(char16_t* dst, size_t dstSize, size_t* dstCount, const char32_t* src, size_t srcSize) { #ifdef _WIN32
static void copyString32to16(char16_t* dst, size_t dstSize, size_t* dstCount, const char32_t* src, size_t srcSize) {
const UTF32* sourceStart = reinterpret_cast<const UTF32*>(src); const UTF32* sourceStart = reinterpret_cast<const UTF32*>(src);
const UTF32* sourceEnd = sourceStart + srcSize; const UTF32* sourceEnd = sourceStart + srcSize;
char16_t* targetStart = reinterpret_cast<char16_t*>(dst); char16_t* targetStart = reinterpret_cast<char16_t*>(dst);
@ -187,8 +188,9 @@ void copyString32to16(char16_t* dst, size_t dstSize, size_t* dstCount, const cha
} }
} }
} }
#endif
void copyString32to8 (char* dst, size_t dstSize, size_t* dstCount, const char32_t* src, size_t srcSize) { static void copyString32to8 (char* dst, size_t dstSize, size_t* dstCount, const char32_t* src, size_t srcSize) {
const UTF32* sourceStart = reinterpret_cast<const UTF32*>(src); const UTF32* sourceStart = reinterpret_cast<const UTF32*>(src);
const UTF32* sourceEnd = sourceStart + srcSize; const UTF32* sourceEnd = sourceStart + srcSize;
UTF8* targetStart = reinterpret_cast<UTF8*>(dst); UTF8* targetStart = reinterpret_cast<UTF8*>(dst);
@ -205,12 +207,12 @@ void copyString32to8 (char* dst, size_t dstSize, size_t* dstCount, const char32_
} }
} }
void copyString32to8 (char* dst, size_t dstLen, const char32_t* src) { static void copyString32to8 (char* dst, size_t dstLen, const char32_t* src) {
size_t dstCount = 0; size_t dstCount = 0;
copyString32to8 (dst, dstLen, &dstCount, src, strlen32(src)); copyString32to8 (dst, dstLen, &dstCount, src, strlen32(src));
} }
void copyString32 (char32_t* dst, const char32_t* src, size_t len) { static void copyString32 (char32_t* dst, const char32_t* src, size_t len) {
while (*src && 1 < len) { while (*src && 1 < len) {
*dst++ = *src++; *dst++ = *src++;
--len; --len;
@ -219,7 +221,7 @@ void copyString32 (char32_t* dst, const char32_t* src, size_t len) {
*dst = 0; *dst = 0;
} }
int strncmp32 (const char32_t* left, const char32_t* right, size_t len) { static int strncmp32 (const char32_t* left, const char32_t* right, size_t len) {
while (0 < len && *left) { while (0 < len && *left) {
if (*left != *right) { if (*left != *right) {
return *left - * right; return *left - * right;
@ -233,7 +235,7 @@ int strncmp32 (const char32_t* left, const char32_t* right, size_t len) {
return 0; return 0;
} }
int write32 (int fd, char32_t* text32, int len32) { static int write32 (int fd, char32_t* text32, int len32) {
#ifdef _WIN32 #ifdef _WIN32
if (_isatty(fd)) { if (_isatty(fd)) {
size_t len16 = 2 * len32 + 1; size_t len16 = 2 * len32 + 1;
@ -464,6 +466,7 @@ struct PromptBase { // a convenience struct for grouping prompt inf
Utf32String promptText; // our copy of the prompt text, edited Utf32String promptText; // our copy of the prompt text, edited
char* promptCharWidths; // character widths from mk_wcwidth() char* promptCharWidths; // character widths from mk_wcwidth()
int promptChars; // chars in promptText int promptChars; // chars in promptText
int promptBytes; // bytes in promptText
int promptExtraLines; // extra lines (beyond 1) occupied by prompt int promptExtraLines; // extra lines (beyond 1) occupied by prompt
int promptIndentation; // column offset to end of prompt int promptIndentation; // column offset to end of prompt
int promptLastLinePosition; // index into promptText where last line begins int promptLastLinePosition; // index into promptText where last line begins
@ -474,6 +477,13 @@ struct PromptBase { // a convenience struct for grouping prompt inf
int promptErrorCode; // error code (invalid UTF-8) or zero int promptErrorCode; // error code (invalid UTF-8) or zero
PromptBase() : promptPreviousInputLen(0) {} PromptBase() : promptPreviousInputLen(0) {}
bool write() {
if (write32(1, promptText.get(), promptBytes) == -1)
return false;
return true;
}
}; };
struct PromptInfo : public PromptBase { struct PromptInfo : public PromptBase {
@ -487,37 +497,78 @@ struct PromptInfo : public PromptBase {
// strip control characters from the prompt -- we do allow newline // strip control characters from the prompt -- we do allow newline
char32_t* pIn = tempUnicode.get(); char32_t* pIn = tempUnicode.get();
char32_t* pOut = pIn; char32_t* pOut = pIn;
int len = 0;
int x = 0;
#ifdef _WIN32
bool const strip = true;
#else
bool const strip = (isatty(1) != 1);
#endif
while (*pIn) { while (*pIn) {
char32_t c = *pIn; char32_t c = *pIn;
if ('\n' == c || !isControlChar(c)) { if ('\n' == c || !isControlChar(c)) {
*pOut = c; *pOut = c;
++pOut; ++pOut;
} ++pIn;
++pIn; ++len;
} if ('\n' == c || ++x >= promptScreenColumns) {
*pOut = 0;
promptChars = static_cast<int>(pOut - tempUnicode.get());
promptText = tempUnicode;
int x = 0;
for (int i = 0; i < promptChars; ++i) {
char32_t c = promptText[i];
if ('\n' == c) {
x = 0;
++promptExtraLines;
promptLastLinePosition = i + 1;
} else {
++x;
if (x >= promptScreenColumns) {
x = 0; x = 0;
++promptExtraLines; ++promptExtraLines;
promptLastLinePosition = i + 1; promptLastLinePosition = len;
} }
} }
else if (c == '\x1b') {
if (strip) {
// jump over control chars
++pIn;
if (*pIn == '[') {
++pIn;
while (*pIn && ((*pIn == ';') || ((*pIn >= '0' && *pIn <= '9')))) {
++pIn;
}
if (*pIn == 'm') {
++pIn;
}
}
}
else {
// copy control chars
*pOut = *pIn;
++pOut;
++pIn;
if (*pIn == '[') {
*pOut = *pIn;
++pOut;
++pIn;
while (*pIn && ((*pIn == ';') || ((*pIn >= '0' && *pIn <= '9')))) {
*pOut = *pIn;
++pOut;
++pIn;
}
if (*pIn == 'm') {
*pOut = *pIn;
++pOut;
++pIn;
}
}
}
}
else {
++pIn;
}
} }
promptIndentation = promptChars - promptLastLinePosition; *pOut = 0;
promptChars = len;
promptBytes = static_cast<int>(pOut - tempUnicode.get());
promptText = tempUnicode;
promptIndentation = len - promptLastLinePosition;
promptCursorRowOffset = promptExtraLines; promptCursorRowOffset = promptExtraLines;
} }
}; };
// Used with DynamicPrompt (history search) // Used with DynamicPrompt (history search)
@ -545,6 +596,7 @@ struct DynamicPrompt : public PromptBase {
(direction > 0) ? &forwardSearchBasePrompt : &reverseSearchBasePrompt; (direction > 0) ? &forwardSearchBasePrompt : &reverseSearchBasePrompt;
size_t promptStartLength = basePrompt->length(); size_t promptStartLength = basePrompt->length();
promptChars = static_cast<int>(promptStartLength + endSearchBasePrompt.length()); promptChars = static_cast<int>(promptStartLength + endSearchBasePrompt.length());
promptBytes = promptChars;
promptLastLinePosition = promptLastLinePosition =
promptChars; // TODO fix this, we are asssuming that the history prompt won't wrap (!) promptChars; // TODO fix this, we are asssuming that the history prompt won't wrap (!)
promptPreviousLen = promptChars; promptPreviousLen = promptChars;
@ -564,6 +616,7 @@ struct DynamicPrompt : public PromptBase {
(direction > 0) ? &forwardSearchBasePrompt : &reverseSearchBasePrompt; (direction > 0) ? &forwardSearchBasePrompt : &reverseSearchBasePrompt;
size_t promptStartLength = basePrompt->length(); size_t promptStartLength = basePrompt->length();
promptChars = static_cast<int>(promptStartLength + searchTextLen + endSearchBasePrompt.length()); promptChars = static_cast<int>(promptStartLength + searchTextLen + endSearchBasePrompt.length());
promptBytes = promptChars;
Utf32String tempUnicode(promptChars + 1); Utf32String tempUnicode(promptChars + 1);
memcpy(tempUnicode.get(), basePrompt->get(), sizeof(char32_t) * promptStartLength); memcpy(tempUnicode.get(), basePrompt->get(), sizeof(char32_t) * promptStartLength);
memcpy(&tempUnicode[promptStartLength], searchText.get(), sizeof(char32_t) * searchTextLen); memcpy(&tempUnicode[promptStartLength], searchText.get(), sizeof(char32_t) * searchTextLen);
@ -787,7 +840,7 @@ static int enableRawMode(void) {
#else #else
struct termios raw; struct termios raw;
if (!isatty(0)) if (!isatty(STDIN_FILENO))
goto fatal; goto fatal;
if (!atexit_registered) { if (!atexit_registered) {
atexit(linenoiseAtExit); atexit(linenoiseAtExit);
@ -955,7 +1008,7 @@ static void dynamicRefresh(PromptBase& pi, char32_t* buf32, int len, int pos) {
pi.promptPreviousInputLen = len; pi.promptPreviousInputLen = len;
// display the prompt // display the prompt
if (write32(1, pi.promptText.get(), pi.promptChars) == -1) if (! pi.write())
return; return;
// display the input line // display the input line
@ -981,7 +1034,7 @@ static void dynamicRefresh(PromptBase& pi, char32_t* buf32, int len, int pos) {
return; return;
// display the prompt // display the prompt
if (write32(1, pi.promptText.get(), pi.promptChars) == -1) if (! pi.write())
return; return;
// display the input line // display the input line
@ -1919,7 +1972,7 @@ int InputBuffer::completeLine(PromptBase& pi) {
if (write(1, "\n", 1) == -1) if (write(1, "\n", 1) == -1)
return 0; return 0;
} }
if (write32(1, pi.promptText.get(), pi.promptChars) == -1) if (! pi.write())
return 0; return 0;
#ifndef _WIN32 #ifndef _WIN32
// we have to generate our own newline on line wrap on Linux // we have to generate our own newline on line wrap on Linux
@ -1952,7 +2005,7 @@ void linenoiseClearScreen(void) {
void InputBuffer::clearScreen(PromptBase& pi) { void InputBuffer::clearScreen(PromptBase& pi) {
linenoiseClearScreen(); linenoiseClearScreen();
if (write32(1, pi.promptText.get(), pi.promptChars) == -1) if (! pi.write())
return; return;
#ifndef _WIN32 #ifndef _WIN32
// we have to generate our own newline on line wrap on Linux // we have to generate our own newline on line wrap on Linux
@ -2190,8 +2243,10 @@ int InputBuffer::incrementalHistorySearch(PromptBase& pi, int startChar) {
// leaving history search, restore previous prompt, maybe make searched line current // leaving history search, restore previous prompt, maybe make searched line current
PromptBase pb; PromptBase pb;
pb.promptChars = pi.promptIndentation; pb.promptChars = pi.promptIndentation;
Utf32String tempUnicode(pb.promptChars + 1); pb.promptBytes = pi.promptBytes;
copyString32(tempUnicode.get(), &pi.promptText[pi.promptLastLinePosition], pb.promptChars + 1); Utf32String tempUnicode(pb.promptBytes + 1);
copyString32(tempUnicode.get(), &pi.promptText[pi.promptLastLinePosition], pb.promptBytes + 1);
tempUnicode.initFromBuffer(); tempUnicode.initFromBuffer();
pb.promptText = tempUnicode; pb.promptText = tempUnicode;
pb.promptExtraLines = 0; pb.promptExtraLines = 0;
@ -2221,6 +2276,10 @@ static bool isCharacterAlphanumeric(char32_t testChar) {
return (iswalnum(testChar) != 0 ? true : false); return (iswalnum(testChar) != 0 ? true : false);
} }
#ifndef _WIN32
static bool gotResize = false;
#endif
int InputBuffer::getInputLine(PromptBase& pi) { int InputBuffer::getInputLine(PromptBase& pi) {
// The latest history entry is always our current buffer // The latest history entry is always our current buffer
if (len > 0) { if (len > 0) {
@ -2235,7 +2294,7 @@ int InputBuffer::getInputLine(PromptBase& pi) {
historyRecallMostRecent = false; historyRecallMostRecent = false;
// display the prompt // display the prompt
if (write32(1, pi.promptText.get(), pi.promptChars) == -1) if (! pi.write())
return -1; return -1;
#ifndef _WIN32 #ifndef _WIN32
@ -2264,11 +2323,22 @@ int InputBuffer::getInputLine(PromptBase& pi) {
int c; int c;
if (terminatingKeystroke == -1) { if (terminatingKeystroke == -1) {
c = linenoiseReadChar(); // get a new keystroke c = linenoiseReadChar(); // get a new keystroke
#ifndef _WIN32
if (c == 0 && gotResize) {
// caught a window resize event
// now redraw the prompt and line
gotResize = false;
pi.promptScreenColumns = getScreenColumns();
dynamicRefresh(pi, buf32, len, pos); // redraw the original prompt with current input
continue;
}
#endif
} else { } else {
c = terminatingKeystroke; // use the terminating keystroke from search c = terminatingKeystroke; // use the terminating keystroke from search
terminatingKeystroke = -1; // clear it once we've used it terminatingKeystroke = -1; // clear it once we've used it
} }
c = cleanupCtrl(c); // convert CTRL + <char> into normal ctrl c = cleanupCtrl(c); // convert CTRL + <char> into normal ctrl
if (c == 0) { if (c == 0) {
@ -2281,7 +2351,7 @@ int InputBuffer::getInputLine(PromptBase& pi) {
} }
if (c == -2) { if (c == -2) {
if (write32(1, pi.promptText.get(), pi.promptChars) == -1) if (! pi.write())
return -1; return -1;
refreshLine(pi); refreshLine(pi);
continue; continue;
@ -2707,7 +2777,7 @@ int InputBuffer::getInputLine(PromptBase& pi) {
disableRawMode(); // Returning to Linux (whatever) shell, leave raw mode disableRawMode(); // Returning to Linux (whatever) shell, leave raw mode
raise(SIGSTOP); // Break out in mid-line raise(SIGSTOP); // Break out in mid-line
enableRawMode(); // Back from Linux shell, re-enter raw mode enableRawMode(); // Back from Linux shell, re-enter raw mode
if (write32(1, pi.promptText.get(), pi.promptChars) == -1) if (! pi.write())
break; // Redraw prompt break; // Redraw prompt
refreshLine(pi); // Refresh the line refreshLine(pi); // Refresh the line
break; break;
@ -2869,6 +2939,9 @@ void linenoisePreloadBuffer(const char* preloadText) {
* memory leaks * memory leaks
*/ */
char* linenoise(const char* prompt) { char* linenoise(const char* prompt) {
#ifndef _WIN32
gotResize = false;
#endif
if (isatty(STDIN_FILENO)) { // input is from a terminal if (isatty(STDIN_FILENO)) { // input is from a terminal
char32_t buf32[LINENOISE_MAX_LINE]; char32_t buf32[LINENOISE_MAX_LINE];
char charWidths[LINENOISE_MAX_LINE]; char charWidths[LINENOISE_MAX_LINE];
@ -2879,7 +2952,7 @@ char* linenoise(const char* prompt) {
} }
PromptInfo pi(prompt, getScreenColumns()); PromptInfo pi(prompt, getScreenColumns());
if (isUnsupportedTerm()) { if (isUnsupportedTerm()) {
if (write32(1, pi.promptText.get(), pi.promptChars) == -1) if (! pi.write())
return 0; return 0;
fflush(stdout); fflush(stdout);
if (preloadedBufferContents.empty()) { if (preloadedBufferContents.empty()) {
@ -3058,3 +3131,23 @@ int linenoiseHistoryLoad(const char* filename) {
return 0; return 0;
} }
#ifndef _WIN32
static void WindowSizeChanged(int) {
// do nothing here but setting this flag
gotResize = true;
}
#endif
int linenoiseInstallWindowChangeHandler(void) {
#ifndef _WIN32
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = &WindowSizeChanged;
if (sigaction(SIGWINCH, &sa, nullptr) == -1) {
return errno;
}
#endif
return 0;
}

View File

@ -1,6 +1,10 @@
v2.8.0 (XXXX-XX-XX) v2.8.0 (XXXX-XX-XX)
------------------- -------------------
* added startup option `--server.hide-product-header` to make the server not send
the HTTP response header `"Server: ArangoDB"` in its HTTP responses. By default,
the option is turned off so the header is still sent as usual.
* added new AQL function `UNSET_RECURSIVE` to recursively unset attritutes from * added new AQL function `UNSET_RECURSIVE` to recursively unset attritutes from
objects/documents objects/documents

View File

@ -797,6 +797,12 @@ endif ()
if (MSVC) if (MSVC)
install_readme(LICENSE . LICENSE.txt) install_readme(LICENSE . LICENSE.txt)
install_readme(LICENSES-OTHER-COMPONENTS.md . LICENSES-OTHER-COMPONENTS.md)
else ()
install_readme(README share/doc/arangodb README)
install_readme(README.md share/doc/arangodb README.md)
install_readme(LICENSE share/doc/arangodb LICENSE)
install_readme(LICENSES-OTHER-COMPONENTS.md share/doc/arangodb LICENSES-OTHER-COMPONENTS.md)
endif () endif ()
## ----------------------------------------------------------------------------- ## -----------------------------------------------------------------------------
@ -908,8 +914,6 @@ if (MSVC)
SET(BITS 32) SET(BITS 32)
endif() endif()
message(STATUS "ARANGO_IMG: ${ARANGO_IMG}") message(STATUS "ARANGO_IMG: ${ARANGO_IMG}")
message(STATUS "ARANGO_ICON: ${ARANGO_ICON}") message(STATUS "ARANGO_ICON: ${ARANGO_ICON}")
message(STATUS "RELATIVE_ARANGO_ICON: ${RELATIVE_ARANGO_ICON}") message(STATUS "RELATIVE_ARANGO_ICON: ${RELATIVE_ARANGO_ICON}")

View File

@ -8,24 +8,26 @@ instead.
!SECTION Determining direct connections !SECTION Determining direct connections
- *EDGES(edgecollection, startvertex, direction, edgeexamples, options)*: !SUBSECTION Edges
Return all edges connected to the vertex *startvertex* as an array. The possible values for *EDGES(edgecollection, startvertex, direction, edgeexamples, options)*:
*direction* are:
Return all edges connected to the vertex *startvertex* as an array. The possible values for
*direction* are:
- *outbound*: Return all outbound edges - *outbound*: Return all outbound edges
- *inbound*: Return all inbound edges - *inbound*: Return all inbound edges
- *any*: Return outbound and inbound edges - *any*: Return outbound and inbound edges
The *edgeexamples* parameter can optionally be used to restrict the results to specific The *edgeexamples* parameter can optionally be used to restrict the results to specific
edge connections only. The matching is then done via the *MATCHES* function. edge connections only. The matching is then done via the *MATCHES* function.
To not restrict the result to specific connections, *edgeexamples* should be left To not restrict the result to specific connections, *edgeexamples* should be left
unspecified. unspecified.
Options is a JSON object that can contain the following properties: Options is a JSON object that can contain the following properties:
- *includeVertices*: A boolean value, when set to true the return format will be modified. - *includeVertices*: A boolean value, when set to true the return format will be modified.
The function will then return an object with two attributes *edge* and *vertex* containing The function will then return an object with two attributes *edge* and *vertex* containing
the respective elements. the respective elements.
In order to specify only options but no *edgeExamples* set *edgeExamples* to *null*. In order to specify only options but no *edgeExamples* set *edgeExamples* to *null*.
*Examples* *Examples*
@ -35,31 +37,33 @@ instead.
EDGES(friendrelations, "friends/john", "any", null, {includeVertices: true}) EDGES(friendrelations, "friends/john", "any", null, {includeVertices: true})
- *NEIGHBORS(vertexcollection, edgecollection, startvertex, direction, edgeexamples, options)*: !SUBSECTION Neighbors
Returns `_id` values of all distinct neighbors that are directly connected to the *NEIGHBORS(vertexcollection, edgecollection, startvertex, direction, edgeexamples, options)*:
vertex *startvertex* as an array.
The possible values for *direction* are:
- *outbound*: Return all outbound edges
- *inbound*: Return all inbound edges
- *any*: Return outbound and inbound edges
The *edgeexamples* parameter can optionally be used to restrict the results to specific Returns `_id` values of all distinct neighbors that are directly connected to the
edge connections only. The matching is then done via the *MATCHES* function. vertex *startvertex* as an array.
To not restrict the result to specific connections, *edgeexamples* should be left
unspecified.
The *options* parameter is an object and used to modify the result. The possible values for *direction* are:
Available options: - *outbound*: Return all outbound edges
- *inbound*: Return all inbound edges
- *any*: Return outbound and inbound edges
* *includeData* is a boolean value to define if the returned documents should be extracted instead The *edgeexamples* parameter can optionally be used to restrict the results to specific
of returning their ids only. The default is *false*. edge connections only. The matching is then done via the *MATCHES* function.
To not restrict the result to specific connections, *edgeexamples* should be left
unspecified.
Note: in ArangoDB versions prior to 2.6 *NEIGHBORS* returned the array of neighbor vertices together The *options* parameter is an object and used to modify the result.
with their connecting edges including all attributes and not only the ids. Available options:
To include the data and not only the ids set the *includeData* option to *true* in 2.6 and above.
To create the result format of 2.5 and earlier please replace the NEIGHBORS function by EDGES * *includeData* is a boolean value to define if the returned documents should be extracted instead
with the option *includeVertices* set to true. of returning their ids only. The default is *false*.
Note: in ArangoDB versions prior to 2.6 *NEIGHBORS* returned the array of neighbor vertices together
with their connecting edges including all attributes and not only the ids.
To include the data and not only the ids set the *includeData* option to *true* in 2.6 and above.
To create the result format of 2.5 and earlier please replace the NEIGHBORS function by EDGES
with the option *includeVertices* set to true.
*Examples* *Examples*
@ -70,148 +74,149 @@ instead.
!SECTION General-purpose traversals !SECTION General-purpose traversals
- *TRAVERSAL(vertexcollection, edgecollection, startVertex, direction, options)*: !SUBSECTION Traversal
Traverses the graph described by *vertexcollection* and *edgecollection*, *TRAVERSAL(vertexcollection, edgecollection, startVertex, direction, options)*:
starting at the vertex identified by id *startVertex*. Vertex connectivity is Traverses the graph described by *vertexcollection* and *edgecollection*,
specified by the *direction* parameter: starting at the vertex identified by id *startVertex*. Vertex connectivity is
- *"outbound"*: Vertices are connected in *_from* to *_to* order specified by the *direction* parameter:
- *"inbound"*: Vertices are connected in *_to* to *_from* order - *"outbound"*: Vertices are connected in *_from* to *_to* order
- *"any"*: Vertices are connected in both *_to* to *_from* and in - *"inbound"*: Vertices are connected in *_to* to *_from* order
*_from* to *_to* order - *"any"*: Vertices are connected in both *_to* to *_from* and in
*_from* to *_to* order
Additional options for the traversal can be provided via the *options* document: Additional options for the traversal can be provided via the *options* document:
- *strategy*: Defines the traversal strategy. Possible values are *depthfirst* - *strategy*: Defines the traversal strategy. Possible values are *depthfirst*
and *breadthfirst*. Defaults to *depthfirst* and *breadthfirst*. Defaults to *depthfirst*
- *order*: Defines the traversal order: Possible values are *preorder*, *postorder*, - *order*: Defines the traversal order: Possible values are *preorder*, *postorder*,
and *preorder-expander*. Defaults to *preorder* and *preorder-expander*. Defaults to *preorder*
- *itemOrder*: Defines the level item order. Can be *forward* or - *itemOrder*: Defines the level item order. Can be *forward* or
*backward*. Defaults to *forward* *backward*. Defaults to *forward*
- *minDepth*: Minimum path depths for vertices to be included. This can be used to - *minDepth*: Minimum path depths for vertices to be included. This can be used to
include only vertices in the result that are found after a certain minimum depth. include only vertices in the result that are found after a certain minimum depth.
Defaults to 0 Defaults to 0
- *maxIterations*: Maximum number of iterations in each traversal. This number can be - *maxIterations*: Maximum number of iterations in each traversal. This number can be
set to prevent endless loops in traversal of cyclic graphs. When a traversal performs set to prevent endless loops in traversal of cyclic graphs. When a traversal performs
as many iterations as the *maxIterations* value, the traversal will abort with an as many iterations as the *maxIterations* value, the traversal will abort with an
error. If *maxIterations* is not set, a server-defined value will be used error. If *maxIterations* is not set, a server-defined value will be used
- *maxDepth*: Maximum path depth for sub-edges expansion. This can be used to - *maxDepth*: Maximum path depth for sub-edges expansion. This can be used to
limit the depth of the traversal to a sensible amount. This should especially be used limit the depth of the traversal to a sensible amount. This should especially be used
for big graphs to limit the traversal to some sensible amount, and for graphs for big graphs to limit the traversal to some sensible amount, and for graphs
containing cycles to prevent infinite traversals. The maximum depth defaults to 256, containing cycles to prevent infinite traversals. The maximum depth defaults to 256,
with the chance of this value being non-sensical. For several graphs, a much lower with the chance of this value being non-sensical. For several graphs, a much lower
maximum depth is sensible, whereas for other, more array-oriented graphs a higher maximum depth is sensible, whereas for other, more array-oriented graphs a higher
depth should be used depth should be used
- *paths*: If *true*, the paths encountered during the traversal will - *paths*: If *true*, the paths encountered during the traversal will
also be returned along with each traversed vertex. If *false*, only the also be returned along with each traversed vertex. If *false*, only the
encountered vertices will be returned. encountered vertices will be returned.
- *uniqueness*: An optional document with the following attributes: - *uniqueness*: An optional document with the following attributes:
- *vertices*: - *vertices*:
- *none*: No vertex uniqueness is enforced - *none*: No vertex uniqueness is enforced
- *global*: A vertex may be visited at most once. This is the default. - *global*: A vertex may be visited at most once. This is the default.
- *path*: A vertex is visited only if not already contained in the current - *path*: A vertex is visited only if not already contained in the current
traversal path traversal path
- *edges*: - *edges*:
- *none*: No edge uniqueness is enforced - *none*: No edge uniqueness is enforced
- *global*: An edge may be visited at most once. This is the default - *global*: An edge may be visited at most once. This is the default
- *path*: An edge is visited only if not already contained in the current - *path*: An edge is visited only if not already contained in the current
traversal path traversal path
- *followEdges*: An optional array of example edge documents that the traversal will - *followEdges*: An optional array of example edge documents that the traversal will
expand into. If no examples are given, the traversal will follow all edges. If one expand into. If no examples are given, the traversal will follow all edges. If one
or many edge examples are given, the traversal will only follow an edge if it matches or many edge examples are given, the traversal will only follow an edge if it matches
at least one of the specified examples. *followEdges* can also be a string with the at least one of the specified examples. *followEdges* can also be a string with the
name of an AQL user-defined function that should be responsible for checking if an name of an AQL user-defined function that should be responsible for checking if an
edge should be followed. In this case, the AQL function will is expected to have the edge should be followed. In this case, the AQL function will is expected to have the
following signature: following signature:
function (config, vertex, edge, path) function (config, vertex, edge, path)
The function is expected to return a boolean value. If it returns *true*, the edge The function is expected to return a boolean value. If it returns *true*, the edge
will be followed. If *false* is returned, the edge will be ignored. will be followed. If *false* is returned, the edge will be ignored.
- *filterVertices*: An optional array of example vertex documents that the traversal will - *filterVertices*: An optional array of example vertex documents that the traversal will
treat specially. If no examples are given, the traversal will handle all encountered treat specially. If no examples are given, the traversal will handle all encountered
vertices equally. If one or many vertex examples are given, the traversal will exclude vertices equally. If one or many vertex examples are given, the traversal will exclude
any non-matching vertex from the result and/or not descend into it. Optionally, any non-matching vertex from the result and/or not descend into it. Optionally,
*filterVertices* can contain a string containing the name of a user-defined AQL function *filterVertices* can contain a string containing the name of a user-defined AQL function
that should be responsible for filtering. If so, the AQL function is expected to have the that should be responsible for filtering. If so, the AQL function is expected to have the
following signature: following signature:
function (config, vertex, path) function (config, vertex, path)
If a custom AQL function is used for *filterVertices*, it is expected to return one of If a custom AQL function is used for *filterVertices*, it is expected to return one of
the following values: the following values:
- *[ ]*: Include the vertex in the result and descend into its connected edges - *[ ]*: Include the vertex in the result and descend into its connected edges
- *[ "prune" ]*: Will include the vertex in the result but not descend into its connected edges - *[ "prune" ]*: Will include the vertex in the result but not descend into its connected edges
- *[ "exclude" ]*: Will not include the vertex in the result but descend into its connected edges - *[ "exclude" ]*: Will not include the vertex in the result but descend into its connected edges
- *[ "prune", "exclude" ]*: Will completely ignore the vertex and its connected edges - *[ "prune", "exclude" ]*: Will completely ignore the vertex and its connected edges
- *vertexFilterMethod*: Only useful in conjunction with *filterVertices* and if no user-defined - *vertexFilterMethod*: Only useful in conjunction with *filterVertices* and if no user-defined
AQL function is used. If specified, it will influence how vertices are handled that don't match AQL function is used. If specified, it will influence how vertices are handled that don't match
the examples in *filterVertices*: the examples in *filterVertices*:
- *[ "prune" ]*: Will include non-matching vertices in the result but not descend into them - *[ "prune" ]*: Will include non-matching vertices in the result but not descend into them
- *[ "exclude" ]*: Will not include non-matching vertices in the result but descend into them - *[ "exclude" ]*: Will not include non-matching vertices in the result but descend into them
- *[ "prune", "exclude" ]*: Will completely ignore the vertex and its connected edges - *[ "prune", "exclude" ]*: Will completely ignore the vertex and its connected edges
- *visitor*: If specified, must be a string containing the name of a custom AQL function that - *visitor*: If specified, must be a string containing the name of a custom AQL function that
will be called whenever the traversal visits a vertex. The custom AQL function is expected will be called whenever the traversal visits a vertex. The custom AQL function is expected
to have the following signature: to have the following signature:
function (config, result, vertex, path, connections) function (config, result, vertex, path, connections)
There are two modes for custom AQL visitor functions, depending on the value of the option There are two modes for custom AQL visitor functions, depending on the value of the option
*visitorReturnsResults*. If it is set to *true*, then any value returned by the visitor will *visitorReturnsResults*. If it is set to *true*, then any value returned by the visitor will
be appended to the list of results of the TRAVERSAL function. If *visitorReturnsResults* is be appended to the list of results of the TRAVERSAL function. If *visitorReturnsResults* is
set to *false*, then any value returned by the custom visitor function will be ignored. set to *false*, then any value returned by the custom visitor function will be ignored.
Instead, the visitor function is allowed to modify its *result* function parameter value Instead, the visitor function is allowed to modify its *result* function parameter value
in-place. The contents of this variable at the end of the traversal will then be the in-place. The contents of this variable at the end of the traversal will then be the
results of the TRAVERSAL function. results of the TRAVERSAL function.
Note: The *connections* function parameter value will contain the edges connected to the Note: The *connections* function parameter value will contain the edges connected to the
vertex only if *order* was set to *preorder-expander*. Otherwise, the value of this parameter vertex only if *order* was set to *preorder-expander*. Otherwise, the value of this parameter
will be *undefined*. will be *undefined*.
The following custom visitor functions are predefined and can be used by specifying the function The following custom visitor functions are predefined and can be used by specifying the function
name in the *visitor* attribute: name in the *visitor* attribute:
- *"_AQL::HASATTRIBUTESVISITOR"*: this visitor will produce an object if it contains the - *"_AQL::HASATTRIBUTESVISITOR"*: this visitor will produce an object if it contains the
attributes specified in *data.attributes* for each visited vertex. If *data.type* is *"all"*, attributes specified in *data.attributes* for each visited vertex. If *data.type* is *"all"*,
then the object will only be returned if all specified attributes are present in the vertex, then the object will only be returned if all specified attributes are present in the vertex,
if *data.type* is *"any"*, the object will be returned if the vertex contains any of the if *data.type* is *"any"*, the object will be returned if the vertex contains any of the
specified attributes. If the optional *data.allowNull* is set to `false`, then the object specified attributes. If the optional *data.allowNull* is set to `false`, then the object
will only be returned if an attribute is present **and** does not contain a `null` value. will only be returned if an attribute is present **and** does not contain a `null` value.
Otherwise an object will be returned already if the attribute is present. Otherwise an object will be returned already if the attribute is present.
- *"_AQL::PROJECTINGVISITOR"*: this visitor will produce an object with the attributes - *"_AQL::PROJECTINGVISITOR"*: this visitor will produce an object with the attributes
specified in *data.attributes* for each visited vertex. This can be used to create a specified in *data.attributes* for each visited vertex. This can be used to create a
projection of each visited vertex' document. projection of each visited vertex' document.
- *"_AQL::IDVISITOR"*: this visitor will return the _id attribute of each visited vertex. - *"_AQL::IDVISITOR"*: this visitor will return the _id attribute of each visited vertex.
- *"_AQL::KEYVISITOR"*: this visitor will return the _key attribute of each visited vertex. - *"_AQL::KEYVISITOR"*: this visitor will return the _key attribute of each visited vertex.
- *"_AQL::COUNTINGVISITOR"*: this visitor will return a single number indicating the number - *"_AQL::COUNTINGVISITOR"*: this visitor will return a single number indicating the number
of vertices visited. of vertices visited.
- *visitorReturnsResults*: only useful in combination with a custom AQL visitor function. If
set to *true*, the data returned by the visitor will be appended to the result. If set to
*false*, any return value of the visitor function will be ignored. Instead, the visitor
function can modify its *result* parameter value in-place. At the end of the traversal,
*result* is expected to be an array.
- *data*: only useful in combination with custom AQL visitor or filter functions. This attribute can
be used to pass arbitrary data into the custom visitor function. The value contained in the
*data* attribute will be made available to the *visitor* and *filterVertices* functions in the *config.data*
attribute.
By default, the result of the TRAVERSAL function is an array of traversed points. Each point - *visitorReturnsResults*: only useful in combination with a custom AQL visitor function. If
is an object consisting of the following attributes: set to *true*, the data returned by the visitor will be appended to the result. If set to
*false*, any return value of the visitor function will be ignored. Instead, the visitor
function can modify its *result* parameter value in-place. At the end of the traversal,
*result* is expected to be an array.
- *vertex*: The vertex at the traversal point - *data*: only useful in combination with custom AQL visitor or filter functions. This attribute can
- *path*: The path history for the traversal point. The path is a document with the be used to pass arbitrary data into the custom visitor function. The value contained in the
attributes *vertices* and *edges*, which are both arrays. Note that *path* is only present *data* attribute will be made available to the *visitor* and *filterVertices* functions in the *config.data*
in the result if the *paths* attribute is set in the *options* attribute.
When using a custom AQL function as a visitor, the result may have a different structure. By default, the result of the TRAVERSAL function is an array of traversed points. Each point
is an object consisting of the following attributes:
- *vertex*: The vertex at the traversal point
- *path*: The path history for the traversal point. The path is a document with the
attributes *vertices* and *edges*, which are both arrays. Note that *path* is only present
in the result if the *paths* attribute is set in the *options*
When using a custom AQL function as a visitor, the result may have a different structure.
*Examples* *Examples*
@ -317,17 +322,17 @@ instead.
data: { attributes: [ "_id", "_key", "name" ] } data: { attributes: [ "_id", "_key", "name" ] }
}) })
!SUBSECTION Traversal Tree
*TRAVERSAL_TREE(vertexcollection, edgecollection, startVertex, direction, connectName, options)*:
Traverses the graph described by *vertexcollection* and *edgecollection*,
starting at the vertex identified by id *startVertex* and creates a hierarchical result.
Vertex connectivity is establish by inserted an attribute which has the name specified via
the *connectName* parameter. Connected vertices will be placed in this attribute as an
array.
- *TRAVERSAL_TREE(vertexcollection, edgecollection, startVertex, direction, connectName, options)*: The *options* are the same as for the *TRAVERSAL* function, except that the result will
Traverses the graph described by *vertexcollection* and *edgecollection*, be set up in a way that resembles a depth-first, pre-order visitation result. Thus, the
starting at the vertex identified by id *startVertex* and creates a hierarchical result. *strategy* and *order* attributes of the *options* attribute will be ignored.
Vertex connectivity is establish by inserted an attribute which has the name specified via
the *connectName* parameter. Connected vertices will be placed in this attribute as an
array.
The *options* are the same as for the *TRAVERSAL* function, except that the result will
be set up in a way that resembles a depth-first, pre-order visitation result. Thus, the
*strategy* and *order* attributes of the *options* attribute will be ignored.
*Examples* *Examples*
@ -335,113 +340,113 @@ instead.
itemOrder: "forward" itemOrder: "forward"
}) })
!SUBSECTION Shortest Path
*SHORTEST_PATH(vertexcollection, edgecollection, startVertex, endVertex, direction, options)*:
Determines the first shortest path from the *startVertex* to the *endVertex*.
Both vertices must be present in the vertex collection specified in *vertexcollection*,
and any connecting edges must be present in the collection specified by *edgecollection*.
Vertex connectivity is specified by the *direction* parameter:
- *"outbound"*: Vertices are connected in *_from* to *_to* order
- *"inbound"*: Vertices are connected in *_to* to *_from* order
- *"any"*: Vertices are connected in both *_to* to *_from* and in
*_from* to *_to* order
The search is aborted when a shortest path is found. Only the first shortest path will be
returned. Any vertex will be visited at most once by the search.
- *SHORTEST_PATH(vertexcollection, edgecollection, startVertex, endVertex, direction, options)*: Additional options for the shortest path can be provided via the *options* document:
Determines the first shortest path from the *startVertex* to the *endVertex*. - *maxIterations*: Maximum number of iterations in the search. This number can be
Both vertices must be present in the vertex collection specified in *vertexcollection*, set to bound long-running searches. When a search performs as many iterations as the
and any connecting edges must be present in the collection specified by *edgecollection*. *maxIterations* value, the search will abort with an error. If *maxIterations* is not
Vertex connectivity is specified by the *direction* parameter: set, a server-defined value may be used.
- *"outbound"*: Vertices are connected in *_from* to *_to* order - *includeData*: Defines if the documents found on the path should be extracted or not.
- *"inbound"*: Vertices are connected in *_to* to *_from* order Default *false*, will only return the *\_id* values.
- *"any"*: Vertices are connected in both *_to* to *_from* and in - *distance*: This option can have two different types of values.
*_from* to *_to* order It can either be the name of an attribute.
The search is aborted when a shortest path is found. Only the first shortest path will be If so this specific attribute will be examined on every edge on the path and will
returned. Any vertex will be visited at most once by the search. be used as a distance. In order to let this work properly you have to make sure
to store only numerical values in this attribute. If the attribute is not present
on any edge the value given in the *defaultDistance* option is used as a replacement.
Using a distance attribute is only allowed in combination with *defaultDistance*.
The second type of value for this option is a custom function with the following signature:
Additional options for the shortest path can be provided via the *options* document: function (config, vertex1, vertex2, edge)
- *maxIterations*: Maximum number of iterations in the search. This number can be
set to bound long-running searches. When a search performs as many iterations as the
*maxIterations* value, the search will abort with an error. If *maxIterations* is not
set, a server-defined value may be used.
- *includeData*: Defines if the documents found on the path should be extracted or not.
Default *false*, will only return the *\_id* values.
- *distance*: This option can have two different types of values.
It can either be the name of an attribute.
If so this specific attribute will be examined on every edge on the path and will
be used as a distance. In order to let this work properly you have to make sure
to store only numerical values in this attribute. If the attribute is not present
on any edge the value given in the *defaultDistance* option is used as a replacement.
Using a distance attribute is only allowed in combination with *defaultDistance*.
The second type of value for this option is a custom function with the following signature:
function (config, vertex1, vertex2, edge) Both vertices and the connecting edge will be passed into the function. The function
is expected to return a numeric value that expresses the distance between the two
vertices. Higher values will mean higher distances, giving the connection a lower
priority in further analysis.
If this options is not specified all vertices are assumed to have the
same distance (1) to each other. If a function name is specified, it must have been
registered as a regular user-defined AQL function.
Both vertices and the connecting edge will be passed into the function. The function - *defaultDistance*: Only useful in combination with an attribute name given in *distance*.
is expected to return a numeric value that expresses the distance between the two If any edge does not have the attribute required for *distance* the numeric value
vertices. Higher values will mean higher distances, giving the connection a lower defined by this option is used.
priority in further analysis.
If this options is not specified all vertices are assumed to have the
same distance (1) to each other. If a function name is specified, it must have been
registered as a regular user-defined AQL function.
- *defaultDistance*: Only useful in combination with an attribute name given in *distance*. - *followEdges*: An optional array of example edge documents that the search will
If any edge does not have the attribute required for *distance* the numeric value expand into. If no examples are given, the search will follow all edges. If one
defined by this option is used. or many edge examples are given, the search will only follow an edge if it matches
at least one of the specified examples. *followEdges* can also be a string with the
name of an AQL user-defined function that should be responsible for checking if an
edge should be followed. In this case, the AQL function will is expected to have the
following signature:
- *followEdges*: An optional array of example edge documents that the search will function (config, vertex, edge, path)
expand into. If no examples are given, the search will follow all edges. If one
or many edge examples are given, the search will only follow an edge if it matches
at least one of the specified examples. *followEdges* can also be a string with the
name of an AQL user-defined function that should be responsible for checking if an
edge should be followed. In this case, the AQL function will is expected to have the
following signature:
function (config, vertex, edge, path) The function is expected to return a boolean value. If it returns *true*, the edge
will be followed. If *false* is returned, the edge will be ignored.
The function is expected to return a boolean value. If it returns *true*, the edge - *filterVertices*: An optional array of example vertex documents that the search will
will be followed. If *false* is returned, the edge will be ignored. treat specially. If no examples are given, the search will handle all encountered
vertices equally. If one or many vertex examples are given, the search will exclude
the vertex from the result and/or not descend into it. Optionally, *filterVertices* can
be a string containing the name of a user-defined AQL function that should be responsible
for filtering. If so, the custom AQL function is expected to have the following signature:
- *filterVertices*: An optional array of example vertex documents that the search will function (config, vertex, path)
treat specially. If no examples are given, the search will handle all encountered
vertices equally. If one or many vertex examples are given, the search will exclude
the vertex from the result and/or not descend into it. Optionally, *filterVertices* can
be a string containing the name of a user-defined AQL function that should be responsible
for filtering. If so, the custom AQL function is expected to have the following signature:
function (config, vertex, path) If a custom AQL function is used, it is expected to return one of the following values:
If a custom AQL function is used, it is expected to return one of the following values: - *[ ]*: Include the vertex in the result and descend into its connected edges
- *[ "prune" ]*: Will include the vertex in the result but not descend into its connected edges
- *[ "exclude" ]*: Will not include the vertex in the result but descend into its connected edges
- *[ "prune", "exclude" ]*: Will completely ignore the vertex and its connected edges
- *[ ]*: Include the vertex in the result and descend into its connected edges - *visitor*: If specified, must be a string containing the name of a custom AQL function that
- *[ "prune" ]*: Will include the vertex in the result but not descend into its connected edges will be called whenever the traversal visits a vertex. The custom AQL function is expected
- *[ "exclude" ]*: Will not include the vertex in the result but descend into its connected edges to have the following signature:
- *[ "prune", "exclude" ]*: Will completely ignore the vertex and its connected edges
- *visitor*: If specified, must be a string containing the name of a custom AQL function that
will be called whenever the traversal visits a vertex. The custom AQL function is expected
to have the following signature:
function (config, result, vertex, path, connections) function (config, result, vertex, path, connections)
There are two modes for custom AQL visitor functions, depending on the value of the option There are two modes for custom AQL visitor functions, depending on the value of the option
*visitorReturnsResults*. If it is set to *true*, then any value returned by the visitor will *visitorReturnsResults*. If it is set to *true*, then any value returned by the visitor will
be appended to the list of results of the TRAVERSAL function. If *visitorReturnsResults* is be appended to the list of results of the TRAVERSAL function. If *visitorReturnsResults* is
set to *false*, then any value returned by the custom visitor function will be ignored. set to *false*, then any value returned by the custom visitor function will be ignored.
Instead, the visitor function is allowed to modify its *result* function parameter value Instead, the visitor function is allowed to modify its *result* function parameter value
in-place. The contents of this variable at the end of the traversal will then be the in-place. The contents of this variable at the end of the traversal will then be the
results of the TRAVERSAL function. results of the TRAVERSAL function.
Note: The *connections* function parameter value will contain the edges connected to the Note: The *connections* function parameter value will contain the edges connected to the
vertex only if *order* was set to *preorder-expander*. Otherwise, the value of this parameter vertex only if *order* was set to *preorder-expander*. Otherwise, the value of this parameter
will be *undefined*. will be *undefined*.
- *visitorReturnsResults*: only useful in combination with a custom AQL visitor function. If - *visitorReturnsResults*: only useful in combination with a custom AQL visitor function. If
set to *true*, the data returned by the visitor will be appended to the result. If set to set to *true*, the data returned by the visitor will be appended to the result. If set to
*false*, any return value of the visitor function will be ignored. Instead, the visitor *false*, any return value of the visitor function will be ignored. Instead, the visitor
function can modify its *result* parameter value in-place. At the end of the traversal, function can modify its *result* parameter value in-place. At the end of the traversal,
*result* is expected to be an array. *result* is expected to be an array.
- *data*: only useful in combination with custom AQL visitor or filter functions. This attribute can - *data*: only useful in combination with custom AQL visitor or filter functions. This attribute can
be used to pass arbitrary data into the custom visitor function. The value contained in the be used to pass arbitrary data into the custom visitor function. The value contained in the
*data* attribute will be made available to the *visitor* and *filterVertices* functions in the *config.data* *data* attribute will be made available to the *visitor* and *filterVertices* functions in the *config.data*
attribute. attribute.
By default, the result of the SHORTEST_PATH function is an object consisting of the following attributes: By default, the result of the SHORTEST_PATH function is an object consisting of the following attributes:
- *vertices*: The list of all vertices encountered on the path. - *vertices*: The list of all vertices encountered on the path.
- *edges*: The list of all edges encountered on the path. - *edges*: The list of all edges encountered on the path.
- *distance*: The total distance needed on this path. Using the given distance computation. - *distance*: The total distance needed on this path. Using the given distance computation.
When using a custom AQL function as a visitor, the result may have a different structure. When using a custom AQL function as a visitor, the result may have a different structure.
*Examples* *Examples*
@ -474,30 +479,30 @@ instead.
return (edge.underConstruction === false); // don't follow these edges return (edge.underConstruction === false); // don't follow these edges
}, false); }, false);
!SECTION Other functions !SECTION Other functions
- *PATHS(vertexcollection, edgecollection, direction, options)*: !SUBSECTION Paths
returns an array of paths through the graph defined by the nodes in the collection *PATHS(vertexcollection, edgecollection, direction, options)*:
*vertexcollection* and edges in the collection *edgecollection*. For each vertex returns an array of paths through the graph defined by the nodes in the collection
in *vertexcollection*, it will determine the paths through the graph depending on the *vertexcollection* and edges in the collection *edgecollection*. For each vertex
value of *direction*: in *vertexcollection*, it will determine the paths through the graph depending on the
- *"outbound"*: Follow all paths that start at the current vertex and lead to another vertex value of *direction*:
- *"inbound"*: Follow all paths that lead from another vertex to the current vertex - *"outbound"*: Follow all paths that start at the current vertex and lead to another vertex
- *"any"*: Combination of *"outbound"* and *"inbound"* - *"inbound"*: Follow all paths that lead from another vertex to the current vertex
The default value for *direction* is *"outbound"*. - *"any"*: Combination of *"outbound"* and *"inbound"*
If specified, *options* must be a JavaScript object with the following optional attributes: The default value for *direction* is *"outbound"*.
- *minLength*: specifies the minimum length of the paths to be returned. The default is 0. If specified, *options* must be a JavaScript object with the following optional attributes:
- *maxLength*: specifies the maximum length of the paths to be returned. The default is 10. - *minLength*: specifies the minimum length of the paths to be returned. The default is 0.
- *followcycles*: if true, cyclic paths will be followed as well. This is turned off by - *maxLength*: specifies the maximum length of the paths to be returned. The default is 10.
default. - *followcycles*: if true, cyclic paths will be followed as well. This is turned off by
default.
The result of the function is an array of paths. Paths of length 0 will also be returned. Each The result of the function is an array of paths. Paths of length 0 will also be returned. Each
path is a document consisting of the following attributes: path is a document consisting of the following attributes:
- *vertices*: array of vertices visited along the path - *vertices*: array of vertices visited along the path
- *edges*: array of edges visited along the path (may be empty) - *edges*: array of edges visited along the path (may be empty)
- *source*: start vertex of path - *source*: start vertex of path
- *destination*: destination vertex of path - *destination*: destination vertex of path
*Examples* *Examples*
@ -507,6 +512,18 @@ instead.
FILTER p.source._id == "users/123456" FILTER p.source._id == "users/123456"
RETURN p.vertices[*].name RETURN p.vertices[*].name
!SECTION Graph consistency
When [using the graph management functions to remove vertices](../GeneralGraphs/Management.md#remove-a-vertex)
you have the guaranty that all referencing edges are also removed.
However, if you use document features alone to remove vertices, no edge collections will be adjusted.
This results in an edge with its `_from` or `_to` attribute referring to vanished vertices.
Now we query such a graph using the [neighbors](#neighbors) or the [shortest path](#shortest-path) functions.
If *includeData* wasn't enabled, the referred missing vertex will not be queried, and thus the result
set will contain the referral to this missing vertex.
If *includeData* is enabled, these missing vertices will be touched by the query.
In order to keep the result set consistent between *includeData* enabled or disabled, a `null` will be padded to fill the gap for each missing vertex.
!SECTION Performance notes !SECTION Performance notes
@ -525,3 +542,5 @@ process is specified by the optional *maxIterations* configuration value. If the
vertices processed in a traversal reaches this cap will, the traversal will abort and throw vertices processed in a traversal reaches this cap will, the traversal will abort and throw
a *too many iterations* exception. a *too many iterations* exception.

View File

@ -32,6 +32,10 @@
@startDocuBlock serverDefaultApi @startDocuBlock serverDefaultApi
!SUBSECTION Hide Product header
@startDocuBlock serverHideProductHeader
!SUBSECTION Allow method override !SUBSECTION Allow method override
@startDocuBlock serverAllowMethod @startDocuBlock serverAllowMethod

View File

@ -93,55 +93,55 @@ These collections are called orphan collections.
If the graph is extended with an edge definition using one of the orphans, If the graph is extended with an edge definition using one of the orphans,
it will be removed from the set of orphan collection automatically. it will be removed from the set of orphan collection automatically.
!SUBSUBSECTION Add !SUBSUBSECTION Add a vertex collection
@startDocuBlock JSF_general_graph__addVertexCollection @startDocuBlock JSF_general_graph__addVertexCollection
!SUBSUBSECTION Get !SUBSUBSECTION Get the orphaned collections
@startDocuBlock JSF_general_graph__orphanCollections @startDocuBlock JSF_general_graph__orphanCollections
!SUBSUBSECTION Remove !SUBSUBSECTION Remove a vertex collection
@startDocuBlock JSF_general_graph__removeVertexCollection @startDocuBlock JSF_general_graph__removeVertexCollection
!SECTION Vertex !SECTION Maniuplating Vertices
!SUBSECTION Save !SUBSECTION Save a vertex
@startDocuBlock JSF_general_graph_vertex_collection_save @startDocuBlock JSF_general_graph_vertex_collection_save
!SUBSECTION Replace !SUBSECTION Replace a vertex
@startDocuBlock JSF_general_graph_vertex_collection_replace @startDocuBlock JSF_general_graph_vertex_collection_replace
!SUBSECTION Update !SUBSECTION Update a vertex
@startDocuBlock JSF_general_graph_vertex_collection_update @startDocuBlock JSF_general_graph_vertex_collection_update
!SUBSECTION Remove !SUBSECTION Remove a vertex
@startDocuBlock JSF_general_graph_vertex_collection_remove @startDocuBlock JSF_general_graph_vertex_collection_remove
!SECTION Edge !SECTION Manipulating Edges
!SUBSECTION Save !SUBSECTION Save a new edge
@startDocuBlock JSF_general_graph_edge_collection_save @startDocuBlock JSF_general_graph_edge_collection_save
!SUBSECTION Replace !SUBSECTION Replace an edge
@startDocuBlock JSF_general_graph_edge_collection_replace @startDocuBlock JSF_general_graph_edge_collection_replace
!SUBSECTION Update !SUBSECTION Update an edge
@startDocuBlock JSF_general_graph_edge_collection_update @startDocuBlock JSF_general_graph_edge_collection_update
!SUBSECTION Remove !SUBSECTION Remove an edge
@startDocuBlock JSF_general_graph_edge_collection_remove @startDocuBlock JSF_general_graph_edge_collection_remove
!SUBSECTION Connect !SUBSECTION Connect edges
@startDocuBlock JSF_general_graph_connectingEdges @startDocuBlock JSF_general_graph_connectingEdges

View File

@ -98,7 +98,9 @@ pack-dmg:
rm -rf Build && mkdir Build rm -rf Build && mkdir Build
./configure \ ./configure \
--prefix=/opt/arangodb --prefix=/opt/arangodb \
CPPFLAGS="-I`brew --prefix`/opt/openssl/include" \
LDFLAGS="-L`brew --prefix`/opt/openssl/lib"
${MAKE} pack-dmg-cmake ${MAKE} pack-dmg-cmake
@ -111,6 +113,9 @@ pack-dmg-cmake:
-D "CPACK_PACKAGE_VERSION_MINOR=${VERSION_MINOR}" \ -D "CPACK_PACKAGE_VERSION_MINOR=${VERSION_MINOR}" \
-D "CPACK_PACKAGE_VERSION_PATCH=${VERSION_PATCH}" \ -D "CPACK_PACKAGE_VERSION_PATCH=${VERSION_PATCH}" \
-D "LIBEV_VERSION=${LIBEV_VERSION}" \ -D "LIBEV_VERSION=${LIBEV_VERSION}" \
-D "OPENSSL_INCLUDE=`brew --prefix`/opt/openssl/include" \
-D "OPENSSL_LIB_PATH=`brew --prefix`/opt/openssl/lib" \
-D "OPENSSL_LIBS=`brew --prefix`/opt/openssl/lib/libssl.a;`brew --prefix`/opt/openssl/lib/libcrypto.a" \
-D "V8_VERSION=${V8_VERSION}" \ -D "V8_VERSION=${V8_VERSION}" \
-D "ZLIB_VERSION=${ZLIB_VERSION}" \ -D "ZLIB_VERSION=${ZLIB_VERSION}" \
.. ..
@ -145,7 +150,9 @@ pack-macosxcode:
rm -rf Build && mkdir Build rm -rf Build && mkdir Build
./configure \ ./configure \
--prefix=/opt/arangodb --prefix=/opt/arangodb \
CPPFLAGS="-I`brew --prefix`/opt/openssl/include" \
LDFLAGS="-L`brew --prefix`/opt/openssl/lib"
${MAKE} -f GNUMakefile pack-macosxcode-cmake MOREOPTS='$(MOREOPTS)' ${MAKE} -f GNUMakefile pack-macosxcode-cmake MOREOPTS='$(MOREOPTS)'
@ -159,6 +166,9 @@ pack-macosxcode-cmake:
-D "CPACK_PACKAGE_VERSION_MINOR=${VERSION_MINOR}" \ -D "CPACK_PACKAGE_VERSION_MINOR=${VERSION_MINOR}" \
-D "CPACK_PACKAGE_VERSION_PATCH=${VERSION_PATCH}" \ -D "CPACK_PACKAGE_VERSION_PATCH=${VERSION_PATCH}" \
-D "LIBEV_VERSION=${LIBEV_VERSION}" \ -D "LIBEV_VERSION=${LIBEV_VERSION}" \
-D "OPENSSL_INCLUDE=`brew --prefix`/opt/openssl/include" \
-D "OPENSSL_LIB_PATH=`brew --prefix`/opt/openssl/lib" \
-D "OPENSSL_LIBS=`brew --prefix`/opt/openssl/lib/libssl.a;`brew --prefix`/opt/openssl/lib/libcrypto.a" \
-D "V8_VERSION=${V8_VERSION}" \ -D "V8_VERSION=${V8_VERSION}" \
-D "ZLIB_VERSION=${ZLIB_VERSION}" \ -D "ZLIB_VERSION=${ZLIB_VERSION}" \
-G Xcode \ -G Xcode \
@ -180,7 +190,9 @@ pack-macosx:
rm -rf Build && mkdir Build rm -rf Build && mkdir Build
./configure \ ./configure \
--prefix=/opt/arangodb --prefix=/opt/arangodb \
CPPFLAGS="-I`brew --prefix`/opt/openssl/include" \
LDFLAGS="-L`brew --prefix`/opt/openssl/lib"
${MAKE} pack-macosx-cmake MOREOPTS='$(MOREOPTS)' ${MAKE} pack-macosx-cmake MOREOPTS='$(MOREOPTS)'
@ -193,6 +205,9 @@ pack-macosx-cmake:
-D "CPACK_PACKAGE_VERSION_MINOR=${VERSION_MINOR}" \ -D "CPACK_PACKAGE_VERSION_MINOR=${VERSION_MINOR}" \
-D "CPACK_PACKAGE_VERSION_PATCH=${VERSION_PATCH}" \ -D "CPACK_PACKAGE_VERSION_PATCH=${VERSION_PATCH}" \
-D "LIBEV_VERSION=${LIBEV_VERSION}" \ -D "LIBEV_VERSION=${LIBEV_VERSION}" \
-D "OPENSSL_INCLUDE=`brew --prefix`/opt/openssl/include" \
-D "OPENSSL_LIB_PATH=`brew --prefix`/opt/openssl/lib" \
-D "OPENSSL_LIBS=`brew --prefix`/opt/openssl/lib/libssl.a;`brew --prefix`/opt/openssl/lib/libcrypto.a" \
-D "V8_VERSION=${V8_VERSION}" \ -D "V8_VERSION=${V8_VERSION}" \
-D "ZLIB_VERSION=${ZLIB_VERSION}" \ -D "ZLIB_VERSION=${ZLIB_VERSION}" \
$(MOREOPTS) \ $(MOREOPTS) \

View File

@ -253,15 +253,16 @@ CLEANUP += @srcdir@/.file-list-js
### @brief /var data ### @brief /var data
################################################################################ ################################################################################
#if ENABLE_RELATIVE
#else
install-data-local: install-data-local:
test -d $(DESTDIR)$(TRI_LOCALSTATEDIR)/lib/arangodb || mkdir -p $(DESTDIR)$(TRI_LOCALSTATEDIR)/lib/arangodb test -d $(DESTDIR)$(TRI_LOCALSTATEDIR)/lib/arangodb || mkdir -p $(DESTDIR)$(TRI_LOCALSTATEDIR)/lib/arangodb
test -d $(DESTDIR)$(TRI_LOCALSTATEDIR)/lib/arangodb-apps || mkdir -p $(DESTDIR)$(TRI_LOCALSTATEDIR)/lib/arangodb-apps test -d $(DESTDIR)$(TRI_LOCALSTATEDIR)/lib/arangodb-apps || mkdir -p $(DESTDIR)$(TRI_LOCALSTATEDIR)/lib/arangodb-apps
test -d $(DESTDIR)$(TRI_LOCALSTATEDIR)/log/arangodb || mkdir -p $(DESTDIR)$(TRI_LOCALSTATEDIR)/log/arangodb test -d $(DESTDIR)$(TRI_LOCALSTATEDIR)/log/arangodb || mkdir -p $(DESTDIR)$(TRI_LOCALSTATEDIR)/log/arangodb
#endif ################################################################################
### @brief /doc
################################################################################
dist_doc_DATA = README README.md LICENSE LICENSES-OTHER-COMPONENTS.md
################################################################################ ################################################################################
### @brief symbolic links ### @brief symbolic links

View File

@ -156,7 +156,7 @@ describe ArangoDB do
# run a HTTP HEAD query on the existing document, with wrong precondition # run a HTTP HEAD query on the existing document, with wrong precondition
cmd = "/_api/document/" + did cmd = "/_api/document/" + did
doc = ArangoDB.log_head("#{prefix}-head-check-documentq", cmd, :header => { :"if-match" => "1" }) doc = ArangoDB.log_head("#{prefix}-head-check-document", cmd, :header => { :"if-match" => "1" })
doc.code.should eq(200) doc.code.should eq(200)
doc.response.body.should be_nil doc.response.body.should be_nil

View File

@ -2292,10 +2292,18 @@ AqlValue Functions::Neighbors (triagens::aql::Query* query,
} }
std::string const collectionName = vertexId.substr(0, split); std::string const collectionName = vertexId.substr(0, split);
if (collectionName.compare(vColName) != 0) {
THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_GRAPH_INVALID_PARAMETER,
"you specified vertex collection `%s` for start vertext from `%s`",
vColName.c_str(),
collectionName.c_str());
}
auto coli = resolver->getCollectionStruct(collectionName); auto coli = resolver->getCollectionStruct(collectionName);
if (coli == nullptr || collectionName.compare(vColName) != 0) { if (coli == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
"`%s`",
collectionName.c_str());
} }
VertexId v(coli->_cid, const_cast<char*>(str + split + 1)); VertexId v(coli->_cid, const_cast<char*>(str + split + 1));
@ -2320,10 +2328,18 @@ AqlValue Functions::Neighbors (triagens::aql::Query* query,
} }
std::string const collectionName = vertexId.substr(0, split); std::string const collectionName = vertexId.substr(0, split);
if (collectionName.compare(vColName) != 0) {
THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_GRAPH_INVALID_PARAMETER,
"you specified vertex collection `%s` for start vertext from `%s`",
vColName.c_str(),
collectionName.c_str());
}
auto coli = resolver->getCollectionStruct(collectionName); auto coli = resolver->getCollectionStruct(collectionName);
if (coli == nullptr || collectionName.compare(vColName) != 0) { if (coli == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
"`%s`",
collectionName.c_str());
} }
VertexId v(coli->_cid, const_cast<char*>(str + split + 1)); VertexId v(coli->_cid, const_cast<char*>(str + split + 1));
@ -2512,21 +2528,25 @@ AqlValue Functions::Near (triagens::aql::Query* query,
true, true,
true); true);
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION(res); THROW_ARANGO_EXCEPTION_FORMAT(res, "`%s`", colName.c_str());
} }
TRI_EnsureCollectionsTransaction(trx->getInternals()); TRI_EnsureCollectionsTransaction(trx->getInternals());
collection = trx->trxCollection(cid); collection = trx->trxCollection(cid);
if (collection == nullptr) { if (collection == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
"`%s`",
colName.c_str());
} }
} }
auto document = trx->documentCollection(cid); auto document = trx->documentCollection(cid);
if (document == nullptr) { if (document == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
"`%s`",
colName.c_str());
} }
triagens::arango::Index* index = nullptr; triagens::arango::Index* index = nullptr;
@ -2678,21 +2698,23 @@ AqlValue Functions::Within (triagens::aql::Query* query,
true, true,
true); true);
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION(res); THROW_ARANGO_EXCEPTION_FORMAT(res, "`%s`", colName.c_str());
} }
TRI_EnsureCollectionsTransaction(trx->getInternals()); TRI_EnsureCollectionsTransaction(trx->getInternals());
collection = trx->trxCollection(cid); collection = trx->trxCollection(cid);
if (collection == nullptr) { if (collection == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
"`%s`",
colName.c_str());
} }
} }
auto document = trx->documentCollection(cid); auto document = trx->documentCollection(cid);
if (document == nullptr) { if (document == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); /// TODO
} }
triagens::arango::Index* index = nullptr; triagens::arango::Index* index = nullptr;
@ -2965,7 +2987,9 @@ static void RegisterCollectionInTransaction (triagens::arango::AqlTransaction* t
TRI_ASSERT(collection == nullptr); TRI_ASSERT(collection == nullptr);
cid = trx->resolver()->getCollectionId(collectionName); cid = trx->resolver()->getCollectionId(collectionName);
if (cid == 0) { if (cid == 0) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
"`%s`",
collectionName.c_str());
} }
// ensure the collection is loaded // ensure the collection is loaded
collection = trx->trxCollection(cid); collection = trx->trxCollection(cid);
@ -2978,7 +3002,7 @@ static void RegisterCollectionInTransaction (triagens::arango::AqlTransaction* t
true, true,
true); true);
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION(res); THROW_ARANGO_EXCEPTION_FORMAT(res, "`%s`", collectionName.c_str());
} }
TRI_EnsureCollectionsTransaction(trx->getInternals()); TRI_EnsureCollectionsTransaction(trx->getInternals());
collection = trx->trxCollection(cid); collection = trx->trxCollection(cid);
@ -3219,7 +3243,9 @@ AqlValue Functions::Edges (triagens::aql::Query* query,
TRI_voc_cid_t startCid = resolver->getCollectionId(parts[0]); TRI_voc_cid_t startCid = resolver->getCollectionId(parts[0]);
if (startCid == 0) { if (startCid == 0) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
"`%s`",
parts[0].c_str());
} }
char* key = const_cast<char*>(parts[1].c_str()); char* key = const_cast<char*>(parts[1].c_str());

View File

@ -285,7 +285,7 @@ void RestSimpleHandler::removeByKeys (TRI_json_t const* json) {
{ {
auto const* value = TRI_LookupObjectJson(json, "options"); auto const* value = TRI_LookupObjectJson(json, "options");
if (TRI_IsObjectJson(value)) { if (TRI_IsObjectJson(value)) {
value = TRI_LookupObjectJson(json, "waitForSync"); value = TRI_LookupObjectJson(value, "waitForSync");
if (TRI_IsBooleanJson(value)) { if (TRI_IsBooleanJson(value)) {
waitForSync = value->_value._boolean; waitForSync = value->_value._boolean;
} }

View File

@ -601,6 +601,7 @@ void ArangoServer::buildApplicationServer () {
("server.allow-use-database", &ALLOW_USE_DATABASE_IN_REST_ACTIONS, "allow change of database in REST actions, only needed for unittests") ("server.allow-use-database", &ALLOW_USE_DATABASE_IN_REST_ACTIONS, "allow change of database in REST actions, only needed for unittests")
("server.threads", &_dispatcherThreads, "number of threads for basic operations") ("server.threads", &_dispatcherThreads, "number of threads for basic operations")
("server.additional-threads", &_additionalThreads, "number of threads in additional queues") ("server.additional-threads", &_additionalThreads, "number of threads in additional queues")
("server.hide-product-header", &HttpResponse::HideProductHeader, "do not expose \"Server: ArangoDB\" header in HTTP responses")
("server.foxx-queues", &_foxxQueues, "enable Foxx queues") ("server.foxx-queues", &_foxxQueues, "enable Foxx queues")
("server.foxx-queues-poll-interval", &_foxxQueuesPollInterval, "Foxx queue manager poll interval (in seconds)") ("server.foxx-queues-poll-interval", &_foxxQueuesPollInterval, "Foxx queue manager poll interval (in seconds)")
("server.session-timeout", &VocbaseContext::ServerSessionTtl, "timeout of web interface server sessions (in seconds)") ("server.session-timeout", &VocbaseContext::ServerSessionTtl, "timeout of web interface server sessions (in seconds)")

View File

@ -604,7 +604,7 @@ namespace triagens {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool _foxxQueues; bool _foxxQueues;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief poll interval for Foxx queues /// @brief poll interval for Foxx queues
/// @startDocuBlock foxxQueuesPollInterval /// @startDocuBlock foxxQueuesPollInterval

View File

@ -1728,7 +1728,7 @@ static bool RunScripts (v8::Isolate* isolate,
current->ForceSet(TRI_V8_ASCII_STRING("__dirname"), TRI_V8_STRING(dirname)); current->ForceSet(TRI_V8_ASCII_STRING("__dirname"), TRI_V8_STRING(dirname));
TRI_FreeString(TRI_CORE_MEM_ZONE, dirname); TRI_FreeString(TRI_CORE_MEM_ZONE, dirname);
TRI_ExecuteGlobalJavaScriptFile(isolate, scripts[i].c_str()); ok = TRI_ExecuteGlobalJavaScriptFile(isolate, scripts[i].c_str());
// restore old values for __dirname and __filename // restore old values for __dirname and __filename
if (oldFilename.IsEmpty() || oldFilename->IsUndefined()) { if (oldFilename.IsEmpty() || oldFilename->IsUndefined()) {
@ -1757,6 +1757,9 @@ static bool RunScripts (v8::Isolate* isolate,
ok = false; ok = false;
break; break;
} }
if (!ok) {
break;
}
} }
BaseClient.flushLog(); BaseClient.flushLog();

View File

@ -148,9 +148,6 @@ case $target in
armv7l-*-linux-gnueabihf) armv7l-*-linux-gnueabihf)
tr_ARM="yes" tr_ARM="yes"
tr_ARM7="yes" tr_ARM7="yes"
CFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS"
CPPFLAGS="$CPPFLAGS"
;; ;;
armv6l-*-linux-gnueabihf) armv6l-*-linux-gnueabihf)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7697,7 +7697,7 @@ var lessons = [
}, },
{ {
title: "Creating Documents", title: "Creating Documents",
text: "Now we have a collection, but it is still empty. So let's create some documents!\n\n" + text: "Now we have a collection, but it is empty. So let's create some documents!\n\n" +
" db.places.save({ _key : \"foo\", city : \"foo-city\" });\n" + " db.places.save({ _key : \"foo\", city : \"foo-city\" });\n" +
" for (i = 0; i <= 10; i++) { db.places.save({ _key: \"example\" + i, zipcode: i }) };" " for (i = 0; i <= 10; i++) { db.places.save({ _key: \"example\" + i, zipcode: i }) };"
}, },
@ -21639,7 +21639,7 @@ global.aqlQuery = function () {
for (i = 1; i < arguments.length; i++) { for (i = 1; i < arguments.length; i++) {
value = arguments[i]; value = arguments[i];
name = 'value' + (i - 1); name = 'value' + (i - 1);
if (value.constructor && value.constructor.name === 'ArangoCollection') { if (value && value.constructor && value.constructor.name === 'ArangoCollection') {
name = '@' + name; name = '@' + name;
value = value.name(); value = value.name();
} }

View File

@ -1,3 +1,3 @@
<script src="sharedLibs.js?version=1446219679364"></script> <script src="sharedLibs.js?version=1446837686877"></script>
<script src="libs.js?version=1446219679364"></script> <script src="libs.js?version=1446837686877"></script>
<script src="app.js?version=1446219679364"></script> <script src="app.js?version=1446837686877"></script>

View File

@ -2290,6 +2290,10 @@ if (list.length > 0) {
</div> </div>
<div id="aqlEditor" class='aql-editor'></div> <div id="aqlEditor" class='aql-editor'></div>
<div id="varsEditorHeader" class='vars-editor-header'>Bind parameters:
<i title='Example: </br> { </br>"@collection": "mycollection", </br>"key": "testkey"</br> } </br> Use bind parameters with @@collection and @key in your query' class="fa fa-info-circle"></i>
</div>
<div id="varsEditor" class='vars-editor'></div>
<div id="wideButtonDiv" class="wide-button-div"> <div id="wideButtonDiv" class="wide-button-div">
@ -2612,4 +2616,4 @@ var cutByResolution = function (str) {
<% }); %> <% }); %>
</ul> </ul>
</div> </div>
<% } %></script></head><body><nav class="navbar"><div class="resizecontainer"><div class="navlogo"><a class="logo" href="#"><img class="arangodbLogo" src="img/arangodb_logo_small.png"></a></div><div id="progressPlaceholderIcon"></div><div class="statmenu" id="statisticBar"></div><div class="usermenu" id="userBar" style="float:right"></div><div class="notificationmenu" id="notificationBar" style="float:right"></div><div class="navmenu" id="navigationBar"></div></div></nav><div class="centralRow resizecontainer"><div id="content" class="centralContent"></div></div><div id="modalPlaceholder"></div><div id="progressPlaceholder" style="display:none"></div><footer class="footer"><div class="resizecontainer" id="footerBar"></div></footer><script src="sharedLibs.js?version=1446219679364"></script><script src="libs.js?version=1446219679364"></script><script src="app.js?version=1446219679364"></script></body></html> <% } %></script></head><body><nav class="navbar"><div class="resizecontainer"><div class="navlogo"><a class="logo" href="#"><img class="arangodbLogo" src="img/arangodb_logo_small.png"></a></div><div id="progressPlaceholderIcon"></div><div class="statmenu" id="statisticBar"></div><div class="usermenu" id="userBar" style="float:right"></div><div class="notificationmenu" id="notificationBar" style="float:right"></div><div class="navmenu" id="navigationBar"></div></div></nav><div class="centralRow resizecontainer"><div id="content" class="centralContent"></div></div><div id="modalPlaceholder"></div><div id="progressPlaceholder" style="display:none"></div><footer class="footer"><div class="resizecontainer" id="footerBar"></div></footer><script src="sharedLibs.js?version=1446837686877"></script><script src="libs.js?version=1446837686877"></script><script src="app.js?version=1446837686877"></script></body></html>

View File

@ -2467,6 +2467,10 @@ if (list.length > 0) {
</div> </div>
<div id="aqlEditor" class='aql-editor'></div> <div id="aqlEditor" class='aql-editor'></div>
<div id="varsEditorHeader" class='vars-editor-header'>Bind parameters:
<i title='Example: </br> { </br>"@collection": "mycollection", </br>"key": "testkey"</br> } </br> Use bind parameters with @@collection and @key in your query' class="fa fa-info-circle"></i>
</div>
<div id="varsEditor" class='vars-editor'></div>
<div id="wideButtonDiv" class="wide-button-div"> <div id="wideButtonDiv" class="wide-button-div">
@ -2859,9 +2863,9 @@ var cutByResolution = function (str) {
</div> </div>
</footer> </footer>
<script src="sharedLibs.js?version=1446219679364"></script> <script src="sharedLibs.js?version=1446837686877"></script>
<script src="libs.js?version=1446219679364"></script> <script src="libs.js?version=1446837686877"></script>
<script src="app.js?version=1446219679364"></script> <script src="app.js?version=1446837686877"></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@ -6199,7 +6199,25 @@ toolbar {
.queryMethods button a { .queryMethods button a {
color: #fff; } color: #fff; }
.aql-editor { .vars-editor-header {
border-top: 1px solid rgba(140, 138, 137, 0.25);
margin-top: -5px;
padding-left: 5px; }
.vars-editor-header i {
border-radius: 2px;
color: #666;
height: 15px;
margin-left: 5px;
padding-left: 3px;
padding-top: 1px;
width: 15px; }
.vars-editor-header i:hover {
background-color: #8aa051;
color: #fff;
cursor: pointer; }
.aql-editor,
.vars-editor {
border-color: #a0a0a0; border-color: #a0a0a0;
border-left: 0 !important; border-left: 0 !important;
border-top: 1px solid rgba(140, 138, 137, 0.25) !important; border-top: 1px solid rgba(140, 138, 137, 0.25) !important;
@ -6209,7 +6227,9 @@ toolbar {
min-width: 99.8%; min-width: 99.8%;
width: auto; } width: auto; }
.aql-editor .ace_error, .aql-editor .ace_error,
.aql-editor .ace_info { .aql-editor .ace_info,
.vars-editor .ace_error,
.vars-editor .ace_info {
background: none; } background: none; }
.queryTH { .queryTH {
@ -6424,7 +6444,8 @@ toolbar {
position: relative; position: relative;
top: 0; top: 0;
width: 25px; } width: 25px; }
.editor-toolbar span:hover { .editor-toolbar span:hover,
.editor-toolbar .vars-editor-header i {
background-color: #8aa051; background-color: #8aa051;
color: #fff; } color: #fff; }
.editor-toolbar i { .editor-toolbar i {
@ -6433,11 +6454,13 @@ toolbar {
.editor-toolbar i:hover { .editor-toolbar i:hover {
cursor: pointer; } cursor: pointer; }
.editor-toolbar .fa { .editor-toolbar .fa {
color: #666;
margin-left: 1px; margin-left: 1px;
margin-top: 2px; } margin-top: 2px; }
.editor-toolbar .fa.fa-upload { .editor-toolbar .fa.fa-upload {
margin-top: 1px; } margin-top: 1px; }
.editor-toolbar .icon_arangodb { .editor-toolbar .icon_arangodb {
color: #666;
font-size: 14pt; } font-size: 14pt; }
.editor-toolbar .icon_arangodb:first-child { .editor-toolbar .icon_arangodb:first-child {
margin-right: 10px; } margin-right: 10px; }

View File

@ -53,8 +53,10 @@
var queries = []; var queries = [];
this.each(function(query) { this.each(function(query) {
console.log(query.attributes);
queries.push({ queries.push({
value: query.attributes.value, value: query.attributes.value,
parameter: query.attributes.parameter,
name: query.attributes.name name: query.attributes.name
}); });
}); });
@ -100,6 +102,7 @@
processData: false, processData: false,
success: function() { success: function() {
window.progressView.hide(); window.progressView.hide();
arangoHelper.arangoNotification("Queries successfully imported.");
callback(); callback();
}, },
error: function() { error: function() {

View File

@ -32,6 +32,10 @@
</div> </div>
<div id="aqlEditor" class='aql-editor'></div> <div id="aqlEditor" class='aql-editor'></div>
<div id="varsEditorHeader" class='vars-editor-header'>Bind parameters:
<i title='Example: </br> { </br>"@collection": "mycollection", </br>"key": "testkey"</br> } </br> Use bind parameters with @@collection and @key in your query' class="fa fa-info-circle"></i>
</div>
<div id="varsEditor" class='vars-editor'></div>
<div id="wideButtonDiv" class="wide-button-div"> <div id="wideButtonDiv" class="wide-button-div">

View File

@ -21,7 +21,6 @@
"click #result-switch": "switchTab", "click #result-switch": "switchTab",
"click #query-switch": "switchTab", "click #query-switch": "switchTab",
'click #customs-switch': "switchTab", 'click #customs-switch': "switchTab",
// 'click #explain-switch': "switchTab",
'click #submitQueryButton': 'submitQuery', 'click #submitQueryButton': 'submitQuery',
'click #explainQueryButton': 'explainQuery', 'click #explainQueryButton': 'explainQuery',
'click #commentText': 'commentText', 'click #commentText': 'commentText',
@ -87,6 +86,9 @@
_.each(this.tableDescription.rows, function(k) { _.each(this.tableDescription.rows, function(k) {
k.thirdRow = '<a class="deleteButton"><span class="icon_arangodb_roundminus"' + k.thirdRow = '<a class="deleteButton"><span class="icon_arangodb_roundminus"' +
' title="Delete query"></span></a>'; ' title="Delete query"></span></a>';
if (k.hasOwnProperty('parameter')) {
delete k.parameter;
}
}); });
// escape all columns but the third (which contains HTML) // escape all columns but the third (which contains HTML)
@ -96,9 +98,12 @@
}, },
editCustomQuery: function(e) { editCustomQuery: function(e) {
var queryName = $(e.target).parent().children().first().text(); var queryName = $(e.target).parent().children().first().text(),
var inputEditor = ace.edit("aqlEditor"); inputEditor = ace.edit("aqlEditor"),
varsEditor = ace.edit("varsEditor");
inputEditor.setValue(this.getCustomQueryValueByName(queryName)); inputEditor.setValue(this.getCustomQueryValueByName(queryName));
varsEditor.setValue(this.getCustomQueryParameterByName(queryName));
this.deselect(varsEditor);
this.deselect(inputEditor); this.deselect(inputEditor);
$('#querySelect').val(queryName); $('#querySelect').val(queryName);
this.switchTab("query-switch"); this.switchTab("query-switch");
@ -147,9 +152,11 @@
}, },
clearInput: function () { clearInput: function () {
var inputEditor = ace.edit("aqlEditor"); var inputEditor = ace.edit("aqlEditor"),
this.setCachedQuery(inputEditor.getValue()); varsEditor = ace.edit("varsEditor");
this.setCachedQuery(inputEditor.getValue(), varsEditor.getValue());
inputEditor.setValue(''); inputEditor.setValue('');
varsEditor.setValue('');
}, },
smallOutput: function () { smallOutput: function () {
@ -176,7 +183,6 @@
customQueries: [], customQueries: [],
tableDescription: { tableDescription: {
id: "arangoQueryTable", id: "arangoQueryTable",
titles: ["Name", "Content", ""], titles: ["Name", "Content", ""],
@ -220,17 +226,34 @@
multiSelectAction: "forEach" multiSelectAction: "forEach"
}); });
var varsEditor = ace.edit("varsEditor");
varsEditor.getSession().setMode("ace/mode/aql");
varsEditor.setFontSize("13px");
varsEditor.commands.addCommand({
name: "togglecomment",
bindKey: {win: "Ctrl-Shift-C", linux: "Ctrl-Shift-C", mac: "Command-Shift-C"},
exec: function (editor) {
editor.toggleCommentLines();
},
multiSelectAction: "forEach"
});
//get cached query if available //get cached query if available
var query = this.getCachedQuery(); var queryObject = this.getCachedQuery();
if (query !== null && query !== undefined && query !== "") { if (queryObject !== null && queryObject !== undefined && queryObject !== "") {
inputEditor.setValue(query); inputEditor.setValue(queryObject.query);
if (queryObject.parameter === '' || queryObject === undefined) {
varsEditor.setValue('{}');
}
else {
varsEditor.setValue(queryObject.parameter);
}
} }
inputEditor.getSession().selection.on('changeCursor', function () { var changedFunction = function() {
var inputEditor = ace.edit("aqlEditor"); var session = inputEditor.getSession(),
var session = inputEditor.getSession(); cursor = inputEditor.getCursorPosition(),
var cursor = inputEditor.getCursorPosition(); token = session.getTokenAt(cursor.row, cursor.column);
var token = session.getTokenAt(cursor.row, cursor.column);
if (token) { if (token) {
if (token.type === "comment") { if (token.type === "comment") {
$("#commentText i") $("#commentText i")
@ -245,8 +268,27 @@
} }
} }
//cache query in localstorage //cache query in localstorage
self.setCachedQuery(inputEditor.getValue()); var a = inputEditor.getValue(),
b = varsEditor.getValue();
if (a.length === 1) {
a = "";
}
if (b.length === 1) {
b = "";
}
self.setCachedQuery(a, b);
};
inputEditor.getSession().selection.on('changeCursor', function () {
changedFunction();
}); });
varsEditor.getSession().selection.on('changeCursor', function () {
changedFunction();
});
$('#queryOutput').resizable({ $('#queryOutput').resizable({
handles: "s", handles: "s",
ghost: true, ghost: true,
@ -258,12 +300,13 @@
} }
}); });
arangoHelper.fixTooltips(".queryTooltips, .icon_arangodb", "top"); arangoHelper.fixTooltips(".vars-editor-header i, .queryTooltips, .icon_arangodb", "top");
$('#aqlEditor .ace_text-input').focus(); $('#aqlEditor .ace_text-input').focus();
var windowHeight = $(window).height() - 295; var windowHeight = $(window).height() - 295;
$('#aqlEditor').height(windowHeight - 19); $('#aqlEditor').height(windowHeight - 100 - 29);
$('#varsEditor').height(100);
$('#queryOutput').height(windowHeight); $('#queryOutput').height(windowHeight);
inputEditor.resize(); inputEditor.resize();
@ -271,6 +314,7 @@
this.initTabArray(); this.initTabArray();
this.renderSelectboxes(); this.renderSelectboxes();
this.deselect(varsEditor);
this.deselect(outputEditor); this.deselect(outputEditor);
this.deselect(inputEditor); this.deselect(inputEditor);
@ -294,9 +338,13 @@
} }
}, },
setCachedQuery: function(query) { setCachedQuery: function(query, vars) {
if(typeof(Storage) !== "undefined") { if (typeof(Storage) !== "undefined") {
localStorage.setItem("cachedQuery", JSON.stringify(query)); var myObject = {
query: query,
parameter: vars
};
localStorage.setItem("cachedQuery", JSON.stringify(myObject));
} }
}, },
@ -345,7 +393,7 @@
exportCustomQueries: function () { exportCustomQueries: function () {
var name, toExport = {}, exportArray = []; var name, toExport = {}, exportArray = [];
_.each(this.customQueries, function(value, key) { _.each(this.customQueries, function(value, key) {
exportArray.push({name: value.name, value: value.value}); exportArray.push({name: value.name, value: value.value, parameter: value.parameter});
}); });
toExport = { toExport = {
"extra": { "extra": {
@ -446,7 +494,8 @@
this.collection.each(function(model) { this.collection.each(function(model) {
self.customQueries.push({ self.customQueries.push({
name: model.get("name"), name: model.get("name"),
value: model.get("value") value: model.get("value"),
parameter: model.get("parameter")
}); });
}); });
}, },
@ -457,8 +506,10 @@
//update queries first, before writing //update queries first, before writing
this.refreshAQL(); this.refreshAQL();
var inputEditor = ace.edit("aqlEditor"); var inputEditor = ace.edit("aqlEditor"),
var saveName = $('#new-query-name').val(); varsEditor = ace.edit("varsEditor"),
saveName = $('#new-query-name').val(),
bindVars = varsEditor.getValue();
if ($('#new-query-name').hasClass('invalid-input')) { if ($('#new-query-name').hasClass('invalid-input')) {
return; return;
@ -469,9 +520,9 @@
return; return;
} }
var content = inputEditor.getValue(); var content = inputEditor.getValue(),
//check for already existing entry //check for already existing entry
var quit = false; quit = false;
$.each(this.customQueries, function (k, v) { $.each(this.customQueries, function (k, v) {
if (v.name === saveName) { if (v.name === saveName) {
v.value = content; v.value = content;
@ -482,14 +533,21 @@
if (quit === true) { if (quit === true) {
//Heiko: Form-Validator - name already taken //Heiko: Form-Validator - name already taken
window.modalView.hide(); // Update model and save
return; this.collection.findWhere({name: saveName}).set("value", content);
}
else {
if (bindVars === '' || bindVars === undefined) {
bindVars = '{}';
}
this.collection.add({
name: saveName,
parameter: bindVars,
value: content
});
} }
this.collection.add({
name: saveName,
value: content
});
this.collection.saveCollectionQueries(); this.collection.saveCollectionQueries();
window.modalView.hide(); window.modalView.hide();
@ -518,13 +576,11 @@
}, },
getCustomQueryValueByName: function (qName) { getCustomQueryValueByName: function (qName) {
var returnVal; return this.collection.findWhere({name: qName}).get("value");
$.each(this.customQueries, function (k, v) { },
if (qName === v.name) {
returnVal = v.value; getCustomQueryParameterByName: function (qName) {
} return this.collection.findWhere({name: qName}).get("parameter");
});
return returnVal;
}, },
refreshAQL: function(select) { refreshAQL: function(select) {
@ -540,7 +596,8 @@
}, },
importSelected: function (e) { importSelected: function (e) {
var inputEditor = ace.edit("aqlEditor"); var inputEditor = ace.edit("aqlEditor"),
varsEditor = ace.edit("varsEditor");
$.each(this.queries, function (k, v) { $.each(this.queries, function (k, v) {
if ($('#' + e.currentTarget.id).val() === v.name) { if ($('#' + e.currentTarget.id).val() === v.name) {
inputEditor.setValue(v.value); inputEditor.setValue(v.value);
@ -549,6 +606,16 @@
$.each(this.customQueries, function (k, v) { $.each(this.customQueries, function (k, v) {
if ($('#' + e.currentTarget.id).val() === v.name) { if ($('#' + e.currentTarget.id).val() === v.name) {
inputEditor.setValue(v.value); inputEditor.setValue(v.value);
if (v.hasOwnProperty('parameter')) {
if (v.parameter === '' || v.parameter === undefined) {
v.parameter = '{}';
}
varsEditor.setValue(v.parameter);
}
else {
varsEditor.setValue('{}');
}
} }
}); });
@ -593,23 +660,9 @@
this.customQueries = _.sortBy(this.customQueries, 'name'); this.customQueries = _.sortBy(this.customQueries, 'name');
}, },
abortQuery: function () {
/*
$.ajax({
type: "DELETE",
url: "/_api/cursor/currentFrontendQuery",
contentType: "application/json",
processData: false,
success: function (data) {
},
error: function (data) {
}
});
*/
},
readQueryData: function() { readQueryData: function() {
var inputEditor = ace.edit("aqlEditor"); var inputEditor = ace.edit("aqlEditor");
var varsEditor = ace.edit("varsEditor");
var selectedText = inputEditor.session.getTextRange(inputEditor.getSelectionRange()); var selectedText = inputEditor.session.getTextRange(inputEditor.getSelectionRange());
var sizeBox = $('#querySize'); var sizeBox = $('#querySize');
var data = { var data = {
@ -617,6 +670,19 @@
batchSize: parseInt(sizeBox.val(), 10), batchSize: parseInt(sizeBox.val(), 10),
id: "currentFrontendQuery" id: "currentFrontendQuery"
}; };
var bindVars = varsEditor.getValue();
if (bindVars.length > 0) {
try {
var params = JSON.parse(bindVars);
if (Object.keys(params).length !== 0) {
data.bindVars = params;
}
}
catch (e) {
arangoHelper.arangoError("Query error", "Could not parse bind parameters.");
}
}
return JSON.stringify(data); return JSON.stringify(data);
}, },
@ -848,7 +914,6 @@
error: function (errObj) { error: function (errObj) {
var res = errObj.responseJSON; var res = errObj.responseJSON;
// Display ErrorMessage // Display ErrorMessage
console.log("Error:", res.errorMessage);
} }
}); });
*/ */
@ -931,7 +996,7 @@
try { try {
var temp = JSON.parse(data.responseText); var temp = JSON.parse(data.responseText);
outputEditor.setValue('[' + temp.errorNum + '] ' + temp.errorMessage); outputEditor.setValue('[' + temp.errorNum + '] ' + temp.errorMessage);
arangoHelper.arangoError("Query error", temp.errorNum, temp.errorMessage); //arangoHelper.arangoError("Query error", temp.errorMessage);
} }
catch (e) { catch (e) {
outputEditor.setValue('ERROR'); outputEditor.setValue('ERROR');

View File

@ -68,7 +68,31 @@ toolbar {
@extend %toolbar; @extend %toolbar;
} }
.aql-editor { .vars-editor-header {
border-top: 1px solid $c-content-border;
margin-top: -5px;
padding-left: 5px;
i {
border-radius: 2px;
color: $c-darker-grey;
height: 15px;
margin-left: 5px;
padding-left: 3px;
padding-top: 1px;
width: 15px;
}
i:hover {
background-color: $c-positive;
color: $c-white;
cursor: pointer;
}
}
.aql-editor,
.vars-editor {
@extend %toolbar; @extend %toolbar;
border-color: $c-editor-toolbar; border-color: $c-editor-toolbar;
border-left: 0 !important; border-left: 0 !important;
@ -376,7 +400,8 @@ toolbar {
width: 25px; width: 25px;
} }
span:hover { span:hover,
.vars-editor-header i {
background-color: $c-positive; background-color: $c-positive;
color: $c-white; color: $c-white;
} }
@ -391,6 +416,7 @@ toolbar {
} }
.fa { .fa {
color: $c-darker-grey;
margin-left: 1px; margin-left: 1px;
margin-top: 2px; margin-top: 2px;
@ -400,6 +426,7 @@ toolbar {
} }
.icon_arangodb { .icon_arangodb {
color: $c-darker-grey;
font-size: 14pt; font-size: 14pt;
&:first-child { &:first-child {

View File

@ -735,7 +735,7 @@ var loadGraph = function(name) {
} }
dropGraph(name); dropGraph(name);
knownGraphs[name](); return knownGraphs[name]();
}; };
exports.loadGraph = loadGraph; exports.loadGraph = loadGraph;

View File

@ -452,7 +452,7 @@ function ahuacatlQueryNeighborsTestSuite () {
actual = getQueryResults(queryStart + theFox + queryEnd); actual = getQueryResults(queryStart + theFox + queryEnd);
assertEqual(actual, [ ]); assertEqual(actual, [ ]);
assertQueryError(errors.ERROR_ARANGO_COLLECTION_NOT_FOUND.code, queryStart + "thefox/thefox" + queryEnd); assertQueryError(errors.ERROR_GRAPH_INVALID_PARAMETER.code, queryStart + "thefox/thefox" + queryEnd);
// Including Data // Including Data
actual = getRawQueryResults(queryStart + v3 + queryEndData); actual = getRawQueryResults(queryStart + v3 + queryEndData);
@ -504,7 +504,7 @@ function ahuacatlQueryNeighborsTestSuite () {
actual = getQueryResults(queryStart + theFox + queryEnd); actual = getQueryResults(queryStart + theFox + queryEnd);
assertEqual(actual, [ ]); assertEqual(actual, [ ]);
assertQueryError(errors.ERROR_ARANGO_COLLECTION_NOT_FOUND.code, queryStart + "thefox/thefox" + queryEnd); assertQueryError(errors.ERROR_GRAPH_INVALID_PARAMETER.code, queryStart + "thefox/thefox" + queryEnd);
// Inclunding Data // Inclunding Data
actual = getRawQueryResults(queryStart + v3 + queryEndData); actual = getRawQueryResults(queryStart + v3 + queryEndData);
@ -555,7 +555,7 @@ function ahuacatlQueryNeighborsTestSuite () {
actual = getQueryResults(queryStart + theFox + queryEnd); actual = getQueryResults(queryStart + theFox + queryEnd);
assertEqual(actual, [ ]); assertEqual(actual, [ ]);
assertQueryError(errors.ERROR_ARANGO_COLLECTION_NOT_FOUND.code, queryStart + "thefox/thefox" + queryEnd); assertQueryError(errors.ERROR_GRAPH_INVALID_PARAMETER.code, queryStart + "thefox/thefox" + queryEnd);
// Inclunding Data // Inclunding Data
actual = getRawQueryResults(queryStart + v3 + queryEndData); actual = getRawQueryResults(queryStart + v3 + queryEndData);

View File

@ -49,7 +49,6 @@ SET(LIB_ARANGO_CONSOLE
Utilities/LinenoiseShell.cpp Utilities/LinenoiseShell.cpp
) )
add_library( add_library(
${LIB_ARANGO} ${LIB_ARANGO}
STATIC STATIC

View File

@ -47,6 +47,12 @@ using namespace std;
std::string const HttpResponse::BatchErrorHeader = "X-Arango-Errors"; std::string const HttpResponse::BatchErrorHeader = "X-Arango-Errors";
////////////////////////////////////////////////////////////////////////////////
/// @brief hide header "Server: ArangoDB" in HTTP responses
////////////////////////////////////////////////////////////////////////////////
bool HttpResponse::HideProductHeader = false;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief http response string /// @brief http response string
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -266,7 +272,9 @@ HttpResponse::HttpResponse (HttpResponseCode code,
_bodySize(0), _bodySize(0),
_freeables() { _freeables() {
_headers.insert(TRI_CHAR_LENGTH_PAIR("server"), "ArangoDB"); if (! HideProductHeader) {
_headers.insert(TRI_CHAR_LENGTH_PAIR("server"), "ArangoDB");
}
_headers.insert(TRI_CHAR_LENGTH_PAIR("connection"), "Keep-Alive"); _headers.insert(TRI_CHAR_LENGTH_PAIR("connection"), "Keep-Alive");
_headers.insert(TRI_CHAR_LENGTH_PAIR("content-type"), "text/plain; charset=utf-8"); _headers.insert(TRI_CHAR_LENGTH_PAIR("content-type"), "text/plain; charset=utf-8");
} }

View File

@ -453,6 +453,21 @@ namespace triagens {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string const BatchErrorHeader; static std::string const BatchErrorHeader;
////////////////////////////////////////////////////////////////////////////////
/// @brief hide the "Server: ArangoDB" header in HTTP responses
/// @startDocuBlock serverHideProductHeader
/// `--server.hide-product-header`
///
/// If *true*, the server will exclude the HTTP header "Server: ArangoDB" in
/// HTTP responses. If set to *false*, the server will send the header in
/// responses.
///
/// The default is *false*.
/// @endDocuBlock
////////////////////////////////////////////////////////////////////////////////
static bool HideProductHeader;
}; };
} }
} }

View File

@ -82,6 +82,7 @@ LinenoiseShell::LinenoiseShell (std::string const& history,
: ShellBase(history, completer) { : ShellBase(history, completer) {
COMPLETER = completer; COMPLETER = completer;
linenoiseSetCompletionCallback(LinenoiseCompletionGenerator); linenoiseSetCompletionCallback(LinenoiseCompletionGenerator);
linenoiseInstallWindowChangeHandler();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -101,6 +101,18 @@ namespace arangodb {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string getLine (const std::string& prompt, bool& eof) override final; std::string getLine (const std::string& prompt, bool& eof) override final;
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the shell implementation supports colors
////////////////////////////////////////////////////////////////////////////////
bool supportsColors () const override final {
#ifdef _WIN32
return false;
#else
return true;
#endif
}
}; };
} }
#endif #endif