1. 如何修改Postgresql源码新增一张系统表
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
{
2. 如何安装并且开始调试PostgreSQL
如何安装并且开始调试PostgreSQL
1. 安装Linux操作系统
注意把gdb、Emacs或DDD这些开发工具都安装上。如果是在虚拟机上安装,依然需要山带设置Linux系统的网络环境;另外需要设置文件共享,方便windows下面的postgreSQL源码能在逗虚芦Linux下面访问到。
2. 安装PostgreSQL
useradd postgre
(自动建立 postgre 组;设计人员为了安全考虑,PostgreSQL 不能以root 用户运行,所以必须建立对应的用户和组。)
解压到 /usr/local/src
tar xvfz postgresql-8.4.tar.gz
cd postgresql-8.4
./configure --prefix=/usr/local/pgsql --enable-debug --enable-assert --without-readline --without-zlib
make
make install
chown -R postgre.postgre /usr/local/pgsql
3. 设置Postgres环境变量(非必须)
vi ~postgre/.bash_profile
添加:
PGLIB=/usr/local/pgsql/lib
PGDATA=$HOME/data
PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
export PGLIB PGDATA PATH MANPATH
4. 建立数据库
以 postgres 用户登录:
su postgre
建立数据库目录:
mkdir data
启动数据库引擎:
initdb –D “数据库目录”
之后可以根据提示,通过psql进入数据库
5. 构造PostgreSQL调试环境
先 psql template1进去,然后
select pg_backend_pid();
获得id,就是gdb后面用到的数字
gdb /usr/local/pgsql/bin/postgres 997(pid的数字)
如果只使誉信用gdb,全部是命令行界面;而Emac、DDD分别是彩色、黑白用户交互式图形界面。
6. 使用gdb进行调试