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 "funcapi.h"
35#include "mb/pg_wchar.h"
36#include "miscadmin.h"
37#include "nodes/supportnodes.h"
38#include "optimizer/optimizer.h"
39#include "optimizer/plancat.h"
40#include "parser/parse_coerce.h"
41#include "port/atomics.h"
43#include "postmaster/postmaster.h" /* for MAX_BACKENDS */
44#include "storage/spin.h"
45#include "tcop/tcopprot.h"
46#include "utils/array.h"
47#include "utils/builtins.h"
48#include "utils/geo_decls.h"
49#include "utils/memutils.h"
50#include "utils/rel.h"
51#include "utils/typcache.h"
52
53/* define our text domain for translations */
54#undef TEXTDOMAIN
55#define TEXTDOMAIN PG_TEXTDOMAIN("postgresql-regress")
56
57#define EXPECT_TRUE(expr) \
58 do { \
59 if (!(expr)) \
60 elog(ERROR, \
61 "%s was unexpectedly false in file \"%s\" line %u", \
62 #expr, __FILE__, __LINE__); \
63 } while (0)
64
65#define EXPECT_EQ_U32(result_expr, expected_expr) \
66 do { \
67 uint32 actual_result = (result_expr); \
68 uint32 expected_result = (expected_expr); \
69 if (actual_result != expected_result) \
70 elog(ERROR, \
71 "%s yielded %u, expected %s in file \"%s\" line %u", \
72 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
73 } while (0)
74
75#define EXPECT_EQ_U64(result_expr, expected_expr) \
76 do { \
77 uint64 actual_result = (result_expr); \
78 uint64 expected_result = (expected_expr); \
79 if (actual_result != expected_result) \
80 elog(ERROR, \
81 "%s yielded " UINT64_FORMAT ", expected %s in file \"%s\" line %u", \
82 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
83 } while (0)
84
85#define LDELIM '('
86#define RDELIM ')'
87#define DELIM ','
88
90
92 .name = "regress",
93 .version = PG_VERSION
94);
95
96
97/* return the point where two paths intersect, or NULL if no intersection. */
99
100Datum
102{
105 int i,
106 j;
107 LSEG seg1,
108 seg2;
109 bool found; /* We've found the intersection */
110
111 found = false; /* Haven't found it yet */
112
113 for (i = 0; i < p1->npts - 1 && !found; i++)
114 {
115 regress_lseg_construct(&seg1, &p1->p[i], &p1->p[i + 1]);
116 for (j = 0; j < p2->npts - 1 && !found; j++)
117 {
118 regress_lseg_construct(&seg2, &p2->p[j], &p2->p[j + 1]);
122 found = true;
123 }
124 }
125
126 if (!found)
128
129 /*
130 * Note: DirectFunctionCall2 will kick out an error if lseg_interpt()
131 * returns NULL, but that should be impossible since we know the two
132 * segments intersect.
133 */
137}
138
139
140/* like lseg_construct, but assume space already allocated */
141static void
143{
144 lseg->p[0].x = pt1->x;
145 lseg->p[0].y = pt1->y;
146 lseg->p[1].x = pt2->x;
147 lseg->p[1].y = pt2->y;
148}
149
151
152Datum
154{
156 bool isnull;
158
159 salary = DatumGetInt32(GetAttributeByName(tuple, "salary", &isnull));
160 if (isnull)
162 PG_RETURN_BOOL(salary > 699);
163}
164
165/* New type "widget"
166 * This used to be "circle", but I added circle to builtins,
167 * so needed to make sure the names do not collide. - tgl 97/04/21
168 */
169
170typedef struct
171{
173 double radius;
174} WIDGET;
175
178
179#define NARGS 3
180
181Datum
183{
184 char *str = PG_GETARG_CSTRING(0);
185 char *p,
186 *coord[NARGS];
187 int i;
188 WIDGET *result;
189
190 for (i = 0, p = str; *p && i < NARGS && *p != RDELIM; p++)
191 {
192 if (*p == DELIM || (*p == LDELIM && i == 0))
193 coord[i++] = p + 1;
194 }
195
196 /*
197 * Note: DON'T convert this error to "soft" style (errsave/ereturn). We
198 * want this data type to stay permanently in the hard-error world so that
199 * it can be used for testing that such cases still work reasonably.
200 */
201 if (i < NARGS)
204 errmsg("invalid input syntax for type %s: \"%s\"",
205 "widget", str)));
206
208 result->center.x = atof(coord[0]);
209 result->center.y = atof(coord[1]);
210 result->radius = atof(coord[2]);
211
213}
214
215Datum
217{
219 char *str = psprintf("(%g,%g,%g)",
220 widget->center.x, widget->center.y, widget->radius);
221
223}
224
226
227Datum
240
242
243Datum
245{
246 char *string = PG_GETARG_CSTRING(0);
247 int i;
248 int len;
249 char *new_string;
250
252 for (i = 0; i < NAMEDATALEN && string[i]; ++i)
253 ;
254 if (i == NAMEDATALEN || !string[i])
255 --i;
256 len = i;
257 for (; i >= 0; --i)
258 new_string[len - i] = string[i];
260}
261
263
264Datum
266{
267 TriggerData *trigdata = (TriggerData *) fcinfo->context;
268 HeapTuple tuple;
269
270 if (!CALLED_AS_TRIGGER(fcinfo))
271 elog(ERROR, "trigger_return_old: not fired by trigger manager");
272
273 tuple = trigdata->tg_trigtuple;
274
275 return PointerGetDatum(tuple);
276}
277
278
279/*
280 * Type int44 has no real-world use, but the regression tests use it
281 * (under the alias "city_budget"). It's a four-element vector of int4's.
282 */
283
284/*
285 * int44in - converts "num, num, ..." to internal form
286 *
287 * Note: Fills any missing positions with zeroes.
288 */
290
291Datum
293{
295 int32 *result = (int32 *) palloc(4 * sizeof(int32));
296 int i;
297
299 "%d, %d, %d, %d",
300 &result[0],
301 &result[1],
302 &result[2],
303 &result[3]);
304 while (i < 4)
305 result[i++] = 0;
306
308}
309
310/*
311 * int44out - converts internal form to "num, num, ..."
312 */
314
315Datum
317{
319 char *result = (char *) palloc(16 * 4);
320
321 snprintf(result, 16 * 4, "%d,%d,%d,%d",
322 an_array[0],
323 an_array[1],
324 an_array[2],
325 an_array[3]);
326
328}
329
331Datum
339
341Datum
343{
345 HeapTupleData tuple;
346 int ncolumns;
347 Datum *values;
348 bool *nulls;
349
350 Oid tupType;
352 TupleDesc tupdesc;
353
355
356 int i;
357
359
360 /* Extract type info from the tuple itself */
364 ncolumns = tupdesc->natts;
365
366 /* Build a temporary HeapTuple control structure */
369 tuple.t_tableOid = InvalidOid;
370 tuple.t_data = rec;
371
372 values = (Datum *) palloc(ncolumns * sizeof(Datum));
373 nulls = (bool *) palloc(ncolumns * sizeof(bool));
374
375 heap_deform_tuple(&tuple, tupdesc, values, nulls);
376
378
379 for (i = 0; i < ncolumns; i++)
380 {
381 varlena *attr;
384
385 /* only work on existing, not-null varlenas */
386 if (TupleDescAttr(tupdesc, i)->attisdropped ||
387 nulls[i] ||
388 TupleDescAttr(tupdesc, i)->attlen != -1 ||
390 continue;
391
392 attr = (varlena *) DatumGetPointer(values[i]);
393
394 /* don't recursively indirect */
396 continue;
397
398 /* copy datum, so it still lives later */
400 attr = detoast_external_attr(attr);
401 else
402 {
403 varlena *oldattr = attr;
404
405 attr = palloc0(VARSIZE_ANY(oldattr));
407 }
408
409 /* build indirection Datum */
411 redirect_pointer.pointer = attr;
414 sizeof(redirect_pointer));
415
417 }
418
419 newtup = heap_form_tuple(tupdesc, values, nulls);
420 pfree(values);
421 pfree(nulls);
422 ReleaseTupleDesc(tupdesc);
423
425
426 /*
427 * We intentionally don't use PG_RETURN_HEAPTUPLEHEADER here, because that
428 * would cause the indirect toast pointers to be flattened out of the
429 * tuple immediately, rendering subsequent testing irrelevant. So just
430 * return the HeapTupleHeader pointer as-is. This violates the general
431 * rule that composite Datums shouldn't contain toast pointers, but so
432 * long as the regression test scripts don't insert the result of this
433 * function into a container type (record, array, etc) it should be OK.
434 */
435 PG_RETURN_POINTER(newtup->t_data);
436}
437
439
440Datum
442{
443#if !defined(WIN32)
444 extern char **environ;
445#endif
446 int nvals = 0;
448 Datum *env;
449
450 for (char **s = environ; *s; s++)
451 nvals++;
452
453 env = palloc(nvals * sizeof(Datum));
454
455 for (int i = 0; i < nvals; i++)
457
459
461}
462
464
465Datum
467{
468 char *envvar = text_to_cstring(PG_GETARG_TEXT_PP(0));
470
471 if (!superuser())
472 elog(ERROR, "must be superuser to change environment variables");
473
474 if (setenv(envvar, envval, 1) != 0)
475 elog(ERROR, "could not set environment variable: %m");
476
478}
479
480/* Sleep until no process has a given PID. */
482
483Datum
485{
486 int pid = PG_GETARG_INT32(0);
487
488 if (!superuser())
489 elog(ERROR, "must be superuser to check PID liveness");
490
491 while (kill(pid, 0) == 0)
492 {
494 pg_usleep(50000);
495 }
496
497 if (errno != ESRCH)
498 elog(ERROR, "could not check PID %d liveness: %m", pid);
499
501}
502
503static void
518
519static void
521{
524 int i;
525
526 pg_atomic_init_u32(&var, 0);
528 pg_atomic_write_u32(&var, 3);
531 3);
537
538 /* test around numerical limits */
541 pg_atomic_fetch_add_u32(&var, 2); /* wrap to 0 */
546 2 * PG_INT16_MAX + 1);
549 pg_atomic_fetch_add_u32(&var, 1); /* top up to UINT_MAX */
563
564 /* fail exchange because of old expected */
565 expected = 10;
567
568 /* CAS is allowed to fail due to interrupts, try a couple of times */
569 for (i = 0; i < 1000; i++)
570 {
571 expected = 0;
573 break;
574 }
575 if (i == 1000)
576 elog(ERROR, "atomic_compare_exchange_u32() never succeeded");
578 pg_atomic_write_u32(&var, 0);
579
580 /* try setting flagbits */
581 EXPECT_TRUE(!(pg_atomic_fetch_or_u32(&var, 1) & 1));
584 /* try clearing flagbits */
585 EXPECT_EQ_U32(pg_atomic_fetch_and_u32(&var, ~2) & 3, 3);
587 /* no bits set anymore */
589}
590
591static void
593{
596 int i;
597
598 pg_atomic_init_u64(&var, 0);
600 pg_atomic_write_u64(&var, 3);
603 3);
609
610 /* fail exchange because of old expected */
611 expected = 10;
613
614 /* CAS is allowed to fail due to interrupts, try a couple of times */
615 for (i = 0; i < 100; i++)
616 {
617 expected = 0;
619 break;
620 }
621 if (i == 100)
622 elog(ERROR, "atomic_compare_exchange_u64() never succeeded");
624
625 pg_atomic_write_u64(&var, 0);
626
627 /* try setting flagbits */
628 EXPECT_TRUE(!(pg_atomic_fetch_or_u64(&var, 1) & 1));
631 /* try clearing flagbits */
632 EXPECT_EQ_U64((pg_atomic_fetch_and_u64(&var, ~2) & 3), 3);
634 /* no bits set anymore */
636}
637
638/*
639 * Perform, fairly minimal, testing of the spinlock implementation.
640 *
641 * It's likely worth expanding these to actually test concurrency etc, but
642 * having some regularly run tests is better than none.
643 */
644static void
646{
647 /*
648 * Basic tests for spinlocks, as well as the underlying operations.
649 *
650 * We embed the spinlock in a struct with other members to test that the
651 * spinlock operations don't perform too wide writes.
652 */
653 {
654 struct test_lock_struct
655 {
656 char data_before[4];
657 slock_t lock;
658 char data_after[4];
660
661 memcpy(struct_w_lock.data_before, "abcd", 4);
662 memcpy(struct_w_lock.data_after, "ef12", 4);
663
664 /* test basic operations via the SpinLock* API */
668
669 /* test basic operations via underlying S_* API */
671 S_LOCK(&struct_w_lock.lock);
672 S_UNLOCK(&struct_w_lock.lock);
673
674 /* and that "contended" acquisition works */
675 s_lock(&struct_w_lock.lock, "testfile", 17, "testfunc");
676 S_UNLOCK(&struct_w_lock.lock);
677
678 /*
679 * Check, using TAS directly, that a single spin cycle doesn't block
680 * when acquiring an already acquired lock.
681 */
682#ifdef TAS
683 S_LOCK(&struct_w_lock.lock);
684
685 if (!TAS(&struct_w_lock.lock))
686 elog(ERROR, "acquired already held spinlock");
687
688#ifdef TAS_SPIN
689 if (!TAS_SPIN(&struct_w_lock.lock))
690 elog(ERROR, "acquired already held spinlock");
691#endif /* defined(TAS_SPIN) */
692
693 S_UNLOCK(&struct_w_lock.lock);
694#endif /* defined(TAS) */
695
696 /*
697 * Verify that after all of this the non-lock contents are still
698 * correct.
699 */
700 if (memcmp(struct_w_lock.data_before, "abcd", 4) != 0)
701 elog(ERROR, "padding before spinlock modified");
702 if (memcmp(struct_w_lock.data_after, "ef12", 4) != 0)
703 elog(ERROR, "padding after spinlock modified");
704 }
705}
706
708Datum
710{
712
714
716
717 /*
718 * Arguably this shouldn't be tested as part of this function, but it's
719 * closely enough related that that seems ok for now.
720 */
722
723 PG_RETURN_BOOL(true);
724}
725
727Datum
729{
730 elog(ERROR, "test_fdw_handler is not implemented");
732}
733
735Datum
737{
738 PG_RETURN_TEXT_P(cstring_to_text("dbname=regress_doesnotexist user=doesnotexist password=secret"));
739}
740
742Datum
747
749Datum
751{
753 Node *ret = NULL;
754
756 {
757 /*
758 * Assume that the target is int4eq; that's safe as long as we don't
759 * attach this to any other boolean-returning function.
760 */
763
764 if (req->is_join)
766 req->args,
767 req->inputcollid,
768 req->jointype,
769 req->sjinfo);
770 else
772 req->args,
773 req->inputcollid,
774 req->varRelid);
775
776 req->selectivity = s1;
777 ret = (Node *) req;
778 }
779
781 {
782 /* Provide some generic estimate */
784
785 req->startup = 0;
786 req->per_tuple = 2 * cpu_operator_cost;
787 ret = (Node *) req;
788 }
789
791 {
792 /*
793 * Assume that the target is generate_series_int4; that's safe as long
794 * as we don't attach this to any other set-returning function.
795 */
797
798 if (req->node && IsA(req->node, FuncExpr)) /* be paranoid */
799 {
800 List *args = ((FuncExpr *) req->node)->args;
801 Node *arg1 = linitial(args);
802 Node *arg2 = lsecond(args);
803
804 if (IsA(arg1, Const) &&
805 !((Const *) arg1)->constisnull &&
806 IsA(arg2, Const) &&
807 !((Const *) arg2)->constisnull)
808 {
811
812 req->rows = val2 - val1 + 1;
813 ret = (Node *) req;
814 }
815 }
816 }
817
819}
820
822Datum
824{
826
828 {
829 /*
830 * Assume that the target is foo_from_bar; that's safe as long as we
831 * don't attach this to any other function.
832 */
834 StringInfoData sql;
835 RangeTblFunction *rtfunc = req->rtfunc;
836 FuncExpr *expr = (FuncExpr *) rtfunc->funcexpr;
837 Node *node;
838 Const *c;
839 char *colname;
840 char *tablename;
845
846 if (list_length(expr->args) != 3)
847 {
848 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with %d args but expected 3", list_length(expr->args))));
850 }
851
852 /* Get colname */
853 node = linitial(expr->args);
854 if (!IsA(node, Const))
855 {
856 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with non-Const parameters")));
858 }
859
860 c = (Const *) node;
861 if (c->consttype != TEXTOID || c->constisnull)
862 {
863 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with non-TEXT parameters")));
865 }
866 colname = TextDatumGetCString(c->constvalue);
867
868 /* Get tablename */
869 node = lsecond(expr->args);
870 if (!IsA(node, Const))
871 {
872 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with non-Const parameters")));
874 }
875
876 c = (Const *) node;
877 if (c->consttype != TEXTOID || c->constisnull)
878 {
879 ereport(WARNING, (errmsg("test_inline_in_from_support_func called with non-TEXT parameters")));
881 }
882 tablename = TextDatumGetCString(c->constvalue);
883
884 /* Begin constructing replacement SELECT query. */
885 initStringInfo(&sql);
886 appendStringInfo(&sql, "SELECT %s::text FROM %s",
887 quote_identifier(colname),
888 quote_identifier(tablename));
889
890 /* Add filter expression if present. */
891 node = lthird(expr->args);
892 if (!(IsA(node, Const) && ((Const *) node)->constisnull))
893 {
894 /*
895 * We only filter if $3 is not constant-NULL. This is not a very
896 * exact implementation of the PL/pgSQL original, but it's close
897 * enough for demonstration purposes.
898 */
899 appendStringInfo(&sql, " WHERE %s::text = $3",
900 quote_identifier(colname));
901 }
902
903 /* Build a SQLFunctionParseInfo with the parameters of my function. */
904 pinfo = prepare_sql_fn_parse_info(req->proc,
905 (Node *) expr,
906 expr->inputcollid);
907
908 /* Parse the generated SQL. */
911 {
912 ereport(WARNING, (errmsg("test_inline_in_from_support_func parsed to more than one node")));
914 }
915
916 /* Analyze the parse tree as if it were a SQL-language body. */
918 sql.data,
920 pinfo, NULL);
921 if (list_length(querytree_list) != 1)
922 {
923 ereport(WARNING, (errmsg("test_inline_in_from_support_func rewrote to more than one node")));
925 }
926
928 if (!IsA(querytree, Query))
929 {
930 ereport(WARNING, (errmsg("test_inline_in_from_support_func didn't parse to a Query")));
932 }
933
935 }
936
938}
939
941Datum
946
947/* one-time tests for encoding infrastructure */
949Datum
951{
952 /* Test pg_encoding_set_invalid() */
953 for (int i = 0; i < _PG_LAST_ENCODING_; i++)
954 {
955 char buf[2],
956 bigbuf[16];
957 int len,
958 mblen,
959 valid;
960
961 if (!PG_VALID_ENCODING(i))
962 continue;
963 if (pg_encoding_max_length(i) == 1)
964 continue;
966 len = strnlen(buf, 2);
967 if (len != 2)
969 "official invalid string for encoding \"%s\" has length %d",
971 mblen = pg_encoding_mblen(i, buf);
972 if (mblen != 2)
974 "official invalid string for encoding \"%s\" has mblen %d",
975 pg_enc2name_tbl[i].name, mblen);
976 valid = pg_encoding_verifymbstr(i, buf, len);
977 if (valid != 0)
979 "official invalid string for encoding \"%s\" has valid prefix of length %d",
980 pg_enc2name_tbl[i].name, valid);
981 valid = pg_encoding_verifymbstr(i, buf, 1);
982 if (valid != 0)
984 "first byte of official invalid string for encoding \"%s\" has valid prefix of length %d",
985 pg_enc2name_tbl[i].name, valid);
986 memset(bigbuf, ' ', sizeof(bigbuf));
987 bigbuf[0] = buf[0];
988 bigbuf[1] = buf[1];
989 valid = pg_encoding_verifymbstr(i, bigbuf, sizeof(bigbuf));
990 if (valid != 0)
992 "trailing data changed official invalid string for encoding \"%s\" to have valid prefix of length %d",
993 pg_enc2name_tbl[i].name, valid);
994 }
995
997}
998
999/*
1000 * Call an encoding conversion or verification function.
1001 *
1002 * Arguments:
1003 * string bytea -- string to convert
1004 * src_enc name -- source encoding
1005 * dest_enc name -- destination encoding
1006 * noError bool -- if set, don't ereport() on invalid or untranslatable
1007 * input
1008 *
1009 * Result is a tuple with two attributes:
1010 * int4 -- number of input bytes successfully converted
1011 * bytea -- converted string
1012 */
1014Datum
1016{
1017 bytea *string = PG_GETARG_BYTEA_PP(0);
1022 bool noError = PG_GETARG_BOOL(3);
1023 TupleDesc tupdesc;
1024 char *src;
1025 char *dst;
1026 bytea *retval;
1027 Size srclen;
1028 Size dstsize;
1029 Oid proc;
1030 int convertedbytes;
1031 int dstlen;
1032 Datum values[2];
1033 bool nulls[2] = {0};
1034 HeapTuple tuple;
1035
1036 if (src_encoding < 0)
1037 ereport(ERROR,
1039 errmsg("invalid source encoding name \"%s\"",
1041 if (dest_encoding < 0)
1042 ereport(ERROR,
1044 errmsg("invalid destination encoding name \"%s\"",
1046
1047 /* Build a tuple descriptor for our result type */
1048 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
1049 elog(ERROR, "return type must be a row type");
1050 tupdesc = BlessTupleDesc(tupdesc);
1051
1052 srclen = VARSIZE_ANY_EXHDR(string);
1053 src = VARDATA_ANY(string);
1054
1056 {
1057 /* just check that the source string is valid */
1058 int oklen;
1059
1061
1062 if (oklen == srclen)
1063 {
1065 retval = string;
1066 }
1067 else if (!noError)
1068 {
1070 }
1071 else
1072 {
1073 /*
1074 * build bytea data type structure.
1075 */
1076 Assert(oklen < srclen);
1078 retval = (bytea *) palloc(oklen + VARHDRSZ);
1079 SET_VARSIZE(retval, oklen + VARHDRSZ);
1080 memcpy(VARDATA(retval), src, oklen);
1081 }
1082 }
1083 else
1084 {
1086 if (!OidIsValid(proc))
1087 ereport(ERROR,
1089 errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
1092
1094 ereport(ERROR,
1096 errmsg("out of memory"),
1097 errdetail("String of %d bytes is too long for encoding conversion.",
1098 (int) srclen)));
1099
1102
1103 /* perform conversion */
1107 (unsigned char *) src, srclen,
1108 (unsigned char *) dst, dstsize,
1109 noError);
1110 dstlen = strlen(dst);
1111
1112 /*
1113 * build bytea data type structure.
1114 */
1115 retval = (bytea *) palloc(dstlen + VARHDRSZ);
1116 SET_VARSIZE(retval, dstlen + VARHDRSZ);
1117 memcpy(VARDATA(retval), dst, dstlen);
1118
1119 pfree(dst);
1120 }
1121
1123 values[1] = PointerGetDatum(retval);
1124 tuple = heap_form_tuple(tupdesc, values, nulls);
1125
1127}
1128
1129/* Convert bytea to text without validation for corruption tests from SQL. */
1131Datum
1136
1137/* And the reverse. */
1139Datum
1144
1145/* Corruption tests in C. */
1147Datum
1149{
1150 const char *func = text_to_cstring(PG_GETARG_BYTEA_PP(0));
1152 text *string = PG_GETARG_BYTEA_PP(2);
1153 int offset = PG_GETARG_INT32(3);
1154 const char *data = VARDATA_ANY(string);
1155 size_t size = VARSIZE_ANY_EXHDR(string);
1156 int result = 0;
1157
1158 if (strcmp(func, "pg_mblen_unbounded") == 0)
1159 result = pg_mblen_unbounded(data + offset);
1160 else if (strcmp(func, "pg_mblen_cstr") == 0)
1161 result = pg_mblen_cstr(data + offset);
1162 else if (strcmp(func, "pg_mblen_with_len") == 0)
1163 result = pg_mblen_with_len(data + offset, size - offset);
1164 else if (strcmp(func, "pg_mblen_range") == 0)
1165 result = pg_mblen_range(data + offset, data + size);
1166 else if (strcmp(func, "pg_encoding_mblen") == 0)
1168 else
1169 elog(ERROR, "unknown function");
1170
1172}
1173
1175Datum
1177{
1179 text *string = PG_GETARG_TEXT_PP(1);
1180 const char *data = VARDATA_ANY(string);
1181 size_t size = VARSIZE_ANY_EXHDR(string);
1182 pg_wchar *wchars = palloc(sizeof(pg_wchar) * (size + 1));
1183 Datum *datums;
1184 int wlen;
1185 int encoding;
1186
1188 if (encoding < 0)
1189 elog(ERROR, "unknown encoding name: %s", encoding_name);
1190
1191 if (size > 0)
1192 {
1193 datums = palloc(sizeof(Datum) * size);
1195 data,
1196 wchars,
1197 size);
1198 Assert(wlen >= 0);
1199 Assert(wlen <= size);
1200 Assert(wchars[wlen] == 0);
1201
1202 for (int i = 0; i < wlen; ++i)
1203 datums[i] = UInt32GetDatum(wchars[i]);
1204 }
1205 else
1206 {
1207 datums = NULL;
1208 wlen = 0;
1209 }
1210
1212}
1213
1215Datum
1217{
1219 ArrayType *array = PG_GETARG_ARRAYTYPE_P(1);
1220 Datum *datums;
1221 bool *nulls;
1222 char *mb;
1223 text *result;
1224 int wlen;
1225 int bytes;
1226 int encoding;
1227
1229 if (encoding < 0)
1230 elog(ERROR, "unknown encoding name: %s", encoding_name);
1231
1232 deconstruct_array_builtin(array, INT4OID, &datums, &nulls, &wlen);
1233
1234 if (wlen > 0)
1235 {
1236 pg_wchar *wchars = palloc(sizeof(pg_wchar) * wlen);
1237
1238 for (int i = 0; i < wlen; ++i)
1239 {
1240 if (nulls[i])
1241 elog(ERROR, "unexpected NULL in array");
1242 wchars[i] = DatumGetInt32(datums[i]);
1243 }
1244
1247 }
1248 else
1249 {
1250 mb = "";
1251 bytes = 0;
1252 }
1253
1254 result = palloc(bytes + VARHDRSZ);
1255 SET_VARSIZE(result, bytes + VARHDRSZ);
1256 memcpy(VARDATA(result), mb, bytes);
1257
1259}
1260
1262Datum
1267
1268/* Provide SQL access to IsBinaryCoercible() */
1270Datum
1272{
1273 Oid srctype = PG_GETARG_OID(0);
1274 Oid targettype = PG_GETARG_OID(1);
1275
1276 PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
1277}
1278
1279/*
1280 * Sanity checks for functions in relpath.h
1281 */
1283Datum
1285{
1286 RelPathStr rpath;
1287
1288 /*
1289 * Verify that PROCNUMBER_CHARS and MAX_BACKENDS stay in sync.
1290 * Unfortunately I don't know how to express that in a way suitable for a
1291 * static assert.
1292 */
1293 if ((int) ceil(log10(MAX_BACKENDS)) != PROCNUMBER_CHARS)
1294 elog(WARNING, "mismatch between MAX_BACKENDS and PROCNUMBER_CHARS");
1295
1296 /* verify that the max-length relpath is generated ok */
1298 INIT_FORKNUM);
1299
1300 if (strlen(rpath.str) != REL_PATH_STR_MAXLEN)
1301 elog(WARNING, "maximum length relpath is if length %zu instead of %zu",
1303
1305}
1306
1307/*
1308 * Simple test to verify NLS support, particularly that the PRI* macros work.
1309 *
1310 * A secondary objective is to verify that <inttypes.h>'s values for the
1311 * PRI* macros match what our snprintf.c code will do. Therefore, we run
1312 * the ereport() calls even when we know that translation will not happen.
1313 */
1315Datum
1317{
1318#ifdef ENABLE_NLS
1319 static bool inited = false;
1320
1321 /*
1322 * Ideally we'd do this bit in a _PG_init() hook. However, it seems best
1323 * that the Solaris hack only get applied in the nls.sql test, so it
1324 * doesn't risk affecting other tests that load this module.
1325 */
1326 if (!inited)
1327 {
1328 /*
1329 * Solaris' built-in gettext is not bright about associating locales
1330 * with message catalogs that are named after just the language.
1331 * Apparently the customary workaround is for users to set the
1332 * LANGUAGE environment variable to provide a mapping. Do so here to
1333 * ensure that the nls.sql regression test will work.
1334 */
1335#if defined(__sun__)
1336 setenv("LANGUAGE", "es_ES.UTF-8:es", 1);
1337#endif
1339 inited = true;
1340 }
1341
1342 /*
1343 * If nls.sql failed to select a non-C locale, no translation will happen.
1344 * Report that so that we can distinguish this outcome from brokenness.
1345 * (We do this here, not in nls.sql, so as to need only 3 expected files.)
1346 */
1347 if (strcmp(GetConfigOption("lc_messages", false, false), "C") == 0)
1348 elog(NOTICE, "lc_messages is 'C'");
1349#else
1350 elog(NOTICE, "NLS is not enabled");
1351#endif
1352
1354 errmsg("translated PRId64 = %" PRId64, (int64) 424242424242));
1356 errmsg("translated PRId32 = %" PRId32, (int32) -1234));
1358 errmsg("translated PRIdMAX = %" PRIdMAX, (intmax_t) -123456789012));
1360 errmsg("translated PRIdPTR = %" PRIdPTR, (intptr_t) -9999));
1361
1363 errmsg("translated PRIu64 = %" PRIu64, (uint64) 424242424242));
1365 errmsg("translated PRIu32 = %" PRIu32, (uint32) -1234));
1367 errmsg("translated PRIuMAX = %" PRIuMAX, (uintmax_t) 123456789012));
1369 errmsg("translated PRIuPTR = %" PRIuPTR, (uintptr_t) 9999));
1370
1372 errmsg("translated PRIx64 = %" PRIx64, (uint64) 424242424242));
1374 errmsg("translated PRIx32 = %" PRIx32, (uint32) -1234));
1376 errmsg("translated PRIxMAX = %" PRIxMAX, (uintmax_t) 123456789012));
1378 errmsg("translated PRIxPTR = %" PRIxPTR, (uintptr_t) 9999));
1379
1381 errmsg("translated PRIX64 = %" PRIX64, (uint64) 424242424242));
1383 errmsg("translated PRIX32 = %" PRIX32, (uint32) -1234));
1385 errmsg("translated PRIXMAX = %" PRIXMAX, (uintmax_t) 123456789012));
1387 errmsg("translated PRIXPTR = %" PRIXPTR, (uintptr_t) 9999));
1388
1390}
1391
1392/* Verify that pg_ticks_to_ns behaves correct, including overflow */
1394Datum
1396{
1397 instr_time t;
1398 int64 test_ns[] = {0, 1000, INT64CONST(1000000000000000)};
1399 int64 max_err;
1400
1401 /*
1402 * The ns-to-ticks-to-ns roundtrip may lose precision due to integer
1403 * truncation in the fixed-point conversion. The maximum error depends on
1404 * ticks_per_ns_scaled relative to the shift factor.
1405 */
1407
1408 for (int i = 0; i < lengthof(test_ns); i++)
1409 {
1410 int64 result;
1411
1415
1416 if (result < test_ns[i] - max_err || result > test_ns[i])
1417 elog(ERROR,
1418 "INSTR_TIME_GET_NANOSEC(t) yielded " INT64_FORMAT
1419 ", expected " INT64_FORMAT " (max_err " INT64_FORMAT
1420 ") in file \"%s\" line %u",
1422 }
1423
1424 PG_RETURN_BOOL(true);
1425}
1426
1427/*
1428 * test_pglz_compress
1429 *
1430 * Compress the input using pglz_compress(). Only the "always" strategy is
1431 * currently supported.
1432 *
1433 * Returns the compressed data, or NULL if compression fails.
1434 */
1436Datum
1455
1456/*
1457 * test_pglz_decompress
1458 *
1459 * Decompress the input using pglz_decompress().
1460 *
1461 * The second argument is the expected uncompressed data size. The third
1462 * argument is here for the check_complete flag.
1463 *
1464 * Returns the decompressed data, or raises an error if decompression fails.
1465 */
1467Datum
1469{
1473 char *source = VARDATA_ANY(input);
1475 bytea *result;
1476 int32 dlen;
1477
1478 if (rawsize < 0)
1479 elog(ERROR, "rawsize must not be negative");
1480
1482
1485 if (dlen < 0)
1486 elog(ERROR, "pglz_decompress failed");
1487
1490}
Datum querytree(PG_FUNCTION_ARGS)
Definition _int_bool.c:665
#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:396
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
Definition atomics.h:349
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition atomics.h:485
static void pg_atomic_clear_flag(volatile pg_atomic_flag *ptr)
Definition atomics.h:205
static uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
Definition atomics.h:410
static uint32 pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition atomics.h:439
static uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition atomics.h:381
static bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
Definition atomics.h:522
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition atomics.h:219
static uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition atomics.h:366
static uint32 pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition atomics.h:424
static uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition atomics.h:532
static bool pg_atomic_test_set_flag(volatile pg_atomic_flag *ptr)
Definition atomics.h:181
static uint64 pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition atomics.h:578
static bool pg_atomic_unlocked_test_flag(volatile pg_atomic_flag *ptr)
Definition atomics.h:194
static void pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition atomics.h:274
static uint64 pg_atomic_fetch_and_u64(volatile pg_atomic_uint64 *ptr, uint64 and_)
Definition atomics.h:551
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
Definition atomics.h:237
static uint64 pg_atomic_fetch_or_u64(volatile pg_atomic_uint64 *ptr, uint64 or_)
Definition atomics.h:560
static uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition atomics.h:569
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
Definition atomics.h:330
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition atomics.h:453
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
Definition atomics.h:467
static uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition atomics.h:541
static uint64 pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval)
Definition atomics.h:513
static void pg_atomic_init_flag(volatile pg_atomic_flag *ptr)
Definition atomics.h:168
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:835
#define INT64CONST(x)
Definition c.h:630
#define INT64_FORMAT
Definition c.h:634
#define VARHDRSZ
Definition c.h:781
#define Assert(condition)
Definition c.h:943
int64_t int64
Definition c.h:621
double float8
Definition c.h:714
#define PG_INT16_MIN
Definition c.h:669
int32_t int32
Definition c.h:620
uint64_t uint64
Definition c.h:625
uint32_t uint32
Definition c.h:624
#define lengthof(array)
Definition c.h:873
#define PG_INT16_MAX
Definition c.h:670
#define OidIsValid(objectId)
Definition c.h:858
size_t Size
Definition c.h:689
bool IsCatalogTextUniqueIndexOid(Oid relid)
Definition catalog.c:156
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:74
#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:686
#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
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:2011
Datum lseg_intersect(PG_FUNCTION_ARGS)
Definition geo_ops.c:2217
Datum lseg_interpt(PG_FUNCTION_ARGS)
Definition geo_ops.c:2408
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:445
#define INSTR_TIME_ADD_NANOSEC(t, n)
Definition instr_time.h:433
#define INSTR_TIME_SET_ZERO(t)
Definition instr_time.h:421
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:1824
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:1232
MemoryContext TopTransactionContext
Definition mcxt.c:171
void pfree(void *pointer)
Definition mcxt.c:1616
void * palloc0(Size size)
Definition mcxt.c:1417
void * palloc(Size size)
Definition mcxt.c:1387
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
#define CHECK_FOR_INTERRUPTS()
Definition miscadmin.h:125
void pg_bindtextdomain(const char *domain)
Definition miscinit.c:1890
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition namespace.c:4152
#define IsA(nodeptr, _type_)
Definition nodes.h:164
double Selectivity
Definition nodes.h:260
static char * errmsg
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
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:260
List * pg_analyze_and_rewrite_withcb(RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
Definition postgres.c:774
List * pg_parse_query(const char *query_string)
Definition postgres.c:615
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:645
Datum test_inline_in_from_support_func(PG_FUNCTION_ARGS)
Definition regress.c:823
#define DELIM
Definition regress.c:87
#define EXPECT_TRUE(expr)
Definition regress.c:57
Datum regress_setenv(PG_FUNCTION_ARGS)
Definition regress.c:466
static void test_atomic_uint32(void)
Definition regress.c:520
Datum test_relpath(PG_FUNCTION_ARGS)
Definition regress.c:1284
Datum test_text_to_wchars(PG_FUNCTION_ARGS)
Definition regress.c:1176
#define EXPECT_EQ_U32(result_expr, expected_expr)
Definition regress.c:65
Datum test_atomic_ops(PG_FUNCTION_ARGS)
Definition regress.c:709
Datum test_wchars_to_text(PG_FUNCTION_ARGS)
Definition regress.c:1216
Datum test_support_func(PG_FUNCTION_ARGS)
Definition regress.c:750
Datum test_bytea_to_text(PG_FUNCTION_ARGS)
Definition regress.c:1132
Datum int44out(PG_FUNCTION_ARGS)
Definition regress.c:316
Datum test_opclass_options_func(PG_FUNCTION_ARGS)
Definition regress.c:942
Datum test_fdw_handler(PG_FUNCTION_ARGS)
Definition regress.c:728
Datum test_instr_time(PG_FUNCTION_ARGS)
Definition regress.c:1395
#define EXPECT_EQ_U64(result_expr, expected_expr)
Definition regress.c:75
Datum interpt_pp(PG_FUNCTION_ARGS)
Definition regress.c:101
static void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2)
Definition regress.c:142
Datum trigger_return_old(PG_FUNCTION_ARGS)
Definition regress.c:265
Datum test_mblen_func(PG_FUNCTION_ARGS)
Definition regress.c:1148
Datum test_fdw_connection(PG_FUNCTION_ARGS)
Definition regress.c:736
#define RDELIM
Definition regress.c:86
Datum test_valid_server_encoding(PG_FUNCTION_ARGS)
Definition regress.c:1263
Datum int44in(PG_FUNCTION_ARGS)
Definition regress.c:292
Datum get_environ(PG_FUNCTION_ARGS)
Definition regress.c:441
#define TEXTDOMAIN
Definition regress.c:55
Datum test_pglz_compress(PG_FUNCTION_ARGS)
Definition regress.c:1437
Datum test_canonicalize_path(PG_FUNCTION_ARGS)
Definition regress.c:332
Datum reverse_name(PG_FUNCTION_ARGS)
Definition regress.c:244
Datum widget_in(PG_FUNCTION_ARGS)
Definition regress.c:182
Datum wait_pid(PG_FUNCTION_ARGS)
Definition regress.c:484
Datum widget_out(PG_FUNCTION_ARGS)
Definition regress.c:216
Datum is_catalog_text_unique_index_oid(PG_FUNCTION_ARGS)
Definition regress.c:743
static void test_atomic_flag(void)
Definition regress.c:504
Datum pt_in_widget(PG_FUNCTION_ARGS)
Definition regress.c:228
Datum test_text_to_bytea(PG_FUNCTION_ARGS)
Definition regress.c:1140
Datum test_enc_setup(PG_FUNCTION_ARGS)
Definition regress.c:950
Datum test_enc_conversion(PG_FUNCTION_ARGS)
Definition regress.c:1015
Datum test_translation(PG_FUNCTION_ARGS)
Definition regress.c:1316
static void test_atomic_uint64(void)
Definition regress.c:592
Datum make_tuple_indirect(PG_FUNCTION_ARGS)
Definition regress.c:342
Datum binary_coercible(PG_FUNCTION_ARGS)
Definition regress.c:1271
#define LDELIM
Definition regress.c:85
#define NARGS
Definition regress.c:179
Datum test_pglz_decompress(PG_FUNCTION_ARGS)
Definition regress.c:1468
Datum overpaid(PG_FUNCTION_ARGS)
Definition regress.c:153
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:801
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:135
char str[REL_PATH_STR_MAXLEN+1]
Definition relpath.h:123
HeapTuple tg_trigtuple
Definition trigger.h:36
Point center
Definition regress.c:172
double radius
Definition regress.c:173
Definition c.h:776
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:1947
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:1851
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
Definition wchar.c:2001
int pg_encoding_max_length(int encoding)
Definition wchar.c:2012
int pg_encoding_mblen(int encoding, const char *mbstr)
Definition wchar.c:1934
#define kill(pid, sig)
Definition win32_port.h:490
#define setenv(x, y, z)
Definition win32_port.h:542