示例函数:
create or replace function ads.fn_create_tmp_tb (n integer, s character varying)returns voidas $$begincreate local temporary table if not exists tmp_tb_01 (idx integer, user_name character varying) insert into tmp_tb_01 (idx, user_name)select n, s raise notice '%', (select user_name from tmp_tb_01 where idx = n)end$$ language plpgsql示例调用:
select ads.fn_create_tmp_tb(1, 'Andy')select ads.fn_create_tmp_tb(2, 'Jack')
1) 在catalog 的makefile 中添加相应的系统表头文件./src/backend/catalog/Makefile:42: pg_foreign_table.h pg_partition_key.h \
2) 建表 -- 以pg_partition_key为例:
2.1)在include的 catalog目录下添加这张表的定义
#ifndef PG_PARTITION_KEY_H
#define PG_PARTITION_KEY_H
#include 'catalog/genbki.h'
#define PartitionKeyRelationId 3180
CATALOG(pg_partition_key,3180) BKI_WITHOUT_OIDS
{
Oid pkrelid
int16 pkattnum
} FormData_pg_partition_key
typedef FormData_pg_partition_key *Form_pg_partition_key
#define Natts_pg_partition_key 2
#define Anum_pg_partition_key_pkrelid 1
#define Anum_pg_partition_key_pkattnum 2
#endif
2.2) 在catalog 的indexing.h 头文件中添加系统表的唯一性索引
DECLARE_UNIQUE_INDEX(pg_partition_key_relid_index, 3181, on pg_partition_key using btree(pkrelid oid_ops))
#define PartitionKeyRelidIndexId 3181 r>3) Syscache -- 以 pg_partion_key为例:
3.1)首先要在syscache.h中添加 SysCacheIdentifier
3.2) 要在syscache.c 的 cacheinfo[] 中添加这张表
cache的定义:
struct cachedesc
{
insert into table1 values(数据) insert into table2 values(数据) insert into table3 values(数据) 一起提交就是多个表同时添加欢迎分享,转载请注明来源:内存溢出
评论列表(0条)