Commit Graph

101 Commits

Author SHA1 Message Date
Tom Lane 7449427a1e Clean up some loose ends from the column privileges patch: add
has_column_privilege and has_any_column_privilege SQL functions; fix the
information_schema views that are supposed to pay attention to column
privileges; adjust pg_stats to show stats for any column you have select
privilege on; and fix COPY to allow copying a subset of columns if the user
has suitable per-column privileges for all the columns.

To improve efficiency of some of the information_schema views, extend the
has_xxx_privilege functions to allow inquiring about the OR of a set of
privileges in just one call.  This is just exposing capability that already
existed in the underlying aclcheck routines.

In passing, make the information_schema views report the owner's own
privileges as being grantable, since Postgres assumes this even when the grant
option bit is not set in the ACL.  This is a longstanding oversight.

Also, make the new has_xxx_privilege functions for foreign data objects follow
the same coding conventions used by the older ones.

Stephen Frost and Tom Lane
2009-02-06 21:15:12 +00:00
Peter Eisentraut 93a6be63a5 Revise the permission checking on user mapping DDL commands.
CREATE/ALTER/DROP USER MAPPING are now allowed either by the server owner or
by a user with USAGE privileges for his own user name.  This is more or less
what the SQL standard wants anyway (plus "implementation-defined")

Hide information_schema.user_mapping_options.option_value, unless the current
user is the one associated with the user mapping, or is the server owner and
the mapping is for PUBLIC, or is a superuser.  This is to protect passwords.

Also, fix a bug in information_schema._pg_foreign_servers, which hid servers
using wrappers where the current user did not have privileges on the wrapper.
The correct behavior is to hide servers where the current user has no
privileges on the server.
2009-01-20 09:10:20 +00:00
Peter Eisentraut 8ae6b4c49f Make the columns is_insertable_into and is_updatable behave uniformly
correctly.  They are supposed to examine which kinds of rules are present,
which they did in some of the info schema views but not in others.
2009-01-14 21:12:09 +00:00
Bruce Momjian 511db38ace Update copyright for 2009. 2009-01-01 17:24:05 +00:00
Peter Eisentraut cae565e503 SQL/MED catalog manipulation facilities
This doesn't do any remote or external things yet, but it gives modules
like plproxy and dblink a standardized and future-proof system for
managing their connection information.

Martin Pihlak and Peter Eisentraut
2008-12-19 16:25:19 +00:00
Tom Lane a0b76dc662 Create a separate grantable privilege for TRUNCATE, rather than having it be
always owner-only.  The TRUNCATE privilege works identically to the DELETE
privilege so far as interactions with the rest of the system go.

Robert Haas
2008-09-08 00:47:41 +00:00
Tom Lane 69a785b8bf Implement SQL-spec RETURNS TABLE syntax for functions.
(Unlike the original submission, this patch treats TABLE output parameters
as being entirely equivalent to OUT parameters -- tgl)

Pavel Stehule
2008-07-18 03:32:53 +00:00
Tom Lane d89737d31c Support "variadic" functions, which can accept a variable number of arguments
so long as all the trailing arguments are of the same (non-array) type.
The function receives them as a single array argument (which is why they
have to all be the same type).

It might be useful to extend this facility to aggregates, but this patch
doesn't do that.

This patch imposes a noticeable slowdown on function lookup --- a follow-on
patch will fix that by adding a redundant column to pg_proc.

Pavel Stehule
2008-07-16 01:30:23 +00:00
Bruce Momjian 9098ab9e32 Update copyrights in source tree to 2008. 2008-01-01 19:46:01 +00:00
Peter Eisentraut a5f1d6c201 Allow information schema definitions to work without requiring implicit
casts to text.
2007-02-27 18:49:43 +00:00
Peter Eisentraut 4c488e857e Update SQL conformance information about XML features. 2007-02-03 17:59:36 +00:00
Tom Lane 6959cb5957 Fix incorrect permissions check in information_schema.key_column_usage view:
it was checking a pg_constraint OID instead of pg_class OID, resulting in
"relation with OID nnnnn does not exist" failures for anyone who wasn't
owner of the table being examined.  Per bug #2848 from Laurence Rowe.

Note: for existing 8.2 installations a simple version update won't fix this;
the easiest fix is to CREATE OR REPLACE this view with the corrected
definition.
2007-01-16 18:32:26 +00:00
Bruce Momjian 29dccf5fe0 Update CVS HEAD for 2007 copyright. Back branches are typically not
back-stamped for this.
2007-01-05 22:20:05 +00:00
Tom Lane 33556af7c7 Fix errors in key_column_usage.position_in_unique_constraint column recently
added to information_schema (per a SQL2003 addition).  The original coding
failed if a referenced column participated in more than one pg_constraint
entry.  Also, it did not work if an FK relied directly on a unique index
without any constraint syntactic sugar --- this case is outside the SQL spec,
but PG has always supported it, so it's reasonable for our information_schema
to handle it too.  Per bug#2750 from Stephen Haberman.

Although this patch changes the initial catalog contents, I didn't force
initdb.  Any beta3 testers who need the fix can install it via CREATE OR
REPLACE VIEW, so forcing them to initdb seems an unnecessary imposition.
2006-11-10 18:10:10 +00:00
Tom Lane 65ab9f4f24 Add a couple of information functions to support direct checks on whether
a schema is our own temp schema or another backend's temp schema, and use
these in place of some former kluges in information_schema.  Per my
proposal of yesterday.
2006-09-14 22:05:06 +00:00
Tom Lane 7bae5a289c Get rid of the separate RULE privilege for tables: now only a table's owner
can create or modify rules for the table.  Do setRuleCheckAsUser() while
loading rules into the relcache, rather than when defining a rule.  This
ensures that permission checks for tables referenced in a rule are done with
respect to the current owner of the rule's table, whereas formerly ALTER TABLE
OWNER would fail to update the permission checking for associated rules.
Removal of separate RULE privilege is needed to prevent various scenarios
in which a grantee of RULE privilege could effectively have any privilege
of the table owner.  For backwards compatibility, GRANT/REVOKE RULE is still
accepted, but it doesn't do anything.  Per discussion here:
http://archives.postgresql.org/pgsql-hackers/2006-04/msg01138.php
2006-09-05 21:08:36 +00:00
Tom Lane 44839ac03e Fix information_schema.key_column_usage to show correct value of
position_in_unique_constraint (column newly added per SQL2003).
Greg Mullane
2006-09-04 23:13:01 +00:00
Bruce Momjian 395c8166aa Sequences were not being shown due to the use of lowercase 's' instead
of 'S', and the views were not checking for table visibility with
regards to temporary tables and sequences.

Greg Sabino Mullane
2006-09-04 21:03:18 +00:00
Peter Eisentraut f7ae90041e Update information schema for SQL:2003 and new PostgreSQL features. 2006-04-02 17:38:13 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Tom Lane aa731ed843 Change nextval and other sequence functions to specify their sequence
argument as a 'regclass' value instead of a text string.  The frontend
conversion of text string to pg_class OID is now encapsulated as an
implicitly-invocable coercion from text to regclass.  This provides
backwards compatibility to the old behavior when the sequence argument
is explicitly typed as 'text'.  When the argument is just an unadorned
literal string, it will be taken as 'regclass', which means that the
stored representation will be an OID.  This solves longstanding problems
with renaming sequences that are referenced in default expressions, as
well as new-in-8.1 problems with renaming such sequences' schemas or
moving them to another schema.  All per recent discussion.
Along the way, fix some rather serious problems in dbmirror's support
for mirroring sequence operations (int4 vs int8 confusion for instance).
2005-10-02 23:50:16 +00:00
Tom Lane f9fd176461 Add pg_has_role() family of privilege inquiry functions modeled after the
existing ones for object privileges.  Update the information_schema for
roles --- pg_has_role() makes this a whole lot easier, removing the need
for most of the explicit joins with pg_user.  The views should be a tad
faster now, too.  Stephen Frost and Tom Lane.
2005-07-26 00:04:19 +00:00
Tom Lane 7762619e95 Replace pg_shadow and pg_group by new role-capable catalogs pg_authid
and pg_auth_members.  There are still many loose ends to finish in this
patch (no documentation, no regression tests, no pg_dump support for
instance).  But I'm going to commit it now anyway so that Alvaro can
make some progress on shared dependencies.  The catalog changes should
be pretty much done.
2005-06-28 05:09:14 +00:00
Tom Lane 982888bddc Fix information_schema for OUT and INOUT parameters. 2005-05-31 03:36:24 +00:00
Tom Lane 70c9763d48 Convert oidvector and int2vector into variable-length arrays. This
change saves a great deal of space in pg_proc and its primary index,
and it eliminates the former requirement that INDEX_MAX_KEYS and
FUNC_MAX_ARGS have the same value.  INDEX_MAX_KEYS is still embedded
in the on-disk representation (because it affects index tuple header
size), but FUNC_MAX_ARGS is not.  I believe it would now be possible
to increase FUNC_MAX_ARGS at little cost, but haven't experimented yet.
There are still a lot of vestigial references to FUNC_MAX_ARGS, which
I will clean up in a separate pass.  However, getting rid of it
altogether would require changing the FunctionCallInfoData struct,
and I'm not sure I want to buy into that.
2005-03-29 00:17:27 +00:00
Tom Lane 7e1c8ef4fc Some more missed copyright notices. Many of these look like they
should have been caught by the src/tools/copyright script ... why
weren't they?
2005-01-01 20:44:34 +00:00
Peter Eisentraut 49cbef7947 Update of conformance information to SQL:2003
by Troels Arvin, Simon Riggs, Elein Mustain

Make spelling of SQL standard names uniform.
2004-11-27 21:27:08 +00:00
Tom Lane 1a76550b3b Fix information schema views to return NULL for precision and scale of
an unconstrained numeric column.  Also, factor out some duplicate code
into functions, to ease future maintenance.
2004-06-22 22:30:32 +00:00
Joe Conway 12661642c8 Add function (actually an int4 and an int8 version) that generates
a series of numbers, optionally using an explicit step size other
than the default value (one). Use function in the information_schema
to replace hard-wired knowledge of INDEX_MAX_KEYS. initdb forced due
to pg_proc change. Documentation update still needed -- will be
committed separately.
2004-02-03 08:29:57 +00:00
Tom Lane 9d8888079d Support named parameters in information_schema.parameters,
per Dennis Bjorklund.  I did not force initdb for this, but
you'd need to do one to get the improved view.
2004-01-24 23:45:13 +00:00
Tom Lane 422249120d information_schema.constraint_column_usage and key_column_usage should
not discriminate against system columns, since we support constraints on
system columns, and in fact constraints on OID are moderately useful.
2003-12-17 22:11:30 +00:00
Peter Eisentraut 0fb3ec1a58 Fix constraint_column_usage for foreign keys. 2003-12-16 14:57:20 +00:00
Tom Lane 80af69ceaa Remove test on c.relkind from check_constraints view; unnecessary and
prevents view from showing constraints on domains.  This addresses the
other half of Claus Colloseus' bug report.
2003-12-07 19:43:02 +00:00
Peter Eisentraut d9d72bcb91 Fix typmod interpretation for bit types. (It was erroneously assumed that
for bit(x), the typmod stores x+4, like for the character types.)
2003-12-07 10:21:58 +00:00
PostgreSQL Daemon 55b113257c make sure the $Id tags are converted to $PostgreSQL as well ... 2003-11-29 22:41:33 +00:00
Tom Lane 97edeec6d2 Correct misspellings of REFERENCES. 2003-11-08 20:43:52 +00:00
Tom Lane e341cdb085 Further work on information_schema. _pg_keyissubset() wasn't quite
fully search-path-proof yet; also, element_types view did not work for
parameters and result types of functions, because it didn't generate
the object_name for the function the same way the data_type_privileges
view does.  While at it, centralize dependencies on INDEX_MAX_KEYS/
FUNC_MAX_ARGS into a function returning setof int, so that it will be
easier to fix information_schema for nonstandard values of these
parameters.
2003-10-18 19:06:10 +00:00
Peter Eisentraut 9ea6d0fc80 Information schema fixes:
Use pg_get_constraintdef instead of pg_constraint.consrc
Use UNION ALL instread of UNION
Make use of regclass type for getting OID of system catalogs
Add schema qualifications where necessary
Fix typos
2003-10-18 12:53:35 +00:00
Peter Eisentraut 44430dbc15 Fix bugs in referential_constraints view. 2003-10-16 23:46:17 +00:00
Peter Eisentraut 4355d4fb21 Information schema views for group privileges, some corrections on column
privileges.
2003-06-29 15:14:41 +00:00
Peter Eisentraut ae20518c7e It was comparing the wrong pair of columns, which triggered the previously
mentioned bug.
2003-06-29 10:18:26 +00:00
Peter Eisentraut 2f80f81e5e Make information schema aware of arrays.
The view element_types is currently not functional, awaiting some fixes in
the planner (reported on -hackers).
2003-06-28 20:50:08 +00:00
Peter Eisentraut 596652d6eb More information schema views. 2003-06-17 18:00:48 +00:00
Peter Eisentraut 8a2922dcb2 Represent grant options in the information schema. 2003-06-11 09:23:55 +00:00
Peter Eisentraut 7ea8e491c8 Information schema views about functions 2003-06-05 16:08:47 +00:00
Peter Eisentraut 297c1658ed Information schema improvements 2003-05-25 09:36:09 +00:00
Peter Eisentraut f89c972ac8 Add documentation for information schema, and some corrections on some
views.
2003-05-18 20:55:57 +00:00
Bruce Momjian a00431b8d8 "Information_schema" changes
- Add domain check constraints to "check_constraints" view
- Create "domains" view
- Create "domain_constraints" view

--
Rod Taylor <rbt@rbt.ca>
2003-03-20 05:06:55 +00:00
Peter Eisentraut 828822bc96 Add remaining documentation tables to information schema. 2003-01-15 23:37:28 +00:00
Peter Eisentraut 2160c9177d Add sql_features table to information schema. Generate the features list
in the documentation from that same data.
2003-01-14 23:19:34 +00:00
Peter Eisentraut 1b42ad7e59 Initial version of the SQL information schema 2002-12-14 00:24:35 +00:00