Commit Graph

514 Commits

Author SHA1 Message Date
Bruce Momjian 432b9b0f75 Add ALTER TABLE <tablename> CLUSTER ON <indexname>
Alvaro Herrera
2003-03-20 18:52:48 +00:00
Bruce Momjian 5f65225fa3 Todo items:
Add ALTER SEQUENCE to modify min/max/increment/cache/cycle values

Also updated create sequence docs to mention NO MINVALUE, & NO MAXVALUE.

New Files:
doc/src/sgml/ref/alter_sequence.sgml
src/test/regress/expected/sequence.out
src/test/regress/sql/sequence.sql


ALTER SEQUENCE is NOT transactional.  It behaves similarly to setval().
It matches the proposed SQL200N spec, as well as Oracle in most ways --
Oracle lacks RESTART WITH for some strange reason.

--
Rod Taylor <rbt@rbt.ca>
2003-03-20 07:02:11 +00:00
Tom Lane 6261c75014 Implement SQL92-compatible FIRST, LAST, ABSOLUTE n, RELATIVE n options
for FETCH and MOVE.
2003-03-11 19:40:24 +00:00
Tom Lane aa83bc04e0 Restructure parsetree representation of DECLARE CURSOR: now it's a
utility statement (DeclareCursorStmt) with a SELECT query dangling from
it, rather than a SELECT query with a few unusual fields in it.  Add
code to determine whether a planned query can safely be run backwards.
If DECLARE CURSOR specifies SCROLL, ensure that the plan can be run
backwards by adding a Materialize plan node if it can't.  Without SCROLL,
you get an error if you try to fetch backwards from a cursor that can't
handle it.  (There is still some discussion about what the exact
behavior should be, but this is necessary infrastructure in any case.)
Along the way, make EXPLAIN DECLARE CURSOR work.
2003-03-10 03:53:52 +00:00
Tom Lane 51972a9d5d COALESCE() and NULLIF() are now first-class expressions, not macros
that turn into CASE expressions.  They evaluate their arguments at most
once.  Patch by Kris Jurka, review and (very light) editorializing by me.
2003-02-16 02:30:39 +00:00
Bruce Momjian f249daf9b7 Adds in NO MAXVALUE and NO MINVALUE options for create sequence per 200X
spec, which will also make alter sequence a touch easier.

sequence.c  init_params() will check for settings which have been
defined twice, and complain.

Rod Taylor
2003-02-13 05:25:24 +00:00
Bruce Momjian 8195f8f042 Code for WITHOUT OIDS.
On Wed, 2003-01-08 at 21:59, Christopher Kings-Lynne wrote:
> I agree.  I want to remove OIDs from heaps of our tables when we go to 7.3.
> I'd rather not have to do it in the dump due to down time.


Rod Taylor <rbt@rbt.ca>
2003-02-13 05:20:05 +00:00
Tom Lane c5ba16a83c Get rid of last few vestiges of parsetree dependency on grammar token
codes, per discussion from last March.  parse.h should now be included
*only* by gram.y, scan.l, keywords.c, parser.c.  This prevents surprising
misbehavior after seemingly-trivial grammar adjustments.
2003-02-10 04:44:47 +00:00
Tom Lane 39b7ec3309 Create a distinction between Lists of integers and Lists of OIDs, to get
rid of the assumption that sizeof(Oid)==sizeof(int).  This is one small
step towards someday supporting 8-byte OIDs.  For the moment, it doesn't
do much except get rid of a lot of unsightly casts.
2003-02-09 06:56:28 +00:00
Tom Lane e24977f3a4 Allow qualified type names in CREATE CAST, DROP CAST. Also allow the
construction 'SETOF type[]' which for some reason was previously
overlooked (you'd have to name the array type directly to make it work).
2003-02-05 20:16:42 +00:00
Bruce Momjian 802a4d4111 Change MOVE LAST to MOVE ALL.
Standard says FETCH LAST is after last row, and we don't do that.
2003-02-03 14:04:24 +00:00
Tom Lane c7bceca156 Implement EXPLAIN EXECUTE. By Neil Conway, with some kibitzing from
Tom Lane.
2003-02-02 23:46:38 +00:00
Peter Eisentraut ef7422510e Grant options, and cascading revoke. Grant options are allowed only for
users right now, not groups.  Extension of has_foo_privileges functions to
query the grant options.  Extension of aclitem type to store grantor.
2003-01-23 23:39:07 +00:00
Peter Eisentraut b65cd56240 Read-only transactions, as defined in SQL. 2003-01-10 22:03:30 +00:00
Tom Lane e69785debf Further tweaking of parsetree & plantree representation of SubLinks.
Simplify SubLink by storing just a List of operator OIDs, instead of
a list of incomplete OpExprs --- that was a bizarre and bulky choice,
with no redeeming social value since we have to build new OpExprs
anyway when forming the plan tree.
2003-01-10 21:08:15 +00:00
Peter Eisentraut 36ea26793a Add optional drop behavior clause to REVOKE command, for SQL conformance.
Currently, only RESTRICT is allowed.
2003-01-10 11:02:51 +00:00
Tom Lane 6bc61fc046 Adjust parser so that 'x NOT IN (subselect)' is converted to
'NOT (x IN (subselect))', that is 'NOT (x = ANY (subselect))',
rather than 'x <> ALL (subselect)' as we formerly did.  This
opens the door to optimizing NOT IN the same way as IN, whereas
there's no hope of optimizing the expression using <>.  Also,
convert 'x <> ALL (subselect)' to the NOT(IN) style, so that
the optimization will be available when processing rules dumped
by older Postgres versions.
initdb forced due to small change in SubLink node representation.
2003-01-09 20:50:53 +00:00
Tom Lane 061168d38f Code review for FETCH/MOVE 0 changes. Improve documentation, do the
right thing with the destination when FETCH 0 can't return a row,
don't try to stuff LONG_MAX into an int value.
2003-01-08 00:22:27 +00:00
Tom Lane daec989f6a ALTER DOMAIN OWNER, from Rod Taylor. 2003-01-06 00:31:45 +00:00
Bruce Momjian 33f0108df8 Cause FETCH 1 to return the current cursor row, or zero if at
beginning/end of cursor.

Have MOVE return 0/1 depending on cursor position.

Matches SQL spec.

Pass cursor counter from parser as a long rather than int.

Doc updates.
2002-12-30 15:31:51 +00:00
Tom Lane b0422b215c Preliminary code review for domain CHECK constraints patch: add documentation,
make VALUE a non-reserved word again, use less invasive method of passing
ConstraintTestValue into transformExpr, fix problems with nested constraint
testing, do correct thing with NULL result from a constraint expression,
remove memory leak.  Domain checks still need much more work if we are going
to allow ALTER DOMAIN, however.
2002-12-12 20:35:16 +00:00
Tom Lane a0bf885f9e Phase 2 of read-only-plans project: restructure expression-tree nodes
so that all executable expression nodes inherit from a common supertype
Expr.  This is somewhat of an exercise in code purity rather than any
real functional advance, but getting rid of the extra Oper or Func node
formerly used in each operator or function call should provide at least
a little space and speed improvement.
initdb forced by changes in stored-rules representation.
2002-12-12 15:49:42 +00:00
Bruce Momjian 05a6b37912 Re-addd Rod's ALTER DOMAIN patch. 2002-12-06 05:00:34 +00:00
Bruce Momjian 5b4c16e099 Back out ALTER DOMAIN patch until missing file appears. 2002-12-06 03:43:35 +00:00
Bruce Momjian 853153ca6d ALTER DOMAIN .. SET / DROP NOT NULL
ALTER DOMAIN .. SET / DROP DEFAULT
ALTER DOMAIN .. ADD / DROP CONSTRAINT

New files:
- doc/src/sgml/ref/alter_domain.sgml

Rod Taylor
2002-12-06 03:28:34 +00:00
Tom Lane f893ee271f Remove unused constisset and constiscast fields of Const nodes. Clean
up code and documentation associated with Param nodes.
2002-11-25 21:29:42 +00:00
Tom Lane 0aa5b6866e Un-break triggers declared for INSERT OR DELETE OR UPDATE. This worked
okay in 7.3, so I think it must have been busted in the recent triggers
patch.
2002-11-25 03:36:50 +00:00
Bruce Momjian 1b7f3cc02d This patch implements FOR EACH STATEMENT triggers, per my email to
-hackers a couple days ago.

Notes/caveats:

        - added regression tests for the new functionality, all
          regression tests pass on my machine

        - added pg_dump support

        - updated PL/PgSQL to support per-statement triggers; didn't
          look at the other procedural languages.

        - there's (even) more code duplication in trigger.c than there
          was previously. Any suggestions on how to refactor the
          ExecXXXTriggers() functions to reuse more code would be
          welcome -- I took a brief look at it, but couldn't see an
          easy way to do it (there are several subtly-different
          versions of the code in question)

        - updated the documentation. I also took the liberty of
          removing a big chunk of duplicated syntax documentation in
          the Programmer's Guide on triggers, and moving that
          information to the CREATE TRIGGER reference page.

        - I also included some spelling fixes and similar small
          cleanups I noticed while making the changes. If you'd like
          me to split those into a separate patch, let me know.

Neil Conway
2002-11-23 03:59:09 +00:00
Bruce Momjian c4501ec551 Remove ALL from CLUSTER ALL. Use just CLUSTER. 2002-11-18 17:12:07 +00:00
Bruce Momjian 8bc717cb88 New version attached. The following is implemented:
- CLUSTER ALL clusters all the tables that have some index with
  indisclustered set and the calling user owns.
- CLUSTER tablename clusters the named table, using the index with
  indisclustered set.  If no index has the bit set, throws elog(ERROR).
- The multi-relation version (CLUSTER ALL) uses a multitransaction
  approach, similar to what VACUUM does.

Alvaro Herrera
2002-11-15 03:09:39 +00:00
Bruce Momjian 6b603e67dc Add DOMAIN check constraints.
Rod Taylor
2002-11-15 02:50:21 +00:00
Bruce Momjian 4e5a947d1c Make MOVE/FETCH 0 actually move/fetch 0. Add MOVE LAST to move to end
of cursor.
2002-11-13 00:44:09 +00:00
Tom Lane f9b5b41ef9 Code review for ON COMMIT patch. Make the actual on-commit action happen
before commit, not after :-( --- the original coding is not only unsafe
if an error occurs while it's processing, but it generates an invalid
sequence of WAL entries.  Resurrect 7.2 logic for deleting items when
no longer needed.  Use an enum instead of random macros.  Editorialize
on names used for routines and constants.  Teach backend/nodes routines
about new field in CreateTable struct.  Add a regression test.
2002-11-11 22:19:25 +00:00
Bruce Momjian 3eabc4490e Tweak CREATE SEQUENCE grammar to be more SQL1999 standards compliant.
Neil Conway
2002-11-10 00:10:20 +00:00
Bruce Momjian ebb531836a Add code to handle [ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP }]
for temp tables.

Gavin Sherry
2002-11-09 23:56:39 +00:00
Tom Lane 5123139210 Remove encoding lookups from grammar stage, push them back to places
where it's safe to do database access.  Along the way, fix core dump
for 'DEFAULT' parameters to CREATE DATABASE.  initdb forced due to
change in pg_proc entry.
2002-11-02 18:41:22 +00:00
Tom Lane cab9437a43 Arrange to compile flex output files as inclusions into other files
(usually bison output files), not as standalone files.  This hack
works around flex's insistence on including <stdio.h> before we are
able to include postgres.h; postgres.h will already be read before
the compiler starts to read the flex output file.  Needed for largefile
support on some platforms.
2002-11-01 22:52:34 +00:00
Bruce Momjian 2982b97f71 Clean up gram.y trailing spaces. 2002-10-31 02:31:00 +00:00
Tom Lane 0582874506 Remove commas from %type and %token lists, for compatibility with newer
versions of bison.
2002-09-22 21:44:43 +00:00
Tom Lane c328b6dd8b Replace pg_attribute.attisinherited with attislocal and attinhcount
columns, to allow more correct behavior in multiple-inheritance cases.
Patch by Alvaro Herrera, review by Tom Lane.
2002-09-22 19:42:52 +00:00
Tom Lane 9946b83ded Bring SIMILAR TO and SUBSTRING into some semblance of conformance with
the SQL99 standard.  (I'm not sure that the character-class features are
quite right, but that can be fixed later.)  Document SQL99 and POSIX
regexps as being different features; provide variants of SUBSTRING for
each.
2002-09-22 17:27:25 +00:00
Tom Lane b26dfb9522 Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution.  Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 21:35:25 +00:00
Tom Lane 6fe27ca2fb Fix some operator-precedence problems. New constructs IS DISTINCT FRM
and IS [NOT] OF were not being parsed consistently with other IS forms.
Also, make the world a little safer for functions named LEFT, RIGHT, etc.
2002-09-05 22:52:48 +00:00
Tom Lane 248c67d7ed CREATE OR REPLACE VIEW, CREATE OR REPLACE RULE.
Gavin Sherry, Neil Conway, and Tom Lane all got their hands dirty
on this one ...
2002-09-02 02:13:02 +00:00
Tom Lane 64505ed58b Code review for standalone composite types, query-specified composite
types, SRFs.  Not happy with memory management yet, but I'll commit these
other changes.
2002-08-29 00:17:06 +00:00
Bruce Momjian 81dfa2ce43 backend where a statically sized buffer is written to. Most of these
should be pretty safe in practice, but it's probably better to be safe
than sorry.

I was actually looking for cases where NAMEDATALEN is assumed to be
32, but only found one. That's fixed too, as well as a few bits of
code cleanup.

Neil Conway
2002-08-28 20:46:24 +00:00
Bruce Momjian 6077db92c2 Allow FOR UPDATE to appear after LIMIT/OFFSET to match MySQL syntax and as
a more logical ordering.
2002-08-28 14:35:37 +00:00
Tom Lane 28e82066a1 PREPARE/EXECUTE statements. Patch by Neil Conway, some kibitzing
from Tom Lane.
2002-08-27 04:55:12 +00:00
Tom Lane 6ebc90b045 Remove Ident nodetype in favor of using String nodes; this fixes some
latent wrong-struct-type bugs and makes the coding style more uniform,
since the majority of places working with lists of column names were
already using Strings not Idents.  While at it, remove vestigial
support for Stream node type, and otherwise-unreferenced nodes.h entries
for T_TupleCount and T_BaseNode.
NB: full recompile is recommended due to changes of Node type numbers.
This shouldn't force an initdb though.
2002-08-19 15:08:47 +00:00
Bruce Momjian b1a5f87209 Tom Lane wrote:
> There's no longer a separate call to heap_storage_create in that routine
> --- the right place to make the test is now in the storage_create
> boolean parameter being passed to heap_create.  A simple change, but
> it passeth patch's understanding ...

Thanks.

Attached is a patch against cvs tip as of 8:30 PM PST or so. Turned out
that even after fixing the failed hunks, there was a new spot in
bufmgr.c which needed to be fixed (related to temp relations;
RelationUpdateNumberOfBlocks). But thankfully the regression test code
caught it :-)

Joe Conway
2002-08-15 16:36:08 +00:00