PostgreSQL Source Code git master
oid8.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * oid8.c
4 * Functions for the built-in type Oid8
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 *
10 * IDENTIFICATION
11 * src/backend/utils/adt/oid8.c
12 *
13 *-------------------------------------------------------------------------
14 */
15#include "postgres.h"
16
17#include "catalog/pg_type.h"
18#include "libpq/pqformat.h"
19#include "utils/builtins.h"
20
21#define MAXOID8LEN 20
22
23/*****************************************************************************
24 * USER I/O ROUTINES *
25 *****************************************************************************/
26
29{
30 char *s = PG_GETARG_CSTRING(0);
31 Oid8 result;
32
33 result = uint64in_subr(s, NULL, "oid8", fcinfo->context);
34 PG_RETURN_OID8(result);
35}
36
39{
41 char buf[MAXOID8LEN + 1];
42 char *result;
43 int len;
44
45 len = pg_ulltoa_n(val, buf) + 1;
46 buf[len - 1] = '\0';
47
48 /*
49 * Since the length is already known, we do a manual palloc() and memcpy()
50 * to avoid the strlen() call that would otherwise be done in pstrdup().
51 */
52 result = palloc(len);
53 memcpy(result, buf, len);
54 PG_RETURN_CSTRING(result);
55}
56
57/*
58 * oid8recv - converts external binary format to oid8
59 */
62{
64
66}
67
68/*
69 * oid8send - converts oid8 to binary format
70 */
73{
74 Oid8 arg1 = PG_GETARG_OID8(0);
76
78 pq_sendint64(&buf, arg1);
80}
81
82/*****************************************************************************
83 * PUBLIC ROUTINES *
84 *****************************************************************************/
85
88{
89 Oid8 arg1 = PG_GETARG_OID8(0);
90 Oid8 arg2 = PG_GETARG_OID8(1);
91
92 PG_RETURN_BOOL(arg1 == arg2);
93}
94
97{
98 Oid8 arg1 = PG_GETARG_OID8(0);
99 Oid8 arg2 = PG_GETARG_OID8(1);
100
101 PG_RETURN_BOOL(arg1 != arg2);
102}
103
104Datum
106{
107 Oid8 arg1 = PG_GETARG_OID8(0);
108 Oid8 arg2 = PG_GETARG_OID8(1);
109
110 PG_RETURN_BOOL(arg1 < arg2);
111}
112
113Datum
115{
116 Oid8 arg1 = PG_GETARG_OID8(0);
117 Oid8 arg2 = PG_GETARG_OID8(1);
118
119 PG_RETURN_BOOL(arg1 <= arg2);
120}
121
122Datum
124{
125 Oid8 arg1 = PG_GETARG_OID8(0);
126 Oid8 arg2 = PG_GETARG_OID8(1);
127
128 PG_RETURN_BOOL(arg1 >= arg2);
129}
130
131Datum
133{
134 Oid8 arg1 = PG_GETARG_OID8(0);
135 Oid8 arg2 = PG_GETARG_OID8(1);
136
137 PG_RETURN_BOOL(arg1 > arg2);
138}
139
140Datum
142{
143 return hashint8(fcinfo);
144}
145
146Datum
148{
149 return hashint8extended(fcinfo);
150}
151
152Datum
154{
155 Oid8 arg1 = PG_GETARG_OID8(0);
156 Oid8 arg2 = PG_GETARG_OID8(1);
157
158 PG_RETURN_OID8((arg1 > arg2) ? arg1 : arg2);
159}
160
161Datum
163{
164 Oid8 arg1 = PG_GETARG_OID8(0);
165 Oid8 arg2 = PG_GETARG_OID8(1);
166
167 PG_RETURN_OID8((arg1 < arg2) ? arg1 : arg2);
168}
uint64 Oid8
Definition: c.h:692
#define PG_RETURN_BYTEA_P(x)
Definition: fmgr.h:373
#define PG_GETARG_OID8(n)
Definition: fmgr.h:276
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:277
#define PG_RETURN_CSTRING(x)
Definition: fmgr.h:364
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:278
#define PG_RETURN_OID8(x)
Definition: fmgr.h:362
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:360
Datum hashint8extended(PG_FUNCTION_ARGS)
Definition: hashfunc.c:103
Datum hashint8(PG_FUNCTION_ARGS)
Definition: hashfunc.c:83
long val
Definition: informix.c:689
void * palloc(Size size)
Definition: mcxt.c:1387
uint64 uint64in_subr(const char *s, char **endloc, const char *typname, Node *escontext)
Definition: numutils.c:985
int pg_ulltoa_n(uint64 value, char *a)
Definition: numutils.c:1140
Datum oid8eq(PG_FUNCTION_ARGS)
Definition: oid8.c:87
#define MAXOID8LEN
Definition: oid8.c:21
Datum oid8recv(PG_FUNCTION_ARGS)
Definition: oid8.c:61
Datum hashoid8(PG_FUNCTION_ARGS)
Definition: oid8.c:141
Datum oid8send(PG_FUNCTION_ARGS)
Definition: oid8.c:72
Datum oid8gt(PG_FUNCTION_ARGS)
Definition: oid8.c:132
Datum oid8lt(PG_FUNCTION_ARGS)
Definition: oid8.c:105
Datum oid8ge(PG_FUNCTION_ARGS)
Definition: oid8.c:123
Datum oid8out(PG_FUNCTION_ARGS)
Definition: oid8.c:38
Datum oid8ne(PG_FUNCTION_ARGS)
Definition: oid8.c:96
Datum oid8larger(PG_FUNCTION_ARGS)
Definition: oid8.c:153
Datum oid8le(PG_FUNCTION_ARGS)
Definition: oid8.c:114
Datum hashoid8extended(PG_FUNCTION_ARGS)
Definition: oid8.c:147
Datum oid8in(PG_FUNCTION_ARGS)
Definition: oid8.c:28
Datum oid8smaller(PG_FUNCTION_ARGS)
Definition: oid8.c:162
const void size_t len
static char buf[DEFAULT_XLOG_SEG_SIZE]
Definition: pg_test_fsync.c:71
uint64_t Datum
Definition: postgres.h:70
void pq_begintypsend(StringInfo buf)
Definition: pqformat.c:325
int64 pq_getmsgint64(StringInfo msg)
Definition: pqformat.c:452
bytea * pq_endtypsend(StringInfo buf)
Definition: pqformat.c:345
static void pq_sendint64(StringInfo buf, uint64 i)
Definition: pqformat.h:152
struct StringInfoData * StringInfo
Definition: string.h:15