Skip to content

Commit

Permalink
Merge pull request #1427 from kuzudb/limit-fixed-list-size
Browse files Browse the repository at this point in the history
Add limit to TENSOR size
  • Loading branch information
acquamarin committed Mar 31, 2023
2 parents 120410f + ce6e40d commit 728a28b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/binder/bind/bind_ddl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ DataType Binder::bindDataType(const std::string& dataType) {
"The number of elements in a fixed list must be greater than 0. Given: " +
std::to_string(boundType.fixedNumElementsInList) + ".");
}
if (Types::getDataTypeSize(boundType) > common::BufferPoolConstants::PAGE_4KB_SIZE) {
throw common::BinderException("The size of fixed list is larger than a "
"DEFAULT_PAGE_SIZE, which is not supported yet.");
auto numElementsPerPage = storage::PageUtils::getNumElementsInAPage(
Types::getDataTypeSize(boundType), true /* hasNull */);
if (numElementsPerPage == 0) {
throw common::BinderException(
StringUtils::string_format("Cannot store a fixed list of size {} in a page.",
Types::getDataTypeSize(boundType)));
}
}
return boundType;
Expand Down
7 changes: 7 additions & 0 deletions test/binder/binder_error_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,10 @@ TEST_F(BinderErrorTest, InvalidFixedListNumElements) {
auto input = "create node table test1(ID INT64, marks INT64[0], PRIMARY KEY(ID))";
ASSERT_STREQ(expectedException.c_str(), getBindingError(input).c_str());
}

TEST_F(BinderErrorTest, InvalidFixedListSize) {
std::string expectedException =
"Binder exception: Cannot store a fixed list of size 4096 in a page.";
auto input = "create node table test1(ID INT64, marks INT64[512], PRIMARY KEY(ID))";
ASSERT_STREQ(expectedException.c_str(), getBindingError(input).c_str());
}

0 comments on commit 728a28b

Please sign in to comment.