Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
f82e2bae
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f82e2bae
编写于
12月 12, 2005
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use a proper enum for tri-valued variables.
上级
59b89e9c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
48 addition
and
53 deletion
+48
-53
src/bin/scripts/createuser.c
src/bin/scripts/createuser.c
+48
-53
未找到文件。
src/bin/scripts/createuser.c
浏览文件 @
f82e2bae
...
...
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.2
2 2005/12/12 15:41:52
momjian Exp $
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.2
3 2005/12/12 15:48:04
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -17,6 +17,11 @@
static
void
help
(
const
char
*
progname
);
enum
trivalue
{
TRI_DEFAULT
,
TRI_NO
,
TRI_YES
};
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -51,7 +56,6 @@ main(int argc, char *argv[])
const
char
*
progname
;
int
optindex
;
int
c
;
char
*
newuser
=
NULL
;
char
*
host
=
NULL
;
char
*
port
=
NULL
;
...
...
@@ -62,16 +66,13 @@ main(int argc, char *argv[])
char
*
conn_limit
=
NULL
;
bool
pwprompt
=
false
;
char
*
newpassword
=
NULL
;
/*
* Tri-valued variables. -1 is "NO", +1 is enable and 0 uses the
* server default.
*/
int
createdb
=
0
;
int
superuser
=
0
;
int
createrole
=
0
;
int
inherit
=
0
;
int
login
=
0
;
int
encrypted
=
0
;
/* Tri-valued variables. */
enum
trivalue
createdb
=
TRI_DEFAULT
,
superuser
=
TRI_DEFAULT
,
createrole
=
TRI_DEFAULT
,
inherit
=
TRI_DEFAULT
,
login
=
TRI_DEFAULT
,
encrypted
=
TRI_DEFAULT
;
PQExpBufferData
sql
;
...
...
@@ -107,36 +108,36 @@ main(int argc, char *argv[])
quiet
=
true
;
break
;
case
'd'
:
createdb
=
+
1
;
createdb
=
TRI_YES
;
break
;
case
'D'
:
createdb
=
-
1
;
createdb
=
TRI_NO
;
break
;
case
's'
:
case
'a'
:
superuser
=
+
1
;
superuser
=
TRI_YES
;
break
;
case
'S'
:
case
'A'
:
superuser
=
-
1
;
superuser
=
TRI_NO
;
break
;
case
'r'
:
createrole
=
+
1
;
createrole
=
TRI_YES
;
break
;
case
'R'
:
createrole
=
-
1
;
createrole
=
TRI_NO
;
break
;
case
'i'
:
inherit
=
+
1
;
inherit
=
TRI_YES
;
break
;
case
'I'
:
inherit
=
-
1
;
inherit
=
TRI_NO
;
break
;
case
'l'
:
login
=
+
1
;
login
=
TRI_YES
;
break
;
case
'L'
:
login
=
-
1
;
login
=
TRI_NO
;
break
;
case
'c'
:
conn_limit
=
optarg
;
...
...
@@ -145,10 +146,10 @@ main(int argc, char *argv[])
pwprompt
=
true
;
break
;
case
'E'
:
encrypted
=
+
1
;
encrypted
=
TRI_YES
;
break
;
case
'N'
:
encrypted
=
-
1
;
encrypted
=
TRI_NO
;
break
;
default:
fprintf
(
stderr
,
_
(
"Try
\"
%s --help
\"
for more information.
\n
"
),
progname
);
...
...
@@ -195,16 +196,16 @@ main(int argc, char *argv[])
reply
=
simple_prompt
(
"Shall the new role be a superuser? (y/n) "
,
1
,
true
);
if
(
check_yesno_response
(
reply
)
==
1
)
superuser
=
+
1
;
superuser
=
TRI_YES
;
else
superuser
=
-
1
;
superuser
=
TRI_NO
;
}
if
(
superuser
==
+
1
)
if
(
superuser
==
TRI_YES
)
{
/* Not much point in trying to restrict a superuser */
createdb
=
+
1
;
createrole
=
+
1
;
createdb
=
TRI_YES
;
createrole
=
TRI_YES
;
}
if
(
createdb
==
0
)
...
...
@@ -213,9 +214,9 @@ main(int argc, char *argv[])
reply
=
simple_prompt
(
"Shall the new role be allowed to create databases? (y/n) "
,
1
,
true
);
if
(
check_yesno_response
(
reply
)
==
1
)
createdb
=
+
1
;
createdb
=
TRI_YES
;
else
createdb
=
-
1
;
createdb
=
TRI_NO
;
}
if
(
createrole
==
0
)
...
...
@@ -224,54 +225,48 @@ main(int argc, char *argv[])
reply
=
simple_prompt
(
"Shall the new role be allowed to create more new roles? (y/n) "
,
1
,
true
);
if
(
check_yesno_response
(
reply
)
==
1
)
createrole
=
+
1
;
createrole
=
TRI_YES
;
else
createrole
=
-
1
;
createrole
=
TRI_NO
;
}
if
(
inherit
==
0
)
{
/* silently default to YES */
inherit
=
+
1
;
}
inherit
=
TRI_YES
;
if
(
login
==
0
)
{
/* silently default to YES */
login
=
+
1
;
}
login
=
TRI_YES
;
initPQExpBuffer
(
&
sql
);
printfPQExpBuffer
(
&
sql
,
"CREATE ROLE %s"
,
fmtId
(
newuser
));
if
(
newpassword
)
{
if
(
encrypted
==
+
1
)
if
(
encrypted
==
TRI_YES
)
appendPQExpBuffer
(
&
sql
,
" ENCRYPTED"
);
if
(
encrypted
==
-
1
)
if
(
encrypted
==
TRI_NO
)
appendPQExpBuffer
(
&
sql
,
" UNENCRYPTED"
);
appendPQExpBuffer
(
&
sql
,
" PASSWORD "
);
appendStringLiteral
(
&
sql
,
newpassword
,
false
);
}
if
(
superuser
==
+
1
)
if
(
superuser
==
TRI_YES
)
appendPQExpBuffer
(
&
sql
,
" SUPERUSER"
);
if
(
superuser
==
-
1
)
if
(
superuser
==
TRI_NO
)
appendPQExpBuffer
(
&
sql
,
" NOSUPERUSER"
);
if
(
createdb
==
+
1
)
if
(
createdb
==
TRI_YES
)
appendPQExpBuffer
(
&
sql
,
" CREATEDB"
);
if
(
createdb
==
-
1
)
if
(
createdb
==
TRI_NO
)
appendPQExpBuffer
(
&
sql
,
" NOCREATEDB"
);
if
(
createrole
==
+
1
)
if
(
createrole
==
TRI_YES
)
appendPQExpBuffer
(
&
sql
,
" CREATEROLE"
);
if
(
createrole
==
-
1
)
if
(
createrole
==
TRI_NO
)
appendPQExpBuffer
(
&
sql
,
" NOCREATEROLE"
);
if
(
inherit
==
+
1
)
if
(
inherit
==
TRI_YES
)
appendPQExpBuffer
(
&
sql
,
" INHERIT"
);
if
(
inherit
==
-
1
)
if
(
inherit
==
TRI_NO
)
appendPQExpBuffer
(
&
sql
,
" NOINHERIT"
);
if
(
login
==
+
1
)
if
(
login
==
TRI_YES
)
appendPQExpBuffer
(
&
sql
,
" LOGIN"
);
if
(
login
==
-
1
)
if
(
login
==
TRI_NO
)
appendPQExpBuffer
(
&
sql
,
" NOLOGIN"
);
if
(
conn_limit
!=
NULL
)
appendPQExpBuffer
(
&
sql
,
" CONNECTION LIMIT %s"
,
conn_limit
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录