50 #define EXPECT_TRUE(expr) \
54 "%s was unexpectedly false in file \"%s\" line %u", \
55 #expr, __FILE__, __LINE__); \
58 #define EXPECT_EQ_U32(result_expr, expected_expr) \
60 uint32 actual_result = (result_expr); \
61 uint32 expected_result = (expected_expr); \
62 if (actual_result != expected_result) \
64 "%s yielded %u, expected %s in file \"%s\" line %u", \
65 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
68 #define EXPECT_EQ_U64(result_expr, expected_expr) \
70 uint64 actual_result = (result_expr); \
71 uint64 expected_result = (expected_expr); \
72 if (actual_result != expected_result) \
74 "%s yielded " UINT64_FORMAT ", expected %s in file \"%s\" line %u", \
75 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
103 for (
i = 0;
i < p1->
npts - 1 && !found;
i++)
106 for (
j = 0;
j <
p2->npts - 1 && !found;
j++)
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;
193 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
194 errmsg(
"invalid input syntax for type %s: \"%s\"",
198 result->
center.
x = atof(coord[0]);
199 result->
center.
y = atof(coord[1]);
200 result->
radius = atof(coord[2]);
248 new_string[
len -
i] =
string[
i];
261 elog(
ERROR,
"trigger_return_old: not fired by trigger manager");
268 #define TTDUMMY_INFINITY 999999
300 elog(
ERROR,
"ttdummy: not fired by trigger manager");
302 elog(
ERROR,
"ttdummy: must be fired for row");
304 elog(
ERROR,
"ttdummy: must be fired before event");
306 elog(
ERROR,
"ttdummy: cannot process INSERT event");
324 if (trigger->tgnargs != 2)
325 elog(
ERROR,
"ttdummy (%s): invalid (!= 2) number of arguments %d",
328 args = trigger->tgargs;
329 tupdesc = rel->rd_att;
330 natts = tupdesc->natts;
332 for (
i = 0;
i < 2;
i++)
336 elog(
ERROR,
"ttdummy (%s): there is no attribute %s",
339 elog(
ERROR,
"ttdummy (%s): attribute %s must be of integer type",
351 if (newtuple != NULL)
360 if (oldon != newon || oldoff != newoff)
362 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
363 errmsg(
"ttdummy (%s): you cannot change %s and/or %s columns (use set_ttdummy)",
388 cnulls = (
char *)
palloc(natts *
sizeof(
char));
389 for (
i = 0;
i < natts;
i++)
391 cvals[
i] =
SPI_getbinval((newtuple != NULL) ? newtuple : trigtuple,
392 tupdesc,
i + 1, &isnull);
393 cnulls[
i] = (isnull) ?
'n' :
' ';
399 cvals[
attnum[0] - 1] = newoff;
400 cnulls[
attnum[0] - 1] =
' ';
402 cnulls[
attnum[1] - 1] =
' ';
407 cvals[
attnum[1] - 1] = newoff;
408 cnulls[
attnum[1] - 1] =
' ';
420 query = (
char *)
palloc(100 + 16 * natts);
426 for (
i = 1;
i <= natts;
i++)
428 sprintf(query + strlen(query),
"$%d%s",
429 i, (
i < natts) ?
", " :
")");
453 rettuple = trigtuple;
509 i = sscanf(input_string,
530 char *result = (
char *)
palloc(16 * 4);
532 snprintf(result, 16 * 4,
"%d,%d,%d,%d",
575 ncolumns = tupdesc->
natts;
584 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
590 for (
i = 0;
i < ncolumns;
i++)
613 struct varlena *oldattr = attr;
621 redirect_pointer.
pointer = attr;
624 sizeof(redirect_pointer));
657 elog(
ERROR,
"must be superuser to change environment variables");
659 if (
setenv(envvar, envval, 1) != 0)
660 elog(
ERROR,
"could not set environment variable: %m");
674 elog(
ERROR,
"must be superuser to check PID liveness");
676 while (
kill(pid, 0) == 0)
683 elog(
ERROR,
"could not check PID %d liveness: %m", pid);
754 for (
i = 0;
i < 1000;
i++)
761 elog(
ERROR,
"atomic_compare_exchange_u32() never succeeded");
800 for (
i = 0;
i < 100;
i++)
807 elog(
ERROR,
"atomic_compare_exchange_u64() never succeeded");
839 struct test_lock_struct
846 memcpy(struct_w_lock.data_before,
"abcd", 4);
847 memcpy(struct_w_lock.data_after,
"ef12", 4);
856 S_LOCK(&struct_w_lock.lock);
860 s_lock(&struct_w_lock.lock,
"testfile", 17,
"testfunc");
868 S_LOCK(&struct_w_lock.lock);
870 if (!
TAS(&struct_w_lock.lock))
871 elog(
ERROR,
"acquired already held spinlock");
875 elog(
ERROR,
"acquired already held spinlock");
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");
896 #ifndef HAVE_SPINLOCKS
904 for (
uint32 i = 0;
i < INT32_MAX - 100000;
i++)
944 #define NUM_TEST_ATOMICS (NUM_SPINLOCK_SEMAPHORES + NUM_ATOMICS_SEMAPHORES + 27)
974 #undef NUM_TEST_ATOMICS
1001 elog(
ERROR,
"test_fdw_handler is not implemented");
1062 !((
Const *) arg1)->constisnull &&
1064 !((
Const *) arg2)->constisnull)
1069 req->
rows = val2 - val1 + 1;
1119 bool nulls[2] = {0};
1122 if (src_encoding < 0)
1124 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1125 errmsg(
"invalid source encoding name \"%s\"",
1126 src_encoding_name)));
1127 if (dest_encoding < 0)
1129 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1130 errmsg(
"invalid destination encoding name \"%s\"",
1131 dest_encoding_name)));
1135 elog(
ERROR,
"return type must be a row type");
1141 if (src_encoding == dest_encoding)
1148 if (oklen == srclen)
1150 convertedbytes = oklen;
1163 convertedbytes = oklen;
1166 memcpy(
VARDATA(retval), src, oklen);
1174 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
1175 errmsg(
"default conversion function for encoding \"%s\" to \"%s\" does not exist",
1181 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1183 errdetail(
"String of %d bytes is too long for encoding conversion.",
1193 (
unsigned char *) src, srclen,
1194 (
unsigned char *) dst, dstsize,
1196 dstlen = strlen(dst);
1203 memcpy(
VARDATA(retval), dst, dstlen);
1237 int column_offset = 0;
1240 elog(
ERROR,
"argument must not contain nulls");
1243 elog(
ERROR,
"argument must be empty or one-dimensional array");
1247 for (
int i = 0;
i < ntypes;
i++)
1249 Oid typeoid = type_oids[
i];
1258 elog(
ERROR,
"type %u is not fixed-length data type", typeoid);
#define PG_GETARG_ARRAYTYPE_P(n)
bool array_contains_nulls(ArrayType *array)
int ArrayGetNItems(int ndim, const int *dims)
static uint32 pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_)
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
static void pg_atomic_clear_flag(volatile pg_atomic_flag *ptr)
static uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
static uint32 pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
static uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
static bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
static uint32 pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
static uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
static bool pg_atomic_test_set_flag(volatile pg_atomic_flag *ptr)
static uint64 pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
static bool pg_atomic_unlocked_test_flag(volatile pg_atomic_flag *ptr)
static void pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static uint64 pg_atomic_fetch_and_u64(volatile pg_atomic_uint64 *ptr, uint64 and_)
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
static uint64 pg_atomic_fetch_or_u64(volatile pg_atomic_uint64 *ptr, uint64 or_)
static uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
static uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
static uint64 pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval)
static void pg_atomic_init_flag(volatile pg_atomic_flag *ptr)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define OidIsValid(objectId)
static void PGresult const char * p2
elog(ERROR, "%s: %s", p2, msg)
struct varlena * detoast_external_attr(struct varlena *attr)
#define INDIRECT_POINTER_SIZE
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
#define PG_GETARG_BYTEA_PP(n)
#define PG_GETARG_TEXT_PP(n)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_NAME(n)
#define PG_GETARG_HEAPTUPLEHEADER(n)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define PG_GETARG_POINT_P(n)
static Datum LsegPGetDatum(const LSEG *X)
static Datum PointPGetDatum(const Point *X)
#define PG_GETARG_PATH_P(n)
Datum point_distance(PG_FUNCTION_ARGS)
Datum lseg_intersect(PG_FUNCTION_ARGS)
Datum lseg_interpt(PG_FUNCTION_ARGS)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
#define HeapTupleHeaderGetTypMod(tup)
#define HeapTupleHeaderGetTypeId(tup)
#define HeapTupleHeaderGetDatumLength(tup)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Assert(fmt[strlen(fmt) - 1] !='\n')
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
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)
void report_invalid_encoding(int encoding, const char *mbstr, int len)
MemoryContext TopTransactionContext
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void * MemoryContextAlloc(MemoryContext context, Size size)
#define CHECK_FOR_INTERRUPTS()
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
#define IsA(nodeptr, _type_)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
#define MAX_CONVERSION_GROWTH
#define pg_encoding_to_char
#define pg_char_to_encoding
Selectivity restriction_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, int varRelid)
Selectivity join_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, JoinType jointype, SpecialJoinInfo *sjinfo)
void canonicalize_path(char *path)
static bool DatumGetBool(Datum X)
static int64 DatumGetInt64(Datum X)
static Datum PointerGetDatum(const void *X)
static float8 DatumGetFloat8(Datum X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
char * psprintf(const char *fmt,...)
static void test_spinlock(void)
#define EXPECT_TRUE(expr)
Datum regress_setenv(PG_FUNCTION_ARGS)
static void test_atomic_spin_nest(void)
static void test_atomic_uint32(void)
Datum ttdummy(PG_FUNCTION_ARGS)
#define EXPECT_EQ_U32(result_expr, expected_expr)
Datum test_atomic_ops(PG_FUNCTION_ARGS)
Datum test_support_func(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(interpt_pp)
Datum int44out(PG_FUNCTION_ARGS)
Datum set_ttdummy(PG_FUNCTION_ARGS)
Datum test_opclass_options_func(PG_FUNCTION_ARGS)
Datum test_fdw_handler(PG_FUNCTION_ARGS)
#define EXPECT_EQ_U64(result_expr, expected_expr)
Datum interpt_pp(PG_FUNCTION_ARGS)
static void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2)
Datum trigger_return_old(PG_FUNCTION_ARGS)
Datum int44in(PG_FUNCTION_ARGS)
Datum get_columns_length(PG_FUNCTION_ARGS)
Datum test_canonicalize_path(PG_FUNCTION_ARGS)
Datum reverse_name(PG_FUNCTION_ARGS)
Datum widget_in(PG_FUNCTION_ARGS)
Datum wait_pid(PG_FUNCTION_ARGS)
Datum widget_out(PG_FUNCTION_ARGS)
static void test_atomic_flag(void)
Datum pt_in_widget(PG_FUNCTION_ARGS)
Datum test_enc_conversion(PG_FUNCTION_ARGS)
static void test_atomic_uint64(void)
Datum make_tuple_indirect(PG_FUNCTION_ARGS)
Datum binary_coercible(PG_FUNCTION_ARGS)
Datum overpaid(PG_FUNCTION_ARGS)
int s_lock(volatile slock_t *lock, const char *file, int line, const char *func)
#define S_INIT_LOCK(lock)
Datum nextval(PG_FUNCTION_ARGS)
void pg_usleep(long microsec)
char * SPI_getrelname(Relation rel)
int SPI_fnumber(TupleDesc tupdesc, const char *fname)
Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber)
const char * SPI_result_code_string(int code)
HeapTuple SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, Datum *Values, const char *Nulls)
SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes)
int SPI_keepplan(SPIPlanPtr plan)
int SPI_execp(SPIPlanPtr plan, Datum *Values, const char *Nulls, long tcount)
Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
Point p[FLEXIBLE_ARRAY_MEMBER]
struct PlannerInfo * root
struct SpecialJoinInfo * sjinfo
#define TRIGGER_FIRED_BEFORE(event)
#define CALLED_AS_TRIGGER(fcinfo)
#define TRIGGER_FIRED_FOR_ROW(event)
#define TRIGGER_FIRED_BY_INSERT(event)
#define TRIGGER_FIRED_BY_UPDATE(event)
#define ReleaseTupleDesc(tupdesc)
#define TupleDescAttr(tupdesc, i)
#define att_align_nominal(cur_offset, attalign)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
#define VARATT_IS_EXTERNAL_ONDISK(PTR)
#define VARATT_IS_EXTERNAL_INDIRECT(PTR)
#define SET_VARTAG_EXTERNAL(PTR, tag)
#define VARDATA_EXTERNAL(PTR)
#define SET_VARSIZE(PTR, len)
#define VARSIZE_ANY_EXHDR(PTR)
char * text_to_cstring(const text *t)
text * cstring_to_text(const char *s)
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)