Skip to content

Commit 1c9d9af

Browse files
authored
Pg 16.3 (#6644)
1 parent e5ae52d commit 1c9d9af

File tree

1,719 files changed

+147612
-102814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,719 files changed

+147612
-102814
lines changed

ydb/core/kqp/ut/pg/kqp_pg_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4406,7 +4406,7 @@ Y_UNIT_TEST_SUITE(KqpPg) {
44064406
)");
44074407
auto result = db.ExecuteQuery(query, NYdb::NQuery::TTxControl::BeginTx().CommitTx(), settings).ExtractValueSync();
44084408
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::GENERIC_ERROR, result.GetIssues().ToString());
4409-
UNIT_ASSERT(result.GetIssues().ToString().Contains("alternative is not implemented yet : 138"));
4409+
UNIT_ASSERT(result.GetIssues().ToString().Contains("alternative is not implemented yet : 34"));
44104410
}
44114411
}
44124412

ydb/library/yql/minikql/mkql_alloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct TMkqlPAllocHeader {
155155
} U;
156156

157157
size_t Size;
158-
void* Self; // should be placed right before pointer to allocated area, see GetMemoryChunkContext
158+
ui64 Self; // should be placed right before pointer to allocated area, see GetMemoryChunkContext
159159
};
160160

161161
static_assert(sizeof(TMkqlPAllocHeader) ==

ydb/library/yql/parser/pg_catalog/ut/catalog_ut.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,14 @@ Y_UNIT_TEST_SUITE(TAggregationsTests) {
150150
UNIT_ASSERT_VALUES_EQUAL(LookupProc(ret.SerializeFuncId).Name, "int8_avg_serialize");
151151
UNIT_ASSERT_VALUES_EQUAL(LookupProc(ret.DeserializeFuncId).Name, "int8_avg_deserialize");
152152

153-
ret = LookupAggregation("string_agg", {LookupType("text").TypeId, LookupType("text").TypeId});
154-
UNIT_ASSERT_VALUES_EQUAL(ret.TransTypeId, LookupType("internal").TypeId);
155-
UNIT_ASSERT_VALUES_EQUAL(ret.Name, "string_agg");
156-
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes.size(), 2);
157-
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes[0], LookupType("text").TypeId);
158-
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes[1], LookupType("text").TypeId);
159-
UNIT_ASSERT_VALUES_EQUAL(LookupProc(ret.TransFuncId).Name, "string_agg_transfn");
153+
ret = LookupAggregation("xmlagg", {LookupType("xml").TypeId});
154+
UNIT_ASSERT_VALUES_EQUAL(ret.TransTypeId, LookupType("xml").TypeId);
155+
UNIT_ASSERT_VALUES_EQUAL(ret.Name, "xmlagg");
156+
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes.size(), 1);
157+
UNIT_ASSERT_VALUES_EQUAL(ret.ArgTypes[0], LookupType("xml").TypeId);
158+
UNIT_ASSERT_VALUES_EQUAL(LookupProc(ret.TransFuncId).Name, "xmlconcat2");
160159
UNIT_ASSERT_VALUES_EQUAL(ret.CombineFuncId, 0);
161-
UNIT_ASSERT_VALUES_EQUAL(LookupProc(ret.FinalFuncId).Name, "string_agg_finalfn");
160+
UNIT_ASSERT_VALUES_EQUAL(ret.FinalFuncId, 0);
162161
UNIT_ASSERT_VALUES_EQUAL(ret.SerializeFuncId, 0);
163162
UNIT_ASSERT_VALUES_EQUAL(ret.DeserializeFuncId, 0);
164163

ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "arena_ctx.h"
2+
#include <util/generic/yexception.h>
23

34
#define TypeName PG_TypeName
45
#define SortBy PG_SortBy
@@ -7,35 +8,57 @@ extern "C" {
78
#include "postgres.h"
89
#include "nodes/memnodes.h"
910
#include "utils/memutils.h"
11+
#include "utils/memutils_internal.h"
1012
}
1113

1214
namespace NYql {
1315

1416
struct TArenaPAllocHeader {
1517
size_t Size;
16-
MemoryContext Self; // should be placed right before pointer to allocated area, see GetMemoryChunkContext
18+
ui64 Self; // should be placed right before pointer to allocated area, see GetMemoryChunkContext
1719
};
1820

1921
static_assert(sizeof(TArenaPAllocHeader) == sizeof(size_t) + sizeof(MemoryContext), "Padding is not allowed");
2022

21-
void *MyAllocSetAlloc(MemoryContext context, Size size) {
23+
extern "C" {
24+
extern void *ArenaAlloc(MemoryContext context, Size size);
25+
extern void ArenaFree(void *pointer);
26+
extern void *ArenaRealloc(void *pointer, Size size);
27+
extern void ArenaReset(MemoryContext context);
28+
extern void ArenaDelete(MemoryContext context);
29+
extern MemoryContext ArenaGetChunkContext(void *pointer);
30+
extern Size ArenaGetChunkSpace(void *pointer);
31+
extern bool ArenaIsEmpty(MemoryContext context);
32+
extern void ArenaStats(MemoryContext context,
33+
MemoryStatsPrintFunc printfunc, void *passthru,
34+
MemoryContextCounters *totals,
35+
bool print_to_stderr);
36+
#ifdef MEMORY_CONTEXT_CHECKING
37+
extern void ArenaCheck(MemoryContext context);
38+
#endif
39+
}
40+
41+
extern "C" void *ArenaAlloc(MemoryContext context, Size size) {
42+
Y_UNUSED(context);
2243
auto fullSize = size + MAXIMUM_ALIGNOF - 1 + sizeof(TArenaPAllocHeader);
2344
auto ptr = TArenaMemoryContext::GetCurrentPool().Allocate(fullSize);
2445
auto aligned = (TArenaPAllocHeader*)MAXALIGN(ptr + sizeof(TArenaPAllocHeader));
25-
aligned[-1].Self = context;
46+
Y_ENSURE((ui64(context) & MEMORY_CONTEXT_METHODID_MASK) == 0);
47+
aligned[-1].Self = ui64(context) | MCTX_UNUSED2_ID;
2648
aligned[-1].Size = size;
2749
return aligned;
2850
}
2951

30-
void MyAllocSetFree(MemoryContext context, void* pointer) {
52+
extern "C" void ArenaFree(void* pointer) {
53+
Y_UNUSED(pointer);
3154
}
3255

33-
void* MyAllocSetRealloc(MemoryContext context, void* pointer, Size size) {
56+
extern "C" void* ArenaRealloc(void* pointer, Size size) {
3457
if (!size) {
3558
return nullptr;
3659
}
3760

38-
void* ret = MyAllocSetAlloc(context, size);
61+
void* ret = ArenaAlloc(nullptr, size);
3962
if (pointer) {
4063
auto prevSize = ((const TArenaPAllocHeader*)pointer)[-1].Size;
4164
memmove(ret, pointer, prevSize);
@@ -44,50 +67,51 @@ void* MyAllocSetRealloc(MemoryContext context, void* pointer, Size size) {
4467
return ret;
4568
}
4669

47-
void MyAllocSetReset(MemoryContext context) {
70+
extern "C" void ArenaReset(MemoryContext context) {
71+
Y_UNUSED(context);
4872
}
4973

50-
void MyAllocSetDelete(MemoryContext context) {
74+
extern "C" void ArenaDelete(MemoryContext context) {
75+
Y_UNUSED(context);
5176
}
5277

53-
Size MyAllocSetGetChunkSpace(MemoryContext context, void* pointer) {
78+
extern "C" MemoryContext ArenaGetChunkContext(void *pointer) {
79+
return (MemoryContext)(((ui64*)pointer)[-1] & ~MEMORY_CONTEXT_METHODID_MASK);
80+
}
81+
82+
extern "C" Size ArenaGetChunkSpace(void* pointer) {
83+
Y_UNUSED(pointer);
5484
return 0;
5585
}
5686

57-
bool MyAllocSetIsEmpty(MemoryContext context) {
87+
extern "C" bool ArenaIsEmpty(MemoryContext context) {
88+
Y_UNUSED(context);
5889
return false;
5990
}
6091

61-
void MyAllocSetStats(MemoryContext context,
92+
extern "C" void ArenaStats(MemoryContext context,
6293
MemoryStatsPrintFunc printfunc, void *passthru,
6394
MemoryContextCounters *totals,
6495
bool print_to_stderr) {
96+
Y_UNUSED(context);
97+
Y_UNUSED(printfunc);
98+
Y_UNUSED(passthru);
99+
Y_UNUSED(totals);
100+
Y_UNUSED(print_to_stderr);
65101
}
66102

67-
void MyAllocSetCheck(MemoryContext context) {
103+
extern "C" void ArenaCheck(MemoryContext context) {
104+
Y_UNUSED(context);
68105
}
69106

70-
const MemoryContextMethods MyMethods = {
71-
MyAllocSetAlloc,
72-
MyAllocSetFree,
73-
MyAllocSetRealloc,
74-
MyAllocSetReset,
75-
MyAllocSetDelete,
76-
MyAllocSetGetChunkSpace,
77-
MyAllocSetIsEmpty,
78-
MyAllocSetStats
79-
#ifdef MEMORY_CONTEXT_CHECKING
80-
,MyAllocSetCheck
81-
#endif
82-
};
83-
84107
__thread TArenaMemoryContext* TArenaMemoryContext::Current = nullptr;
85108

86109
TArenaMemoryContext::TArenaMemoryContext() {
87110
MyContext = (MemoryContext)malloc(sizeof(MemoryContextData));
111+
static_assert(MEMORY_CONTEXT_METHODID_MASK < sizeof(void*));
88112
MemoryContextCreate(MyContext,
89113
T_AllocSetContext,
90-
&MyMethods,
114+
MCTX_UNUSED2_ID,
91115
nullptr,
92116
"arena");
93117
Acquire();

ydb/library/yql/parser/pg_wrapper/arrow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "pg_compat.h"
12
#include "arrow.h"
23
#include "arrow_impl.h"
34
#include <ydb/library/yql/minikql/defs.h>

ydb/library/yql/parser/pg_wrapper/arrow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
extern "C" {
1616
#include "postgres.h"
1717
#include "fmgr.h"
18+
#include "varatt.h"
1819
#include "catalog/pg_type_d.h"
1920
#include "catalog/pg_collation_d.h"
2021
}

ydb/library/yql/parser/pg_wrapper/arrow_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "pg_compat.h"
12
#include "arrow.h"
23

34
namespace NYql {

ydb/library/yql/parser/pg_wrapper/cflags.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,5 @@ CFLAGS(
131131
-Dpg_prng_fseed=yql_pg_prng_fseed
132132
-Dpg_prng_seed_check=yql_pg_prng_seed_check
133133
-Dpg_prng_seed=yql_pg_prng_seed
134+
-Dpg_prng_double_normal=yql_pg_prng_double_normal
134135
)

0 commit comments

Comments
 (0)