PostgreSQL Source Code  git master
regress.c File Reference
#include "postgres.h"
#include <math.h>
#include <signal.h>
#include "access/detoast.h"
#include "access/htup_details.h"
#include "access/transam.h"
#include "access/xact.h"
#include "catalog/namespace.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_type.h"
#include "commands/sequence.h"
#include "commands/trigger.h"
#include "executor/executor.h"
#include "executor/spi.h"
#include "funcapi.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/supportnodes.h"
#include "optimizer/optimizer.h"
#include "optimizer/plancat.h"
#include "parser/parse_coerce.h"
#include "port/atomics.h"
#include "storage/spin.h"
#include "utils/builtins.h"
#include "utils/geo_decls.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/typcache.h"
Include dependency graph for regress.c:

Go to the source code of this file.

Data Structures

struct  WIDGET
 

Macros

#define EXPECT_TRUE(expr)
 
#define EXPECT_EQ_U32(result_expr, expected_expr)
 
#define EXPECT_EQ_U64(result_expr, expected_expr)
 
#define LDELIM   '('
 
#define RDELIM   ')'
 
#define DELIM   ','
 
#define NARGS   3
 
#define TTDUMMY_INFINITY   999999
 
#define NUM_TEST_ATOMICS   (NUM_SPINLOCK_SEMAPHORES + NUM_ATOMICS_SEMAPHORES + 27)
 

Functions

static void regress_lseg_construct (LSEG *lseg, Point *pt1, Point *pt2)
 
 PG_FUNCTION_INFO_V1 (interpt_pp)
 
Datum interpt_pp (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (overpaid)
 
Datum overpaid (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (widget_in)
 
 PG_FUNCTION_INFO_V1 (widget_out)
 
Datum widget_in (PG_FUNCTION_ARGS)
 
Datum widget_out (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (pt_in_widget)
 
Datum pt_in_widget (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (reverse_name)
 
Datum reverse_name (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (trigger_return_old)
 
Datum trigger_return_old (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (ttdummy)
 
Datum ttdummy (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (set_ttdummy)
 
Datum set_ttdummy (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (int44in)
 
Datum int44in (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (int44out)
 
Datum int44out (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (test_canonicalize_path)
 
Datum test_canonicalize_path (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (make_tuple_indirect)
 
Datum make_tuple_indirect (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (regress_setenv)
 
Datum regress_setenv (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (wait_pid)
 
Datum wait_pid (PG_FUNCTION_ARGS)
 
static void test_atomic_flag (void)
 
static void test_atomic_uint32 (void)
 
static void test_atomic_uint64 (void)
 
static void test_spinlock (void)
 
static void test_atomic_spin_nest (void)
 
 PG_FUNCTION_INFO_V1 (test_atomic_ops)
 
Datum test_atomic_ops (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (test_fdw_handler)
 
Datum test_fdw_handler (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (test_support_func)
 
Datum test_support_func (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (test_opclass_options_func)
 
Datum test_opclass_options_func (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (test_enc_conversion)
 
Datum test_enc_conversion (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (binary_coercible)
 
Datum binary_coercible (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (get_columns_length)
 
Datum get_columns_length (PG_FUNCTION_ARGS)
 

Variables

 PG_MODULE_MAGIC
 
static SPIPlanPtr splan = NULL
 
static bool ttoff = false
 

Macro Definition Documentation

◆ DELIM

#define DELIM   ','

Definition at line 79 of file regress.c.

◆ EXPECT_EQ_U32

#define EXPECT_EQ_U32 (   result_expr,
  expected_expr 
)
Value:
do { \
uint32 result = (result_expr); \
uint32 expected = (expected_expr); \
if (result != expected) \
elog(ERROR, \
"%s yielded %u, expected %s in file \"%s\" line %u", \
#result_expr, result, #expected_expr, __FILE__, __LINE__); \
} while (0)
#define ERROR
Definition: elog.h:33

Definition at line 57 of file regress.c.

◆ EXPECT_EQ_U64

#define EXPECT_EQ_U64 (   result_expr,
  expected_expr 
)
Value:
do { \
uint64 result = (result_expr); \
uint64 expected = (expected_expr); \
if (result != expected) \
elog(ERROR, \
"%s yielded " UINT64_FORMAT ", expected %s in file \"%s\" line %u", \
#result_expr, result, #expected_expr, __FILE__, __LINE__); \
} while (0)
#define UINT64_FORMAT
Definition: c.h:484

Definition at line 67 of file regress.c.

◆ EXPECT_TRUE

#define EXPECT_TRUE (   expr)
Value:
do { \
if (!(expr)) \
elog(ERROR, \
"%s was unexpectedly false in file \"%s\" line %u", \
#expr, __FILE__, __LINE__); \
} while (0)

Definition at line 49 of file regress.c.

◆ LDELIM

#define LDELIM   '('

Definition at line 77 of file regress.c.

◆ NARGS

#define NARGS   3

Definition at line 168 of file regress.c.

◆ NUM_TEST_ATOMICS

#define NUM_TEST_ATOMICS   (NUM_SPINLOCK_SEMAPHORES + NUM_ATOMICS_SEMAPHORES + 27)

◆ RDELIM

#define RDELIM   ')'

Definition at line 78 of file regress.c.

◆ TTDUMMY_INFINITY

#define TTDUMMY_INFINITY   999999

Definition at line 262 of file regress.c.

Function Documentation

◆ binary_coercible()

Datum binary_coercible ( PG_FUNCTION_ARGS  )

Definition at line 1213 of file regress.c.

1214 {
1215  Oid srctype = PG_GETARG_OID(0);
1216  Oid targettype = PG_GETARG_OID(1);
1217 
1218  PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
1219 }
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
bool IsBinaryCoercible(Oid srctype, Oid targettype)
unsigned int Oid
Definition: postgres_ext.h:31

References IsBinaryCoercible(), PG_GETARG_OID, and PG_RETURN_BOOL.

◆ get_columns_length()

Datum get_columns_length ( PG_FUNCTION_ARGS  )

Definition at line 1227 of file regress.c.

1228 {
1230  Oid *type_oids;
1231  int ntypes;
1232  int column_offset = 0;
1233 
1234  if (ARR_HASNULL(ta) && array_contains_nulls(ta))
1235  elog(ERROR, "argument must not contain nulls");
1236 
1237  if (ARR_NDIM(ta) > 1)
1238  elog(ERROR, "argument must be empty or one-dimensional array");
1239 
1240  type_oids = (Oid *) ARR_DATA_PTR(ta);
1241  ntypes = ArrayGetNItems(ARR_NDIM(ta), ARR_DIMS(ta));
1242  for (int i = 0; i < ntypes; i++)
1243  {
1244  Oid typeoid = type_oids[i];
1245  int16 typlen;
1246  bool typbyval;
1247  char typalign;
1248 
1249  get_typlenbyvalalign(typeoid, &typlen, &typbyval, &typalign);
1250 
1251  /* the data type must be fixed-length */
1252  if (typlen < 0)
1253  elog(ERROR, "type %u is not fixed-length data type", typeoid);
1254 
1255  column_offset = att_align_nominal(column_offset + typlen, typalign);
1256  }
1257 
1258  PG_RETURN_INT32(column_offset);
1259 }
#define ARR_NDIM(a)
Definition: array.h:283
#define PG_GETARG_ARRAYTYPE_P(n)
Definition: array.h:256
#define ARR_DATA_PTR(a)
Definition: array.h:315
#define ARR_DIMS(a)
Definition: array.h:287
#define ARR_HASNULL(a)
Definition: array.h:284
bool array_contains_nulls(ArrayType *array)
Definition: arrayfuncs.c:3713
int ArrayGetNItems(int ndim, const int *dims)
Definition: arrayutils.c:76
signed short int16
Definition: c.h:428
#define elog(elevel,...)
Definition: elog.h:218
#define PG_RETURN_INT32(x)
Definition: fmgr.h:354
int i
Definition: isn.c:73
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
Definition: lsyscache.c:2228
char typalign
Definition: pg_type.h:176
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:148

References ARR_DATA_PTR, ARR_DIMS, ARR_HASNULL, ARR_NDIM, array_contains_nulls(), ArrayGetNItems(), att_align_nominal, elog, ERROR, get_typlenbyvalalign(), i, PG_GETARG_ARRAYTYPE_P, PG_RETURN_INT32, and typalign.

◆ int44in()

Datum int44in ( PG_FUNCTION_ARGS  )

Definition at line 497 of file regress.c.

498 {
499  char *input_string = PG_GETARG_CSTRING(0);
500  int32 *result = (int32 *) palloc(4 * sizeof(int32));
501  int i;
502 
503  i = sscanf(input_string,
504  "%d, %d, %d, %d",
505  &result[0],
506  &result[1],
507  &result[2],
508  &result[3]);
509  while (i < 4)
510  result[i++] = 0;
511 
512  PG_RETURN_POINTER(result);
513 }
signed int int32
Definition: c.h:429
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:277
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361
void * palloc(Size size)
Definition: mcxt.c:1068

References i, palloc(), PG_GETARG_CSTRING, and PG_RETURN_POINTER.

◆ int44out()

Datum int44out ( PG_FUNCTION_ARGS  )

Definition at line 521 of file regress.c.

522 {
523  int32 *an_array = (int32 *) PG_GETARG_POINTER(0);
524  char *result = (char *) palloc(16 * 4);
525 
526  snprintf(result, 16 * 4, "%d,%d,%d,%d",
527  an_array[0],
528  an_array[1],
529  an_array[2],
530  an_array[3]);
531 
532  PG_RETURN_CSTRING(result);
533 }
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_RETURN_CSTRING(x)
Definition: fmgr.h:362
#define snprintf
Definition: port.h:225

References palloc(), PG_GETARG_POINTER, PG_RETURN_CSTRING, and snprintf.

◆ interpt_pp()

Datum interpt_pp ( PG_FUNCTION_ARGS  )

Definition at line 90 of file regress.c.

91 {
92  PATH *p1 = PG_GETARG_PATH_P(0);
93  PATH *p2 = PG_GETARG_PATH_P(1);
94  int i,
95  j;
96  LSEG seg1,
97  seg2;
98  bool found; /* We've found the intersection */
99 
100  found = false; /* Haven't found it yet */
101 
102  for (i = 0; i < p1->npts - 1 && !found; i++)
103  {
104  regress_lseg_construct(&seg1, &p1->p[i], &p1->p[i + 1]);
105  for (j = 0; j < p2->npts - 1 && !found; j++)
106  {
107  regress_lseg_construct(&seg2, &p2->p[j], &p2->p[j + 1]);
109  LsegPGetDatum(&seg1),
110  LsegPGetDatum(&seg2))))
111  found = true;
112  }
113  }
114 
115  if (!found)
116  PG_RETURN_NULL();
117 
118  /*
119  * Note: DirectFunctionCall2 will kick out an error if lseg_interpt()
120  * returns NULL, but that should be impossible since we know the two
121  * segments intersect.
122  */
124  LsegPGetDatum(&seg1),
125  LsegPGetDatum(&seg2)));
126 }
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:633
#define PG_RETURN_NULL()
Definition: fmgr.h:345
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:353
#define LsegPGetDatum(X)
Definition: geo_decls.h:181
#define PG_GETARG_PATH_P(n)
Definition: geo_decls.h:188
Datum lseg_intersect(PG_FUNCTION_ARGS)
Definition: geo_ops.c:2153
Datum lseg_interpt(PG_FUNCTION_ARGS)
Definition: geo_ops.c:2326
int j
Definition: isn.c:74
#define DatumGetBool(X)
Definition: postgres.h:437
static void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2)
Definition: regress.c:131
Point p[FLEXIBLE_ARRAY_MEMBER]
Definition: geo_decls.h:121
int32 npts
Definition: geo_decls.h:118

References DatumGetBool, DirectFunctionCall2, i, j, lseg_interpt(), lseg_intersect(), LsegPGetDatum, PATH::npts, PATH::p, p2, PG_GETARG_PATH_P, PG_RETURN_DATUM, PG_RETURN_NULL, and regress_lseg_construct().

◆ make_tuple_indirect()

Datum make_tuple_indirect ( PG_FUNCTION_ARGS  )

Definition at line 547 of file regress.c.

548 {
550  HeapTupleData tuple;
551  int ncolumns;
552  Datum *values;
553  bool *nulls;
554 
555  Oid tupType;
556  int32 tupTypmod;
557  TupleDesc tupdesc;
558 
559  HeapTuple newtup;
560 
561  int i;
562 
563  MemoryContext old_context;
564 
565  /* Extract type info from the tuple itself */
566  tupType = HeapTupleHeaderGetTypeId(rec);
567  tupTypmod = HeapTupleHeaderGetTypMod(rec);
568  tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
569  ncolumns = tupdesc->natts;
570 
571  /* Build a temporary HeapTuple control structure */
573  ItemPointerSetInvalid(&(tuple.t_self));
574  tuple.t_tableOid = InvalidOid;
575  tuple.t_data = rec;
576 
577  values = (Datum *) palloc(ncolumns * sizeof(Datum));
578  nulls = (bool *) palloc(ncolumns * sizeof(bool));
579 
580  heap_deform_tuple(&tuple, tupdesc, values, nulls);
581 
583 
584  for (i = 0; i < ncolumns; i++)
585  {
586  struct varlena *attr;
587  struct varlena *new_attr;
588  struct varatt_indirect redirect_pointer;
589 
590  /* only work on existing, not-null varlenas */
591  if (TupleDescAttr(tupdesc, i)->attisdropped ||
592  nulls[i] ||
593  TupleDescAttr(tupdesc, i)->attlen != -1)
594  continue;
595 
596  attr = (struct varlena *) DatumGetPointer(values[i]);
597 
598  /* don't recursively indirect */
599  if (VARATT_IS_EXTERNAL_INDIRECT(attr))
600  continue;
601 
602  /* copy datum, so it still lives later */
603  if (VARATT_IS_EXTERNAL_ONDISK(attr))
604  attr = detoast_external_attr(attr);
605  else
606  {
607  struct varlena *oldattr = attr;
608 
609  attr = palloc0(VARSIZE_ANY(oldattr));
610  memcpy(attr, oldattr, VARSIZE_ANY(oldattr));
611  }
612 
613  /* build indirection Datum */
614  new_attr = (struct varlena *) palloc0(INDIRECT_POINTER_SIZE);
615  redirect_pointer.pointer = attr;
617  memcpy(VARDATA_EXTERNAL(new_attr), &redirect_pointer,
618  sizeof(redirect_pointer));
619 
620  values[i] = PointerGetDatum(new_attr);
621  }
622 
623  newtup = heap_form_tuple(tupdesc, values, nulls);
624  pfree(values);
625  pfree(nulls);
626  ReleaseTupleDesc(tupdesc);
627 
628  MemoryContextSwitchTo(old_context);
629 
630  /*
631  * We intentionally don't use PG_RETURN_HEAPTUPLEHEADER here, because that
632  * would cause the indirect toast pointers to be flattened out of the
633  * tuple immediately, rendering subsequent testing irrelevant. So just
634  * return the HeapTupleHeader pointer as-is. This violates the general
635  * rule that composite Datums shouldn't contain toast pointers, but so
636  * long as the regression test scripts don't insert the result of this
637  * function into a container type (record, array, etc) it should be OK.
638  */
639  PG_RETURN_POINTER(newtup->t_data);
640 }
static Datum values[MAXATTR]
Definition: bootstrap.c:156
struct varlena * detoast_external_attr(struct varlena *attr)
Definition: detoast.c:45
#define INDIRECT_POINTER_SIZE
Definition: detoast.h:34
#define PG_GETARG_HEAPTUPLEHEADER(n)
Definition: fmgr.h:312
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1249
#define HeapTupleHeaderGetTypMod(tup)
Definition: htup_details.h:462
#define HeapTupleHeaderGetTypeId(tup)
Definition: htup_details.h:452
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:446
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
MemoryContext TopTransactionContext
Definition: mcxt.c:53
void pfree(void *pointer)
Definition: mcxt.c:1175
void * palloc0(Size size)
Definition: mcxt.c:1099
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
int16 attlen
Definition: pg_attribute.h:68
#define VARATT_IS_EXTERNAL_ONDISK(PTR)
Definition: postgres.h:327
#define VARATT_IS_EXTERNAL_INDIRECT(PTR)
Definition: postgres.h:329
uintptr_t Datum
Definition: postgres.h:411
#define VARSIZE_ANY(PTR)
Definition: postgres.h:348
#define DatumGetPointer(X)
Definition: postgres.h:593
#define SET_VARTAG_EXTERNAL(PTR, tag)
Definition: postgres.h:346
#define VARDATA_EXTERNAL(PTR)
Definition: postgres.h:323
@ VARTAG_INDIRECT
Definition: postgres.h:123
#define PointerGetDatum(X)
Definition: postgres.h:600
#define InvalidOid
Definition: postgres_ext.h:36
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
HeapTupleHeader t_data
Definition: htup.h:68
Oid t_tableOid
Definition: htup.h:66
Definition: c.h:622
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
Definition: typcache.c:1830

References attlen, DatumGetPointer, detoast_external_attr(), heap_deform_tuple(), heap_form_tuple(), HeapTupleHeaderGetDatumLength, HeapTupleHeaderGetTypeId, HeapTupleHeaderGetTypMod, i, INDIRECT_POINTER_SIZE, InvalidOid, ItemPointerSetInvalid, lookup_rowtype_tupdesc(), MemoryContextSwitchTo(), TupleDescData::natts, palloc(), palloc0(), pfree(), PG_GETARG_HEAPTUPLEHEADER, PG_RETURN_POINTER, varatt_indirect::pointer, PointerGetDatum, ReleaseTupleDesc, SET_VARTAG_EXTERNAL, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, TopTransactionContext, TupleDescAttr, values, VARATT_IS_EXTERNAL_INDIRECT, VARATT_IS_EXTERNAL_ONDISK, VARDATA_EXTERNAL, VARSIZE_ANY, and VARTAG_INDIRECT.

◆ overpaid()

Datum overpaid ( PG_FUNCTION_ARGS  )

Definition at line 142 of file regress.c.

143 {
145  bool isnull;
146  int32 salary;
147 
148  salary = DatumGetInt32(GetAttributeByName(tuple, "salary", &isnull));
149  if (isnull)
150  PG_RETURN_NULL();
151  PG_RETURN_BOOL(salary > 699);
152 }
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
Definition: execUtils.c:1023
#define DatumGetInt32(X)
Definition: postgres.h:516

References DatumGetInt32, GetAttributeByName(), PG_GETARG_HEAPTUPLEHEADER, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ PG_FUNCTION_INFO_V1() [1/22]

PG_FUNCTION_INFO_V1 ( binary_coercible  )

◆ PG_FUNCTION_INFO_V1() [2/22]

PG_FUNCTION_INFO_V1 ( get_columns_length  )

◆ PG_FUNCTION_INFO_V1() [3/22]

PG_FUNCTION_INFO_V1 ( int44in  )

◆ PG_FUNCTION_INFO_V1() [4/22]

PG_FUNCTION_INFO_V1 ( int44out  )

◆ PG_FUNCTION_INFO_V1() [5/22]

PG_FUNCTION_INFO_V1 ( interpt_pp  )

◆ PG_FUNCTION_INFO_V1() [6/22]

PG_FUNCTION_INFO_V1 ( make_tuple_indirect  )

◆ PG_FUNCTION_INFO_V1() [7/22]

PG_FUNCTION_INFO_V1 ( overpaid  )

◆ PG_FUNCTION_INFO_V1() [8/22]

PG_FUNCTION_INFO_V1 ( pt_in_widget  )

◆ PG_FUNCTION_INFO_V1() [9/22]

PG_FUNCTION_INFO_V1 ( regress_setenv  )

◆ PG_FUNCTION_INFO_V1() [10/22]

PG_FUNCTION_INFO_V1 ( reverse_name  )

◆ PG_FUNCTION_INFO_V1() [11/22]

PG_FUNCTION_INFO_V1 ( set_ttdummy  )

◆ PG_FUNCTION_INFO_V1() [12/22]

PG_FUNCTION_INFO_V1 ( test_atomic_ops  )

◆ PG_FUNCTION_INFO_V1() [13/22]

PG_FUNCTION_INFO_V1 ( test_canonicalize_path  )

◆ PG_FUNCTION_INFO_V1() [14/22]

PG_FUNCTION_INFO_V1 ( test_enc_conversion  )

◆ PG_FUNCTION_INFO_V1() [15/22]

PG_FUNCTION_INFO_V1 ( test_fdw_handler  )

◆ PG_FUNCTION_INFO_V1() [16/22]

PG_FUNCTION_INFO_V1 ( test_opclass_options_func  )

◆ PG_FUNCTION_INFO_V1() [17/22]

PG_FUNCTION_INFO_V1 ( test_support_func  )

◆ PG_FUNCTION_INFO_V1() [18/22]

PG_FUNCTION_INFO_V1 ( trigger_return_old  )

◆ PG_FUNCTION_INFO_V1() [19/22]

PG_FUNCTION_INFO_V1 ( ttdummy  )

◆ PG_FUNCTION_INFO_V1() [20/22]

PG_FUNCTION_INFO_V1 ( wait_pid  )

◆ PG_FUNCTION_INFO_V1() [21/22]

PG_FUNCTION_INFO_V1 ( widget_in  )

◆ PG_FUNCTION_INFO_V1() [22/22]

PG_FUNCTION_INFO_V1 ( widget_out  )

◆ pt_in_widget()

Datum pt_in_widget ( PG_FUNCTION_ARGS  )

Definition at line 212 of file regress.c.

213 {
214  Point *point = PG_GETARG_POINT_P(0);
215  WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(1);
216  float8 distance;
217 
219  PointPGetDatum(point),
220  PointPGetDatum(&widget->center)));
221 
222  PG_RETURN_BOOL(distance < widget->radius);
223 }
double float8
Definition: c.h:565
#define PG_GETARG_POINT_P(n)
Definition: geo_decls.h:177
#define PointPGetDatum(X)
Definition: geo_decls.h:176
Datum point_distance(PG_FUNCTION_ARGS)
Definition: geo_ops.c:1962
#define DatumGetFloat8(X)
Definition: postgres.h:758
Point center
Definition: regress.c:161

References WIDGET::center, DatumGetFloat8, DirectFunctionCall2, PG_GETARG_POINT_P, PG_GETARG_POINTER, PG_RETURN_BOOL, point_distance(), and PointPGetDatum.

◆ regress_lseg_construct()

static void regress_lseg_construct ( LSEG lseg,
Point pt1,
Point pt2 
)
static

Definition at line 131 of file regress.c.

132 {
133  lseg->p[0].x = pt1->x;
134  lseg->p[0].y = pt1->y;
135  lseg->p[1].x = pt2->x;
136  lseg->p[1].y = pt2->y;
137 }
Point p[2]
Definition: geo_decls.h:108
float8 y
Definition: geo_decls.h:99
float8 x
Definition: geo_decls.h:98

References LSEG::p, Point::x, and Point::y.

Referenced by interpt_pp().

◆ regress_setenv()

Datum regress_setenv ( PG_FUNCTION_ARGS  )

Definition at line 645 of file regress.c.

646 {
647  char *envvar = text_to_cstring(PG_GETARG_TEXT_PP(0));
648  char *envval = text_to_cstring(PG_GETARG_TEXT_PP(1));
649 
650  if (!superuser())
651  elog(ERROR, "must be superuser to change environment variables");
652 
653  if (setenv(envvar, envval, 1) != 0)
654  elog(ERROR, "could not set environment variable: %m");
655 
656  PG_RETURN_VOID();
657 }
#define PG_RETURN_VOID()
Definition: fmgr.h:349
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
bool superuser(void)
Definition: superuser.c:46
char * text_to_cstring(const text *t)
Definition: varlena.c:221
#define setenv(x, y, z)
Definition: win32_port.h:507

References elog, ERROR, PG_GETARG_TEXT_PP, PG_RETURN_VOID, setenv, superuser(), and text_to_cstring().

◆ reverse_name()

Datum reverse_name ( PG_FUNCTION_ARGS  )

Definition at line 228 of file regress.c.

229 {
230  char *string = PG_GETARG_CSTRING(0);
231  int i;
232  int len;
233  char *new_string;
234 
235  new_string = palloc0(NAMEDATALEN);
236  for (i = 0; i < NAMEDATALEN && string[i]; ++i)
237  ;
238  if (i == NAMEDATALEN || !string[i])
239  --i;
240  len = i;
241  for (; i >= 0; --i)
242  new_string[len - i] = string[i];
243  PG_RETURN_CSTRING(new_string);
244 }
#define NAMEDATALEN
const void size_t len

References i, len, NAMEDATALEN, palloc0(), PG_GETARG_CSTRING, and PG_RETURN_CSTRING.

◆ set_ttdummy()

Datum set_ttdummy ( PG_FUNCTION_ARGS  )

Definition at line 459 of file regress.c.

460 {
461  int32 on = PG_GETARG_INT32(0);
462 
463  if (ttoff) /* OFF currently */
464  {
465  if (on == 0)
466  PG_RETURN_INT32(0);
467 
468  /* turn ON */
469  ttoff = false;
470  PG_RETURN_INT32(0);
471  }
472 
473  /* ON currently */
474  if (on != 0)
475  PG_RETURN_INT32(1);
476 
477  /* turn OFF */
478  ttoff = true;
479 
480  PG_RETURN_INT32(1);
481 }
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269
static bool ttoff
Definition: regress.c:265

References PG_GETARG_INT32, PG_RETURN_INT32, and ttoff.

◆ test_atomic_flag()

static void test_atomic_flag ( void  )
static

Definition at line 683 of file regress.c.

684 {
686 
696 }
static void pg_atomic_clear_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:209
static bool pg_atomic_test_set_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:185
static bool pg_atomic_unlocked_test_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:198
static void pg_atomic_init_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:172
#define EXPECT_TRUE(expr)
Definition: regress.c:49
char * flag(int b)
Definition: test-ctype.c:33

References EXPECT_TRUE, flag(), pg_atomic_clear_flag(), pg_atomic_init_flag(), pg_atomic_test_set_flag(), and pg_atomic_unlocked_test_flag().

Referenced by test_atomic_ops().

◆ test_atomic_ops()

Datum test_atomic_ops ( PG_FUNCTION_ARGS  )

Definition at line 972 of file regress.c.

973 {
975 
977 
979 
980  /*
981  * Arguably this shouldn't be tested as part of this function, but it's
982  * closely enough related that that seems ok for now.
983  */
984  test_spinlock();
985 
987 
988  PG_RETURN_BOOL(true);
989 }
static void test_spinlock(void)
Definition: regress.c:824
static void test_atomic_spin_nest(void)
Definition: regress.c:935
static void test_atomic_uint32(void)
Definition: regress.c:699
static void test_atomic_flag(void)
Definition: regress.c:683
static void test_atomic_uint64(void)
Definition: regress.c:771

References PG_RETURN_BOOL, test_atomic_flag(), test_atomic_spin_nest(), test_atomic_uint32(), test_atomic_uint64(), and test_spinlock().

◆ test_atomic_spin_nest()

static void test_atomic_spin_nest ( void  )
static

Definition at line 935 of file regress.c.

936 {
937  slock_t lock;
938 #define NUM_TEST_ATOMICS (NUM_SPINLOCK_SEMAPHORES + NUM_ATOMICS_SEMAPHORES + 27)
941 
942  SpinLockInit(&lock);
943 
944  for (int i = 0; i < NUM_TEST_ATOMICS; i++)
945  {
946  pg_atomic_init_u32(&atomics32[i], 0);
947  pg_atomic_init_u64(&atomics64[i], 0);
948  }
949 
950  /* just so it's not all zeroes */
951  for (int i = 0; i < NUM_TEST_ATOMICS; i++)
952  {
953  EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&atomics32[i], i), 0);
954  EXPECT_EQ_U64(pg_atomic_fetch_add_u64(&atomics64[i], i), 0);
955  }
956 
957  /* test whether we can do atomic op with lock held */
958  SpinLockAcquire(&lock);
959  for (int i = 0; i < NUM_TEST_ATOMICS; i++)
960  {
961  EXPECT_EQ_U32(pg_atomic_fetch_sub_u32(&atomics32[i], i), i);
962  EXPECT_EQ_U32(pg_atomic_read_u32(&atomics32[i]), 0);
963  EXPECT_EQ_U64(pg_atomic_fetch_sub_u64(&atomics64[i], i), i);
964  EXPECT_EQ_U64(pg_atomic_read_u64(&atomics64[i]), 0);
965  }
966  SpinLockRelease(&lock);
967 }
static uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition: atomics.h:343
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition: atomics.h:223
static uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition: atomics.h:328
static uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition: atomics.h:467
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
Definition: atomics.h:241
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition: atomics.h:415
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
Definition: atomics.h:429
static uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition: atomics.h:476
#define EXPECT_EQ_U32(result_expr, expected_expr)
Definition: regress.c:57
#define NUM_TEST_ATOMICS
#define EXPECT_EQ_U64(result_expr, expected_expr)
Definition: regress.c:67
int slock_t
Definition: s_lock.h:975
#define SpinLockInit(lock)
Definition: spin.h:60
#define SpinLockRelease(lock)
Definition: spin.h:64
#define SpinLockAcquire(lock)
Definition: spin.h:62

References EXPECT_EQ_U32, EXPECT_EQ_U64, i, NUM_TEST_ATOMICS, pg_atomic_fetch_add_u32(), pg_atomic_fetch_add_u64(), pg_atomic_fetch_sub_u32(), pg_atomic_fetch_sub_u64(), pg_atomic_init_u32(), pg_atomic_init_u64(), pg_atomic_read_u32(), pg_atomic_read_u64(), SpinLockAcquire, SpinLockInit, and SpinLockRelease.

Referenced by test_atomic_ops().

◆ test_atomic_uint32()

static void test_atomic_uint32 ( void  )
static

Definition at line 699 of file regress.c.

700 {
701  pg_atomic_uint32 var;
702  uint32 expected;
703  int i;
704 
705  pg_atomic_init_u32(&var, 0);
707  pg_atomic_write_u32(&var, 3);
710  3);
713  EXPECT_EQ_U32(pg_atomic_add_fetch_u32(&var, 10), 10);
716 
717  /* test around numerical limits */
718  EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, INT_MAX), 0);
719  EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, INT_MAX), INT_MAX);
720  pg_atomic_fetch_add_u32(&var, 2); /* wrap to 0 */
723  PG_INT16_MAX);
725  2 * PG_INT16_MAX + 1);
727  PG_INT16_MAX);
728  pg_atomic_fetch_add_u32(&var, 1); /* top up to UINT_MAX */
729  EXPECT_EQ_U32(pg_atomic_read_u32(&var), UINT_MAX);
730  EXPECT_EQ_U32(pg_atomic_fetch_sub_u32(&var, INT_MAX), UINT_MAX);
731  EXPECT_EQ_U32(pg_atomic_read_u32(&var), (uint32) INT_MAX + 1);
732  EXPECT_EQ_U32(pg_atomic_sub_fetch_u32(&var, INT_MAX), 1);
733  pg_atomic_sub_fetch_u32(&var, 1);
734  expected = PG_INT16_MAX;
735  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
736  expected = PG_INT16_MAX + 1;
737  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
738  expected = PG_INT16_MIN;
739  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
740  expected = PG_INT16_MIN - 1;
741  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
742 
743  /* fail exchange because of old expected */
744  expected = 10;
745  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
746 
747  /* CAS is allowed to fail due to interrupts, try a couple of times */
748  for (i = 0; i < 1000; i++)
749  {
750  expected = 0;
751  if (!pg_atomic_compare_exchange_u32(&var, &expected, 1))
752  break;
753  }
754  if (i == 1000)
755  elog(ERROR, "atomic_compare_exchange_u32() never succeeded");
757  pg_atomic_write_u32(&var, 0);
758 
759  /* try setting flagbits */
760  EXPECT_TRUE(!(pg_atomic_fetch_or_u32(&var, 1) & 1));
761  EXPECT_TRUE(pg_atomic_fetch_or_u32(&var, 2) & 1);
763  /* try clearing flagbits */
764  EXPECT_EQ_U32(pg_atomic_fetch_and_u32(&var, ~2) & 3, 3);
766  /* no bits set anymore */
768 }
static uint32 pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_)
Definition: atomics.h:358
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
Definition: atomics.h:311
static uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
Definition: atomics.h:372
static uint32 pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition: atomics.h:401
static uint32 pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition: atomics.h:386
static void pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition: atomics.h:258
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
Definition: atomics.h:292
unsigned int uint32
Definition: c.h:441
#define PG_INT16_MIN
Definition: c.h:520
#define PG_INT16_MAX
Definition: c.h:521

References elog, ERROR, EXPECT_EQ_U32, EXPECT_TRUE, i, pg_atomic_add_fetch_u32(), pg_atomic_compare_exchange_u32(), pg_atomic_exchange_u32(), pg_atomic_fetch_add_u32(), pg_atomic_fetch_and_u32(), pg_atomic_fetch_or_u32(), pg_atomic_fetch_sub_u32(), pg_atomic_init_u32(), pg_atomic_read_u32(), pg_atomic_sub_fetch_u32(), pg_atomic_write_u32(), PG_INT16_MAX, and PG_INT16_MIN.

Referenced by test_atomic_ops().

◆ test_atomic_uint64()

static void test_atomic_uint64 ( void  )
static

Definition at line 771 of file regress.c.

772 {
773  pg_atomic_uint64 var;
774  uint64 expected;
775  int i;
776 
777  pg_atomic_init_u64(&var, 0);
779  pg_atomic_write_u64(&var, 3);
782  3);
785  EXPECT_EQ_U64(pg_atomic_add_fetch_u64(&var, 10), 10);
788 
789  /* fail exchange because of old expected */
790  expected = 10;
791  EXPECT_TRUE(!pg_atomic_compare_exchange_u64(&var, &expected, 1));
792 
793  /* CAS is allowed to fail due to interrupts, try a couple of times */
794  for (i = 0; i < 100; i++)
795  {
796  expected = 0;
797  if (!pg_atomic_compare_exchange_u64(&var, &expected, 1))
798  break;
799  }
800  if (i == 100)
801  elog(ERROR, "atomic_compare_exchange_u64() never succeeded");
803 
804  pg_atomic_write_u64(&var, 0);
805 
806  /* try setting flagbits */
807  EXPECT_TRUE(!(pg_atomic_fetch_or_u64(&var, 1) & 1));
808  EXPECT_TRUE(pg_atomic_fetch_or_u64(&var, 2) & 1);
810  /* try clearing flagbits */
811  EXPECT_EQ_U64((pg_atomic_fetch_and_u64(&var, ~2) & 3), 3);
813  /* no bits set anymore */
815 }
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition: atomics.h:438
static bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
Definition: atomics.h:456
static uint64 pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition: atomics.h:513
static uint64 pg_atomic_fetch_and_u64(volatile pg_atomic_uint64 *ptr, uint64 and_)
Definition: atomics.h:486
static uint64 pg_atomic_fetch_or_u64(volatile pg_atomic_uint64 *ptr, uint64 or_)
Definition: atomics.h:495
static uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition: atomics.h:504
static uint64 pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval)
Definition: atomics.h:447

References elog, ERROR, EXPECT_EQ_U64, EXPECT_TRUE, i, pg_atomic_add_fetch_u64(), pg_atomic_compare_exchange_u64(), pg_atomic_exchange_u64(), pg_atomic_fetch_add_u64(), pg_atomic_fetch_and_u64(), pg_atomic_fetch_or_u64(), pg_atomic_fetch_sub_u64(), pg_atomic_init_u64(), pg_atomic_read_u64(), pg_atomic_sub_fetch_u64(), and pg_atomic_write_u64().

Referenced by test_atomic_ops().

◆ test_canonicalize_path()

Datum test_canonicalize_path ( PG_FUNCTION_ARGS  )

Definition at line 537 of file regress.c.

538 {
539  char *path = text_to_cstring(PG_GETARG_TEXT_PP(0));
540 
541  canonicalize_path(path);
543 }
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
void canonicalize_path(char *path)
Definition: path.c:264
text * cstring_to_text(const char *s)
Definition: varlena.c:188

References canonicalize_path(), cstring_to_text(), PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, and text_to_cstring().

◆ test_enc_conversion()

Datum test_enc_conversion ( PG_FUNCTION_ARGS  )

Definition at line 1095 of file regress.c.

1096 {
1097  bytea *string = PG_GETARG_BYTEA_PP(0);
1098  char *src_encoding_name = NameStr(*PG_GETARG_NAME(1));
1099  int src_encoding = pg_char_to_encoding(src_encoding_name);
1100  char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2));
1101  int dest_encoding = pg_char_to_encoding(dest_encoding_name);
1102  bool noError = PG_GETARG_BOOL(3);
1103  TupleDesc tupdesc;
1104  char *src;
1105  char *dst;
1106  bytea *retval;
1107  Size srclen;
1108  Size dstsize;
1109  Oid proc;
1110  int convertedbytes;
1111  int dstlen;
1112  Datum values[2];
1113  bool nulls[2];
1114  HeapTuple tuple;
1115 
1116  if (src_encoding < 0)
1117  ereport(ERROR,
1118  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1119  errmsg("invalid source encoding name \"%s\"",
1120  src_encoding_name)));
1121  if (dest_encoding < 0)
1122  ereport(ERROR,
1123  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1124  errmsg("invalid destination encoding name \"%s\"",
1125  dest_encoding_name)));
1126 
1127  /* Build a tuple descriptor for our result type */
1128  if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
1129  elog(ERROR, "return type must be a row type");
1130  tupdesc = BlessTupleDesc(tupdesc);
1131 
1132  srclen = VARSIZE_ANY_EXHDR(string);
1133  src = VARDATA_ANY(string);
1134 
1135  if (src_encoding == dest_encoding)
1136  {
1137  /* just check that the source string is valid */
1138  int oklen;
1139 
1140  oklen = pg_encoding_verifymbstr(src_encoding, src, srclen);
1141 
1142  if (oklen == srclen)
1143  {
1144  convertedbytes = oklen;
1145  retval = string;
1146  }
1147  else if (!noError)
1148  {
1149  report_invalid_encoding(src_encoding, src + oklen, srclen - oklen);
1150  }
1151  else
1152  {
1153  /*
1154  * build bytea data type structure.
1155  */
1156  Assert(oklen < srclen);
1157  convertedbytes = oklen;
1158  retval = (bytea *) palloc(oklen + VARHDRSZ);
1159  SET_VARSIZE(retval, oklen + VARHDRSZ);
1160  memcpy(VARDATA(retval), src, oklen);
1161  }
1162  }
1163  else
1164  {
1165  proc = FindDefaultConversionProc(src_encoding, dest_encoding);
1166  if (!OidIsValid(proc))
1167  ereport(ERROR,
1168  (errcode(ERRCODE_UNDEFINED_FUNCTION),
1169  errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
1170  pg_encoding_to_char(src_encoding),
1171  pg_encoding_to_char(dest_encoding))));
1172 
1173  if (srclen >= (MaxAllocSize / (Size) MAX_CONVERSION_GROWTH))
1174  ereport(ERROR,
1175  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1176  errmsg("out of memory"),
1177  errdetail("String of %d bytes is too long for encoding conversion.",
1178  (int) srclen)));
1179 
1180  dstsize = (Size) srclen * MAX_CONVERSION_GROWTH + 1;
1181  dst = MemoryContextAlloc(CurrentMemoryContext, dstsize);
1182 
1183  /* perform conversion */
1184  convertedbytes = pg_do_encoding_conversion_buf(proc,
1185  src_encoding,
1186  dest_encoding,
1187  (unsigned char *) src, srclen,
1188  (unsigned char *) dst, dstsize,
1189  noError);
1190  dstlen = strlen(dst);
1191 
1192  /*
1193  * build bytea data type structure.
1194  */
1195  retval = (bytea *) palloc(dstlen + VARHDRSZ);
1196  SET_VARSIZE(retval, dstlen + VARHDRSZ);
1197  memcpy(VARDATA(retval), dst, dstlen);
1198 
1199  pfree(dst);
1200  }
1201 
1202  MemSet(nulls, 0, sizeof(nulls));
1203  values[0] = Int32GetDatum(convertedbytes);
1204  values[1] = PointerGetDatum(retval);
1205  tuple = heap_form_tuple(tupdesc, values, nulls);
1206 
1208 }
#define NameStr(name)
Definition: c.h:681
#define VARHDRSZ
Definition: c.h:627
#define MemSet(start, val, len)
Definition: c.h:1008
#define OidIsValid(objectId)
Definition: c.h:710
size_t Size
Definition: c.h:540
int errdetail(const char *fmt,...)
Definition: elog.c:1037
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define ereport(elevel,...)
Definition: elog.h:143
int pg_char_to_encoding(const char *name)
Definition: encnames.c:550
const char * pg_encoding_to_char(int encoding)
Definition: encnames.c:588
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2071
#define PG_GETARG_BYTEA_PP(n)
Definition: fmgr.h:308
#define PG_GETARG_NAME(n)
Definition: fmgr.h:278
#define PG_GETARG_BOOL(n)
Definition: fmgr.h:274
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:276
@ TYPEFUNC_COMPOSITE
Definition: funcapi.h:149
#define HeapTupleGetDatum(tuple)
Definition: funcapi.h:220
Assert(fmt[strlen(fmt) - 1] !='\n')
int pg_do_encoding_conversion_buf(Oid proc, int src_encoding, int dest_encoding, unsigned char *src, int srclen, unsigned char *dest, int destlen, bool noError)
Definition: mbutils.c:469
void report_invalid_encoding(int encoding, const char *mbstr, int len)
Definition: mbutils.c:1647
MemoryContext CurrentMemoryContext
Definition: mcxt.c:42
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:863
#define MaxAllocSize
Definition: memutils.h:40
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:3756
#define MAX_CONVERSION_GROWTH
Definition: pg_wchar.h:300
#define VARDATA(PTR)
Definition: postgres.h:315
#define VARDATA_ANY(PTR)
Definition: postgres.h:361
#define Int32GetDatum(X)
Definition: postgres.h:523
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:342
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:354
char string[11]
Definition: preproc-type.c:46
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
Definition: wchar.c:2176

References Assert(), BlessTupleDesc(), CurrentMemoryContext, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, FindDefaultConversionProc(), get_call_result_type(), heap_form_tuple(), HeapTupleGetDatum, Int32GetDatum, MAX_CONVERSION_GROWTH, MaxAllocSize, MemoryContextAlloc(), MemSet, NameStr, OidIsValid, palloc(), pfree(), pg_char_to_encoding(), pg_do_encoding_conversion_buf(), pg_encoding_to_char(), pg_encoding_verifymbstr(), PG_GETARG_BOOL, PG_GETARG_BYTEA_PP, PG_GETARG_NAME, PG_RETURN_DATUM, PointerGetDatum, report_invalid_encoding(), SET_VARSIZE, TYPEFUNC_COMPOSITE, values, VARDATA, VARDATA_ANY, VARHDRSZ, and VARSIZE_ANY_EXHDR.

◆ test_fdw_handler()

Datum test_fdw_handler ( PG_FUNCTION_ARGS  )

Definition at line 993 of file regress.c.

994 {
995  elog(ERROR, "test_fdw_handler is not implemented");
996  PG_RETURN_NULL();
997 }

References elog, ERROR, and PG_RETURN_NULL.

◆ test_opclass_options_func()

Datum test_opclass_options_func ( PG_FUNCTION_ARGS  )

Definition at line 1074 of file regress.c.

1075 {
1076  PG_RETURN_NULL();
1077 }

References PG_RETURN_NULL.

◆ test_spinlock()

static void test_spinlock ( void  )
static

Definition at line 824 of file regress.c.

825 {
826  /*
827  * Basic tests for spinlocks, as well as the underlying operations.
828  *
829  * We embed the spinlock in a struct with other members to test that the
830  * spinlock operations don't perform too wide writes.
831  */
832  {
833  struct test_lock_struct
834  {
835  char data_before[4];
836  slock_t lock;
837  char data_after[4];
838  } struct_w_lock;
839 
840  memcpy(struct_w_lock.data_before, "abcd", 4);
841  memcpy(struct_w_lock.data_after, "ef12", 4);
842 
843  /* test basic operations via the SpinLock* API */
844  SpinLockInit(&struct_w_lock.lock);
845  SpinLockAcquire(&struct_w_lock.lock);
846  SpinLockRelease(&struct_w_lock.lock);
847 
848  /* test basic operations via underlying S_* API */
849  S_INIT_LOCK(&struct_w_lock.lock);
850  S_LOCK(&struct_w_lock.lock);
851  S_UNLOCK(&struct_w_lock.lock);
852 
853  /* and that "contended" acquisition works */
854  s_lock(&struct_w_lock.lock, "testfile", 17, "testfunc");
855  S_UNLOCK(&struct_w_lock.lock);
856 
857  /*
858  * Check, using TAS directly, that a single spin cycle doesn't block
859  * when acquiring an already acquired lock.
860  */
861 #ifdef TAS
862  S_LOCK(&struct_w_lock.lock);
863 
864  if (!TAS(&struct_w_lock.lock))
865  elog(ERROR, "acquired already held spinlock");
866 
867 #ifdef TAS_SPIN
868  if (!TAS_SPIN(&struct_w_lock.lock))
869  elog(ERROR, "acquired already held spinlock");
870 #endif /* defined(TAS_SPIN) */
871 
872  S_UNLOCK(&struct_w_lock.lock);
873 #endif /* defined(TAS) */
874 
875  /*
876  * Verify that after all of this the non-lock contents are still
877  * correct.
878  */
879  if (memcmp(struct_w_lock.data_before, "abcd", 4) != 0)
880  elog(ERROR, "padding before spinlock modified");
881  if (memcmp(struct_w_lock.data_after, "ef12", 4) != 0)
882  elog(ERROR, "padding after spinlock modified");
883  }
884 
885  /*
886  * Ensure that allocating more than INT32_MAX emulated spinlocks works.
887  * That's interesting because the spinlock emulation uses a 32bit integer
888  * to map spinlocks onto semaphores. There've been bugs...
889  */
890 #ifndef HAVE_SPINLOCKS
891  {
892  /*
893  * Initialize enough spinlocks to advance counter close to wraparound.
894  * It's too expensive to perform acquire/release for each, as those
895  * may be syscalls when the spinlock emulation is used (and even just
896  * atomic TAS would be expensive).
897  */
898  for (uint32 i = 0; i < INT32_MAX - 100000; i++)
899  {
900  slock_t lock;
901 
902  SpinLockInit(&lock);
903  }
904 
905  for (uint32 i = 0; i < 200000; i++)
906  {
907  slock_t lock;
908 
909  SpinLockInit(&lock);
910 
911  SpinLockAcquire(&lock);
912  SpinLockRelease(&lock);
913  SpinLockAcquire(&lock);
914  SpinLockRelease(&lock);
915  }
916  }
917 #endif
918 }
int s_lock(volatile slock_t *lock, const char *file, int line, const char *func)
Definition: s_lock.c:92
#define TAS(lock)
Definition: s_lock.h:985
#define S_UNLOCK(lock)
Definition: s_lock.h:983
#define TAS_SPIN(lock)
Definition: s_lock.h:1042
#define S_INIT_LOCK(lock)
Definition: s_lock.h:984
#define S_LOCK(lock)
Definition: s_lock.h:996

References elog, ERROR, i, S_INIT_LOCK, S_LOCK, s_lock(), S_UNLOCK, SpinLockAcquire, SpinLockInit, SpinLockRelease, TAS, and TAS_SPIN.

Referenced by test_atomic_ops().

◆ test_support_func()

Datum test_support_func ( PG_FUNCTION_ARGS  )

Definition at line 1001 of file regress.c.

1002 {
1003  Node *rawreq = (Node *) PG_GETARG_POINTER(0);
1004  Node *ret = NULL;
1005 
1006  if (IsA(rawreq, SupportRequestSelectivity))
1007  {
1008  /*
1009  * Assume that the target is int4eq; that's safe as long as we don't
1010  * attach this to any other boolean-returning function.
1011  */
1013  Selectivity s1;
1014 
1015  if (req->is_join)
1016  s1 = join_selectivity(req->root, Int4EqualOperator,
1017  req->args,
1018  req->inputcollid,
1019  req->jointype,
1020  req->sjinfo);
1021  else
1022  s1 = restriction_selectivity(req->root, Int4EqualOperator,
1023  req->args,
1024  req->inputcollid,
1025  req->varRelid);
1026 
1027  req->selectivity = s1;
1028  ret = (Node *) req;
1029  }
1030 
1031  if (IsA(rawreq, SupportRequestCost))
1032  {
1033  /* Provide some generic estimate */
1034  SupportRequestCost *req = (SupportRequestCost *) rawreq;
1035 
1036  req->startup = 0;
1037  req->per_tuple = 2 * cpu_operator_cost;
1038  ret = (Node *) req;
1039  }
1040 
1041  if (IsA(rawreq, SupportRequestRows))
1042  {
1043  /*
1044  * Assume that the target is generate_series_int4; that's safe as long
1045  * as we don't attach this to any other set-returning function.
1046  */
1047  SupportRequestRows *req = (SupportRequestRows *) rawreq;
1048 
1049  if (req->node && IsA(req->node, FuncExpr)) /* be paranoid */
1050  {
1051  List *args = ((FuncExpr *) req->node)->args;
1052  Node *arg1 = linitial(args);
1053  Node *arg2 = lsecond(args);
1054 
1055  if (IsA(arg1, Const) &&
1056  !((Const *) arg1)->constisnull &&
1057  IsA(arg2, Const) &&
1058  !((Const *) arg2)->constisnull)
1059  {
1060  int32 val1 = DatumGetInt32(((Const *) arg1)->constvalue);
1061  int32 val2 = DatumGetInt32(((Const *) arg2)->constvalue);
1062 
1063  req->rows = val2 - val1 + 1;
1064  ret = (Node *) req;
1065  }
1066  }
1067  }
1068 
1069  PG_RETURN_POINTER(ret);
1070 }
double cpu_operator_cost
Definition: costsize.c:124
#define IsA(nodeptr, _type_)
Definition: nodes.h:624
double Selectivity
Definition: nodes.h:706
#define linitial(l)
Definition: pg_list.h:174
#define lsecond(l)
Definition: pg_list.h:179
Selectivity restriction_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, int varRelid)
Definition: plancat.c:1846
Selectivity join_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, JoinType jointype, SpecialJoinInfo *sjinfo)
Definition: plancat.c:1885
char * s1
Definition: pg_list.h:51
Definition: nodes.h:574
struct PlannerInfo * root
Definition: supportnodes.h:96
struct SpecialJoinInfo * sjinfo
Definition: supportnodes.h:103

References generate_unaccent_rules::args, SupportRequestSelectivity::args, cpu_operator_cost, DatumGetInt32, SupportRequestSelectivity::inputcollid, SupportRequestSelectivity::is_join, IsA, join_selectivity(), SupportRequestSelectivity::jointype, linitial, lsecond, SupportRequestRows::node, SupportRequestCost::per_tuple, PG_GETARG_POINTER, PG_RETURN_POINTER, restriction_selectivity(), SupportRequestSelectivity::root, SupportRequestRows::rows, s1, SupportRequestSelectivity::selectivity, SupportRequestSelectivity::sjinfo, SupportRequestCost::startup, and SupportRequestSelectivity::varRelid.

◆ trigger_return_old()

Datum trigger_return_old ( PG_FUNCTION_ARGS  )

Definition at line 249 of file regress.c.

250 {
251  TriggerData *trigdata = (TriggerData *) fcinfo->context;
252  HeapTuple tuple;
253 
254  if (!CALLED_AS_TRIGGER(fcinfo))
255  elog(ERROR, "trigger_return_old: not fired by trigger manager");
256 
257  tuple = trigdata->tg_trigtuple;
258 
259  return PointerGetDatum(tuple);
260 }
HeapTuple tg_trigtuple
Definition: trigger.h:36
#define CALLED_AS_TRIGGER(fcinfo)
Definition: trigger.h:26

References CALLED_AS_TRIGGER, elog, ERROR, if(), PointerGetDatum, and TriggerData::tg_trigtuple.

◆ ttdummy()

Datum ttdummy ( PG_FUNCTION_ARGS  )

Definition at line 270 of file regress.c.

271 {
272  TriggerData *trigdata = (TriggerData *) fcinfo->context;
273  Trigger *trigger; /* to get trigger name */
274  char **args; /* arguments */
275  int attnum[2]; /* fnumbers of start/stop columns */
276  Datum oldon,
277  oldoff;
278  Datum newon,
279  newoff;
280  Datum *cvals; /* column values */
281  char *cnulls; /* column nulls */
282  char *relname; /* triggered relation name */
283  Relation rel; /* triggered relation */
284  HeapTuple trigtuple;
285  HeapTuple newtuple = NULL;
286  HeapTuple rettuple;
287  TupleDesc tupdesc; /* tuple description */
288  int natts; /* # of attributes */
289  bool isnull; /* to know is some column NULL or not */
290  int ret;
291  int i;
292 
293  if (!CALLED_AS_TRIGGER(fcinfo))
294  elog(ERROR, "ttdummy: not fired by trigger manager");
295  if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
296  elog(ERROR, "ttdummy: must be fired for row");
297  if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event))
298  elog(ERROR, "ttdummy: must be fired before event");
299  if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
300  elog(ERROR, "ttdummy: cannot process INSERT event");
301  if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
302  newtuple = trigdata->tg_newtuple;
303 
304  trigtuple = trigdata->tg_trigtuple;
305 
306  rel = trigdata->tg_relation;
307  relname = SPI_getrelname(rel);
308 
309  /* check if TT is OFF for this relation */
310  if (ttoff) /* OFF - nothing to do */
311  {
312  pfree(relname);
313  return PointerGetDatum((newtuple != NULL) ? newtuple : trigtuple);
314  }
315 
316  trigger = trigdata->tg_trigger;
317 
318  if (trigger->tgnargs != 2)
319  elog(ERROR, "ttdummy (%s): invalid (!= 2) number of arguments %d",
320  relname, trigger->tgnargs);
321 
322  args = trigger->tgargs;
323  tupdesc = rel->rd_att;
324  natts = tupdesc->natts;
325 
326  for (i = 0; i < 2; i++)
327  {
328  attnum[i] = SPI_fnumber(tupdesc, args[i]);
329  if (attnum[i] <= 0)
330  elog(ERROR, "ttdummy (%s): there is no attribute %s",
331  relname, args[i]);
332  if (SPI_gettypeid(tupdesc, attnum[i]) != INT4OID)
333  elog(ERROR, "ttdummy (%s): attribute %s must be of integer type",
334  relname, args[i]);
335  }
336 
337  oldon = SPI_getbinval(trigtuple, tupdesc, attnum[0], &isnull);
338  if (isnull)
339  elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[0]);
340 
341  oldoff = SPI_getbinval(trigtuple, tupdesc, attnum[1], &isnull);
342  if (isnull)
343  elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[1]);
344 
345  if (newtuple != NULL) /* UPDATE */
346  {
347  newon = SPI_getbinval(newtuple, tupdesc, attnum[0], &isnull);
348  if (isnull)
349  elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[0]);
350  newoff = SPI_getbinval(newtuple, tupdesc, attnum[1], &isnull);
351  if (isnull)
352  elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[1]);
353 
354  if (oldon != newon || oldoff != newoff)
355  ereport(ERROR,
356  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
357  errmsg("ttdummy (%s): you cannot change %s and/or %s columns (use set_ttdummy)",
358  relname, args[0], args[1])));
359 
360  if (newoff != TTDUMMY_INFINITY)
361  {
362  pfree(relname); /* allocated in upper executor context */
363  return PointerGetDatum(NULL);
364  }
365  }
366  else if (oldoff != TTDUMMY_INFINITY) /* DELETE */
367  {
368  pfree(relname);
369  return PointerGetDatum(NULL);
370  }
371 
372  newoff = DirectFunctionCall1(nextval, CStringGetTextDatum("ttdummy_seq"));
373  /* nextval now returns int64; coerce down to int32 */
374  newoff = Int32GetDatum((int32) DatumGetInt64(newoff));
375 
376  /* Connect to SPI manager */
377  if ((ret = SPI_connect()) < 0)
378  elog(ERROR, "ttdummy (%s): SPI_connect returned %d", relname, ret);
379 
380  /* Fetch tuple values and nulls */
381  cvals = (Datum *) palloc(natts * sizeof(Datum));
382  cnulls = (char *) palloc(natts * sizeof(char));
383  for (i = 0; i < natts; i++)
384  {
385  cvals[i] = SPI_getbinval((newtuple != NULL) ? newtuple : trigtuple,
386  tupdesc, i + 1, &isnull);
387  cnulls[i] = (isnull) ? 'n' : ' ';
388  }
389 
390  /* change date column(s) */
391  if (newtuple) /* UPDATE */
392  {
393  cvals[attnum[0] - 1] = newoff; /* start_date eq current date */
394  cnulls[attnum[0] - 1] = ' ';
395  cvals[attnum[1] - 1] = TTDUMMY_INFINITY; /* stop_date eq INFINITY */
396  cnulls[attnum[1] - 1] = ' ';
397  }
398  else
399  /* DELETE */
400  {
401  cvals[attnum[1] - 1] = newoff; /* stop_date eq current date */
402  cnulls[attnum[1] - 1] = ' ';
403  }
404 
405  /* if there is no plan ... */
406  if (splan == NULL)
407  {
408  SPIPlanPtr pplan;
409  Oid *ctypes;
410  char *query;
411 
412  /* allocate space in preparation */
413  ctypes = (Oid *) palloc(natts * sizeof(Oid));
414  query = (char *) palloc(100 + 16 * natts);
415 
416  /*
417  * Construct query: INSERT INTO _relation_ VALUES ($1, ...)
418  */
419  sprintf(query, "INSERT INTO %s VALUES (", relname);
420  for (i = 1; i <= natts; i++)
421  {
422  sprintf(query + strlen(query), "$%d%s",
423  i, (i < natts) ? ", " : ")");
424  ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
425  }
426 
427  /* Prepare plan for query */
428  pplan = SPI_prepare(query, natts, ctypes);
429  if (pplan == NULL)
430  elog(ERROR, "ttdummy (%s): SPI_prepare returned %s", relname, SPI_result_code_string(SPI_result));
431 
432  if (SPI_keepplan(pplan))
433  elog(ERROR, "ttdummy (%s): SPI_keepplan failed", relname);
434 
435  splan = pplan;
436  }
437 
438  ret = SPI_execp(splan, cvals, cnulls, 0);
439 
440  if (ret < 0)
441  elog(ERROR, "ttdummy (%s): SPI_execp returned %d", relname, ret);
442 
443  /* Tuple to return to upper Executor ... */
444  if (newtuple) /* UPDATE */
445  rettuple = SPI_modifytuple(rel, trigtuple, 1, &(attnum[1]), &newoff, NULL);
446  else /* DELETE */
447  rettuple = trigtuple;
448 
449  SPI_finish(); /* don't forget say Bye to SPI mgr */
450 
451  pfree(relname);
452 
453  return PointerGetDatum(rettuple);
454 }
#define CStringGetTextDatum(s)
Definition: builtins.h:85
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:631
int16 attnum
Definition: pg_attribute.h:83
NameData relname
Definition: pg_class.h:38
#define sprintf
Definition: port.h:227
#define DatumGetInt64(X)
Definition: postgres.h:651
static SPIPlanPtr splan
Definition: regress.c:264
#define TTDUMMY_INFINITY
Definition: regress.c:262
Datum nextval(PG_FUNCTION_ARGS)
Definition: sequence.c:591
char * SPI_getrelname(Relation rel)
Definition: spi.c:1324
int SPI_fnumber(TupleDesc tupdesc, const char *fname)
Definition: spi.c:1173
Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber)
Definition: spi.c:1306
int SPI_connect(void)
Definition: spi.c:95
int SPI_result
Definition: spi.c:47
const char * SPI_result_code_string(int code)
Definition: spi.c:1970
int SPI_finish(void)
Definition: spi.c:183
HeapTuple SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, Datum *Values, const char *Nulls)
Definition: spi.c:1104
SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes)
Definition: spi.c:858
int SPI_keepplan(SPIPlanPtr plan)
Definition: spi.c:974
int SPI_execp(SPIPlanPtr plan, Datum *Values, const char *Nulls, long tcount)
Definition: spi.c:702
Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
Definition: spi.c:1250
Relation tg_relation
Definition: trigger.h:35
TriggerEvent tg_event
Definition: trigger.h:34
HeapTuple tg_newtuple
Definition: trigger.h:37
Trigger * tg_trigger
Definition: trigger.h:38
#define TRIGGER_FIRED_BEFORE(event)
Definition: trigger.h:128
#define TRIGGER_FIRED_FOR_ROW(event)
Definition: trigger.h:122
#define TRIGGER_FIRED_BY_INSERT(event)
Definition: trigger.h:110
#define TRIGGER_FIRED_BY_UPDATE(event)
Definition: trigger.h:116

References generate_unaccent_rules::args, attnum, CALLED_AS_TRIGGER, CStringGetTextDatum, DatumGetInt64, DirectFunctionCall1, elog, ereport, errcode(), errmsg(), ERROR, i, if(), Int32GetDatum, nextval(), palloc(), pfree(), PointerGetDatum, relname, SPI_connect(), SPI_execp(), SPI_finish(), SPI_fnumber(), SPI_getbinval(), SPI_getrelname(), SPI_gettypeid(), SPI_keepplan(), SPI_modifytuple(), SPI_prepare(), SPI_result, SPI_result_code_string(), splan, sprintf, TriggerData::tg_event, TriggerData::tg_newtuple, TriggerData::tg_relation, TriggerData::tg_trigger, TriggerData::tg_trigtuple, TRIGGER_FIRED_BEFORE, TRIGGER_FIRED_BY_INSERT, TRIGGER_FIRED_BY_UPDATE, TRIGGER_FIRED_FOR_ROW, TTDUMMY_INFINITY, and ttoff.

◆ wait_pid()

Datum wait_pid ( PG_FUNCTION_ARGS  )

Definition at line 663 of file regress.c.

664 {
665  int pid = PG_GETARG_INT32(0);
666 
667  if (!superuser())
668  elog(ERROR, "must be superuser to check PID liveness");
669 
670  while (kill(pid, 0) == 0)
671  {
673  pg_usleep(50000);
674  }
675 
676  if (errno != ESRCH)
677  elog(ERROR, "could not check PID %d liveness: %m", pid);
678 
679  PG_RETURN_VOID();
680 }
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:121
void pg_usleep(long microsec)
Definition: signal.c:53
#define kill(pid, sig)
Definition: win32_port.h:464

References CHECK_FOR_INTERRUPTS, elog, ERROR, kill, PG_GETARG_INT32, PG_RETURN_VOID, pg_usleep(), and superuser().

◆ widget_in()

Datum widget_in ( PG_FUNCTION_ARGS  )

Definition at line 171 of file regress.c.

172 {
173  char *str = PG_GETARG_CSTRING(0);
174  char *p,
175  *coord[NARGS];
176  int i;
177  WIDGET *result;
178 
179  for (i = 0, p = str; *p && i < NARGS && *p != RDELIM; p++)
180  {
181  if (*p == DELIM || (*p == LDELIM && i == 0))
182  coord[i++] = p + 1;
183  }
184 
185  if (i < NARGS)
186  ereport(ERROR,
187  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
188  errmsg("invalid input syntax for type %s: \"%s\"",
189  "widget", str)));
190 
191  result = (WIDGET *) palloc(sizeof(WIDGET));
192  result->center.x = atof(coord[0]);
193  result->center.y = atof(coord[1]);
194  result->radius = atof(coord[2]);
195 
196  PG_RETURN_POINTER(result);
197 }
#define DELIM
Definition: regress.c:79
#define RDELIM
Definition: regress.c:78
#define LDELIM
Definition: regress.c:77
#define NARGS
Definition: regress.c:168
double radius
Definition: regress.c:162

References WIDGET::center, DELIM, ereport, errcode(), errmsg(), ERROR, i, LDELIM, NARGS, palloc(), PG_GETARG_CSTRING, PG_RETURN_POINTER, WIDGET::radius, RDELIM, generate_unaccent_rules::str, Point::x, and Point::y.

◆ widget_out()

Datum widget_out ( PG_FUNCTION_ARGS  )

Definition at line 200 of file regress.c.

201 {
202  WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(0);
203  char *str = psprintf("(%g,%g,%g)",
204  widget->center.x, widget->center.y, widget->radius);
205 
207 }
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46

References WIDGET::center, PG_GETARG_POINTER, PG_RETURN_CSTRING, psprintf(), WIDGET::radius, generate_unaccent_rules::str, Point::x, and Point::y.

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 83 of file regress.c.

◆ splan

SPIPlanPtr splan = NULL
static

◆ ttoff

bool ttoff = false
static

Definition at line 265 of file regress.c.

Referenced by set_ttdummy(), and ttdummy().