mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(rds-data): reject result rows larger than 64 KB (#5290)
Return UnsupportedResultException 'Packet for query is too large'. * Fix #5113 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
3041d6bd90
commit
93cc2ff957
3 files changed
+66
-9
No files matched your search
@@ -74,23 +74,55 @@ class RdsDataServiceTest {
|
||||
assertEquals(10, response.get("records").size());
|
||||
}
|
||||
|
||||
/** Records serialize as [[{"stringValue":"..."}]]: 22 bytes around a single string. */
|
||||
/** Records serialize as [[{"stringValue":"..."}]]: 20 bytes around a single string per row. */
|
||||
@Test
|
||||
void executeStatementCountsTheWholeRecordsArrayAtTheBoundary() throws Exception {
|
||||
int overhead = 22;
|
||||
int limit = 1024 * 1024;
|
||||
int rows = 25;
|
||||
int exactLength = 41922;
|
||||
TestHarness harness = new TestHarness();
|
||||
ObjectNode exact = harness.service.executeStatement(harness.request(
|
||||
"select repeat('x', " + (limit - overhead) + ") as c"), REGION);
|
||||
assertEquals(1, exact.get("records").size());
|
||||
"select repeat('x', " + exactLength + ") as c from system_range(1, " + rows + ")"), REGION);
|
||||
assertEquals(rows, exact.get("records").size());
|
||||
|
||||
ObjectNode over = harness.request("select repeat('x', " + (limit - overhead + 1) + ") as c");
|
||||
ObjectNode over = harness.request(
|
||||
"select repeat('x', " + (exactLength + 1) + ") as c from system_range(1, " + rows + ")");
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> harness.service.executeStatement(over, REGION));
|
||||
assertEquals("UnsupportedResultException", error.getErrorCode());
|
||||
assertEquals("Database response exceeded size limit", error.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void executeStatementRejectsARowOverSixtyFourKilobytes() throws Exception {
|
||||
int limit = 64 * 1024;
|
||||
TestHarness harness = new TestHarness();
|
||||
ObjectNode exact = harness.service.executeStatement(harness.request(
|
||||
"select repeat('x', " + (limit - 1) + ") as a, 'y' as b"), REGION);
|
||||
assertEquals(1, exact.get("records").size());
|
||||
|
||||
ObjectNode over = harness.request("select repeat('x', " + limit + ") as a, 'y' as b");
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> harness.service.executeStatement(over, REGION));
|
||||
assertEquals("UnsupportedResultException", error.getErrorCode());
|
||||
assertEquals("Packet for query is too large", error.getMessage());
|
||||
assertEquals(400, error.getHttpStatus());
|
||||
}
|
||||
|
||||
/** The limit applies to the row the database returns, not to its JSON escaping or base64 encoding. */
|
||||
@Test
|
||||
void executeStatementMeasuresARowBeforeItIsSerialized() throws Exception {
|
||||
int size = 60 * 1024;
|
||||
TestHarness harness = new TestHarness();
|
||||
ObjectNode quotes = harness.service.executeStatement(harness.request(
|
||||
"select repeat('\"', " + size + ") as c"), REGION);
|
||||
assertEquals(size, quotes.get("records").get(0).get(0).get("stringValue").asText().length());
|
||||
|
||||
ObjectNode binary = harness.service.executeStatement(harness.request(
|
||||
"select cast(repeat('x', " + size + ") as varbinary) as c"), REGION);
|
||||
assertEquals(1, binary.get("records").size());
|
||||
assertTrue(binary.get("records").get(0).get(0).has("blobValue"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Message and error code checked against Aurora PostgreSQL 17.7 through the real
|
||||
* Data API on 2026-09-13.
|
||||
|
||||
Reference in new issue
Block a user