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/array.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 80 of file regress.c.

◆ EXPECT_EQ_U32

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

Definition at line 58 of file regress.c.

◆ EXPECT_EQ_U64

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

Definition at line 68 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 50 of file regress.c.

◆ LDELIM

#define LDELIM   '('

Definition at line 78 of file regress.c.

◆ NARGS

#define NARGS   3

Definition at line 169 of file regress.c.

◆ NUM_TEST_ATOMICS

#define NUM_TEST_ATOMICS   (NUM_SPINLOCK_SEMAPHORES + NUM_ATOMICS_SEMAPHORES + 27)

◆ RDELIM

#define RDELIM   ')'

Definition at line 79 of file regress.c.

◆ TTDUMMY_INFINITY

#define TTDUMMY_INFINITY   999999

Definition at line 268 of file regress.c.

Function Documentation

◆ binary_coercible()

Datum binary_coercible ( PG_FUNCTION_ARGS  )

Definition at line 1218 of file regress.c.

1219 {
1220  Oid srctype = PG_GETARG_OID(0);
1221  Oid targettype = PG_GETARG_OID(1);
1222 
1223  PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
1224 }
#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 1232 of file regress.c.

1233 {
1235  Oid *type_oids;
1236  int ntypes;
1237  int column_offset = 0;
1238 
1239  if (ARR_HASNULL(ta) && array_contains_nulls(ta))
1240  elog(ERROR, "argument must not contain nulls");
1241 
1242  if (ARR_NDIM(ta) > 1)
1243  elog(ERROR, "argument must be empty or one-dimensional array");
1244 
1245  type_oids = (Oid *) ARR_DATA_PTR(ta);
1246  ntypes = ArrayGetNItems(ARR_NDIM(ta), ARR_DIMS(ta));
1247  for (int i = 0; i < ntypes; i++)
1248  {
1249  Oid typeoid = type_oids[i];
1250  int16 typlen;
1251  bool typbyval;
1252  char typalign;
1253 
1254  get_typlenbyvalalign(typeoid, &typlen, &typbyval, &typalign);
1255 
1256  /* the data type must be fixed-length */
1257  if (typlen < 0)
1258  elog(ERROR, "type %u is not fixed-length data type", typeoid);
1259 
1260  column_offset = att_align_nominal(column_offset + typlen, typalign);
1261  }
1262 
1263  PG_RETURN_INT32(column_offset);
1264 }
#define ARR_NDIM(a)
Definition: array.h:290
#define PG_GETARG_ARRAYTYPE_P(n)
Definition: array.h:263
#define ARR_DATA_PTR(a)
Definition: array.h:322
#define ARR_DIMS(a)
Definition: array.h:294
#define ARR_HASNULL(a)
Definition: array.h:291
bool array_contains_nulls(ArrayType *array)
Definition: arrayfuncs.c:3749
int ArrayGetNItems(int ndim, const int *dims)
Definition: arrayutils.c:57
signed short int16
Definition: c.h:482
#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:2226
char typalign
Definition: pg_type.h:176
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:129

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 503 of file regress.c.

504 {
505  char *input_string = PG_GETARG_CSTRING(0);
506  int32 *result = (int32 *) palloc(4 * sizeof(int32));
507  int i;
508 
509  i = sscanf(input_string,
510  "%d, %d, %d, %d",
511  &result[0],
512  &result[1],
513  &result[2],
514  &result[3]);
515  while (i < 4)
516  result[i++] = 0;
517 
518  PG_RETURN_POINTER(result);
519 }
signed int int32
Definition: c.h:483
#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:1201

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

◆ int44out()

Datum int44out ( PG_FUNCTION_ARGS  )

Definition at line 527 of file regress.c.

528 {
529  int32 *an_array = (int32 *) PG_GETARG_POINTER(0);
530  char *result = (char *) palloc(16 * 4);
531 
532  snprintf(result, 16 * 4, "%d,%d,%d,%d",
533  an_array[0],
534  an_array[1],
535  an_array[2],
536  an_array[3]);
537 
538  PG_RETURN_CSTRING(result);
539 }
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_RETURN_CSTRING(x)
Definition: fmgr.h:362
#define snprintf
Definition: port.h:238

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

◆ interpt_pp()

Datum interpt_pp ( PG_FUNCTION_ARGS  )

Definition at line 91 of file regress.c.

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

554 {
556  HeapTupleData tuple;
557  int ncolumns;
558  Datum *values;
559  bool *nulls;
560 
561  Oid tupType;
562  int32 tupTypmod;
563  TupleDesc tupdesc;
564 
565  HeapTuple newtup;
566 
567  int i;
568 
569  MemoryContext old_context;
570 
571  /* Extract type info from the tuple itself */
572  tupType = HeapTupleHeaderGetTypeId(rec);
573  tupTypmod = HeapTupleHeaderGetTypMod(rec);
574  tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
575  ncolumns = tupdesc->natts;
576 
577  /* Build a temporary HeapTuple control structure */
579  ItemPointerSetInvalid(&(tuple.t_self));
580  tuple.t_tableOid = InvalidOid;
581  tuple.t_data = rec;
582 
583  values = (Datum *) palloc(ncolumns * sizeof(Datum));
584  nulls = (bool *) palloc(ncolumns * sizeof(bool));
585 
586  heap_deform_tuple(&tuple, tupdesc, values, nulls);
587 
589 
590  for (i = 0; i < ncolumns; i++)
591  {
592  struct varlena *attr;
593  struct varlena *new_attr;
594  struct varatt_indirect redirect_pointer;
595 
596  /* only work on existing, not-null varlenas */
597  if (TupleDescAttr(tupdesc, i)->attisdropped ||
598  nulls[i] ||
599  TupleDescAttr(tupdesc, i)->attlen != -1)
600  continue;
601 
602  attr = (struct varlena *) DatumGetPointer(values[i]);
603 
604  /* don't recursively indirect */
605  if (VARATT_IS_EXTERNAL_INDIRECT(attr))
606  continue;
607 
608  /* copy datum, so it still lives later */
609  if (VARATT_IS_EXTERNAL_ONDISK(attr))
610  attr = detoast_external_attr(attr);
611  else
612  {
613  struct varlena *oldattr = attr;
614 
615  attr = palloc0(VARSIZE_ANY(oldattr));
616  memcpy(attr, oldattr, VARSIZE_ANY(oldattr));
617  }
618 
619  /* build indirection Datum */
620  new_attr = (struct varlena *) palloc0(INDIRECT_POINTER_SIZE);
621  redirect_pointer.pointer = attr;
623  memcpy(VARDATA_EXTERNAL(new_attr), &redirect_pointer,
624  sizeof(redirect_pointer));
625 
626  values[i] = PointerGetDatum(new_attr);
627  }
628 
629  newtup = heap_form_tuple(tupdesc, values, nulls);
630  pfree(values);
631  pfree(nulls);
632  ReleaseTupleDesc(tupdesc);
633 
634  MemoryContextSwitchTo(old_context);
635 
636  /*
637  * We intentionally don't use PG_RETURN_HEAPTUPLEHEADER here, because that
638  * would cause the indirect toast pointers to be flattened out of the
639  * tuple immediately, rendering subsequent testing irrelevant. So just
640  * return the HeapTupleHeader pointer as-is. This violates the general
641  * rule that composite Datums shouldn't contain toast pointers, but so
642  * long as the regression test scripts don't insert the result of this
643  * function into a container type (record, array, etc) it should be OK.
644  */
645  PG_RETURN_POINTER(newtup->t_data);
646 }
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, const Datum *values, const bool *isnull)
Definition: heaptuple.c:1117
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1346
#define HeapTupleHeaderGetTypMod(tup)
Definition: htup_details.h:466
#define HeapTupleHeaderGetTypeId(tup)
Definition: htup_details.h:456
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:450
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Definition: itemptr.h:184
MemoryContext TopTransactionContext
Definition: mcxt.c:146
void pfree(void *pointer)
Definition: mcxt.c:1431
void * palloc0(Size size)
Definition: mcxt.c:1232
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
int16 attlen
Definition: pg_attribute.h:59
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
uintptr_t Datum
Definition: postgres.h:64
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312
#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:676
#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:1832
#define VARATT_IS_EXTERNAL_ONDISK(PTR)
Definition: varatt.h:290
#define VARATT_IS_EXTERNAL_INDIRECT(PTR)
Definition: varatt.h:292
#define VARSIZE_ANY(PTR)
Definition: varatt.h:311
#define SET_VARTAG_EXTERNAL(PTR, tag)
Definition: varatt.h:309
#define VARDATA_EXTERNAL(PTR)
Definition: varatt.h:286
@ VARTAG_INDIRECT
Definition: varatt.h:86

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 143 of file regress.c.

144 {
146  bool isnull;
147  int32 salary;
148 
149  salary = DatumGetInt32(GetAttributeByName(tuple, "salary", &isnull));
150  if (isnull)
151  PG_RETURN_NULL();
152  PG_RETURN_BOOL(salary > 699);
153 }
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
Definition: execUtils.c:1000
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:202

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 218 of file regress.c.

219 {
220  Point *point = PG_GETARG_POINT_P(0);
221  WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(1);
222  float8 distance;
223 
225  PointPGetDatum(point),
226  PointPGetDatum(&widget->center)));
227 
228  PG_RETURN_BOOL(distance < widget->radius);
229 }
double float8
Definition: c.h:619
#define PG_GETARG_POINT_P(n)
Definition: geo_decls.h:185
static Datum PointPGetDatum(const Point *X)
Definition: geo_decls.h:181
Datum point_distance(PG_FUNCTION_ARGS)
Definition: geo_ops.c:1993
static float8 DatumGetFloat8(Datum X)
Definition: postgres.h:494
Point center
Definition: regress.c:162

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 132 of file regress.c.

133 {
134  lseg->p[0].x = pt1->x;
135  lseg->p[0].y = pt1->y;
136  lseg->p[1].x = pt2->x;
137  lseg->p[1].y = pt2->y;
138 }
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 651 of file regress.c.

652 {
653  char *envvar = text_to_cstring(PG_GETARG_TEXT_PP(0));
654  char *envval = text_to_cstring(PG_GETARG_TEXT_PP(1));
655 
656  if (!superuser())
657  elog(ERROR, "must be superuser to change environment variables");
658 
659  if (setenv(envvar, envval, 1) != 0)
660  elog(ERROR, "could not set environment variable: %m");
661 
662  PG_RETURN_VOID();
663 }
#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:217
#define setenv(x, y, z)
Definition: win32_port.h:537

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 234 of file regress.c.

235 {
236  char *string = PG_GETARG_CSTRING(0);
237  int i;
238  int len;
239  char *new_string;
240 
241  new_string = palloc0(NAMEDATALEN);
242  for (i = 0; i < NAMEDATALEN && string[i]; ++i)
243  ;
244  if (i == NAMEDATALEN || !string[i])
245  --i;
246  len = i;
247  for (; i >= 0; --i)
248  new_string[len - i] = string[i];
249  PG_RETURN_CSTRING(new_string);
250 }
#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 465 of file regress.c.

466 {
467  int32 on = PG_GETARG_INT32(0);
468 
469  if (ttoff) /* OFF currently */
470  {
471  if (on == 0)
472  PG_RETURN_INT32(0);
473 
474  /* turn ON */
475  ttoff = false;
476  PG_RETURN_INT32(0);
477  }
478 
479  /* ON currently */
480  if (on != 0)
481  PG_RETURN_INT32(1);
482 
483  /* turn OFF */
484  ttoff = true;
485 
486  PG_RETURN_INT32(1);
487 }
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269
static bool ttoff
Definition: regress.c:271

References PG_GETARG_INT32, PG_RETURN_INT32, and ttoff.

◆ test_atomic_flag()

static void test_atomic_flag ( void  )
static

Definition at line 689 of file regress.c.

690 {
692 
702 }
static void pg_atomic_clear_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:204
static bool pg_atomic_test_set_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:180
static bool pg_atomic_unlocked_test_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:193
static void pg_atomic_init_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:167
#define EXPECT_TRUE(expr)
Definition: regress.c:50
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 978 of file regress.c.

979 {
981 
983 
985 
986  /*
987  * Arguably this shouldn't be tested as part of this function, but it's
988  * closely enough related that that seems ok for now.
989  */
990  test_spinlock();
991 
993 
994  PG_RETURN_BOOL(true);
995 }
static void test_spinlock(void)
Definition: regress.c:830
static void test_atomic_spin_nest(void)
Definition: regress.c:941
static void test_atomic_uint32(void)
Definition: regress.c:705
static void test_atomic_flag(void)
Definition: regress.c:689
static void test_atomic_uint64(void)
Definition: regress.c:777

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 941 of file regress.c.

942 {
943  slock_t lock;
944 #define NUM_TEST_ATOMICS (NUM_SPINLOCK_SEMAPHORES + NUM_ATOMICS_SEMAPHORES + 27)
947 
948  SpinLockInit(&lock);
949 
950  for (int i = 0; i < NUM_TEST_ATOMICS; i++)
951  {
952  pg_atomic_init_u32(&atomics32[i], 0);
953  pg_atomic_init_u64(&atomics64[i], 0);
954  }
955 
956  /* just so it's not all zeroes */
957  for (int i = 0; i < NUM_TEST_ATOMICS; i++)
958  {
959  EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&atomics32[i], i), 0);
960  EXPECT_EQ_U64(pg_atomic_fetch_add_u64(&atomics64[i], i), 0);
961  }
962 
963  /* test whether we can do atomic op with lock held */
964  SpinLockAcquire(&lock);
965  for (int i = 0; i < NUM_TEST_ATOMICS; i++)
966  {
967  EXPECT_EQ_U32(pg_atomic_fetch_sub_u32(&atomics32[i], i), i);
968  EXPECT_EQ_U32(pg_atomic_read_u32(&atomics32[i]), 0);
969  EXPECT_EQ_U64(pg_atomic_fetch_sub_u64(&atomics64[i], i), i);
970  EXPECT_EQ_U64(pg_atomic_read_u64(&atomics64[i]), 0);
971  }
972  SpinLockRelease(&lock);
973 }
static uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition: atomics.h:338
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition: atomics.h:218
static uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition: atomics.h:323
static uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition: atomics.h:462
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
Definition: atomics.h:236
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition: atomics.h:410
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
Definition: atomics.h:424
static uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition: atomics.h:471
#define EXPECT_EQ_U32(result_expr, expected_expr)
Definition: regress.c:58
#define NUM_TEST_ATOMICS
#define EXPECT_EQ_U64(result_expr, expected_expr)
Definition: regress.c:68
int slock_t
Definition: s_lock.h:754
#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 705 of file regress.c.

706 {
707  pg_atomic_uint32 var;
708  uint32 expected;
709  int i;
710 
711  pg_atomic_init_u32(&var, 0);
713  pg_atomic_write_u32(&var, 3);
716  3);
719  EXPECT_EQ_U32(pg_atomic_add_fetch_u32(&var, 10), 10);
722 
723  /* test around numerical limits */
724  EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, INT_MAX), 0);
725  EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, INT_MAX), INT_MAX);
726  pg_atomic_fetch_add_u32(&var, 2); /* wrap to 0 */
729  PG_INT16_MAX);
731  2 * PG_INT16_MAX + 1);
733  PG_INT16_MAX);
734  pg_atomic_fetch_add_u32(&var, 1); /* top up to UINT_MAX */
735  EXPECT_EQ_U32(pg_atomic_read_u32(&var), UINT_MAX);
736  EXPECT_EQ_U32(pg_atomic_fetch_sub_u32(&var, INT_MAX), UINT_MAX);
737  EXPECT_EQ_U32(pg_atomic_read_u32(&var), (uint32) INT_MAX + 1);
738  EXPECT_EQ_U32(pg_atomic_sub_fetch_u32(&var, INT_MAX), 1);
739  pg_atomic_sub_fetch_u32(&var, 1);
740  expected = PG_INT16_MAX;
741  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
742  expected = PG_INT16_MAX + 1;
743  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
744  expected = PG_INT16_MIN;
745  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
746  expected = PG_INT16_MIN - 1;
747  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
748 
749  /* fail exchange because of old expected */
750  expected = 10;
751  EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
752 
753  /* CAS is allowed to fail due to interrupts, try a couple of times */
754  for (i = 0; i < 1000; i++)
755  {
756  expected = 0;
757  if (!pg_atomic_compare_exchange_u32(&var, &expected, 1))
758  break;
759  }
760  if (i == 1000)
761  elog(ERROR, "atomic_compare_exchange_u32() never succeeded");
763  pg_atomic_write_u32(&var, 0);
764 
765  /* try setting flagbits */
766  EXPECT_TRUE(!(pg_atomic_fetch_or_u32(&var, 1) & 1));
767  EXPECT_TRUE(pg_atomic_fetch_or_u32(&var, 2) & 1);
769  /* try clearing flagbits */
770  EXPECT_EQ_U32(pg_atomic_fetch_and_u32(&var, ~2) & 3, 3);
772  /* no bits set anymore */
774 }
static uint32 pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_)
Definition: atomics.h:353
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
Definition: atomics.h:306
static uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
Definition: atomics.h:367
static uint32 pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition: atomics.h:396
static uint32 pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition: atomics.h:381
static void pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition: atomics.h:253
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
Definition: atomics.h:287
unsigned int uint32
Definition: c.h:495
#define PG_INT16_MIN
Definition: c.h:574
#define PG_INT16_MAX
Definition: c.h:575

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 777 of file regress.c.

778 {
779  pg_atomic_uint64 var;
780  uint64 expected;
781  int i;
782 
783  pg_atomic_init_u64(&var, 0);
785  pg_atomic_write_u64(&var, 3);
788  3);
791  EXPECT_EQ_U64(pg_atomic_add_fetch_u64(&var, 10), 10);
794 
795  /* fail exchange because of old expected */
796  expected = 10;
797  EXPECT_TRUE(!pg_atomic_compare_exchange_u64(&var, &expected, 1));
798 
799  /* CAS is allowed to fail due to interrupts, try a couple of times */
800  for (i = 0; i < 100; i++)
801  {
802  expected = 0;
803  if (!pg_atomic_compare_exchange_u64(&var, &expected, 1))
804  break;
805  }
806  if (i == 100)
807  elog(ERROR, "atomic_compare_exchange_u64() never succeeded");
809 
810  pg_atomic_write_u64(&var, 0);
811 
812  /* try setting flagbits */
813  EXPECT_TRUE(!(pg_atomic_fetch_or_u64(&var, 1) & 1));
814  EXPECT_TRUE(pg_atomic_fetch_or_u64(&var, 2) & 1);
816  /* try clearing flagbits */
817  EXPECT_EQ_U64((pg_atomic_fetch_and_u64(&var, ~2) & 3), 3);
819  /* no bits set anymore */
821 }
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition: atomics.h:433
static bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
Definition: atomics.h:451
static uint64 pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition: atomics.h:508
static uint64 pg_atomic_fetch_and_u64(volatile pg_atomic_uint64 *ptr, uint64 and_)
Definition: atomics.h:481
static uint64 pg_atomic_fetch_or_u64(volatile pg_atomic_uint64 *ptr, uint64 or_)
Definition: atomics.h:490
static uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition: atomics.h:499
static uint64 pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval)
Definition: atomics.h:442

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 543 of file regress.c.

544 {
545  char *path = text_to_cstring(PG_GETARG_TEXT_PP(0));
546 
547  canonicalize_path(path);
549 }
#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:184

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 1101 of file regress.c.

1102 {
1103  bytea *string = PG_GETARG_BYTEA_PP(0);
1104  char *src_encoding_name = NameStr(*PG_GETARG_NAME(1));
1105  int src_encoding = pg_char_to_encoding(src_encoding_name);
1106  char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2));
1107  int dest_encoding = pg_char_to_encoding(dest_encoding_name);
1108  bool noError = PG_GETARG_BOOL(3);
1109  TupleDesc tupdesc;
1110  char *src;
1111  char *dst;
1112  bytea *retval;
1113  Size srclen;
1114  Size dstsize;
1115  Oid proc;
1116  int convertedbytes;
1117  int dstlen;
1118  Datum values[2];
1119  bool nulls[2] = {0};
1120  HeapTuple tuple;
1121 
1122  if (src_encoding < 0)
1123  ereport(ERROR,
1124  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1125  errmsg("invalid source encoding name \"%s\"",
1126  src_encoding_name)));
1127  if (dest_encoding < 0)
1128  ereport(ERROR,
1129  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1130  errmsg("invalid destination encoding name \"%s\"",
1131  dest_encoding_name)));
1132 
1133  /* Build a tuple descriptor for our result type */
1134  if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
1135  elog(ERROR, "return type must be a row type");
1136  tupdesc = BlessTupleDesc(tupdesc);
1137 
1138  srclen = VARSIZE_ANY_EXHDR(string);
1139  src = VARDATA_ANY(string);
1140 
1141  if (src_encoding == dest_encoding)
1142  {
1143  /* just check that the source string is valid */
1144  int oklen;
1145 
1146  oklen = pg_encoding_verifymbstr(src_encoding, src, srclen);
1147 
1148  if (oklen == srclen)
1149  {
1150  convertedbytes = oklen;
1151  retval = string;
1152  }
1153  else if (!noError)
1154  {
1155  report_invalid_encoding(src_encoding, src + oklen, srclen - oklen);
1156  }
1157  else
1158  {
1159  /*
1160  * build bytea data type structure.
1161  */
1162  Assert(oklen < srclen);
1163  convertedbytes = oklen;
1164  retval = (bytea *) palloc(oklen + VARHDRSZ);
1165  SET_VARSIZE(retval, oklen + VARHDRSZ);
1166  memcpy(VARDATA(retval), src, oklen);
1167  }
1168  }
1169  else
1170  {
1171  proc = FindDefaultConversionProc(src_encoding, dest_encoding);
1172  if (!OidIsValid(proc))
1173  ereport(ERROR,
1174  (errcode(ERRCODE_UNDEFINED_FUNCTION),
1175  errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
1176  pg_encoding_to_char(src_encoding),
1177  pg_encoding_to_char(dest_encoding))));
1178 
1179  if (srclen >= (MaxAllocSize / (Size) MAX_CONVERSION_GROWTH))
1180  ereport(ERROR,
1181  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1182  errmsg("out of memory"),
1183  errdetail("String of %d bytes is too long for encoding conversion.",
1184  (int) srclen)));
1185 
1186  dstsize = (Size) srclen * MAX_CONVERSION_GROWTH + 1;
1187  dst = MemoryContextAlloc(CurrentMemoryContext, dstsize);
1188 
1189  /* perform conversion */
1190  convertedbytes = pg_do_encoding_conversion_buf(proc,
1191  src_encoding,
1192  dest_encoding,
1193  (unsigned char *) src, srclen,
1194  (unsigned char *) dst, dstsize,
1195  noError);
1196  dstlen = strlen(dst);
1197 
1198  /*
1199  * build bytea data type structure.
1200  */
1201  retval = (bytea *) palloc(dstlen + VARHDRSZ);
1202  SET_VARSIZE(retval, dstlen + VARHDRSZ);
1203  memcpy(VARDATA(retval), dst, dstlen);
1204 
1205  pfree(dst);
1206  }
1207 
1208  values[0] = Int32GetDatum(convertedbytes);
1209  values[1] = PointerGetDatum(retval);
1210  tuple = heap_form_tuple(tupdesc, values, nulls);
1211 
1213 }
#define NameStr(name)
Definition: c.h:735
#define VARHDRSZ
Definition: c.h:681
#define OidIsValid(objectId)
Definition: c.h:764
size_t Size
Definition: c.h:594
int errdetail(const char *fmt,...)
Definition: elog.c:1208
int errcode(int sqlerrcode)
Definition: elog.c:860
int errmsg(const char *fmt,...)
Definition: elog.c:1075
#define ereport(elevel,...)
Definition: elog.h:149
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2070
#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
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
Definition: funcapi.h:230
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:470
void report_invalid_encoding(int encoding, const char *mbstr, int len)
Definition: mbutils.c:1705
MemoryContext CurrentMemoryContext
Definition: mcxt.c:135
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:1034
#define MaxAllocSize
Definition: memutils.h:40
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:4065
#define MAX_CONVERSION_GROWTH
Definition: pg_wchar.h:303
#define pg_encoding_to_char
Definition: pg_wchar.h:561
#define pg_char_to_encoding
Definition: pg_wchar.h:560
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:212
char string[11]
Definition: preproc-type.c:52
#define VARDATA(PTR)
Definition: varatt.h:278
#define VARDATA_ANY(PTR)
Definition: varatt.h:324
#define SET_VARSIZE(PTR, len)
Definition: varatt.h:305
#define VARSIZE_ANY_EXHDR(PTR)
Definition: varatt.h:317
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
Definition: wchar.c:2178

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(), 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 999 of file regress.c.

1000 {
1001  elog(ERROR, "test_fdw_handler is not implemented");
1002  PG_RETURN_NULL();
1003 }

References elog(), ERROR, and PG_RETURN_NULL.

◆ test_opclass_options_func()

Datum test_opclass_options_func ( PG_FUNCTION_ARGS  )

Definition at line 1080 of file regress.c.

1081 {
1082  PG_RETURN_NULL();
1083 }

References PG_RETURN_NULL.

◆ test_spinlock()

static void test_spinlock ( void  )
static

Definition at line 830 of file regress.c.

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

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 1007 of file regress.c.

1008 {
1009  Node *rawreq = (Node *) PG_GETARG_POINTER(0);
1010  Node *ret = NULL;
1011 
1012  if (IsA(rawreq, SupportRequestSelectivity))
1013  {
1014  /*
1015  * Assume that the target is int4eq; that's safe as long as we don't
1016  * attach this to any other boolean-returning function.
1017  */
1019  Selectivity s1;
1020 
1021  if (req->is_join)
1022  s1 = join_selectivity(req->root, Int4EqualOperator,
1023  req->args,
1024  req->inputcollid,
1025  req->jointype,
1026  req->sjinfo);
1027  else
1028  s1 = restriction_selectivity(req->root, Int4EqualOperator,
1029  req->args,
1030  req->inputcollid,
1031  req->varRelid);
1032 
1033  req->selectivity = s1;
1034  ret = (Node *) req;
1035  }
1036 
1037  if (IsA(rawreq, SupportRequestCost))
1038  {
1039  /* Provide some generic estimate */
1040  SupportRequestCost *req = (SupportRequestCost *) rawreq;
1041 
1042  req->startup = 0;
1043  req->per_tuple = 2 * cpu_operator_cost;
1044  ret = (Node *) req;
1045  }
1046 
1047  if (IsA(rawreq, SupportRequestRows))
1048  {
1049  /*
1050  * Assume that the target is generate_series_int4; that's safe as long
1051  * as we don't attach this to any other set-returning function.
1052  */
1053  SupportRequestRows *req = (SupportRequestRows *) rawreq;
1054 
1055  if (req->node && IsA(req->node, FuncExpr)) /* be paranoid */
1056  {
1057  List *args = ((FuncExpr *) req->node)->args;
1058  Node *arg1 = linitial(args);
1059  Node *arg2 = lsecond(args);
1060 
1061  if (IsA(arg1, Const) &&
1062  !((Const *) arg1)->constisnull &&
1063  IsA(arg2, Const) &&
1064  !((Const *) arg2)->constisnull)
1065  {
1066  int32 val1 = DatumGetInt32(((Const *) arg1)->constvalue);
1067  int32 val2 = DatumGetInt32(((Const *) arg2)->constvalue);
1068 
1069  req->rows = val2 - val1 + 1;
1070  ret = (Node *) req;
1071  }
1072  }
1073  }
1074 
1075  PG_RETURN_POINTER(ret);
1076 }
double cpu_operator_cost
Definition: costsize.c:124
#define IsA(nodeptr, _type_)
Definition: nodes.h:158
double Selectivity
Definition: nodes.h:240
#define linitial(l)
Definition: pg_list.h:178
#define lsecond(l)
Definition: pg_list.h:183
Selectivity restriction_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, int varRelid)
Definition: plancat.c:1921
Selectivity join_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, JoinType jointype, SpecialJoinInfo *sjinfo)
Definition: plancat.c:1960
char * s1
Definition: pg_list.h:54
Definition: nodes.h:129
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 255 of file regress.c.

256 {
257  TriggerData *trigdata = (TriggerData *) fcinfo->context;
258  HeapTuple tuple;
259 
260  if (!CALLED_AS_TRIGGER(fcinfo))
261  elog(ERROR, "trigger_return_old: not fired by trigger manager");
262 
263  tuple = trigdata->tg_trigtuple;
264 
265  return PointerGetDatum(tuple);
266 }
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:77
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 276 of file regress.c.

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

670 {
671  int pid = PG_GETARG_INT32(0);
672 
673  if (!superuser())
674  elog(ERROR, "must be superuser to check PID liveness");
675 
676  while (kill(pid, 0) == 0)
677  {
679  pg_usleep(50000);
680  }
681 
682  if (errno != ESRCH)
683  elog(ERROR, "could not check PID %d liveness: %m", pid);
684 
685  PG_RETURN_VOID();
686 }
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:122
void pg_usleep(long microsec)
Definition: signal.c:53
#define kill(pid, sig)
Definition: win32_port.h:485

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 172 of file regress.c.

173 {
174  char *str = PG_GETARG_CSTRING(0);
175  char *p,
176  *coord[NARGS];
177  int i;
178  WIDGET *result;
179 
180  for (i = 0, p = str; *p && i < NARGS && *p != RDELIM; p++)
181  {
182  if (*p == DELIM || (*p == LDELIM && i == 0))
183  coord[i++] = p + 1;
184  }
185 
186  /*
187  * Note: DON'T convert this error to "soft" style (errsave/ereturn). We
188  * want this data type to stay permanently in the hard-error world so that
189  * it can be used for testing that such cases still work reasonably.
190  */
191  if (i < NARGS)
192  ereport(ERROR,
193  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
194  errmsg("invalid input syntax for type %s: \"%s\"",
195  "widget", str)));
196 
197  result = (WIDGET *) palloc(sizeof(WIDGET));
198  result->center.x = atof(coord[0]);
199  result->center.y = atof(coord[1]);
200  result->radius = atof(coord[2]);
201 
202  PG_RETURN_POINTER(result);
203 }
#define DELIM
Definition: regress.c:80
#define RDELIM
Definition: regress.c:79
#define LDELIM
Definition: regress.c:78
#define NARGS
Definition: regress.c:169
double radius
Definition: regress.c:163

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 206 of file regress.c.

207 {
208  WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(0);
209  char *str = psprintf("(%g,%g,%g)",
210  widget->center.x, widget->center.y, widget->radius);
211 
213 }
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 84 of file regress.c.

◆ splan

◆ ttoff

bool ttoff = false
static

Definition at line 271 of file regress.c.

Referenced by set_ttdummy(), and ttdummy().