aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-02-22 19:23:23 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-02-22 19:24:40 -0500
commitbdca82f44d0e0168dece56cbd53b54ba142f328f (patch)
tree0a627b98d399ddce7b4523cf1d138e721a860f9d /src/include
parent1c51c7d5ffd407426f314b2cd317ef77f14efb1f (diff)
downloadpostgresql-bdca82f44d0e0168dece56cbd53b54ba142f328f.tar.gz
postgresql-bdca82f44d0e0168dece56cbd53b54ba142f328f.zip
Add a relkind field to RangeTblEntry to avoid some syscache lookups.
The recent additions for FDW support required checking foreign-table-ness in several places in the parse/plan chain. While it's not clear whether that would really result in a noticeable slowdown, it seems best to avoid any performance risk by keeping a copy of the relation's relkind in RangeTblEntry. That might have some other uses later, anyway. Per discussion.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/pg_class.h17
-rw-r--r--src/include/nodes/parsenodes.h7
3 files changed, 15 insertions, 11 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 70106414cfe..0a0544bc38a 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201102221
+#define CATALOG_VERSION_NO 201102222
#endif
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index 42bc8635a24..e103530a3f2 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -49,7 +49,7 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
Oid reltoastidxid; /* if toast table, OID of chunk_id index */
bool relhasindex; /* T if has (or has had) any indexes */
bool relisshared; /* T if shared across databases */
- char relpersistence; /* see RELPERSISTENCE_xxx constants */
+ char relpersistence; /* see RELPERSISTENCE_xxx constants below */
char relkind; /* see RELKIND_xxx constants below */
int2 relnatts; /* number of user attributes */
@@ -139,17 +139,18 @@ DESCR("");
DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 26 0 t f f f f 3 _null_ _null_ ));
DESCR("");
+
+#define RELKIND_RELATION 'r' /* ordinary table */
#define RELKIND_INDEX 'i' /* secondary index */
-#define RELKIND_RELATION 'r' /* ordinary cataloged heap */
-#define RELKIND_SEQUENCE 'S' /* SEQUENCE relation */
-#define RELKIND_UNCATALOGED 'u' /* temporary heap */
-#define RELKIND_TOASTVALUE 't' /* moved off huge values */
+#define RELKIND_SEQUENCE 'S' /* sequence object */
+#define RELKIND_TOASTVALUE 't' /* for out-of-line values */
#define RELKIND_VIEW 'v' /* view */
#define RELKIND_COMPOSITE_TYPE 'c' /* composite type */
#define RELKIND_FOREIGN_TABLE 'f' /* foreign table */
+#define RELKIND_UNCATALOGED 'u' /* not yet cataloged */
-#define RELPERSISTENCE_PERMANENT 'p'
-#define RELPERSISTENCE_UNLOGGED 'u'
-#define RELPERSISTENCE_TEMP 't'
+#define RELPERSISTENCE_PERMANENT 'p' /* regular table */
+#define RELPERSISTENCE_UNLOGGED 'u' /* unlogged permanent table */
+#define RELPERSISTENCE_TEMP 't' /* temporary table */
#endif /* PG_CLASS_H */
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 63a61e3da24..536c03245e3 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -597,6 +597,9 @@ typedef struct XmlSerialize
* like outer joins and join-output-column aliasing.) Other special
* RTE types also exist, as indicated by RTEKind.
*
+ * Note that we consider RTE_RELATION to cover anything that has a pg_class
+ * entry. relkind distinguishes the sub-cases.
+ *
* alias is an Alias node representing the AS alias-clause attached to the
* FROM expression, or NULL if no clause.
*
@@ -643,7 +646,7 @@ typedef struct XmlSerialize
* indicates no permissions checking). If checkAsUser is not zero,
* then do the permissions checks using the access rights of that user,
* not the current effective user ID. (This allows rules to act as
- * setuid gateways.)
+ * setuid gateways.) Permissions checks only apply to RELATION RTEs.
*
* For SELECT/INSERT/UPDATE permissions, if the user doesn't have
* table-wide permissions then it is sufficient to have the permissions
@@ -660,7 +663,6 @@ typedef enum RTEKind
RTE_RELATION, /* ordinary relation reference */
RTE_SUBQUERY, /* subquery in FROM */
RTE_JOIN, /* join */
- RTE_SPECIAL, /* special rule relation (NEW or OLD) */
RTE_FUNCTION, /* function in FROM */
RTE_VALUES, /* VALUES (<exprlist>), (<exprlist>), ... */
RTE_CTE /* common table expr (WITH list element) */
@@ -682,6 +684,7 @@ typedef struct RangeTblEntry
* Fields valid for a plain relation RTE (else zero):
*/
Oid relid; /* OID of the relation */
+ char relkind; /* relation kind (see pg_class.relkind) */
/*
* Fields valid for a subquery RTE (else NULL):