PostgreSQL Source Code: src/test/regress/regress.c Source File

PostgreSQL Source Code git master
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-2025, 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"
30#include "executor/executor.h"
31#include "executor/spi.h"
32#include "funcapi.h"
33#include "mb/pg_wchar.h"
34#include "miscadmin.h"
35#include "nodes/supportnodes.h"
36#include "optimizer/optimizer.h"
37#include "optimizer/plancat.h"
38#include "parser/parse_coerce.h"
39#include "port/atomics.h"
40#include "postmaster/postmaster.h" /* for MAX_BACKENDS */
41#include "storage/spin.h"
42#include "utils/array.h"
43#include "utils/builtins.h"
44#include "utils/geo_decls.h"
45#include "utils/memutils.h"
46#include "utils/rel.h"
47#include "utils/typcache.h"
48
49 #define EXPECT_TRUE(expr) \
50 do { \
51 if (!(expr)) \
52 elog(ERROR, \
53 "%s was unexpectedly false in file \"%s\" line %u", \
54 #expr, __FILE__, __LINE__); \
55 } while (0)
56
57 #define EXPECT_EQ_U32(result_expr, expected_expr) \
58 do { \
59 uint32 actual_result = (result_expr); \
60 uint32 expected_result = (expected_expr); \
61 if (actual_result != expected_result) \
62 elog(ERROR, \
63 "%s yielded %u, expected %s in file \"%s\" line %u", \
64 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
65 } while (0)
66
67 #define EXPECT_EQ_U64(result_expr, expected_expr) \
68 do { \
69 uint64 actual_result = (result_expr); \
70 uint64 expected_result = (expected_expr); \
71 if (actual_result != expected_result) \
72 elog(ERROR, \
73 "%s yielded " UINT64_FORMAT ", expected %s in file \"%s\" line %u", \
74 #result_expr, actual_result, #expected_expr, __FILE__, __LINE__); \
75 } while (0)
76
77 #define LDELIM '('
78 #define RDELIM ')'
79 #define DELIM ','
80
81static void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2);
82
83 PG_MODULE_MAGIC_EXT(
84 .name = "regress",
85 .version = PG_VERSION
86);
87
88
89/* return the point where two paths intersect, or NULL if no intersection. */
90 PG_FUNCTION_INFO_V1(interpt_pp);
91
92Datum
93 interpt_pp(PG_FUNCTION_ARGS)
94{
95 PATH *p1 = PG_GETARG_PATH_P(0);
96 PATH *p2 = PG_GETARG_PATH_P(1);
97 int i,
98 j;
99 LSEG seg1,
100 seg2;
101 bool found; /* We've found the intersection */
102
103 found = false; /* Haven't found it yet */
104
105 for (i = 0; i < p1->npts - 1 && !found; i++)
106 {
107 regress_lseg_construct(&seg1, &p1->p[i], &p1->p[i + 1]);
108 for (j = 0; j < p2->npts - 1 && !found; j++)
109 {
110 regress_lseg_construct(&seg2, &p2->p[j], &p2->p[j + 1]);
111 if (DatumGetBool(DirectFunctionCall2(lseg_intersect,
112 LsegPGetDatum(&seg1),
113 LsegPGetDatum(&seg2))))
114 found = true;
115 }
116 }
117
118 if (!found)
119 PG_RETURN_NULL();
120
121 /*
122 * Note: DirectFunctionCall2 will kick out an error if lseg_interpt()
123 * returns NULL, but that should be impossible since we know the two
124 * segments intersect.
125 */
126 PG_RETURN_DATUM(DirectFunctionCall2(lseg_interpt,
127 LsegPGetDatum(&seg1),
128 LsegPGetDatum(&seg2)));
129}
130
131
132/* like lseg_construct, but assume space already allocated */
133static void
134 regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2)
135{
136 lseg->p[0].x = pt1->x;
137 lseg->p[0].y = pt1->y;
138 lseg->p[1].x = pt2->x;
139 lseg->p[1].y = pt2->y;
140}
141
142 PG_FUNCTION_INFO_V1(overpaid);
143
144Datum
145 overpaid(PG_FUNCTION_ARGS)
146{
147 HeapTupleHeader tuple = PG_GETARG_HEAPTUPLEHEADER(0);
148 bool isnull;
149 int32 salary;
150
151 salary = DatumGetInt32(GetAttributeByName(tuple, "salary", &isnull));
152 if (isnull)
153 PG_RETURN_NULL();
154 PG_RETURN_BOOL(salary > 699);
155}
156
157/* New type "widget"
158 * This used to be "circle", but I added circle to builtins,
159 * so needed to make sure the names do not collide. - tgl 97/04/21
160 */
161
162 typedef struct
163{
164 Point center;
165 double radius;
166} WIDGET;
167
168 PG_FUNCTION_INFO_V1(widget_in);
169 PG_FUNCTION_INFO_V1(widget_out);
170
171 #define NARGS 3
172
173Datum
174 widget_in(PG_FUNCTION_ARGS)
175{
176 char *str = PG_GETARG_CSTRING(0);
177 char *p,
178 *coord[NARGS];
179 int i;
180 WIDGET *result;
181
182 for (i = 0, p = str; *p && i < NARGS && *p != RDELIM; p++)
183 {
184 if (*p == DELIM || (*p == LDELIM && i == 0))
185 coord[i++] = p + 1;
186 }
187
188 /*
189 * Note: DON'T convert this error to "soft" style (errsave/ereturn). We
190 * want this data type to stay permanently in the hard-error world so that
191 * it can be used for testing that such cases still work reasonably.
192 */
193 if (i < NARGS)
194 ereport(ERROR,
195 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
196 errmsg("invalid input syntax for type %s: \"%s\"",
197 "widget", str)));
198
199 result = (WIDGET *) palloc(sizeof(WIDGET));
200 result->center.x = atof(coord[0]);
201 result->center.y = atof(coord[1]);
202 result->radius = atof(coord[2]);
203
204 PG_RETURN_POINTER(result);
205}
206
207Datum
208 widget_out(PG_FUNCTION_ARGS)
209{
210 WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(0);
211 char *str = psprintf("(%g,%g,%g)",
212 widget->center.x, widget->center.y, widget->radius);
213
214 PG_RETURN_CSTRING(str);
215}
216
217 PG_FUNCTION_INFO_V1(pt_in_widget);
218
219Datum
220 pt_in_widget(PG_FUNCTION_ARGS)
221{
222 Point *point = PG_GETARG_POINT_P(0);
223 WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(1);
224 float8 distance;
225
226 distance = DatumGetFloat8(DirectFunctionCall2(point_distance,
227 PointPGetDatum(point),
228 PointPGetDatum(&widget->center)));
229
230 PG_RETURN_BOOL(distance < widget->radius);
231}
232
233 PG_FUNCTION_INFO_V1(reverse_name);
234
235Datum
236 reverse_name(PG_FUNCTION_ARGS)
237{
238 char *string = PG_GETARG_CSTRING(0);
239 int i;
240 int len;
241 char *new_string;
242
243 new_string = palloc0(NAMEDATALEN);
244 for (i = 0; i < NAMEDATALEN && string[i]; ++i)
245 ;
246 if (i == NAMEDATALEN || !string[i])
247 --i;
248 len = i;
249 for (; i >= 0; --i)
250 new_string[len - i] = string[i];
251 PG_RETURN_CSTRING(new_string);
252}
253
254 PG_FUNCTION_INFO_V1(trigger_return_old);
255
256Datum
257 trigger_return_old(PG_FUNCTION_ARGS)
258{
259 TriggerData *trigdata = (TriggerData *) fcinfo->context;
260 HeapTuple tuple;
261
262 if (!CALLED_AS_TRIGGER(fcinfo))
263 elog(ERROR, "trigger_return_old: not fired by trigger manager");
264
265 tuple = trigdata->tg_trigtuple;
266
267 return PointerGetDatum(tuple);
268}
269
270
271/*
272 * Type int44 has no real-world use, but the regression tests use it
273 * (under the alias "city_budget"). It's a four-element vector of int4's.
274 */
275
276/*
277 * int44in - converts "num, num, ..." to internal form
278 *
279 * Note: Fills any missing positions with zeroes.
280 */
281 PG_FUNCTION_INFO_V1(int44in);
282
283Datum
284 int44in(PG_FUNCTION_ARGS)
285{
286 char *input_string = PG_GETARG_CSTRING(0);
287 int32 *result = (int32 *) palloc(4 * sizeof(int32));
288 int i;
289
290 i = sscanf(input_string,
291 "%d, %d, %d, %d",
292 &result[0],
293 &result[1],
294 &result[2],
295 &result[3]);
296 while (i < 4)
297 result[i++] = 0;
298
299 PG_RETURN_POINTER(result);
300}
301
302/*
303 * int44out - converts internal form to "num, num, ..."
304 */
305 PG_FUNCTION_INFO_V1(int44out);
306
307Datum
308 int44out(PG_FUNCTION_ARGS)
309{
310 int32 *an_array = (int32 *) PG_GETARG_POINTER(0);
311 char *result = (char *) palloc(16 * 4);
312
313 snprintf(result, 16 * 4, "%d,%d,%d,%d",
314 an_array[0],
315 an_array[1],
316 an_array[2],
317 an_array[3]);
318
319 PG_RETURN_CSTRING(result);
320}
321
322 PG_FUNCTION_INFO_V1(test_canonicalize_path);
323Datum
324 test_canonicalize_path(PG_FUNCTION_ARGS)
325{
326 char *path = text_to_cstring(PG_GETARG_TEXT_PP(0));
327
328 canonicalize_path(path);
329 PG_RETURN_TEXT_P(cstring_to_text(path));
330}
331
332 PG_FUNCTION_INFO_V1(make_tuple_indirect);
333Datum
334 make_tuple_indirect(PG_FUNCTION_ARGS)
335{
336 HeapTupleHeader rec = PG_GETARG_HEAPTUPLEHEADER(0);
337 HeapTupleData tuple;
338 int ncolumns;
339 Datum *values;
340 bool *nulls;
341
342 Oid tupType;
343 int32 tupTypmod;
344 TupleDesc tupdesc;
345
346 HeapTuple newtup;
347
348 int i;
349
350 MemoryContext old_context;
351
352 /* Extract type info from the tuple itself */
353 tupType = HeapTupleHeaderGetTypeId(rec);
354 tupTypmod = HeapTupleHeaderGetTypMod(rec);
355 tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
356 ncolumns = tupdesc->natts;
357
358 /* Build a temporary HeapTuple control structure */
359 tuple.t_len = HeapTupleHeaderGetDatumLength(rec);
360 ItemPointerSetInvalid(&(tuple.t_self));
361 tuple.t_tableOid = InvalidOid;
362 tuple.t_data = rec;
363
364 values = (Datum *) palloc(ncolumns * sizeof(Datum));
365 nulls = (bool *) palloc(ncolumns * sizeof(bool));
366
367 heap_deform_tuple(&tuple, tupdesc, values, nulls);
368
369 old_context = MemoryContextSwitchTo(TopTransactionContext);
370
371 for (i = 0; i < ncolumns; i++)
372 {
373 struct varlena *attr;
374 struct varlena *new_attr;
375 struct varatt_indirect redirect_pointer;
376
377 /* only work on existing, not-null varlenas */
378 if (TupleDescAttr(tupdesc, i)->attisdropped ||
379 nulls[i] ||
380 TupleDescAttr(tupdesc, i)->attlen != -1 ||
381 TupleDescAttr(tupdesc, i)->attstorage == TYPSTORAGE_PLAIN)
382 continue;
383
384 attr = (struct varlena *) DatumGetPointer(values[i]);
385
386 /* don't recursively indirect */
387 if (VARATT_IS_EXTERNAL_INDIRECT(attr))
388 continue;
389
390 /* copy datum, so it still lives later */
391 if (VARATT_IS_EXTERNAL_ONDISK(attr))
392 attr = detoast_external_attr(attr);
393 else
394 {
395 struct varlena *oldattr = attr;
396
397 attr = palloc0(VARSIZE_ANY(oldattr));
398 memcpy(attr, oldattr, VARSIZE_ANY(oldattr));
399 }
400
401 /* build indirection Datum */
402 new_attr = (struct varlena *) palloc0(INDIRECT_POINTER_SIZE);
403 redirect_pointer.pointer = attr;
404 SET_VARTAG_EXTERNAL(new_attr, VARTAG_INDIRECT);
405 memcpy(VARDATA_EXTERNAL(new_attr), &redirect_pointer,
406 sizeof(redirect_pointer));
407
408 values[i] = PointerGetDatum(new_attr);
409 }
410
411 newtup = heap_form_tuple(tupdesc, values, nulls);
412 pfree(values);
413 pfree(nulls);
414 ReleaseTupleDesc(tupdesc);
415
416 MemoryContextSwitchTo(old_context);
417
418 /*
419 * We intentionally don't use PG_RETURN_HEAPTUPLEHEADER here, because that
420 * would cause the indirect toast pointers to be flattened out of the
421 * tuple immediately, rendering subsequent testing irrelevant. So just
422 * return the HeapTupleHeader pointer as-is. This violates the general
423 * rule that composite Datums shouldn't contain toast pointers, but so
424 * long as the regression test scripts don't insert the result of this
425 * function into a container type (record, array, etc) it should be OK.
426 */
427 PG_RETURN_POINTER(newtup->t_data);
428}
429
430 PG_FUNCTION_INFO_V1(get_environ);
431
432Datum
433 get_environ(PG_FUNCTION_ARGS)
434{
435#if !defined(WIN32) || defined(_MSC_VER)
436 extern char **environ;
437#endif
438 int nvals = 0;
439 ArrayType *result;
440 Datum *env;
441
442 for (char **s = environ; *s; s++)
443 nvals++;
444
445 env = palloc(nvals * sizeof(Datum));
446
447 for (int i = 0; i < nvals; i++)
448 env[i] = CStringGetTextDatum(environ[i]);
449
450 result = construct_array_builtin(env, nvals, TEXTOID);
451
452 PG_RETURN_POINTER(result);
453}
454
455 PG_FUNCTION_INFO_V1(regress_setenv);
456
457Datum
458 regress_setenv(PG_FUNCTION_ARGS)
459{
460 char *envvar = text_to_cstring(PG_GETARG_TEXT_PP(0));
461 char *envval = text_to_cstring(PG_GETARG_TEXT_PP(1));
462
463 if (!superuser())
464 elog(ERROR, "must be superuser to change environment variables");
465
466 if (setenv(envvar, envval, 1) != 0)
467 elog(ERROR, "could not set environment variable: %m");
468
469 PG_RETURN_VOID();
470}
471
472/* Sleep until no process has a given PID. */
473 PG_FUNCTION_INFO_V1(wait_pid);
474
475Datum
476 wait_pid(PG_FUNCTION_ARGS)
477{
478 int pid = PG_GETARG_INT32(0);
479
480 if (!superuser())
481 elog(ERROR, "must be superuser to check PID liveness");
482
483 while (kill(pid, 0) == 0)
484 {
485 CHECK_FOR_INTERRUPTS();
486 pg_usleep(50000);
487 }
488
489 if (errno != ESRCH)
490 elog(ERROR, "could not check PID %d liveness: %m", pid);
491
492 PG_RETURN_VOID();
493}
494
495static void
496 test_atomic_flag(void)
497{
498 pg_atomic_flag flag;
499
500 pg_atomic_init_flag(&flag);
501 EXPECT_TRUE(pg_atomic_unlocked_test_flag(&flag));
502 EXPECT_TRUE(pg_atomic_test_set_flag(&flag));
503 EXPECT_TRUE(!pg_atomic_unlocked_test_flag(&flag));
504 EXPECT_TRUE(!pg_atomic_test_set_flag(&flag));
505 pg_atomic_clear_flag(&flag);
506 EXPECT_TRUE(pg_atomic_unlocked_test_flag(&flag));
507 EXPECT_TRUE(pg_atomic_test_set_flag(&flag));
508 pg_atomic_clear_flag(&flag);
509}
510
511static void
512 test_atomic_uint32(void)
513{
514 pg_atomic_uint32 var;
515 uint32 expected;
516 int i;
517
518 pg_atomic_init_u32(&var, 0);
519 EXPECT_EQ_U32(pg_atomic_read_u32(&var), 0);
520 pg_atomic_write_u32(&var, 3);
521 EXPECT_EQ_U32(pg_atomic_read_u32(&var), 3);
522 EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, pg_atomic_read_u32(&var) - 2),
523 3);
524 EXPECT_EQ_U32(pg_atomic_fetch_sub_u32(&var, 1), 4);
525 EXPECT_EQ_U32(pg_atomic_sub_fetch_u32(&var, 3), 0);
526 EXPECT_EQ_U32(pg_atomic_add_fetch_u32(&var, 10), 10);
527 EXPECT_EQ_U32(pg_atomic_exchange_u32(&var, 5), 10);
528 EXPECT_EQ_U32(pg_atomic_exchange_u32(&var, 0), 5);
529
530 /* test around numerical limits */
531 EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, INT_MAX), 0);
532 EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, INT_MAX), INT_MAX);
533 pg_atomic_fetch_add_u32(&var, 2); /* wrap to 0 */
534 EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, PG_INT16_MAX), 0);
535 EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, PG_INT16_MAX + 1),
536 PG_INT16_MAX);
537 EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, PG_INT16_MIN),
538 2 * PG_INT16_MAX + 1);
539 EXPECT_EQ_U32(pg_atomic_fetch_add_u32(&var, PG_INT16_MIN - 1),
540 PG_INT16_MAX);
541 pg_atomic_fetch_add_u32(&var, 1); /* top up to UINT_MAX */
542 EXPECT_EQ_U32(pg_atomic_read_u32(&var), UINT_MAX);
543 EXPECT_EQ_U32(pg_atomic_fetch_sub_u32(&var, INT_MAX), UINT_MAX);
544 EXPECT_EQ_U32(pg_atomic_read_u32(&var), (uint32) INT_MAX + 1);
545 EXPECT_EQ_U32(pg_atomic_sub_fetch_u32(&var, INT_MAX), 1);
546 pg_atomic_sub_fetch_u32(&var, 1);
547 expected = PG_INT16_MAX;
548 EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
549 expected = PG_INT16_MAX + 1;
550 EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
551 expected = PG_INT16_MIN;
552 EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
553 expected = PG_INT16_MIN - 1;
554 EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
555
556 /* fail exchange because of old expected */
557 expected = 10;
558 EXPECT_TRUE(!pg_atomic_compare_exchange_u32(&var, &expected, 1));
559
560 /* CAS is allowed to fail due to interrupts, try a couple of times */
561 for (i = 0; i < 1000; i++)
562 {
563 expected = 0;
564 if (!pg_atomic_compare_exchange_u32(&var, &expected, 1))
565 break;
566 }
567 if (i == 1000)
568 elog(ERROR, "atomic_compare_exchange_u32() never succeeded");
569 EXPECT_EQ_U32(pg_atomic_read_u32(&var), 1);
570 pg_atomic_write_u32(&var, 0);
571
572 /* try setting flagbits */
573 EXPECT_TRUE(!(pg_atomic_fetch_or_u32(&var, 1) & 1));
574 EXPECT_TRUE(pg_atomic_fetch_or_u32(&var, 2) & 1);
575 EXPECT_EQ_U32(pg_atomic_read_u32(&var), 3);
576 /* try clearing flagbits */
577 EXPECT_EQ_U32(pg_atomic_fetch_and_u32(&var, ~2) & 3, 3);
578 EXPECT_EQ_U32(pg_atomic_fetch_and_u32(&var, ~1), 1);
579 /* no bits set anymore */
580 EXPECT_EQ_U32(pg_atomic_fetch_and_u32(&var, ~0), 0);
581}
582
583static void
584 test_atomic_uint64(void)
585{
586 pg_atomic_uint64 var;
587 uint64 expected;
588 int i;
589
590 pg_atomic_init_u64(&var, 0);
591 EXPECT_EQ_U64(pg_atomic_read_u64(&var), 0);
592 pg_atomic_write_u64(&var, 3);
593 EXPECT_EQ_U64(pg_atomic_read_u64(&var), 3);
594 EXPECT_EQ_U64(pg_atomic_fetch_add_u64(&var, pg_atomic_read_u64(&var) - 2),
595 3);
596 EXPECT_EQ_U64(pg_atomic_fetch_sub_u64(&var, 1), 4);
597 EXPECT_EQ_U64(pg_atomic_sub_fetch_u64(&var, 3), 0);
598 EXPECT_EQ_U64(pg_atomic_add_fetch_u64(&var, 10), 10);
599 EXPECT_EQ_U64(pg_atomic_exchange_u64(&var, 5), 10);
600 EXPECT_EQ_U64(pg_atomic_exchange_u64(&var, 0), 5);
601
602 /* fail exchange because of old expected */
603 expected = 10;
604 EXPECT_TRUE(!pg_atomic_compare_exchange_u64(&var, &expected, 1));
605
606 /* CAS is allowed to fail due to interrupts, try a couple of times */
607 for (i = 0; i < 100; i++)
608 {
609 expected = 0;
610 if (!pg_atomic_compare_exchange_u64(&var, &expected, 1))
611 break;
612 }
613 if (i == 100)
614 elog(ERROR, "atomic_compare_exchange_u64() never succeeded");
615 EXPECT_EQ_U64(pg_atomic_read_u64(&var), 1);
616
617 pg_atomic_write_u64(&var, 0);
618
619 /* try setting flagbits */
620 EXPECT_TRUE(!(pg_atomic_fetch_or_u64(&var, 1) & 1));
621 EXPECT_TRUE(pg_atomic_fetch_or_u64(&var, 2) & 1);
622 EXPECT_EQ_U64(pg_atomic_read_u64(&var), 3);
623 /* try clearing flagbits */
624 EXPECT_EQ_U64((pg_atomic_fetch_and_u64(&var, ~2) & 3), 3);
625 EXPECT_EQ_U64(pg_atomic_fetch_and_u64(&var, ~1), 1);
626 /* no bits set anymore */
627 EXPECT_EQ_U64(pg_atomic_fetch_and_u64(&var, ~0), 0);
628}
629
630/*
631 * Perform, fairly minimal, testing of the spinlock implementation.
632 *
633 * It's likely worth expanding these to actually test concurrency etc, but
634 * having some regularly run tests is better than none.
635 */
636static void
637 test_spinlock(void)
638{
639 /*
640 * Basic tests for spinlocks, as well as the underlying operations.
641 *
642 * We embed the spinlock in a struct with other members to test that the
643 * spinlock operations don't perform too wide writes.
644 */
645 {
646 struct test_lock_struct
647 {
648 char data_before[4];
649 slock_t lock;
650 char data_after[4];
651 } struct_w_lock;
652
653 memcpy(struct_w_lock.data_before, "abcd", 4);
654 memcpy(struct_w_lock.data_after, "ef12", 4);
655
656 /* test basic operations via the SpinLock* API */
657 SpinLockInit(&struct_w_lock.lock);
658 SpinLockAcquire(&struct_w_lock.lock);
659 SpinLockRelease(&struct_w_lock.lock);
660
661 /* test basic operations via underlying S_* API */
662 S_INIT_LOCK(&struct_w_lock.lock);
663 S_LOCK(&struct_w_lock.lock);
664 S_UNLOCK(&struct_w_lock.lock);
665
666 /* and that "contended" acquisition works */
667 s_lock(&struct_w_lock.lock, "testfile", 17, "testfunc");
668 S_UNLOCK(&struct_w_lock.lock);
669
670 /*
671 * Check, using TAS directly, that a single spin cycle doesn't block
672 * when acquiring an already acquired lock.
673 */
674#ifdef TAS
675 S_LOCK(&struct_w_lock.lock);
676
677 if (!TAS(&struct_w_lock.lock))
678 elog(ERROR, "acquired already held spinlock");
679
680#ifdef TAS_SPIN
681 if (!TAS_SPIN(&struct_w_lock.lock))
682 elog(ERROR, "acquired already held spinlock");
683#endif /* defined(TAS_SPIN) */
684
685 S_UNLOCK(&struct_w_lock.lock);
686#endif /* defined(TAS) */
687
688 /*
689 * Verify that after all of this the non-lock contents are still
690 * correct.
691 */
692 if (memcmp(struct_w_lock.data_before, "abcd", 4) != 0)
693 elog(ERROR, "padding before spinlock modified");
694 if (memcmp(struct_w_lock.data_after, "ef12", 4) != 0)
695 elog(ERROR, "padding after spinlock modified");
696 }
697}
698
699 PG_FUNCTION_INFO_V1(test_atomic_ops);
700Datum
701 test_atomic_ops(PG_FUNCTION_ARGS)
702{
703 test_atomic_flag();
704
705 test_atomic_uint32();
706
707 test_atomic_uint64();
708
709 /*
710 * Arguably this shouldn't be tested as part of this function, but it's
711 * closely enough related that that seems ok for now.
712 */
713 test_spinlock();
714
715 PG_RETURN_BOOL(true);
716}
717
718 PG_FUNCTION_INFO_V1(test_fdw_handler);
719Datum
720 test_fdw_handler(PG_FUNCTION_ARGS)
721{
722 elog(ERROR, "test_fdw_handler is not implemented");
723 PG_RETURN_NULL();
724}
725
726 PG_FUNCTION_INFO_V1(is_catalog_text_unique_index_oid);
727Datum
728 is_catalog_text_unique_index_oid(PG_FUNCTION_ARGS)
729{
730 return BoolGetDatum(IsCatalogTextUniqueIndexOid(PG_GETARG_OID(0)));
731}
732
733 PG_FUNCTION_INFO_V1(test_support_func);
734Datum
735 test_support_func(PG_FUNCTION_ARGS)
736{
737 Node *rawreq = (Node *) PG_GETARG_POINTER(0);
738 Node *ret = NULL;
739
740 if (IsA(rawreq, SupportRequestSelectivity))
741 {
742 /*
743 * Assume that the target is int4eq; that's safe as long as we don't
744 * attach this to any other boolean-returning function.
745 */
746 SupportRequestSelectivity *req = (SupportRequestSelectivity *) rawreq;
747 Selectivity s1;
748
749 if (req->is_join)
750 s1 = join_selectivity(req->root, Int4EqualOperator,
751 req->args,
752 req->inputcollid,
753 req->jointype,
754 req->sjinfo);
755 else
756 s1 = restriction_selectivity(req->root, Int4EqualOperator,
757 req->args,
758 req->inputcollid,
759 req->varRelid);
760
761 req->selectivity = s1;
762 ret = (Node *) req;
763 }
764
765 if (IsA(rawreq, SupportRequestCost))
766 {
767 /* Provide some generic estimate */
768 SupportRequestCost *req = (SupportRequestCost *) rawreq;
769
770 req->startup = 0;
771 req->per_tuple = 2 * cpu_operator_cost;
772 ret = (Node *) req;
773 }
774
775 if (IsA(rawreq, SupportRequestRows))
776 {
777 /*
778 * Assume that the target is generate_series_int4; that's safe as long
779 * as we don't attach this to any other set-returning function.
780 */
781 SupportRequestRows *req = (SupportRequestRows *) rawreq;
782
783 if (req->node && IsA(req->node, FuncExpr)) /* be paranoid */
784 {
785 List *args = ((FuncExpr *) req->node)->args;
786 Node *arg1 = linitial(args);
787 Node *arg2 = lsecond(args);
788
789 if (IsA(arg1, Const) &&
790 !((Const *) arg1)->constisnull &&
791 IsA(arg2, Const) &&
792 !((Const *) arg2)->constisnull)
793 {
794 int32 val1 = DatumGetInt32(((Const *) arg1)->constvalue);
795 int32 val2 = DatumGetInt32(((Const *) arg2)->constvalue);
796
797 req->rows = val2 - val1 + 1;
798 ret = (Node *) req;
799 }
800 }
801 }
802
803 PG_RETURN_POINTER(ret);
804}
805
806 PG_FUNCTION_INFO_V1(test_opclass_options_func);
807Datum
808 test_opclass_options_func(PG_FUNCTION_ARGS)
809{
810 PG_RETURN_NULL();
811}
812
813/* one-time tests for encoding infrastructure */
814 PG_FUNCTION_INFO_V1(test_enc_setup);
815Datum
816 test_enc_setup(PG_FUNCTION_ARGS)
817{
818 /* Test pg_encoding_set_invalid() */
819 for (int i = 0; i < _PG_LAST_ENCODING_; i++)
820 {
821 char buf[2],
822 bigbuf[16];
823 int len,
824 mblen,
825 valid;
826
827 if (pg_encoding_max_length(i) == 1)
828 continue;
829 pg_encoding_set_invalid(i, buf);
830 len = strnlen(buf, 2);
831 if (len != 2)
832 elog(WARNING,
833 "official invalid string for encoding \"%s\" has length %d",
834 pg_enc2name_tbl[i].name, len);
835 mblen = pg_encoding_mblen(i, buf);
836 if (mblen != 2)
837 elog(WARNING,
838 "official invalid string for encoding \"%s\" has mblen %d",
839 pg_enc2name_tbl[i].name, mblen);
840 valid = pg_encoding_verifymbstr(i, buf, len);
841 if (valid != 0)
842 elog(WARNING,
843 "official invalid string for encoding \"%s\" has valid prefix of length %d",
844 pg_enc2name_tbl[i].name, valid);
845 valid = pg_encoding_verifymbstr(i, buf, 1);
846 if (valid != 0)
847 elog(WARNING,
848 "first byte of official invalid string for encoding \"%s\" has valid prefix of length %d",
849 pg_enc2name_tbl[i].name, valid);
850 memset(bigbuf, ' ', sizeof(bigbuf));
851 bigbuf[0] = buf[0];
852 bigbuf[1] = buf[1];
853 valid = pg_encoding_verifymbstr(i, bigbuf, sizeof(bigbuf));
854 if (valid != 0)
855 elog(WARNING,
856 "trailing data changed official invalid string for encoding \"%s\" to have valid prefix of length %d",
857 pg_enc2name_tbl[i].name, valid);
858 }
859
860 PG_RETURN_VOID();
861}
862
863/*
864 * Call an encoding conversion or verification function.
865 *
866 * Arguments:
867 * string bytea -- string to convert
868 * src_enc name -- source encoding
869 * dest_enc name -- destination encoding
870 * noError bool -- if set, don't ereport() on invalid or untranslatable
871 * input
872 *
873 * Result is a tuple with two attributes:
874 * int4 -- number of input bytes successfully converted
875 * bytea -- converted string
876 */
877 PG_FUNCTION_INFO_V1(test_enc_conversion);
878Datum
879 test_enc_conversion(PG_FUNCTION_ARGS)
880{
881 bytea *string = PG_GETARG_BYTEA_PP(0);
882 char *src_encoding_name = NameStr(*PG_GETARG_NAME(1));
883 int src_encoding = pg_char_to_encoding(src_encoding_name);
884 char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2));
885 int dest_encoding = pg_char_to_encoding(dest_encoding_name);
886 bool noError = PG_GETARG_BOOL(3);
887 TupleDesc tupdesc;
888 char *src;
889 char *dst;
890 bytea *retval;
891 Size srclen;
892 Size dstsize;
893 Oid proc;
894 int convertedbytes;
895 int dstlen;
896 Datum values[2];
897 bool nulls[2] = {0};
898 HeapTuple tuple;
899
900 if (src_encoding < 0)
901 ereport(ERROR,
902 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
903 errmsg("invalid source encoding name \"%s\"",
904 src_encoding_name)));
905 if (dest_encoding < 0)
906 ereport(ERROR,
907 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
908 errmsg("invalid destination encoding name \"%s\"",
909 dest_encoding_name)));
910
911 /* Build a tuple descriptor for our result type */
912 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
913 elog(ERROR, "return type must be a row type");
914 tupdesc = BlessTupleDesc(tupdesc);
915
916 srclen = VARSIZE_ANY_EXHDR(string);
917 src = VARDATA_ANY(string);
918
919 if (src_encoding == dest_encoding)
920 {
921 /* just check that the source string is valid */
922 int oklen;
923
924 oklen = pg_encoding_verifymbstr(src_encoding, src, srclen);
925
926 if (oklen == srclen)
927 {
928 convertedbytes = oklen;
929 retval = string;
930 }
931 else if (!noError)
932 {
933 report_invalid_encoding(src_encoding, src + oklen, srclen - oklen);
934 }
935 else
936 {
937 /*
938 * build bytea data type structure.
939 */
940 Assert(oklen < srclen);
941 convertedbytes = oklen;
942 retval = (bytea *) palloc(oklen + VARHDRSZ);
943 SET_VARSIZE(retval, oklen + VARHDRSZ);
944 memcpy(VARDATA(retval), src, oklen);
945 }
946 }
947 else
948 {
949 proc = FindDefaultConversionProc(src_encoding, dest_encoding);
950 if (!OidIsValid(proc))
951 ereport(ERROR,
952 (errcode(ERRCODE_UNDEFINED_FUNCTION),
953 errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
954 pg_encoding_to_char(src_encoding),
955 pg_encoding_to_char(dest_encoding))));
956
957 if (srclen >= (MaxAllocSize / (Size) MAX_CONVERSION_GROWTH))
958 ereport(ERROR,
959 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
960 errmsg("out of memory"),
961 errdetail("String of %d bytes is too long for encoding conversion.",
962 (int) srclen)));
963
964 dstsize = (Size) srclen * MAX_CONVERSION_GROWTH + 1;
965 dst = MemoryContextAlloc(CurrentMemoryContext, dstsize);
966
967 /* perform conversion */
968 convertedbytes = pg_do_encoding_conversion_buf(proc,
969 src_encoding,
970 dest_encoding,
971 (unsigned char *) src, srclen,
972 (unsigned char *) dst, dstsize,
973 noError);
974 dstlen = strlen(dst);
975
976 /*
977 * build bytea data type structure.
978 */
979 retval = (bytea *) palloc(dstlen + VARHDRSZ);
980 SET_VARSIZE(retval, dstlen + VARHDRSZ);
981 memcpy(VARDATA(retval), dst, dstlen);
982
983 pfree(dst);
984 }
985
986 values[0] = Int32GetDatum(convertedbytes);
987 values[1] = PointerGetDatum(retval);
988 tuple = heap_form_tuple(tupdesc, values, nulls);
989
990 PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
991}
992
993/* Provide SQL access to IsBinaryCoercible() */
994 PG_FUNCTION_INFO_V1(binary_coercible);
995Datum
996 binary_coercible(PG_FUNCTION_ARGS)
997{
998 Oid srctype = PG_GETARG_OID(0);
999 Oid targettype = PG_GETARG_OID(1);
1000
1001 PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
1002}
1003
1004/*
1005 * Sanity checks for functions in relpath.h
1006 */
1007 PG_FUNCTION_INFO_V1(test_relpath);
1008Datum
1009 test_relpath(PG_FUNCTION_ARGS)
1010{
1011 RelPathStr rpath;
1012
1013 /*
1014 * Verify that PROCNUMBER_CHARS and MAX_BACKENDS stay in sync.
1015 * Unfortunately I don't know how to express that in a way suitable for a
1016 * static assert.
1017 */
1018 if ((int) ceil(log10(MAX_BACKENDS)) != PROCNUMBER_CHARS)
1019 elog(WARNING, "mismatch between MAX_BACKENDS and PROCNUMBER_CHARS");
1020
1021 /* verify that the max-length relpath is generated ok */
1022 rpath = GetRelationPath(OID_MAX, OID_MAX, OID_MAX, MAX_BACKENDS - 1,
1023 INIT_FORKNUM);
1024
1025 if (strlen(rpath.str) != REL_PATH_STR_MAXLEN)
1026 elog(WARNING, "maximum length relpath is if length %zu instead of %zu",
1027 strlen(rpath.str), REL_PATH_STR_MAXLEN);
1028
1029 PG_RETURN_VOID();
1030}
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
Definition: arrayfuncs.c:3381
static uint32 pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_)
Definition: atomics.h:394
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
Definition: atomics.h:347
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition: atomics.h:483
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:408
static uint32 pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition: atomics.h:437
static uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
Definition: atomics.h:379
static bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
Definition: atomics.h:510
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:364
static uint32 pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition: atomics.h:422
static uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition: atomics.h:520
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:566
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:539
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:548
static uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition: atomics.h:557
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
Definition: atomics.h:328
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition: atomics.h:451
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
Definition: atomics.h:465
static uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
Definition: atomics.h:529
static uint64 pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval)
Definition: atomics.h:501
static void pg_atomic_init_flag(volatile pg_atomic_flag *ptr)
Definition: atomics.h:168
static Datum values[MAXATTR]
Definition: bootstrap.c:153
#define CStringGetTextDatum(s)
Definition: builtins.h:97
#define NameStr(name)
Definition: c.h:751
#define VARHDRSZ
Definition: c.h:697
double float8
Definition: c.h:635
#define PG_INT16_MIN
Definition: c.h:590
int32_t int32
Definition: c.h:534
uint64_t uint64
Definition: c.h:539
uint32_t uint32
Definition: c.h:538
#define PG_INT16_MAX
Definition: c.h:591
#define OidIsValid(objectId)
Definition: c.h:774
size_t Size
Definition: c.h:610
bool IsCatalogTextUniqueIndexOid(Oid relid)
Definition: catalog.c:156
double cpu_operator_cost
Definition: costsize.c:134
struct varlena * detoast_external_attr(struct varlena *attr)
Definition: detoast.c:45
#define INDIRECT_POINTER_SIZE
Definition: detoast.h:34
int errdetail(const char *fmt,...)
Definition: elog.c:1207
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define WARNING
Definition: elog.h:36
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
#define ereport(elevel,...)
Definition: elog.h:150
const pg_enc2name pg_enc2name_tbl[]
Definition: encnames.c:308
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2260
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
Definition: execUtils.c:1061
#define MaxAllocSize
Definition: fe_memutils.h:22
#define PG_RETURN_VOID()
Definition: fmgr.h:349
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
#define PG_GETARG_BYTEA_PP(n)
Definition: fmgr.h:308
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:684
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_RETURN_CSTRING(x)
Definition: fmgr.h:362
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:277
#define PG_RETURN_NULL()
Definition: fmgr.h:345
#define PG_GETARG_NAME(n)
Definition: fmgr.h:278
#define PG_GETARG_HEAPTUPLEHEADER(n)
Definition: fmgr.h:312
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
#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:353
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
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
#define PG_GETARG_POINT_P(n)
Definition: geo_decls.h:185
static Datum LsegPGetDatum(const LSEG *X)
Definition: geo_decls.h:194
static Datum PointPGetDatum(const Point *X)
Definition: geo_decls.h:181
#define PG_GETARG_PATH_P(n)
Definition: geo_decls.h:216
Datum point_distance(PG_FUNCTION_ARGS)
Definition: geo_ops.c:1993
Datum lseg_intersect(PG_FUNCTION_ARGS)
Definition: geo_ops.c:2188
Datum lseg_interpt(PG_FUNCTION_ARGS)
Definition: geo_ops.c:2361
Assert(PointerIsAligned(start, uint64))
const char * str
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition: heaptuple.c:1117
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1346
static int32 HeapTupleHeaderGetTypMod(const HeapTupleHeaderData *tup)
Definition: htup_details.h:516
static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)
Definition: htup_details.h:492
static Oid HeapTupleHeaderGetTypeId(const HeapTupleHeaderData *tup)
Definition: htup_details.h:504
j
int j
Definition: isn.c:78
i
int i
Definition: isn.c:77
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:81
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Definition: itemptr.h:184
int pg_do_encoding_conversion_buf(Oid proc, int src_encoding, int dest_encoding, unsigned char *src, int srclen, unsigned char *dest, int destlen, bool noError)
Definition: mbutils.c:470
void report_invalid_encoding(int encoding, const char *mbstr, int len)
Definition: mbutils.c:1699
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:1229
MemoryContext TopTransactionContext
Definition: mcxt.c:171
void pfree(void *pointer)
Definition: mcxt.c:1594
void * palloc0(Size size)
Definition: mcxt.c:1395
void * palloc(Size size)
Definition: mcxt.c:1365
MemoryContext CurrentMemoryContext
Definition: mcxt.c:160
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:122
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:4150
#define IsA(nodeptr, _type_)
Definition: nodes.h:164
double Selectivity
Definition: nodes.h:260
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
bool IsBinaryCoercible(Oid srctype, Oid targettype)
Definition: parse_coerce.c:3030
char attstorage
Definition: pg_attribute.h:108
int16 attlen
Definition: pg_attribute.h:59
#define NAMEDATALEN
const void size_t len
#define linitial(l)
Definition: pg_list.h:178
#define lsecond(l)
Definition: pg_list.h:183
static char * buf
Definition: pg_test_fsync.c:72
#define MAX_CONVERSION_GROWTH
Definition: pg_wchar.h:302
@ _PG_LAST_ENCODING_
Definition: pg_wchar.h:271
#define pg_encoding_to_char
Definition: pg_wchar.h:630
#define pg_char_to_encoding
Definition: pg_wchar.h:629
Selectivity restriction_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, int varRelid)
Definition: plancat.c:2073
Selectivity join_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, JoinType jointype, SpecialJoinInfo *sjinfo)
Definition: plancat.c:2112
void canonicalize_path(char *path)
Definition: path.c:337
#define snprintf
Definition: port.h:239
size_t strnlen(const char *str, size_t maxlen)
Definition: strnlen.c:26
static bool DatumGetBool(Datum X)
Definition: postgres.h:100
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:332
static Datum BoolGetDatum(bool X)
Definition: postgres.h:112
static float8 DatumGetFloat8(Datum X)
Definition: postgres.h:475
uint64_t Datum
Definition: postgres.h:70
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:322
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:222
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:212
#define InvalidOid
Definition: postgres_ext.h:37
unsigned int Oid
Definition: postgres_ext.h:32
#define OID_MAX
Definition: postgres_ext.h:40
char * s1
char string[11]
Definition: preproc-type.c:52
#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:637
#define DELIM
Definition: regress.c:79
#define EXPECT_TRUE(expr)
Definition: regress.c:49
Datum regress_setenv(PG_FUNCTION_ARGS)
Definition: regress.c:458
static void test_atomic_uint32(void)
Definition: regress.c:512
Datum test_relpath(PG_FUNCTION_ARGS)
Definition: regress.c:1009
#define EXPECT_EQ_U32(result_expr, expected_expr)
Definition: regress.c:57
Datum test_atomic_ops(PG_FUNCTION_ARGS)
Definition: regress.c:701
Datum test_support_func(PG_FUNCTION_ARGS)
Definition: regress.c:735
PG_FUNCTION_INFO_V1(interpt_pp)
Datum int44out(PG_FUNCTION_ARGS)
Definition: regress.c:308
Datum test_opclass_options_func(PG_FUNCTION_ARGS)
Definition: regress.c:808
Datum test_fdw_handler(PG_FUNCTION_ARGS)
Definition: regress.c:720
#define EXPECT_EQ_U64(result_expr, expected_expr)
Definition: regress.c:67
Datum interpt_pp(PG_FUNCTION_ARGS)
Definition: regress.c:93
static void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2)
Definition: regress.c:134
Datum trigger_return_old(PG_FUNCTION_ARGS)
Definition: regress.c:257
#define RDELIM
Definition: regress.c:78
Datum int44in(PG_FUNCTION_ARGS)
Definition: regress.c:284
Datum get_environ(PG_FUNCTION_ARGS)
Definition: regress.c:433
Datum test_canonicalize_path(PG_FUNCTION_ARGS)
Definition: regress.c:324
Datum reverse_name(PG_FUNCTION_ARGS)
Definition: regress.c:236
Datum widget_in(PG_FUNCTION_ARGS)
Definition: regress.c:174
PG_MODULE_MAGIC_EXT(.name="regress",.version=PG_VERSION)
Datum wait_pid(PG_FUNCTION_ARGS)
Definition: regress.c:476
Datum widget_out(PG_FUNCTION_ARGS)
Definition: regress.c:208
Datum is_catalog_text_unique_index_oid(PG_FUNCTION_ARGS)
Definition: regress.c:728
static void test_atomic_flag(void)
Definition: regress.c:496
Datum pt_in_widget(PG_FUNCTION_ARGS)
Definition: regress.c:220
Datum test_enc_setup(PG_FUNCTION_ARGS)
Definition: regress.c:816
Datum test_enc_conversion(PG_FUNCTION_ARGS)
Definition: regress.c:879
static void test_atomic_uint64(void)
Definition: regress.c:584
Datum make_tuple_indirect(PG_FUNCTION_ARGS)
Definition: regress.c:334
Datum binary_coercible(PG_FUNCTION_ARGS)
Definition: regress.c:996
#define LDELIM
Definition: regress.c:77
#define NARGS
Definition: regress.c:171
Datum overpaid(PG_FUNCTION_ARGS)
Definition: regress.c:145
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
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:688
#define S_UNLOCK(lock)
Definition: s_lock.h:673
#define TAS_SPIN(lock)
Definition: s_lock.h:692
#define S_INIT_LOCK(lock)
Definition: s_lock.h:677
#define S_LOCK(lock)
Definition: s_lock.h:646
void pg_usleep(long microsec)
Definition: signal.c:53
#define SpinLockInit(lock)
Definition: spin.h:57
#define SpinLockRelease(lock)
Definition: spin.h:61
#define SpinLockAcquire(lock)
Definition: spin.h:59
Definition: array.h:93
Definition: primnodes.h:324
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: geo_decls.h:107
Point p[2]
Definition: geo_decls.h:108
Definition: pg_list.h:54
Definition: nodes.h:135
Definition: geo_decls.h:116
Point p[FLEXIBLE_ARRAY_MEMBER]
Definition: geo_decls.h:121
int32 npts
Definition: geo_decls.h:118
Definition: geo_decls.h:97
float8 y
Definition: geo_decls.h:99
float8 x
Definition: geo_decls.h:98
char str[REL_PATH_STR_MAXLEN+1]
Definition: relpath.h:123
SpecialJoinInfo * sjinfo
Definition: supportnodes.h:103
PlannerInfo * root
Definition: supportnodes.h:96
HeapTuple tg_trigtuple
Definition: trigger.h:36
int natts
Definition: tupdesc.h:137
Definition: regress.c:163
Point center
Definition: regress.c:164
double radius
Definition: regress.c:165
struct varlena * pointer
Definition: varatt.h:59
Definition: c.h:692
bool superuser(void)
Definition: superuser.c:46
char * flag(int b)
Definition: test-ctype.c:33
#define CALLED_AS_TRIGGER(fcinfo)
Definition: trigger.h:26
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:219
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition: tupdesc.h:160
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
Definition: typcache.c:1921
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:181
char * text_to_cstring(const text *t)
Definition: varlena.c:214
const char * name
void pg_encoding_set_invalid(int encoding, char *dst)
Definition: wchar.c:2051
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
Definition: wchar.c:2202
int pg_encoding_max_length(int encoding)
Definition: wchar.c:2213
int pg_encoding_mblen(int encoding, const char *mbstr)
Definition: wchar.c:2135
#define kill(pid, sig)
Definition: win32_port.h:493
#define setenv(x, y, z)
Definition: win32_port.h:545

AltStyle によって変換されたページ (->オリジナル) /