|
9 | 9 | * |
10 | 10 | * |
11 | 11 | * IDENTIFICATION |
12 | | - * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.68 2010/07/06 19:18:56 momjian Exp $ |
| 12 | + * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.69 2010/07/16 00:13:23 tgl Exp $ |
13 | 13 | * |
14 | 14 | *------------------------------------------------------------------------- |
15 | 15 | */ |
@@ -640,16 +640,9 @@ DefineOpFamily(CreateOpFamilyStmt *stmt) |
640 | 640 | { |
641 | 641 | char*opfname;/* name of opfamily we're creating */ |
642 | 642 | Oidamoid,/* our AM's oid */ |
643 | | -namespaceoid,/* namespace to create opfamily in */ |
644 | | -opfamilyoid;/* oid of opfamily we create */ |
645 | | -Relationrel; |
| 643 | +namespaceoid;/* namespace to create opfamily in */ |
646 | 644 | HeapTupletup; |
647 | | -Datumvalues[Natts_pg_opfamily]; |
648 | | -boolnulls[Natts_pg_opfamily]; |
649 | 645 | AclResultaclresult; |
650 | | -NameDataopfName; |
651 | | -ObjectAddressmyself, |
652 | | -referenced; |
653 | 646 |
|
654 | 647 | /* Convert list of names to a name and namespace */ |
655 | 648 | namespaceoid=QualifiedNameGetCreationNamespace(stmt->opfamilyname, |
@@ -678,68 +671,14 @@ DefineOpFamily(CreateOpFamilyStmt *stmt) |
678 | 671 | /* |
679 | 672 | * Currently, we require superuser privileges to create an opfamily. See |
680 | 673 | * comments in DefineOpClass. |
681 | | - * |
682 | | - * XXX re-enable NOT_USED code sections below if you remove this test. |
683 | 674 | */ |
684 | 675 | if (!superuser()) |
685 | 676 | ereport(ERROR, |
686 | 677 | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), |
687 | 678 | errmsg("must be superuser to create an operator family"))); |
688 | 679 |
|
689 | | -rel=heap_open(OperatorFamilyRelationId,RowExclusiveLock); |
690 | | - |
691 | | -/* |
692 | | - * Make sure there is no existing opfamily of this name (this is just to |
693 | | - * give a more friendly error message than "duplicate key"). |
694 | | - */ |
695 | | -if (SearchSysCacheExists3(OPFAMILYAMNAMENSP, |
696 | | -ObjectIdGetDatum(amoid), |
697 | | -CStringGetDatum(opfname), |
698 | | -ObjectIdGetDatum(namespaceoid))) |
699 | | -ereport(ERROR, |
700 | | -(errcode(ERRCODE_DUPLICATE_OBJECT), |
701 | | -errmsg("operator family \"%s\" for access method \"%s\" already exists", |
702 | | -opfname,stmt->amname))); |
703 | | - |
704 | | -/* |
705 | | - * Okay, let's create the pg_opfamily entry. |
706 | | - */ |
707 | | -memset(values,0,sizeof(values)); |
708 | | -memset(nulls, false,sizeof(nulls)); |
709 | | - |
710 | | -values[Anum_pg_opfamily_opfmethod-1]=ObjectIdGetDatum(amoid); |
711 | | -namestrcpy(&opfName,opfname); |
712 | | -values[Anum_pg_opfamily_opfname-1]=NameGetDatum(&opfName); |
713 | | -values[Anum_pg_opfamily_opfnamespace-1]=ObjectIdGetDatum(namespaceoid); |
714 | | -values[Anum_pg_opfamily_opfowner-1]=ObjectIdGetDatum(GetUserId()); |
715 | | - |
716 | | -tup=heap_form_tuple(rel->rd_att,values,nulls); |
717 | | - |
718 | | -opfamilyoid=simple_heap_insert(rel,tup); |
719 | | - |
720 | | -CatalogUpdateIndexes(rel,tup); |
721 | | - |
722 | | -heap_freetuple(tup); |
723 | | - |
724 | | -/* |
725 | | - * Create dependencies for the opfamily proper. Note: we do not create a |
726 | | - * dependency link to the AM, because we don't currently support DROP |
727 | | - * ACCESS METHOD. |
728 | | - */ |
729 | | -myself.classId=OperatorFamilyRelationId; |
730 | | -myself.objectId=opfamilyoid; |
731 | | -myself.objectSubId=0; |
732 | | - |
733 | | -/* dependency on namespace */ |
734 | | -referenced.classId=NamespaceRelationId; |
735 | | -referenced.objectId=namespaceoid; |
736 | | -referenced.objectSubId=0; |
737 | | -recordDependencyOn(&myself,&referenced,DEPENDENCY_NORMAL); |
738 | | - |
739 | | -/* dependency on owner */ |
740 | | -recordDependencyOnOwner(OperatorFamilyRelationId,opfamilyoid,GetUserId()); |
741 | | - |
742 | | -heap_close(rel,RowExclusiveLock); |
| 680 | +/* Insert pg_opfamily catalog entry */ |
| 681 | +(void)CreateOpFamily(stmt->amname,opfname,namespaceoid,amoid); |
743 | 682 | } |
744 | 683 |
|
745 | 684 |
|
|