Greenplum 自定义复合类型 数组

简介:

标签

PostgreSQL , Greenplum , composite type array


背景

如果你现在要在Greenplum中创建一个复合类型,是不会自动给你创建对应的数组类型的。(而实际上PostgreSQL 在2007年已经支持了这个功能)

Greenplum需要等到5.0,才能使用上它了。

https://github.com/greenplum-db/gpdb/commit/8954a537ee6199a80c38581fd3cd7ed463abbdea

Support arrays of composite types  
Backport from upstream with this commit:  
  
    commit bc8036f  
    Author: Tom Lane <tgl@sss.pgh.pa.us>  
    Date:   Fri May 11 17:57:14 2007 +0000  
  
        Support arrays of composite types, including the rowtypes of regular tables  
        and views (but not system catalogs, nor sequences or toast tables).  Get rid  
        of the hardwired convention that a type's array type is named exactly "_type",  
        instead using a new column pg_type.typarray to provide the linkage.  (It still  
        will be named "_type", though, except in odd corner cases such as  
        maximum-length type names.)  
  
        Along the way, make tracking of owner and schema dependencies for types more  
        uniform: a type directly created by the user has these dependencies, while a  
        table rowtype or auto-generated array type does not have them, but depends on  
        its parent object instead.  
  
        David Fetter, Andrew Dunstan, Tom Lane  
 master (#1)  5.0.0-alpha.1 5.0.0-alpha.0  
1 parent 5b33bee commit 8954a537ee6199a80c38581fd3cd7ed463abbdea @HaozhouWang HaozhouWang committed on 9 Mar 2016  

https://www.postgresql.org/docs/8.2/static/sql-createtype.html

Array Types

Whenever a user-defined base data type is created, PostgreSQL automatically creates an associated array type,   
whose name consists of the base type's name prepended with an underscore.   
The parser understands this naming convention, and translates requests for columns of type foo[] into requests for type _foo.   
The implicitly-created array type is variable length and uses the built-in input and output functions array_in and array_out.  
  
You might reasonably ask why there is an ELEMENT option, if the system makes the correct array type automatically.   
The only case where it's useful to use ELEMENT is when you are making a fixed-length type that happens to be internally an array of a number of identical things,  
and you want to allow these things to be accessed directly by subscripting, in addition to whatever operations you plan to provide for the type as a whole.   
For example, type name allows its constituent char elements to be accessed this way.   
A 2-D point type could allow its two component numbers to be accessed like point[0] and point[1].   
  
Note that this facility only works for fixed-length types whose internal form is exactly a sequence of identical fixed-length fields.   
A subscriptable variable-length type must have the generalized internal representation used by array_in and array_out. For historical reasons   
(i.e., this is clearly wrong but it's far too late to change it),   
subscripting of fixed-length array types starts from zero, rather than from one as for variable-length arrays.  
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍如何基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
5天前
|
人工智能 API 内存技术
刚刚 DeepSeek V4.1 Flash 开启内测,1 分钟教你用上!
刚刚 DeepSeek 内测群发布了 DeepSeek V4.1 Flash 中间版本内测的消息,这次的模型采用了新的结构,原生支持多模态、能力更强、速度更快、且成本更低。
1699 7
|
9天前
|
人工智能 运维 BI
阿里云千问办公QwenWork深度解析:基于Qwen3.8,六大核心能力重构企业全自动化工作流与计费选型指南
传统AI办公工具大多停留在对话问答、文档摘要、简单文案生成层面,只能完成单点碎片化任务,无法自主拆解复杂业务流程,很难串联多工具、多文档、外部业务系统完成端到端完整工作交付。很多企业在落地AI办公的时候,需要组合多款不同工具,来回切换界面,手动复制粘贴中间结果,智能化改造落地门槛居高不下。千问办公QwenWork是整合多款智能体产品能力打造的一体化企业办公智能体平台,底层基座依托Qwen3.8大模型,打通桌面端Agent、云端Agent、企业协同Agent三种运行形态,不再局限简单问答,接收业务目标之后自主拆解任务步骤,调用各类工具,处理文档、表格、浏览器自动化、数据查询,直接输出可交付的办公
1625 2
|
6天前
|
SQL 人工智能 前端开发
QoderWake 1.0 正式发布:从桌面里的 Agent,到工作现场的数字员工
QoderWake v1.0正式发布:企业级数字员工团队平台。支持“一句话建岗”,预置10类特训岗位;Waker常驻钉钉/飞书群,@即响应、自动协作、跨任务记忆;具备定时/事件/API多触发方式与统一任务看板;已沉淀27.6万条记忆、12.3万项技能,助力组织实现人机协同增效。
742 1
|
10天前
|
网络协议 Linux iOS开发
【2026实测】Wireshark下载+安装+汉化+使用教程(图文版,巨详细)
Wireshark 是一款免费开源的网络协议分析工具,可实时捕获、解析并可视化数据包,助你诊断网络故障、分析通信协议(如HTTP、DNS、TCP等)。支持Windows/macOS/Linux,含中文界面,新手入门便捷。(239字)
|
18天前
|
人工智能 自然语言处理 安全
阿里云千问办公、Qoder Teams、Qoder CN区别与选择指南:模型能力、适用场景与最新活动参考
本文聚焦阿里云2026年推出的三款自研AI办公产品,清晰拆解千问办公、Qoder Teams、Qoder CN的差异化定位与能力边界:千问办公主打职场全场景提效,支持自然语言指令一键完成PPT生成、数据分析等高频办公任务;Qoder Teams面向程序员团队,深度整合AI代码生成、团队协同与企业知识库能力;Qoder CN则专为金融、政务等强合规场景打造,实现数据不出境与VPC私有化部署。文章同步给出分场景选型指南与最新活动定价,帮助不同类型的企业按需组合产品,实现业务岗、研发岗与强合规场景的AI能力全覆盖。
3900 5
阿里云千问办公、Qoder Teams、Qoder CN区别与选择指南:模型能力、适用场景与最新活动参考
|
4天前
|
缓存 测试技术 API
DeepSeek V4.1 Flash 内测接入:改个模型名即可调用(附代码)
DeepSeek V4.1 Flash 内测不用申请,base_url 不变、改个模型名就能调,9/10 到期。本文讲清接入、计费限流与多模态注意点。
723 0
DeepSeek V4.1 Flash 内测接入:改个模型名即可调用(附代码)
|
9天前
|
人工智能 自然语言处理 安全
阿里云AI数智鉴密:AI 生成内容如何拿到一张"防篡改的身份证"
隐形水印 + C2PA签名:让AI生成内容“持证上岗”。
1147 0
|
11天前
|
缓存 数据可视化 开发工具
DeepSeek Harness 怎么更新?dsh 更新完整指南:更新本体(npx、npm、源码)与更新插件两种方式
DeepSeek Harness 的更新分两层:本体更新(npx 自动最新、npm update -g、源码 git pull)与插件更新(插件市场点更新、命令行覆盖安装)。本文按「准备 → 更新本体 → 更新插件 → 更新后检查」四步走,覆盖新手常见疑问。
1327 1
DeepSeek Harness 怎么更新?dsh 更新完整指南:更新本体(npx、npm、源码)与更新插件两种方式