PostgreSQL Source Code git master
Loading...
Searching...
No Matches
test_custom_types.c File Reference
#include "postgres.h"
#include "fmgr.h"
#include "commands/vacuum.h"
#include "utils/builtins.h"
Include dependency graph for test_custom_types.c:

Go to the source code of this file.

Functions

 PG_FUNCTION_INFO_V1 (int_custom_in)
 
 PG_FUNCTION_INFO_V1 (int_custom_out)
 
 PG_FUNCTION_INFO_V1 (int_custom_typanalyze_false)
 
 PG_FUNCTION_INFO_V1 (int_custom_typanalyze_invalid)
 
 PG_FUNCTION_INFO_V1 (int_custom_eq)
 
 PG_FUNCTION_INFO_V1 (int_custom_ne)
 
 PG_FUNCTION_INFO_V1 (int_custom_lt)
 
 PG_FUNCTION_INFO_V1 (int_custom_le)
 
 PG_FUNCTION_INFO_V1 (int_custom_gt)
 
 PG_FUNCTION_INFO_V1 (int_custom_ge)
 
 PG_FUNCTION_INFO_V1 (int_custom_cmp)
 
Datum int_custom_in (PG_FUNCTION_ARGS)
 
Datum int_custom_out (PG_FUNCTION_ARGS)
 
Datum int_custom_typanalyze_false (PG_FUNCTION_ARGS)
 
static void int_custom_invalid_stats (VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)
 
Datum int_custom_typanalyze_invalid (PG_FUNCTION_ARGS)
 
Datum int_custom_eq (PG_FUNCTION_ARGS)
 
Datum int_custom_ne (PG_FUNCTION_ARGS)
 
Datum int_custom_lt (PG_FUNCTION_ARGS)
 
Datum int_custom_le (PG_FUNCTION_ARGS)
 
Datum int_custom_gt (PG_FUNCTION_ARGS)
 
Datum int_custom_ge (PG_FUNCTION_ARGS)
 
Datum int_custom_cmp (PG_FUNCTION_ARGS)
 

Variables

 PG_MODULE_MAGIC
 

Function Documentation

◆ int_custom_cmp()

Datum int_custom_cmp ( PG_FUNCTION_ARGS  )

Definition at line 171 of file test_custom_types.c.

172{
175
176 if (arg1 < arg2)
177 PG_RETURN_INT32(-1);
178 else if (arg1 > arg2)
180 else
182}
int32_t int32
Definition c.h:575
#define PG_RETURN_INT32(x)
Definition fmgr.h:355
#define PG_GETARG_INT32(n)
Definition fmgr.h:269
static int fb(int x)

References fb(), PG_GETARG_INT32, and PG_RETURN_INT32.

◆ int_custom_eq()

Datum int_custom_eq ( PG_FUNCTION_ARGS  )

Definition at line 117 of file test_custom_types.c.

118{
121
123}
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360

References fb(), PG_GETARG_INT32, and PG_RETURN_BOOL.

◆ int_custom_ge()

Datum int_custom_ge ( PG_FUNCTION_ARGS  )

Definition at line 162 of file test_custom_types.c.

163{
166
168}

References fb(), PG_GETARG_INT32, and PG_RETURN_BOOL.

◆ int_custom_gt()

Datum int_custom_gt ( PG_FUNCTION_ARGS  )

Definition at line 153 of file test_custom_types.c.

154{
157
159}

References fb(), PG_GETARG_INT32, and PG_RETURN_BOOL.

◆ int_custom_in()

Datum int_custom_in ( PG_FUNCTION_ARGS  )

Definition at line 45 of file test_custom_types.c.

46{
47 char *num = PG_GETARG_CSTRING(0);
48
49 PG_RETURN_INT32(pg_strtoint32_safe(num, fcinfo->context));
50}
#define PG_GETARG_CSTRING(n)
Definition fmgr.h:278
int32 pg_strtoint32_safe(const char *s, Node *escontext)
Definition numutils.c:388

References PG_GETARG_CSTRING, PG_RETURN_INT32, and pg_strtoint32_safe().

◆ int_custom_invalid_stats()

static void int_custom_invalid_stats ( VacAttrStats stats,
AnalyzeAttrFetchFunc  fetchfunc,
int  samplerows,
double  totalrows 
)
static

Definition at line 82 of file test_custom_types.c.

84{
85 /* We are not valid, and do not want to be. */
86 stats->stats_valid = false;
87}
bool stats_valid
Definition vacuum.h:144

References VacAttrStats::stats_valid.

Referenced by int_custom_typanalyze_invalid().

◆ int_custom_le()

Datum int_custom_le ( PG_FUNCTION_ARGS  )

Definition at line 144 of file test_custom_types.c.

145{
148
150}

References fb(), PG_GETARG_INT32, and PG_RETURN_BOOL.

◆ int_custom_lt()

Datum int_custom_lt ( PG_FUNCTION_ARGS  )

Definition at line 135 of file test_custom_types.c.

136{
139
141}

References fb(), PG_GETARG_INT32, and PG_RETURN_BOOL.

◆ int_custom_ne()

Datum int_custom_ne ( PG_FUNCTION_ARGS  )

Definition at line 126 of file test_custom_types.c.

127{
130
132}

References fb(), PG_GETARG_INT32, and PG_RETURN_BOOL.

◆ int_custom_out()

Datum int_custom_out ( PG_FUNCTION_ARGS  )

Definition at line 58 of file test_custom_types.c.

59{
61 char *result = (char *) palloc(12); /* sign, 10 digits, '\0' */
62
63 pg_ltoa(arg1, result);
64 PG_RETURN_CSTRING(result);
65}
#define PG_RETURN_CSTRING(x)
Definition fmgr.h:364
void * palloc(Size size)
Definition mcxt.c:1387
int pg_ltoa(int32 value, char *a)
Definition numutils.c:1119

References fb(), palloc(), PG_GETARG_INT32, pg_ltoa(), and PG_RETURN_CSTRING.

◆ int_custom_typanalyze_false()

Datum int_custom_typanalyze_false ( PG_FUNCTION_ARGS  )

Definition at line 73 of file test_custom_types.c.

74{
75 PG_RETURN_BOOL(false);
76}

References PG_RETURN_BOOL.

◆ int_custom_typanalyze_invalid()

Datum int_custom_typanalyze_invalid ( PG_FUNCTION_ARGS  )

Definition at line 96 of file test_custom_types.c.

97{
99
100 /* If the attstattarget column is negative, use the default value */
101 if (stats->attstattarget < 0)
103
104 /* Buggy number, no need to care as long as it is positive */
105 stats->minrows = 300;
106
107 /* Set callback to compute some invalid stats */
109
110 PG_RETURN_BOOL(true);
111}
int default_statistics_target
Definition analyze.c:70
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
int minrows
Definition vacuum.h:137
int attstattarget
Definition vacuum.h:125
AnalyzeAttrComputeStatsFunc compute_stats
Definition vacuum.h:136
static void int_custom_invalid_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)

References VacAttrStats::attstattarget, VacAttrStats::compute_stats, default_statistics_target, int_custom_invalid_stats(), VacAttrStats::minrows, PG_GETARG_POINTER, and PG_RETURN_BOOL.

◆ PG_FUNCTION_INFO_V1() [1/11]

PG_FUNCTION_INFO_V1 ( int_custom_cmp  )

◆ PG_FUNCTION_INFO_V1() [2/11]

PG_FUNCTION_INFO_V1 ( int_custom_eq  )

◆ PG_FUNCTION_INFO_V1() [3/11]

PG_FUNCTION_INFO_V1 ( int_custom_ge  )

◆ PG_FUNCTION_INFO_V1() [4/11]

PG_FUNCTION_INFO_V1 ( int_custom_gt  )

◆ PG_FUNCTION_INFO_V1() [5/11]

PG_FUNCTION_INFO_V1 ( int_custom_in  )

◆ PG_FUNCTION_INFO_V1() [6/11]

PG_FUNCTION_INFO_V1 ( int_custom_le  )

◆ PG_FUNCTION_INFO_V1() [7/11]

PG_FUNCTION_INFO_V1 ( int_custom_lt  )

◆ PG_FUNCTION_INFO_V1() [8/11]

PG_FUNCTION_INFO_V1 ( int_custom_ne  )

◆ PG_FUNCTION_INFO_V1() [9/11]

PG_FUNCTION_INFO_V1 ( int_custom_out  )

◆ PG_FUNCTION_INFO_V1() [10/11]

PG_FUNCTION_INFO_V1 ( int_custom_typanalyze_false  )

◆ PG_FUNCTION_INFO_V1() [11/11]

PG_FUNCTION_INFO_V1 ( int_custom_typanalyze_invalid  )

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 24 of file test_custom_types.c.