!6623 解决A模式下使用union all创建视图 varchar类型字段在视图中未显示字符串长度的问题
Merge pull request !6623 from yanguotao/view_a_compatibility
This commit is contained in:
@ -4097,6 +4097,10 @@ static Node* transformSetOperationTree(ParseState* pstate, SelectStmt* stmt, boo
|
||||
/* if same type and same typmod, use typmod; else default */
|
||||
if (lcoltype == rcoltype && lcoltypmod == rcoltypmod) {
|
||||
rescoltypmod = lcoltypmod;
|
||||
} else if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT && lcoltype == rcoltype && \
|
||||
!(lcoltypmod == -1 || rcoltypmod == -1)) {
|
||||
/* same type, neither typmod is -1, select max */
|
||||
rescoltypmod = Max(lcoltypmod, rcoltypmod);
|
||||
} else {
|
||||
rescoltypmod = -1;
|
||||
}
|
||||
|
||||
@ -114,3 +114,25 @@ select relname from pg_class where relname = 'ttv1';
|
||||
reset restrict_nonsystem_relation_kind;
|
||||
drop view ttv1;
|
||||
drop table t1;
|
||||
create table tt3 (c1 varchar2(10),c2 varchar2(5));
|
||||
\d tt3;
|
||||
Table "public.tt3"
|
||||
Column | Type | Modifiers
|
||||
--------+-----------------------+-----------
|
||||
c1 | character varying(10) |
|
||||
c2 | character varying(5) |
|
||||
|
||||
create table tt_union(col1 varchar2(15));
|
||||
insert into tt_union values('1234567890abcdr');
|
||||
create view t_v3 as select c1 as id from tt3 union all select col1 from tt_union;
|
||||
\d t_v3;
|
||||
View "public.t_v3"
|
||||
Column | Type | Modifiers
|
||||
--------+-----------------------+-----------
|
||||
id | character varying(15) |
|
||||
|
||||
drop table tt3 cascade;
|
||||
NOTICE: drop cascades to view t_v3
|
||||
drop view t_v3 cascade;
|
||||
ERROR: view "t_v3" does not exist
|
||||
drop table tt_union cascade;
|
||||
|
||||
@ -93,3 +93,13 @@ select relname from pg_class where relname = 'ttv1';
|
||||
reset restrict_nonsystem_relation_kind;
|
||||
drop view ttv1;
|
||||
drop table t1;
|
||||
|
||||
create table tt3 (c1 varchar2(10),c2 varchar2(5));
|
||||
\d tt3;
|
||||
create table tt_union(col1 varchar2(15));
|
||||
insert into tt_union values('1234567890abcdr');
|
||||
create view t_v3 as select c1 as id from tt3 union all select col1 from tt_union;
|
||||
\d t_v3;
|
||||
drop table tt3 cascade;
|
||||
drop view t_v3 cascade;
|
||||
drop table tt_union cascade;
|
||||
|
||||
Reference in New Issue
Block a user