Postgresql关于EOH的使用注意

注意通常拿到的指针不是EOH头

EOH是一种扩展数据结构,之前有几篇博客讨论过了,最近在改相关代码加深了一些理解。

EOH目前支持ER_methods、EA_methods两套实现,分别是record类型展开和数组类型展开。

在内存中的样子大概是(EA为例)

复制代码
typedef struct ExpandedArrayHeader
{
	ExpandedObjectHeader hdr;

	int			ea_magic;

	int			ndims;			/* # of dimensions */
	int		   *dims;			/* array dimensions */
	int		   *lbound;			/* index lower bounds for each dimension */

	Oid			element_type;	/* element type OID */
	int16		typlen;			/* needed info about element datatype */
	bool		typbyval;
	char		typalign;
	...
	...
	...
  • 注意:使用时传的不是指向EOH头部的指针,而是使用hdr->eoh_rw_ptr或hdr->eoh_ro_ptr中存放的指针(指向EOH头部)。
  • 注意eoh_rw_ptr和eoh_ro_ptr是1be结构,用DatumGetEOHP函数取出其中存放的指针。

使用时经常需要一层转换,例如这里:

注意使用value的逻辑一般都兼容EOH或valena结构

EOH使用EOH_flatten_into后会拉平数据,输出到result中紧凑存放。

一般的处理逻辑都可以适配EOH或这种紧凑形式,无需互相转换。

这就是为什么EOH只有flatten接口,没有生成EOH的接口,因为使用者适配了。

相关推荐
ZPC82104 小时前
Ubuntu 实时性优化(专属定制版,适配 fast_shm 通信)
linux·数据库·postgresql
有想法的py工程师8 小时前
PostgreSQL 在AWS的 T 系列实例上的性能陷阱
数据库·postgresql·aws
l1t17 小时前
DeepSeek总结的PostgreSQL 19查询提示功能
数据库·postgresql
dishugj1 天前
psql-客户端工具日常使用命令整理
数据库·postgresql
倒流时光三十年1 天前
PostgreSQL 大表字段扩长度 -- 会不会锁表?
数据库·postgresql
dishugj1 天前
PSQL常见报错问题以及解决方案
数据库·postgresql
逝水流痕Summer1 天前
PG触发器查询
数据库·postgresql
dishugj1 天前
在一台机器上启动多个PostgreSQL实例的方法
数据库·postgresql
Navicat中国1 天前
用 Navicat 来可视化 PostgreSQL GIS 数据,是否支持?
数据库·postgresql·gis·数据可视化·navicat
l1t1 天前
试用支持postgresql wire协议的duckdb服务器duckgres
服务器·数据库·postgresql