Commit Graph

74 Commits

Author SHA1 Message Date
Tom Lane 9309d5f2ba In ALTER COLUMN TYPE, strip any implicit coercion operations appearing
at the top level of the column's old default expression before adding
an implicit coercion to the new column type.  This seems to satisfy the
principle of least surprise, as per discussion of bug #1290.
2004-10-22 17:20:05 +00:00
Tom Lane af4de81469 ALTER TABLE SET TABLESPACE. Gavin Sherry, some rework by Tom Lane. 2004-07-11 23:13:58 +00:00
Bruce Momjian 36ae5efab1 Improve without cluster wording. 2004-06-02 21:04:40 +00:00
Bruce Momjian 1cdc58722c OK, here's the final version of ALTER TABLE ... SET WITHOUT CLUSTER.
Has docs + regression test.

Christopher Kings-Lynne
2004-06-02 21:01:10 +00:00
Tom Lane c792cbcc26 Recommend ALTER TABLE ... TYPE as the best way to reclaim space occupied by deleted columns. The old method involving UPDATE and VACUUM FULL will be considerably less efficient. 2004-05-27 03:30:11 +00:00
Tom Lane 077db40fa1 ALTER TABLE rewrite. New cool stuff:
* ALTER ... ADD COLUMN with defaults and NOT NULL constraints works per SQL
spec.  A default is implemented by rewriting the table with the new value
stored in each row.

* ALTER COLUMN TYPE.  You can change a column's datatype to anything you
want, so long as you can specify how to convert the old value.  Rewrites
the table.  (Possible future improvement: optimize no-op conversions such
as varchar(N) to varchar(N+1).)

* Multiple ALTER actions in a single ALTER TABLE command.  You can perform
any number of column additions, type changes, and constraint additions with
only one pass over the table contents.

Basic documentation provided in ALTER TABLE ref page, but some more docs
work is needed.

Original patch from Rod Taylor, additional work from Tom Lane.
2004-05-05 04:48:48 +00:00
Neil Conway ce5273757b Make a cross-reference in the ALTER TABLE ref page into a <xref>. 2004-03-24 09:49:20 +00:00
Tom Lane 24614a9880 Upgrade ALTER TABLE DROP COLUMN so that it can drop an OID column, and
remove separate implementation of ALTER TABLE SET WITHOUT OIDS in favor
of doing a regular DROP.  Also, cause CREATE TABLE to account completely
correctly for the inheritance status of the OID column.  This fixes
problems with dropping OID columns that have dependencies, as noted by
Christopher Kings-Lynne, as well as making sure that you can't drop an
OID column that was inherited from a parent.
2004-03-23 19:35:17 +00:00
Neil Conway 80ec228389 Refer to GUC variables using <xref> tags rather than <varname> tags,
where appropriate. Add "id" and "xreflabel" tags to the descriptions
of the GUC variables to facilitate this. Also make a few minor docs
cleanups.
2004-03-09 16:57:47 +00:00
Neil Conway 1a6a27650d Add a few more xrefs, where they seemed appropriate: for example, refer
to the discussion of planner statistics in the documentation for the
default_statistics_target GUC var.
2004-03-01 17:58:39 +00:00
Bruce Momjian 7ce9b7c0d8 This patch adds a new GUC var, "default_with_oids", which follows the
proposal for eventually deprecating OIDs on user tables that I posted
earlier to pgsql-hackers. pg_dump now always specifies WITH OIDS or
WITHOUT OIDS when dumping a table. The documentation has been updated.

Neil Conway
2003-12-01 22:08:02 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
Peter Eisentraut 5d00f984d8 Make the SQL command synopses appear less random. 2003-09-22 00:16:58 +00:00
Tom Lane d4019b7cd3 Remove a bunch of content-free Diagnostics sections, as per previous
discussion.  (Still have some work to do editing the remainder.)
2003-09-09 18:28:53 +00:00
Peter Eisentraut c326d8f4f2 Add/edit index entries. 2003-08-31 17:32:24 +00:00
Peter Eisentraut 7c084d148f Bring SQL ref pages to consistent format, part 1. 2003-04-15 13:25:08 +00:00
Peter Eisentraut 5e5c5cd31a Merge documentation into one book. (Build with "make html".) Replace
vague cross-references with real links.
2003-03-25 16:15:44 +00:00
Bruce Momjian 432b9b0f75 Add ALTER TABLE <tablename> CLUSTER ON <indexname>
Alvaro Herrera
2003-03-20 18:52:48 +00:00
Bruce Momjian cde8bbc413 This patch makes the following changes to the documentation:
- more work from the SGML police

- some grammar improvements: rewriting a paragraph or two, replacing
contractions where (IMHO) appropriate

- fix missing utility commands in lock mode docs

- improve CLUSTER, REINDEX, SET SESSION AUTHORIZATION ref pages

Neil Conway
2003-02-19 04:06:28 +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
Bruce Momjian be2b660ecd This patch includes a lot of minor cleanups to the SGML documentation,
including:

- replacing all the appropriate usages of <citetitle>PostgreSQL
...</citetitle> with &cite-user;, &cite-admin;, and so on

- fix an omission in the EXECUTE documentation

- add some more text to the EXPLAIN documentation

- improve the PL/PgSQL RETURN NEXT documentation (more work to do here)

- minor markup fixes


Neil Conway
2003-01-19 00:13:31 +00:00
Tom Lane 9cecff0314 Document that zero-column tables are allowed (and non-standard). 2002-12-16 19:08:25 +00:00
Tom Lane 272bf59d29 Fix inconsistent formatting. 2002-10-19 23:09:20 +00:00
Tom Lane 93dca0d224 Fix incomplete definition of ALTER TABLE ADD/DROP CONSTRAINT syntax.
Add some verbiage about recent tweaks to behavior of ADD and DROP
COLUMN when there are descendant tables.
2002-10-19 22:51:45 +00:00
Peter Eisentraut bc49968764 Add more appropriate markup. 2002-09-21 18:32:54 +00:00
Bruce Momjian 88bd306832 > Neil Conway <nconway@klamath.dyndns.org> writes:
> > This patch improves the documentation of the UPDATE and ALTER TABLE
> > commands to elaborate on the effect of specifying an "ONLY" clause.
>
> Unfortunately this is still only half the truth ... see the
> SQL_INHERITANCE configuration variable.

Okay, I've attached an updated patch with more information on
SQL_INHERITANCE and inheritance behavior in prior releases.

Neil Conway
2002-08-15 02:59:18 +00:00
Tom Lane 38bb77a5d1 ALTER TABLE DROP COLUMN works. Patch by Christopher Kings-Lynne,
code review by Tom Lane.  Remaining issues: functions that take or
return tuple types are likely to break if one drops (or adds!)
a column in the table defining the type.  Need to think about what
to do here.

Along the way: some code review for recent COPY changes; mark system
columns attnotnull = true where appropriate, per discussion a month ago.
2002-08-02 18:15:10 +00:00
Tom Lane ce7565ab91 Instead of having a configure-time DEFAULT_ATTSTATTARGET, store -1 in
attstattarget to indicate 'use the default'.  The default is now a GUC
variable default_statistics_target, and so may be changed on the fly.  Along
the way we gain the ability to have pg_dump dump the per-column statistics
target when it's not the default.  Patch by Neil Conway, with some kibitzing
from Tom Lane.
2002-07-31 17:19:54 +00:00
Tom Lane 7c6df91dda Second phase of committing Rod Taylor's pg_depend/pg_constraint patch.
pg_relcheck is gone; CHECK, UNIQUE, PRIMARY KEY, and FOREIGN KEY
constraints all have real live entries in pg_constraint.  pg_depend
exists, and RESTRICT/CASCADE options work on most kinds of DROP;
however, pg_depend is not yet very well populated with dependencies.
(Most of the ones that are present at this point just replace formerly
hardwired associations, such as the implicit drop of a relation's pg_type
entry when the relation is dropped.)  Need to add more logic to create
dependency entries, improve pg_dump to dump constraints in place of
indexes and triggers, and add some regression tests.
2002-07-12 18:43:19 +00:00
Peter Eisentraut 2c50f6344b Revise command completion tags as per hackers message on 20 March. 2002-05-18 15:44:48 +00:00
Bruce Momjian 19b31e0713 Oops, wrong commit on previous. It was:
The attached patch allows views to have default values. You can't
specify a default value within a CREATE VIEW statement, it must be
done using ALTER TABLE ... ALTER COLUMN ... SET DEFAULT after the
view has already been created. Most of the hard work was done by
Tom Lane, I just patched pg_dump and updated the documentation.

Neil Conway <neilconway@rogers.com>
2002-04-24 02:40:45 +00:00
Tom Lane 0c1fe3d2b9 Update SQL-command reference pages for schema features. 2002-04-23 02:07:16 +00:00
Thomas G. Lockhart c05f29e895 Augment the date/time examples in the User's Guide to reflect the newer
capabilities of specifying time zones as intervals per SQL9x.
Put refentrytitle contents on the same line as the tag.
 Otherwise, leading whitespace is propagated into the product, which
 (at least) messes up the ToC layout.
Remove (some) docinfo tags containing dates. Best to omit if the dates
 are not accurate; maybe use CVS dates instead or leave them out.
2002-04-21 19:02:39 +00:00
Tom Lane 9b77f61930 ALTER TABLE SET/DROP NOT NULL, from Christopher Kings-Lynne. 2002-04-01 04:35:40 +00:00
Bruce Momjian 62e6eb9bf7 alter table doc cleanups.
Neil Conway
2002-03-06 20:42:38 +00:00
Bruce Momjian 03194432de I attach a version of my toast-slicing patch, against current CVS
(current as of a few hours ago.)

This patch:

1. Adds PG_GETARG_xxx_P_SLICE() macros and associated support routines.

2. Adds routines in src/backend/access/tuptoaster.c for fetching only
necessary chunks of a toasted value. (Modelled on latest changes to
assume chunks are returned in order).

3. Amends text_substr and bytea_substr to use new methods. It now
handles multibyte cases -and should still lead to a performance
improvement in the multibyte case where the substring is near the
beginning of the string.

4. Added new command: ALTER TABLE tabname ALTER COLUMN colname SET
STORAGE {PLAIN | EXTERNAL | EXTENDED | MAIN} to parser and documented in
alter-table.sgml. (NB I used ColId as the item type for the storage
mode string, rather than a new production - I hope this makes sense!).
All this does is sets attstorage for the specified column.

4. AlterTableAlterColumnStatistics is now AlterTableAlterColumnFlags and
handles both statistics and storage (it uses the subtype code to
distinguish). The previous version of my patch also re-arranged other
code in backend/commands/command.c but I have dropped that from this
patch.(I plan to return to it separately).

5. Documented new macros (and also the PG_GETARG_xxx_P_COPY macros) in
xfunc.sgml. ref/alter_table.sgml also contains documentation for ALTER
COLUMN SET STORAGE.

John Gray
2002-03-05 05:33:31 +00:00
Bruce Momjian 62feef6c95 Fix SGML typo in previous patch. 2002-02-17 13:29:00 +00:00
Bruce Momjian bf4507e3af I think it's important that it's actually documented that they can add
primary keys after the fact!

Also, we need to add regression tests for alter table / add primary key
and alter table / drop constraint.  These shouldn't be added until 7.3
tho
methinks...

Chris
2002-02-17 11:50:09 +00:00
Bruce Momjian a966ac1df0 Clarify params to ALTER TABLE to clearly show single parameters.
e.g. table contraint definition -> table_constraint_definition.
2002-02-16 23:45:48 +00:00
Peter Eisentraut bf43bed848 Spell-check and markup police 2002-01-20 22:19:57 +00:00
Thomas G. Lockhart 03a321d214 Use PostgreSQL consistantly throughout docs. Before, usage was split evenly
between Postgres and PostgreSQL.
2001-12-08 03:24:40 +00:00
Bruce Momjian ed19b9149a Add mention that ALTER TABLE RENAME affects indexes and sequences too. 2001-11-22 03:42:32 +00:00
Peter Eisentraut 17f0b55d15 Initial round of tweakage for man pages 2001-11-18 20:35:02 +00:00
Tom Lane 26e8a4f356 Repair erroneous ALTER DROP CONSTRAINT example. 2001-11-10 20:13:37 +00:00
Peter Eisentraut f08c9ff84b Make the CREATE TABLE ref page more readable and update some information. 2001-10-22 18:14:47 +00:00
Tom Lane f9e6e27c87 Break transformCreateStmt() into multiple routines and make
transformAlterStmt() use these routines, instead of having lots of
duplicate (not to mention should-have-been-duplicate) code.
Adding a column with a CHECK constraint actually works now,
and the tests to reject unsupported DEFAULT and NOT NULL clauses
actually fire now.  ALTER TABLE ADD PRIMARY KEY works, modulo
having to have created the column(s) NOT NULL already.
2001-10-12 00:07:15 +00:00
Tatsuo Ishii 3b99f74d95 Fix typo (add ;) 2001-09-12 02:13:25 +00:00
Bruce Momjian bd9b32803b Here is my much-promised patch to let people add UNIQUE constraints after
table creation time.  Big deal you say - but this patch is the basis of the
next thing which is adding PRIMARY KEYs after table creation time.  (Which
is currently impossible without twiddling catalogs)

Rundown
-------

* I have made the makeObjectName function of analyze.c non-static, and
exported it in analyze.h

* I have included analyze.h and defrem.h into command.c, to support
makingObjectNames and creating indices

* I removed the 'case CONSTR_PRIMARY' clause so that it properly fails and
says you can't add primary keys, rather than just doing nothing and
reporting nothing!!!

* I have modified the docs.

Algorithm
---------

* If name specified is null, search for a new valid constraint name.  I'm
not sure if I should "lock" my generated name somehow tho - should I open
the relation before doing this step?

* Open relation in access exclusive mode

* Check that the constraint does not already exist

* Define the new index

* Warn if they're doubling up on an existing index

Christopher Kings-Lynne
2001-09-07 21:57:53 +00:00
Peter Eisentraut 89a1ea4207 Put some kind of grammatical uniformity in the <refpurpose> lines. 2001-09-03 12:57:50 +00:00
Bruce Momjian 3d56fb7598 This is a docs patch to go with my DROP CONSTRAINT patch.
Christopher Kings
2001-05-30 13:01:08 +00:00