1. 20 3月, 2016 1 次提交
    • T
      Build backend/parser/scan.l and interfaces/ecpg/preproc/pgc.l standalone. · 72b1e3a2
      Tom Lane 提交于
      Now that we know about the %top{} trick, we can revert to building flex
      lexers as separate .o files.  This is worth doing for a couple of reasons
      besides sheer cleanliness.  We can narrow the scope of the -Wno-error flag
      that's forced on scan.c.  Also, since these grammar and lexer files are
      so large, splitting them into separate build targets should have some
      advantages in build speed, particularly in parallel or ccache'd builds.
      
      We have quite a few other .l files that could be changed likewise, but the
      above arguments don't apply to them, so the benefit of fixing them seems
      pretty minimal.  Leave the rest for some other day.
      72b1e3a2
  2. 19 3月, 2016 18 次提交
    • A
      pgbench: Allow changing weights for scripts · 7bafffea
      Alvaro Herrera 提交于
      Previously, all scripts had the same probability of being chosen when
      multiple of them were specified via -b, -f, -N, -S.  With this commit,
      -b and -f now search for an "@" in the script name and use the integer
      found after it as the drawing probability for that script.
      
      (One disadvantage is that if you have script whose names contain @, you
      are now forced to specify "@1" at the end; otherwise the name's @ is
      confused with a weight separator.  We don't expect many pgbench script
      with @ in their names in the wild, so this shouldn't be too serious a
      problem.)
      
      While at it, rework the interface between addScript, process_file,
      process_builtin, and findBuiltin.  It had gotten a bit out of hand with
      recent commits.
      
      Author: Fabien Coelho
      Reviewed-By: Andres Freund, Robert Haas, Álvaro Herrera, Michaël Paquier
      Discussion: http://www.postgresql.org/message-id/alpine.DEB.2.10.1603160721240.1666@sto
      7bafffea
    • T
      With ancient gcc, skip pg_attribute_printf() on function pointer. · b46d9beb
      Tom Lane 提交于
      Buildfarm results show that the ability to attach pg_attribute_printf
      decoration to a function pointer appeared somewhere between gcc 2.95.3
      and gcc 4.0.1.  Guess that it was there in 4.0.
      b46d9beb
    • P
      Allow SSL server key file to have group read access if owned by root · 9a83564c
      Peter Eisentraut 提交于
      We used to require the server key file to have permissions 0600 or less
      for best security.  But some systems (such as Debian) have certificate
      and key files managed by the operating system that can be shared with
      other services.  In those cases, the "postgres" user is made a member of
      a special group that has access to those files, and the server key file
      has permissions 0640.  To accommodate that kind of setup, also allow the
      key file to have permissions 0640 but only if owned by root.
      
      From: Christoph Berg <myon@debian.org>
      Reviewed-by: NAlvaro Herrera <alvherre@alvh.no-ip.org>
      9a83564c
    • A
      Fix stupid omission in c4901a1e. · 6eb2be15
      Andres Freund 提交于
      Reported-By: Jeff Janes
      Discussion: CAMkU=1zGxREwoyaCrp_CHadEB+dPgpVyKBysCJ+6xP9gCOvAuw@mail.gmail.com
      6eb2be15
    • T
      Fix missed update in _readForeignScan(). · 07aed46a
      Tom Lane 提交于
      Blatant fail in 0bf3ae88.
      Caught by buildfarm member mandrill.
      07aed46a
    • T
      Use yylex_init not yylex_init_extra(). · ff0a7e61
      Tom Lane 提交于
      Older versions of flex don't have the latter.  Per buildfarm.
      ff0a7e61
    • T
      Suppress FLEX_NO_BACKUP check for psqlscanslash.l. · a3e39f83
      Tom Lane 提交于
      The existing infrastructure for FLEX_NO_BACKUP doesn't work reliably
      when two lexers are built in parallel in the same directory.  We can
      probably fix that, but as a short-term workaround, just don't make
      the check for psqlscanslash.l.
      
      Per buildfarm.
      a3e39f83
    • T
      Split psql's lexer into two separate .l files for SQL and backslash cases. · 0ea9efbe
      Tom Lane 提交于
      This gets us to a point where psqlscan.l can be used by other frontend
      programs for the same purpose psql uses it for, ie to detect when it's
      collected a complete SQL command from input that is divided across
      line boundaries.  Moreover, other programs can supply their own lexers
      for backslash commands of their own choosing.  A follow-on patch will
      use this in pgbench.
      
      The end result here is roughly the same as in Kyotaro Horiguchi's
      0001-Make-SQL-parser-part-of-psqlscan-independent-from-ps.patch, although
      the details of the method for switching between lexers are quite different.
      Basically, in this patch we share the entire PsqlScanState, YY_BUFFER_STATE
      stack, *and* yyscan_t between different lexers.  The only thing we need
      to do to switch to a different lexer is to make sure the start_state is
      valid for the new lexer.  This works because flex doesn't keep any other
      persistent state that depends on the specific lexing tables generated for
      a particular .l file.  (We are assuming that both lexers are built with
      the same flex version, or at least versions that are compatible with
      respect to the contents of yyscan_t; but that doesn't seem likely to
      be a big problem in practice, considering how slowly flex changes.)
      
      Aside from being more efficient than Horiguchi-san's original solution,
      this avoids possible corner-case changes in semantics: the original code
      was capable of popping the input buffer stack while still staying in
      backslash-related parsing states.  I'm not sure that that equates to any
      useful user-visible behaviors, but I'm not sure it doesn't either, so
      I'm loath to assume that we only need to consider the topmost buffer when
      parsing a backslash command.
      
      I've attempted to update the MSVC build scripts for the added .l file,
      but will rely on the buildfarm to see if I missed anything.
      
      Kyotaro Horiguchi and Tom Lane
      0ea9efbe
    • T
      Convert psql's flex lexer to be re-entrant, and make it compile standalone. · 27199058
      Tom Lane 提交于
      Change psqlscan.l to specify '%option reentrant', adjust internal APIs
      to match, and get rid of its internal static variables.  While this is
      good cleanup in an abstract sense, the reason to do it right now is that
      it seems the only practical way to support use of separate flex lexers
      with common PsqlScanState infrastructure.  If we build two non-reentrant
      lexers then we are going to have problems with dangling buffer pointers
      in whichever lexer isn't active when we transition from one buffer to
      another, as well as curious side-effects if we try to share any code
      between the files.  (Horiguchi-san had a different solution to that in his
      pending patch, but I find it ugly and probably broken for corner cases.)
      
      Depending on which version of flex you're using, this may result in getting
      a "warning: unused variable 'yyg'" warning from psqlscan, similar to the
      one you'd have seen for a long time in backend/parser/scan.l.  I put a
      local -Wno-error into CFLAGS for the file, for the convenience of those
      who compile with -Werror.
      
      Also, stop compiling psqlscan as part of mainloop.c, and make it a
      standalone build target instead.  This is a lot cleaner than before, though
      it doesn't really change much in practice as of this commit.  (I'm not sure
      whether the MSVC build scripts will need some help with this part, but the
      buildfarm will soon tell us.)
      27199058
    • P
      Merge wal_level "archive" and "hot_standby" into new name "replica" · b555ed81
      Peter Eisentraut 提交于
      The distinction between "archive" and "hot_standby" existed only because
      at the time "hot_standby" was added, there was some uncertainty about
      stability.  This is now a long time ago.  We would like to move forward
      with simplifying the replication configuration, but this distinction is
      in the way, because a primary server cannot tell (without asking a
      standby or predicting the future) which one of these would be the
      appropriate level.
      
      Pick a new name for the combined setting to make it clearer that it
      covers all (non-logical) backup and replication uses.  The old values
      are still accepted but are converted internally.
      Reviewed-by: NMichael Paquier <michael.paquier@gmail.com>
      Reviewed-by: NDavid Steele <david@pgmasters.net>
      b555ed81
    • T
      Decouple psqlscan.l from surrounding program. · 4e1d2a17
      Tom Lane 提交于
      Remove assorted external references from psqlscan.l in preparation for
      making it usable by other frontend programs.  This mostly involves
      getting rid of direct calls to psql_error() and GetVariable() in favor
      of introducing a callback-functions struct to encapsulate variable
      fetching and error printing.  In addition, pass the current encoding
      and standard-strings status as additional parameters to psql_scan_setup
      instead of looking directly at "pset" or calling additional functions.
      
      I did not bother to change some references to psql_error that are in
      functions that will soon migrate to a psql-specific backslash-command
      lexer.  Other than that, this version of psqlscan.l is capable of
      compiling standalone.  It still depends on assorted src/common functions
      as well as some encoding-related libpq functions, but we expect that
      all programs using it will be happy with those dependencies.
      
      Kyotaro Horiguchi, somewhat editorialized on by me
      4e1d2a17
    • R
      Use INT64_FORMAT instead of %ld for int64. · 08a6d36d
      Robert Haas 提交于
      Commit 0011c009 introduced this
      mistake.
      
      Patch by me.  Reported by Andres Freund, who also reviewed the
      patch.
      08a6d36d
    • A
      Only clear latch self-pipe/event if there is a pending notification. · c4901a1e
      Andres Freund 提交于
      This avoids a good number of, individually quite fast, system calls in
      scenarios with many quick queries. Besides the aesthetic benefit of
      seing fewer superflous system calls with strace, it also improves
      performance by ~2% measured by pgbench -M prepared -c 96 -j 8 -S (scale
      100).
      
      Without having benchmarked it, this patch also adjust the windows code,
      as that makes it easier to unify the unix/windows codepaths in a later
      patch. There's little reason to diverge in behaviour between the
      platforms.
      
      Discussion: CA+TgmoYc1Zm+Szoc_Qbzi92z2c1vRHZmjhfPn5uC=w8bXv6Avg@mail.gmail.com
      Reviewed-By: Robert Haas
      c4901a1e
    • A
      Make it easier to choose the used waiting primitive in unix_latch.c. · c1796620
      Andres Freund 提交于
      This allows for easier testing of the different primitives; in
      preparation for adding a new primitive.
      
      Discussion: 20160114143931.GG10941@awork2.anarazel.de
      Reviewed-By: Robert Haas
      c1796620
    • A
      Error out if waiting on socket readiness without a specified socket. · 6bc4d95f
      Andres Freund 提交于
      Previously we just ignored such an attempt, but that seems to serve no
      purpose but making things harder to debug.
      
      Discussion: 20160114143931.GG10941@awork2.anarazel.de
          20151230173734.hx7jj2fnwyljfqek@alap3.anarazel.de
      Reviewed-By: Robert Haas
      6bc4d95f
    • A
      Remove unused, and dangerous, TestLatch() macro. · fad0f9d8
      Andres Freund 提交于
      The macro has not seen any in-tree use since latches had been introduced
      in 2746e5f2, in 2010.
      fad0f9d8
    • R
      Directly modify foreign tables. · 0bf3ae88
      Robert Haas 提交于
      postgres_fdw can now sent an UPDATE or DELETE statement directly to
      the foreign server in simple cases, rather than sending a SELECT FOR
      UPDATE statement and then updating or deleting rows one-by-one.
      
      Etsuro Fujita, reviewed by Rushabh Lathia, Shigeru Hanada, Kyotaro
      Horiguchi, Albe Laurenz, Thom Brown, and me.
      0bf3ae88
    • T
      Clean up some misplaced #includes. · 3422fecc
      Tom Lane 提交于
      Random .h files have no business including postgres-fe.h (or postgres.h).
      If that wasn't the first #include done by the calling .c file, it's the
      .c file that's broken.  Noted while prepping Kyotaro Horiguchi's psql
      lexer refactoring patch.
      3422fecc
  3. 18 3月, 2016 10 次提交
    • T
      Fix a typo · 61d2ebdb
      Teodor Sigaev 提交于
      Erik Rijkers
      61d2ebdb
    • T
      Introduce parse_ident() · 3187d6de
      Teodor Sigaev 提交于
      SQL-layer function to split qualified identifier into array parts.
      
      Author: Pavel Stehule with minor editorization by me and Jim Nasby
      3187d6de
    • R
      Push scan/join target list beneath Gather when possible. · 992b5ba3
      Robert Haas 提交于
      This means that, for example, "SELECT expensive_func(a) FROM bigtab
      WHERE something" can compute expensive_func(a) in the workers rather
      than the leader if it happens to be parallel-safe, which figures to be
      a big win in some practical cases.
      
      Currently, we can only do this if the entire target list is
      parallel-safe.  If we worked harder, we might be able to evaluate
      parallel-safe targets in the worker and any parallel-restricted
      targets in the leader, but that would be more complicated, and there
      aren't that many parallel-restricted functions that people are likely
      to use in queries anyway.  I think.  So just do the simple thing for
      the moment.
      
      Robert Haas, Amit Kapila, and Tom Lane
      992b5ba3
    • R
      Various minor corrections of and improvements to comments. · 2d8a1e22
      Robert Haas 提交于
      Aleksander Alekseev
      2d8a1e22
    • T
      pg_trgm's set_limit() now uses SetConfigOption() · aa698d75
      Teodor Sigaev 提交于
      Deprecated set_limit() is modified to use SetConfigOption() to set
      similarity_threshold which is actually an instance of
      pg_trgm.similarity_threshold GUC variable. Previous coding directly sets
      similarity_threshold what could cause an inconsistency between states of
      actual variable and GUC representation.
      
      Per gripe from Tom Lane
      aa698d75
    • A
      docs: Fix typo'd brin_summarize_new_values · 696684d8
      Alvaro Herrera 提交于
      I wrote "brin_summarize_new_pages" instead, in docs as well as in the
      commit message of commit ac443d10.
      
      Bug: #14030
      Reported-By: Chris Pacejo
      696684d8
    • T
      Remove useless double calls of make_parsestate(). · bd0ab289
      Tom Lane 提交于
      Aleksander Alekseev
      bd0ab289
    • R
      Update tuplesort.c comments for memory mangement improvements. · c27033ff
      Robert Haas 提交于
      I'm committing these changes separately so that it's clear what is
      Peter's original work versus what I changed.  This is a followup to
      commit 0011c009, and these changes
      are all by me.
      c27033ff
    • R
      Improve memory management for external sorts. · 0011c009
      Robert Haas 提交于
      Introduce a new memory context which stores tuple data, and reset it
      at the end of each merge pass; this helps avoid memory fragmentation
      and, consequently, overallocation.  Also, for the final merge patch,
      eliminate memory context chunk header overhead entirely by allocating
      all of the memory used for buffering tuples during the merge in a
      single chunk.  Since this modestly increases the number of tuples we
      can store, grow the memtuples array a bit so that we're less likely to
      run short of slots there.
      
      Peter Geoghegan.  Review and testing of patches in this series by
      Jeff Janes, Greg Stark, Mithun Cy, and me.
      0011c009
    • T
      Fix assorted breakage in to_char()'s OF format option. · 55c3a04d
      Tom Lane 提交于
      In HEAD, fix incorrect field width for hours part of OF when tm_gmtoff is
      negative.  This was introduced by commit 2d87eedc as a result of
      falsely applying a pattern that's correct when + signs are omitted, which
      is not the case for OF.
      
      In 9.4, fix missing abs() call that allowed a sign to be attached to the
      minutes part of OF.  This was fixed in 9.5 by 9b43d73b, but for
      inscrutable reasons not back-patched.
      
      In all three versions, ensure that the sign of tm_gmtoff is correctly
      reported even when the GMT offset is less than 1 hour.
      
      Add regression tests, which evidently we desperately need here.
      
      Thomas Munro and Tom Lane, per report from David Fetter
      55c3a04d
  4. 17 3月, 2016 10 次提交
    • T
      Improve support of Hunspell · f4ceed6c
      Teodor Sigaev 提交于
      - allow to use non-ascii characters as affix flag. Non-numeric affix flags now
        are stored as string instead of numeric value of character.
      - allow to use 0 as affix flag in numeric encoded affixes
      
      That adds support for arabian, hungarian, turkish and
      brazilian portuguese languages.
      
      Author: Artur Zakirov with heavy editorization by me
      f4ceed6c
    • R
      Fix typos. · 0218e8b3
      Robert Haas 提交于
      Jim Nasby
      0218e8b3
    • P
      Add syslog_split_messages parameter · fc201dfd
      Peter Eisentraut 提交于
      Reviewed-by: NAndreas Karlsson <andreas@proxel.se>
      fc201dfd
    • P
      Add syslog_sequence_numbers parameter · f4c454e9
      Peter Eisentraut 提交于
      Reviewed-by: NAndreas Karlsson <andreas@proxel.se>
      f4c454e9
    • T
      Fix "pg_bench -C -M prepared". · 47211af1
      Tom Lane 提交于
      This didn't work because when we dropped and re-established a database
      connection, we did not bother to reset session-specific state such as
      the statements-are-prepared flags.
      
      The st->prepared[] array certainly needs to be flushed, and I cleared a
      couple of other fields as well that couldn't possibly retain meaningful
      state for a new connection.
      
      In passing, fix some bogus comments and strange field order choices.
      
      Per report from Robins Tharakan.
      47211af1
    • T
      Fix j2day() to behave sanely for negative Julian dates. · 5db51464
      Tom Lane 提交于
      Somebody had apparently once figured that casting to unsigned int would
      produce the right output for negative inputs, but that would only be
      true if 2^32 were a multiple of 7, which of course it ain't.  We need
      to use a signed division and then correct the sign of the remainder.
      
      AFAICT, the only case where this would arise currently is when doing
      ISO-week calculations for dates in 4714BC, where we'd compute a
      negative Julian date representing 4714-01-04BC and then do some
      arithmetic with it.  Since we don't even really document support for
      such dates, this is not of much consequence.  But we may as well
      get it right.
      
      Per report from Vitaly Burovoy.
      5db51464
    • T
      Be more careful about out-of-range dates and timestamps. · a70e13a3
      Tom Lane 提交于
      Tighten the semantics of boundary-case timestamptz so that we allow
      timestamps >= '4714-11-24 00:00+00 BC' and < 'ENDYEAR-01-01 00:00+00 AD'
      exactly, no more and no less, but it is allowed to enter timestamps
      within that range using non-GMT timezone offsets (which could make the
      nominal date 4714-11-23 BC or ENDYEAR-01-01 AD).  This eliminates
      dump/reload failure conditions for timestamps near the endpoints.
      To do this, separate checking of the inputs for date2j() from the
      final range check, and allow the Julian date code to handle a range
      slightly wider than the nominal range of the datatypes.
      
      Also add a bunch of checks to detect out-of-range dates and timestamps
      that formerly could be returned by operations such as date-plus-integer.
      All C-level functions that return date, timestamp, or timestamptz should
      now be proof against returning a value that doesn't pass IS_VALID_DATE()
      or IS_VALID_TIMESTAMP().
      
      Vitaly Burovoy, reviewed by Anastasia Lubennikova, and substantially
      whacked around by me
      a70e13a3
    • R
      Another comment update. · f2b74b01
      Robert Haas 提交于
      I thought this was in my last commit, but I goofed.
      f2b74b01
    • R
      Fix problems in commit c16dc1ac. · bc55cc0b
      Robert Haas 提交于
      Vinayak Pokale provided a patch for a copy-and-paste error in a
      comment.  I noticed that I'd use the word "automatically" nearby where
      I meant to talk about things being "atomic".  Rahila Syed spotted a
      misplaced counter update.  Fix all that stuff.
      bc55cc0b
    • T
      Add files forgotten in f576b17c · e4b523e5
      Teodor Sigaev 提交于
      e4b523e5
  5. 16 3月, 2016 1 次提交
    • T
      Add word_similarity to pg_trgm contrib module. · f576b17c
      Teodor Sigaev 提交于
      Patch introduces a concept of similarity over string and just a word from
      another string.
      
      Version of extension is not changed because 1.2 was already introduced in 9.6
      release cycle, so, there wasn't a public version.
      
      Author: Alexander Korotkov, Artur Zakirov
      f576b17c