bloated heapam.h

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: bloated heapam.h
Date: 2008-05-09 18:56:10
Message-ID: 20080509185610.GJ5748@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I noticed heapam.h is included in way too many places. This is bad IMHO
because heapam.h itself includes a lot of other headers.

A lot of these are easy to fix; the source files just need to include
some other headers. Standard cleanup, I don't think anybody would
object to that. For example,

Index: src/backend/access/gin/ginvacuum.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/access/gin/ginvacuum.c,v
retrieving revision 1.19
diff -c -p -r1.19 ginvacuum.c
*** src/backend/access/gin/ginvacuum.c 1 Jan 2008 19:45:46 -0000 1.19
--- src/backend/access/gin/ginvacuum.c 9 May 2008 18:44:31 -0000
***************
*** 15,24 ****
#include "postgres.h"
#include "access/genam.h"
#include "access/gin.h"
- #include "access/heapam.h"
#include "miscadmin.h"
#include "storage/freespace.h"
! #include "storage/freespace.h"
#include "commands/vacuum.h"

typedef struct
--- 15,23 ----
#include "postgres.h"
#include "access/genam.h"
#include "access/gin.h"
#include "miscadmin.h"
#include "storage/freespace.h"
! #include "storage/lmgr.h"
#include "commands/vacuum.h"

typedef struct

Others are more conflictive. For example syncscan.c is keeping the
prototypes for its own functions on heapam.h. Also pruneheap.c and
rewriteheap.c. As a result, not only themselves need to include
heapam.h (without any other need for it), but they force some other
files into including heapam.h to get their prototypes. I think this is
a mistake; I propose splitting those prototypes to their own files, and
#including those as appropriate.

Objections?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2008-05-09 19:19:35 Re: constraint exclusion analysis caching
Previous Message Aidan Van Dyk 2008-05-09 18:51:51 Re: psql wrapped format default for backslash-d commands