Commit Graph

623 Commits

Author SHA1 Message Date
Neil Conway be8100d64e Implement IS NOT DISTINCT FROM, update the regression tests and docs.
Patch from Pavel Stehule, minor fixups by myself.
2005-12-11 10:54:28 +00:00
Tom Lane 3d376fce8d Change the parser to translate "foo [NOT] IN (expression-list)" to
ScalarArrayOpExpr when possible, that is, whenever there is an array type
for the values of the expression list.  This completes the project I've
been working on to improve the speed of index searches with long IN lists,
as per discussion back in mid-October.

I did not force initdb, but until you do one you will see failures in the
"rules" regression test, because some of the standard system views use IN
and their compiled formats have changed.
2005-11-28 04:35:32 +00:00
Andrew Dunstan 5b352d8e12 DROP DATABASE IF EXISTS variant 2005-11-22 15:24:18 +00:00
Alvaro Herrera cec3b0a9e6 Implement DROP OWNED and REASSIGN OWNED. These new commands facilitate the
process of dropping roles by dropping objects owned by them and privileges
granted to them, or giving the owned objects to someone else, through the
use of the data stored in the new pg_shdepend catalog.

Some refactoring of the GRANT/REVOKE code was needed, as well as ALTER OWNER
code.  Further cleanup of code duplication in the GRANT code seems necessary.

Implemented by me after an idea from Tom Lane, who also provided various kind
of implementation advice.

Regression tests pass.  Some tests for the new functionality are also added,
as well as rudimentary documentation.
2005-11-21 12:49:33 +00:00
Andrew Dunstan daea4d8eae DROP objecttype IF EXISTS for the following objects:
table view index sequence schema type domain conversion
2005-11-19 17:39:45 +00:00
Tom Lane b31eeadcab Force the second argument of SUBSTRING(foo FOR bar) to be int4, to avoid
surprising results when it's some other numeric type.  This doesn't solve
the generic problem of surprising implicit casts to text, but it's a
low-impact way of making sure this particular case behaves sanely.
Per gripe from Harald Fuchs and subsequent discussion.
2005-11-13 19:11:28 +00:00
Bruce Momjian 9f53cfd9db Add comments explaining clauses used by CREATE ROLE but not ALTER. 2005-09-23 22:25:25 +00:00
Tom Lane e0dedd0559 Implement a preliminary 'template' facility for procedural languages,
as per my recent proposal.  For now the template data is hard-wired in
proclang.c --- this should be replaced later by a new shared system
catalog, but we don't want to force initdb during 8.1 beta.  This change
lets us cleanly load existing dump files even if they contain outright
wrong information about a PL's support functions, such as a wrong path
to the shared library or a missing validator function.  Also, we can
revert the recent kluges to make pg_dump dump PL support functions that
are stored in pg_catalog.
While at it, I removed the code in pg_regress that replaced $libdir
with a hardcoded path for temporary installations.  This is no longer
needed given our support for relocatable installations.
2005-09-05 23:50:49 +00:00
Tom Lane 83ba41f02b Fix SHOW and RESET grammar to accept custom variable names. 2005-08-24 19:34:12 +00:00
Tom Lane 188c7c8ccf Add ALTER TABLE ENABLE/DISABLE TRIGGER commands. Change pg_dump to
use these instead of its previous hack of changing pg_class.reltriggers.
Documentation is lacking, will add that later.
Patch by Satoshi Nagayasu, review and some extra work by Tom Lane.
2005-08-23 22:40:47 +00:00
Tom Lane 2a4fad1a0e Add NOWAIT option to SELECT FOR UPDATE/SHARE.
Original patch by Hans-Juergen Schoenig, revisions by Karel Zak
and Tom Lane.
2005-08-01 20:31:16 +00:00
Tom Lane 35508d1cca Add ALTER object SET SCHEMA capability for a limited but useful set of
object kinds (tables, functions, types).  Documentation is not here yet.
Original code by Bernd Helmle, extensive rework by Bruce Momjian and
Tom Lane.
2005-08-01 04:03:59 +00:00
Tom Lane d42cf5a42a Add per-user and per-database connection limit options.
This patch also includes preliminary update of pg_dumpall for roles.
Petr Jelinek, with review by Bruce Momjian and Tom Lane.
2005-07-31 17:19:22 +00:00
Tom Lane 0c2d7e39f9 Minor correction: cause ALTER ROLE role ROLE rolenames to behave
sensibly, even though we don't document it.
2005-07-26 22:37:50 +00:00
Tom Lane af019fb9ae Add a role property 'rolinherit' which, when false, denotes that the role
doesn't automatically inherit the privileges of roles it is a member of;
for such a role, membership in another role can be exploited only by doing
explicit SET ROLE.  The default inherit setting is TRUE, so by default
the behavior doesn't change, but creating a user with NOINHERIT gives closer
adherence to our current reading of SQL99.  Documentation still lacking,
and I think the information schema needs another look.
2005-07-26 16:38:29 +00:00
Tom Lane e5d6b91220 Add SET ROLE. This is a partial commit of Stephen Frost's recent patch;
I'm still working on the has_role function and information_schema changes.
2005-07-25 22:12:34 +00:00
Tom Lane c33d575899 More cleanup on roles patch. Allow admin option to be inherited through
role memberships; make superuser/createrole distinction do something
useful; fix some locking and CommandCounterIncrement issues; prevent
creation of loops in the membership graph.
2005-06-29 20:34:15 +00:00
Tom Lane 0eaa36a16a Bring syntax of role-related commands into SQL compliance. To avoid
syntactic conflicts, both privilege and role GRANT/REVOKE commands have
to use the same production for scanning the list of tokens that might
eventually turn out to be privileges or role names.  So, change the
existing GRANT/REVOKE code to expect a list of strings not pre-reduced
AclMode values.  Fix a couple other minor issues while at it, such as
InitializeAcl function name conflicting with a Windows system function.
2005-06-28 19:51:26 +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 943b396245 Add Oracle-compatible GREATEST and LEAST functions. Pavel Stehule 2005-06-26 22:05:42 +00:00
Tom Lane db53fa6dc7 Remove overspecification of precision of CURRENT_TIMESTAMP, LOCALTIMESTAMP,
CURRENT_TIME, and LOCALTIME: now they just produce "timestamptz" not
"timestamptz(6)", etc.  This makes the behavior more consistent with our
choice to not assign a specific default precision to column datatypes.
It should also save a few cycles at runtime due to not having to invoke
the round-to-given-precision functions.
I also took the opportunity to translate CURRENT_TIMESTAMP into "now()"
instead of an invocation of the timestamptz input converter --- this should
save a few cycles too.
2005-06-24 14:28:06 +00:00
Tom Lane 4cc7a93d22 Make REINDEX DATABASE do what one would expect, namely reindex all indexes
in the database.  The old behavior (reindex system catalogs only) is now
available as REINDEX SYSTEM.  I did not add the complementary REINDEX USER
case since there did not seem to be consensus for this, but it would be
trivial to add later.  Per recent discussions.
2005-06-22 21:14:31 +00:00
Tom Lane d0a89683a3 Two-phase commit. Original patch by Heikki Linnakangas, with additional
hacking by Alvaro Herrera and Tom Lane.
2005-06-17 22:32:51 +00:00
Bruce Momjian d1944de61b Move SYMMETRIC/ASYMMETRIC to reserved words to avoid shift/reduce conflicts. 2005-06-15 19:44:05 +00:00
Bruce Momjian 8b84aebddf Add BETWEEN SYMMETRIC.
Pavel Stehule
2005-06-14 23:47:39 +00:00
Tom Lane 77c168a836 Remove grammar productions for prefix and postfix % and ^ operators,
as well as the existing pg_catalog entries for prefix and postfix %.
These have never been documented, though they did appear in one old
regression test.  This avoids surprising behavior in cases like
"SELECT -25 % -10".  Per recent discussion.
Note: although there is a catalog change here, I did not force initdb
since there's no harm in leaving the inaccessible entries in one's
copy of pg_operator.
2005-06-08 21:15:29 +00:00
Bruce Momjian b63990c6a8 Add COPY WITH CVS HEADER to allow a heading line as the first line in
COPY.

Andrew Dunstan
2005-05-07 02:22:49 +00:00
Bruce Momjian acc4f3e3cb Update comment to mention "Name classification hierarchy" as place to
check for reserved words.
2005-05-06 03:42:17 +00:00
Tom Lane bedb78d386 Implement sharable row-level locks, and use them for foreign key references
to eliminate unnecessary deadlocks.  This commit adds SELECT ... FOR SHARE
paralleling SELECT ... FOR UPDATE.  The implementation uses a new SLRU
data structure (managed much like pg_subtrans) to represent multiple-
transaction-ID sets.  When more than one transaction is holding a shared
lock on a particular row, we create a MultiXactId representing that set
of transactions and store its ID in the row's XMAX.  This scheme allows
an effectively unlimited number of row locks, just as we did before,
while not costing any extra overhead except when a shared lock actually
has to be shared.   Still TODO: use the regular lock manager to control
the grant order when multiple backends are waiting for a row lock.

Alvaro Herrera and Tom Lane.
2005-04-28 21:47:18 +00:00
Tom Lane c114e166e5 Define the right-hand input of AT TIME ZONE as a full a_expr instead of
c_expr.  Perhaps the restriction was once needed to avoid bison errors,
but it seems to work just fine now --- and even generates a slightly
smaller state machine.  This change allows examples like
SELECT '13:45'::timetz AT TIME ZONE '-07:00'::interval;
to work without parentheses around the right-hand input.
2005-04-23 17:22:16 +00:00
Neil Conway f5ab0a14ea Add a "USING" clause to DELETE, which is equivalent to the FROM clause
in UPDATE. We also now issue a NOTICE if a query has _any_ implicit
range table entries -- in the past, we would only warn about implicit
RTEs in SELECTs with at least one explicit RTE.

As a result of the warning change, 25 of the regression tests had to
be updated. I also took the opportunity to remove some bogus whitespace
differences between some of the float4 and float8 variants. I believe
I have correctly updated all the platform-specific variants, but let
me know if that's not the case.

Original patch for DELETE ... USING from Euler Taveira de Oliveira,
reworked by Neil Conway.
2005-04-07 01:51:41 +00:00
Tom Lane 47888fe842 First phase of OUT-parameters project. We can now define and use SQL
functions with OUT parameters.  The various PLs still need work, as does
pg_dump.  Rudimentary docs and regression tests included.
2005-03-31 22:46:33 +00:00
Tom Lane eb47ee4865 Fix grammar for IN/OUT/INOUT parameters. This commit doesn't actually
implement any new feature, it just pushes the 'not implemented' error
message deeper into the backend.  I also tweaked the grammar to accept
Oracle-ish parameter syntax (parameter name first), as well as the
SQL99 standard syntax (parameter mode first), since it was easy and
people will doubtless try to use both anyway.
2005-03-29 17:58:51 +00:00
Neil Conway c069655441 Allow ALTER FUNCTION to change a function's strictness, volatility, and
whether or not it is a security definer. Changing a function's strictness
is required by SQL2003, and the other capabilities make sense. Also, allow
an optional RESTRICT noise word to be specified, for SQL conformance.

Some trivial regression tests added and the documentation has been
updated.
2005-03-14 00:19:37 +00:00
Neil Conway 73f630500b Add support for temporary views, including documentation and regression
tests. Contributed by Koju Iijima, review from Neil Conway, Gavin Sherry
and Tom Lane.

Also, fix error in description of WITH CHECK OPTION clause in the CREATE
VIEW reference page: it should be "CASCADED", not "CASCADE".
2005-02-02 06:36:02 +00:00
Tom Lane f07b9689c9 Generalize TRUNCATE to support truncating multiple tables in one
command.  This is useful because we can allow truncation of tables
referenced by foreign keys, so long as the referencing table is
truncated in the same command.

Alvaro Herrera
2005-01-27 03:19:37 +00:00
PostgreSQL Daemon 2ff501590b Tag appropriate files for rc3
Also performed an initial run through of upgrading our Copyright date to
extend to 2005 ... first run here was very simple ... change everything
where: grep 1996-2004 && the word 'Copyright' ... scanned through the
generated list with 'less' first, and after, to make sure that I only
picked up the right entries ...
2004-12-31 22:04:05 +00:00
Tom Lane 3a372d61d0 Kris Jurka pointed out that the qualified_name production wasn't
working as intended --- for some reason, FROM a.b.c was getting
parsed as if it were a function name and not a qualified name.
I think there must be a bug in bison, because it should have
complained that the grammar was ambiguous.  Anyway, fix it along
the same lines previously used for func_name vs columnref, and get
rid of the right-recursion in attrs that seems to have confused
bison.
2004-11-08 04:02:20 +00:00
Tom Lane 98e8b48053 Create 'default_tablespace' GUC variable that supplies a TABLESPACE
clause implicitly whenever one is not given explicitly.  Remove concept
of a schema having an associated tablespace, and simplify the rules for
selecting a default tablespace for a table or index.  It's now just
(a) explicit TABLESPACE clause; (b) default_tablespace if that's not an
empty string; (c) database's default.  This will allow pg_dump to use
SET commands instead of tablespace clauses to determine object locations
(but I didn't actually make it do so).  All per recent discussions.
2004-11-05 19:17:13 +00:00
Tom Lane 4c5e810fcd Code review for NOWAIT patch: downgrade NOWAIT from fully reserved keyword
to unreserved keyword, use ereport not elog, assign a separate error code
for 'could not obtain lock' so that applications will be able to detect
that case cleanly.
2004-10-01 16:40:05 +00:00
Tom Lane f065957062 Come to think of it, functions in FROM have the same syntactic restriction
as CREATE INDEX did, and can be fixed the same way, for another small
improvement in usability and reduction in grammar size.
2004-09-30 00:24:27 +00:00
Tom Lane 912c27f9c2 Split out everything that looks like a function call from c_expr into
a separate production func_expr.  This allows us to accept all these
variants in the backwards-compatible syntax for creating a functional
index; which beats documenting exactly which things work and which don't.
Interestingly, it also seems to make the generated state machine a little
bit smaller.
2004-09-29 23:39:20 +00:00
Bruce Momjian da9a8649d8 Update copyright to 2004. 2004-08-29 04:13:13 +00:00
Tom Lane 3cb1ffa653 Allow second and subsequent names in a qualified (dotted) name to be
ColLabel instead of just ColId --- that is, any keyword can appear after
a dot and it will be taken as an identifier.  Fixes problems with names
that are okay as standalone function names but fail when qualified.
2004-08-24 20:41:40 +00:00
Tom Lane 37d937ea2c Code review for ALTER INDEX patch. 2004-08-22 00:08:28 +00:00
Bruce Momjian 09d4e96d7e Add ALTER INDEX, particularly for moving tablespaces.
Gavin Sherry
2004-08-20 04:29:33 +00:00
Tom Lane 7f7e8cc3f2 Allow commas in BEGIN, START TRANSACTION, and SET TRANSACTION, as required
by the SQL standard.  For backwards compatibility, however, continue to
accept the syntax without.  Minor editorialization in the reference pages
for these commands, too.
2004-08-12 21:00:34 +00:00
Tom Lane a583675108 Allow optional SAVEPOINT keyword in RELEASE and ROLLBACK TO, for greater
compliance with SQL2003 spec syntax.

Oliver Jowett
2004-08-12 19:12:21 +00:00
Tom Lane f0efe26402 Support USING INDEX TABLESPACE clause for PRIMARY KEY and UNIQUE
constraints.  Christopher Kings-Lynne.
2004-08-02 04:28:29 +00:00
Tom Lane cc813fc2b8 Replace nested-BEGIN syntax for subtransactions with spec-compliant
SAVEPOINT/RELEASE/ROLLBACK-TO syntax.  (Alvaro)
Cause COMMIT of a failed transaction to report ROLLBACK instead of
COMMIT in its command tag.  (Tom)
Fix a few loose ends in the nested-transactions stuff.
2004-07-27 05:11:48 +00:00