mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Use palloc_object() and palloc_array() in more areas of the tree
The idea is to encourage more the use of these new routines across the
tree, as these offer stronger type safety guarantees than palloc().
The following paths are included in this batch, treating all the areas
proposed by the author for the most trivial changes, except src/backend
(by far the largest batch):
src/bin/
src/common/
src/fe_utils/
src/include/
src/pl/
src/test/
src/tutorial/
Similar work has been done in 31d3847a37.
The code compiles the same before and after this commit, with the
following exceptions due to changes in line numbers because some of the
new allocation formulas are shorter:
blkreftable.c
pgfnames.c
pl_exec.c
Author: David Geier <geidav.pg@gmail.com>
Discussion: https://postgr.es/m/ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com
This commit is contained in:
@@ -506,11 +506,11 @@ my_compress(PG_FUNCTION_ARGS)
|
|||||||
if (entry->leafkey)
|
if (entry->leafkey)
|
||||||
{
|
{
|
||||||
/* replace entry->key with a compressed version */
|
/* replace entry->key with a compressed version */
|
||||||
compressed_data_type *compressed_data = palloc(sizeof(compressed_data_type));
|
compressed_data_type *compressed_data = palloc_object(compressed_data_type);
|
||||||
|
|
||||||
/* fill *compressed_data from entry->key ... */
|
/* fill *compressed_data from entry->key ... */
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(compressed_data),
|
gistentryinit(*retval, PointerGetDatum(compressed_data),
|
||||||
entry->rel, entry->page, entry->offset, FALSE);
|
entry->rel, entry->page, entry->offset, FALSE);
|
||||||
}
|
}
|
||||||
@@ -921,8 +921,8 @@ my_fetch(PG_FUNCTION_ARGS)
|
|||||||
fetched_data_type *fetched_data;
|
fetched_data_type *fetched_data;
|
||||||
GISTENTRY *retval;
|
GISTENTRY *retval;
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
fetched_data = palloc(sizeof(fetched_data_type));
|
fetched_data = palloc_object(fetched_data_type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert 'fetched_data' into the a Datum of the original datatype.
|
* Convert 'fetched_data' into the a Datum of the original datatype.
|
||||||
|
|||||||
@@ -2491,7 +2491,7 @@ makepoint(PG_FUNCTION_ARGS)
|
|||||||
/* Here, the pass-by-reference nature of Point is not hidden. */
|
/* Here, the pass-by-reference nature of Point is not hidden. */
|
||||||
Point *pointx = PG_GETARG_POINT_P(0);
|
Point *pointx = PG_GETARG_POINT_P(0);
|
||||||
Point *pointy = PG_GETARG_POINT_P(1);
|
Point *pointy = PG_GETARG_POINT_P(1);
|
||||||
Point *new_point = (Point *) palloc(sizeof(Point));
|
Point *new_point = palloc_object(Point);
|
||||||
|
|
||||||
new_point->x = pointx->x;
|
new_point->x = pointx->x;
|
||||||
new_point->y = pointy->y;
|
new_point->y = pointy->y;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ complex_in(PG_FUNCTION_ARGS)
|
|||||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||||
"complex", str)));
|
"complex", str)));
|
||||||
|
|
||||||
result = (Complex *) palloc(sizeof(Complex));
|
result = palloc_object(Complex);
|
||||||
result->x = x;
|
result->x = x;
|
||||||
result->y = y;
|
result->y = y;
|
||||||
PG_RETURN_POINTER(result);
|
PG_RETURN_POINTER(result);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ astreamer_recovery_injector_new(astreamer *next,
|
|||||||
{
|
{
|
||||||
astreamer_recovery_injector *streamer;
|
astreamer_recovery_injector *streamer;
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_recovery_injector));
|
streamer = palloc0_object(astreamer_recovery_injector);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_recovery_injector_ops;
|
&astreamer_recovery_injector_ops;
|
||||||
streamer->base.bbs_next = next;
|
streamer->base.bbs_next = next;
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ combinebackup_per_wal_range_cb(JsonManifestParseContext *context,
|
|||||||
manifest_wal_range *range;
|
manifest_wal_range *range;
|
||||||
|
|
||||||
/* Allocate and initialize a struct describing this WAL range. */
|
/* Allocate and initialize a struct describing this WAL range. */
|
||||||
range = palloc(sizeof(manifest_wal_range));
|
range = palloc_object(manifest_wal_range);
|
||||||
range->tli = tli;
|
range->tli = tli;
|
||||||
range->start_lsn = start_lsn;
|
range->start_lsn = start_lsn;
|
||||||
range->end_lsn = end_lsn;
|
range->end_lsn = end_lsn;
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables,
|
|||||||
tblinfo[i].numParents,
|
tblinfo[i].numParents,
|
||||||
tblinfo[i].dobj.name);
|
tblinfo[i].dobj.name);
|
||||||
|
|
||||||
attachinfo = (TableAttachInfo *) palloc(sizeof(TableAttachInfo));
|
attachinfo = palloc_object(TableAttachInfo);
|
||||||
attachinfo->dobj.objType = DO_TABLE_ATTACH;
|
attachinfo->dobj.objType = DO_TABLE_ATTACH;
|
||||||
attachinfo->dobj.catId.tableoid = 0;
|
attachinfo->dobj.catId.tableoid = 0;
|
||||||
attachinfo->dobj.catId.oid = 0;
|
attachinfo->dobj.catId.oid = 0;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ astreamer_verify_content_new(astreamer *next, verifier_context *context,
|
|||||||
{
|
{
|
||||||
astreamer_verify *streamer;
|
astreamer_verify *streamer;
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_verify));
|
streamer = palloc0_object(astreamer_verify);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_verify_ops;
|
&astreamer_verify_ops;
|
||||||
|
|
||||||
|
|||||||
@@ -584,7 +584,7 @@ verifybackup_per_wal_range_cb(JsonManifestParseContext *context,
|
|||||||
manifest_wal_range *range;
|
manifest_wal_range *range;
|
||||||
|
|
||||||
/* Allocate and initialize a struct describing this WAL range. */
|
/* Allocate and initialize a struct describing this WAL range. */
|
||||||
range = palloc(sizeof(manifest_wal_range));
|
range = palloc_object(manifest_wal_range);
|
||||||
range->tli = tli;
|
range->tli = tli;
|
||||||
range->start_lsn = start_lsn;
|
range->start_lsn = start_lsn;
|
||||||
range->end_lsn = end_lsn;
|
range->end_lsn = end_lsn;
|
||||||
|
|||||||
@@ -530,7 +530,7 @@ retrieve_objects(PGconn *conn, vacuumingOptions *vacopts,
|
|||||||
PQExpBufferData catalog_query;
|
PQExpBufferData catalog_query;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
SimpleStringListCell *cell;
|
SimpleStringListCell *cell;
|
||||||
SimpleStringList *found_objs = palloc0(sizeof(SimpleStringList));
|
SimpleStringList *found_objs = palloc0_object(SimpleStringList);
|
||||||
bool objects_listed = false;
|
bool objects_listed = false;
|
||||||
|
|
||||||
initPQExpBuffer(&catalog_query);
|
initPQExpBuffer(&catalog_query);
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ static void BlockRefTableFileTerminate(BlockRefTableBuffer *buffer);
|
|||||||
BlockRefTable *
|
BlockRefTable *
|
||||||
CreateEmptyBlockRefTable(void)
|
CreateEmptyBlockRefTable(void)
|
||||||
{
|
{
|
||||||
BlockRefTable *brtab = palloc(sizeof(BlockRefTable));
|
BlockRefTable *brtab = palloc_object(BlockRefTable);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Even completely empty database has a few hundred relation forks, so it
|
* Even completely empty database has a few hundred relation forks, so it
|
||||||
@@ -497,7 +497,7 @@ WriteBlockRefTable(BlockRefTable *brtab,
|
|||||||
|
|
||||||
/* Extract entries into serializable format and sort them. */
|
/* Extract entries into serializable format and sort them. */
|
||||||
sdata =
|
sdata =
|
||||||
palloc(brtab->hash->members * sizeof(BlockRefTableSerializedEntry));
|
palloc_array(BlockRefTableSerializedEntry, brtab->hash->members);
|
||||||
blockreftable_start_iterate(brtab->hash, &it);
|
blockreftable_start_iterate(brtab->hash, &it);
|
||||||
while ((brtentry = blockreftable_iterate(brtab->hash, &it)) != NULL)
|
while ((brtentry = blockreftable_iterate(brtab->hash, &it)) != NULL)
|
||||||
{
|
{
|
||||||
@@ -584,7 +584,7 @@ CreateBlockRefTableReader(io_callback_fn read_callback,
|
|||||||
uint32 magic;
|
uint32 magic;
|
||||||
|
|
||||||
/* Initialize data structure. */
|
/* Initialize data structure. */
|
||||||
reader = palloc0(sizeof(BlockRefTableReader));
|
reader = palloc0_object(BlockRefTableReader);
|
||||||
reader->buffer.io_callback = read_callback;
|
reader->buffer.io_callback = read_callback;
|
||||||
reader->buffer.io_callback_arg = read_callback_arg;
|
reader->buffer.io_callback_arg = read_callback_arg;
|
||||||
reader->error_filename = error_filename;
|
reader->error_filename = error_filename;
|
||||||
@@ -660,7 +660,7 @@ BlockRefTableReaderNextRelation(BlockRefTableReader *reader,
|
|||||||
/* Read chunk size array. */
|
/* Read chunk size array. */
|
||||||
if (reader->chunk_size != NULL)
|
if (reader->chunk_size != NULL)
|
||||||
pfree(reader->chunk_size);
|
pfree(reader->chunk_size);
|
||||||
reader->chunk_size = palloc(sentry.nchunks * sizeof(uint16));
|
reader->chunk_size = palloc_array(uint16, sentry.nchunks);
|
||||||
BlockRefTableRead(reader, reader->chunk_size,
|
BlockRefTableRead(reader, reader->chunk_size,
|
||||||
sentry.nchunks * sizeof(uint16));
|
sentry.nchunks * sizeof(uint16));
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ CreateBlockRefTableWriter(io_callback_fn write_callback,
|
|||||||
uint32 magic = BLOCKREFTABLE_MAGIC;
|
uint32 magic = BLOCKREFTABLE_MAGIC;
|
||||||
|
|
||||||
/* Prepare buffer and CRC check and save callbacks. */
|
/* Prepare buffer and CRC check and save callbacks. */
|
||||||
writer = palloc0(sizeof(BlockRefTableWriter));
|
writer = palloc0_object(BlockRefTableWriter);
|
||||||
writer->buffer.io_callback = write_callback;
|
writer->buffer.io_callback = write_callback;
|
||||||
writer->buffer.io_callback_arg = write_callback_arg;
|
writer->buffer.io_callback_arg = write_callback_arg;
|
||||||
INIT_CRC32C(writer->buffer.crc);
|
INIT_CRC32C(writer->buffer.crc);
|
||||||
@@ -874,7 +874,7 @@ DestroyBlockRefTableWriter(BlockRefTableWriter *writer)
|
|||||||
BlockRefTableEntry *
|
BlockRefTableEntry *
|
||||||
CreateBlockRefTableEntry(RelFileLocator rlocator, ForkNumber forknum)
|
CreateBlockRefTableEntry(RelFileLocator rlocator, ForkNumber forknum)
|
||||||
{
|
{
|
||||||
BlockRefTableEntry *entry = palloc0(sizeof(BlockRefTableEntry));
|
BlockRefTableEntry *entry = palloc0_object(BlockRefTableEntry);
|
||||||
|
|
||||||
memcpy(&entry->key.rlocator, &rlocator, sizeof(RelFileLocator));
|
memcpy(&entry->key.rlocator, &rlocator, sizeof(RelFileLocator));
|
||||||
entry->key.forknum = forknum;
|
entry->key.forknum = forknum;
|
||||||
@@ -997,10 +997,9 @@ BlockRefTableEntryMarkBlockModified(BlockRefTableEntry *entry,
|
|||||||
|
|
||||||
if (entry->nchunks == 0)
|
if (entry->nchunks == 0)
|
||||||
{
|
{
|
||||||
entry->chunk_size = palloc0(sizeof(uint16) * max_chunks);
|
entry->chunk_size = palloc0_array(uint16, max_chunks);
|
||||||
entry->chunk_usage = palloc0(sizeof(uint16) * max_chunks);
|
entry->chunk_usage = palloc0_array(uint16, max_chunks);
|
||||||
entry->chunk_data =
|
entry->chunk_data = palloc0_array(BlockRefTableChunk, max_chunks);
|
||||||
palloc0(sizeof(BlockRefTableChunk) * max_chunks);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1029,7 +1028,7 @@ BlockRefTableEntryMarkBlockModified(BlockRefTableEntry *entry,
|
|||||||
if (entry->chunk_size[chunkno] == 0)
|
if (entry->chunk_size[chunkno] == 0)
|
||||||
{
|
{
|
||||||
entry->chunk_data[chunkno] =
|
entry->chunk_data[chunkno] =
|
||||||
palloc(sizeof(uint16) * INITIAL_ENTRIES_PER_CHUNK);
|
palloc_array(uint16, INITIAL_ENTRIES_PER_CHUNK);
|
||||||
entry->chunk_size[chunkno] = INITIAL_ENTRIES_PER_CHUNK;
|
entry->chunk_size[chunkno] = INITIAL_ENTRIES_PER_CHUNK;
|
||||||
entry->chunk_data[chunkno][0] = chunkoffset;
|
entry->chunk_data[chunkno][0] = chunkoffset;
|
||||||
entry->chunk_usage[chunkno] = 1;
|
entry->chunk_usage[chunkno] = 1;
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ json_parse_manifest_incremental_init(JsonManifestParseContext *context)
|
|||||||
JsonManifestParseState *parse;
|
JsonManifestParseState *parse;
|
||||||
pg_cryptohash_ctx *manifest_ctx;
|
pg_cryptohash_ctx *manifest_ctx;
|
||||||
|
|
||||||
incstate = palloc(sizeof(JsonManifestParseIncrementalState));
|
incstate = palloc_object(JsonManifestParseIncrementalState);
|
||||||
parse = palloc(sizeof(JsonManifestParseState));
|
parse = palloc_object(JsonManifestParseState);
|
||||||
|
|
||||||
parse->context = context;
|
parse->context = context;
|
||||||
parse->state = JM_EXPECT_TOPLEVEL_START;
|
parse->state = JM_EXPECT_TOPLEVEL_START;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ pgfnames(const char *path)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
filenames = (char **) palloc(fnsize * sizeof(char *));
|
filenames = palloc_array(char *, fnsize);
|
||||||
|
|
||||||
while (errno = 0, (file = readdir(dir)) != NULL)
|
while (errno = 0, (file = readdir(dir)) != NULL)
|
||||||
{
|
{
|
||||||
@@ -58,8 +58,7 @@ pgfnames(const char *path)
|
|||||||
if (numnames + 1 >= fnsize)
|
if (numnames + 1 >= fnsize)
|
||||||
{
|
{
|
||||||
fnsize *= 2;
|
fnsize *= 2;
|
||||||
filenames = (char **) repalloc(filenames,
|
filenames = repalloc_array(filenames, char *, fnsize);
|
||||||
fnsize * sizeof(char *));
|
|
||||||
}
|
}
|
||||||
filenames[numnames++] = pstrdup(file->d_name);
|
filenames[numnames++] = pstrdup(file->d_name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ rmtree(const char *path, bool rmtopdir)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dirnames = (char **) palloc(sizeof(char *) * dirnames_capacity);
|
dirnames = palloc_array(char *, dirnames_capacity);
|
||||||
|
|
||||||
while (errno = 0, (de = readdir(dir)))
|
while (errno = 0, (de = readdir(dir)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ initStringInfoInternal(StringInfo str, int initsize)
|
|||||||
static inline StringInfo
|
static inline StringInfo
|
||||||
makeStringInfoInternal(int initsize)
|
makeStringInfoInternal(int initsize)
|
||||||
{
|
{
|
||||||
StringInfo res = (StringInfo) palloc(sizeof(StringInfoData));
|
StringInfo res = palloc_object(StringInfoData);
|
||||||
|
|
||||||
initStringInfoInternal(res, initsize);
|
initStringInfoInternal(res, initsize);
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ astreamer_plain_writer_new(char *pathname, FILE *file)
|
|||||||
{
|
{
|
||||||
astreamer_plain_writer *streamer;
|
astreamer_plain_writer *streamer;
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_plain_writer));
|
streamer = palloc0_object(astreamer_plain_writer);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_plain_writer_ops;
|
&astreamer_plain_writer_ops;
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ astreamer_extractor_new(const char *basepath,
|
|||||||
{
|
{
|
||||||
astreamer_extractor *streamer;
|
astreamer_extractor *streamer;
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_extractor));
|
streamer = palloc0_object(astreamer_extractor);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_extractor_ops;
|
&astreamer_extractor_ops;
|
||||||
streamer->basepath = pstrdup(basepath);
|
streamer->basepath = pstrdup(basepath);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ astreamer_gzip_writer_new(char *pathname, FILE *file,
|
|||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
astreamer_gzip_writer *streamer;
|
astreamer_gzip_writer *streamer;
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_gzip_writer));
|
streamer = palloc0_object(astreamer_gzip_writer);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_gzip_writer_ops;
|
&astreamer_gzip_writer_ops;
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ astreamer_gzip_decompressor_new(astreamer *next)
|
|||||||
|
|
||||||
Assert(next != NULL);
|
Assert(next != NULL);
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_gzip_decompressor));
|
streamer = palloc0_object(astreamer_gzip_decompressor);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_gzip_decompressor_ops;
|
&astreamer_gzip_decompressor_ops;
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ astreamer_lz4_compressor_new(astreamer *next, pg_compress_specification *compres
|
|||||||
|
|
||||||
Assert(next != NULL);
|
Assert(next != NULL);
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_lz4_frame));
|
streamer = palloc0_object(astreamer_lz4_frame);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_lz4_compressor_ops;
|
&astreamer_lz4_compressor_ops;
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ astreamer_lz4_decompressor_new(astreamer *next)
|
|||||||
|
|
||||||
Assert(next != NULL);
|
Assert(next != NULL);
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_lz4_frame));
|
streamer = palloc0_object(astreamer_lz4_frame);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_lz4_decompressor_ops;
|
&astreamer_lz4_decompressor_ops;
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ astreamer_tar_parser_new(astreamer *next)
|
|||||||
{
|
{
|
||||||
astreamer_tar_parser *streamer;
|
astreamer_tar_parser *streamer;
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_tar_parser));
|
streamer = palloc0_object(astreamer_tar_parser);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_tar_parser_ops;
|
&astreamer_tar_parser_ops;
|
||||||
streamer->base.bbs_next = next;
|
streamer->base.bbs_next = next;
|
||||||
@@ -357,7 +357,7 @@ astreamer_tar_archiver_new(astreamer *next)
|
|||||||
{
|
{
|
||||||
astreamer_tar_archiver *streamer;
|
astreamer_tar_archiver *streamer;
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_tar_archiver));
|
streamer = palloc0_object(astreamer_tar_archiver);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_tar_archiver_ops;
|
&astreamer_tar_archiver_ops;
|
||||||
streamer->base.bbs_next = next;
|
streamer->base.bbs_next = next;
|
||||||
@@ -463,7 +463,7 @@ astreamer_tar_terminator_new(astreamer *next)
|
|||||||
{
|
{
|
||||||
astreamer *streamer;
|
astreamer *streamer;
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer));
|
streamer = palloc0_object(astreamer);
|
||||||
*((const astreamer_ops **) &streamer->bbs_ops) =
|
*((const astreamer_ops **) &streamer->bbs_ops) =
|
||||||
&astreamer_tar_terminator_ops;
|
&astreamer_tar_terminator_ops;
|
||||||
streamer->bbs_next = next;
|
streamer->bbs_next = next;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ astreamer_zstd_compressor_new(astreamer *next, pg_compress_specification *compre
|
|||||||
|
|
||||||
Assert(next != NULL);
|
Assert(next != NULL);
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_zstd_frame));
|
streamer = palloc0_object(astreamer_zstd_frame);
|
||||||
|
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_zstd_compressor_ops;
|
&astreamer_zstd_compressor_ops;
|
||||||
@@ -266,7 +266,7 @@ astreamer_zstd_decompressor_new(astreamer *next)
|
|||||||
|
|
||||||
Assert(next != NULL);
|
Assert(next != NULL);
|
||||||
|
|
||||||
streamer = palloc0(sizeof(astreamer_zstd_frame));
|
streamer = palloc0_object(astreamer_zstd_frame);
|
||||||
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
*((const astreamer_ops **) &streamer->base.bbs_ops) =
|
||||||
&astreamer_zstd_decompressor_ops;
|
&astreamer_zstd_decompressor_ops;
|
||||||
|
|
||||||
|
|||||||
@@ -1825,7 +1825,7 @@ RT_CREATE(MemoryContext ctx)
|
|||||||
dsa_pointer dp;
|
dsa_pointer dp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tree = (RT_RADIX_TREE *) palloc0(sizeof(RT_RADIX_TREE));
|
tree = palloc0_object(RT_RADIX_TREE);
|
||||||
|
|
||||||
#ifdef RT_SHMEM
|
#ifdef RT_SHMEM
|
||||||
tree->dsa = dsa;
|
tree->dsa = dsa;
|
||||||
@@ -1835,7 +1835,7 @@ RT_CREATE(MemoryContext ctx)
|
|||||||
tree->ctl->magic = RT_RADIX_TREE_MAGIC;
|
tree->ctl->magic = RT_RADIX_TREE_MAGIC;
|
||||||
LWLockInitialize(&tree->ctl->lock, tranche_id);
|
LWLockInitialize(&tree->ctl->lock, tranche_id);
|
||||||
#else
|
#else
|
||||||
tree->ctl = (RT_RADIX_TREE_CONTROL *) palloc0(sizeof(RT_RADIX_TREE_CONTROL));
|
tree->ctl = palloc0_object(RT_RADIX_TREE_CONTROL);
|
||||||
|
|
||||||
/* Create a slab context for each size class */
|
/* Create a slab context for each size class */
|
||||||
for (int i = 0; i < RT_NUM_SIZE_CLASSES; i++)
|
for (int i = 0; i < RT_NUM_SIZE_CLASSES; i++)
|
||||||
@@ -1868,7 +1868,7 @@ RT_ATTACH(dsa_area *dsa, RT_HANDLE handle)
|
|||||||
RT_RADIX_TREE *tree;
|
RT_RADIX_TREE *tree;
|
||||||
dsa_pointer control;
|
dsa_pointer control;
|
||||||
|
|
||||||
tree = (RT_RADIX_TREE *) palloc0(sizeof(RT_RADIX_TREE));
|
tree = palloc0_object(RT_RADIX_TREE);
|
||||||
|
|
||||||
/* Find the control object in shared memory */
|
/* Find the control object in shared memory */
|
||||||
control = handle;
|
control = handle;
|
||||||
@@ -2057,7 +2057,7 @@ RT_BEGIN_ITERATE(RT_RADIX_TREE * tree)
|
|||||||
RT_ITER *iter;
|
RT_ITER *iter;
|
||||||
RT_CHILD_PTR root;
|
RT_CHILD_PTR root;
|
||||||
|
|
||||||
iter = (RT_ITER *) palloc0(sizeof(RT_ITER));
|
iter = palloc0_object(RT_ITER);
|
||||||
iter->tree = tree;
|
iter->tree = tree;
|
||||||
|
|
||||||
Assert(RT_PTR_ALLOC_IS_VALID(tree->ctl->root));
|
Assert(RT_PTR_ALLOC_IS_VALID(tree->ctl->root));
|
||||||
|
|||||||
@@ -1082,8 +1082,8 @@ plperl_build_tuple_result(HV *perlhash, TupleDesc td)
|
|||||||
HE *he;
|
HE *he;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
values = palloc0(sizeof(Datum) * td->natts);
|
values = palloc0_array(Datum, td->natts);
|
||||||
nulls = palloc(sizeof(bool) * td->natts);
|
nulls = palloc_array(bool, td->natts);
|
||||||
memset(nulls, true, sizeof(bool) * td->natts);
|
memset(nulls, true, sizeof(bool) * td->natts);
|
||||||
|
|
||||||
hv_iterinit(perlhash);
|
hv_iterinit(perlhash);
|
||||||
@@ -1502,7 +1502,7 @@ plperl_ref_from_pg_array(Datum arg, Oid typid)
|
|||||||
* Currently we make no effort to cache any of the stuff we look up here,
|
* Currently we make no effort to cache any of the stuff we look up here,
|
||||||
* which is bad.
|
* which is bad.
|
||||||
*/
|
*/
|
||||||
info = palloc0(sizeof(plperl_array_info));
|
info = palloc0_object(plperl_array_info);
|
||||||
|
|
||||||
/* get element type information, including output conversion function */
|
/* get element type information, including output conversion function */
|
||||||
get_type_io_data(elementtype, IOFunc_output,
|
get_type_io_data(elementtype, IOFunc_output,
|
||||||
@@ -1538,7 +1538,7 @@ plperl_ref_from_pg_array(Datum arg, Oid typid)
|
|||||||
&nitems);
|
&nitems);
|
||||||
|
|
||||||
/* Get total number of elements in each dimension */
|
/* Get total number of elements in each dimension */
|
||||||
info->nelems = palloc(sizeof(int) * info->ndims);
|
info->nelems = palloc_array(int, info->ndims);
|
||||||
info->nelems[0] = nitems;
|
info->nelems[0] = nitems;
|
||||||
for (i = 1; i < info->ndims; i++)
|
for (i = 1; i < info->ndims; i++)
|
||||||
info->nelems[i] = info->nelems[i - 1] / dims[i - 1];
|
info->nelems[i] = info->nelems[i - 1] / dims[i - 1];
|
||||||
@@ -2797,7 +2797,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
|
|||||||
* struct prodesc and subsidiary data must all live in proc_cxt.
|
* struct prodesc and subsidiary data must all live in proc_cxt.
|
||||||
************************************************************/
|
************************************************************/
|
||||||
oldcontext = MemoryContextSwitchTo(proc_cxt);
|
oldcontext = MemoryContextSwitchTo(proc_cxt);
|
||||||
prodesc = (plperl_proc_desc *) palloc0(sizeof(plperl_proc_desc));
|
prodesc = palloc0_object(plperl_proc_desc);
|
||||||
prodesc->proname = pstrdup(NameStr(procStruct->proname));
|
prodesc->proname = pstrdup(NameStr(procStruct->proname));
|
||||||
MemoryContextSetIdentifier(proc_cxt, prodesc->proname);
|
MemoryContextSetIdentifier(proc_cxt, prodesc->proname);
|
||||||
prodesc->fn_cxt = proc_cxt;
|
prodesc->fn_cxt = proc_cxt;
|
||||||
@@ -3596,7 +3596,7 @@ plperl_spi_prepare(char *query, int argc, SV **argv)
|
|||||||
"PL/Perl spi_prepare query",
|
"PL/Perl spi_prepare query",
|
||||||
ALLOCSET_SMALL_SIZES);
|
ALLOCSET_SMALL_SIZES);
|
||||||
MemoryContextSwitchTo(plan_cxt);
|
MemoryContextSwitchTo(plan_cxt);
|
||||||
qdesc = (plperl_query_desc *) palloc0(sizeof(plperl_query_desc));
|
qdesc = palloc0_object(plperl_query_desc);
|
||||||
snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc);
|
snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc);
|
||||||
qdesc->plan_cxt = plan_cxt;
|
qdesc->plan_cxt = plan_cxt;
|
||||||
qdesc->nargs = argc;
|
qdesc->nargs = argc;
|
||||||
|
|||||||
@@ -298,8 +298,8 @@ plpgsql_compile_callback(FunctionCallInfo fcinfo,
|
|||||||
forValidator,
|
forValidator,
|
||||||
plpgsql_error_funcname);
|
plpgsql_error_funcname);
|
||||||
|
|
||||||
in_arg_varnos = (int *) palloc(numargs * sizeof(int));
|
in_arg_varnos = palloc_array(int, numargs);
|
||||||
out_arg_variables = (PLpgSQL_variable **) palloc(numargs * sizeof(PLpgSQL_variable *));
|
out_arg_variables = palloc_array(PLpgSQL_variable *, numargs);
|
||||||
|
|
||||||
MemoryContextSwitchTo(func_cxt);
|
MemoryContextSwitchTo(func_cxt);
|
||||||
|
|
||||||
@@ -772,7 +772,7 @@ plpgsql_compile_inline(char *proc_source)
|
|||||||
plpgsql_check_syntax = check_function_bodies;
|
plpgsql_check_syntax = check_function_bodies;
|
||||||
|
|
||||||
/* Function struct does not live past current statement */
|
/* Function struct does not live past current statement */
|
||||||
function = (PLpgSQL_function *) palloc0(sizeof(PLpgSQL_function));
|
function = palloc0_object(PLpgSQL_function);
|
||||||
|
|
||||||
plpgsql_curr_compile = function;
|
plpgsql_curr_compile = function;
|
||||||
|
|
||||||
@@ -954,7 +954,7 @@ add_dummy_return(PLpgSQL_function *function)
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_block *new;
|
PLpgSQL_stmt_block *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_block));
|
new = palloc0_object(PLpgSQL_stmt_block);
|
||||||
new->cmd_type = PLPGSQL_STMT_BLOCK;
|
new->cmd_type = PLPGSQL_STMT_BLOCK;
|
||||||
new->stmtid = ++function->nstatements;
|
new->stmtid = ++function->nstatements;
|
||||||
new->body = list_make1(function->action);
|
new->body = list_make1(function->action);
|
||||||
@@ -966,7 +966,7 @@ add_dummy_return(PLpgSQL_function *function)
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_return *new;
|
PLpgSQL_stmt_return *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_return));
|
new = palloc0_object(PLpgSQL_stmt_return);
|
||||||
new->cmd_type = PLPGSQL_STMT_RETURN;
|
new->cmd_type = PLPGSQL_STMT_RETURN;
|
||||||
new->stmtid = ++function->nstatements;
|
new->stmtid = ++function->nstatements;
|
||||||
new->expr = NULL;
|
new->expr = NULL;
|
||||||
@@ -1776,7 +1776,7 @@ plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype,
|
|||||||
/* Ordinary scalar datatype */
|
/* Ordinary scalar datatype */
|
||||||
PLpgSQL_var *var;
|
PLpgSQL_var *var;
|
||||||
|
|
||||||
var = palloc0(sizeof(PLpgSQL_var));
|
var = palloc0_object(PLpgSQL_var);
|
||||||
var->dtype = PLPGSQL_DTYPE_VAR;
|
var->dtype = PLPGSQL_DTYPE_VAR;
|
||||||
var->refname = pstrdup(refname);
|
var->refname = pstrdup(refname);
|
||||||
var->lineno = lineno;
|
var->lineno = lineno;
|
||||||
@@ -1833,7 +1833,7 @@ plpgsql_build_record(const char *refname, int lineno,
|
|||||||
{
|
{
|
||||||
PLpgSQL_rec *rec;
|
PLpgSQL_rec *rec;
|
||||||
|
|
||||||
rec = palloc0(sizeof(PLpgSQL_rec));
|
rec = palloc0_object(PLpgSQL_rec);
|
||||||
rec->dtype = PLPGSQL_DTYPE_REC;
|
rec->dtype = PLPGSQL_DTYPE_REC;
|
||||||
rec->refname = pstrdup(refname);
|
rec->refname = pstrdup(refname);
|
||||||
rec->lineno = lineno;
|
rec->lineno = lineno;
|
||||||
@@ -1859,14 +1859,14 @@ build_row_from_vars(PLpgSQL_variable **vars, int numvars)
|
|||||||
PLpgSQL_row *row;
|
PLpgSQL_row *row;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
row = palloc0(sizeof(PLpgSQL_row));
|
row = palloc0_object(PLpgSQL_row);
|
||||||
row->dtype = PLPGSQL_DTYPE_ROW;
|
row->dtype = PLPGSQL_DTYPE_ROW;
|
||||||
row->refname = "(unnamed row)";
|
row->refname = "(unnamed row)";
|
||||||
row->lineno = -1;
|
row->lineno = -1;
|
||||||
row->rowtupdesc = CreateTemplateTupleDesc(numvars);
|
row->rowtupdesc = CreateTemplateTupleDesc(numvars);
|
||||||
row->nfields = numvars;
|
row->nfields = numvars;
|
||||||
row->fieldnames = palloc(numvars * sizeof(char *));
|
row->fieldnames = palloc_array(char *, numvars);
|
||||||
row->varnos = palloc(numvars * sizeof(int));
|
row->varnos = palloc_array(int, numvars);
|
||||||
|
|
||||||
for (i = 0; i < numvars; i++)
|
for (i = 0; i < numvars; i++)
|
||||||
{
|
{
|
||||||
@@ -1940,7 +1940,7 @@ plpgsql_build_recfield(PLpgSQL_rec *rec, const char *fldname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* nope, so make a new one */
|
/* nope, so make a new one */
|
||||||
recfield = palloc0(sizeof(PLpgSQL_recfield));
|
recfield = palloc0_object(PLpgSQL_recfield);
|
||||||
recfield->dtype = PLPGSQL_DTYPE_RECFIELD;
|
recfield->dtype = PLPGSQL_DTYPE_RECFIELD;
|
||||||
recfield->fieldname = pstrdup(fldname);
|
recfield->fieldname = pstrdup(fldname);
|
||||||
recfield->recparentno = rec->dno;
|
recfield->recparentno = rec->dno;
|
||||||
@@ -2004,7 +2004,7 @@ build_datatype(HeapTuple typeTup, int32 typmod,
|
|||||||
errmsg("type \"%s\" is only a shell",
|
errmsg("type \"%s\" is only a shell",
|
||||||
NameStr(typeStruct->typname))));
|
NameStr(typeStruct->typname))));
|
||||||
|
|
||||||
typ = (PLpgSQL_type *) palloc(sizeof(PLpgSQL_type));
|
typ = palloc_object(PLpgSQL_type);
|
||||||
|
|
||||||
typ->typname = pstrdup(NameStr(typeStruct->typname));
|
typ->typname = pstrdup(NameStr(typeStruct->typname));
|
||||||
typ->typoid = typeStruct->oid;
|
typ->typoid = typeStruct->oid;
|
||||||
@@ -2184,7 +2184,7 @@ plpgsql_parse_err_condition(char *condname)
|
|||||||
|
|
||||||
if (strcmp(condname, "others") == 0)
|
if (strcmp(condname, "others") == 0)
|
||||||
{
|
{
|
||||||
new = palloc(sizeof(PLpgSQL_condition));
|
new = palloc_object(PLpgSQL_condition);
|
||||||
new->sqlerrstate = PLPGSQL_OTHERS;
|
new->sqlerrstate = PLPGSQL_OTHERS;
|
||||||
new->condname = condname;
|
new->condname = condname;
|
||||||
new->next = NULL;
|
new->next = NULL;
|
||||||
@@ -2196,7 +2196,7 @@ plpgsql_parse_err_condition(char *condname)
|
|||||||
{
|
{
|
||||||
if (strcmp(condname, exception_label_map[i].label) == 0)
|
if (strcmp(condname, exception_label_map[i].label) == 0)
|
||||||
{
|
{
|
||||||
new = palloc(sizeof(PLpgSQL_condition));
|
new = palloc_object(PLpgSQL_condition);
|
||||||
new->sqlerrstate = exception_label_map[i].sqlerrstate;
|
new->sqlerrstate = exception_label_map[i].sqlerrstate;
|
||||||
new->condname = condname;
|
new->condname = condname;
|
||||||
new->next = prev;
|
new->next = prev;
|
||||||
@@ -2258,7 +2258,7 @@ plpgsql_finish_datums(PLpgSQL_function *function)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
function->ndatums = plpgsql_nDatums;
|
function->ndatums = plpgsql_nDatums;
|
||||||
function->datums = palloc(sizeof(PLpgSQL_datum *) * plpgsql_nDatums);
|
function->datums = palloc_array(PLpgSQL_datum *, plpgsql_nDatums);
|
||||||
for (i = 0; i < plpgsql_nDatums; i++)
|
for (i = 0; i < plpgsql_nDatums; i++)
|
||||||
{
|
{
|
||||||
function->datums[i] = plpgsql_Datums[i];
|
function->datums[i] = plpgsql_Datums[i];
|
||||||
@@ -2323,7 +2323,7 @@ plpgsql_add_initdatums(int **varnos)
|
|||||||
{
|
{
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
*varnos = (int *) palloc(sizeof(int) * n);
|
*varnos = palloc_array(int, n);
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
for (i = datums_last; i < plpgsql_nDatums; i++)
|
for (i = datums_last; i < plpgsql_nDatums; i++)
|
||||||
|
|||||||
@@ -1318,8 +1318,7 @@ copy_plpgsql_datums(PLpgSQL_execstate *estate,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Allocate local datum-pointer array */
|
/* Allocate local datum-pointer array */
|
||||||
estate->datums = (PLpgSQL_datum **)
|
estate->datums = palloc_array(PLpgSQL_datum *, ndatums);
|
||||||
palloc(sizeof(PLpgSQL_datum *) * ndatums);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To reduce palloc overhead, we make a single palloc request for all the
|
* To reduce palloc overhead, we make a single palloc request for all the
|
||||||
@@ -1497,7 +1496,7 @@ plpgsql_fulfill_promise(PLpgSQL_execstate *estate,
|
|||||||
int lbs[1];
|
int lbs[1];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
elems = palloc(sizeof(Datum) * nelems);
|
elems = palloc_array(Datum, nelems);
|
||||||
for (i = 0; i < nelems; i++)
|
for (i = 0; i < nelems; i++)
|
||||||
elems[i] = CStringGetTextDatum(estate->trigdata->tg_trigger->tgargs[i]);
|
elems[i] = CStringGetTextDatum(estate->trigdata->tg_trigger->tgargs[i]);
|
||||||
dims[0] = nelems;
|
dims[0] = nelems;
|
||||||
@@ -2340,11 +2339,11 @@ make_callstmt_target(PLpgSQL_execstate *estate, PLpgSQL_expr *expr)
|
|||||||
*/
|
*/
|
||||||
MemoryContextSwitchTo(estate->func->fn_cxt);
|
MemoryContextSwitchTo(estate->func->fn_cxt);
|
||||||
|
|
||||||
row = (PLpgSQL_row *) palloc0(sizeof(PLpgSQL_row));
|
row = palloc0_object(PLpgSQL_row);
|
||||||
row->dtype = PLPGSQL_DTYPE_ROW;
|
row->dtype = PLPGSQL_DTYPE_ROW;
|
||||||
row->refname = "(unnamed row)";
|
row->refname = "(unnamed row)";
|
||||||
row->lineno = -1;
|
row->lineno = -1;
|
||||||
row->varnos = (int *) palloc(numargs * sizeof(int));
|
row->varnos = palloc_array(int, numargs);
|
||||||
|
|
||||||
MemoryContextSwitchTo(get_eval_mcontext(estate));
|
MemoryContextSwitchTo(get_eval_mcontext(estate));
|
||||||
|
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ pl_block : decl_sect K_BEGIN proc_sect exception_sect K_END opt_label
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_block *new;
|
PLpgSQL_stmt_block *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_block));
|
new = palloc0_object(PLpgSQL_stmt_block);
|
||||||
|
|
||||||
new->cmd_type = PLPGSQL_STMT_BLOCK;
|
new->cmd_type = PLPGSQL_STMT_BLOCK;
|
||||||
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
||||||
@@ -606,14 +606,14 @@ decl_cursor_args :
|
|||||||
int i;
|
int i;
|
||||||
ListCell *l;
|
ListCell *l;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_row));
|
new = palloc0_object(PLpgSQL_row);
|
||||||
new->dtype = PLPGSQL_DTYPE_ROW;
|
new->dtype = PLPGSQL_DTYPE_ROW;
|
||||||
new->refname = "(unnamed row)";
|
new->refname = "(unnamed row)";
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->rowtupdesc = NULL;
|
new->rowtupdesc = NULL;
|
||||||
new->nfields = list_length($2);
|
new->nfields = list_length($2);
|
||||||
new->fieldnames = palloc(new->nfields * sizeof(char *));
|
new->fieldnames = palloc_array(char *, new->nfields);
|
||||||
new->varnos = palloc(new->nfields * sizeof(int));
|
new->varnos = palloc_array(int, new->nfields);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
foreach (l, $2)
|
foreach (l, $2)
|
||||||
@@ -898,7 +898,7 @@ stmt_perform : K_PERFORM
|
|||||||
PLpgSQL_stmt_perform *new;
|
PLpgSQL_stmt_perform *new;
|
||||||
int startloc;
|
int startloc;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_perform));
|
new = palloc0_object(PLpgSQL_stmt_perform);
|
||||||
new->cmd_type = PLPGSQL_STMT_PERFORM;
|
new->cmd_type = PLPGSQL_STMT_PERFORM;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -934,7 +934,7 @@ stmt_call : K_CALL
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_call *new;
|
PLpgSQL_stmt_call *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_call));
|
new = palloc0_object(PLpgSQL_stmt_call);
|
||||||
new->cmd_type = PLPGSQL_STMT_CALL;
|
new->cmd_type = PLPGSQL_STMT_CALL;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -953,7 +953,7 @@ stmt_call : K_CALL
|
|||||||
/* use the same structures as for CALL, for simplicity */
|
/* use the same structures as for CALL, for simplicity */
|
||||||
PLpgSQL_stmt_call *new;
|
PLpgSQL_stmt_call *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_call));
|
new = palloc0_object(PLpgSQL_stmt_call);
|
||||||
new->cmd_type = PLPGSQL_STMT_CALL;
|
new->cmd_type = PLPGSQL_STMT_CALL;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -992,7 +992,7 @@ stmt_assign : T_DATUM
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_assignable($1.datum, @1, yyscanner);
|
check_assignable($1.datum, @1, yyscanner);
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_assign));
|
new = palloc0_object(PLpgSQL_stmt_assign);
|
||||||
new->cmd_type = PLPGSQL_STMT_ASSIGN;
|
new->cmd_type = PLPGSQL_STMT_ASSIGN;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -1015,7 +1015,7 @@ stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';'
|
|||||||
PLpgSQL_stmt_getdiag *new;
|
PLpgSQL_stmt_getdiag *new;
|
||||||
ListCell *lc;
|
ListCell *lc;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_getdiag));
|
new = palloc0_object(PLpgSQL_stmt_getdiag);
|
||||||
new->cmd_type = PLPGSQL_STMT_GETDIAG;
|
new->cmd_type = PLPGSQL_STMT_GETDIAG;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -1101,7 +1101,7 @@ getdiag_list_item : getdiag_target assign_operator getdiag_item
|
|||||||
{
|
{
|
||||||
PLpgSQL_diag_item *new;
|
PLpgSQL_diag_item *new;
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_diag_item));
|
new = palloc_object(PLpgSQL_diag_item);
|
||||||
new->target = $1->dno;
|
new->target = $1->dno;
|
||||||
new->kind = $3;
|
new->kind = $3;
|
||||||
|
|
||||||
@@ -1191,7 +1191,7 @@ stmt_if : K_IF expr_until_then proc_sect stmt_elsifs stmt_else K_END K_IF ';'
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_if *new;
|
PLpgSQL_stmt_if *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_if));
|
new = palloc0_object(PLpgSQL_stmt_if);
|
||||||
new->cmd_type = PLPGSQL_STMT_IF;
|
new->cmd_type = PLPGSQL_STMT_IF;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -1212,7 +1212,7 @@ stmt_elsifs :
|
|||||||
{
|
{
|
||||||
PLpgSQL_if_elsif *new;
|
PLpgSQL_if_elsif *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_if_elsif));
|
new = palloc0_object(PLpgSQL_if_elsif);
|
||||||
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
||||||
new->cond = $3;
|
new->cond = $3;
|
||||||
new->stmts = $4;
|
new->stmts = $4;
|
||||||
@@ -1264,7 +1264,7 @@ case_when_list : case_when_list case_when
|
|||||||
|
|
||||||
case_when : K_WHEN expr_until_then proc_sect
|
case_when : K_WHEN expr_until_then proc_sect
|
||||||
{
|
{
|
||||||
PLpgSQL_case_when *new = palloc(sizeof(PLpgSQL_case_when));
|
PLpgSQL_case_when *new = palloc_object(PLpgSQL_case_when);
|
||||||
|
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->expr = $2;
|
new->expr = $2;
|
||||||
@@ -1296,7 +1296,7 @@ stmt_loop : opt_loop_label K_LOOP loop_body
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_loop *new;
|
PLpgSQL_stmt_loop *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_loop));
|
new = palloc0_object(PLpgSQL_stmt_loop);
|
||||||
new->cmd_type = PLPGSQL_STMT_LOOP;
|
new->cmd_type = PLPGSQL_STMT_LOOP;
|
||||||
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -1314,7 +1314,7 @@ stmt_while : opt_loop_label K_WHILE expr_until_loop loop_body
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_while *new;
|
PLpgSQL_stmt_while *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_while));
|
new = palloc0_object(PLpgSQL_stmt_while);
|
||||||
new->cmd_type = PLPGSQL_STMT_WHILE;
|
new->cmd_type = PLPGSQL_STMT_WHILE;
|
||||||
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -1380,7 +1380,7 @@ for_control : for_variable K_IN
|
|||||||
"LOOP or USING",
|
"LOOP or USING",
|
||||||
&term, &yylval, &yylloc, yyscanner);
|
&term, &yylval, &yylloc, yyscanner);
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_dynfors));
|
new = palloc0_object(PLpgSQL_stmt_dynfors);
|
||||||
new->cmd_type = PLPGSQL_STMT_DYNFORS;
|
new->cmd_type = PLPGSQL_STMT_DYNFORS;
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
if ($1.row)
|
if ($1.row)
|
||||||
@@ -1426,7 +1426,7 @@ for_control : for_variable K_IN
|
|||||||
PLpgSQL_stmt_forc *new;
|
PLpgSQL_stmt_forc *new;
|
||||||
PLpgSQL_var *cursor = (PLpgSQL_var *) yylval.wdatum.datum;
|
PLpgSQL_var *cursor = (PLpgSQL_var *) yylval.wdatum.datum;
|
||||||
|
|
||||||
new = (PLpgSQL_stmt_forc *) palloc0(sizeof(PLpgSQL_stmt_forc));
|
new = palloc0_object(PLpgSQL_stmt_forc);
|
||||||
new->cmd_type = PLPGSQL_STMT_FORC;
|
new->cmd_type = PLPGSQL_STMT_FORC;
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
new->curvar = cursor->dno;
|
new->curvar = cursor->dno;
|
||||||
@@ -1545,7 +1545,7 @@ for_control : for_variable K_IN
|
|||||||
NULL),
|
NULL),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_fori));
|
new = palloc0_object(PLpgSQL_stmt_fori);
|
||||||
new->cmd_type = PLPGSQL_STMT_FORI;
|
new->cmd_type = PLPGSQL_STMT_FORI;
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
new->var = fvar;
|
new->var = fvar;
|
||||||
@@ -1573,7 +1573,7 @@ for_control : for_variable K_IN
|
|||||||
check_sql_expr(expr1->query, expr1->parseMode,
|
check_sql_expr(expr1->query, expr1->parseMode,
|
||||||
expr1loc, yyscanner);
|
expr1loc, yyscanner);
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_fors));
|
new = palloc0_object(PLpgSQL_stmt_fors);
|
||||||
new->cmd_type = PLPGSQL_STMT_FORS;
|
new->cmd_type = PLPGSQL_STMT_FORS;
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
if ($1.row)
|
if ($1.row)
|
||||||
@@ -1675,7 +1675,7 @@ stmt_foreach_a : opt_loop_label K_FOREACH for_variable foreach_slice K_IN K_ARRA
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_foreach_a *new;
|
PLpgSQL_stmt_foreach_a *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_foreach_a));
|
new = palloc0_object(PLpgSQL_stmt_foreach_a);
|
||||||
new->cmd_type = PLPGSQL_STMT_FOREACH_A;
|
new->cmd_type = PLPGSQL_STMT_FOREACH_A;
|
||||||
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@2, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -1723,7 +1723,7 @@ stmt_exit : exit_type opt_label opt_exitcond
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_exit *new;
|
PLpgSQL_stmt_exit *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_exit));
|
new = palloc0_object(PLpgSQL_stmt_exit);
|
||||||
new->cmd_type = PLPGSQL_STMT_EXIT;
|
new->cmd_type = PLPGSQL_STMT_EXIT;
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
new->is_exit = $1;
|
new->is_exit = $1;
|
||||||
@@ -1813,7 +1813,7 @@ stmt_raise : K_RAISE
|
|||||||
PLpgSQL_stmt_raise *new;
|
PLpgSQL_stmt_raise *new;
|
||||||
int tok;
|
int tok;
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_stmt_raise));
|
new = palloc_object(PLpgSQL_stmt_raise);
|
||||||
|
|
||||||
new->cmd_type = PLPGSQL_STMT_RAISE;
|
new->cmd_type = PLPGSQL_STMT_RAISE;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
@@ -1959,7 +1959,7 @@ stmt_assert : K_ASSERT
|
|||||||
PLpgSQL_stmt_assert *new;
|
PLpgSQL_stmt_assert *new;
|
||||||
int tok;
|
int tok;
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_stmt_assert));
|
new = palloc_object(PLpgSQL_stmt_assert);
|
||||||
|
|
||||||
new->cmd_type = PLPGSQL_STMT_ASSERT;
|
new->cmd_type = PLPGSQL_STMT_ASSERT;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
@@ -2045,7 +2045,7 @@ stmt_dynexecute : K_EXECUTE
|
|||||||
NULL, &endtoken,
|
NULL, &endtoken,
|
||||||
&yylval, &yylloc, yyscanner);
|
&yylval, &yylloc, yyscanner);
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_stmt_dynexecute));
|
new = palloc_object(PLpgSQL_stmt_dynexecute);
|
||||||
new->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
|
new->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -2103,7 +2103,7 @@ stmt_open : K_OPEN cursor_variable
|
|||||||
PLpgSQL_stmt_open *new;
|
PLpgSQL_stmt_open *new;
|
||||||
int tok;
|
int tok;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_open));
|
new = palloc0_object(PLpgSQL_stmt_open);
|
||||||
new->cmd_type = PLPGSQL_STMT_OPEN;
|
new->cmd_type = PLPGSQL_STMT_OPEN;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -2229,7 +2229,7 @@ stmt_close : K_CLOSE cursor_variable ';'
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_close *new;
|
PLpgSQL_stmt_close *new;
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_stmt_close));
|
new = palloc_object(PLpgSQL_stmt_close);
|
||||||
new->cmd_type = PLPGSQL_STMT_CLOSE;
|
new->cmd_type = PLPGSQL_STMT_CLOSE;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -2250,7 +2250,7 @@ stmt_commit : K_COMMIT opt_transaction_chain ';'
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_commit *new;
|
PLpgSQL_stmt_commit *new;
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_stmt_commit));
|
new = palloc_object(PLpgSQL_stmt_commit);
|
||||||
new->cmd_type = PLPGSQL_STMT_COMMIT;
|
new->cmd_type = PLPGSQL_STMT_COMMIT;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -2264,7 +2264,7 @@ stmt_rollback : K_ROLLBACK opt_transaction_chain ';'
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_rollback *new;
|
PLpgSQL_stmt_rollback *new;
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_stmt_rollback));
|
new = palloc_object(PLpgSQL_stmt_rollback);
|
||||||
new->cmd_type = PLPGSQL_STMT_ROLLBACK;
|
new->cmd_type = PLPGSQL_STMT_ROLLBACK;
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -2327,7 +2327,7 @@ exception_sect :
|
|||||||
* current block.
|
* current block.
|
||||||
*/
|
*/
|
||||||
int lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
int lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
PLpgSQL_exception_block *new = palloc(sizeof(PLpgSQL_exception_block));
|
PLpgSQL_exception_block *new = palloc_object(PLpgSQL_exception_block);
|
||||||
PLpgSQL_variable *var;
|
PLpgSQL_variable *var;
|
||||||
|
|
||||||
plpgsql_curr_compile->has_exception_block = true;
|
plpgsql_curr_compile->has_exception_block = true;
|
||||||
@@ -2375,7 +2375,7 @@ proc_exception : K_WHEN proc_conditions K_THEN proc_sect
|
|||||||
{
|
{
|
||||||
PLpgSQL_exception *new;
|
PLpgSQL_exception *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_exception));
|
new = palloc0_object(PLpgSQL_exception);
|
||||||
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(@1, yyscanner);
|
||||||
new->conditions = $2;
|
new->conditions = $2;
|
||||||
new->action = $4;
|
new->action = $4;
|
||||||
@@ -2420,7 +2420,7 @@ proc_condition : any_identifier
|
|||||||
if (strspn(sqlstatestr, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != 5)
|
if (strspn(sqlstatestr, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != 5)
|
||||||
yyerror(&yylloc, NULL, yyscanner, "invalid SQLSTATE code");
|
yyerror(&yylloc, NULL, yyscanner, "invalid SQLSTATE code");
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_condition));
|
new = palloc_object(PLpgSQL_condition);
|
||||||
new->sqlerrstate =
|
new->sqlerrstate =
|
||||||
MAKE_SQLSTATE(sqlstatestr[0],
|
MAKE_SQLSTATE(sqlstatestr[0],
|
||||||
sqlstatestr[1],
|
sqlstatestr[1],
|
||||||
@@ -2671,7 +2671,7 @@ static PLpgSQL_expr *
|
|||||||
make_plpgsql_expr(const char *query,
|
make_plpgsql_expr(const char *query,
|
||||||
RawParseMode parsemode)
|
RawParseMode parsemode)
|
||||||
{
|
{
|
||||||
PLpgSQL_expr *expr = palloc0(sizeof(PLpgSQL_expr));
|
PLpgSQL_expr *expr = palloc0_object(PLpgSQL_expr);
|
||||||
|
|
||||||
expr->query = pstrdup(query);
|
expr->query = pstrdup(query);
|
||||||
expr->parseMode = parsemode;
|
expr->parseMode = parsemode;
|
||||||
@@ -3181,7 +3181,7 @@ make_execsql_stmt(int firsttoken, int location, PLword *word, YYSTYPE *yylvalp,
|
|||||||
|
|
||||||
check_sql_expr(expr->query, expr->parseMode, location, yyscanner);
|
check_sql_expr(expr->query, expr->parseMode, location, yyscanner);
|
||||||
|
|
||||||
execsql = palloc0(sizeof(PLpgSQL_stmt_execsql));
|
execsql = palloc0_object(PLpgSQL_stmt_execsql);
|
||||||
execsql->cmd_type = PLPGSQL_STMT_EXECSQL;
|
execsql->cmd_type = PLPGSQL_STMT_EXECSQL;
|
||||||
execsql->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
execsql->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
||||||
execsql->stmtid = ++plpgsql_curr_compile->nstatements;
|
execsql->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -3208,7 +3208,7 @@ read_fetch_direction(YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
|
|||||||
* We create the PLpgSQL_stmt_fetch struct here, but only fill in the
|
* We create the PLpgSQL_stmt_fetch struct here, but only fill in the
|
||||||
* fields arising from the optional direction clause
|
* fields arising from the optional direction clause
|
||||||
*/
|
*/
|
||||||
fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch));
|
fetch = (PLpgSQL_stmt_fetch *) palloc0_object(PLpgSQL_stmt_fetch);
|
||||||
fetch->cmd_type = PLPGSQL_STMT_FETCH;
|
fetch->cmd_type = PLPGSQL_STMT_FETCH;
|
||||||
fetch->stmtid = ++plpgsql_curr_compile->nstatements;
|
fetch->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
/* set direction defaults: */
|
/* set direction defaults: */
|
||||||
@@ -3360,7 +3360,7 @@ make_return_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yysc
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_return *new;
|
PLpgSQL_stmt_return *new;
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_return));
|
new = palloc0_object(PLpgSQL_stmt_return);
|
||||||
new->cmd_type = PLPGSQL_STMT_RETURN;
|
new->cmd_type = PLPGSQL_STMT_RETURN;
|
||||||
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -3448,7 +3448,7 @@ make_return_next_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t
|
|||||||
errmsg("cannot use RETURN NEXT in a non-SETOF function"),
|
errmsg("cannot use RETURN NEXT in a non-SETOF function"),
|
||||||
parser_errposition(location)));
|
parser_errposition(location)));
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_return_next));
|
new = palloc0_object(PLpgSQL_stmt_return_next);
|
||||||
new->cmd_type = PLPGSQL_STMT_RETURN_NEXT;
|
new->cmd_type = PLPGSQL_STMT_RETURN_NEXT;
|
||||||
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -3512,7 +3512,7 @@ make_return_query_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_
|
|||||||
errmsg("cannot use RETURN QUERY in a non-SETOF function"),
|
errmsg("cannot use RETURN QUERY in a non-SETOF function"),
|
||||||
parser_errposition(location)));
|
parser_errposition(location)));
|
||||||
|
|
||||||
new = palloc0(sizeof(PLpgSQL_stmt_return_query));
|
new = palloc0_object(PLpgSQL_stmt_return_query);
|
||||||
new->cmd_type = PLPGSQL_STMT_RETURN_QUERY;
|
new->cmd_type = PLPGSQL_STMT_RETURN_QUERY;
|
||||||
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
@@ -3706,14 +3706,14 @@ read_into_scalar_list(char *initial_name,
|
|||||||
*/
|
*/
|
||||||
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
|
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
|
||||||
|
|
||||||
row = palloc0(sizeof(PLpgSQL_row));
|
row = palloc0_object(PLpgSQL_row);
|
||||||
row->dtype = PLPGSQL_DTYPE_ROW;
|
row->dtype = PLPGSQL_DTYPE_ROW;
|
||||||
row->refname = "(unnamed row)";
|
row->refname = "(unnamed row)";
|
||||||
row->lineno = plpgsql_location_to_lineno(initial_location, yyscanner);
|
row->lineno = plpgsql_location_to_lineno(initial_location, yyscanner);
|
||||||
row->rowtupdesc = NULL;
|
row->rowtupdesc = NULL;
|
||||||
row->nfields = nfields;
|
row->nfields = nfields;
|
||||||
row->fieldnames = palloc(sizeof(char *) * nfields);
|
row->fieldnames = palloc_array(char *, nfields);
|
||||||
row->varnos = palloc(sizeof(int) * nfields);
|
row->varnos = palloc_array(int, nfields);
|
||||||
while (--nfields >= 0)
|
while (--nfields >= 0)
|
||||||
{
|
{
|
||||||
row->fieldnames[nfields] = fieldnames[nfields];
|
row->fieldnames[nfields] = fieldnames[nfields];
|
||||||
@@ -3741,14 +3741,14 @@ make_scalar_list1(char *initial_name,
|
|||||||
|
|
||||||
check_assignable(initial_datum, location, yyscanner);
|
check_assignable(initial_datum, location, yyscanner);
|
||||||
|
|
||||||
row = palloc0(sizeof(PLpgSQL_row));
|
row = palloc0_object(PLpgSQL_row);
|
||||||
row->dtype = PLPGSQL_DTYPE_ROW;
|
row->dtype = PLPGSQL_DTYPE_ROW;
|
||||||
row->refname = "(unnamed row)";
|
row->refname = "(unnamed row)";
|
||||||
row->lineno = lineno;
|
row->lineno = lineno;
|
||||||
row->rowtupdesc = NULL;
|
row->rowtupdesc = NULL;
|
||||||
row->nfields = 1;
|
row->nfields = 1;
|
||||||
row->fieldnames = palloc(sizeof(char *));
|
row->fieldnames = palloc_object(char *);
|
||||||
row->varnos = palloc(sizeof(int));
|
row->varnos = palloc_object(int);
|
||||||
row->fieldnames[0] = initial_name;
|
row->fieldnames[0] = initial_name;
|
||||||
row->varnos[0] = initial_datum->dno;
|
row->varnos[0] = initial_datum->dno;
|
||||||
|
|
||||||
@@ -3955,7 +3955,7 @@ read_cursor_args(PLpgSQL_var *cursor, int until, YYSTYPE *yylvalp, YYLTYPE *yyll
|
|||||||
* Read the arguments, one by one.
|
* Read the arguments, one by one.
|
||||||
*/
|
*/
|
||||||
row = (PLpgSQL_row *) plpgsql_Datums[cursor->cursor_explicit_argrow];
|
row = (PLpgSQL_row *) plpgsql_Datums[cursor->cursor_explicit_argrow];
|
||||||
argv = (char **) palloc0(row->nfields * sizeof(char *));
|
argv = (char **) palloc0_array(char *, row->nfields);
|
||||||
|
|
||||||
for (argc = 0; argc < row->nfields; argc++)
|
for (argc = 0; argc < row->nfields; argc++)
|
||||||
{
|
{
|
||||||
@@ -4091,7 +4091,7 @@ read_raise_options(YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
|
|||||||
if ((tok = yylex(yylvalp, yyllocp, yyscanner)) == 0)
|
if ((tok = yylex(yylvalp, yyllocp, yyscanner)) == 0)
|
||||||
yyerror(yyllocp, NULL, yyscanner, "unexpected end of function definition");
|
yyerror(yyllocp, NULL, yyscanner, "unexpected end of function definition");
|
||||||
|
|
||||||
opt = (PLpgSQL_raise_option *) palloc(sizeof(PLpgSQL_raise_option));
|
opt = palloc_object(PLpgSQL_raise_option);
|
||||||
|
|
||||||
if (tok_is_keyword(tok, yylvalp,
|
if (tok_is_keyword(tok, yylvalp,
|
||||||
K_ERRCODE, "errcode"))
|
K_ERRCODE, "errcode"))
|
||||||
@@ -4182,7 +4182,7 @@ make_case(int location, PLpgSQL_expr *t_expr,
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_case *new;
|
PLpgSQL_stmt_case *new;
|
||||||
|
|
||||||
new = palloc(sizeof(PLpgSQL_stmt_case));
|
new = palloc_object(PLpgSQL_stmt_case);
|
||||||
new->cmd_type = PLPGSQL_STMT_CASE;
|
new->cmd_type = PLPGSQL_STMT_CASE;
|
||||||
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
|
||||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, PLyTrigType is_trigger)
|
|||||||
|
|
||||||
oldcxt = MemoryContextSwitchTo(cxt);
|
oldcxt = MemoryContextSwitchTo(cxt);
|
||||||
|
|
||||||
proc = (PLyProcedure *) palloc0(sizeof(PLyProcedure));
|
proc = palloc0_object(PLyProcedure);
|
||||||
proc->mcxt = cxt;
|
proc->mcxt = cxt;
|
||||||
|
|
||||||
PG_TRY();
|
PG_TRY();
|
||||||
@@ -293,8 +293,8 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, PLyTrigType is_trigger)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate arrays for per-input-argument data */
|
/* Allocate arrays for per-input-argument data */
|
||||||
proc->argnames = (char **) palloc0(sizeof(char *) * proc->nargs);
|
proc->argnames = (char **) palloc0_array(char *, proc->nargs);
|
||||||
proc->args = (PLyDatumToOb *) palloc0(sizeof(PLyDatumToOb) * proc->nargs);
|
proc->args = (PLyDatumToOb *) palloc0_array(PLyDatumToOb, proc->nargs);
|
||||||
|
|
||||||
for (i = pos = 0; i < total; i++)
|
for (i = pos = 0; i < total; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ PLy_spi_prepare(PyObject *self, PyObject *args)
|
|||||||
nargs = list ? PySequence_Length(list) : 0;
|
nargs = list ? PySequence_Length(list) : 0;
|
||||||
|
|
||||||
plan->nargs = nargs;
|
plan->nargs = nargs;
|
||||||
plan->types = nargs ? palloc0(sizeof(Oid) * nargs) : NULL;
|
plan->types = nargs ? palloc0_array(Oid, nargs) : NULL;
|
||||||
plan->args = nargs ? palloc0(sizeof(PLyObToDatum) * nargs) : NULL;
|
plan->args = nargs ? palloc0_array(PLyObToDatum, nargs) : NULL;
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
|
|
||||||
|
|||||||
@@ -1353,8 +1353,8 @@ PLyMapping_ToComposite(PLyObToDatum *arg, TupleDesc desc, PyObject *mapping)
|
|||||||
Assert(PyMapping_Check(mapping));
|
Assert(PyMapping_Check(mapping));
|
||||||
|
|
||||||
/* Build tuple */
|
/* Build tuple */
|
||||||
values = palloc(sizeof(Datum) * desc->natts);
|
values = palloc_array(Datum, desc->natts);
|
||||||
nulls = palloc(sizeof(bool) * desc->natts);
|
nulls = palloc_array(bool, desc->natts);
|
||||||
for (i = 0; i < desc->natts; ++i)
|
for (i = 0; i < desc->natts; ++i)
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
@@ -1435,8 +1435,8 @@ PLySequence_ToComposite(PLyObToDatum *arg, TupleDesc desc, PyObject *sequence)
|
|||||||
errmsg("length of returned sequence did not match number of columns in row")));
|
errmsg("length of returned sequence did not match number of columns in row")));
|
||||||
|
|
||||||
/* Build tuple */
|
/* Build tuple */
|
||||||
values = palloc(sizeof(Datum) * desc->natts);
|
values = palloc_array(Datum, desc->natts);
|
||||||
nulls = palloc(sizeof(bool) * desc->natts);
|
nulls = palloc_array(bool, desc->natts);
|
||||||
idx = 0;
|
idx = 0;
|
||||||
for (i = 0; i < desc->natts; ++i)
|
for (i = 0; i < desc->natts; ++i)
|
||||||
{
|
{
|
||||||
@@ -1493,8 +1493,8 @@ PLyGenericObject_ToComposite(PLyObToDatum *arg, TupleDesc desc, PyObject *object
|
|||||||
volatile int i;
|
volatile int i;
|
||||||
|
|
||||||
/* Build tuple */
|
/* Build tuple */
|
||||||
values = palloc(sizeof(Datum) * desc->natts);
|
values = palloc_array(Datum, desc->natts);
|
||||||
nulls = palloc(sizeof(bool) * desc->natts);
|
nulls = palloc_array(bool, desc->natts);
|
||||||
for (i = 0; i < desc->natts; ++i)
|
for (i = 0; i < desc->natts; ++i)
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
|
|||||||
@@ -1586,7 +1586,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
|
|||||||
* struct prodesc and subsidiary data must all live in proc_cxt.
|
* struct prodesc and subsidiary data must all live in proc_cxt.
|
||||||
************************************************************/
|
************************************************************/
|
||||||
oldcontext = MemoryContextSwitchTo(proc_cxt);
|
oldcontext = MemoryContextSwitchTo(proc_cxt);
|
||||||
prodesc = (pltcl_proc_desc *) palloc0(sizeof(pltcl_proc_desc));
|
prodesc = palloc0_object(pltcl_proc_desc);
|
||||||
prodesc->user_proname = pstrdup(user_proname);
|
prodesc->user_proname = pstrdup(user_proname);
|
||||||
MemoryContextSetIdentifier(proc_cxt, prodesc->user_proname);
|
MemoryContextSetIdentifier(proc_cxt, prodesc->user_proname);
|
||||||
prodesc->internal_proname = pstrdup(internal_proname);
|
prodesc->internal_proname = pstrdup(internal_proname);
|
||||||
@@ -2668,7 +2668,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
|
|||||||
"PL/Tcl spi_prepare query",
|
"PL/Tcl spi_prepare query",
|
||||||
ALLOCSET_SMALL_SIZES);
|
ALLOCSET_SMALL_SIZES);
|
||||||
MemoryContextSwitchTo(plan_cxt);
|
MemoryContextSwitchTo(plan_cxt);
|
||||||
qdesc = (pltcl_query_desc *) palloc0(sizeof(pltcl_query_desc));
|
qdesc = palloc0_object(pltcl_query_desc);
|
||||||
snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc);
|
snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc);
|
||||||
qdesc->nargs = nargs;
|
qdesc->nargs = nargs;
|
||||||
qdesc->argtypes = (Oid *) palloc(nargs * sizeof(Oid));
|
qdesc->argtypes = (Oid *) palloc(nargs * sizeof(Oid));
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ dibuild(Relation heap, Relation index, IndexInfo *indexInfo)
|
|||||||
{
|
{
|
||||||
IndexBuildResult *result;
|
IndexBuildResult *result;
|
||||||
|
|
||||||
result = (IndexBuildResult *) palloc(sizeof(IndexBuildResult));
|
result = palloc_object(IndexBuildResult);
|
||||||
|
|
||||||
/* let's pretend that no tuples were scanned */
|
/* let's pretend that no tuples were scanned */
|
||||||
result->heap_tuples = 0;
|
result->heap_tuples = 0;
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ spgist_name_choose(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
out->result.splitTuple.prefixNNodes = 1;
|
out->result.splitTuple.prefixNNodes = 1;
|
||||||
out->result.splitTuple.prefixNodeLabels =
|
out->result.splitTuple.prefixNodeLabels =
|
||||||
(Datum *) palloc(sizeof(Datum));
|
palloc_object(Datum);
|
||||||
out->result.splitTuple.prefixNodeLabels[0] =
|
out->result.splitTuple.prefixNodeLabels[0] =
|
||||||
Int16GetDatum(*(unsigned char *) (prefixStr + commonLen));
|
Int16GetDatum(*(unsigned char *) (prefixStr + commonLen));
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ spgist_name_choose(PG_FUNCTION_ARGS)
|
|||||||
out->result.splitTuple.prefixHasPrefix = in->hasPrefix;
|
out->result.splitTuple.prefixHasPrefix = in->hasPrefix;
|
||||||
out->result.splitTuple.prefixPrefixDatum = in->prefixDatum;
|
out->result.splitTuple.prefixPrefixDatum = in->prefixDatum;
|
||||||
out->result.splitTuple.prefixNNodes = 1;
|
out->result.splitTuple.prefixNNodes = 1;
|
||||||
out->result.splitTuple.prefixNodeLabels = (Datum *) palloc(sizeof(Datum));
|
out->result.splitTuple.prefixNodeLabels = palloc_object(Datum);
|
||||||
out->result.splitTuple.prefixNodeLabels[0] = Int16GetDatum(-2);
|
out->result.splitTuple.prefixNodeLabels[0] = Int16GetDatum(-2);
|
||||||
out->result.splitTuple.childNodeN = 0;
|
out->result.splitTuple.childNodeN = 0;
|
||||||
out->result.splitTuple.postfixHasPrefix = false;
|
out->result.splitTuple.postfixHasPrefix = false;
|
||||||
@@ -318,9 +318,9 @@ spgist_name_inner_consistent(PG_FUNCTION_ARGS)
|
|||||||
* and see if it's consistent with the query. If so, emit an entry into
|
* and see if it's consistent with the query. If so, emit an entry into
|
||||||
* the output arrays.
|
* the output arrays.
|
||||||
*/
|
*/
|
||||||
out->nodeNumbers = (int *) palloc(sizeof(int) * in->nNodes);
|
out->nodeNumbers = palloc_array(int, in->nNodes);
|
||||||
out->levelAdds = (int *) palloc(sizeof(int) * in->nNodes);
|
out->levelAdds = palloc_array(int, in->nNodes);
|
||||||
out->reconstructedValues = (Datum *) palloc(sizeof(Datum) * in->nNodes);
|
out->reconstructedValues = palloc_array(Datum, in->nNodes);
|
||||||
out->nNodes = 0;
|
out->nNodes = 0;
|
||||||
|
|
||||||
for (i = 0; i < in->nNodes; i++)
|
for (i = 0; i < in->nNodes; i++)
|
||||||
|
|||||||
@@ -622,7 +622,7 @@ test_random_operations(PG_FUNCTION_ARGS)
|
|||||||
* still possible if all the operations hit the "0" case during phase 4
|
* still possible if all the operations hit the "0" case during phase 4
|
||||||
* where multiple operation types are mixed together.
|
* where multiple operation types are mixed together.
|
||||||
*/
|
*/
|
||||||
members = palloc(sizeof(int) * num_ops);
|
members = palloc_array(int, num_ops);
|
||||||
|
|
||||||
/* Phase 1: Random insertions in first set */
|
/* Phase 1: Random insertions in first set */
|
||||||
for (int i = 0; i < num_ops / 2; i++)
|
for (int i = 0; i < num_ops / 2; i++)
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ test_single_value_and_filler(uint64 value, uint64 filler_min, uint64 filler_max)
|
|||||||
|
|
||||||
intset = intset_create();
|
intset = intset_create();
|
||||||
|
|
||||||
iter_expected = palloc(sizeof(uint64) * (filler_max - filler_min + 1));
|
iter_expected = palloc_array(uint64, filler_max - filler_min + 1);
|
||||||
if (value < filler_min)
|
if (value < filler_min)
|
||||||
{
|
{
|
||||||
intset_add_member(intset, value);
|
intset_add_member(intset, value);
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 's': /* do semantic processing */
|
case 's': /* do semantic processing */
|
||||||
testsem = &sem;
|
testsem = &sem;
|
||||||
sem.semstate = palloc(sizeof(struct DoState));
|
sem.semstate = palloc_object(struct DoState);
|
||||||
((struct DoState *) sem.semstate)->lex = lex;
|
((struct DoState *) sem.semstate)->lex = lex;
|
||||||
((struct DoState *) sem.semstate)->buf = makeStringInfo();
|
((struct DoState *) sem.semstate)->buf = makeStringInfo();
|
||||||
need_strings = true;
|
need_strings = true;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ PG_FUNCTION_INFO_V1(testprs_lextype);
|
|||||||
Datum
|
Datum
|
||||||
testprs_start(PG_FUNCTION_ARGS)
|
testprs_start(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
ParserState *pst = (ParserState *) palloc0(sizeof(ParserState));
|
ParserState *pst = palloc0_object(ParserState);
|
||||||
|
|
||||||
pst->buffer = (char *) PG_GETARG_POINTER(0);
|
pst->buffer = (char *) PG_GETARG_POINTER(0);
|
||||||
pst->len = PG_GETARG_INT32(1);
|
pst->len = PG_GETARG_INT32(1);
|
||||||
@@ -112,7 +112,7 @@ testprs_lextype(PG_FUNCTION_ARGS)
|
|||||||
* the same lexids like Teodor in the default word parser; in this way we
|
* the same lexids like Teodor in the default word parser; in this way we
|
||||||
* can reuse the headline function of the default word parser.
|
* can reuse the headline function of the default word parser.
|
||||||
*/
|
*/
|
||||||
LexDescr *descr = (LexDescr *) palloc(sizeof(LexDescr) * (2 + 1));
|
LexDescr *descr = palloc_array(LexDescr, 2 + 1);
|
||||||
|
|
||||||
/* there are only two types in this parser */
|
/* there are only two types in this parser */
|
||||||
descr[0].lexid = 3;
|
descr[0].lexid = 3;
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ test_basic(rt_node_class_test_elem *test_info, int shift, bool asc)
|
|||||||
elog(NOTICE, "testing node %s with shift %d and %s keys",
|
elog(NOTICE, "testing node %s with shift %d and %s keys",
|
||||||
test_info->class_name, shift, asc ? "ascending" : "descending");
|
test_info->class_name, shift, asc ? "ascending" : "descending");
|
||||||
|
|
||||||
keys = palloc(sizeof(uint64) * children);
|
keys = palloc_array(uint64, children);
|
||||||
for (int i = 0; i < children; i++)
|
for (int i = 0; i < children; i++)
|
||||||
{
|
{
|
||||||
if (asc)
|
if (asc)
|
||||||
|
|||||||
@@ -107,10 +107,8 @@ test_regex(PG_FUNCTION_ARGS)
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
/* Pre-create workspace that build_test_match_result needs */
|
/* Pre-create workspace that build_test_match_result needs */
|
||||||
matchctx->elems = (Datum *) palloc(sizeof(Datum) *
|
matchctx->elems = palloc_array(Datum, matchctx->npatterns + 1);
|
||||||
(matchctx->npatterns + 1));
|
matchctx->nulls = palloc_array(bool, matchctx->npatterns + 1);
|
||||||
matchctx->nulls = (bool *) palloc(sizeof(bool) *
|
|
||||||
(matchctx->npatterns + 1));
|
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
funcctx->user_fctx = matchctx;
|
funcctx->user_fctx = matchctx;
|
||||||
@@ -436,7 +434,7 @@ setup_test_matches(text *orig_str,
|
|||||||
Oid collation,
|
Oid collation,
|
||||||
bool use_subpatterns)
|
bool use_subpatterns)
|
||||||
{
|
{
|
||||||
test_regex_ctx *matchctx = palloc0(sizeof(test_regex_ctx));
|
test_regex_ctx *matchctx = palloc0_object(test_regex_ctx);
|
||||||
int eml = pg_database_encoding_max_length();
|
int eml = pg_database_encoding_max_length();
|
||||||
int orig_len;
|
int orig_len;
|
||||||
pg_wchar *wide_str;
|
pg_wchar *wide_str;
|
||||||
@@ -457,7 +455,7 @@ setup_test_matches(text *orig_str,
|
|||||||
|
|
||||||
/* convert string to pg_wchar form for matching */
|
/* convert string to pg_wchar form for matching */
|
||||||
orig_len = VARSIZE_ANY_EXHDR(orig_str);
|
orig_len = VARSIZE_ANY_EXHDR(orig_str);
|
||||||
wide_str = (pg_wchar *) palloc(sizeof(pg_wchar) * (orig_len + 1));
|
wide_str = palloc_array(pg_wchar, orig_len + 1);
|
||||||
wide_len = pg_mb2wchar_with_len(VARDATA_ANY(orig_str), wide_str, orig_len);
|
wide_len = pg_mb2wchar_with_len(VARDATA_ANY(orig_str), wide_str, orig_len);
|
||||||
|
|
||||||
/* do we want to remember subpatterns? */
|
/* do we want to remember subpatterns? */
|
||||||
@@ -474,7 +472,7 @@ setup_test_matches(text *orig_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* temporary output space for RE package */
|
/* temporary output space for RE package */
|
||||||
pmatch = palloc(sizeof(regmatch_t) * pmatch_len);
|
pmatch = palloc_array(regmatch_t, pmatch_len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the real output space (grown dynamically if needed)
|
* the real output space (grown dynamically if needed)
|
||||||
@@ -483,7 +481,7 @@ setup_test_matches(text *orig_str,
|
|||||||
* than at 2^27
|
* than at 2^27
|
||||||
*/
|
*/
|
||||||
array_len = re_flags->glob ? 255 : 31;
|
array_len = re_flags->glob ? 255 : 31;
|
||||||
matchctx->match_locs = (int *) palloc(sizeof(int) * array_len);
|
matchctx->match_locs = palloc_array(int, array_len);
|
||||||
array_idx = 0;
|
array_idx = 0;
|
||||||
|
|
||||||
/* search for the pattern, perhaps repeatedly */
|
/* search for the pattern, perhaps repeatedly */
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ RememberManyTestResources(ResourceOwner owner,
|
|||||||
|
|
||||||
for (int i = 0; i < nresources; i++)
|
for (int i = 0; i < nresources; i++)
|
||||||
{
|
{
|
||||||
ManyTestResource *mres = palloc(sizeof(ManyTestResource));
|
ManyTestResource *mres = palloc_object(ManyTestResource);
|
||||||
|
|
||||||
mres->kind = &kinds[kind_idx];
|
mres->kind = &kinds[kind_idx];
|
||||||
dlist_node_init(&mres->node);
|
dlist_node_init(&mres->node);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ List *
|
|||||||
test_rls_hooks_permissive(CmdType cmdtype, Relation relation)
|
test_rls_hooks_permissive(CmdType cmdtype, Relation relation)
|
||||||
{
|
{
|
||||||
List *policies = NIL;
|
List *policies = NIL;
|
||||||
RowSecurityPolicy *policy = palloc0(sizeof(RowSecurityPolicy));
|
RowSecurityPolicy *policy = palloc0_object(RowSecurityPolicy);
|
||||||
Datum role;
|
Datum role;
|
||||||
FuncCall *n;
|
FuncCall *n;
|
||||||
Node *e;
|
Node *e;
|
||||||
@@ -112,7 +112,7 @@ List *
|
|||||||
test_rls_hooks_restrictive(CmdType cmdtype, Relation relation)
|
test_rls_hooks_restrictive(CmdType cmdtype, Relation relation)
|
||||||
{
|
{
|
||||||
List *policies = NIL;
|
List *policies = NIL;
|
||||||
RowSecurityPolicy *policy = palloc0(sizeof(RowSecurityPolicy));
|
RowSecurityPolicy *policy = palloc0_object(RowSecurityPolicy);
|
||||||
Datum role;
|
Datum role;
|
||||||
FuncCall *n;
|
FuncCall *n;
|
||||||
Node *e;
|
Node *e;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ worker_spi_main(Datum main_arg)
|
|||||||
char *p;
|
char *p;
|
||||||
bits32 flags = 0;
|
bits32 flags = 0;
|
||||||
|
|
||||||
table = palloc(sizeof(worktable));
|
table = palloc_object(worktable);
|
||||||
sprintf(name, "schema%d", index);
|
sprintf(name, "schema%d", index);
|
||||||
table->schema = pstrdup(name);
|
table->schema = pstrdup(name);
|
||||||
table->name = pstrdup("counted");
|
table->name = pstrdup("counted");
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ widget_in(PG_FUNCTION_ARGS)
|
|||||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||||
"widget", str)));
|
"widget", str)));
|
||||||
|
|
||||||
result = (WIDGET *) palloc(sizeof(WIDGET));
|
result = palloc_object(WIDGET);
|
||||||
result->center.x = atof(coord[0]);
|
result->center.x = atof(coord[0]);
|
||||||
result->center.y = atof(coord[1]);
|
result->center.y = atof(coord[1]);
|
||||||
result->radius = atof(coord[2]);
|
result->radius = atof(coord[2]);
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ struct pg_tzenum
|
|||||||
pg_tzenum *
|
pg_tzenum *
|
||||||
pg_tzenumerate_start(void)
|
pg_tzenumerate_start(void)
|
||||||
{
|
{
|
||||||
pg_tzenum *ret = (pg_tzenum *) palloc0(sizeof(pg_tzenum));
|
pg_tzenum *ret = palloc0_object(pg_tzenum);
|
||||||
char *startdir = pstrdup(pg_TZDIR());
|
char *startdir = pstrdup(pg_TZDIR());
|
||||||
|
|
||||||
ret->baselen = strlen(startdir) + 1;
|
ret->baselen = strlen(startdir) + 1;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ complex_in(PG_FUNCTION_ARGS)
|
|||||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||||
"complex", str)));
|
"complex", str)));
|
||||||
|
|
||||||
result = (Complex *) palloc(sizeof(Complex));
|
result = palloc_object(Complex);
|
||||||
result->x = x;
|
result->x = x;
|
||||||
result->y = y;
|
result->y = y;
|
||||||
PG_RETURN_POINTER(result);
|
PG_RETURN_POINTER(result);
|
||||||
@@ -73,7 +73,7 @@ complex_recv(PG_FUNCTION_ARGS)
|
|||||||
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
||||||
Complex *result;
|
Complex *result;
|
||||||
|
|
||||||
result = (Complex *) palloc(sizeof(Complex));
|
result = palloc_object(Complex);
|
||||||
result->x = pq_getmsgfloat8(buf);
|
result->x = pq_getmsgfloat8(buf);
|
||||||
result->y = pq_getmsgfloat8(buf);
|
result->y = pq_getmsgfloat8(buf);
|
||||||
PG_RETURN_POINTER(result);
|
PG_RETURN_POINTER(result);
|
||||||
@@ -108,7 +108,7 @@ complex_add(PG_FUNCTION_ARGS)
|
|||||||
Complex *b = (Complex *) PG_GETARG_POINTER(1);
|
Complex *b = (Complex *) PG_GETARG_POINTER(1);
|
||||||
Complex *result;
|
Complex *result;
|
||||||
|
|
||||||
result = (Complex *) palloc(sizeof(Complex));
|
result = palloc_object(Complex);
|
||||||
result->x = a->x + b->x;
|
result->x = a->x + b->x;
|
||||||
result->y = a->y + b->y;
|
result->y = a->y + b->y;
|
||||||
PG_RETURN_POINTER(result);
|
PG_RETURN_POINTER(result);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ makepoint(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
Point *pointx = PG_GETARG_POINT_P(0);
|
Point *pointx = PG_GETARG_POINT_P(0);
|
||||||
Point *pointy = PG_GETARG_POINT_P(1);
|
Point *pointy = PG_GETARG_POINT_P(1);
|
||||||
Point *new_point = (Point *) palloc(sizeof(Point));
|
Point *new_point = palloc_object(Point);
|
||||||
|
|
||||||
new_point->x = pointx->x;
|
new_point->x = pointx->x;
|
||||||
new_point->y = pointy->y;
|
new_point->y = pointy->y;
|
||||||
|
|||||||
Reference in New Issue
Block a user