#include "postgres.h"#include <limits.h>#include "libpq/pqformat.h"#include "utils/builtins.h"
Go to the source code of this file.
Functions | |
| Datum | charin (PG_FUNCTION_ARGS) |
| Datum | charout (PG_FUNCTION_ARGS) |
| Datum | charrecv (PG_FUNCTION_ARGS) |
| Datum | charsend (PG_FUNCTION_ARGS) |
| Datum | chareq (PG_FUNCTION_ARGS) |
| Datum | charne (PG_FUNCTION_ARGS) |
| Datum | charlt (PG_FUNCTION_ARGS) |
| Datum | charle (PG_FUNCTION_ARGS) |
| Datum | chargt (PG_FUNCTION_ARGS) |
| Datum | charge (PG_FUNCTION_ARGS) |
| Datum | chartoi4 (PG_FUNCTION_ARGS) |
| Datum | i4tochar (PG_FUNCTION_ARGS) |
| Datum | text_char (PG_FUNCTION_ARGS) |
| Datum | char_text (PG_FUNCTION_ARGS) |
| Datum char_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 195 of file char.c.
References palloc(), PG_GETARG_CHAR, PG_RETURN_TEXT_P, SET_VARSIZE, VARDATA, and VARHDRSZ.
{
char arg1 = PG_GETARG_CHAR(0);
text *result = palloc(VARHDRSZ + 1);
/*
* Convert \0 to an empty string, for consistency with charout (and
* because the text stuff doesn't like embedded nulls all that well).
*/
if (arg1 != '\0')
{
SET_VARSIZE(result, VARHDRSZ + 1);
*(VARDATA(result)) = arg1;
}
else
SET_VARSIZE(result, VARHDRSZ);
PG_RETURN_TEXT_P(result);
}
| Datum chareq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 99 of file char.c.
References PG_GETARG_CHAR, and PG_RETURN_BOOL.
{
char arg1 = PG_GETARG_CHAR(0);
char arg2 = PG_GETARG_CHAR(1);
PG_RETURN_BOOL(arg1 == arg2);
}
| Datum charge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 144 of file char.c.
References PG_GETARG_CHAR, and PG_RETURN_BOOL.
{
char arg1 = PG_GETARG_CHAR(0);
char arg2 = PG_GETARG_CHAR(1);
PG_RETURN_BOOL((uint8) arg1 >= (uint8) arg2);
}
| Datum chargt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 135 of file char.c.
References PG_GETARG_CHAR, and PG_RETURN_BOOL.
{
char arg1 = PG_GETARG_CHAR(0);
char arg2 = PG_GETARG_CHAR(1);
PG_RETURN_BOOL((uint8) arg1 > (uint8) arg2);
}
| Datum charin | ( | PG_FUNCTION_ARGS | ) |
Definition at line 33 of file char.c.
References PG_GETARG_CSTRING, and PG_RETURN_CHAR.
{
char *ch = PG_GETARG_CSTRING(0);
PG_RETURN_CHAR(ch[0]);
}
| Datum charle | ( | PG_FUNCTION_ARGS | ) |
Definition at line 126 of file char.c.
References PG_GETARG_CHAR, and PG_RETURN_BOOL.
{
char arg1 = PG_GETARG_CHAR(0);
char arg2 = PG_GETARG_CHAR(1);
PG_RETURN_BOOL((uint8) arg1 <= (uint8) arg2);
}
| Datum charlt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 117 of file char.c.
References PG_GETARG_CHAR, and PG_RETURN_BOOL.
{
char arg1 = PG_GETARG_CHAR(0);
char arg2 = PG_GETARG_CHAR(1);
PG_RETURN_BOOL((uint8) arg1 < (uint8) arg2);
}
| Datum charne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 108 of file char.c.
References PG_GETARG_CHAR, and PG_RETURN_BOOL.
{
char arg1 = PG_GETARG_CHAR(0);
char arg2 = PG_GETARG_CHAR(1);
PG_RETURN_BOOL(arg1 != arg2);
}
| Datum charout | ( | PG_FUNCTION_ARGS | ) |
Definition at line 48 of file char.c.
References palloc(), PG_GETARG_CHAR, and PG_RETURN_CSTRING.
{
char ch = PG_GETARG_CHAR(0);
char *result = (char *) palloc(2);
result[0] = ch;
result[1] = '\0';
PG_RETURN_CSTRING(result);
}
| Datum charrecv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 66 of file char.c.
References buf, PG_GETARG_POINTER, PG_RETURN_CHAR, and pq_getmsgbyte().
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
PG_RETURN_CHAR(pq_getmsgbyte(buf));
}
| Datum charsend | ( | PG_FUNCTION_ARGS | ) |
Definition at line 77 of file char.c.
References buf, PG_GETARG_CHAR, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), and pq_sendbyte().
{
char arg1 = PG_GETARG_CHAR(0);
StringInfoData buf;
pq_begintypsend(&buf);
pq_sendbyte(&buf, arg1);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
| Datum chartoi4 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 154 of file char.c.
References PG_GETARG_CHAR, and PG_RETURN_INT32.
{
char arg1 = PG_GETARG_CHAR(0);
PG_RETURN_INT32((int32) ((int8) arg1));
}
| Datum i4tochar | ( | PG_FUNCTION_ARGS | ) |
Definition at line 162 of file char.c.
References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT32, and PG_RETURN_CHAR.
{
int32 arg1 = PG_GETARG_INT32(0);
if (arg1 < SCHAR_MIN || arg1 > SCHAR_MAX)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("\"char\" out of range")));
PG_RETURN_CHAR((int8) arg1);
}
| Datum text_char | ( | PG_FUNCTION_ARGS | ) |
Definition at line 176 of file char.c.
References PG_GETARG_TEXT_P, PG_RETURN_CHAR, VARDATA, VARHDRSZ, and VARSIZE.
{
text *arg1 = PG_GETARG_TEXT_P(0);
char result;
/*
* An empty input string is converted to \0 (for consistency with charin).
* If the input is longer than one character, the excess data is silently
* discarded.
*/
if (VARSIZE(arg1) > VARHDRSZ)
result = *(VARDATA(arg1));
else
result = '\0';
PG_RETURN_CHAR(result);
}
1.7.1