PostgreSQL Source Code git master
Loading...
Searching...
No Matches
regress.c
Go to the documentation of this file.
1/*------------------------------------------------------------------------
2 *
3 * regress.c
4 * Code for various C-language functions defined as part of the
5 * regression tests.
6 *
7 * This code is released under the terms of the PostgreSQL License.
8 *
9 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
10 * Portions Copyright (c) 1994, Regents of the University of California
11 *
12 * src/test/regress/regress.c
13 *
14 *-------------------------------------------------------------------------
15 */
16
17#include "postgres.h"
18
19#include <math.h>
20#include <signal.h>
21
22#include "access/detoast.h"
23#include "access/htup_details.h"
24#include "catalog/catalog.h"
25#include "catalog/namespace.h"
26#include "catalog/pg_operator.h"
27#include "catalog/pg_type.h"
28#include "commands/sequence.h"
29#include "commands/trigger.h"
31#include "executor/executor.h"
32#include "executor/functions.h"
33#include "executor/spi.h"
34#include "foreign/foreign.h"
35#include "funcapi.h"
36#include "mb/pg_wchar.h"
37#include "miscadmin.h"
38#include "nodes/supportnodes.h"
39#include "optimizer/optimizer.h"
40#include "optimizer/plancat.h"
41#include "parser/parse_coerce.h"
42#include "port/atomics.h"
44#include "postmaster/postmaster.h" /* for MAX_BACKENDS */
45#include "storage/spin.h"
46#include "tcop/tcopprot.h"
47#include "utils/array.h"
48#include "utils/builtins.h"
49#include "utils/geo_decls.h"
50#include "utils/memutils.h"
51#include "utils/rel.h"
52#include "utils/typcache.h"
53
54/* define our text domain for translations */
55#undef TEXTDOMAIN
56#define TEXTDOMAIN PG_TEXTDOMAIN("postgresql-regress")
57
58#define EXPECT_TRUE(expr) \
59 do { \
60 if (!(expr)) \
61 elog(ERROR, \
62 "%s was unexpectedly false in file \"%s\" line %u", \
63 #expr, __FILE__, __LINE__); \
64 } while (0)
65
66#define EXPECT_EQ_U32(result_expr, expected_expr) \
67 do { \
68 uint32 actual_result = (result_expr); \
69 uint32 expected_result = (expected_expr); \
70 if (actual_result != expected_result) \
71 elog(ERROR, \
72 "%s yielded %u, expected %s in file \"%s\" line %u", \
73 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
74 } while (0)
75
76#define EXPECT_EQ_U64(result_expr, expected_expr) \
77 do { \
78 uint64 actual_result = (result_expr); \
79 uint64 expected_result = (expected_expr); \
80 if (actual_result != expected_result) \
81 elog(ERROR, \
82 "%s yielded " UINT64_FORMAT ", expected %s in file \"%s\" line %u", \
83 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
84 } while (0)
85
86#define LDELIM '('
87#define RDELIM ')'
88#define DELIM ','
89
91
93 .name = "regress",
94 .version = PG_VERSION
95);
96
97
98/* return the point where two paths intersect, or NULL if no intersection. */
100
101Datum
103{
106 int i,
107 j;
108 LSEG seg1,
109 seg2;
110 bool found; /* We've found the intersection */
111
112 found = false; /* Haven't found it yet */
113
114 for (i = 0; i < p1->npts - 1 && !found; i++)
115 {
116 regress_lseg_construct(&seg1, &p1->p[i], &p1->p[i + 1]);
117 for (j = 0; j < p2->npts - 1 && !found; j++)
118 {
119 regress_lseg_construct(&seg2, &p2->p[j], &p2->p[j + 1]);
123 found = true;
124 }
125 }
126
127 if (!found)
129
130 /*
131 * Note: DirectFunctionCall2 will kick out an error if lseg_interpt()
132 * returns NULL, but that should be impossible since we know the two
133 * segments intersect.
134 */
138}
139
140
141/* like lseg_construct, but assume space already allocated */
142static void
144{
145 lseg->p[0].x = pt1->x;
146 lseg->p[0].y = pt1->y;
147 lseg->p[1].x = pt2->x;
148 lseg->p[1].y = pt2->y;
149}
150
152
153Datum
155{
157 bool isnull;
159
160 salary = DatumGetInt32(GetAttributeByName(tuple, "salary", &isnull));
161 if (isnull)
163 PG_RETURN_BOOL(salary > 699);
164}
165
166/*
167 * New type "widget"
168 * This used to be "circle", but I added circle to builtins,
169 * so needed to make sure the names do not collide. - tgl 97/04/21
170 */
171
172typedef struct
173{
175 double radius;
176} WIDGET;
177
180
181#define NARGS 3
182
183Datum
185{
186 char *str = PG_GETARG_CSTRING(0);
187 char *p,
188 *coord[NARGS];
189 int i;
190 WIDGET *result;
191
192 for (i = 0, p = str; *p && i < NARGS && *p != RDELIM; p++)
193 {
194 if (*p == DELIM || (*p == LDELIM && i == 0))
195 coord[i++] = p + 1;
196 }
197
198 /*
199 * Note: DON'T convert this error to "soft" style (errsave/ereturn). We
200 * want this data type to stay permanently in the hard-error world so that
201 * it can be used for testing that such cases still work reasonably.
202 */
203 if (i < NARGS)
206 errmsg("invalid input syntax for type %s: \"%s\"",
207 "widget", str)));
208
210 result->center.x = atof(coord[0]);
211 result->center.y = atof(coord[1]);
212 result->radius = atof(coord[2]);
213
215}
216
217Datum
219{
221 char *str = psprintf("(%g,%g,%g)",
222 widget->center.x, widget->center.y, widget->radius);
223
225}
226
228
229Datum
242
244
245Datum
247{
248 char *string = PG_GETARG_CSTRING(0);
249 int i;
250 int len;
251 char *new_string;
252
254 for (i = 0; i < NAMEDATALEN && string[i]; ++i)
255 ;
256 if (i == NAMEDATALEN || !string[i])
257 --i;
258 len = i;
259 for (; i >= 0; --i)
260 new_string[len - i] = string[i];
262}
263
265
266Datum
268{
269 TriggerData *trigdata = (TriggerData *) fcinfo->context;
270 HeapTuple tuple;
271
272 if (!CALLED_AS_TRIGGER(fcinfo))
273 elog(ERROR, "trigger_return_old: not fired by trigger manager");
274
275 tuple = trigdata->tg_trigtuple;
276
277 return PointerGetDatum(tuple);
278}
279
280
281/*
282 * Type int44 has no real-world use, but the regression tests use it
283 * (under the alias "city_budget"). It's a four-element vector of int4's.
284 */
285
286/*
287 * int44in - converts "num, num, ..." to internal form
288 *
289 * Note: Fills any missing positions with zeroes.
290 */
292
293Datum
295{
297 int32 *result = (int32 *) palloc(4 * sizeof(int32));
298 int i;
299
301 "%d, %d, %d, %d",
302 &result[0],
303 &result[1],
304 &result[2],
305 &result[3]);
306 while (i < 4)
307 result[i++] = 0;
308
310}
311
312/*
313 * int44out - converts internal form to "num, num, ..."
314 */
316
317Datum
319{
321 char *result = (char *) palloc(16 * 4);
322
323 snprintf(result, 16 * 4, "%d,%d,%d,%d",
324 an_array[0],
325 an_array[1],
326 an_array[2],
327 an_array[3]);
328
330}
331
333Datum
341
343Datum
345{
347 HeapTupleData tuple;
348 int ncolumns;
349 Datum *values;
350 bool *nulls;
351
352 Oid tupType;
354 TupleDesc tupdesc;
355
357
358 int i;
359
361
362 /* Extract type info from the tuple itself */
366 ncolumns = tupdesc->natts;
367
368 /* Build a temporary HeapTuple control structure */
371 tuple.t_tableOid = InvalidOid;
372 tuple.t_data = rec;
373
374 values = (Datum *) palloc(ncolumns * sizeof(Datum));
375 nulls = (bool *) palloc(ncolumns * sizeof(bool));
376
377 heap_deform_tuple(&tuple, tupdesc, values, nulls);
378
380
381 for (i = 0; i < ncolumns; i++)
382 {
383 varlena *attr;
386
387 /* only work on existing, not-null varlenas */
388 if (TupleDescAttr(tupdesc, i)->attisdropped ||
389 nulls[i] ||
390 TupleDescAttr(tupdesc, i)->attlen != -1 ||
392 continue;
393
394 attr = (varlena *) DatumGetPointer(values[i]);
395
396 /* don't recursively indirect */
398 continue;
399
400 /* copy datum, so it still lives later */
402 attr = detoast_external_attr(attr);
403 else
404 {
405 varlena *oldattr = attr;
406
407 attr = palloc0(VARSIZE_ANY(oldattr));
409 }
410
411 /* build indirection Datum */
413 redirect_pointer.pointer = attr;
416 sizeof(redirect_pointer));
417
419 }
420
421 newtup = heap_form_tuple(tupdesc, values, nulls);
422 pfree(values);
423 pfree(nulls);
424 ReleaseTupleDesc(tupdesc);
425
427
428 /*
429 * We intentionally don't use PG_RETURN_HEAPTUPLEHEADER here, because that
430 * would cause the indirect toast pointers to be flattened out of the
431 * tuple immediately, rendering subsequent testing irrelevant. So just
432 * return the HeapTupleHeader pointer as-is. This violates the general
433 * rule that composite Datums shouldn't contain toast pointers, but so
434 * long as the regression test scripts don't insert the result of this
435 * function into a container type (record, array, etc) it should be OK.
436 */
437 PG_RETURN_POINTER(newtup->t_data);
438}
439
441
442Datum
444{
445#if !defined(WIN32)
446 extern char **environ;
447#endif
448 int nvals = 0;
450 Datum *env;
451
452 for (char **s = environ; *s; s++)
453 nvals++;
454
455 env = palloc(nvals * sizeof(Datum));
456
457 for (int i = 0; i < nvals; i++)
459
461
463}
464
466
467Datum
469{
470 char *envvar = text_to_cstring(PG_GETARG_TEXT_PP(0));
472
473 if (!superuser())
474 elog(ERROR, "must be superuser to change environment variables");
475
476 if (setenv(envvar, envval, 1) != 0)
477 elog(ERROR, "could not set environment variable: %m");
478
480}
481
482/* Sleep until no process has a given PID. */
484
485Datum
487{
488 int pid = PG_GETARG_INT32(0);
489
490 if (!superuser())
491 elog(ERROR, "must be superuser to check PID liveness");
492
493 while (kill(pid, 0) == 0)
494 {
496 pg_usleep(50000);
497 }
498
499 if (errno != ESRCH)
500 elog(ERROR, "could not check PID %d liveness: %m", pid);
501
503}
504
505static void
520
521static void
523{
526 int i;
527
528 pg_atomic_init_u32(&var, 0);
530 pg_atomic_write_u32(&var, 3);
533 3);
539
540 /* test around numerical limits */
543 pg_atomic_fetch_add_u32(&var, 2); /* wrap to 0 */
548 2 * PG_INT16_MAX + 1);
551 pg_atomic_fetch_add_u32(&var, 1); /* top up to UINT_MAX */
565
566 /* fail exchange because of old expected */
567 expected = 10;
569
570 /* CAS is allowed to fail due to interrupts, try a couple of times */
571 for (i = 0; i < 1000; i++)
572 {
573 expected = 0;
575 break;
576 }
577 if (i == 1000)
578 elog(ERROR, "atomic_compare_exchange_u32() never succeeded");
580 pg_atomic_write_u32(&var, 0);
581
582 /* try setting flagbits */
583 EXPECT_TRUE(!(pg_atomic_fetch_or_u32(&var, 1) & 1));
586 /* try clearing flagbits */
587 EXPECT_EQ_U32(pg_atomic_fetch_and_u32(&var, ~2) & 3, 3);
589 /* no bits set anymore */
591}
592
593static void
595{
598 int i;
599
600 pg_atomic_init_u64(&var, 0);
602 pg_atomic_write_u64(&var, 3);
605 3);
611
612 /* fail exchange because of old expected */
613 expected = 10;
615
616 /* CAS is allowed to fail due to interrupts, try a couple of times */
617 for (i = 0; i < 100; i++)
618 {
619 expected = 0;
621 break;
622 }
623 if (i == 100)
624 elog(ERROR, "atomic_compare_exchange_u64() never succeeded");
626
627 pg_atomic_write_u64(&var, 0);
628
629 /* try setting flagbits */
630 EXPECT_TRUE(!(pg_atomic_fetch_or_u64(&var, 1) & 1));
633 /* try clearing flagbits */
634 EXPECT_EQ_U64((pg_atomic_fetch_and_u64(&var, ~2) & 3), 3);
636 /* no bits set anymore */
638}
639
640/*
641 * Perform, fairly minimal, testing of the spinlock implementation.
642 *
643 * It's likely worth expanding these to actually test concurrency etc, but
644 * having some regularly run tests is better than none.
645 */
646static void
648{
649 /*
650 * Basic tests for spinlocks, as well as the underlying operations.
651 *
652 * We embed the spinlock in a struct with other members to test that the
653 * spinlock operations don't perform too wide writes.
654 */
655 {
656 struct test_lock_struct
657 {
658 char data_before[4];
659 slock_t lock;
660 char data_after[4];
662
663 memcpy(struct_w_lock.data_before, "abcd", 4);
664 memcpy(struct_w_lock.data_after, "ef12", 4);
665
666 /* test basic operations via the SpinLock* API */
670
671 /* test basic operations via underlying S_* API */
673 S_LOCK(&struct_w_lock.lock);
674 S_UNLOCK(&struct_w_lock.lock);
675
676 /* and that "contended" acquisition works */
677 s_lock(&struct_w_lock.lock, "testfile", 17, "testfunc");
678 S_UNLOCK(&struct_w_lock.lock);
679
680 /*
681 * Check, using TAS directly, that a single spin cycle doesn't block
682 * when acquiring an already acquired lock.
683 */
684#ifdef TAS
685 S_LOCK(&struct_w_lock.lock);
686
687 if (!TAS(&struct_w_lock.lock))
688 elog(ERROR, "acquired already held spinlock");
689
690#ifdef TAS_SPIN
691 if (!TAS_SPIN(&struct_w_lock.lock))
692 elog(ERROR, "acquired already held spinlock");
693#endif /* defined(TAS_SPIN) */
694
695 S_UNLOCK(&struct_w_lock.lock);
696#endif /* defined(TAS) */
697
698 /*
699 * Verify that after all of this the non-lock contents are still
700 * correct.
701 */
702 if (memcmp(struct_w_lock.data_before, "abcd", 4) != 0)
703 elog(ERROR, "padding before spinlock modified");
704 if (memcmp(struct_w_lock.data_after, "ef12", 4) != 0)
705 elog(ERROR, "padding after spinlock modified");
706 }
707}
708
710Datum
712{
714
716
718
719 /*
720 * Arguably this shouldn't be tested as part of this function, but it's
721 * closely enough related that that seems ok for now.
722 */
724
725 PG_RETURN_BOOL(true);
726}
727
729Datum
731{
732 elog(ERROR, "test_fdw_handler is not implemented");
734}
735
737Datum
739{
740 /* Ensure the test fails if no valid user mapping exists. */
742 PG_RETURN_TEXT_P(cstring_to_text("dbname=regress_doesnotexist user=doesnotexist password=secret"));
743}
744
746Datum
748{
749 /* Ensure the test fails if no valid user mapping exists. */
751 PG_RETURN_TEXT_P(cstring_to_text("dbname=regress_doesnotexist user=doesnotexist"));
752}
753
755Datum
760
762Datum
764{
766 Node *ret = NULL;
767
769 {
770 /*
771 * Assume that the target is int4eq; that's safe as long as we don't
772 * attach this to any other boolean-returning function.
773 */
776
777 if (req->is_join)
779 req->args,
780 req->inputcollid,
781 req->jointype,
782 req->sjinfo);
783 else
785 req->args,
786 req->inputcollid,
787 req->varRelid);
788
789 req->selectivity = s1;
790 ret = (Node *) req;
791 }
792
794 {
795 /* Provide some generic estimate */
797
798 req->startup = 0;
799 req->per_tuple = 2 * cpu_operator_cost;
800 ret = (Node *) req;
801 }
802
804 {
805 /*
806 * Assume that the target is generate_series_int4; that's safe as long
807 * as we don't attach this to any other set-returning function.
808 */
810
811 if (req->node && IsA(req->node, FuncExpr)) /* be paranoid */
812 {
813 List *args = ((FuncExpr *) req->node)->args;
814 Node *arg1 = linitial(args);
815 Node *arg2 = lsecond(args);
816
817 if (IsA(arg1, Const) &&
818 !((Const *) arg1)->constisnull &&
819 IsA(arg2, Const) &&
820 !((Const *) arg2)->constisnull)
821 {
824
825 req->rows = val2 - val1 + 1;
826 ret = (Node *) req;
827 }
828 }
829 }
830
832}
833
835Datum
837{
839
841 {
842 /*
843 * Assume that the target is foo_from_bar; that's safe as long as we
844 * don't attach this to any other function.
845 */
847 StringInfoData sql;
848 RangeTblFunction *rtfunc = req->rtfunc;
849 FuncExpr *expr = (FuncExpr *) rtfunc->funcexpr;
850 Node *node;
851 Const *c;
852 char *colname;
853 char *tablename;
858
859 if (list_length(expr->args) != 3)
860 {
861 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with %d args but expected 3", list_length(expr->args))));
863 }
864
865 /* Get colname */
866 node = linitial(expr->args);
867 if (!IsA(node, Const))
868 {
869 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with non-Const parameters")));
871 }
872
873 c = (Const *) node;
874 if (c->consttype != TEXTOID || c->constisnull)
875 {
876 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with non-TEXT parameters")));
878 }
879 colname = TextDatumGetCString(c->constvalue);
880
881 /* Get tablename */
882 node = lsecond(expr->args);
883 if (!IsA(node, Const))
884 {
885 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with non-Const parameters")));
887 }
888
889 c = (Const *) node;
890 if (c->consttype != TEXTOID || c->constisnull)
891 {
892 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with non-TEXT parameters")));
894 }
895 tablename = TextDatumGetCString(c->constvalue);
896
897 /* Begin constructing replacement SELECT query. */
898 initStringInfo(&sql);
899 appendStringInfo(&sql, "SELECT %s::text FROM %s",
900 quote_identifier(colname),
901 quote_identifier(tablename));
902
903 /* Add filter expression if present. */
904 node = lthird(expr->args);
905 if (!(IsA(node, Const) && ((Const *) node)->constisnull))
906 {
907 /*
908 * We only filter if $3 is not constant-NULL. This is not a very
909 * exact implementation of the PL/pgSQL original, but it's close
910 * enough for demonstration purposes.
911 */
912 appendStringInfo(&sql, " WHERE %s::text = $3",
913 quote_identifier(colname));
914 }
915
916 /* Build a SQLFunctionParseInfo with the parameters of my function. */
917 pinfo = prepare_sql_fn_parse_info(req->proc,
918 (Node *) expr,
919 expr->inputcollid);
920
921 /* Parse the generated SQL. */
924 {
925 ereport(WARNING, (errmsg("test_inline_in_from_support_func parsed to more than one node")));
927 }
928
929 /* Analyze the parse tree as if it were a SQL-language body. */
931 sql.data,
933 pinfo, NULL);
934 if (list_length(querytree_list) != 1)
935 {
936 ereport(WARNING, (errmsg("test_inline_in_from_support_func rewrote to more than one node")));
938 }
939
941 if (!IsA(querytree, Query))
942 {
943 ereport(WARNING, (errmsg("test_inline_in_from_support_func didn't parse to a Query")));
945 }
946
948 }
949
951}
952
954Datum
959
960/* one-time tests for encoding infrastructure */
962Datum
964{
965 /* Test pg_encoding_set_invalid() */
966 for (int i = 0; i < _PG_LAST_ENCODING_; i++)
967 {
968 char buf[2],
969 bigbuf[16];
970 int len,
971 mblen,
972 valid;
973
974 if (!PG_VALID_ENCODING(i))
975 continue;
976 if (pg_encoding_max_length(i) == 1)
977 continue;
979 len = strnlen(buf, 2);
980 if (len != 2)
982 "official invalid string for encoding \"%s\" has length %d",
984 mblen = pg_encoding_mblen(i, buf);
985 if (mblen != 2)
987 "official invalid string for encoding \"%s\" has mblen %d",
988 pg_enc2name_tbl[i].name, mblen);
989 valid = pg_encoding_verifymbstr(i, buf, len);
990 if (valid != 0)
992 "official invalid string for encoding \"%s\" has valid prefix of length %d",
993 pg_enc2name_tbl[i].name, valid);
994 valid = pg_encoding_verifymbstr(i, buf, 1);
995 if (valid != 0)
997 "first byte of official invalid string for encoding \"%s\" has valid prefix of length %d",
998 pg_enc2name_tbl[i].name, valid);
999 memset(bigbuf, ' ', sizeof(bigbuf));
1000 bigbuf[0] = buf[0];
1001 bigbuf[1] = buf[1];
1002 valid = pg_encoding_verifymbstr(i, bigbuf, sizeof(bigbuf));
1003 if (valid != 0)
1004 elog(WARNING,
1005 "trailing data changed official invalid string for encoding \"%s\" to have valid prefix of length %d",
1006 pg_enc2name_tbl[i].name, valid);
1007 }
1008
1010}
1011
1012/*
1013 * Call an encoding conversion or verification function.
1014 *
1015 * Arguments:
1016 * string bytea -- string to convert
1017 * src_enc name -- source encoding
1018 * dest_enc name -- destination encoding
1019 * noError bool -- if set, don't ereport() on invalid or untranslatable
1020 * input
1021 *
1022 * Result is a tuple with two attributes:
1023 * int4 -- number of input bytes successfully converted
1024 * bytea -- converted string
1025 */
1027Datum
1029{
1030 bytea *string = PG_GETARG_BYTEA_PP(0);
1035 bool noError = PG_GETARG_BOOL(3);
1036 TupleDesc tupdesc;
1037 char *src;
1038 char *dst;
1039 bytea *retval;
1040 Size srclen;
1041 Size dstsize;
1042 Oid proc;
1043 int convertedbytes;
1044 int dstlen;
1045 Datum values[2];
1046 bool nulls[2] = {0};
1047 HeapTuple tuple;
1048
1049 if (src_encoding < 0)
1050 ereport(ERROR,
1052 errmsg("invalid source encoding name \"%s\"",
1054 if (dest_encoding < 0)
1055 ereport(ERROR,
1057 errmsg("invalid destination encoding name \"%s\"",
1059
1060 /* Build a tuple descriptor for our result type */
1061 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
1062 elog(ERROR, "return type must be a row type");
1063 tupdesc = BlessTupleDesc(tupdesc);
1064
1065 srclen = VARSIZE_ANY_EXHDR(string);
1066 src = VARDATA_ANY(string);
1067
1069 {
1070 /* just check that the source string is valid */
1071 int oklen;
1072
1074
1075 if (oklen == srclen)
1076 {
1078 retval = string;
1079 }
1080 else if (!noError)
1081 {
1083 }
1084 else
1085 {
1086 /*
1087 * build bytea data type structure.
1088 */
1089 Assert(oklen < srclen);
1091 retval = (bytea *) palloc(oklen + VARHDRSZ);
1092 SET_VARSIZE(retval, oklen + VARHDRSZ);
1093 memcpy(VARDATA(retval), src, oklen);
1094 }
1095 }
1096 else
1097 {
1099 if (!OidIsValid(proc))
1100 ereport(ERROR,
1102 errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
1105
1107 ereport(ERROR,
1109 errmsg("out of memory"),
1110 errdetail("String of %d bytes is too long for encoding conversion.",
1111 (int) srclen)));
1112
1115
1116 /* perform conversion */
1120 (unsigned char *) src, srclen,
1121 (unsigned char *) dst, dstsize,
1122 noError);
1123 dstlen = strlen(dst);
1124
1125 /*
1126 * build bytea data type structure.
1127 */
1128 retval = (bytea *) palloc(dstlen + VARHDRSZ);
1129 SET_VARSIZE(retval, dstlen + VARHDRSZ);
1130 memcpy(VARDATA(retval), dst, dstlen);
1131
1132 pfree(dst);
1133 }
1134
1136 values[1] = PointerGetDatum(retval);
1137 tuple = heap_form_tuple(tupdesc, values, nulls);
1138
1140}
1141
1142/* Convert bytea to text without validation for corruption tests from SQL. */
1144Datum
1149
1150/* And the reverse. */
1152Datum
1157
1158/* Corruption tests in C. */
1160Datum
1162{
1163 const char *func = text_to_cstring(PG_GETARG_BYTEA_PP(0));
1165 text *string = PG_GETARG_BYTEA_PP(2);
1166 int offset = PG_GETARG_INT32(3);
1167 const char *data = VARDATA_ANY(string);
1168 size_t size = VARSIZE_ANY_EXHDR(string);
1169 int result = 0;
1170
1171 if (strcmp(func, "pg_mblen_unbounded") == 0)
1172 result = pg_mblen_unbounded(data + offset);
1173 else if (strcmp(func, "pg_mblen_cstr") == 0)
1174 result = pg_mblen_cstr(data + offset);
1175 else if (strcmp(func, "pg_mblen_with_len") == 0)
1176 result = pg_mblen_with_len(data + offset, size - offset);
1177 else if (strcmp(func, "pg_mblen_range") == 0)
1178 result = pg_mblen_range(data + offset, data + size);
1179 else if (strcmp(func, "pg_encoding_mblen") == 0)
1181 else
1182 elog(ERROR, "unknown function");
1183
1185}
1186
1188Datum
1190{
1192 text *string = PG_GETARG_TEXT_PP(1);
1193 const char *data = VARDATA_ANY(string);
1194 size_t size = VARSIZE_ANY_EXHDR(string);
1195 pg_wchar *wchars = palloc(sizeof(pg_wchar) * (size + 1));
1196 Datum *datums;
1197 int wlen;
1198 int encoding;
1199
1201 if (encoding < 0)
1202 elog(ERROR, "unknown encoding name: %s", encoding_name);
1203
1204 if (size > 0)
1205 {
1206 datums = palloc(sizeof(Datum) * size);
1208 data,
1209 wchars,
1210 size);
1211 Assert(wlen >= 0);
1212 Assert(wlen <= size);
1213 Assert(wchars[wlen] == 0);
1214
1215 for (int i = 0; i < wlen; ++i)
1216 datums[i] = UInt32GetDatum(wchars[i]);
1217 }
1218 else
1219 {
1220 datums = NULL;
1221 wlen = 0;
1222 }
1223
1225}
1226
1228Datum
1230{
1232 ArrayType *array = PG_GETARG_ARRAYTYPE_P(1);
1233 Datum *datums;
1234 bool *nulls;
1235 char *mb;
1236 text *result;
1237 int wlen;
1238 int bytes;
1239 int encoding;
1240
1242 if (encoding < 0)
1243 elog(ERROR, "unknown encoding name: %s", encoding_name);
1244
1245 deconstruct_array_builtin(array, INT4OID, &datums, &nulls, &wlen);
1246
1247 if (wlen > 0)
1248 {
1249 pg_wchar *wchars = palloc(sizeof(pg_wchar) * wlen);
1250
1251 for (int i = 0; i < wlen; ++i)
1252 {
1253 if (nulls[i])
1254 elog(ERROR, "unexpected NULL in array");
1255 wchars[i] = DatumGetInt32(datums[i]);
1256 }
1257
1260 }
1261 else
1262 {
1263 mb = "";
1264 bytes = 0;
1265 }
1266
1267 result = palloc(bytes + VARHDRSZ);
1268 SET_VARSIZE(result, bytes + VARHDRSZ);
1269 memcpy(VARDATA(result), mb, bytes);
1270
1272}
1273
1275Datum
1280
1281/* Provide SQL access to IsBinaryCoercible() */
1283Datum
1285{
1286 Oid srctype = PG_GETARG_OID(0);
1287 Oid targettype = PG_GETARG_OID(1);
1288
1289 PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
1290}
1291
1292/*
1293 * Sanity checks for functions in relpath.h
1294 */
1296Datum
1298{
1299 RelPathStr rpath;
1300
1301 /*
1302 * Verify that PROCNUMBER_CHARS and MAX_BACKENDS stay in sync.
1303 * Unfortunately I don't know how to express that in a way suitable for a
1304 * static assert.
1305 */
1306 if ((int) ceil(log10(MAX_BACKENDS)) != PROCNUMBER_CHARS)
1307 elog(WARNING, "mismatch between MAX_BACKENDS and PROCNUMBER_CHARS");
1308
1309 /* verify that the max-length relpath is generated ok */
1311 INIT_FORKNUM);
1312
1313 if (strlen(rpath.str) != REL_PATH_STR_MAXLEN)
1314 elog(WARNING, "maximum length relpath is if length %zu instead of %zu",
1316
1318}
1319
1320/*
1321 * Simple test to verify NLS support, particularly that the PRI* macros work.
1322 *
1323 * A secondary objective is to verify that <inttypes.h>'s values for the
1324 * PRI* macros match what our snprintf.c code will do. Therefore, we run
1325 * the ereport() calls even when we know that translation will not happen.
1326 */
1328Datum
1330{
1331#ifdef ENABLE_NLS
1332 static bool inited = false;
1333
1334 /*
1335 * Ideally we'd do this bit in a _PG_init() hook. However, it seems best
1336 * that the Solaris hack only get applied in the nls.sql test, so it
1337 * doesn't risk affecting other tests that load this module.
1338 */
1339 if (!inited)
1340 {
1341 /*
1342 * Solaris' built-in gettext is not bright about associating locales
1343 * with message catalogs that are named after just the language.
1344 * Apparently the customary workaround is for users to set the
1345 * LANGUAGE environment variable to provide a mapping. Do so here to
1346 * ensure that the nls.sql regression test will work.
1347 *
1348 * With glibc and perhaps other implementations, LANGUAGE overrides
1349 * LC_MESSAGES, which we don't want either; so let's unset it if we're
1350 * not on Solaris.
1351 */
1352#if defined(__sun__)
1353 setenv("LANGUAGE", "es_ES.UTF-8:es", 1);
1354#else
1355 unsetenv("LANGUAGE");
1356#endif
1358 inited = true;
1359 }
1360
1361 /*
1362 * If nls.sql failed to select a non-C locale, no translation will happen.
1363 * Report that so that we can distinguish this outcome from brokenness.
1364 * (We do this here, not in nls.sql, so as to need only 3 expected files.)
1365 */
1366 if (strcmp(GetConfigOption("lc_messages", false, false), "C") == 0)
1367 elog(NOTICE, "lc_messages is 'C'");
1368#else
1369 elog(NOTICE, "NLS is not enabled");
1370#endif
1371
1373 errmsg("translated PRId64 = %" PRId64, (int64) 424242424242));
1375 errmsg("translated PRId32 = %" PRId32, (int32) -1234));
1377 errmsg("translated PRIdMAX = %" PRIdMAX, (intmax_t) -123456789012));
1379 errmsg("translated PRIdPTR = %" PRIdPTR, (intptr_t) -9999));
1380
1382 errmsg("translated PRIu64 = %" PRIu64, (uint64) 424242424242));
1384 errmsg("translated PRIu32 = %" PRIu32, (uint32) -1234));
1386 errmsg("translated PRIuMAX = %" PRIuMAX, (uintmax_t) 123456789012));
1388 errmsg("translated PRIuPTR = %" PRIuPTR, (uintptr_t) 9999));
1389
1391 errmsg("translated PRIx64 = %" PRIx64, (uint64) 424242424242));
1393 errmsg("translated PRIx32 = %" PRIx32, (uint32) -1234));
1395 errmsg("translated PRIxMAX = %" PRIxMAX, (uintmax_t) 123456789012));
1397 errmsg("translated PRIxPTR = %" PRIxPTR, (uintptr_t) 9999));
1398
1400 errmsg("translated PRIX64 = %" PRIX64, (uint64) 424242424242));
1402 errmsg("translated PRIX32 = %" PRIX32, (uint32) -1234));
1404 errmsg("translated PRIXMAX = %" PRIXMAX, (uintmax_t) 123456789012));
1406 errmsg("translated PRIXPTR = %" PRIXPTR, (uintptr_t) 9999));
1407
1409}
1410
1411/* Verify that pg_ticks_to_ns behaves correct, including overflow */
1413Datum
1415{
1416 instr_time t;
1417 int64 test_ns[] = {0, 1000, INT64CONST(1000000000000000)};
1418 int64 max_err;
1419
1420 /*
1421 * The ns-to-ticks-to-ns roundtrip may lose precision due to integer
1422 * truncation in the fixed-point conversion. The maximum error depends on
1423 * ticks_per_ns_scaled relative to the shift factor.
1424 */
1426
1427 for (size_t i = 0; i < lengthof(test_ns); i++)
1428 {
1429 int64 result;
1430
1434
1435 if (result < test_ns[i] - max_err || result > test_ns[i])
1436 elog(ERROR,
1437 "INSTR_TIME_GET_NANOSEC(t) yielded " INT64_FORMAT
1438 ", expected " INT64_FORMAT " (max_err " INT64_FORMAT
1439 ") in file \"%s\" line %u",
1441 }
1442
1443 PG_RETURN_BOOL(true);
1444}
1445
1446/*
1447 * test_pglz_compress
1448 *
1449 * Compress the input using pglz_compress(). Only the "always" strategy is
1450 * currently supported.
1451 *
1452 * Returns the compressed data, or NULL if compression fails.
1453 */
1455Datum
1474
1475/*
1476 * test_pglz_decompress
1477 *
1478 * Decompress the input using pglz_decompress().
1479 *
1480 * The second argument is the expected uncompressed data size. The third
1481 * argument is here for the check_complete flag.
1482 *
1483 * Returns the decompressed data, or raises an error if decompression fails.
1484 */
1486Datum
1488{
1492 char *source = VARDATA_ANY(input);
1494 bytea *result;
1495 int32 dlen;
1496
1497 if (rawsize < 0)
1498 elog(ERROR, "rawsize must not be negative");
1499
1501
1504 if (dlen < 0)
1505 elog(ERROR, "pglz_decompress failed");
1506
1509}
Datum querytree(PG_FUNCTION_ARGS)
Definition _int_bool.c:711
#define PG_GETARG_ARRAYTYPE_P(n)
Definition array.h:263
#define PG_RETURN_ARRAYTYPE_P(x)
Definition array.h:265
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
static uint32 pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_)
Definition atomics.h:391
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
Definition atomics.h:344
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition atomics.h:480
static void pg_atomic_clear_flag(volatile pg_atomic_flag *ptr)
Definition atomics.h:200
static uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
Definition atomics.h:405
static uint32 pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition atomics.h:434
static uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition atomics.h:376
static bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
Definition atomics.h:517
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition atomics.h:214
static uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition atomics.h:361
static uint32 pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition atomics.h:419
static uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition atomics.h:527
static bool pg_atomic_test_set_flag(volatile pg_atomic_flag *ptr)
Definition atomics.h:176
static uint64 pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition atomics.h:573
static bool pg_atomic_unlocked_test_flag(volatile pg_atomic_flag *ptr)
Definition atomics.h:189
static void pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition atomics.h:269
static uint64 pg_atomic_fetch_and_u64(volatile pg_atomic_uint64 *ptr, uint64 and_)
Definition atomics.h:546
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
Definition atomics.h:232
static uint64 pg_atomic_fetch_or_u64(volatile pg_atomic_uint64 *ptr, uint64 or_)
Definition atomics.h:555
static uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition atomics.h:564
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
Definition atomics.h:325
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition atomics.h:448
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
Definition atomics.h:462
static uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition atomics.h:536
static uint64 pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval)
Definition atomics.h:508
static void pg_atomic_init_flag(volatile pg_atomic_flag *ptr)
Definition atomics.h:163
static Datum values[MAXATTR]
Definition bootstrap.c:190
#define CStringGetTextDatum(s)
Definition builtins.h:98
#define TextDatumGetCString(d)
Definition builtins.h:99
#define NameStr(name)
Definition c.h:894
#define INT64CONST(x)
Definition c.h:689
#define INT64_FORMAT
Definition c.h:693
#define VARHDRSZ
Definition c.h:840
#define Assert(condition)
Definition c.h:1002
int64_t int64
Definition c.h:680
double float8
Definition c.h:773
#define PG_INT16_MIN
Definition c.h:728
int32_t int32
Definition c.h:679
uint64_t uint64
Definition c.h:684
uint32_t uint32
Definition c.h:683
#define lengthof(array)
Definition c.h:932
#define PG_INT16_MAX
Definition c.h:729
#define OidIsValid(objectId)
Definition c.h:917
size_t Size
Definition c.h:748
bool IsCatalogTextUniqueIndexOid(Oid relid)
Definition catalog.c:158
uint32 result
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
double cpu_operator_cost
Definition costsize.c:135
varlena * detoast_external_attr(varlena *attr)
Definition detoast.c:45
#define INDIRECT_POINTER_SIZE
Definition detoast.h:34
int errcode(int sqlerrcode)
Definition elog.c:875
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define WARNING
Definition elog.h:37
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
#define NOTICE
Definition elog.h:36
#define ereport(elevel,...)
Definition elog.h:152
const pg_enc2name pg_enc2name_tbl[]
Definition encnames.c:308
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
Definition execUtils.c:1087
#define palloc_object(type)
Definition fe_memutils.h:89
#define MaxAllocSize
Definition fe_memutils.h:22
#define PG_RETURN_VOID()
Definition fmgr.h:350
#define PG_GETARG_OID(n)
Definition fmgr.h:275
#define PG_GETARG_BYTEA_PP(n)
Definition fmgr.h:309
#define PG_GETARG_TEXT_PP(n)
Definition fmgr.h:310
#define PG_RETURN_BYTEA_P(x)
Definition fmgr.h:373
#define DirectFunctionCall2(func, arg1, arg2)
Definition fmgr.h:690
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
#define PG_MODULE_MAGIC_EXT(...)
Definition fmgr.h:540
#define PG_RETURN_CSTRING(x)
Definition fmgr.h:364
#define PG_GETARG_CSTRING(n)
Definition fmgr.h:278
#define PG_RETURN_NULL()
Definition fmgr.h:346
#define PG_FUNCTION_INFO_V1(funcname)
Definition fmgr.h:417
#define PG_GETARG_NAME(n)
Definition fmgr.h:279
#define PG_GETARG_HEAPTUPLEHEADER(n)
Definition fmgr.h:313
#define PG_RETURN_TEXT_P(x)
Definition fmgr.h:374
#define PG_RETURN_INT32(x)
Definition fmgr.h:355
#define PG_GETARG_INT32(n)
Definition fmgr.h:269
#define PG_GETARG_BOOL(n)
Definition fmgr.h:274
#define PG_RETURN_DATUM(x)
Definition fmgr.h:354
#define PG_RETURN_POINTER(x)
Definition fmgr.h:363
#define PG_FUNCTION_ARGS
Definition fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
UserMapping * GetUserMapping(Oid userid, Oid serverid)
Definition foreign.c:232
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
void sql_fn_parser_setup(struct ParseState *pstate, SQLFunctionParseInfoPtr pinfo)
Definition functions.c:341
SQLFunctionParseInfoPtr prepare_sql_fn_parse_info(HeapTuple procedureTuple, Node *call_expr, Oid inputCollation)
Definition functions.c:252
#define PG_GETARG_POINT_P(n)
Definition geo_decls.h:184
static Datum LsegPGetDatum(const LSEG *X)
Definition geo_decls.h:193
static Datum PointPGetDatum(const Point *X)
Definition geo_decls.h:180
#define PG_GETARG_PATH_P(n)
Definition geo_decls.h:215
Datum point_distance(PG_FUNCTION_ARGS)
Definition geo_ops.c:2044
Datum lseg_intersect(PG_FUNCTION_ARGS)
Definition geo_ops.c:2251
Datum lseg_interpt(PG_FUNCTION_ARGS)
Definition geo_ops.c:2443
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
Definition guc.c:4257
const char * str
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1025
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition heaptuple.c:1254
static int32 HeapTupleHeaderGetTypMod(const HeapTupleHeaderData *tup)
static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)
static Oid HeapTupleHeaderGetTypeId(const HeapTupleHeaderData *tup)
FILE * input
static char * encoding
Definition initdb.c:139
uint64 ticks_per_ns_scaled
Definition instr_time.c:61
#define TICKS_TO_NS_SHIFT
Definition instr_time.h:89
#define INSTR_TIME_GET_NANOSEC(t)
Definition instr_time.h:453
#define INSTR_TIME_ADD_NANOSEC(t, n)
Definition instr_time.h:441
#define INSTR_TIME_SET_ZERO(t)
Definition instr_time.h:429
int j
Definition isn.c:78
int i
Definition isn.c:77
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Definition itemptr.h:184
unsigned int pg_wchar
Definition mbprint.c:31
int pg_encoding_wchar2mb_with_len(int encoding, const pg_wchar *from, char *to, int len)
Definition mbutils.c:1026
int pg_mblen_cstr(const char *mbstr)
Definition mbutils.c:1045
int pg_mblen_unbounded(const char *mbstr)
Definition mbutils.c:1137
int pg_mblen_range(const char *mbstr, const char *end)
Definition mbutils.c:1084
int pg_mblen_with_len(const char *mbstr, int limit)
Definition mbutils.c:1108
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:478
void report_invalid_encoding(int encoding, const char *mbstr, int len)
Definition mbutils.c:1825
int pg_encoding_mb2wchar_with_len(int encoding, const char *from, pg_wchar *to, int len)
Definition mbutils.c:1004
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1235
MemoryContext TopTransactionContext
Definition mcxt.c:172
void pfree(void *pointer)
Definition mcxt.c:1619
void * palloc0(Size size)
Definition mcxt.c:1420
void * palloc(Size size)
Definition mcxt.c:1390
MemoryContext CurrentMemoryContext
Definition mcxt.c:161
#define CHECK_FOR_INTERRUPTS()
Definition miscadmin.h:125
void pg_bindtextdomain(const char *domain)
Definition miscinit.c:1892
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition namespace.c:4152
#define IsA(nodeptr, _type_)
Definition nodes.h:162
double Selectivity
Definition nodes.h:258
static char * errmsg
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:138
void(* ParserSetupHook)(ParseState *pstate, void *arg)
Definition params.h:107
bool IsBinaryCoercible(Oid srctype, Oid targettype)
char attstorage
int16 attlen
#define NAMEDATALEN
const void size_t len
const void * data
static int list_length(const List *l)
Definition pg_list.h:152
#define lthird(l)
Definition pg_list.h:188
#define linitial(l)
Definition pg_list.h:178
#define lsecond(l)
Definition pg_list.h:183
const PGLZ_Strategy *const PGLZ_strategy_always
int32 pglz_decompress(const char *source, int32 slen, char *dest, int32 rawsize, bool check_complete)
int32 pglz_compress(const char *source, int32 slen, char *dest, const PGLZ_Strategy *strategy)
#define PGLZ_MAX_OUTPUT(_dlen)
static rewind_source * source
Definition pg_rewind.c:89
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define MAX_CONVERSION_GROWTH
Definition pg_wchar.h:155
@ _PG_LAST_ENCODING_
Definition pg_wchar.h:121
#define PG_VALID_ENCODING(_enc)
Definition pg_wchar.h:140
#define pg_encoding_to_char
Definition pg_wchar.h:483
#define pg_valid_server_encoding
Definition pg_wchar.h:484
#define pg_char_to_encoding
Definition pg_wchar.h:482
Selectivity restriction_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, int varRelid)
Definition plancat.c:2225
Selectivity join_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, JoinType jointype, SpecialJoinInfo *sjinfo)
Definition plancat.c:2264
void canonicalize_path(char *path)
Definition path.c:337
#define snprintf
Definition port.h:261
List * pg_analyze_and_rewrite_withcb(RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
Definition postgres.c:776
List * pg_parse_query(const char *query_string)
Definition postgres.c:617
static bool DatumGetBool(Datum X)
Definition postgres.h:100
static Datum BoolGetDatum(bool X)
Definition postgres.h:112
static float8 DatumGetFloat8(Datum X)
Definition postgres.h:498
uint64_t Datum
Definition postgres.h:70
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:332
static Datum Int32GetDatum(int32 X)
Definition postgres.h:212
static Datum UInt32GetDatum(uint32 X)
Definition postgres.h:232
static int32 DatumGetInt32(Datum X)
Definition postgres.h:202
#define PointerGetDatum(X)
Definition postgres.h:354
#define InvalidOid
unsigned int Oid
#define OID_MAX
char * c
static int fb(int x)
char * s1
char string[11]
#define MAX_BACKENDS
Definition procnumber.h:39
char ** environ
char * psprintf(const char *fmt,...)
Definition psprintf.c:43
static void test_spinlock(void)
Definition regress.c:647
Datum test_inline_in_from_support_func(PG_FUNCTION_ARGS)
Definition regress.c:836
#define DELIM
Definition regress.c:88
Datum test_fdw_connection_no_password(PG_FUNCTION_ARGS)
Definition regress.c:747
#define EXPECT_TRUE(expr)
Definition regress.c:58
Datum regress_setenv(PG_FUNCTION_ARGS)
Definition regress.c:468
static void test_atomic_uint32(void)
Definition regress.c:522
Datum test_relpath(PG_FUNCTION_ARGS)
Definition regress.c:1297
Datum test_text_to_wchars(PG_FUNCTION_ARGS)
Definition regress.c:1189
#define EXPECT_EQ_U32(result_expr, expected_expr)
Definition regress.c:66
Datum test_atomic_ops(PG_FUNCTION_ARGS)
Definition regress.c:711
Datum test_wchars_to_text(PG_FUNCTION_ARGS)
Definition regress.c:1229
Datum test_support_func(PG_FUNCTION_ARGS)
Definition regress.c:763
Datum test_bytea_to_text(PG_FUNCTION_ARGS)
Definition regress.c:1145
Datum int44out(PG_FUNCTION_ARGS)
Definition regress.c:318
Datum test_opclass_options_func(PG_FUNCTION_ARGS)
Definition regress.c:955
Datum test_fdw_handler(PG_FUNCTION_ARGS)
Definition regress.c:730
Datum test_instr_time(PG_FUNCTION_ARGS)
Definition regress.c:1414
#define EXPECT_EQ_U64(result_expr, expected_expr)
Definition regress.c:76
Datum interpt_pp(PG_FUNCTION_ARGS)
Definition regress.c:102
static void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2)
Definition regress.c:143
Datum trigger_return_old(PG_FUNCTION_ARGS)
Definition regress.c:267
Datum test_mblen_func(PG_FUNCTION_ARGS)
Definition regress.c:1161
Datum test_fdw_connection(PG_FUNCTION_ARGS)
Definition regress.c:738
#define RDELIM
Definition regress.c:87
Datum test_valid_server_encoding(PG_FUNCTION_ARGS)
Definition regress.c:1276
Datum int44in(PG_FUNCTION_ARGS)
Definition regress.c:294
Datum get_environ(PG_FUNCTION_ARGS)
Definition regress.c:443
#define TEXTDOMAIN
Definition regress.c:56
Datum test_pglz_compress(PG_FUNCTION_ARGS)
Definition regress.c:1456
Datum test_canonicalize_path(PG_FUNCTION_ARGS)
Definition regress.c:334
Datum reverse_name(PG_FUNCTION_ARGS)
Definition regress.c:246
Datum widget_in(PG_FUNCTION_ARGS)
Definition regress.c:184
Datum wait_pid(PG_FUNCTION_ARGS)
Definition regress.c:486
Datum widget_out(PG_FUNCTION_ARGS)
Definition regress.c:218
Datum is_catalog_text_unique_index_oid(PG_FUNCTION_ARGS)
Definition regress.c:756
static void test_atomic_flag(void)
Definition regress.c:506
Datum pt_in_widget(PG_FUNCTION_ARGS)
Definition regress.c:230
Datum test_text_to_bytea(PG_FUNCTION_ARGS)
Definition regress.c:1153
Datum test_enc_setup(PG_FUNCTION_ARGS)
Definition regress.c:963
Datum test_enc_conversion(PG_FUNCTION_ARGS)
Definition regress.c:1028
Datum test_translation(PG_FUNCTION_ARGS)
Definition regress.c:1329
static void test_atomic_uint64(void)
Definition regress.c:594
Datum make_tuple_indirect(PG_FUNCTION_ARGS)
Definition regress.c:344
Datum binary_coercible(PG_FUNCTION_ARGS)
Definition regress.c:1284
#define LDELIM
Definition regress.c:86
#define NARGS
Definition regress.c:181
Datum test_pglz_decompress(PG_FUNCTION_ARGS)
Definition regress.c:1487
Datum overpaid(PG_FUNCTION_ARGS)
Definition regress.c:154
RelPathStr GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber, int procNumber, ForkNumber forkNumber)
Definition relpath.c:143
#define REL_PATH_STR_MAXLEN
Definition relpath.h:96
@ INIT_FORKNUM
Definition relpath.h:61
#define PROCNUMBER_CHARS
Definition relpath.h:84
const char * quote_identifier(const char *ident)
int s_lock(volatile slock_t *lock, const char *file, int line, const char *func)
Definition s_lock.c:98
#define TAS(lock)
Definition s_lock.h:704
#define S_UNLOCK(lock)
Definition s_lock.h:689
#define TAS_SPIN(lock)
Definition s_lock.h:708
#define S_INIT_LOCK(lock)
Definition s_lock.h:693
#define S_LOCK(lock)
Definition s_lock.h:666
void pg_usleep(long microsec)
Definition signal.c:53
static void SpinLockRelease(volatile slock_t *lock)
Definition spin.h:62
static void SpinLockAcquire(volatile slock_t *lock)
Definition spin.h:56
static void SpinLockInit(volatile slock_t *lock)
Definition spin.h:50
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition stringinfo.c:145
void initStringInfo(StringInfo str)
Definition stringinfo.c:97
List * args
Definition primnodes.h:788
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 pg_list.h:54
Definition nodes.h:133
char str[REL_PATH_STR_MAXLEN+1]
Definition relpath.h:123
HeapTuple tg_trigtuple
Definition trigger.h:36
Point center
Definition regress.c:174
double radius
Definition regress.c:175
Definition c.h:835
bool superuser(void)
Definition superuser.c:47
char * flag(int b)
Definition test-ctype.c:33
#define CALLED_AS_TRIGGER(fcinfo)
Definition trigger.h:26
#define ReleaseTupleDesc(tupdesc)
Definition tupdesc.h:240
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:178
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
Definition typcache.c:1963
static bool VARATT_IS_EXTERNAL_ONDISK(const void *PTR)
Definition varatt.h:361
static Size VARSIZE_ANY(const void *PTR)
Definition varatt.h:460
static Size VARSIZE_ANY_EXHDR(const void *PTR)
Definition varatt.h:472
static char * VARDATA_EXTERNAL(const void *PTR)
Definition varatt.h:340
static bool VARATT_IS_EXTERNAL_INDIRECT(const void *PTR)
Definition varatt.h:368
static char * VARDATA(const void *PTR)
Definition varatt.h:305
static char * VARDATA_ANY(const void *PTR)
Definition varatt.h:486
static void SET_VARTAG_EXTERNAL(void *PTR, vartag_external tag)
Definition varatt.h:453
@ VARTAG_INDIRECT
Definition varatt.h:86
static void SET_VARSIZE(void *PTR, Size len)
Definition varatt.h:432
text * cstring_to_text(const char *s)
Definition varlena.c:184
char * text_to_cstring(const text *t)
Definition varlena.c:217
const char * name
void pg_encoding_set_invalid(int encoding, char *dst)
Definition wchar.c:1852
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
Definition wchar.c:2002
int pg_encoding_max_length(int encoding)
Definition wchar.c:2013
int pg_encoding_mblen(int encoding, const char *mbstr)
Definition wchar.c:1935
#define unsetenv(x)
Definition win32_port.h:560
#define kill(pid, sig)
Definition win32_port.h:507
#define setenv(x, y, z)
Definition win32_port.h:559