Skip to content

Commit df12995

Browse files
authored
Merge e2cc51b into 6569863
2 parents 6569863 + e2cc51b commit df12995

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed

ydb/core/scheme/scheme_tablecell.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,14 @@ void DbgPrintValue(TString &res, const TCell &r, NScheme::TTypeInfo typeInfo) {
487487
case NScheme::NTypeIds::ActorId:
488488
res += ToString(r.AsValue<NActors::TActorId>());
489489
break;
490-
case NScheme::NTypeIds::Pg:
491-
// TODO: support pg types
490+
case NScheme::NTypeIds::Pg: {
491+
auto convert = NPg::PgNativeTextFromNativeBinary(r.AsBuf(), typeInfo.GetTypeDesc());
492+
if (!convert.Error)
493+
res += convert.Str;
494+
else
495+
res += *convert.Error;
492496
break;
497+
}
493498
default:
494499
res += EscapeC(r.Data(), r.Size());
495500
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <library/cpp/testing/unittest/registar.h>
2+
3+
#include <ydb/core/scheme/scheme_tablecell.h>
4+
#include <ydb/core/scheme/scheme_type_registry.h>
5+
6+
extern "C" {
7+
#include "postgres.h"
8+
#include "catalog/pg_type_d.h"
9+
}
10+
11+
namespace NKikimr {
12+
namespace NTable {
13+
14+
Y_UNIT_TEST_SUITE(PgTest) {
15+
16+
Y_UNIT_TEST(DumpCells) {
17+
NScheme::TTypeRegistry typeRegistry;
18+
19+
char strVal[] = "This is the value";
20+
TCell strCell((const char*)&strVal, sizeof(strVal) - 1);
21+
22+
NScheme::TTypeInfo typeInfo(NScheme::TString::TypeId);
23+
TString strRes = DbgPrintCell(strCell, typeInfo, typeRegistry);
24+
UNIT_ASSERT_STRINGS_EQUAL(strRes, TStringBuilder() << "String : " << strVal);
25+
26+
NScheme::TTypeInfo pgTypeInfo(NScheme::NTypeIds::Pg, NPg::TypeDescFromPgTypeId(TEXTOID));
27+
TString pgStrRes = DbgPrintCell(strCell, pgTypeInfo, typeRegistry);
28+
UNIT_ASSERT_STRINGS_EQUAL(pgStrRes, TStringBuilder() << "pgtext : " << strVal);
29+
}
30+
}
31+
32+
}
33+
}

ydb/core/scheme/ut_pg/ya.make

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
UNITTEST_FOR(ydb/core/scheme)
2+
3+
FORK_SUBTESTS()
4+
5+
SRCS(
6+
scheme_tablecell_pg_ut.cpp
7+
)
8+
9+
PEERDIR(
10+
ydb/core/scheme
11+
ydb/library/yql/public/udf/service/exception_policy
12+
ydb/library/yql/parser/pg_wrapper
13+
)
14+
15+
ADDINCL(
16+
ydb/library/yql/parser/pg_wrapper/postgresql/src/include
17+
)
18+
19+
IF (OS_WINDOWS)
20+
CFLAGS(
21+
"-D__thread=__declspec(thread)"
22+
-Dfstat=microsoft_native_fstat
23+
-Dstat=microsoft_native_stat
24+
)
25+
ENDIF()
26+
27+
NO_COMPILER_WARNINGS()
28+
29+
YQL_LAST_ABI_VERSION()
30+
31+
END()

0 commit comments

Comments
 (0)