|
|
@ -147,11 +147,11 @@ Datum |
|
|
|
bit_in(PG_FUNCTION_ARGS) |
|
|
|
bit_in(PG_FUNCTION_ARGS) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *input_string = PG_GETARG_CSTRING(0); |
|
|
|
char *input_string = PG_GETARG_CSTRING(0); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef NOT_USED |
|
|
|
#ifdef NOT_USED |
|
|
|
Oid typelem = PG_GETARG_OID(1); |
|
|
|
Oid typelem = PG_GETARG_OID(1); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
int32 atttypmod = PG_GETARG_INT32(2); |
|
|
|
int32 atttypmod = PG_GETARG_INT32(2); |
|
|
|
|
|
|
|
Node *escontext = fcinfo->context; |
|
|
|
VarBit *result; /* The resulting bit string */ |
|
|
|
VarBit *result; /* The resulting bit string */ |
|
|
|
char *sp; /* pointer into the character string */ |
|
|
|
char *sp; /* pointer into the character string */ |
|
|
|
bits8 *r; /* pointer into the result */ |
|
|
|
bits8 *r; /* pointer into the result */ |
|
|
@ -193,7 +193,7 @@ bit_in(PG_FUNCTION_ARGS) |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (slen > VARBITMAXLEN / 4) |
|
|
|
if (slen > VARBITMAXLEN / 4) |
|
|
|
ereport(ERROR, |
|
|
|
ereturn(escontext, (Datum) 0, |
|
|
|
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
|
|
|
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
|
|
|
errmsg("bit string length exceeds the maximum allowed (%d)", |
|
|
|
errmsg("bit string length exceeds the maximum allowed (%d)", |
|
|
|
VARBITMAXLEN))); |
|
|
|
VARBITMAXLEN))); |
|
|
@ -207,7 +207,7 @@ bit_in(PG_FUNCTION_ARGS) |
|
|
|
if (atttypmod <= 0) |
|
|
|
if (atttypmod <= 0) |
|
|
|
atttypmod = bitlen; |
|
|
|
atttypmod = bitlen; |
|
|
|
else if (bitlen != atttypmod) |
|
|
|
else if (bitlen != atttypmod) |
|
|
|
ereport(ERROR, |
|
|
|
ereturn(escontext, (Datum) 0, |
|
|
|
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH), |
|
|
|
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH), |
|
|
|
errmsg("bit string length %d does not match type bit(%d)", |
|
|
|
errmsg("bit string length %d does not match type bit(%d)", |
|
|
|
bitlen, atttypmod))); |
|
|
|
bitlen, atttypmod))); |
|
|
@ -229,7 +229,7 @@ bit_in(PG_FUNCTION_ARGS) |
|
|
|
if (*sp == '1') |
|
|
|
if (*sp == '1') |
|
|
|
*r |= x; |
|
|
|
*r |= x; |
|
|
|
else if (*sp != '0') |
|
|
|
else if (*sp != '0') |
|
|
|
ereport(ERROR, |
|
|
|
ereturn(escontext, (Datum) 0, |
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
|
|
|
errmsg("\"%.*s\" is not a valid binary digit", |
|
|
|
errmsg("\"%.*s\" is not a valid binary digit", |
|
|
|
pg_mblen(sp), sp))); |
|
|
|
pg_mblen(sp), sp))); |
|
|
@ -254,7 +254,7 @@ bit_in(PG_FUNCTION_ARGS) |
|
|
|
else if (*sp >= 'a' && *sp <= 'f') |
|
|
|
else if (*sp >= 'a' && *sp <= 'f') |
|
|
|
x = (bits8) (*sp - 'a') + 10; |
|
|
|
x = (bits8) (*sp - 'a') + 10; |
|
|
|
else |
|
|
|
else |
|
|
|
ereport(ERROR, |
|
|
|
ereturn(escontext, (Datum) 0, |
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
|
|
|
errmsg("\"%.*s\" is not a valid hexadecimal digit", |
|
|
|
errmsg("\"%.*s\" is not a valid hexadecimal digit", |
|
|
|
pg_mblen(sp), sp))); |
|
|
|
pg_mblen(sp), sp))); |
|
|
@ -452,11 +452,11 @@ Datum |
|
|
|
varbit_in(PG_FUNCTION_ARGS) |
|
|
|
varbit_in(PG_FUNCTION_ARGS) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *input_string = PG_GETARG_CSTRING(0); |
|
|
|
char *input_string = PG_GETARG_CSTRING(0); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef NOT_USED |
|
|
|
#ifdef NOT_USED |
|
|
|
Oid typelem = PG_GETARG_OID(1); |
|
|
|
Oid typelem = PG_GETARG_OID(1); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
int32 atttypmod = PG_GETARG_INT32(2); |
|
|
|
int32 atttypmod = PG_GETARG_INT32(2); |
|
|
|
|
|
|
|
Node *escontext = fcinfo->context; |
|
|
|
VarBit *result; /* The resulting bit string */ |
|
|
|
VarBit *result; /* The resulting bit string */ |
|
|
|
char *sp; /* pointer into the character string */ |
|
|
|
char *sp; /* pointer into the character string */ |
|
|
|
bits8 *r; /* pointer into the result */ |
|
|
|
bits8 *r; /* pointer into the result */ |
|
|
@ -494,7 +494,7 @@ varbit_in(PG_FUNCTION_ARGS) |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (slen > VARBITMAXLEN / 4) |
|
|
|
if (slen > VARBITMAXLEN / 4) |
|
|
|
ereport(ERROR, |
|
|
|
ereturn(escontext, (Datum) 0, |
|
|
|
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
|
|
|
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
|
|
|
errmsg("bit string length exceeds the maximum allowed (%d)", |
|
|
|
errmsg("bit string length exceeds the maximum allowed (%d)", |
|
|
|
VARBITMAXLEN))); |
|
|
|
VARBITMAXLEN))); |
|
|
@ -508,7 +508,7 @@ varbit_in(PG_FUNCTION_ARGS) |
|
|
|
if (atttypmod <= 0) |
|
|
|
if (atttypmod <= 0) |
|
|
|
atttypmod = bitlen; |
|
|
|
atttypmod = bitlen; |
|
|
|
else if (bitlen > atttypmod) |
|
|
|
else if (bitlen > atttypmod) |
|
|
|
ereport(ERROR, |
|
|
|
ereturn(escontext, (Datum) 0, |
|
|
|
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), |
|
|
|
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), |
|
|
|
errmsg("bit string too long for type bit varying(%d)", |
|
|
|
errmsg("bit string too long for type bit varying(%d)", |
|
|
|
atttypmod))); |
|
|
|
atttypmod))); |
|
|
@ -530,7 +530,7 @@ varbit_in(PG_FUNCTION_ARGS) |
|
|
|
if (*sp == '1') |
|
|
|
if (*sp == '1') |
|
|
|
*r |= x; |
|
|
|
*r |= x; |
|
|
|
else if (*sp != '0') |
|
|
|
else if (*sp != '0') |
|
|
|
ereport(ERROR, |
|
|
|
ereturn(escontext, (Datum) 0, |
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
|
|
|
errmsg("\"%.*s\" is not a valid binary digit", |
|
|
|
errmsg("\"%.*s\" is not a valid binary digit", |
|
|
|
pg_mblen(sp), sp))); |
|
|
|
pg_mblen(sp), sp))); |
|
|
@ -555,7 +555,7 @@ varbit_in(PG_FUNCTION_ARGS) |
|
|
|
else if (*sp >= 'a' && *sp <= 'f') |
|
|
|
else if (*sp >= 'a' && *sp <= 'f') |
|
|
|
x = (bits8) (*sp - 'a') + 10; |
|
|
|
x = (bits8) (*sp - 'a') + 10; |
|
|
|
else |
|
|
|
else |
|
|
|
ereport(ERROR, |
|
|
|
ereturn(escontext, (Datum) 0, |
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
|
|
|
errmsg("\"%.*s\" is not a valid hexadecimal digit", |
|
|
|
errmsg("\"%.*s\" is not a valid hexadecimal digit", |
|
|
|
pg_mblen(sp), sp))); |
|
|
|
pg_mblen(sp), sp))); |
|
|
|