1. 15 3月, 2013 1 次提交
    • H
      Also update psqlscan.l with the UESCAPE error rule changes. · f7559c01
      Heikki Linnakangas 提交于
      Even though this patch had no user-visible difference, better keep the code
      in psqlscan.l sync with the backend lexer. And of course it's nice to shrink
      the psql binary, too. Ecpg's version of the lexer doesn't have the error
      rule, it doesn't try to avoid backing up, so it doesn't need to be modified.
      
      As reminded by Tom Lane
      f7559c01
  2. 14 3月, 2013 1 次提交
  3. 11 3月, 2013 2 次提交
  4. 07 3月, 2013 2 次提交
  5. 06 3月, 2013 2 次提交
  6. 04 3月, 2013 2 次提交
    • P
      psql: Let \l accept a pattern · 0ea1f6e9
      Peter Eisentraut 提交于
      reviewed by Satoshi Nagayasu
      0ea1f6e9
    • K
      Add a materialized view relations. · 3bf3ab8c
      Kevin Grittner 提交于
      A materialized view has a rule just like a view and a heap and
      other physical properties like a table.  The rule is only used to
      populate the table, references in queries refer to the
      materialized data.
      
      This is a minimal implementation, but should still be useful in
      many cases.  Currently data is only populated "on demand" by the
      CREATE MATERIALIZED VIEW and REFRESH MATERIALIZED VIEW statements.
      It is expected that future releases will add incremental updates
      with various timings, and that a more refined concept of defining
      what is "fresh" data will be developed.  At some point it may even
      be possible to have queries use a materialized in place of
      references to underlying tables, but that requires the other
      above-mentioned features to be working first.
      
      Much of the documentation work by Robert Haas.
      Review by Noah Misch, Thom Brown, Robert Haas, Marko Tiikkaja
      Security review by KaiGai Kohei, with a decision on how best to
      implement sepgsql still pending.
      3bf3ab8c
  7. 28 2月, 2013 1 次提交
    • H
      Add support for piping COPY to/from an external program. · 3d009e45
      Heikki Linnakangas 提交于
      This includes backend "COPY TO/FROM PROGRAM '...'" syntax, and corresponding
      psql \copy syntax. Like with reading/writing files, the backend version is
      superuser-only, and in the psql version, the program is run in the client.
      
      In the passing, the psql \copy STDIN/STDOUT syntax is subtly changed: if you
      the stdin/stdout is quoted, it's now interpreted as a filename. For example,
      "\copy foo from 'stdin'" now reads from a file called 'stdin', not from
      standard input. Before this, there was no way to specify a filename called
      stdin, stdout, pstdin or pstdout.
      
      This creates a new function in pgport, wait_result_to_str(), which can
      be used to convert the exit status of a process, as returned by wait(3),
      to a human-readable string.
      
      Etsuro Fujita, reviewed by Amit Kapila.
      3d009e45
  8. 26 2月, 2013 3 次提交
    • H
      Only quote libpq connection string values that need quoting. · 2953cd6d
      Heikki Linnakangas 提交于
      There's no harm in excessive quoting per se, but it makes the strings nicer
      to read. The values can get quite unwieldy, when they're first quoted within
      within single-quotes when included in the connection string, and then all
      the single-quotes are escaped when the connection string is passed as a
      shell argument.
      2953cd6d
    • H
      Add -d option to pg_dumpall, for specifying a connection string. · 3dee636e
      Heikki Linnakangas 提交于
      Like with pg_basebackup and pg_receivexlog, it's a bit strange to call the
      option -d/--dbname, when in fact you cannot pass a database name in it.
      
      Original patch by Amit Kapila, heavily modified by me.
      3dee636e
    • H
      Add -d/--dbname option to pg_dump. · 691e595d
      Heikki Linnakangas 提交于
      You could already pass a database name just by passing it as the last
      option, without -d. This is an alias for that, like the -d/--dbname option
      in psql and many other client applications. For consistency.
      691e595d
  9. 25 2月, 2013 1 次提交
    • H
      Add -d option to pg_basebackup and pg_receivexlog, for connection string. · aa05c37e
      Heikki Linnakangas 提交于
      Without this, there's no way to pass arbitrary libpq connection parameters
      to these applications. It's a bit strange that the option is called
      -d/--dbname, when in fact you can *not* pass a database name in it, but it's
      consistent with other client applications where a connection string is also
      passed using -d.
      
      Original patch by Amit Kapila, heavily modified by me.
      aa05c37e
  10. 20 2月, 2013 2 次提交
  11. 19 2月, 2013 1 次提交
    • A
      Split pgstat file in smaller pieces · 187492b6
      Alvaro Herrera 提交于
      We now write one file per database and one global file, instead of
      having the whole thing in a single huge file.  This reduces the I/O that
      must be done when partial data is required -- which is all the time,
      because each process only needs information on its own database anyway.
      Also, the autovacuum launcher does not need data about tables and
      functions in each database; having the global stats for all DBs is
      enough.
      
      Catalog version bumped because we have a new subdir under PGDATA.
      
      Author: Tomas Vondra.  Some rework by Álvaro
      Testing by Jeff Janes
      Other discussion by Heikki Linnakangas, Tom Lane.
      187492b6
  12. 17 2月, 2013 1 次提交
  13. 12 2月, 2013 3 次提交
    • A
      Create libpgcommon, and move pg_malloc et al to it · 8396447c
      Alvaro Herrera 提交于
      libpgcommon is a new static library to allow sharing code among the
      various frontend programs and backend; this lets us eliminate duplicate
      implementations of common routines.  We avoid libpgport, because that's
      intended as a place for porting issues; per discussion, it seems better
      to keep them separate.
      
      The first use case, and the only implemented by this patch, is pg_malloc
      and friends, which many frontend programs were already using.
      
      At the same time, we can use this to provide palloc emulation functions
      for the frontend; this way, some palloc-using files in the backend can
      also be used by the frontend cleanly.  To do this, we change palloc() in
      the backend to be a function instead of a macro on top of
      MemoryContextAlloc().  This was previously believed to cause loss of
      performance, but this implementation has been tweaked by Tom and Andres
      so that on modern compilers it provides a slight improvement over the
      previous one.
      
      This lets us clean up some places that were already with
      localized hacks.
      
      Most of the pg_malloc/palloc changes in this patch were authored by
      Andres Freund. Zoltán Böszörményi also independently provided a form of
      that.  libpgcommon infrastructure was authored by Álvaro.
      8396447c
    • H
      Support unlogged GiST index. · 62401db4
      Heikki Linnakangas 提交于
      The reason this wasn't supported before was that GiST indexes need an
      increasing sequence to detect concurrent page-splits. In a regular WAL-
      logged GiST index, the LSN of the page-split record is used for that
      purpose, and in a temporary index, we can get away with a backend-local
      counter. Neither of those methods works for an unlogged relation.
      
      To provide such an increasing sequence of numbers, create a "fake LSN"
      counter that is saved and restored across shutdowns. On recovery, unlogged
      relations are blown away, so the counter doesn't need to survive that
      either.
      
      Jeevan Chalke, based on discussions with Robert Haas, Tom Lane and me.
      62401db4
    • H
      Include previous TLI in end-of-recovery and shutdown checkpoint records. · 7803e932
      Heikki Linnakangas 提交于
      This isn't used for anything but a sanity check at the moment, but it could
      be highly valuable for debugging purposes. It could also be used to recreate
      timeline history by traversing WAL, which seems useful.
      7803e932
  14. 09 2月, 2013 3 次提交
  15. 08 2月, 2013 1 次提交
  16. 07 2月, 2013 1 次提交
  17. 03 2月, 2013 2 次提交
    • T
      Create a psql command \gset to store query results into psql variables. · d2d153fd
      Tom Lane 提交于
      This eases manipulation of query results in psql scripts.
      
      Pavel Stehule, reviewed by Piyush Newe, Shigeru Hanada, and Tom Lane
      d2d153fd
    • T
      Prevent "\g filename" from affecting subsequent commands after an error. · 101d6ae7
      Tom Lane 提交于
      In the previous coding, psql's state variable saying that output should
      go to a file was only reset after successful completion of a query
      returning tuples.  Thus for example,
      
      regression=# select 1/0
      regression-# \g somefile
      ERROR:  division by zero
      regression=# select 1/2;
      regression=#
      
      ... huh, I wonder where that output went.  Even more oddly, the state
      was not reset even if it's the file that's causing the failure:
      
      regression=# select 1/2 \g /foo
      /foo: Permission denied
      regression=# select 1/2;
      /foo: Permission denied
      regression=# select 1/2;
      /foo: Permission denied
      
      This seems to me not to satisfy the principle of least surprise.
      \g is certainly not documented in a way that suggests its effects are
      at all persistent.
      
      To fix, adjust the code so that the flag is reset at exit from SendQuery
      no matter what happened.
      
      Noted while reviewing the \gset patch, which had comparable issues.
      Arguably this is a bug fix, but I'll refrain from back-patching for now.
      101d6ae7
  18. 29 1月, 2013 1 次提交
    • S
      Fast promote mode skips checkpoint at end of recovery. · fd4ced52
      Simon Riggs 提交于
      pg_ctl promote -m fast will skip the checkpoint at end of recovery so that we
      can achieve very fast failover when the apply delay is low. Write new WAL record
      XLOG_END_OF_RECOVERY to allow us to switch timeline correctly for downstream log
      readers. If we skip synchronous end of recovery checkpoint we request a normal
      spread checkpoint so that the window of re-recovery is low.
      
      Simon Riggs and Kyotaro Horiguchi, with input from Fujii Masao.
      Review by Heikki Linnakangas
      fd4ced52
  19. 26 1月, 2013 1 次提交
  20. 25 1月, 2013 3 次提交
  21. 24 1月, 2013 2 次提交
  22. 23 1月, 2013 1 次提交
    • A
      Improve concurrency of foreign key locking · 0ac5ad51
      Alvaro Herrera 提交于
      This patch introduces two additional lock modes for tuples: "SELECT FOR
      KEY SHARE" and "SELECT FOR NO KEY UPDATE".  These don't block each
      other, in contrast with already existing "SELECT FOR SHARE" and "SELECT
      FOR UPDATE".  UPDATE commands that do not modify the values stored in
      the columns that are part of the key of the tuple now grab a SELECT FOR
      NO KEY UPDATE lock on the tuple, allowing them to proceed concurrently
      with tuple locks of the FOR KEY SHARE variety.
      
      Foreign key triggers now use FOR KEY SHARE instead of FOR SHARE; this
      means the concurrency improvement applies to them, which is the whole
      point of this patch.
      
      The added tuple lock semantics require some rejiggering of the multixact
      module, so that the locking level that each transaction is holding can
      be stored alongside its Xid.  Also, multixacts now need to persist
      across server restarts and crashes, because they can now represent not
      only tuple locks, but also tuple updates.  This means we need more
      careful tracking of lifetime of pg_multixact SLRU files; since they now
      persist longer, we require more infrastructure to figure out when they
      can be removed.  pg_upgrade also needs to be careful to copy
      pg_multixact files over from the old server to the new, or at least part
      of multixact.c state, depending on the versions of the old and new
      servers.
      
      Tuple time qualification rules (HeapTupleSatisfies routines) need to be
      careful not to consider tuples with the "is multi" infomask bit set as
      being only locked; they might need to look up MultiXact values (i.e.
      possibly do pg_multixact I/O) to find out the Xid that updated a tuple,
      whereas they previously were assured to only use information readily
      available from the tuple header.  This is considered acceptable, because
      the extra I/O would involve cases that would previously cause some
      commands to block waiting for concurrent transactions to finish.
      
      Another important change is the fact that locking tuples that have
      previously been updated causes the future versions to be marked as
      locked, too; this is essential for correctness of foreign key checks.
      This causes additional WAL-logging, also (there was previously a single
      WAL record for a locked tuple; now there are as many as updated copies
      of the tuple there exist.)
      
      With all this in place, contention related to tuples being checked by
      foreign key rules should be much reduced.
      
      As a bonus, the old behavior that a subtransaction grabbing a stronger
      tuple lock than the parent (sub)transaction held on a given tuple and
      later aborting caused the weaker lock to be lost, has been fixed.
      
      Many new spec files were added for isolation tester framework, to ensure
      overall behavior is sane.  There's probably room for several more tests.
      
      There were several reviewers of this patch; in particular, Noah Misch
      and Andres Freund spent considerable time in it.  Original idea for the
      patch came from Simon Riggs, after a problem report by Joel Jacobson.
      Most code is from me, with contributions from Marti Raudsepp, Alexander
      Shulgin, Noah Misch and Andres Freund.
      
      This patch was discussed in several pgsql-hackers threads; the most
      important start at the following message-ids:
      	AANLkTimo9XVcEzfiBR-ut3KVNDkjm2Vxh+t8kAmWjPuv@mail.gmail.com
      	1290721684-sup-3951@alvh.no-ip.org
      	1294953201-sup-2099@alvh.no-ip.org
      	1320343602-sup-2290@alvh.no-ip.org
      	1339690386-sup-8927@alvh.no-ip.org
      	4FE5FF020200002500048A3D@gw.wicourts.gov
      	4FEAB90A0200002500048B7D@gw.wicourts.gov
      0ac5ad51
  23. 20 1月, 2013 1 次提交
    • T
      Use SET TRANSACTION READ ONLY in pg_dump, if server supports it. · 26d905a1
      Tom Lane 提交于
      This currently does little except serve as documentation.  (The one case
      where it has a performance benefit, SERIALIZABLE mode in 9.1 and up, was
      already using READ ONLY mode.)  However, it's possible that it might have
      performance benefits in future, and in any case it seems like good
      practice since it would catch any accidentally non-read-only operations.
      
      Pavan Deolasee
      26d905a1
  24. 19 1月, 2013 1 次提交
  25. 18 1月, 2013 1 次提交
    • B
      psql latex fixes · 74a82baf
      Bruce Momjian 提交于
      Remove extra line at bottom of table for new 'latex' mode border=3.
      Also update 'latex'-longtable 'tableattr' docs to say
      'whitespace-separated' instead of 'space'.
      74a82baf