mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
### Does this PR have any customer impact? No ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Refactoring ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description Remove helio from file name Remove helio references from source content except schema reference Start local documentdb server with the documentdb extension Regression tests using the documentdb extension ---- #### AI description (iteration 1) #### PR Classification Code cleanup #### PR Summary This pull request removes references to "helio" from the `documentdb_core` source code. - `scripts/utils.sh`: Renamed variables from `preloadExtensions` to `preloadLibraries`. - `pg_documentdb_core/include/utils/error_utils.h`: Updated function and macro names to replace "Helio" with "DocumentDB". - `pg_documentdb_core/include/io/helio_bson_core.h` and `pg_documentdb_core/include/query/helio_bson_compare.h`: Moved to `pg_documentdb_core/include/io/bson_core.h` and `pg_documentdb_core/include/query/bson_compare.h`. - `pg_documentdb_core/src/collation/collation.c` and `pg_documentdb_core/src/io/pgbson.c`: Replaced error codes and messages to use "DocumentDB" instead of "Helio". - `scripts/validate_helio_extension_state.sh`: Added exceptions for certain files to skip validation for "helio" references.
135 lines
3.1 KiB
C
135 lines
3.1 KiB
C
/*-------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* src/bson_init.c
|
|
*
|
|
* Initialization of the shared library initialization for bson.
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#include <postgres.h>
|
|
#include <miscadmin.h>
|
|
#include <utils/guc.h>
|
|
#include <bson.h>
|
|
|
|
#include "bson_init.h"
|
|
|
|
static void * pg_malloc(size_t num_bytes);
|
|
static void * pg_calloc(size_t n_members, size_t num_bytes);
|
|
static void * pg_realloc(void *mem, size_t num_bytes);
|
|
static void * pg_aligned_alloc(size_t alignment, size_t num_bytes);
|
|
static void pg_free(void *mem);
|
|
|
|
static bool gHasSetVTable = false;
|
|
static bson_mem_vtable_t gMemVtable = {
|
|
pg_malloc,
|
|
pg_calloc,
|
|
pg_realloc,
|
|
pg_free,
|
|
pg_aligned_alloc,
|
|
{ 0 }
|
|
};
|
|
|
|
|
|
/* --------------------------------------------------------- */
|
|
/* GUCs and default values */
|
|
/* --------------------------------------------------------- */
|
|
|
|
/* GUC controlling whether or not we use the pretty printed version json representation for bson */
|
|
#define DEFAULT_BSON_TEXT_USE_JSON_REPRESENTATION false
|
|
bool BsonTextUseJsonRepresentation = DEFAULT_BSON_TEXT_USE_JSON_REPRESENTATION;
|
|
|
|
/* GUC deciding whether collation is support */
|
|
#define DEFAULT_ENABLE_COLLATION false
|
|
bool EnableCollation = DEFAULT_ENABLE_COLLATION;
|
|
|
|
/* --------------------------------------------------------- */
|
|
/* Top level exports */
|
|
/* --------------------------------------------------------- */
|
|
|
|
/*
|
|
* Registers callbacks for Bson to use postgres allocators.
|
|
*/
|
|
void
|
|
InstallBsonMemVTables(void)
|
|
{
|
|
if (!gHasSetVTable)
|
|
{
|
|
bson_mem_set_vtable(&gMemVtable);
|
|
gHasSetVTable = true;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
* Initializes core configurations pertaining to documentdb core.
|
|
*/
|
|
void
|
|
InitDocumentDBCoreConfigurations(const char *prefix)
|
|
{
|
|
DefineCustomBoolVariable(
|
|
psprintf("%s.bsonUseEJson", prefix),
|
|
gettext_noop(
|
|
"Determines whether the bson text is printed as extended Json. Used mainly for test."),
|
|
NULL, &BsonTextUseJsonRepresentation, DEFAULT_BSON_TEXT_USE_JSON_REPRESENTATION,
|
|
PGC_USERSET, 0, NULL, NULL, NULL);
|
|
|
|
DefineCustomBoolVariable(
|
|
psprintf("%s.enableCollation", prefix),
|
|
gettext_noop(
|
|
"Determines whether collation is supported."),
|
|
NULL, &EnableCollation,
|
|
DEFAULT_ENABLE_COLLATION,
|
|
PGC_USERSET, 0, NULL, NULL, NULL);
|
|
}
|
|
|
|
|
|
/* --------------------------------------------------------- */
|
|
/* Private methods */
|
|
/* --------------------------------------------------------- */
|
|
static void *
|
|
pg_malloc(size_t num_bytes)
|
|
{
|
|
return palloc(num_bytes);
|
|
}
|
|
|
|
|
|
static void *
|
|
pg_calloc(size_t n_members, size_t num_bytes)
|
|
{
|
|
/* TODO: Is this the best way to handle this? */
|
|
return palloc0(n_members * num_bytes);
|
|
}
|
|
|
|
|
|
static void *
|
|
pg_realloc(void *mem, size_t num_bytes)
|
|
{
|
|
if (mem == NULL)
|
|
{
|
|
return pg_malloc(num_bytes);
|
|
}
|
|
|
|
return repalloc(mem, num_bytes);
|
|
}
|
|
|
|
|
|
static void *
|
|
pg_aligned_alloc(size_t alignment, size_t num_bytes)
|
|
{
|
|
#if PG_VERSION_NUM >= 160000
|
|
return palloc_aligned(num_bytes, alignment, 0);
|
|
#else
|
|
return pg_malloc(num_bytes);
|
|
#endif
|
|
}
|
|
|
|
|
|
static void
|
|
pg_free(void *mem)
|
|
{
|
|
if (mem != NULL)
|
|
{
|
|
pfree(mem);
|
|
}
|
|
}
|