1. 14 12月, 2008 1 次提交
  2. 07 12月, 2008 1 次提交
  3. 19 11月, 2008 1 次提交
    • H
      Rethink the way FSM truncation works. Instead of WAL-logging FSM · 33960006
      Heikki Linnakangas 提交于
      truncations in FSM code, call FreeSpaceMapTruncateRel from smgr_redo. To
      make that cleaner from modularity point of view, move the WAL-logging one
      level up to RelationTruncate, and move RelationTruncate and all the
      related WAL-logging to new src/backend/catalog/storage.c file. Introduce
      new RelationCreateStorage and RelationDropStorage functions that are used
      instead of calling smgrcreate/smgrscheduleunlink directly. Move the
      pending rel deletion stuff from smgrcreate/smgrscheduleunlink to the new
      functions. This leaves smgr.c as a thin wrapper around md.c; all the
      transactional stuff is now in storage.c.
      
      This will make it easier to add new forks with similar truncation logic,
      like the visibility map.
      33960006
  4. 14 11月, 2008 1 次提交
  5. 02 11月, 2008 1 次提交
    • T
      Remove all uses of the deprecated functions heap_formtuple, heap_modifytuple, · 902d1cb3
      Tom Lane 提交于
      and heap_deformtuple in favor of the newer functions heap_form_tuple et al
      (which do the same things but use bool control flags instead of arbitrary
      char values).  Eliminate the former duplicate coding of these functions,
      reducing the deprecated functions to mere wrappers around the newer ones.
      We can't get rid of them entirely because add-on modules probably still
      contain many instances of the old coding style.
      
      Kris Jurka
      902d1cb3
  6. 21 10月, 2008 1 次提交
  7. 07 10月, 2008 1 次提交
    • H
      When a relation is moved to another tablespace, we can't assume that we can · fa3938fc
      Heikki Linnakangas 提交于
      use the old relfilenode in the new tablespace. There might be another relation
      in the new tablespace with the same relfilenode, so we must generate a fresh
      relfilenode in the new tablespace.
      
      The 8.3 patch to let deleted relation files linger as zero-length files until
      the next checkpoint made this more obvious: moving a relation from one table
      space another, and then back again, caused a collision with the lingering
      file.
      
      Back-patch to 8.1. The issue is present in 8.0 as well, but it doesn't seem
      worth fixing there, because we didn't have protection from OID collisions
      after OID wraparound before 8.1.
      
      Report by Guillaume Lelarge.
      fa3938fc
  8. 08 9月, 2008 1 次提交
  9. 02 9月, 2008 1 次提交
  10. 29 8月, 2008 1 次提交
    • T
      Extend the parser location infrastructure to include a location field in · a2794623
      Tom Lane 提交于
      most node types used in expression trees (both before and after parse
      analysis).  This allows us to place an error cursor in many situations
      where we formerly could not, because the information wasn't available
      beyond the very first level of parse analysis.  There's a fair amount
      of work still to be done to persuade individual ereport() calls to actually
      include an error location, but this gets the initdb-forcing part of the
      work out of the way; and the situation is already markedly better than
      before for complaints about unimplementable implicit casts, such as
      CASE and UNION constructs with incompatible alternative data types.
      Per my proposal of a few days ago.
      a2794623
  11. 26 8月, 2008 1 次提交
  12. 11 8月, 2008 1 次提交
    • H
      Introduce the concept of relation forks. An smgr relation can now consist · 3f0e808c
      Heikki Linnakangas 提交于
      of multiple forks, and each fork can be created and grown separately.
      
      The bulk of this patch is about changing the smgr API to include an extra
      ForkNumber argument in every smgr function. Also, smgrscheduleunlink and
      smgrdounlink no longer implicitly call smgrclose, because other forks might
      still exist after unlinking one. The callers of those functions have been
      modified to call smgrclose instead.
      
      This patch in itself doesn't have any user-visible effect, but provides the
      infrastructure needed for upcoming patches. The additional forks envisioned
      are a rewritten FSM implementation that doesn't rely on a fixed-size shared
      memory block, and a visibility map to allow skipping portions of a table in
      VACUUM that have no dead tuples.
      3f0e808c
  13. 17 7月, 2008 2 次提交
  14. 19 6月, 2008 1 次提交
  15. 16 6月, 2008 1 次提交
  16. 15 6月, 2008 2 次提交
    • T
      Rearrange ALTER TABLE syntax processing as per my recent proposal: the · a0b012a1
      Tom Lane 提交于
      grammar allows ALTER TABLE/INDEX/SEQUENCE/VIEW interchangeably for all
      subforms of those commands, and then we sort out what's really legal
      at execution time.  This allows the ALTER SEQUENCE/VIEW reference pages
      to fully document all the ALTER forms available for sequences and views
      respectively, and eliminates a longstanding cause of confusion for users.
      
      The net effect is that the following forms are allowed that weren't before:
      	ALTER SEQUENCE OWNER TO
      	ALTER VIEW ALTER COLUMN SET/DROP DEFAULT
      	ALTER VIEW OWNER TO
      	ALTER VIEW SET SCHEMA
      (There's no actual functionality gain here, but formerly you had to say
      ALTER TABLE instead.)
      
      Interestingly, the grammar tables actually get smaller, probably because
      there are fewer special cases to keep track of.
      
      I did not disallow using ALTER TABLE for these operations.  Perhaps we
      should, but there's a backwards-compatibility issue if we do; in fact
      it would break existing pg_dump scripts.  I did however tighten up
      ALTER SEQUENCE and ALTER VIEW to reject non-sequences and non-views
      in the new cases as well as a couple of cases where they didn't before.
      
      The patch doesn't change pg_dump to use the new syntaxes, either.
      a0b012a1
    • T
      Refactor the handling of the various DropStmt variants so that when multiple · 0cefb50f
      Tom Lane 提交于
      objects are specified, we drop them all in a single performMultipleDeletions
      call.  This makes the RESTRICT/CASCADE checks more relaxed: it's not counted
      as a cascade if one of the later objects has a dependency on an earlier one.
      NOTICE messages about such cases go away, too.
      
      In passing, fix the permissions check for DROP CONVERSION, which for some
      reason was never made role-aware, and omitted the namespace-owner exemption
      too.
      
      Alex Hunsaker, with further fiddling by me.
      0cefb50f
  17. 19 5月, 2008 1 次提交
  18. 17 5月, 2008 1 次提交
    • T
      Add a RESTART (without parameter) option to ALTER SEQUENCE, allowing a · 10a3471b
      Tom Lane 提交于
      sequence to be reset to its original starting value.  This requires adding the
      original start value to the set of parameters (columns) of a sequence object,
      which is a user-visible change with potential compatibility implications;
      it also forces initdb.
      
      Also add hopefully-SQL-compatible RESTART/CONTINUE IDENTITY options to
      TRUNCATE TABLE.  RESTART IDENTITY executes ALTER SEQUENCE RESTART for all
      sequences "owned by" any of the truncated relations.  CONTINUE IDENTITY is
      a no-op option.
      
      Zoltan Boszormenyi
      10a3471b
  19. 12 5月, 2008 1 次提交
    • A
      Restructure some header files a bit, in particular heapam.h, by removing some · f8c4d7db
      Alvaro Herrera 提交于
      unnecessary #include lines in it.  Also, move some tuple routine prototypes and
      macros to htup.h, which allows removal of heapam.h inclusion from some .c
      files.
      
      For this to work, a new header file access/sysattr.h needed to be created,
      initially containing attribute numbers of system columns, for pg_dump usage.
      
      While at it, make contrib ltree, intarray and hstore header files more
      consistent with our header style.
      f8c4d7db
  20. 10 5月, 2008 1 次提交
    • T
      Change the rules for inherited CHECK constraints to be essentially the same · cd902b33
      Tom Lane 提交于
      as those for inherited columns; that is, it's no longer allowed for a child
      table to not have a check constraint matching one that exists on a parent.
      This satisfies the principle of least surprise (rows selected from the parent
      will always appear to meet its check constraints) and eliminates some
      longstanding bogosity in pg_dump, which formerly had to guess about whether
      check constraints were really inherited or not.
      
      The implementation involves adding conislocal and coninhcount columns to
      pg_constraint (paralleling attislocal and attinhcount in pg_attribute)
      and refactoring various ALTER TABLE actions to be more like those for
      columns.
      
      Alex Hunsaker, Nikhil Sontakke, Tom Lane
      cd902b33
  21. 25 4月, 2008 1 次提交
    • T
      Fix ALTER TABLE ADD COLUMN ... PRIMARY KEY so that the new column is correctly · 5c068038
      Tom Lane 提交于
      checked to see if it's been initialized to all non-nulls.  The implicit NOT
      NULL constraint was not being checked during the ALTER (in fact, not even if
      there was an explicit NOT NULL too), because ATExecAddColumn neglected to
      set the flag needed to make the test happen.  This has been broken since
      the capability was first added, in 8.0.
      
      Brendan Jurd, per a report from Kaloyan Iliev.
      5c068038
  22. 31 3月, 2008 1 次提交
  23. 28 3月, 2008 1 次提交
  24. 27 3月, 2008 4 次提交
  25. 26 3月, 2008 1 次提交
    • T
      Simplify and standardize conversions between TEXT datums and ordinary C · 220db7cc
      Tom Lane 提交于
      strings.  This patch introduces four support functions cstring_to_text,
      cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and
      two macros CStringGetTextDatum and TextDatumGetCString.  A number of
      existing macros that provided variants on these themes were removed.
      
      Most of the places that need to make such conversions now require just one
      function or macro call, in place of the multiple notational layers that used
      to be needed.  There are no longer any direct calls of textout or textin,
      and we got most of the places that were using handmade conversions via
      memcpy (there may be a few still lurking, though).
      
      This commit doesn't make any serious effort to eliminate transient memory
      leaks caused by detoasting toasted text objects before they reach
      text_to_cstring.  We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few
      places where it was easy, but much more could be done.
      
      Brendan Jurd and Tom Lane
      220db7cc
  26. 20 3月, 2008 1 次提交
  27. 08 2月, 2008 1 次提交
    • T
      Fix CREATE TABLE ... LIKE ... INCLUDING INDEXES to not cause unwanted · b7fe5f70
      Tom Lane 提交于
      tablespace permissions failures when copying an index that is in the
      database's default tablespace.  A side-effect of the change is that explicitly
      specifying the default tablespace no longer triggers a permissions check;
      this is not how it was done in pre-8.3 releases but is argued to be more
      consistent.  Per bug #3921 from Andrew Gilligan.  (Note: I argued in the
      subsequent discussion that maybe LIKE shouldn't copy index tablespaces
      at all, but since no one indicated agreement with that idea, I've refrained
      from doing it.)
      b7fe5f70
  28. 31 1月, 2008 1 次提交
    • T
      Add checks to TRUNCATE, CLUSTER, and REINDEX to prevent performing these · 0688d840
      Tom Lane 提交于
      operations when the current transaction has any open references to the
      target relation or index (implying it has an active query using the relation).
      The need for this was previously recognized in connection with ALTER TABLE,
      but anything that summarily eliminates tuples or moves them around would
      confuse an active scan.
      
      While this patch does not in itself fix bug #3883 (the deadlock would happen
      before the new check fires), it will discourage people from attempting the
      sequence of operations that creates a deadlock risk, so it's at least a
      partial response to that problem.
      
      In passing, add a previously-missing check to REINDEX to prevent trying to
      reindex another backend's temp table.  This isn't a security problem since
      only a superuser would get past the schema permission checks, but if we are
      testing for this in other utility commands then surely REINDEX should too.
      0688d840
  29. 18 1月, 2008 1 次提交
    • T
      Fix ALTER INDEX RENAME so that if the index belongs to a unique or primary key · 0df7717f
      Tom Lane 提交于
      constraint, the constraint is renamed as well.  This avoids inconsistent
      situations that could confuse pg_dump (not to mention humans).  We might at
      some point provide ALTER TABLE RENAME CONSTRAINT as a more general solution,
      but there seems no reason not to allow doing it this way too.  Per bug #3854
      and related discussions.
      0df7717f
  30. 03 1月, 2008 1 次提交
    • T
      Forbid ALTER TABLE and CLUSTER when there are pending AFTER-trigger events · 20e86215
      Tom Lane 提交于
      in the current backend for the target table.  These operations move tuples
      around and would thus invalidate the TIDs stored in the trigger event records.
      (We need not worry about events in other backends, since acquiring exclusive
      lock should be enough to ensure there aren't any.)  It might be sufficient
      to forbid only the table-rewriting variants of ALTER TABLE, but in the absence
      of any compelling use-case, let's just be safe and simple.  Per follow-on
      investigation of bug #3847, though this is not actually the same problem
      reported therein.
      
      Possibly this should be back-patched, but since the case has never been
      reported from the field, I didn't bother.
      20e86215
  31. 02 1月, 2008 1 次提交
  32. 02 12月, 2007 1 次提交
    • T
      Code review for LIKE ... INCLUDING INDEXES patch. Fix failure to propagate · 265f904d
      Tom Lane 提交于
      constraint status of copied indexes (bug #3774), as well as various other
      small bugs such as failure to pstrdup when needed.  Allow INCLUDING INDEXES
      indexes to be merged with identical declared indexes (perhaps not real useful,
      but the code is there and having it not apply to LIKE indexes seems pretty
      unorthogonal).  Avoid useless work in generateClonedIndexStmt().  Undo some
      poorly chosen API changes, and put a couple of routines in modules that seem
      to be better places for them.
      265f904d
  33. 16 11月, 2007 1 次提交
  34. 12 11月, 2007 1 次提交
    • T
      Ensure that typmod decoration on a datatype name is validated in all cases, · 0bd4da23
      Tom Lane 提交于
      even in code paths where we don't pay any subsequent attention to the typmod
      value.  This seems needed in view of the fact that 8.3's generalized typmod
      support will accept a lot of bogus syntax, such as "timestamp(foo)" or
      "record(int, 42)" --- if we allow such things to pass without comment,
      users will get confused.  Per a recent example from Greg Stark.
      
      To implement this in a way that's not very vulnerable to future
      bugs-of-omission, refactor the API of parse_type.c's TypeName lookup routines
      so that typmod validation is folded into the base lookup operation.  Callers
      can still choose not to receive the encoded typmod, but we'll check the
      decoration anyway if it's present.
      0bd4da23
  35. 13 10月, 2007 1 次提交
    • T
      Remove hack in pg_tablespace_aclmask() that disallowed permissions · 6daef2bc
      Tom Lane 提交于
      on pg_global even to superusers, and replace it with checks in various
      other places to complain about invalid uses of pg_global.  This ends
      up being a bit more code but it allows a more specific error message
      to be given, and it un-breaks pg_tablespace_size() on pg_global.
      Per discussion.
      6daef2bc