修改第二个参数为列引用时的处理逻辑
This commit is contained in:
@ -12117,12 +12117,12 @@ AddFuncGroup(
|
||||
),
|
||||
AddFuncGroup(
|
||||
"to_binary_float", 6,
|
||||
AddBuiltinFunc(_0(7012), _1("to_binary_float"), _2(3), _3(false), _4(false), _5(to_binary_float_text), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(3, 25, 25, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("to_binary_float_text"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert text to a single precision floating-point number, with default return expr on convert error"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7013), _1("to_binary_float"), _2(1), _3(false), _4(false), _5(NULL), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(SQLlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 25), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("select pg_catalog.to_binary_float($1, ' ', false)"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert text to a single precision floating-point number"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7014), _1("to_binary_float"), _2(3), _3(false), _4(false), _5(to_binary_float_number), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(3, 701, 701, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("to_binary_float_number"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert float8 to a single precision floating-point number, with default return expr on convert error"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7015), _1("to_binary_float"), _2(1), _3(false), _4(false), _5(NULL), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(SQLlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 701), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("select pg_catalog.to_binary_float($1, 0, false)"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert float8 to a single precision floating-point number"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7016), _1("to_binary_float"), _2(3), _3(false), _4(false), _5(NULL), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(SQLlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(3, 701, 25, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("select pg_catalog.to_binary_float($1, 0, false)"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert float8 to a single precision floating-point number, with default return expr on convert error"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7017), _1("to_binary_float"), _2(3), _3(false), _4(false), _5(to_binary_float_text_number), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(3, 25, 701, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("to_binary_float_text_number"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert text to a single precision floating-point number, with default return expr on convert error"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0))
|
||||
AddBuiltinFunc(_0(7012), _1("to_binary_float"), _2(3), _3(false), _4(false), _5(to_binary_float_text), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(4, 25, 25, 16, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("to_binary_float_text"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert text to a single precision floating-point number, with default return expr on convert error"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7013), _1("to_binary_float"), _2(1), _3(false), _4(false), _5(NULL), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(SQLlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 25), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("select pg_catalog.to_binary_float($1, ' ', false, false)"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert text to a single precision floating-point number"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7014), _1("to_binary_float"), _2(3), _3(false), _4(false), _5(to_binary_float_number), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(4, 701, 701, 16, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("to_binary_float_number"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert float8 to a single precision floating-point number, with default return expr on convert error"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7015), _1("to_binary_float"), _2(1), _3(false), _4(false), _5(NULL), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(SQLlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 701), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("select pg_catalog.to_binary_float($1, 0, false, false)"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert float8 to a single precision floating-point number"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7016), _1("to_binary_float"), _2(3), _3(false), _4(false), _5(NULL), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(SQLlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(4, 701, 25, 16, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("select pg_catalog.to_binary_float($1, 0, false, false)"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert float8 to a single precision floating-point number, with default return expr on convert error"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)),
|
||||
AddBuiltinFunc(_0(7017), _1("to_binary_float"), _2(3), _3(false), _4(false), _5(to_binary_float_text_number), _6(700), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(4, 25, 701, 16, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("to_binary_float_text_number"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert text to a single precision floating-point number, with default return expr on convert error"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0))
|
||||
),
|
||||
AddFuncGroup(
|
||||
"to_char", 11,
|
||||
|
||||
@ -27770,16 +27770,12 @@ func_application_special: func_name '(' ')'
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("The syntax or function is not supported. \"%s\"", $4)));
|
||||
}
|
||||
if (IsA($5, ColumnRef)) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("Default param can't be ColumnRef")));
|
||||
}
|
||||
|
||||
FuncCall *n = makeNode(FuncCall);
|
||||
n->funcname = $1;
|
||||
n->args = lappend($3, $5);
|
||||
n->args = lappend(n->args, makeBoolAConst(TRUE, -1));
|
||||
n->args = lappend(n->args, makeBoolAConst(IsA($5, ColumnRef), -1));
|
||||
n->agg_order = $9;
|
||||
n->agg_star = FALSE;
|
||||
n->agg_distinct = FALSE;
|
||||
|
||||
@ -3035,6 +3035,11 @@ static double to_binary_float_internal(char* origin_num, bool *err)
|
||||
|
||||
/*
|
||||
* to_binary_float_text() - convert to a single precision floating-point number.
|
||||
*
|
||||
* arg[0]: input arg;
|
||||
* arg[1]: default arg;
|
||||
* arg[2]: has default arg;
|
||||
* arg[3]: default is column ref.
|
||||
*/
|
||||
Datum to_binary_float_text(PG_FUNCTION_ARGS)
|
||||
{
|
||||
@ -3046,6 +3051,13 @@ Datum to_binary_float_text(PG_FUNCTION_ARGS)
|
||||
double result, r1, r2;
|
||||
bool err1, err2;
|
||||
|
||||
// if default arg is col, report error
|
||||
if (with_default && PG_GETARG_BOOL(3)) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("default argument must be a literal or bind")));
|
||||
}
|
||||
|
||||
err1 = true;
|
||||
if (!str1_null) {
|
||||
num1 = TextDatumGetCString(PG_GETARG_TEXT_P(0));
|
||||
@ -3111,8 +3123,9 @@ static double handle_float4_overflow(double val)
|
||||
*/
|
||||
Datum to_binary_float_number(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_ARGISNULL(0))
|
||||
if (PG_ARGISNULL(0)) {
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
|
||||
float8 val = handle_float4_overflow(PG_GETARG_FLOAT8(0));
|
||||
|
||||
@ -3121,15 +3134,21 @@ Datum to_binary_float_number(PG_FUNCTION_ARGS)
|
||||
|
||||
Datum to_binary_float_text_number(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_ARGISNULL(0))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
bool with_default = PG_GETARG_BOOL(2);
|
||||
|
||||
char *num;
|
||||
double result;
|
||||
bool err;
|
||||
|
||||
if (with_default && PG_GETARG_BOOL(3)) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("default argument must be a literal or bind")));
|
||||
}
|
||||
|
||||
if (PG_ARGISNULL(0)) {
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
|
||||
err = false;
|
||||
num = TextDatumGetCString(PG_GETARG_TEXT_P(0));
|
||||
result = to_binary_float_internal(num, &err);
|
||||
|
||||
@ -2,10 +2,10 @@ DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, text, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, text, bool, bool) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, float8, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, float8, bool, bool) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, float8, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, float8, bool, bool) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, text, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, text, bool, bool) CASCADE;
|
||||
|
||||
@ -2,10 +2,10 @@ DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, text, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, text, bool, bool) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, float8, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, float8, bool, bool) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, float8, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, float8, bool, bool) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, text, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, text, bool, bool) CASCADE;
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, text, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, text, bool, bool) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids=IUO_PROC, 7012;
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(text, text, bool)
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(text, text, bool, bool)
|
||||
RETURNS float4
|
||||
as 'to_binary_float_text'
|
||||
LANGUAGE INTERNAL
|
||||
IMMUTABLE;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text, text, bool) IS 'convert text to a single precision floating-point number, with default return expr on convert error';
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text, text, bool, bool) IS 'convert text to a single precision floating-point number, with default return expr on convert error';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text) CASCADE;
|
||||
@ -14,21 +14,21 @@ CREATE FUNCTION pg_catalog.to_binary_float(text)
|
||||
RETURNS float4 AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN (select pg_catalog.to_binary_float($1, ' ', false));
|
||||
RETURN (select pg_catalog.to_binary_float($1, ' ', false, false));
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text) IS 'convert text to a single precision floating-point number';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, float8, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, float8, bool, bool) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids=IUO_PROC, 7014;
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(float8, float8, bool)
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(float8, float8, bool, bool)
|
||||
RETURNS float4
|
||||
as 'to_binary_float_number'
|
||||
LANGUAGE INTERNAL
|
||||
IMMUTABLE;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8, float8, bool) IS 'convert float8 to a single precision floating-point number, with default return expr on convert error';
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8, float8, bool, bool) IS 'convert float8 to a single precision floating-point number, with default return expr on convert error';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8) CASCADE;
|
||||
@ -37,31 +37,31 @@ CREATE FUNCTION pg_catalog.to_binary_float(float8)
|
||||
RETURNS float4 AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN (select pg_catalog.to_binary_float($1, 0, false));
|
||||
RETURN (select pg_catalog.to_binary_float($1, 0, false, false));
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8) IS 'convert float8 to a single precision floating-point number';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, text, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, text, bool, bool) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids=IUO_PROC, 7016;
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(float8, text, bool)
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(float8, text, bool, bool)
|
||||
RETURNS float4 AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN (select pg_catalog.to_binary_float($1, 0, false));
|
||||
RETURN (select pg_catalog.to_binary_float($1, 0, false, false));
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8, float8, bool) IS 'convert float8 to a single precision floating-point number, with default return expr on convert error';
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8, float8, bool, bool) IS 'convert float8 to a single precision floating-point number, with default return expr on convert error';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, float8, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, float8, bool, bool) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids=IUO_PROC, 7017;
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(text, float8, bool)
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(text, float8, bool, bool)
|
||||
RETURNS float4
|
||||
as 'to_binary_float_text_number'
|
||||
LANGUAGE INTERNAL
|
||||
IMMUTABLE;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text, text, bool) IS 'convert text to a single precision floating-point number, with default return expr on convert error';
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text, text, bool, bool) IS 'convert text to a single precision floating-point number, with default return expr on convert error';
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, text, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, text, bool, bool) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids=IUO_PROC, 7012;
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(text, text, bool)
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(text, text, bool, bool)
|
||||
RETURNS float4
|
||||
as 'to_binary_float_text'
|
||||
LANGUAGE INTERNAL
|
||||
IMMUTABLE;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text, text, bool) IS 'convert text to a single precision floating-point number, with default return expr on convert error';
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text, text, bool, bool) IS 'convert text to a single precision floating-point number, with default return expr on convert error';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text) CASCADE;
|
||||
@ -14,21 +14,21 @@ CREATE FUNCTION pg_catalog.to_binary_float(text)
|
||||
RETURNS float4 AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN (select pg_catalog.to_binary_float($1, ' ', false));
|
||||
RETURN (select pg_catalog.to_binary_float($1, ' ', false, false));
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text) IS 'convert text to a single precision floating-point number';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, float8, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, float8, bool, bool) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids=IUO_PROC, 7014;
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(float8, float8, bool)
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(float8, float8, bool, bool)
|
||||
RETURNS float4
|
||||
as 'to_binary_float_number'
|
||||
LANGUAGE INTERNAL
|
||||
IMMUTABLE;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8, float8, bool) IS 'convert float8 to a single precision floating-point number, with default return expr on convert error';
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8, float8, bool, bool) IS 'convert float8 to a single precision floating-point number, with default return expr on convert error';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8) CASCADE;
|
||||
@ -37,31 +37,31 @@ CREATE FUNCTION pg_catalog.to_binary_float(float8)
|
||||
RETURNS float4 AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN (select pg_catalog.to_binary_float($1, 0, false));
|
||||
RETURN (select pg_catalog.to_binary_float($1, 0, false, false));
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8) IS 'convert float8 to a single precision floating-point number';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, text, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(float8, text, bool, bool) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids=IUO_PROC, 7016;
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(float8, text, bool)
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(float8, text, bool, bool)
|
||||
RETURNS float4 AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN (select pg_catalog.to_binary_float($1, 0, false));
|
||||
RETURN (select pg_catalog.to_binary_float($1, 0, false, false));
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8, float8, bool) IS 'convert float8 to a single precision floating-point number, with default return expr on convert error';
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(float8, float8, bool, bool) IS 'convert float8 to a single precision floating-point number, with default return expr on convert error';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, float8, bool) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_binary_float(text, float8, bool, bool) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids=IUO_PROC, 7017;
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(text, float8, bool)
|
||||
CREATE FUNCTION pg_catalog.to_binary_float(text, float8, bool, bool)
|
||||
RETURNS float4
|
||||
as 'to_binary_float_text_number'
|
||||
LANGUAGE INTERNAL
|
||||
IMMUTABLE;
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text, text, bool) IS 'convert text to a single precision floating-point number, with default return expr on convert error';
|
||||
COMMENT ON FUNCTION pg_catalog.to_binary_float(text, text, bool, bool) IS 'convert text to a single precision floating-point number, with default return expr on convert error';
|
||||
|
||||
@ -175,8 +175,19 @@ SELECT TO_BINARY_FLOAT(c1 DEFAULT NULL ON CONVERSION ERROR) FROM tbf ORDER By c1
|
||||
8
|
||||
(8 rows)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT c1 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- errorя╝М column can't be default param
|
||||
ERROR: Default param can't be ColumnRef
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT c1 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error, column can't be default param
|
||||
to_binary_float
|
||||
-----------------
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
(8 rows)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(c2 DEFAULT 3.14 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
to_binary_float
|
||||
-----------------
|
||||
@ -434,6 +445,7 @@ SELECT TO_BINARY_FLOAT(' 6.66 ' DEFAULT 3.14 ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('today' DEFAULT 'roll' ON CONVERSION ERROR); -- error
|
||||
ERROR: invalid input syntax for type real
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
<<<<<<< HEAD
|
||||
SELECT TO_BINARY_FLOAT(3.402E+100);
|
||||
to_binary_float
|
||||
-----------------
|
||||
@ -446,6 +458,112 @@ SELECT TO_BINARY_FLOAT('test' DEFAULT 3.04E+100 ON CONVERSION ERROR);
|
||||
Infinity
|
||||
(1 row)
|
||||
|
||||
=======
|
||||
-- test default column
|
||||
SELECT TO_BINARY_FLOAT(1.79E+309 DEFAULT y ON CONVERSION ERROR);
|
||||
ERROR: column "y" does not exist
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79E+309 DEFAULT y ON CONVERSION ERR...
|
||||
^
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT(c3 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
to_binary_float
|
||||
-----------------
|
||||
1.23
|
||||
3.14157
|
||||
2.02405e+11
|
||||
|
||||
|
||||
NaN
|
||||
Infinity
|
||||
Infinity
|
||||
(8 rows)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(c4 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
to_binary_float
|
||||
-----------------
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
(8 rows)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
to_binary_float
|
||||
-----------------
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
3.14
|
||||
(8 rows)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14E+100 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
to_binary_float
|
||||
-----------------
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
(8 rows)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14E+100 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
to_binary_float
|
||||
-----------------
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
Infinity
|
||||
(8 rows)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- overflow
|
||||
ERROR: "31400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- overflow
|
||||
ERROR: "31400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT('3.14E+100' DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT('3.14E+100' DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT('3.14E+400' DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT('3.14E+400' DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
>>>>>>> 1073a6efb (修改第二个参数为列引用时的处理逻辑)
|
||||
-- test overflow and null
|
||||
SELECT TO_BINARY_FLOAT(1.79769313486231E+100 DEFAULT 3.14 ON CONVERSION ERROR);
|
||||
to_binary_float
|
||||
|
||||
@ -43,7 +43,7 @@ SELECT TO_BINARY_FLOAT(c1 DEFAULT '3.14' ON CONVERSION ERROR) FROM tbf ORDER By
|
||||
SELECT TO_BINARY_FLOAT(c1 DEFAULT '3.14FDW' ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
SELECT TO_BINARY_FLOAT(c1 DEFAULT NULL ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT c1 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- errorя╝М column can't be default param
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT c1 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error, column can't be default param
|
||||
|
||||
SELECT TO_BINARY_FLOAT(c2 DEFAULT 3.14 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
SELECT TO_BINARY_FLOAT(c2 DEFAULT '3.14' ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
@ -78,6 +78,25 @@ SELECT TO_BINARY_FLOAT('today' DEFAULT 'roll' ON CONVERSION ERROR); -- error
|
||||
SELECT TO_BINARY_FLOAT(3.402E+100);
|
||||
SELECT TO_BINARY_FLOAT('test' DEFAULT 3.04E+100 ON CONVERSION ERROR);
|
||||
|
||||
-- test default column
|
||||
SELECT TO_BINARY_FLOAT(1.79E+309 DEFAULT y ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(c3 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
SELECT TO_BINARY_FLOAT(c4 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
SELECT TO_BINARY_FLOAT(3.14E+100 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
SELECT TO_BINARY_FLOAT(3.14E+100 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- overflow
|
||||
SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- overflow
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
SELECT TO_BINARY_FLOAT('3.14E+100' DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
SELECT TO_BINARY_FLOAT('3.14E+100' DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
SELECT TO_BINARY_FLOAT('3.14E+400' DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
SELECT TO_BINARY_FLOAT('3.14E+400' DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
|
||||
-- test overflow and null
|
||||
SELECT TO_BINARY_FLOAT(1.79769313486231E+100 DEFAULT 3.14 ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(2.22507485850720E-100 DEFAULT 3.14 ON CONVERSION ERROR);
|
||||
|
||||
Reference in New Issue
Block a user