~aglenyoung/+junk/postgres-9.3-dtrace

« back to all changes in this revision

Viewing changes to src/backend/commands/alter.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt, Christoph Berg, Martin Pitt
  • Date: 2013-06-26 15:13:32 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130626151332-p34yjpn0txbdsdzd
Tags: 9.3~beta2-1
[ Christoph Berg ]
* hurd-i386: Ignore testsuite failures so we have a working libpq5 (they
  don't implement semaphores so the server won't even start).
* Mark postgresql-9.3 as beta in the description, suggested by Joshua D.
  Drake.

[ Martin Pitt ]
* New upstream release 9.3 beta2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
#include "utils/tqual.h"
63
63
 
64
64
 
65
 
static Oid AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid);
 
65
static Oid      AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid);
66
66
 
67
67
/*
68
68
 * Raise an error to the effect that an object of the given name is already
71
71
static void
72
72
report_name_conflict(Oid classId, const char *name)
73
73
{
74
 
        char   *msgfmt;
 
74
        char       *msgfmt;
75
75
 
76
76
        switch (classId)
77
77
        {
100
100
static void
101
101
report_namespace_conflict(Oid classId, const char *name, Oid nspOid)
102
102
{
103
 
        char   *msgfmt;
 
103
        char       *msgfmt;
104
104
 
105
105
        Assert(OidIsValid(nspOid));
106
106
 
168
168
        Datum      *values;
169
169
        bool       *nulls;
170
170
        bool       *replaces;
 
171
        NameData        nameattrdata;
171
172
 
172
173
        oldtup = SearchSysCache1(oidCacheId, ObjectIdGetDatum(objectId));
173
174
        if (!HeapTupleIsValid(oldtup))
221
222
        }
222
223
 
223
224
        /*
224
 
     * Check for duplicate name (more friendly than unique-index failure).
225
 
     * Since this is just a friendliness check, we can just skip it in cases
226
 
     * where there isn't suitable support.
227
 
     */
 
225
         * Check for duplicate name (more friendly than unique-index failure).
 
226
         * Since this is just a friendliness check, we can just skip it in cases
 
227
         * where there isn't suitable support.
 
228
         */
228
229
        if (classId == ProcedureRelationId)
229
230
        {
230
231
                Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(oldtup);
231
232
 
232
233
                IsThereFunctionInNamespace(new_name, proc->pronargs,
233
 
                                                                   proc->proargtypes, proc->pronamespace);
 
234
                                                                   &proc->proargtypes, proc->pronamespace);
234
235
        }
235
236
        else if (classId == CollationRelationId)
236
237
        {
273
274
        values = palloc0(RelationGetNumberOfAttributes(rel) * sizeof(Datum));
274
275
        nulls = palloc0(RelationGetNumberOfAttributes(rel) * sizeof(bool));
275
276
        replaces = palloc0(RelationGetNumberOfAttributes(rel) * sizeof(bool));
276
 
        values[Anum_name - 1] = PointerGetDatum(new_name);
 
277
        namestrcpy(&nameattrdata, new_name);
 
278
        values[Anum_name - 1] = NameGetDatum(&nameattrdata);
277
279
        replaces[Anum_name - 1] = true;
278
280
        newtup = heap_modify_tuple(oldtup, RelationGetDescr(rel),
279
281
                                                           values, nulls, replaces);
355
357
                case OBJECT_TSPARSER:
356
358
                case OBJECT_TSTEMPLATE:
357
359
                        {
358
 
                                ObjectAddress   address;
359
 
                                Relation                catalog;
360
 
                                Relation                relation;
 
360
                                ObjectAddress address;
 
361
                                Relation        catalog;
 
362
                                Relation        relation;
361
363
 
362
364
                                address = get_object_address(stmt->renameType,
363
365
                                                                                         stmt->object, stmt->objarg,
377
379
                default:
378
380
                        elog(ERROR, "unrecognized rename stmt type: %d",
379
381
                                 (int) stmt->renameType);
380
 
                        return InvalidOid;                      /* keep compiler happy */
 
382
                        return InvalidOid;      /* keep compiler happy */
381
383
        }
382
384
}
383
385
 
609
611
                Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(tup);
610
612
 
611
613
                IsThereFunctionInNamespace(NameStr(proc->proname), proc->pronargs,
612
 
                                                                   proc->proargtypes, nspOid);
 
614
                                                                   &proc->proargtypes, nspOid);
613
615
        }
614
616
        else if (classId == CollationRelationId)
615
617
        {
699
701
                        return AlterEventTriggerOwner(strVal(linitial(stmt->object)),
700
702
                                                                                  newowner);
701
703
 
702
 
                /* Generic cases */
 
704
                        /* Generic cases */
703
705
                case OBJECT_AGGREGATE:
704
706
                case OBJECT_COLLATION:
705
707
                case OBJECT_CONVERSION:
716
718
                                Relation        catalog;
717
719
                                Relation        relation;
718
720
                                Oid                     classId;
719
 
                                ObjectAddress   address;
 
721
                                ObjectAddress address;
720
722
 
721
723
                                address = get_object_address(stmt->objectType,
722
724
                                                                                         stmt->object,
804
806
                /* Superusers can bypass permission checks */
805
807
                if (!superuser())
806
808
                {
807
 
                        AclObjectKind   aclkind = get_object_aclkind(classId);
 
809
                        AclObjectKind aclkind = get_object_aclkind(classId);
808
810
 
809
811
                        /* must be owner */
810
812
                        if (!has_privs_of_role(GetUserId(), old_ownerId))
811
813
                        {
812
 
                                char   *objname;
813
 
                                char    namebuf[NAMEDATALEN];
 
814
                                char       *objname;
 
815
                                char            namebuf[NAMEDATALEN];
814
816
 
815
817
                                if (Anum_name != InvalidAttrNumber)
816
818
                                {
833
835
                        /* New owner must have CREATE privilege on namespace */
834
836
                        if (OidIsValid(namespaceId))
835
837
                        {
836
 
                                AclResult   aclresult;
 
838
                                AclResult       aclresult;
837
839
 
838
840
                                aclresult = pg_namespace_aclcheck(namespaceId, new_ownerId,
839
841
                                                                                                  ACL_CREATE);
861
863
                                                                 Anum_acl, RelationGetDescr(rel), &isnull);
862
864
                        if (!isnull)
863
865
                        {
864
 
                                Acl    *newAcl;
 
866
                                Acl                *newAcl;
865
867
 
866
868
                                newAcl = aclnewowner(DatumGetAclP(datum),
867
869
                                                                         old_ownerId, new_ownerId);