53#define TEXTDOMAIN PG_TEXTDOMAIN("regress")
55#define EXPECT_TRUE(expr) \
59 "%s was unexpectedly false in file \"%s\" line %u", \
60 #expr, __FILE__, __LINE__); \
63#define EXPECT_EQ_U32(result_expr, expected_expr) \
65 uint32 actual_result = (result_expr); \
66 uint32 expected_result = (expected_expr); \
67 if (actual_result != expected_result) \
69 "%s yielded %u, expected %s in file \"%s\" line %u", \
70 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
73#define EXPECT_EQ_U64(result_expr, expected_expr) \
75 uint64 actual_result = (result_expr); \
76 uint64 expected_result = (expected_expr); \
77 if (actual_result != expected_result) \
79 "%s yielded " UINT64_FORMAT ", expected %s in file \"%s\" line %u", \
80 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
111 for (
i = 0;
i < p1->
npts - 1 && !found;
i++)
114 for (
j = 0;
j < p2->
npts - 1 && !found;
j++)
142 lseg->
p[0].
x = pt1->
x;
143 lseg->
p[0].
y = pt1->
y;
144 lseg->
p[1].
x = pt2->
x;
145 lseg->
p[1].
y = pt2->
y;
201 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
202 errmsg(
"invalid input syntax for type %s: \"%s\"",
206 result->
center.
x = atof(coord[0]);
207 result->
center.
y = atof(coord[1]);
208 result->
radius = atof(coord[2]);
256 new_string[
len -
i] =
string[
i];
269 elog(
ERROR,
"trigger_return_old: not fired by trigger manager");
296 i = sscanf(input_string,
317 char *result = (
char *)
palloc(16 * 4);
319 snprintf(result, 16 * 4,
"%d,%d,%d,%d",
362 ncolumns = tupdesc->
natts;
371 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
377 for (
i = 0;
i < ncolumns;
i++)
401 struct varlena *oldattr = attr;
409 redirect_pointer.
pointer = attr;
412 sizeof(redirect_pointer));
448 for (
char **s =
environ; *s; s++)
453 for (
int i = 0;
i < nvals;
i++)
470 elog(
ERROR,
"must be superuser to change environment variables");
472 if (
setenv(envvar, envval, 1) != 0)
473 elog(
ERROR,
"could not set environment variable: %m");
487 elog(
ERROR,
"must be superuser to check PID liveness");
489 while (
kill(pid, 0) == 0)
496 elog(
ERROR,
"could not check PID %d liveness: %m", pid);
567 for (
i = 0;
i < 1000;
i++)
574 elog(
ERROR,
"atomic_compare_exchange_u32() never succeeded");
613 for (
i = 0;
i < 100;
i++)
620 elog(
ERROR,
"atomic_compare_exchange_u64() never succeeded");
652 struct test_lock_struct
659 memcpy(struct_w_lock.data_before,
"abcd", 4);
660 memcpy(struct_w_lock.data_after,
"ef12", 4);
669 S_LOCK(&struct_w_lock.lock);
673 s_lock(&struct_w_lock.lock,
"testfile", 17,
"testfunc");
681 S_LOCK(&struct_w_lock.lock);
683 if (!
TAS(&struct_w_lock.lock))
684 elog(
ERROR,
"acquired already held spinlock");
688 elog(
ERROR,
"acquired already held spinlock");
698 if (memcmp(struct_w_lock.data_before,
"abcd", 4) != 0)
699 elog(
ERROR,
"padding before spinlock modified");
700 if (memcmp(struct_w_lock.data_after,
"ef12", 4) != 0)
701 elog(
ERROR,
"padding after spinlock modified");
728 elog(
ERROR,
"test_fdw_handler is not implemented");
796 !((
Const *) arg1)->constisnull &&
798 !((
Const *) arg2)->constisnull)
803 req->
rows = val2 - val1 + 1;
833 List *raw_parsetree_list;
834 List *querytree_list;
847 ereport(
WARNING, (
errmsg(
"test_inline_in_from_support_func called with non-Const parameters")));
852 if (
c->consttype != TEXTOID ||
c->constisnull)
863 ereport(
WARNING, (
errmsg(
"test_inline_in_from_support_func called with non-Const parameters")));
868 if (
c->consttype != TEXTOID ||
c->constisnull)
958 "official invalid string for encoding \"%s\" has length %d",
963 "official invalid string for encoding \"%s\" has mblen %d",
968 "official invalid string for encoding \"%s\" has valid prefix of length %d",
973 "first byte of official invalid string for encoding \"%s\" has valid prefix of length %d",
975 memset(bigbuf,
' ',
sizeof(bigbuf));
981 "trailing data changed official invalid string for encoding \"%s\" to have valid prefix of length %d",
1022 bool nulls[2] = {0};
1025 if (src_encoding < 0)
1027 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1028 errmsg(
"invalid source encoding name \"%s\"",
1029 src_encoding_name)));
1030 if (dest_encoding < 0)
1032 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1033 errmsg(
"invalid destination encoding name \"%s\"",
1034 dest_encoding_name)));
1038 elog(
ERROR,
"return type must be a row type");
1044 if (src_encoding == dest_encoding)
1051 if (oklen == srclen)
1053 convertedbytes = oklen;
1066 convertedbytes = oklen;
1069 memcpy(
VARDATA(retval), src, oklen);
1077 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
1078 errmsg(
"default conversion function for encoding \"%s\" to \"%s\" does not exist",
1084 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1086 errdetail(
"String of %d bytes is too long for encoding conversion.",
1096 (
unsigned char *) src, srclen,
1097 (
unsigned char *) dst, dstsize,
1099 dstlen = strlen(dst);
1106 memcpy(
VARDATA(retval), dst, dstlen);
1144 elog(
WARNING,
"mismatch between MAX_BACKENDS and PROCNUMBER_CHARS");
1151 elog(
WARNING,
"maximum length relpath is if length %zu instead of %zu",
1165 static bool inited =
false;
1182 setenv(
"LANGUAGE",
"es_ES.UTF-8:es", 1);
1189 errmsg(
"translated PRId64 = %" PRId64, (
int64) 424242424242));
1191 errmsg(
"translated PRId32 = %" PRId32, (
int32) -1234));
1193 errmsg(
"translated PRIdMAX = %" PRIdMAX, (intmax_t) -5678));
1195 errmsg(
"translated PRIdPTR = %" PRIdPTR, (intptr_t) 9999));
1198 errmsg(
"translated PRIu64 = %" PRIu64, (
uint64) 424242424242));
1200 errmsg(
"translated PRIu32 = %" PRIu32, (
uint32) 1234));
1202 errmsg(
"translated PRIuMAX = %" PRIuMAX, (uintmax_t) 5678));
1204 errmsg(
"translated PRIuPTR = %" PRIuPTR, (uintptr_t) 9999));
1207 errmsg(
"translated PRIx64 = %" PRIx64, (
uint64) 424242424242));
1209 errmsg(
"translated PRIx32 = %" PRIx32, (
uint32) 1234));
1211 errmsg(
"translated PRIxMAX = %" PRIxMAX, (uintmax_t) 5678));
1213 errmsg(
"translated PRIxPTR = %" PRIxPTR, (uintptr_t) 9999));
1216 errmsg(
"translated PRIX64 = %" PRIX64, (
uint64) 424242424242));
1218 errmsg(
"translated PRIX32 = %" PRIX32, (
uint32) 1234));
1220 errmsg(
"translated PRIXMAX = %" PRIXMAX, (uintmax_t) 5678));
1222 errmsg(
"translated PRIXPTR = %" PRIXPTR, (uintptr_t) 9999));
Datum querytree(PG_FUNCTION_ARGS)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
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 TextDatumGetCString(d)
#define OidIsValid(objectId)
bool IsCatalogTextUniqueIndexOid(Oid relid)
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,...)
const pg_enc2name pg_enc2name_tbl[]
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
#define palloc_object(type)
#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 PG_GETARG_CSTRING(n)
#define PG_GETARG_NAME(n)
#define PG_GETARG_HEAPTUPLEHEADER(n)
#define PG_RETURN_TEXT_P(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)
void sql_fn_parser_setup(struct ParseState *pstate, SQLFunctionParseInfoPtr pinfo)
SQLFunctionParseInfoPtr prepare_sql_fn_parse_info(HeapTuple procedureTuple, Node *call_expr, Oid inputCollation)
#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)
Assert(PointerIsAligned(start, uint64))
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
static int32 HeapTupleHeaderGetTypMod(const HeapTupleHeaderData *tup)
static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)
static Oid HeapTupleHeaderGetTypeId(const HeapTupleHeaderData *tup)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
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)
void * MemoryContextAlloc(MemoryContext context, Size size)
MemoryContext TopTransactionContext
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define CHECK_FOR_INTERRUPTS()
void pg_bindtextdomain(const char *domain)
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
#define IsA(nodeptr, _type_)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
void(* ParserSetupHook)(ParseState *pstate, void *arg)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
static int list_length(const List *l)
static char buf[DEFAULT_XLOG_SEG_SIZE]
#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)
size_t strnlen(const char *str, size_t maxlen)
List * pg_analyze_and_rewrite_withcb(RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
List * pg_parse_query(const char *query_string)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool 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)
Datum test_inline_in_from_support_func(PG_FUNCTION_ARGS)
#define EXPECT_TRUE(expr)
Datum regress_setenv(PG_FUNCTION_ARGS)
static void test_atomic_uint32(void)
Datum test_relpath(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 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_environ(PG_FUNCTION_ARGS)
Datum test_canonicalize_path(PG_FUNCTION_ARGS)
Datum reverse_name(PG_FUNCTION_ARGS)
Datum widget_in(PG_FUNCTION_ARGS)
PG_MODULE_MAGIC_EXT(.name="regress",.version=PG_VERSION)
Datum wait_pid(PG_FUNCTION_ARGS)
Datum widget_out(PG_FUNCTION_ARGS)
Datum is_catalog_text_unique_index_oid(PG_FUNCTION_ARGS)
static void test_atomic_flag(void)
Datum pt_in_widget(PG_FUNCTION_ARGS)
Datum test_enc_setup(PG_FUNCTION_ARGS)
Datum test_enc_conversion(PG_FUNCTION_ARGS)
Datum test_translation(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)
RelPathStr GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber, int procNumber, ForkNumber forkNumber)
#define REL_PATH_STR_MAXLEN
const char * quote_identifier(const char *ident)
int s_lock(volatile slock_t *lock, const char *file, int line, const char *func)
#define S_INIT_LOCK(lock)
void pg_usleep(long microsec)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
void appendStringInfo(StringInfo str, const char *fmt,...)
void initStringInfo(StringInfo str)
Point p[FLEXIBLE_ARRAY_MEMBER]
char str[REL_PATH_STR_MAXLEN+1]
RangeTblFunction * rtfunc
#define CALLED_AS_TRIGGER(fcinfo)
#define ReleaseTupleDesc(tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
static bool VARATT_IS_EXTERNAL_ONDISK(const void *PTR)
static Size VARSIZE_ANY(const void *PTR)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_EXTERNAL(const void *PTR)
static bool VARATT_IS_EXTERNAL_INDIRECT(const void *PTR)
static char * VARDATA(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
static void SET_VARTAG_EXTERNAL(void *PTR, vartag_external tag)
static void SET_VARSIZE(void *PTR, Size len)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)
void pg_encoding_set_invalid(int encoding, char *dst)
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
int pg_encoding_max_length(int encoding)
int pg_encoding_mblen(int encoding, const char *mbstr)