diff options
| author | Itagaki Takahiro <itagaki.takahiro@gmail.com> | 2009-12-11 03:34:57 +0000 |
|---|---|---|
| committer | Itagaki Takahiro <itagaki.takahiro@gmail.com> | 2009-12-11 03:34:57 +0000 |
| commit | f1325ce213ae1843d2ee636ff6780c3f8ac9ada6 (patch) | |
| tree | 2fab9db3d075fcca27a87e92a9be02263865b93a /src/bin/psql | |
| parent | 64579962bbe522bf9ced8e4ed712b9072fb89142 (diff) | |
Add large object access control.
A new system catalog pg_largeobject_metadata manages
ownership and access privileges of large objects.
KaiGai Kohei, reviewed by Jaime Casanova.
Diffstat (limited to 'src/bin/psql')
| -rw-r--r-- | src/bin/psql/large_obj.c | 31 | ||||
| -rw-r--r-- | src/bin/psql/tab-complete.c | 16 |
2 files changed, 37 insertions, 10 deletions
diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c index e4da1d3e962..c77077f9870 100644 --- a/src/bin/psql/large_obj.c +++ b/src/bin/psql/large_obj.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.52 2009/01/01 17:23:55 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.53 2009/12/11 03:34:56 itagaki Exp $ */ #include "postgres_fe.h" #include "large_obj.h" @@ -278,13 +278,28 @@ do_lo_list(void) char buf[1024]; printQueryOpt myopt = pset.popt; - snprintf(buf, sizeof(buf), - "SELECT loid as \"%s\",\n" - " pg_catalog.obj_description(loid, 'pg_largeobject') as \"%s\"\n" - "FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) x\n" - "ORDER BY 1", - gettext_noop("ID"), - gettext_noop("Description")); + if (pset.sversion >= 80500) + { + snprintf(buf, sizeof(buf), + "SELECT oid as \"%s\",\n" + " pg_catalog.pg_get_userbyid(lomowner) as \"%s\",\n" + " pg_catalog.obj_description(oid, 'pg_largeobject') as \"%s\"\n" + " FROM pg_catalog.pg_largeobject_metadata " + " ORDER BY oid", + gettext_noop("ID"), + gettext_noop("Owner"), + gettext_noop("Description")); + } + else + { + snprintf(buf, sizeof(buf), + "SELECT loid as \"%s\",\n" + " pg_catalog.obj_description(loid, 'pg_largeobject') as \"%s\"\n" + "FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) x\n" + "ORDER BY 1", + gettext_noop("ID"), + gettext_noop("Description")); + } res = PSQLexec(buf, false); if (!res) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 7cd07574151..10734fe00c4 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.187 2009/10/13 21:04:01 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.188 2009/12/11 03:34:56 itagaki Exp $ */ /*---------------------------------------------------------------------- @@ -691,7 +691,7 @@ psql_completion(char *text, int start, int end) { static const char *const list_ALTER[] = {"AGGREGATE", "CONVERSION", "DATABASE", "DOMAIN", "FOREIGN DATA WRAPPER", "FUNCTION", - "GROUP", "INDEX", "LANGUAGE", "OPERATOR", "ROLE", "SCHEMA", "SERVER", "SEQUENCE", "TABLE", + "GROUP", "INDEX", "LANGUAGE", "LARGE OBJECT", "OPERATOR", "ROLE", "SCHEMA", "SERVER", "SEQUENCE", "TABLE", "TABLESPACE", "TEXT SEARCH", "TRIGGER", "TYPE", "USER", "USER MAPPING FOR", "VIEW", NULL}; COMPLETE_WITH_LIST(list_ALTER); @@ -760,6 +760,17 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_LIST(list_ALTERLANGUAGE); } + /* ALTER LARGE OBJECT <oid> */ + else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && + pg_strcasecmp(prev3_wd, "LARGE") == 0 && + pg_strcasecmp(prev2_wd, "OBJECT") == 0) + { + static const char *const list_ALTERLARGEOBJECT[] = + {"OWNER TO", NULL}; + + COMPLETE_WITH_LIST(list_ALTERLARGEOBJECT); + } + /* ALTER USER,ROLE <name> */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && !(pg_strcasecmp(prev2_wd, "USER") == 0 && pg_strcasecmp(prev_wd, "MAPPING") == 0) && @@ -1732,6 +1743,7 @@ psql_completion(char *text, int start, int end) " UNION SELECT 'FOREIGN SERVER'" " UNION SELECT 'FUNCTION'" " UNION SELECT 'LANGUAGE'" + " UNION SELECT 'LARGE OBJECT'" " UNION SELECT 'SCHEMA'" " UNION SELECT 'TABLESPACE'"); |
