diff options
author | monster <monster@ydb.tech> | 2023-01-31 17:52:48 +0300 |
---|---|---|
committer | monster <monster@ydb.tech> | 2023-01-31 17:52:48 +0300 |
commit | 463ec9cb70707115500bab6035be4f22822a0381 (patch) | |
tree | 78bd0198ef62ca1a29a2341183626d5556ef616c | |
parent | 6f3e374920f26d9fb38d142db6e1ea3b8e47650a (diff) | |
download | ydb-463ec9cb70707115500bab6035be4f22822a0381.tar.gz |
do not write zero in input buffer when reading arrays
-rw-r--r-- | ydb/core/kqp/ut/pg/kqp_pg_ut.cpp | 28 | ||||
-rw-r--r-- | ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/arrayfuncs.c | 6 |
2 files changed, 12 insertions, 22 deletions
diff --git a/ydb/core/kqp/ut/pg/kqp_pg_ut.cpp b/ydb/core/kqp/ut/pg/kqp_pg_ut.cpp index a3f1a6e1090..1fba5803392 100644 --- a/ydb/core/kqp/ut/pg/kqp_pg_ut.cpp +++ b/ydb/core/kqp/ut/pg/kqp_pg_ut.cpp @@ -422,8 +422,8 @@ Y_UNIT_TEST_SUITE(KqpPg) { return typeSpec.ArrayPrint(str); }; - testSingleType(arrayId, false, false, textInArray, textOutArray); - testSingleType(arrayId, false, true, textInArray, textOutArray); + testSingleType(arrayId, typeSpec.IsKey, false, textInArray, textOutArray); + testSingleType(arrayId, typeSpec.IsKey, true, textInArray, textOutArray); }; auto testByteaType = [&] () { @@ -528,23 +528,19 @@ Y_UNIT_TEST_SUITE(KqpPg) { { testSingleType(id, typeSpec.IsKey, typeSpec.TextIn, typeSpec.TextOut); - //arrays do not work for now due to postgress requesting null-terminated - //data in ReadArrayBinary - //KIKIMR-16501 - - // auto arrayId = NYql::NPg::LookupType(id).ArrayTypeId; + auto arrayId = NYql::NPg::LookupType(id).ArrayTypeId; - // auto textInArray = [&typeSpec] (auto i) { - // auto str = typeSpec.TextIn(i); - // return typeSpec.ArrayPrint(str); - // }; + auto textInArray = [&typeSpec] (auto i) { + auto str = typeSpec.TextIn(i); + return typeSpec.ArrayPrint(str); + }; - // auto textOutArray = [&typeSpec] (auto i) { - // auto str = typeSpec.TextOut(i); - // return typeSpec.ArrayPrint(str); - // }; + auto textOutArray = [&typeSpec] (auto i) { + auto str = typeSpec.TextOut(i); + return typeSpec.ArrayPrint(str); + }; - // testSingleType(arrayId, false, textInArray, textOutArray); + testSingleType(arrayId, typeSpec.IsKey, textInArray, textOutArray); }; auto testByteaType = [&] () { diff --git a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/arrayfuncs.c b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/arrayfuncs.c index c490398475f..74a6fead43e 100644 --- a/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/arrayfuncs.c +++ b/ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt/arrayfuncs.c @@ -1472,7 +1472,6 @@ ReadArrayBinary(StringInfo buf, { int itemlen; StringInfoData elem_buf; - char csave; /* Get and check the item length */ itemlen = pq_getmsgint(buf, 4); @@ -1503,9 +1502,6 @@ ReadArrayBinary(StringInfo buf, buf->cursor += itemlen; - csave = buf->data[buf->cursor]; - buf->data[buf->cursor] = '\0'; - /* Now call the element's receiveproc */ values[i] = ReceiveFunctionCall(receiveproc, &elem_buf, typioparam, typmod); @@ -1517,8 +1513,6 @@ ReadArrayBinary(StringInfo buf, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("improper binary format in array element %d", i + 1))); - - buf->data[buf->cursor] = csave; } /* |