自增-CONCAT
This commit is contained in:
@ -323,9 +323,6 @@ Node *type_transfer(Node *node, Oid atttypid, bool isSelect)
|
||||
case INT1OID:
|
||||
case INT2OID:
|
||||
case INT4OID:
|
||||
result = coerce_type(NULL, node, con->consttype,
|
||||
INT4OID, -1, COERCION_IMPLICIT, COERCE_IMPLICIT_CAST, -1);
|
||||
break;
|
||||
case INT8OID:
|
||||
result = coerce_type(NULL, node, con->consttype,
|
||||
INT8OID, -1, COERCION_IMPLICIT, COERCE_IMPLICIT_CAST, -1);
|
||||
@ -684,18 +681,31 @@ Node* coerce_type(ParseState* pstate, Node* node, Oid inputTypeId, Oid targetTyp
|
||||
newus->value = (Expr*)result;
|
||||
|
||||
pathtype = find_coercion_pathway(targetTypeId, inputTypeId, ccontext, &funcId);
|
||||
if (pathtype != COERCION_PATH_NONE) {
|
||||
if (pathtype != COERCION_PATH_RELABELTYPE) {
|
||||
switch (pathtype) {
|
||||
case COERCION_PATH_NONE:
|
||||
return (Node *)newus;
|
||||
break;
|
||||
case COERCION_PATH_RELABELTYPE: {
|
||||
result = coerce_to_domain((Node *)newus, InvalidOid, -1, targetTypeId, cformat, location, false, false);
|
||||
if (result == (Node *)newus) {
|
||||
RelabelType* r = makeRelabelType((Expr*)result, targetTypeId, -1, InvalidOid, cformat);
|
||||
|
||||
r->location = location;
|
||||
result = (Node*)r;
|
||||
}
|
||||
return result;
|
||||
} break;
|
||||
default: {
|
||||
Oid baseTypeId;
|
||||
int32 baseTypeMod;
|
||||
|
||||
baseTypeMod = targetTypeMod;
|
||||
baseTypeId = getBaseTypeAndTypmod(targetTypeId, &baseTypeMod);
|
||||
|
||||
result = build_coercion_expression(
|
||||
(Node *)newus, pathtype, funcId, baseTypeId, baseTypeMod, cformat, location, (cformat != COERCE_IMPLICIT_CAST));
|
||||
result = build_coercion_expression((Node *)newus, pathtype, funcId, baseTypeId,
|
||||
baseTypeMod, cformat, location, (cformat != COERCE_IMPLICIT_CAST));
|
||||
|
||||
if (targetTypeId != baseTypeId)
|
||||
if (targetTypeId != baseTypeId) {
|
||||
result = coerce_to_domain(result,
|
||||
baseTypeId,
|
||||
baseTypeMod,
|
||||
@ -704,18 +714,9 @@ Node* coerce_type(ParseState* pstate, Node* node, Oid inputTypeId, Oid targetTyp
|
||||
location,
|
||||
true,
|
||||
exprIsLengthCoercion(result, NULL));
|
||||
} else {
|
||||
result = coerce_to_domain((Node *)newus, InvalidOid, -1, targetTypeId, cformat, location, false, false);
|
||||
if (result == (Node *)newus) {
|
||||
RelabelType* r = makeRelabelType((Expr*)result, targetTypeId, -1, InvalidOid, cformat);
|
||||
|
||||
r->location = location;
|
||||
result = (Node*)r;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return (Node *)newus;
|
||||
}
|
||||
if (IsA(node, Param) && pstate != NULL && pstate->p_coerce_param_hook != NULL) {
|
||||
/*
|
||||
|
@ -1095,10 +1095,6 @@ static Datum ExecEvalConst(ExprState* exprstate, ExprContext* econtext, bool* is
|
||||
|
||||
/* if not found, return a null const */
|
||||
if (found) {
|
||||
if (entry->isParse) {
|
||||
con = (Const *)uservar->value;
|
||||
entry->isParse = false;
|
||||
} else {
|
||||
Oid target_type = InvalidOid;
|
||||
if (IsA(uservar->value, CoerceViaIO)) {
|
||||
target_type = ((CoerceViaIO *)uservar->value)->resulttype;
|
||||
@ -1117,7 +1113,6 @@ static Datum ExecEvalConst(ExprState* exprstate, ExprContext* econtext, bool* is
|
||||
}
|
||||
con = (Const *)node;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
con = makeConst(UNKNOWNOID, -1, InvalidOid, -2, (Datum)0, true, false);
|
||||
}
|
||||
|
@ -728,6 +728,7 @@ SELECT @r, (SELECT @r:= parent_id FROM my_table WHERE id = @r) AS parent_id2,
|
||||
@l:= @l+ 1 AS lvl FROM
|
||||
(SELECT @r:= 5, @l:= 0) vars,
|
||||
my_table h WHERE @r <>0;
|
||||
-- error, dolphin cast bigint to integer Implicit
|
||||
SELECT @r, (SELECT @r:= parent_id FROM my_table WHERE id = @r) AS parent_id2 FROM
|
||||
(SELECT @r:= 5) vars,
|
||||
my_table h WHERE @r<> 0;
|
||||
@ -761,6 +762,18 @@ INNER JOIN recursive_query r ON e.col_2 = (r.col_2 + INTERVAL '1year')
|
||||
SELECT col_1, col_2, col_3
|
||||
FROM recursive_query
|
||||
ORDER BY col_2 ASC;
|
||||
-- 自增-CONCAT-报错
|
||||
SET @counter := 0;
|
||||
SET @sequence := '';
|
||||
begin
|
||||
label_1:
|
||||
WHILE @counter < 10 DO
|
||||
SET @counter := @counter + 1;
|
||||
SET @sequence := CONCAT(@sequence, @counter, ', ');
|
||||
END WHILE label_1;
|
||||
end;
|
||||
/
|
||||
SELECT TRIM(TRAILING ', ' FROM @sequence);
|
||||
\c regression
|
||||
drop database if exists test_set;
|
||||
|
||||
|
@ -241,10 +241,10 @@ create table t_const as select @v1, @v2, @v3, @v4, @v5;
|
||||
Table "public.t_const"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
--------+------------------+-----------+----------+--------------+-------------
|
||||
@v1 | integer | | plain | |
|
||||
@v1 | bigint | | plain | |
|
||||
@v2 | double precision | | plain | |
|
||||
@v3 | text | | extended | |
|
||||
@v4 | integer | | plain | |
|
||||
@v4 | bigint | | plain | |
|
||||
@v5 | text | | extended | |
|
||||
Has OIDs: no
|
||||
Options: orientation=row, compression=no
|
||||
@ -405,8 +405,8 @@ create table res_select1 as select @v_select_bool1, @v_select_int1, @v_select_fl
|
||||
Table "public.res_select1"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
----------------------+------------------+-----------+----------+--------------+-------------
|
||||
@v_select_bool1 | integer | | plain | |
|
||||
@v_select_int1 | integer | | plain | |
|
||||
@v_select_bool1 | bigint | | plain | |
|
||||
@v_select_int1 | bigint | | plain | |
|
||||
@v_select_float1 | double precision | | plain | |
|
||||
@v_select_number1 | double precision | | plain | |
|
||||
@v_select_text1 | text | | extended | |
|
||||
@ -427,8 +427,8 @@ create table res_select2 as select @v_select_bool2, @v_select_int2, @v_select_fl
|
||||
Table "public.res_select2"
|
||||
Column | Type | Modifiers | Storage | Stats target | Description
|
||||
----------------------+------------------+-----------+----------+--------------+-------------
|
||||
@v_select_bool2 | integer | | plain | |
|
||||
@v_select_int2 | integer | | plain | |
|
||||
@v_select_bool2 | bigint | | plain | |
|
||||
@v_select_int2 | bigint | | plain | |
|
||||
@v_select_float2 | double precision | | plain | |
|
||||
@v_select_number2 | double precision | | plain | |
|
||||
@v_select_text2 | text | | extended | |
|
||||
@ -1450,17 +1450,11 @@ my_table h WHERE @r <>0;
|
||||
1 | | 4
|
||||
(4 rows)
|
||||
|
||||
-- error, dolphin cast bigint to integer Implicit
|
||||
SELECT @r, (SELECT @r:= parent_id FROM my_table WHERE id = @r) AS parent_id2 FROM
|
||||
(SELECT @r:= 5) vars,
|
||||
my_table h WHERE @r<> 0;
|
||||
@r | parent_id2
|
||||
----+------------
|
||||
5 | 4
|
||||
4 | 2
|
||||
2 | 1
|
||||
1 |
|
||||
(4 rows)
|
||||
|
||||
ERROR: failed to find conversion function from bigint to integer
|
||||
SELECT @r, (SELECT @r:= parent_id FROM my_table WHERE id = @r) AS parent_id2 FROM
|
||||
(SELECT @r:= 5) vars,
|
||||
my_table h WHERE @r<> 0;
|
||||
@ -1509,6 +1503,23 @@ ORDER BY col_2 ASC;
|
||||
dddd | 03-23-2023 | default col_3
|
||||
(2 rows)
|
||||
|
||||
-- 自增-CONCAT-报错
|
||||
SET @counter := 0;
|
||||
SET @sequence := '';
|
||||
begin
|
||||
label_1:
|
||||
WHILE @counter < 10 DO
|
||||
SET @counter := @counter + 1;
|
||||
SET @sequence := CONCAT(@sequence, @counter, ', ');
|
||||
END WHILE label_1;
|
||||
end;
|
||||
/
|
||||
SELECT TRIM(TRAILING ', ' FROM @sequence);
|
||||
rtrim
|
||||
-------------------------------
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|
||||
(1 row)
|
||||
|
||||
\c regression
|
||||
drop database if exists test_set;
|
||||
\! @abs_bindir@/gs_guc reload -Z datanode -D @abs_srcdir@/tmp_check/datanode1 -c "enable_set_variable_b_format=off" >/dev/null 2>&1
|
||||
|
Reference in New Issue
Block a user