[sepostgresql/f15/master] upgrade base version to 9.0.3
KaiGai Kohei
kaigai at fedoraproject.org
Fri Apr 15 07:32:03 UTC 2011
commit 5de2a5408e9a3b58c1446bb7ddd614927c6cc840
Author: KaiGai Kohei <kaigai at kaigai.gr.jp>
Date: Fri Apr 15 09:29:12 2011 +0200
upgrade base version to 9.0.3
.gitignore | 1 +
sepostgresql-9.0-fullset.patch | 871 ++++++++++++++++++++++------------------
sepostgresql.spec | 12 +-
sources | 2 +-
4 files changed, 500 insertions(+), 386 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 1b4ef6d..81ff717 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
postgresql-9.0beta1.tar.gz
/postgresql-9.0.0.tar.gz
/postgresql-9.0.1.tar.gz
+/postgresql-9.0.3.tar.gz
diff --git a/sepostgresql-9.0-fullset.patch b/sepostgresql-9.0-fullset.patch
index f3dddff..e4b3c26 100644
--- a/sepostgresql-9.0-fullset.patch
+++ b/sepostgresql-9.0-fullset.patch
@@ -1,5 +1,182 @@
+ configure | 198 ++++++
+ configure.in | 13 +
+ contrib/adminpack/adminpack.c | 28 +-
+ src/Makefile.global.in | 1 +
+ src/backend/Makefile | 7 +-
+ src/backend/access/common/heaptuple.c | 14 +
+ src/backend/access/common/tupdesc.c | 20 +-
+ src/backend/access/gin/ginutil.c | 2 +-
+ src/backend/access/heap/heapam.c | 35 +
+ src/backend/access/heap/tuptoaster.c | 6 +
+ src/backend/access/transam/twophase.c | 2 +-
+ src/backend/access/transam/xact.c | 19 +
+ src/backend/access/transam/xlog.c | 2 +-
+ src/backend/bootstrap/bootparse.y | 7 +-
+ src/backend/bootstrap/bootstrap.c | 14 +
+ src/backend/catalog/Makefile | 4 +-
+ src/backend/catalog/aclchk.c | 20 +
+ src/backend/catalog/catalog.c | 6 +
+ src/backend/catalog/genbki.pl | 3 +-
+ src/backend/catalog/heap.c | 120 +++-
+ src/backend/catalog/index.c | 28 +-
+ src/backend/catalog/namespace.c | 26 +-
+ src/backend/catalog/pg_aggregate.c | 9 +-
+ src/backend/catalog/pg_conversion.c | 4 +-
+ src/backend/catalog/pg_largeobject.c | 65 ++-
+ src/backend/catalog/pg_namespace.c | 4 +-
+ src/backend/catalog/pg_operator.c | 21 +
+ src/backend/catalog/pg_proc.c | 8 +-
+ src/backend/catalog/pg_seclabel.c | 646 +++++++++++++++++++
+ src/backend/catalog/pg_type.c | 17 +-
+ src/backend/catalog/toasting.c | 12 +-
+ src/backend/commands/aggregatecmds.c | 4 +
+ src/backend/commands/alter.c | 61 ++
+ src/backend/commands/cluster.c | 23 +-
+ src/backend/commands/comment.c | 60 ++
+ src/backend/commands/conversioncmds.c | 16 +-
+ src/backend/commands/copy.c | 265 +++++++--
+ src/backend/commands/dbcommands.c | 87 +++
+ src/backend/commands/explain.c | 2 +-
+ src/backend/commands/foreigncmds.c | 39 ++
+ src/backend/commands/functioncmds.c | 82 +++-
+ src/backend/commands/indexcmds.c | 18 +-
+ src/backend/commands/lockcmds.c | 4 +
+ src/backend/commands/opclasscmds.c | 48 ++-
+ src/backend/commands/operatorcmds.c | 6 +
+ src/backend/commands/prepare.c | 2 +-
+ src/backend/commands/proclang.c | 10 +-
+ src/backend/commands/schemacmds.c | 57 ++-
+ src/backend/commands/sequence.c | 16 +
+ src/backend/commands/tablecmds.c | 509 +++++++++++++++-
+ src/backend/commands/tablespace.c | 64 ++
+ src/backend/commands/trigger.c | 11 +
+ src/backend/commands/tsearchcmds.c | 64 ++-
+ src/backend/commands/typecmds.c | 159 +++++-
+ src/backend/commands/user.c | 20 +
+ src/backend/commands/vacuum.c | 3 +
+ src/backend/commands/view.c | 4 +
+ src/backend/executor/execJunk.c | 5 +-
+ src/backend/executor/execMain.c | 63 ++-
+ src/backend/executor/execQual.c | 11 +-
+ src/backend/executor/execScan.c | 23 +-
+ src/backend/executor/execTuples.c | 17 +-
+ src/backend/executor/execUtils.c | 6 +-
+ src/backend/executor/functions.c | 6 +-
+ src/backend/executor/nodeAgg.c | 5 +-
+ src/backend/executor/nodeFunctionscan.c | 2 +-
+ src/backend/executor/nodeMergejoin.c | 4 +
+ src/backend/executor/nodeModifyTable.c | 76 +++-
+ src/backend/executor/nodeSubplan.c | 4 +-
+ src/backend/executor/nodeWindowAgg.c | 7 +
+ src/backend/executor/spi.c | 13 +-
+ src/backend/libpq/be-fsstubs.c | 40 +-
+ src/backend/nodes/copyfuncs.c | 19 +
+ src/backend/nodes/equalfuncs.c | 17 +
+ src/backend/nodes/outfuncs.c | 1 +
+ src/backend/nodes/readfuncs.c | 1 +
+ src/backend/optimizer/plan/planner.c | 11 +
+ src/backend/optimizer/util/clauses.c | 8 +-
+ src/backend/parser/analyze.c | 4 +-
+ src/backend/parser/gram.y | 120 ++++-
+ src/backend/parser/parse_relation.c | 12 +-
+ src/backend/parser/parse_target.c | 75 ++-
+ src/backend/parser/parse_utilcmd.c | 10 +-
+ src/backend/postmaster/postmaster.c | 45 ++-
+ src/backend/rewrite/rewriteDefine.c | 4 +
+ src/backend/rewrite/rewriteRemove.c | 4 +
+ src/backend/sepgsql/Makefile | 21 +
+ src/backend/sepgsql/attribute.c | 260 ++++++++
+ src/backend/sepgsql/avc.c | 503 +++++++++++++++
+ src/backend/sepgsql/blob.c | 245 ++++++++
+ src/backend/sepgsql/conversion.c | 147 +++++
+ src/backend/sepgsql/database.c | 201 ++++++
+ src/backend/sepgsql/fdw.c | 296 +++++++++
+ src/backend/sepgsql/file.c | 287 +++++++++
+ src/backend/sepgsql/label.c | 588 ++++++++++++++++++
+ src/backend/sepgsql/misc.c | 147 +++++
+ src/backend/sepgsql/operator.c | 454 ++++++++++++++
+ src/backend/sepgsql/proc.c | 366 +++++++++++
+ src/backend/sepgsql/relation.c | 819 +++++++++++++++++++++++++
+ src/backend/sepgsql/role.c | 142 +++++
+ src/backend/sepgsql/rowlv.c | 346 +++++++++++
+ src/backend/sepgsql/schema.c | 173 ++++++
+ src/backend/sepgsql/selinux.c | 690 +++++++++++++++++++++
+ src/backend/sepgsql/tablespace.c | 157 +++++
+ src/backend/sepgsql/tsearch.c | 524 ++++++++++++++++
+ src/backend/sepgsql/type.c | 314 ++++++++++
+ src/backend/storage/large_object/inv_api.c | 4 +-
+ src/backend/tcop/fastpath.c | 5 +
+ src/backend/tcop/pquery.c | 2 +-
+ src/backend/tcop/utility.c | 49 ++
+ src/backend/tsearch/wparser.c | 4 +-
+ src/backend/utils/adt/acl.c | 2 +-
+ src/backend/utils/adt/datetime.c | 4 +-
+ src/backend/utils/adt/dbsize.c | 6 +
+ src/backend/utils/adt/genfile.c | 9 +-
+ src/backend/utils/adt/lockfuncs.c | 2 +-
+ src/backend/utils/adt/misc.c | 2 +-
+ src/backend/utils/adt/pgstatfuncs.c | 2 +-
+ src/backend/utils/adt/ri_triggers.c | 24 +
+ src/backend/utils/adt/tid.c | 5 +
+ src/backend/utils/adt/trigfuncs.c | 4 +
+ src/backend/utils/adt/tsvector_op.c | 2 +-
+ src/backend/utils/cache/plancache.c | 8 +-
+ src/backend/utils/cache/relcache.c | 38 +-
+ src/backend/utils/cache/syscache.c | 24 +
+ src/backend/utils/fmgr/fmgr.c | 32 +-
+ src/backend/utils/fmgr/funcapi.c | 4 +-
+ src/backend/utils/init/postinit.c | 7 +
+ src/backend/utils/misc/guc.c | 74 ++-
+ src/backend/utils/misc/postgresql.conf.sample | 2 +
+ src/backend/utils/mmgr/portalmem.c | 2 +-
+ src/bin/initdb/initdb.c | 13 +
+ src/bin/pg_dump/pg_backup.h | 3 +-
+ src/bin/pg_dump/pg_backup_archiver.c | 81 +++-
+ src/bin/pg_dump/pg_backup_archiver.h | 9 +-
+ src/bin/pg_dump/pg_dump.c | 400 ++++++++++--
+ src/bin/pg_dump/pg_dump.h | 7 +
+ src/bin/pg_dump/pg_dumpall.c | 60 ++-
+ src/bin/pg_dump/pg_restore.c | 6 +
+ src/include/access/htup.h | 35 +-
+ src/include/access/sysattr.h | 3 +-
+ src/include/access/tupdesc.h | 5 +-
+ src/include/bootstrap/bootstrap.h | 1 +
+ src/include/catalog/heap.h | 16 +-
+ src/include/catalog/indexing.h | 5 +
+ src/include/catalog/pg_class.h | 28 +-
+ src/include/catalog/pg_conversion_fn.h | 2 +-
+ src/include/catalog/pg_largeobject.h | 3 +-
+ src/include/catalog/pg_namespace.h | 2 +-
+ src/include/catalog/pg_proc.h | 4 +
+ src/include/catalog/pg_proc_fn.h | 3 +-
+ src/include/catalog/pg_seclabel.h | 79 +++
+ src/include/catalog/pg_type_fn.h | 3 +-
+ src/include/catalog/toasting.h | 3 +
+ src/include/commands/alter.h | 1 +
+ src/include/commands/dbcommands.h | 1 +
+ src/include/commands/defrem.h | 2 +
+ src/include/commands/schemacmds.h | 1 +
+ src/include/commands/tablecmds.h | 7 +
+ src/include/commands/tablespace.h | 1 +
+ src/include/commands/typecmds.h | 2 +
+ src/include/executor/executor.h | 9 +-
+ src/include/fmgr.h | 1 +
+ src/include/nodes/nodes.h | 1 +
+ src/include/nodes/parsenodes.h | 17 +
+ src/include/parser/kwlist.h | 1 +
+ src/include/pg_config.h.in | 3 +
+ src/include/sepgsql/hooks.h | 293 +++++++++
+ src/include/sepgsql/sepgsql.h | 318 ++++++++++
+ src/include/storage/large_object.h | 2 +-
+ src/include/storage/lwlock.h | 1 +
+ src/include/utils/guc.h | 1 +
+ src/include/utils/syscache.h | 11 +
+ src/pl/plpgsql/src/pl_comp.c | 2 +-
+ src/test/regress/expected/sanity_check.out | 3 +-
+ 175 files changed, 11679 insertions(+), 375 deletions(-)
+
diff --git a/configure b/configure
-index c4ba09e..bbed799 100755
+index a4f4c9e..e8e71c1 100755
--- a/configure
+++ b/configure
@@ -708,6 +708,7 @@ LDFLAGS_EX
@@ -229,7 +406,7 @@ index c4ba09e..bbed799 100755
#
diff --git a/configure.in b/configure.in
-index c381505..14d0aba 100644
+index 26166d0..0a58c40 100644
--- a/configure.in
+++ b/configure.in
@@ -755,6 +755,19 @@ PGAC_ARG_BOOL(with, zlib, yes,
@@ -554,7 +731,7 @@ index 2a75820..065ba1a 100644
TupleDescInitEntry(state->tupdesc[i], (AttrNumber) 1, NULL,
INT2OID, -1, 0);
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
-index 48a387e..f00a9cc 100644
+index 1c93400..1236873 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -52,6 +52,7 @@
@@ -737,10 +914,10 @@ index 8436dea..d9de0e4 100644
CurrentTransactionState = s;
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
-index 15b3476..54a9105 100644
+index bb06a2e..77feebf 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
-@@ -8895,7 +8895,7 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
+@@ -8916,7 +8916,7 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
* Construct a tuple descriptor for the result row. This must match this
* function's pg_proc entry!
*/
@@ -860,7 +1037,7 @@ index a970039..0381d6b 100644
pg_foreign_data_wrapper.h pg_foreign_server.h pg_user_mapping.h \
pg_default_acl.h \
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
-index 0470a70..62fedb1 100644
+index 9b5602e..80be522 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -38,6 +38,7 @@
@@ -879,7 +1056,7 @@ index 0470a70..62fedb1 100644
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
-@@ -1500,6 +1502,10 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm,
+@@ -1506,6 +1508,10 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm,
if (curr_att == ObjectIdAttributeNumber && !classForm->relhasoids)
continue;
@@ -890,7 +1067,7 @@ index 0470a70..62fedb1 100644
/* Views don't have any system columns at all */
if (classForm->relkind == RELKIND_VIEW && curr_att < 0)
continue;
-@@ -1609,6 +1615,8 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
+@@ -1615,6 +1621,8 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
relOid, grantorId, ACL_KIND_COLUMN,
relname, attnum,
NameStr(pg_attribute_tuple->attname));
@@ -899,7 +1076,7 @@ index 0470a70..62fedb1 100644
/*
* Generate new ACL.
-@@ -1870,6 +1878,8 @@ ExecGrant_Relation(InternalGrant *istmt)
+@@ -1876,6 +1884,8 @@ ExecGrant_Relation(InternalGrant *istmt)
? ACL_KIND_SEQUENCE : ACL_KIND_CLASS,
NameStr(pg_class_tuple->relname),
0, NULL);
@@ -908,7 +1085,7 @@ index 0470a70..62fedb1 100644
/*
* Generate new ACL.
-@@ -2064,6 +2074,8 @@ ExecGrant_Database(InternalGrant *istmt)
+@@ -2070,6 +2080,8 @@ ExecGrant_Database(InternalGrant *istmt)
datId, grantorId, ACL_KIND_DATABASE,
NameStr(pg_database_tuple->datname),
0, NULL);
@@ -917,7 +1094,7 @@ index 0470a70..62fedb1 100644
/*
* Generate new ACL.
-@@ -2189,6 +2201,8 @@ ExecGrant_Fdw(InternalGrant *istmt)
+@@ -2195,6 +2207,8 @@ ExecGrant_Fdw(InternalGrant *istmt)
fdwid, grantorId, ACL_KIND_FDW,
NameStr(pg_fdw_tuple->fdwname),
0, NULL);
@@ -926,7 +1103,7 @@ index 0470a70..62fedb1 100644
/*
* Generate new ACL.
-@@ -2314,6 +2328,8 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
+@@ -2320,6 +2334,8 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
srvid, grantorId, ACL_KIND_FOREIGN_SERVER,
NameStr(pg_server_tuple->srvname),
0, NULL);
@@ -935,7 +1112,7 @@ index 0470a70..62fedb1 100644
/*
* Generate new ACL.
-@@ -2832,6 +2848,8 @@ ExecGrant_Namespace(InternalGrant *istmt)
+@@ -2838,6 +2854,8 @@ ExecGrant_Namespace(InternalGrant *istmt)
nspid, grantorId, ACL_KIND_NAMESPACE,
NameStr(pg_namespace_tuple->nspname),
0, NULL);
@@ -944,7 +1121,7 @@ index 0470a70..62fedb1 100644
/*
* Generate new ACL.
-@@ -2956,6 +2974,8 @@ ExecGrant_Tablespace(InternalGrant *istmt)
+@@ -2962,6 +2980,8 @@ ExecGrant_Tablespace(InternalGrant *istmt)
tblId, grantorId, ACL_KIND_TABLESPACE,
NameStr(pg_tablespace_tuple->spcname),
0, NULL);
@@ -1350,7 +1527,7 @@ index 47e0c9b..73cbfcf 100644
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
-index dea6889..18d96da 100644
+index 8af382b..01f53fd 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -39,6 +39,7 @@
@@ -1361,7 +1538,7 @@ index dea6889..18d96da 100644
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
-@@ -90,7 +91,8 @@ static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
+@@ -89,7 +90,8 @@ static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
Oid *classObjectId);
static void InitializeAttributeOids(Relation indexRelation,
int numatts, Oid indexoid);
@@ -1371,7 +1548,7 @@ index dea6889..18d96da 100644
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
IndexInfo *indexInfo,
Oid *classOids,
-@@ -155,7 +157,7 @@ ConstructTupleDescriptor(Relation heapRelation,
+@@ -154,7 +156,7 @@ ConstructTupleDescriptor(Relation heapRelation,
/*
* allocate the new tuple descriptor
*/
@@ -1380,7 +1557,7 @@ index dea6889..18d96da 100644
/*
* For simple index columns, we copy the pg_attribute row from the parent
-@@ -182,7 +184,8 @@ ConstructTupleDescriptor(Relation heapRelation,
+@@ -181,7 +183,8 @@ ConstructTupleDescriptor(Relation heapRelation,
* here we are indexing on a system attribute (-1...-n)
*/
from = SystemAttributeDefinition(atnum,
@@ -1390,7 +1567,7 @@ index dea6889..18d96da 100644
}
else
{
-@@ -339,13 +342,16 @@ InitializeAttributeOids(Relation indexRelation,
+@@ -338,13 +341,16 @@ InitializeAttributeOids(Relation indexRelation,
* ----------------------------------------------------------------
*/
static void
@@ -1408,7 +1585,7 @@ index dea6889..18d96da 100644
/*
* open the attribute relation and its indexes
*/
-@@ -367,7 +373,8 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
+@@ -366,7 +372,8 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
Assert(indexTupDesc->attrs[i]->attnum == i + 1);
Assert(indexTupDesc->attrs[i]->attcacheoff == -1);
@@ -1418,7 +1595,7 @@ index dea6889..18d96da 100644
}
CatalogCloseIndexes(indstate);
-@@ -545,6 +552,7 @@ index_create(Oid heapRelationId,
+@@ -544,6 +551,7 @@ index_create(Oid heapRelationId,
bool mapped_relation;
bool is_exclusion;
Oid namespaceId;
@@ -1426,7 +1603,7 @@ index dea6889..18d96da 100644
int i;
is_exclusion = (indexInfo->ii_ExclusionOps != NULL);
-@@ -682,15 +690,21 @@ index_create(Oid heapRelationId,
+@@ -681,15 +689,21 @@ index_create(Oid heapRelationId,
indexRelation->rd_rel->relam = accessMethodObjectId;
indexRelation->rd_rel->relkind = RELKIND_INDEX;
indexRelation->rd_rel->relhasoids = false;
@@ -1449,7 +1626,7 @@ index dea6889..18d96da 100644
/* done with pg_class */
heap_close(pg_class, RowExclusiveLock);
-@@ -706,7 +720,7 @@ index_create(Oid heapRelationId,
+@@ -705,7 +719,7 @@ index_create(Oid heapRelationId,
/*
* append ATTRIBUTE tuples for the index
*/
@@ -2716,7 +2893,7 @@ index cecdfa5..5b51f68 100644
+ }
+}
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
-index 7a1b8e8..69988d0 100644
+index 61020dc..f8408b4 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -30,12 +30,14 @@
@@ -2794,7 +2971,7 @@ index 7a1b8e8..69988d0 100644
/* The heap rewrite module does the rest */
rewrite_heap_tuple(rwstate, tuple, copiedTuple);
-@@ -1464,7 +1480,8 @@ get_tables_to_cluster(MemoryContext cluster_context)
+@@ -1469,7 +1485,8 @@ get_tables_to_cluster(MemoryContext cluster_context)
{
index = (Form_pg_index) GETSTRUCT(indexTuple);
@@ -4140,7 +4317,7 @@ index 26a3a52..e2b8683 100644
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FUNCTION),
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
-index 780dbc2..f471123 100644
+index a129511..6c2dbc4 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -40,6 +40,7 @@
@@ -4192,7 +4369,7 @@ index 780dbc2..f471123 100644
+
ReleaseSysCache(tuple);
- if (!reindex_relation(heapOid, true, false))
+ if (!reindex_relation(heapOid, true, 0))
@@ -1670,6 +1683,9 @@ ReindexDatabase(const char *databaseName, bool do_system, bool do_user)
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
databaseName);
@@ -4660,7 +4837,7 @@ index 292a427..3c8a36f 100644
if (!seqrel->rd_islocaltemp)
PreventCommandIfReadOnly("setval()");
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
-index c4d81bb..9516700 100644
+index 6a1804b..2453fcf 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -32,6 +32,7 @@
@@ -4916,7 +5093,7 @@ index c4d81bb..9516700 100644
/*
* Nothing to do here; Phase 3 does the work
*/
-@@ -3145,6 +3210,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
+@@ -3146,6 +3211,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
MemoryContext oldCxt;
List *dropped_attrs = NIL;
ListCell *lc;
@@ -4924,7 +5101,7 @@ index c4d81bb..9516700 100644
econtext = GetPerTupleExprContext(estate);
-@@ -3175,6 +3241,19 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
+@@ -3176,6 +3242,19 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
}
/*
@@ -4944,7 +5121,7 @@ index c4d81bb..9516700 100644
* Scan through the rows, generating a new row if needed and then
* checking all the constraints.
*/
-@@ -3191,11 +3270,16 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
+@@ -3192,11 +3271,16 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
if (newrel)
{
Oid tupOid = InvalidOid;
@@ -4961,7 +5138,7 @@ index c4d81bb..9516700 100644
/* Set dropped attributes to null in new tuple */
foreach(lc, dropped_attrs)
-@@ -3227,6 +3311,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
+@@ -3228,6 +3312,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
/* Preserve OID, if any */
if (newTupDesc->tdhasoid)
HeapTupleSetOid(tuple, tupOid);
@@ -4971,7 +5148,7 @@ index c4d81bb..9516700 100644
}
/* Now check any constraints on the possibly-changed tuple */
-@@ -3625,7 +3712,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse,
+@@ -3626,7 +3713,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse,
static void
ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
@@ -4980,7 +5157,7 @@ index c4d81bb..9516700 100644
{
Oid myrelid = RelationGetRelid(rel);
Relation pgclass,
-@@ -3639,6 +3726,10 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
+@@ -3640,6 +3727,10 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
int32 typmod;
Form_pg_type tform;
Expr *defval;
@@ -4991,7 +5168,7 @@ index c4d81bb..9516700 100644
attrdesc = heap_open(AttributeRelationId, RowExclusiveLock);
-@@ -3667,6 +3758,13 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
+@@ -3668,6 +3759,13 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
errmsg("child table \"%s\" has different type for column \"%s\"",
RelationGetRelationName(rel), colDef->colname)));
@@ -5005,7 +5182,7 @@ index c4d81bb..9516700 100644
/* If it's OID, child column must actually be OID */
if (isOid && childatt->attnum != ObjectIdAttributeNumber)
ereport(ERROR,
-@@ -3674,6 +3772,13 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
+@@ -3675,6 +3773,13 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
errmsg("child table \"%s\" has a conflicting \"%s\" column",
RelationGetRelationName(rel), colDef->colname)));
@@ -5019,7 +5196,7 @@ index c4d81bb..9516700 100644
/* Bump the existing child att's inhcount */
childatt->attinhcount++;
simple_heap_update(attrdesc, &tuple->t_self, tuple);
-@@ -3713,6 +3818,8 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
+@@ -3714,6 +3819,8 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
/* Determine the new attribute's number */
if (isOid)
newattnum = ObjectIdAttributeNumber;
@@ -5028,7 +5205,7 @@ index c4d81bb..9516700 100644
else
{
newattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1;
-@@ -3752,7 +3859,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
+@@ -3753,7 +3860,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
ReleaseSysCache(typeTuple);
@@ -5037,7 +5214,7 @@ index c4d81bb..9516700 100644
heap_close(attrdesc, RowExclusiveLock);
-@@ -3761,6 +3868,8 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
+@@ -3762,6 +3869,8 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
*/
if (isOid)
((Form_pg_class) GETSTRUCT(reltup))->relhasoids = true;
@@ -5046,7 +5223,7 @@ index c4d81bb..9516700 100644
else
((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum;
-@@ -3872,7 +3981,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
+@@ -3873,7 +3982,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
* If we are adding an OID column, we have to tell Phase 3 to rewrite the
* table to fix that.
*/
@@ -5055,7 +5232,7 @@ index c4d81bb..9516700 100644
tab->new_changeoids = true;
/*
-@@ -3925,6 +4034,31 @@ ATPrepAddOids(List **wqueue, Relation rel, bool recurse, AlterTableCmd *cmd)
+@@ -3926,6 +4035,31 @@ ATPrepAddOids(List **wqueue, Relation rel, bool recurse, AlterTableCmd *cmd)
}
/*
@@ -5087,7 +5264,7 @@ index c4d81bb..9516700 100644
* ALTER TABLE ALTER COLUMN DROP NOT NULL
*/
static void
-@@ -3936,6 +4070,9 @@ ATExecDropNotNull(Relation rel, const char *colName)
+@@ -3937,6 +4071,9 @@ ATExecDropNotNull(Relation rel, const char *colName)
List *indexoidlist;
ListCell *indexoidscan;
@@ -5097,7 +5274,7 @@ index c4d81bb..9516700 100644
/*
* lookup the attribute
*/
-@@ -4026,6 +4163,9 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
+@@ -4027,6 +4164,9 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
AttrNumber attnum;
Relation attr_rel;
@@ -5107,7 +5284,7 @@ index c4d81bb..9516700 100644
/*
* lookup the attribute
*/
-@@ -4076,6 +4216,9 @@ ATExecColumnDefault(Relation rel, const char *colName,
+@@ -4077,6 +4217,9 @@ ATExecColumnDefault(Relation rel, const char *colName,
{
AttrNumber attnum;
@@ -5117,7 +5294,7 @@ index c4d81bb..9516700 100644
/*
* get the number of the attribute
*/
-@@ -4150,6 +4293,9 @@ ATExecSetStatistics(Relation rel, const char *colName, Node *newValue)
+@@ -4151,6 +4294,9 @@ ATExecSetStatistics(Relation rel, const char *colName, Node *newValue)
HeapTuple tuple;
Form_pg_attribute attrtuple;
@@ -5127,7 +5304,7 @@ index c4d81bb..9516700 100644
Assert(IsA(newValue, Integer));
newtarget = intVal(newValue);
-@@ -4216,6 +4362,9 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
+@@ -4217,6 +4363,9 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
bool repl_null[Natts_pg_attribute];
bool repl_repl[Natts_pg_attribute];
@@ -5137,7 +5314,7 @@ index c4d81bb..9516700 100644
attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName);
-@@ -4275,6 +4424,9 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue)
+@@ -4276,6 +4425,9 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue)
HeapTuple tuple;
Form_pg_attribute attrtuple;
@@ -5147,7 +5324,7 @@ index c4d81bb..9516700 100644
Assert(IsA(newValue, String));
storagemode = strVal(newValue);
-@@ -4373,6 +4525,9 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
+@@ -4374,6 +4526,9 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
if (recursing)
ATSimplePermissions(rel, false);
@@ -5157,7 +5334,7 @@ index c4d81bb..9516700 100644
/*
* get the number of the attribute
*/
-@@ -4398,8 +4553,10 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
+@@ -4399,8 +4554,10 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
attnum = targetatt->attnum;
@@ -5170,7 +5347,7 @@ index c4d81bb..9516700 100644
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot drop system column \"%s\"",
-@@ -4515,7 +4672,8 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
+@@ -4516,7 +4673,8 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
* If we dropped the OID column, must adjust pg_class.relhasoids and tell
* Phase 3 to physically get rid of the column.
*/
@@ -5180,7 +5357,7 @@ index c4d81bb..9516700 100644
{
Relation class_rel;
Form_pg_class tuple_class;
-@@ -4530,7 +4688,11 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
+@@ -4531,7 +4689,11 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
RelationGetRelid(rel));
tuple_class = (Form_pg_class) GETSTRUCT(tuple);
@@ -5193,7 +5370,7 @@ index c4d81bb..9516700 100644
simple_heap_update(class_rel, &tuple->t_self, tuple);
/* Keep the catalog indexes up to date */
-@@ -4677,6 +4839,9 @@ ATAddCheckConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
+@@ -4678,6 +4840,9 @@ ATAddCheckConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
if (recursing)
ATSimplePermissions(rel, false);
@@ -5203,7 +5380,7 @@ index c4d81bb..9516700 100644
/*
* Call AddRelationNewConstraints to do the work, making sure it works on
* a copy of the Constraint so transformExpr can't modify the original. It
-@@ -4883,6 +5048,9 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
+@@ -4884,6 +5049,9 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
checkFkeyPermissions(pkrel, pkattnum, numpks);
checkFkeyPermissions(rel, fkattnum, numfks);
@@ -5213,7 +5390,7 @@ index c4d81bb..9516700 100644
/*
* Look up the equality operators to use in the constraint.
*
-@@ -5628,6 +5796,9 @@ ATExecDropConstraint(Relation rel, const char *constrName,
+@@ -5629,6 +5797,9 @@ ATExecDropConstraint(Relation rel, const char *constrName,
if (recursing)
ATSimplePermissions(rel, false);
@@ -5223,7 +5400,7 @@ index c4d81bb..9516700 100644
conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
/*
-@@ -5965,6 +6136,9 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
+@@ -5966,6 +6137,9 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
SysScanDesc scan;
HeapTuple depTup;
@@ -5233,7 +5410,7 @@ index c4d81bb..9516700 100644
attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
/* Look up the target column */
-@@ -6578,6 +6752,8 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing)
+@@ -6596,6 +6770,8 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing)
aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
get_namespace_name(namespaceOid));
}
@@ -5242,7 +5419,7 @@ index c4d81bb..9516700 100644
}
memset(repl_null, false, sizeof(repl_null));
-@@ -6743,6 +6919,9 @@ ATExecClusterOn(Relation rel, const char *indexName)
+@@ -6761,6 +6937,9 @@ ATExecClusterOn(Relation rel, const char *indexName)
{
Oid indexOid;
@@ -5252,7 +5429,7 @@ index c4d81bb..9516700 100644
indexOid = get_relname_relid(indexName, rel->rd_rel->relnamespace);
if (!OidIsValid(indexOid))
-@@ -6767,6 +6946,9 @@ ATExecClusterOn(Relation rel, const char *indexName)
+@@ -6785,6 +6964,9 @@ ATExecClusterOn(Relation rel, const char *indexName)
static void
ATExecDropCluster(Relation rel)
{
@@ -5262,7 +5439,7 @@ index c4d81bb..9516700 100644
mark_index_clustered(rel, InvalidOid);
}
-@@ -6817,6 +6999,9 @@ ATExecSetRelOptions(Relation rel, List *defList, bool isReset)
+@@ -6835,6 +7017,9 @@ ATExecSetRelOptions(Relation rel, List *defList, bool isReset)
bool repl_repl[Natts_pg_class];
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
@@ -5272,7 +5449,7 @@ index c4d81bb..9516700 100644
if (defList == NIL)
return; /* nothing to do */
-@@ -7145,6 +7330,9 @@ static void
+@@ -7163,6 +7348,9 @@ static void
ATExecEnableDisableTrigger(Relation rel, char *trigname,
char fires_when, bool skip_system)
{
@@ -5282,7 +5459,7 @@ index c4d81bb..9516700 100644
EnableDisableTrigger(rel, trigname, fires_when, skip_system);
}
-@@ -7157,6 +7345,9 @@ static void
+@@ -7175,6 +7363,9 @@ static void
ATExecEnableDisableRule(Relation rel, char *trigname,
char fires_when)
{
@@ -5292,7 +5469,7 @@ index c4d81bb..9516700 100644
EnableDisableRule(rel, trigname, fires_when);
}
-@@ -7199,6 +7390,10 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent)
+@@ -7217,6 +7408,10 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent)
*/
ATSimplePermissions(parent_rel, false);
@@ -5303,7 +5480,7 @@ index c4d81bb..9516700 100644
/* Permanent rels cannot inherit from temporary ones */
if (parent_rel->rd_istemp && !child_rel->rd_istemp)
ereport(ERROR,
-@@ -7551,6 +7746,9 @@ ATExecDropInherit(Relation rel, RangeVar *parent)
+@@ -7569,6 +7764,9 @@ ATExecDropInherit(Relation rel, RangeVar *parent)
List *connames;
bool found = false;
@@ -5313,7 +5490,7 @@ index c4d81bb..9516700 100644
/*
* AccessShareLock on the parent is probably enough, seeing that DROP
* TABLE doesn't lock parent tables at all. We need some lock since we'll
-@@ -7848,6 +8046,9 @@ AlterTableNamespace(RangeVar *relation, const char *newschema,
+@@ -7866,6 +8064,9 @@ AlterTableNamespace(RangeVar *relation, const char *newschema,
/* get schema OID and check its permissions */
nspOid = LookupCreationNamespace(newschema);
@@ -5323,7 +5500,7 @@ index c4d81bb..9516700 100644
if (oldNspOid == nspOid)
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_TABLE),
-@@ -8045,6 +8246,282 @@ AlterSeqNamespaces(Relation classRel, Relation rel,
+@@ -8063,6 +8264,282 @@ AlterSeqNamespaces(Relation classRel, Relation rel,
relation_close(depRel, AccessShareLock);
}
@@ -6454,7 +6631,7 @@ index c291529..dd0b12a 100644
CheckTableNotInUse(rel, "CREATE OR REPLACE VIEW");
diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c
-index 2fa7e68..c2b926c 100644
+index da22709..cbd4932 100644
--- a/src/backend/executor/execJunk.c
+++ b/src/backend/executor/execJunk.c
@@ -58,7 +58,8 @@
@@ -6477,7 +6654,7 @@ index 2fa7e68..c2b926c 100644
/*
* Use the given slot, or make a new slot if we weren't given one.
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
-index 0b6cbcc..fbce8e4 100644
+index 6d4a773..a8ad9a3 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -38,6 +38,7 @@
@@ -6520,7 +6697,7 @@ index 0b6cbcc..fbce8e4 100644
}
}
-@@ -829,6 +841,7 @@ InitPlan(QueryDesc *queryDesc, int eflags)
+@@ -826,6 +838,7 @@ InitPlan(QueryDesc *queryDesc, int eflags)
j = ExecInitJunkFilter(planstate->plan->targetlist,
tupType->tdhasoid,
@@ -6528,7 +6705,7 @@ index 0b6cbcc..fbce8e4 100644
ExecInitExtraTupleSlot(estate));
estate->es_junkFilter = j;
-@@ -1065,6 +1078,37 @@ ExecContextForcesOids(PlanState *planstate, bool *hasoids)
+@@ -1062,6 +1075,37 @@ ExecContextForcesOids(PlanState *planstate, bool *hasoids)
return false;
}
@@ -6566,7 +6743,7 @@ index 0b6cbcc..fbce8e4 100644
/* ----------------------------------------------------------------
* ExecEndPlan
*
-@@ -2073,6 +2117,7 @@ OpenIntoRel(QueryDesc *queryDesc)
+@@ -2130,6 +2174,7 @@ OpenIntoRel(QueryDesc *queryDesc)
Oid intoRelationId;
TupleDesc tupdesc;
DR_intorel *myState;
@@ -6574,7 +6751,7 @@ index 0b6cbcc..fbce8e4 100644
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
Assert(into);
-@@ -2144,6 +2189,14 @@ OpenIntoRel(QueryDesc *queryDesc)
+@@ -2201,6 +2246,14 @@ OpenIntoRel(QueryDesc *queryDesc)
get_tablespace_name(tablespaceId));
}
@@ -6589,7 +6766,7 @@ index 0b6cbcc..fbce8e4 100644
/* Parse and validate any reloptions */
reloptions = transformRelOptions((Datum) 0,
into->options,
-@@ -2174,7 +2227,8 @@ OpenIntoRel(QueryDesc *queryDesc)
+@@ -2231,7 +2284,8 @@ OpenIntoRel(QueryDesc *queryDesc)
into->onCommit,
reloptions,
true,
@@ -6599,7 +6776,7 @@ index 0b6cbcc..fbce8e4 100644
FreeTupleDesc(tupdesc);
-@@ -2298,6 +2352,11 @@ intorel_receive(TupleTableSlot *slot, DestReceiver *self)
+@@ -2355,6 +2409,11 @@ intorel_receive(TupleTableSlot *slot, DestReceiver *self)
*/
if (myState->rel->rd_rel->relhasoids)
HeapTupleSetOid(tuple, InvalidOid);
@@ -6823,7 +7000,7 @@ index 5886c1b..50f91f5 100644
}
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
-index ea2cfc9..7b489db 100644
+index 75fc173..99cb650 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -1153,7 +1153,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
@@ -6835,7 +7012,7 @@ index ea2cfc9..7b489db 100644
}
else if (fn_typtype == TYPTYPE_COMPOSITE || rettype == RECORDOID)
{
-@@ -1192,7 +1192,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
+@@ -1197,7 +1197,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
}
/* Set up junk filter if needed */
if (junkFilter)
@@ -6844,7 +7021,7 @@ index ea2cfc9..7b489db 100644
return false; /* NOT returning whole tuple */
}
}
-@@ -1205,7 +1205,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
+@@ -1210,7 +1210,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
* what the caller expects will happen at runtime.
*/
if (junkFilter)
@@ -6919,7 +7096,7 @@ index 948f580..7d9f4f4 100644
fmgr_info(cmpproc, &(clause->cmpfinfo));
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
-index 9699381..03afb4e 100644
+index f4b2b16..62c76b5 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -38,11 +38,13 @@
@@ -7049,7 +7226,7 @@ index 9699381..03afb4e 100644
/*
* Reset the per-output-tuple exprcontext. This is needed because
* triggers expect to use that context as workspace. It's a bit ugly
-@@ -713,6 +768,14 @@ ExecModifyTable(ModifyTableState *node)
+@@ -714,6 +769,14 @@ ExecModifyTable(ModifyTableState *node)
if (junkfilter != NULL)
{
@@ -7064,7 +7241,7 @@ index 9699381..03afb4e 100644
/*
* extract the 'ctid' junk attribute.
*/
-@@ -742,11 +805,11 @@ ExecModifyTable(ModifyTableState *node)
+@@ -743,11 +806,11 @@ ExecModifyTable(ModifyTableState *node)
switch (operation)
{
case CMD_INSERT:
@@ -7078,7 +7255,7 @@ index 9699381..03afb4e 100644
break;
case CMD_DELETE:
slot = ExecDelete(tupleid, planSlot,
-@@ -858,7 +921,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
+@@ -855,7 +918,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
* RETURNING list. We assume the rest will look the same.
*/
tupDesc = ExecTypeFromTL((List *) linitial(node->returningLists),
@@ -7087,7 +7264,7 @@ index 9699381..03afb4e 100644
/* Set up a slot for the output of the RETURNING projection(s) */
ExecInitResultTupleSlot(estate, &mtstate->ps);
-@@ -892,7 +955,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
+@@ -889,7 +952,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
* We still must construct a dummy result tuple type, because InitPlan
* expects one (maybe should change that?).
*/
@@ -7096,7 +7273,7 @@ index 9699381..03afb4e 100644
ExecInitResultTupleSlot(estate, &mtstate->ps);
ExecAssignResultType(&mtstate->ps, tupDesc);
-@@ -984,6 +1047,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
+@@ -986,6 +1049,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
j = ExecInitJunkFilter(subplan->targetlist,
resultRelInfo->ri_RelationDesc->rd_att->tdhasoid,
@@ -7374,10 +7551,10 @@ index 464183d..67d0316 100644
PG_RETURN_INT32(0);
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
-index 6e6844b..8d58a17 100644
+index 0b2aa3d..90bb7d4 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
-@@ -1825,6 +1825,7 @@ _copyRangeTblEntry(RangeTblEntry *from)
+@@ -1823,6 +1823,7 @@ _copyRangeTblEntry(RangeTblEntry *from)
COPY_SCALAR_FIELD(checkAsUser);
COPY_BITMAPSET_FIELD(selectedCols);
COPY_BITMAPSET_FIELD(modifiedCols);
@@ -7385,7 +7562,7 @@ index 6e6844b..8d58a17 100644
return newnode;
}
-@@ -2757,6 +2758,21 @@ _copyAlterOwnerStmt(AlterOwnerStmt *from)
+@@ -2755,6 +2756,21 @@ _copyAlterOwnerStmt(AlterOwnerStmt *from)
return newnode;
}
@@ -7407,7 +7584,7 @@ index 6e6844b..8d58a17 100644
static RuleStmt *
_copyRuleStmt(RuleStmt *from)
{
-@@ -3971,6 +3987,9 @@ copyObject(void *from)
+@@ -3972,6 +3988,9 @@ copyObject(void *from)
case T_AlterOwnerStmt:
retval = _copyAlterOwnerStmt(from);
break;
@@ -7460,10 +7637,10 @@ index 6e00584..2adfa91 100644
retval = _equalRuleStmt(a, b);
break;
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
-index ae0e2ab..36eee35 100644
+index 032150e..63f6b77 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
-@@ -2137,6 +2137,7 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
+@@ -2143,6 +2143,7 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
WRITE_OID_FIELD(checkAsUser);
WRITE_BITMAPSET_FIELD(selectedCols);
WRITE_BITMAPSET_FIELD(modifiedCols);
@@ -7484,7 +7661,7 @@ index f28191d..f6f31e5 100644
READ_DONE();
}
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
-index 317a7e8..5b88ad6 100644
+index 45ba902..be917ec 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -39,6 +39,7 @@
@@ -7513,7 +7690,7 @@ index 317a7e8..5b88ad6 100644
* pullup (so that all non-inherited RTEs are present) and before
* inheritance expansion (so that the info is available for
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
-index 8486516..acd6bac 100644
+index 8902b5b..321bba9 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -38,6 +38,7 @@
@@ -7524,7 +7701,7 @@ index 8486516..acd6bac 100644
#include "tcop/tcopprot.h"
#include "utils/acl.h"
#include "utils/builtins.h"
-@@ -3724,6 +3725,10 @@ inline_function(Oid funcid, Oid result_type, List *args,
+@@ -3752,6 +3753,10 @@ inline_function(Oid funcid, Oid result_type, List *args,
if (pg_proc_aclcheck(funcid, GetUserId(), ACL_EXECUTE) != ACLCHECK_OK)
return NULL;
@@ -7535,7 +7712,7 @@ index 8486516..acd6bac 100644
/*
* Make a temporary memory context, so that we don't leak all the stuff
* that parsing might create.
-@@ -4176,7 +4181,8 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
+@@ -4205,7 +4210,8 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
funcform->provolatile == PROVOLATILE_VOLATILE ||
funcform->prosecdef ||
!funcform->proretset ||
@@ -7546,7 +7723,7 @@ index 8486516..acd6bac 100644
ReleaseSysCache(func_tuple);
return NULL;
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
-index 1576613..51e197f 100644
+index 70cdb59..1a88724 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -25,6 +25,7 @@
@@ -7565,7 +7742,7 @@ index 1576613..51e197f 100644
#include "utils/rel.h"
-@@ -651,7 +653,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
+@@ -660,7 +662,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
tle = makeTargetEntry(expr,
attr_num,
col->name,
@@ -7575,7 +7752,7 @@ index 1576613..51e197f 100644
rte->modifiedCols = bms_add_member(rte->modifiedCols,
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
-index 50ed871..d6b13da 100644
+index 05ff082..acb1799 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -183,8 +183,8 @@ static TypeName *TableFuncTypeName(List *columns);
@@ -7615,7 +7792,7 @@ index 50ed871..d6b13da 100644
| AlterSeqStmt
| AlterTableStmt
| AlterRoleSetStmt
-@@ -1758,6 +1761,20 @@ alter_table_cmd:
+@@ -1761,6 +1764,20 @@ alter_table_cmd:
n->subtype = AT_DropOids;
$$ = (Node *)n;
}
@@ -7636,7 +7813,7 @@ index 50ed871..d6b13da 100644
/* ALTER TABLE <name> CLUSTER ON <indexname> */
| CLUSTER ON name
{
-@@ -6027,6 +6044,102 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
+@@ -6028,6 +6045,102 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
}
;
@@ -7980,7 +8157,7 @@ index d1e1dac..8e994da 100644
cxt.ckconstraints = NIL;
cxt.fkconstraints = NIL;
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
-index 4666fd6..784723d 100644
+index 279f0f0..f91f746 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -109,6 +109,7 @@
@@ -8021,7 +8198,7 @@ index 4666fd6..784723d 100644
/* If we need to signal the autovacuum launcher, do so now */
if (avlauncher_needs_signal)
{
-@@ -2120,6 +2128,8 @@ SIGHUP_handler(SIGNAL_ARGS)
+@@ -2125,6 +2133,8 @@ SIGHUP_handler(SIGNAL_ARGS)
signal_child(SysLoggerPID, SIGHUP);
if (PgStatPID != 0)
signal_child(PgStatPID, SIGHUP);
@@ -8030,7 +8207,7 @@ index 4666fd6..784723d 100644
/* Reload authentication config files too */
if (!load_hba())
-@@ -2180,6 +2190,9 @@ pmdie(SIGNAL_ARGS)
+@@ -2185,6 +2195,9 @@ pmdie(SIGNAL_ARGS)
/* and the walwriter too */
if (WalWriterPID != 0)
signal_child(WalWriterPID, SIGTERM);
@@ -8040,7 +8217,7 @@ index 4666fd6..784723d 100644
/*
* If we're in recovery, we can't kill the startup process
-@@ -2242,6 +2255,9 @@ pmdie(SIGNAL_ARGS)
+@@ -2247,6 +2260,9 @@ pmdie(SIGNAL_ARGS)
/* and the walwriter too */
if (WalWriterPID != 0)
signal_child(WalWriterPID, SIGTERM);
@@ -8050,7 +8227,7 @@ index 4666fd6..784723d 100644
pmState = PM_WAIT_BACKENDS;
}
-@@ -2277,6 +2293,8 @@ pmdie(SIGNAL_ARGS)
+@@ -2282,6 +2298,8 @@ pmdie(SIGNAL_ARGS)
signal_child(PgArchPID, SIGQUIT);
if (PgStatPID != 0)
signal_child(PgStatPID, SIGQUIT);
@@ -8059,7 +8236,7 @@ index 4666fd6..784723d 100644
ExitPostmaster(0);
break;
}
-@@ -2549,6 +2567,16 @@ reaper(SIGNAL_ARGS)
+@@ -2554,6 +2572,16 @@ reaper(SIGNAL_ARGS)
continue;
}
@@ -8076,7 +8253,7 @@ index 4666fd6..784723d 100644
/*
* Else do standard backend child cleanup.
*/
-@@ -2765,6 +2793,18 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
+@@ -2770,6 +2798,18 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
signal_child(AutoVacPID, (SendStop ? SIGSTOP : SIGQUIT));
}
@@ -8095,7 +8272,7 @@ index 4666fd6..784723d 100644
/*
* Force a power-cycle of the pgarch process too. (This isn't absolutely
* necessary, but it seems like a good idea for robustness, and it
-@@ -2921,7 +2961,8 @@ PostmasterStateMachine(void)
+@@ -2926,7 +2966,8 @@ PostmasterStateMachine(void)
WalReceiverPID == 0 &&
(BgWriterPID == 0 || !FatalError) &&
WalWriterPID == 0 &&
@@ -10159,10 +10336,10 @@ index 0000000..9a9e8a3
+}
diff --git a/src/backend/sepgsql/label.c b/src/backend/sepgsql/label.c
new file mode 100644
-index 0000000..7ab355c
+index 0000000..ec8244d
--- /dev/null
+++ b/src/backend/sepgsql/label.c
-@@ -0,0 +1,656 @@
+@@ -0,0 +1,588 @@
+/*
+ * label.c
+ * SE-PostgreSQL security label management
@@ -10192,6 +10369,7 @@ index 0000000..7ab355c
+#include "utils/tqual.h"
+#include <fnmatch.h> // for workaround hack
+#include <selinux/selinux.h>
++#include <selinux/label.h>
+
+/*
+ * guc parameter to turn on/off mcstrans
@@ -10380,256 +10558,212 @@ index 0000000..7ab355c
+ return nsid.secid;
+}
+
-+/*
-+ * a workaround implementation until libselinux/refpolicy don't
-+ * support db_schema or other object classes.
-+ */
-+static struct {
-+ uint16 tclass;
-+ char *pattern;
-+ char *context;
-+} initial_label_catalog[] = {
-+ {SEPG_CLASS_DB_DATABASE, "*",
-+ "system_u:object_r:sepgsql_db_t:s0"},
-+ {SEPG_CLASS_DB_SCHEMA, "*.*",
-+ "system_u:object_r:sepgsql_db_t:s0"},
-+ {SEPG_CLASS_DB_TABLE, "*.pg_catalog.*",
-+ "system_u:object_r:sepgsql_sysobj_t:s0"},
-+ {SEPG_CLASS_DB_TABLE, "*.*.*",
-+ "system_u:object_r:sepgsql_table_t:s0"},
-+ {SEPG_CLASS_DB_VIEW, "*.*.*",
-+ "system_u:object_r:sepgsql_db_t:s0"},
-+ {SEPG_CLASS_DB_SEQUENCE, "*.*.*",
-+ "system_u:object_r:sepgsql_db_t:s0"},
-+ {SEPG_CLASS_DB_PROCEDURE, "*.pg_catalog.*",
-+ "system_u:object_r:sepgsql_proc_exec_t:s0"},
-+ {SEPG_CLASS_DB_PROCEDURE, "*.*.*",
-+ "system_u:object_r:sepgsql_user_proc_exec_t:s0"},
-+ {SEPG_CLASS_DB_COLUMN, "*.pg_catalog.*.*",
-+ "system_u:object_r:sepgsql_sysobj_t:s0"},
-+ {SEPG_CLASS_DB_COLUMN, "*.*.*.*",
-+ "system_u:object_r:sepgsql_table_t:s0"},
-+ {SEPG_CLASS_DB_TUPLE, "*.pg_catalog.*",
-+ "system_u:object_r:sepgsql_sysobj_t:s0"},
-+ {SEPG_CLASS_DB_TUPLE, "*.*.*",
-+ "system_u:object_r:sepgsql_table_t:s0"},
-+ {SEPG_CLASS_DB_BLOB, "*.*",
-+ "system_u:object_r:sepgsql_blob_t:s0"},
-+ {0, NULL, NULL},
-+};
-+
-+static char *
-+lookup_init_catalog(uint16 tclass, const char *name)
++static Oid
++sepgsql_initial_labeling_lookup(struct selabel_handle *sehnd,
++ Oid relationId, HeapTuple tuple)
+{
-+ int i;
++ Form_pg_database datForm;
++ Form_pg_namespace nspForm;
++ Form_pg_class clsForm;
++ Form_pg_attribute attForm;
++ Form_pg_proc proForm;
++ char namebuf[NAMEDATALEN * 3 + 10];
++ Oid namespaceId;
++ Oid securityId = InvalidOid;
++ int type = 0;
++ security_context_t context;
+
-+ for (i = 0; initial_label_catalog[i].pattern; i++)
++ switch (relationId)
+ {
-+ if (initial_label_catalog[i].tclass == tclass &&
-+ fnmatch(initial_label_catalog[i].pattern, name, 0) == 0)
-+ return initial_label_catalog[i].context;
-+ }
-+ elog(ERROR, "no valid initial security context for %s (tclass=%d)",
-+ name, tclass);
-+ return NULL; /* for compiler quiet */
-+}
++ case DatabaseRelationId:
++ datForm = (Form_pg_database) GETSTRUCT(tuple);
++ snprintf(namebuf, sizeof(namebuf), "%s",
++ NameStr(datForm->datname));
++ type = SELABEL_DB_DATABASE;
++ break;
+
-+static char *
-+lookup_init_tuple_label(Oid relOid, HeapTuple tuple)
-+{
-+ Oid relNsp = get_rel_namespace(relOid);
-+ char namebuf[NAMEDATALEN * 3 + 10];
++ case NamespaceRelationId:
++ nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
++ snprintf(namebuf, sizeof(namebuf), "%s.%s",
++ get_database_name(MyDatabaseId),
++ NameStr(nspForm->nspname));
++ type = SELABEL_DB_SCHEMA;
++ break;
+
-+ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
-+ get_database_name(MyDatabaseId),
-+ get_namespace_name(relNsp),
-+ get_rel_name(relOid));
++ case RelationRelationId:
++ clsForm = (Form_pg_class) GETSTRUCT(tuple);
++ namespaceId = clsForm->relnamespace;
++ switch (clsForm->relkind)
++ {
++ case RELKIND_RELATION:
++ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
++ get_database_name(MyDatabaseId),
++ get_namespace_name(namespaceId),
++ NameStr(clsForm->relname));
++ type = SELABEL_DB_TABLE;
++ break;
+
-+ return lookup_init_catalog(SEPG_CLASS_DB_TUPLE, namebuf);
-+}
++ case RELKIND_SEQUENCE:
++ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
++ get_database_name(MyDatabaseId),
++ get_namespace_name(namespaceId),
++ NameStr(clsForm->relname));
++ type = SELABEL_DB_SEQUENCE;
++ break;
+
-+static char *
-+lookup_init_database_label(HeapTuple tuple)
-+{
-+ Form_pg_database datForm = (Form_pg_database) GETSTRUCT(tuple);
++ case RELKIND_VIEW:
++ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
++ get_database_name(MyDatabaseId),
++ get_namespace_name(namespaceId),
++ NameStr(clsForm->relname));
++ type = SELABEL_DB_VIEW;
++ break;
+
-+ return lookup_init_catalog(SEPG_CLASS_DB_DATABASE,
-+ NameStr(datForm->datname));
-+}
++ case RELKIND_INDEX: {
++ HeapTuple tbltup;
++ HeapTuple indtup;
++ Oid tableId;
+
-+static char *
-+lookup_init_schema_label(HeapTuple tuple)
-+{
-+ Form_pg_namespace nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
-+ char namebuf[NAMEDATALEN * 2 + 10];
++ indtup = SearchSysCache1(INDEXRELID,
++ ObjectIdGetDatum(HeapTupleGetOid(tuple)));
++ if (!HeapTupleIsValid(indtup))
++ elog(ERROR, "cache lookup failed for index %u",
++ HeapTupleGetOid(tuple));
+
-+ snprintf(namebuf, sizeof(namebuf), "%s.%s",
-+ get_database_name(MyDatabaseId),
-+ NameStr(nspForm->nspname));
++ tableId = ((Form_pg_index) GETSTRUCT(indtup))->indrelid;
++ tbltup = SearchSysCache1(RELOID, ObjectIdGetDatum(tableId));
++ if (!HeapTupleIsValid(tbltup))
++ elog(ERROR, "cache lookup failed for relation %u", tableId);
+
-+ return lookup_init_catalog(SEPG_CLASS_DB_SCHEMA, namebuf);
-+}
++ securityId = sepgsql_initial_labeling_lookup(sehnd, RelationRelationId, tbltup);
+
-+static char *
-+lookup_init_relation_label(HeapTuple tuple)
-+{
-+ Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
-+ const char *relName = NameStr(classForm->relname);
-+ Oid relNsp = classForm->relnamespace;
-+ char *seclabel;
-+ char namebuf[NAMEDATALEN * 3 + 10];
++ ReleaseSysCache(tbltup);
++ ReleaseSysCache(indtup);
+
-+ switch (classForm->relkind)
-+ {
-+ case RELKIND_RELATION:
-+ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
-+ get_database_name(MyDatabaseId),
-+ get_namespace_name(relNsp), relName);
-+ seclabel = lookup_init_catalog(SEPG_CLASS_DB_TABLE, namebuf);
-+ break;
++ return securityId;
++ }
++ case RELKIND_TOASTVALUE: {
++ HeapTuple tbltup;
++ Oid tableId;
+
-+ case RELKIND_SEQUENCE:
-+ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
-+ get_database_name(MyDatabaseId),
-+ get_namespace_name(relNsp), relName);
-+ seclabel = lookup_init_catalog(SEPG_CLASS_DB_SEQUENCE, namebuf);
-+ break;
++ /*
++ * XXX - we assume all the toast relation's name is
++ * "pg_toast_%u", and the "%u" shall be replaced by OID
++ * of the relation which owns the toast relation
++ */
++ tableId = strtoul(NameStr(clsForm->relname) + 9, NULL, 10);
+
-+ case RELKIND_VIEW:
-+ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
-+ get_database_name(MyDatabaseId),
-+ get_namespace_name(relNsp), relName);
-+ seclabel = lookup_init_catalog(SEPG_CLASS_DB_VIEW, namebuf);
-+ break;
++ tbltup = SearchSysCache1(RELOID,
++ ObjectIdGetDatum(tableId));
++ if (!HeapTupleIsValid(tbltup))
++ elog(ERROR, "cache lookup failed for relation %u", tableId);
+
-+ case RELKIND_INDEX: {
-+ HeapTuple tbltup;
-+ HeapTuple indtup;
-+ Oid tblOid;
-+ Oid indOid = HeapTupleGetOid(tuple);
++ securityId = sepgsql_initial_labeling_lookup(sehnd, RelationRelationId, tbltup);
+
-+ indtup = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indOid));
-+ if (!HeapTupleIsValid(indtup))
-+ elog(ERROR, "cache lookup failed for index %u", indOid);
++ ReleaseSysCache(tbltup);
+
-+ tblOid = ((Form_pg_index) GETSTRUCT(indtup))->indrelid;
-+ tbltup = SearchSysCache1(RELOID, ObjectIdGetDatum(tblOid));
-+ if (!HeapTupleIsValid(tbltup))
-+ elog(ERROR, "cache lookup failed for relation %u", tblOid);
++ return securityId;
++ }
++ case RELKIND_COMPOSITE_TYPE: {
++ HeapTuple typtup;
+
-+ seclabel = lookup_init_relation_label(tbltup);
++ typtup = SearchSysCache1(TYPEOID,
++ ObjectIdGetDatum(clsForm->reltype));
++ if (!HeapTupleIsValid(typtup))
++ elog(ERROR, "cache lookup failed for type %u", clsForm->reltype);
+
-+ ReleaseSysCache(tbltup);
-+ ReleaseSysCache(indtup);
++ securityId = sepgsql_initial_labeling_lookup(sehnd, TypeRelationId, typtup);
+
++ ReleaseSysCache(typtup);
++
++ return securityId;
++ }
++ default:
++ elog(ERROR, "unexpected relkind %c of \"%s\"",
++ clsForm->relkind, NameStr(clsForm->relname));
++ break;
++ }
+ break;
-+ }
-+ case RELKIND_TOASTVALUE: {
-+ HeapTuple tbltup;
-+ Oid tblOid;
+
-+ /*
-+ * XXX - we assume all the toast relation's name is
-+ * "pg_toast_%u", and the "%u" shall be replaced by OID
-+ * of the relation which owns the toast relation
-+ */
-+ tblOid = strtoul(relName + 9, NULL, 10);
++ case AttributeRelationId:
++ attForm = (Form_pg_attribute) GETSTRUCT(tuple);
++ if (get_rel_relkind(attForm->attrelid) == RELKIND_RELATION)
++ {
++ namespaceId = get_rel_namespace(attForm->attrelid);
++ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s.%s",
++ get_database_name(MyDatabaseId),
++ get_namespace_name(namespaceId),
++ get_rel_name(attForm->attrelid),
++ NameStr(attForm->attname));
++ type = SELABEL_DB_COLUMN;
++ }
++ else
++ {
++ HeapTuple classTup;
+
-+ tbltup = SearchSysCache1(RELOID,
-+ ObjectIdGetDatum(tblOid));
-+ if (!HeapTupleIsValid(tbltup))
-+ elog(ERROR, "cache lookup failed for relation %u", tblOid);
++ classTup = SearchSysCache1(RELOID, ObjectIdGetDatum(attForm->attrelid));
++ if (!HeapTupleIsValid(classTup))
++ elog(ERROR, "cache lookup failed for relation %u", attForm->attrelid);
+
-+ seclabel = lookup_init_relation_label(tbltup);
++ securityId = sepgsql_initial_labeling_lookup(sehnd, RelationRelationId, classTup);
+
-+ ReleaseSysCache(tbltup);
++ ReleaseSysCache(classTup);
+
++ return securityId;
++ }
+ break;
-+ }
-+ case RELKIND_COMPOSITE_TYPE: {
-+ Oid typOid = classForm->reltype;
-+ HeapTuple typtup;
-+
-+ typtup = SearchSysCache1(TYPEOID,
-+ ObjectIdGetDatum(typOid));
-+ if (!HeapTupleIsValid(typtup))
-+ elog(ERROR, "cache lookup failed for type %u", typOid);
+
-+ seclabel = lookup_init_tuple_label(TypeRelationId, typtup);
-+
-+ ReleaseSysCache(typtup);
++ case ProcedureRelationId:
++ proForm = (Form_pg_proc) GETSTRUCT(tuple);
++ namespaceId = proForm->pronamespace;
++ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
++ get_database_name(MyDatabaseId),
++ get_namespace_name(namespaceId),
++ NameStr(proForm->proname));
++ type = SELABEL_DB_PROCEDURE;
++ break;
+
++ case LargeObjectMetadataRelationId:
++ snprintf(namebuf, sizeof(namebuf), "%s.%u",
++ get_database_name(MyDatabaseId),
++ HeapTupleGetOid(tuple));
++ type = SELABEL_DB_BLOB;
+ break;
-+ }
++
+ default:
-+ elog(ERROR, "unexpected relkind %c of \"%s\"",
-+ classForm->relkind, relName);
-+ seclabel = NULL; /* compiler quiet */
++ namespaceId = get_rel_namespace(relationId);
++ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
++ get_database_name(MyDatabaseId),
++ get_namespace_name(namespaceId),
++ get_rel_name(relationId));
++ type = SELABEL_DB_TUPLE;
+ break;
+ }
-+ return seclabel;
-+}
+
-+static char *
-+lookup_init_attribute_label(HeapTuple tuple)
-+{
-+ Form_pg_attribute attForm = (Form_pg_attribute) GETSTRUCT(tuple);
-+ Oid tblOid = attForm->attrelid;
-+ char *seclabel;
-+ char namebuf[NAMEDATALEN * 4 + 10];
-+
-+ if (get_rel_relkind(tblOid) == RELKIND_RELATION)
++ if (selabel_lookup_raw(sehnd, &context, namebuf, type) == 0)
+ {
-+ Oid tblNsp = get_rel_namespace(tblOid);
-+
-+ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s.%s",
-+ get_database_name(MyDatabaseId),
-+ get_namespace_name(tblNsp),
-+ get_rel_name(tblOid),
-+ NameStr(attForm->attname));
-+
-+ seclabel = lookup_init_catalog(SEPG_CLASS_DB_COLUMN, namebuf);
++ PG_TRY();
++ {
++ securityId = seclabelTransInput(relationId, context);
++ }
++ PG_CATCH();
++ {
++ freecon(context);
++ PG_RE_THROW();
++ }
++ PG_END_TRY();
++ freecon(context);
+ }
++ else if (errno == ENOENT)
++ elog(WARNING,
++ "SELinux: no initial label assigned for %s (type=%d), skipping",
++ namebuf, type);
+ else
-+ {
-+ HeapTuple tbltup;
-+
-+ tbltup = SearchSysCache1(RELOID, ObjectIdGetDatum(tblOid));
-+ if (!HeapTupleIsValid(tbltup))
-+ elog(ERROR, "cache lookup failed for relation %u", tblOid);
-+
-+ seclabel = lookup_init_relation_label(tbltup);
-+
-+ ReleaseSysCache(tbltup);
-+ }
-+ return seclabel;
-+}
++ elog(ERROR,
++ "SELinux: could not determine initial security label for %s (type=%d): %m",
++ namebuf, type);
+
-+static char *
-+lookup_init_procedure_label(HeapTuple tuple)
-+{
-+ Form_pg_proc proForm = (Form_pg_proc) GETSTRUCT(tuple);
-+ Oid proNsp = proForm->pronamespace;
-+ char namebuf[NAMEDATALEN * 3 + 10];
-+
-+ snprintf(namebuf, sizeof(namebuf), "%s.%s.%s",
-+ get_database_name(MyDatabaseId),
-+ get_namespace_name(proNsp),
-+ NameStr(proForm->proname));
-+
-+ return lookup_init_catalog(SEPG_CLASS_DB_PROCEDURE, namebuf);
-+}
-+
-+static char *
-+lookup_init_largeobject_label(HeapTuple tuple)
-+{
-+ char namebuf[NAMEDATALEN + 20];
-+
-+ snprintf(namebuf, sizeof(namebuf), "%s.%u",
-+ get_database_name(MyDatabaseId),
-+ HeapTupleGetOid(tuple));
-+
-+ return lookup_init_catalog(SEPG_CLASS_DB_BLOB, namebuf);
++ return securityId;
+}
+
+void
@@ -10639,15 +10773,16 @@ index 0000000..7ab355c
+ SysScanDesc classScan;
+ ScanKeyData classSkey;
+ HeapTuple classTup;
-+ Relation rel;
-+ HeapScanDesc scan;
-+ HeapTuple oldtup;
-+ HeapTuple newtup;
++ struct selabel_handle *sehnd;
+
+ Assert(IsBootstrapProcessingMode());
+
+ StartTransactionCommand();
+
++ sehnd = selabel_open(SELABEL_CTX_DB, NULL, 0);
++ if (!sehnd)
++ elog(ERROR, "failed to open initial selinux label");
++
+ classRel = heap_open(RelationRelationId, AccessShareLock);
+
+ ScanKeyInit(&classSkey,
@@ -10660,7 +10795,11 @@ index 0000000..7ab355c
+
+ while (HeapTupleIsValid(classTup = systable_getnext(classScan)))
+ {
-+ Oid relOid = HeapTupleGetOid(classTup);
++ Relation rel;
++ HeapScanDesc scan;
++ HeapTuple oldtup;
++ HeapTuple newtup;
++ Oid relOid = HeapTupleGetOid(classTup);
+
+ Assert(((Form_pg_class) GETSTRUCT(classTup))->relhassecids);
+
@@ -10670,52 +10809,20 @@ index 0000000..7ab355c
+
+ while (HeapTupleIsValid(oldtup = heap_getnext(scan, ForwardScanDirection)))
+ {
-+ char *label;
-+ Oid secid;
-+
-+ switch (relOid)
-+ {
-+ case DatabaseRelationId:
-+ label = lookup_init_database_label(oldtup);
-+ break;
-+
-+ case NamespaceRelationId:
-+ label = lookup_init_schema_label(oldtup);
-+ break;
-+
-+ case RelationRelationId:
-+ label = lookup_init_relation_label(oldtup);
-+ break;
-+
-+ case AttributeRelationId:
-+ label = lookup_init_attribute_label(oldtup);
-+ break;
-+
-+ case ProcedureRelationId:
-+ label = lookup_init_procedure_label(oldtup);
-+ break;
++ Oid securityId = sepgsql_initial_labeling_lookup(sehnd, relOid, oldtup);
+
-+ case LargeObjectMetadataRelationId:
-+ label = lookup_init_largeobject_label(oldtup);
-+ break;
-+
-+ default:
-+ label = lookup_init_tuple_label(relOid, oldtup);
-+ break;
-+ }
+ /*
+ * inplace-updating
+ */
+ newtup = heap_copytuple(oldtup);
+
-+ secid = seclabelTransInput(relOid, label);
-+
-+ HeapTupleSetSecid(newtup, secid);
++ HeapTupleSetSecid(newtup, securityId);
+
+ heap_inplace_update(rel, newtup);
+
+ heap_freetuple(newtup);
+ }
++
+ heap_endscan(scan);
+
+ heap_close(rel, RowExclusiveLock);
@@ -10724,6 +10831,8 @@ index 0000000..7ab355c
+
+ heap_close(classRel, AccessShareLock);
+
++ selabel_close(sehnd);
++
+ CommitTransactionCommand();
+}
+
@@ -15983,7 +16092,7 @@ index 4e55b16..a9f9f7e 100644
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
-index e1f5ab6..43f47f6 100644
+index a3880da..7537ac8 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -76,6 +76,8 @@
@@ -16082,10 +16191,10 @@ index 5a73779..67fce14 100644
const char *defn,
const char *dropStmt, const char *copyStmt,
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
-index be5339e..8352c93 100644
+index 6528f4d..e482bde 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
-@@ -540,6 +540,8 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
+@@ -542,6 +542,8 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
}
else
{
@@ -16094,7 +16203,7 @@ index be5339e..8352c93 100644
_disableTriggersIfNecessary(AH, te, ropt);
/* Select owner and schema as necessary */
-@@ -575,6 +577,16 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
+@@ -577,6 +579,16 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
"ONLY " : ""),
fmtId(te->tag));
}
@@ -16111,7 +16220,7 @@ index be5339e..8352c93 100644
/*
* If we have a copy statement, use it. As of V1.3, these
-@@ -595,6 +607,9 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
+@@ -597,6 +609,9 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
AH->writingCopyData = false;
@@ -16121,7 +16230,7 @@ index be5339e..8352c93 100644
/* close out the transaction started above */
if (is_parallel && te->created)
CommitTransaction(AH);
-@@ -712,7 +727,7 @@ ArchiveEntry(Archive *AHX,
+@@ -714,7 +729,7 @@ ArchiveEntry(Archive *AHX,
const char *tag,
const char *namespace,
const char *tablespace,
@@ -16130,7 +16239,7 @@ index be5339e..8352c93 100644
const char *desc, teSection section,
const char *defn,
const char *dropStmt, const char *copyStmt,
-@@ -744,6 +759,7 @@ ArchiveEntry(Archive *AHX,
+@@ -746,6 +761,7 @@ ArchiveEntry(Archive *AHX,
newToc->tablespace = tablespace ? strdup(tablespace) : NULL;
newToc->owner = strdup(owner);
newToc->withOids = withOids;
@@ -16138,7 +16247,7 @@ index be5339e..8352c93 100644
newToc->desc = strdup(desc);
newToc->defn = strdup(defn);
newToc->dropStmt = strdup(dropStmt);
-@@ -2046,6 +2062,7 @@ WriteToc(ArchiveHandle *AH)
+@@ -2048,6 +2064,7 @@ WriteToc(ArchiveHandle *AH)
WriteStr(AH, te->tablespace);
WriteStr(AH, te->owner);
WriteStr(AH, te->withOids ? "true" : "false");
@@ -16146,7 +16255,7 @@ index be5339e..8352c93 100644
/* Dump list of dependencies */
for (i = 0; i < te->nDeps; i++)
-@@ -2157,6 +2174,16 @@ ReadToc(ArchiveHandle *AH)
+@@ -2159,6 +2176,16 @@ ReadToc(ArchiveHandle *AH)
else
te->withOids = true;
@@ -16163,7 +16272,7 @@ index be5339e..8352c93 100644
/* Read TOC entry dependencies */
if (AH->version >= K_VERS_1_5)
{
-@@ -2275,6 +2302,9 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
+@@ -2277,6 +2304,9 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
if ((!include_acls || ropt->aclsSkip) && _tocEntryIsACL(te))
return 0;
@@ -16173,7 +16282,7 @@ index be5339e..8352c93 100644
/* Ignore DATABASE entry unless we should create it */
if (!ropt->createDB && strcmp(te->desc, "DATABASE") == 0)
return 0;
-@@ -2341,6 +2371,8 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
+@@ -2343,6 +2373,8 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
(strcmp(te->desc, "ACL") == 0 &&
strncmp(te->tag, "LARGE OBJECT ", 13) == 0) ||
(strcmp(te->desc, "COMMENT") == 0 &&
@@ -16182,7 +16291,7 @@ index be5339e..8352c93 100644
strncmp(te->tag, "LARGE OBJECT ", 13) == 0))
res = res & REQ_DATA;
else
-@@ -2492,6 +2524,36 @@ _doSetWithOids(ArchiveHandle *AH, const bool withOids)
+@@ -2494,6 +2526,36 @@ _doSetWithOids(ArchiveHandle *AH, const bool withOids)
destroyPQExpBuffer(cmd);
}
@@ -16219,7 +16328,7 @@ index be5339e..8352c93 100644
/*
* Issue the commands to connect to the specified database.
-@@ -2590,6 +2652,18 @@ _setWithOids(ArchiveHandle *AH, TocEntry *te)
+@@ -2592,6 +2654,18 @@ _setWithOids(ArchiveHandle *AH, TocEntry *te)
}
}
@@ -16238,7 +16347,7 @@ index be5339e..8352c93 100644
/*
* Issue the commands to select the specified schema as the current schema
-@@ -2827,9 +2901,12 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
+@@ -2829,9 +2903,12 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
_selectOutputSchema(AH, te->namespace);
_selectTablespace(AH, te->tablespace);
@@ -16253,7 +16362,7 @@ index be5339e..8352c93 100644
/* Emit header comment for item */
if (!AH->noTocComments)
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
-index 0a135ee..27b2ef5 100644
+index 9f826b6..a46be6b 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -63,7 +63,7 @@ typedef z_stream *z_streamp;
@@ -18077,7 +18186,7 @@ index 6047735..ce9a994 100644
#endif /* SYSATTR_H */
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
-index e38a6e76..d5688d5 100644
+index e38a6e7..d5688d5 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -75,13 +75,14 @@ typedef struct tupleDesc
@@ -18508,7 +18617,7 @@ index 4dc2d4f..e50a83f 100644
#endif /* TYPECMDS_H */
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
-index b2424a0..609f31b 100644
+index 13b6aa5..0350a17 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -131,8 +131,8 @@ extern TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable,
@@ -18522,15 +18631,15 @@ index b2424a0..609f31b 100644
extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
TupleDesc cleanTupType,
TupleTableSlot *slot);
-@@ -164,6 +164,7 @@ extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,
+@@ -166,6 +166,7 @@ extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,
int instrument_options);
extern ResultRelInfo *ExecGetTriggerResultRel(EState *estate, Oid relid);
extern bool ExecContextForcesOids(PlanState *planstate, bool *hasoids);
+extern bool ExecContextForcesSecids(PlanState *planstate, bool *hassecid);
extern void ExecConstraints(ResultRelInfo *resultRelInfo,
TupleTableSlot *slot, EState *estate);
- extern TupleTableSlot *EvalPlanQual(EState *estate, EPQState *epqstate,
-@@ -234,8 +235,8 @@ extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate);
+ extern ExecRowMark *ExecFindRowMark(EState *estate, Index rti);
+@@ -238,8 +239,8 @@ extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate);
extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate);
extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate,
TupleDesc tupType);
@@ -18608,7 +18717,7 @@ index 54eebbc..94d0969 100644
/* ----------------------
* Create Rule Statement
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
-index 5065bd6..0c67e25 100644
+index ad835d9..71595e3 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -208,6 +208,7 @@ PG_KEYWORD("isnull", ISNULL, TYPE_FUNC_NAME_KEYWORD)
@@ -19323,10 +19432,10 @@ index 9faefbe..90b7c94 100644
SearchSysCacheList(cacheId, 1, key1, 0, 0, 0)
#define SearchSysCacheList2(cacheId, key1, key2) \
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
-index 25d2760..9bb9d3f 100644
+index 589d514..5370346 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
-@@ -1936,7 +1936,7 @@ build_row_from_vars(PLpgSQL_variable **vars, int numvars)
+@@ -1965,7 +1965,7 @@ build_row_from_vars(PLpgSQL_variable **vars, int numvars)
row = palloc0(sizeof(PLpgSQL_row));
row->dtype = PLPGSQL_DTYPE_ROW;
diff --git a/sepostgresql.spec b/sepostgresql.spec
index 2e823f2..6c40640 100644
--- a/sepostgresql.spec
+++ b/sepostgresql.spec
@@ -11,8 +11,8 @@
Summary: Security Enhanced PostgreSQL
Name: sepostgresql
-Version: 9.0.1
-Release: 20101008%{?dist}
+Version: 9.0.3
+Release: 20110415%{?dist}
License: PostgreSQL
Group: Applications/Databases
Url: http://code.google.com/p/sepgsql/
@@ -24,7 +24,7 @@ Source3: sepostgresql.logrotate
Patch0: sepostgresql-fedora-prefix.patch
Patch1: sepostgresql-9.0-fullset.patch
BuildRequires: perl glibc-devel bison flex readline-devel zlib-devel >= 1.0.4
-BuildRequires: checkpolicy libselinux-devel >= 2.0.80 audit-libs-devel
+BuildRequires: checkpolicy libselinux-devel >= 2.0.96 audit-libs-devel
BuildRequires: selinux-policy >= 3.6.8
%if %{ssl}
BuildRequires: openssl-devel
@@ -33,7 +33,7 @@ Requires(pre): shadow-utils
Requires(post): policycoreutils /sbin/chkconfig
Requires(preun): /sbin/chkconfig /sbin/service
Requires(postun): policycoreutils
-Requires: policycoreutils >= 2.0.16 libselinux >= 2.0.80
+Requires: policycoreutils >= 2.0.16 libselinux >= 2.0.96
Requires: selinux-policy >= 3.6.8
Requires: tzdata logrotate
@@ -181,6 +181,10 @@ fi
%attr(700,sepgsql,sepgsql) %dir %{_localstatedir}/lib/sepgsql/backups
%changelog
+* Fri Apr 15 2011 KaiGai Kohei <kaigai at kaigai.gr.jp> - 9.0.3-20110415
+- upgrade base version to 9.0.3
+- initial labeling logic was revised to use selabel_lookup()
+
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 9.0.1-20101008
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
diff --git a/sources b/sources
index 5a1101a..8ba5714 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-5093c321bc47af2ea9afa726605ff1ce postgresql-9.0.1.tar.gz
+56386ded2d5dcd8a4ceef0da81c3d22c postgresql-9.0.3.tar.gz
More information about the scm-commits
mailing list