6
6
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
7
7
* Portions Copyright (c) 1994, Regents of the University of California
8
8
*
9
- * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.76 2001/06/12 05:55:49 tgl Exp $
9
+ * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.77 2001/06/14 01:09:22 tgl Exp $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
29
29
#include "utils/array.h"
30
30
#include "utils/builtins.h"
31
31
#include "utils/fmgroids.h"
32
+ #include "utils/lsyscache.h"
32
33
#include "utils/syscache.h"
33
34
34
35
@@ -728,16 +729,9 @@ CreateGroup(CreateGroupStmt *stmt)
728
729
const char * groupuser = strVal (lfirst (item ));
729
730
Value * v ;
730
731
731
- tuple = SearchSysCache (SHADOWNAME ,
732
- PointerGetDatum (groupuser ),
733
- 0 , 0 , 0 );
734
- if (!HeapTupleIsValid (tuple ))
735
- elog (ERROR , "CREATE GROUP: user \"%s\" does not exist" , groupuser );
736
-
737
- v = makeInteger (((Form_pg_shadow ) GETSTRUCT (tuple ))-> usesysid );
732
+ v = makeInteger (get_usesysid (groupuser ));
738
733
if (!member (v , newlist ))
739
734
newlist = lcons (v , newlist );
740
- ReleaseSysCache (tuple );
741
735
}
742
736
743
737
/* build an array to insert */
@@ -879,18 +873,10 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag)
879
873
if (strcmp (tag , "ALTER GROUP" ) == 0 )
880
874
{
881
875
/* Get the uid of the proposed user to add. */
882
- tuple = SearchSysCache (SHADOWNAME ,
883
- PointerGetDatum (strVal (lfirst (item ))),
884
- 0 , 0 , 0 );
885
- if (!HeapTupleIsValid (tuple ))
886
- elog (ERROR , "%s: user \"%s\" does not exist" ,
887
- tag , strVal (lfirst (item )));
888
- v = makeInteger (((Form_pg_shadow ) GETSTRUCT (tuple ))-> usesysid );
889
- ReleaseSysCache (tuple );
876
+ v = makeInteger (get_usesysid (strVal (lfirst (item ))));
890
877
}
891
878
else if (strcmp (tag , "CREATE USER" ) == 0 )
892
879
{
893
-
894
880
/*
895
881
* in this case we already know the uid and it wouldn't be
896
882
* in the cache anyway yet
@@ -906,12 +892,12 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag)
906
892
if (!member (v , newlist ))
907
893
newlist = lcons (v , newlist );
908
894
else
909
-
910
895
/*
911
896
* we silently assume here that this error will only come
912
897
* up in a ALTER GROUP statement
913
898
*/
914
- elog (NOTICE , "%s: user \"%s\" is already in group \"%s\"" , tag , strVal (lfirst (item )), stmt -> name );
899
+ elog (NOTICE , "%s: user \"%s\" is already in group \"%s\"" ,
900
+ tag , strVal (lfirst (item )), stmt -> name );
915
901
}
916
902
917
903
newarray = palloc (ARR_OVERHEAD (1 ) + length (newlist ) * sizeof (int32 ));
@@ -1001,13 +987,7 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag)
1001
987
if (!is_dropuser )
1002
988
{
1003
989
/* Get the uid of the proposed user to drop. */
1004
- tuple = SearchSysCache (SHADOWNAME ,
1005
- PointerGetDatum (strVal (lfirst (item ))),
1006
- 0 , 0 , 0 );
1007
- if (!HeapTupleIsValid (tuple ))
1008
- elog (ERROR , "ALTER GROUP: user \"%s\" does not exist" , strVal (lfirst (item )));
1009
- v = makeInteger (((Form_pg_shadow ) GETSTRUCT (tuple ))-> usesysid );
1010
- ReleaseSysCache (tuple );
990
+ v = makeInteger (get_usesysid (strVal (lfirst (item ))));
1011
991
}
1012
992
else
1013
993
{
0 commit comments