PostgreSQL Source Code: src/backend/utils/adt/enum.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
15
24#include "utils/fmgroids.h"
27
28
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62static void
64{
67
68
69
70
71
73 return;
74
75
76
77
78
82 return;
83
84
85
86
87
88
89
91 return;
92
93
94
95
96
98 (errcode(ERRCODE_UNSAFE_NEW_ENUM_VALUE_USAGE),
99 errmsg("unsafe use of new value \"%s\" of enum type %s",
102 errhint("New enum values must be committed before they can be used.")));
103}
104
105
106
107
110{
113 Node *escontext = fcinfo->context;
114 Oid enumoid;
116
117
120 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
121 errmsg("invalid input value for enum %s: \"%s\"",
124
130 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
131 errmsg("invalid input value for enum %s: \"%s\"",
134
135
136
137
138
139
140
142
143
144
145
146
148
150
152}
153
156{
158 char *result;
161
165 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
166 errmsg("invalid internal value for enum: %u",
167 enumval)));
169
171
173
175}
176
177
180{
183 Oid enumoid;
186 int nbytes;
187
189
190
193 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
194 errmsg("invalid input value for enum %s: \"%s\"",
197
203 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
204 errmsg("invalid input value for enum %s: \"%s\"",
207
208
210
212
214
216
218}
219
222{
227
231 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
232 errmsg("invalid internal value for enum: %u",
233 enumval)));
235
238
240
242}
243
244
245
246
247
248
249
250
251static int
253{
255
256
257
258
259
260
261
262
264
265
266 if (arg1 == arg2)
267 return 0;
268
269
270 if ((arg1 & 1) == 0 && (arg2 & 1) == 0)
271 {
272 if (arg1 < arg2)
273 return -1;
274 else
275 return 1;
276 }
277
278
280 if (tcache == NULL)
281 {
284 Oid typeoid;
285
286
290 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
291 errmsg("invalid internal value for enum: %u",
292 arg1)));
294 typeoid = en->enumtypid;
296
299 }
300
301
303}
304
307{
310
312}
313
316{
319
321}
322
325{
328
330}
331
334{
337
339}
340
343{
346
348}
349
352{
355
357}
358
361{
364
366}
367
370{
373
375}
376
379{
382
384}
385
386
387
388
389
390
391static Oid
393{
399 Oid minmax;
400
401
402
403
404
405
407 Anum_pg_enum_enumtypid,
410
414 1, &skey);
415
418 {
419
422 }
423 else
424 {
425
427 }
428
432
433 return minmax;
434}
435
438{
439 Oid enumtypoid;
441
442
443
444
445
446
450 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
451 errmsg("could not determine actual enum type")));
452
453
455
458 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
459 errmsg("enum %s contains no values",
461
463}
464
467{
468 Oid enumtypoid;
470
471
472
473
474
475
479 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
480 errmsg("could not determine actual enum type")));
481
482
484
487 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
488 errmsg("enum %s contains no values",
490
492}
493
494
497{
500 Oid enumtypoid;
501
504 else
508 else
510
511
512
513
514
515
519 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
520 errmsg("could not determine actual enum type")));
521
523}
524
525
528{
529 Oid enumtypoid;
530
531
532
533
534
535
539 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
540 errmsg("could not determine actual enum type")));
541
544}
545
548{
556 int max,
557 cnt;
558 bool left_found;
559
560
561
562
563
564
566 Anum_pg_enum_enumtypid,
569
573
574 max = 64;
576 cnt = 0;
578
580 {
582
583 if (!left_found && lower == enum_oid)
584 left_found = true;
585
586 if (left_found)
587 {
588
590
591 if (cnt >= max)
592 {
593 max *= 2;
595 }
596
598 }
599
601 break;
602 }
603
607
608
609
611 sizeof(Oid), true, TYPALIGN_INT);
612
614
615 return result;
616}
#define PG_RETURN_ARRAYTYPE_P(x)
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
#define OidIsValid(objectId)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define ereport(elevel,...)
Datum enum_range_all(PG_FUNCTION_ARGS)
Datum enum_last(PG_FUNCTION_ARGS)
static void check_safe_enum_use(HeapTuple enumval_tup)
Datum enum_gt(PG_FUNCTION_ARGS)
Datum enum_first(PG_FUNCTION_ARGS)
static Oid enum_endpoint(Oid enumtypoid, ScanDirection direction)
Datum enum_smaller(PG_FUNCTION_ARGS)
Datum enum_lt(PG_FUNCTION_ARGS)
Datum enum_cmp(PG_FUNCTION_ARGS)
Datum enum_eq(PG_FUNCTION_ARGS)
Datum enum_range_bounds(PG_FUNCTION_ARGS)
Datum enum_send(PG_FUNCTION_ARGS)
static ArrayType * enum_range_internal(Oid enumtypoid, Oid lower, Oid upper)
Datum enum_ge(PG_FUNCTION_ARGS)
Datum enum_in(PG_FUNCTION_ARGS)
Datum enum_recv(PG_FUNCTION_ARGS)
static int enum_cmp_internal(Oid arg1, Oid arg2, FunctionCallInfo fcinfo)
Datum enum_out(PG_FUNCTION_ARGS)
Datum enum_larger(PG_FUNCTION_ARGS)
Datum enum_le(PG_FUNCTION_ARGS)
Datum enum_ne(PG_FUNCTION_ARGS)
Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_GETARG_CSTRING(n)
#define PG_RETURN_INT32(x)
#define PG_RETURN_BOOL(x)
char * format_type_be(Oid type_oid)
SysScanDesc systable_beginscan_ordered(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, ScanKey key)
void systable_endscan_ordered(SysScanDesc sysscan)
HeapTuple systable_getnext_ordered(SysScanDesc sysscan, ScanDirection direction)
Assert(PointerIsAligned(start, uint64))
#define HeapTupleIsValid(tuple)
static TransactionId HeapTupleHeaderGetXmin(const HeapTupleHeaderData *tup)
static void * GETSTRUCT(const HeapTupleData *tuple)
static bool HeapTupleHeaderXminCommitted(const HeapTupleHeaderData *tup)
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
if(TABLE==NULL||TABLE_index==NULL)
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
Datum lower(PG_FUNCTION_ARGS)
Datum upper(PG_FUNCTION_ARGS)
bool EnumUncommitted(Oid enum_id)
FormData_pg_enum * Form_pg_enum
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
void pq_sendtext(StringInfo buf, const char *str, int slen)
char * pq_getmsgtext(StringInfo msg, int rawbytes, int *nbytes)
void pq_begintypsend(StringInfo buf)
bytea * pq_endtypsend(StringInfo buf)
bool TransactionIdIsInProgress(TransactionId xid)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
#define BTEqualStrategyNumber
StringInfoData * StringInfo
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
bool TransactionIdDidCommit(TransactionId transactionId)
int compare_values_of_enum(TypeCacheEntry *tcache, Oid arg1, Oid arg2)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)