Correctifs appliqués

Álvaro Herrera pushed:

Tom Lane pushed:

  • Adjust pgbench to allow non-ASCII characters in variable names. This puts it in sync with psql's notion of what is a valid variable name. Like psql, we document that "non-Latin letters" are allowed, but actually any non-ASCII character is accepted. Fabien Coelho Discussion:
  • Fix some subtle problems in pgbench transaction stats counting. With --latency-limit, transactions might get skipped even beyond the transaction count limit specified by -t, throwing off the expected number of transactions and thus the denominator for later stats. Be sure to stop skipping transactions once -t is reached. Also, include skipped transactions in the "cnt" fields; this requires discounting them again in a couple of places, but most places are better off with this definition. In particular this is needed to get correct overall stats for the combination of -R/-L/-t options. Merge some more processing into processXactStats() to simplify this. In passing, add a check that --progress-timestamp is specified only when --progress is. We might consider back-patching this, but given that it only matters for a combination of options, and given the lack of field complaints, consensus seems to be not to bother. Fabien Coelho, reviewed by Nikolay Shaplov Discussion:
  • Be more careful about newline-chomping in pgbench. process_backslash_command would drop the last character of the input command on the assumption that it was a newline. Given a non newline terminated input file, this could result in dropping the last character of the command. Fix that by doing an actual test that we're removing a newline. While at it, allow for Windows newlines (\r\n), and suppress multiple newlines if any. I do not think either of those cases really occur, since (a) we read script files in text mode and (b) the lexer stops when it hits a newline. But it's cheap enough and it provides a stronger guarantee about what the result string looks like. This is just cosmetic, I think, since the possibly-overly-chomped line was only used for display not for further processing. So it doesn't seem necessary to back-patch. Fabien Coelho, reviewed by Nikolay Shaplov, whacked around a bit by me Discussion:
  • Reformat psql's --help=variables output. The previous format with variable names and descriptions in separate columns was extremely constraining about the length of the descriptions. We'd dealt with that in several inconsistent ways over the years, including letting the lines run over 80 characters, breaking descriptions into multiple lines, or shoving the description onto a separate line. But it's been a long time since the output could realistically fit onto a single screen vertically, so let's just rely even more heavily on the pager to deal with the vertical distance, and split each entry into two (or more) lines, in the format variable-name variable description goes here Each variable name + description remains a single translatable string, in hopes of reducing translator confusion; we're just changing the embedded whitespace. I failed to resist the temptation to copy-edit one or two of the descriptions while at it. Discussion:
  • Add psql variables showing server version and psql version. We already had a psql variable VERSION that shows the verbose form of psql's own version. Add VERSION_NAME to show the short form (e.g., "11devel") and VERSION_NUM to show the numeric form (e.g., 110000). Also add SERVER_VERSION_NAME and SERVER_VERSION_NUM to show the short and numeric forms of the server's version. (We'd probably add SERVER_VERSION with the verbose string if it were readily available; but adding another network round trip to get it seems too expensive.) The numeric forms, in particular, are expected to be useful for scripting purposes, now that psql can do conditional tests. Fabien Coelho, reviewed by Pavel Stehule Discussion:
  • In psql, use PSQL_PAGER in preference to PAGER, if it's set. This allows the user's environment to set up a psql-specific choice of pager, in much the same way that we provide PSQL_EDITOR to allow a psql-specific override of the more widely known EDITOR variable. Pavel Stehule, reviewed by Thomas Munro Discussion:
  • Use lfirst_node() and linitial_node() where appropriate in planner.c. There's no particular reason to target this module for the first wholesale application of these macros; but we gotta start somewhere. Ashutosh Bapat and Jeevan Chalke Discussion:
  • Add \gdesc psql command. This command acts somewhat like \g, but instead of executing the query buffer, it merely prints a description of the columns that the query result would have. (Of course, this still requires parsing the query; if parse analysis fails, you get an error anyway.) We accomplish this using an unnamed prepared statement, which should be invisible to psql users. Pavel Stehule, reviewed by Fabien Coelho Discussion:
  • Clean up handling of dropped columns in NAMEDTUPLESTORE RTEs. The NAMEDTUPLESTORE patch piggybacked on the infrastructure for TABLEFUNC/VALUES/CTE RTEs, none of which can ever have dropped columns, so the possibility was ignored most places. Fix that, including adding a specification to parsenodes.h about what it's supposed to look like. In passing, clean up assorted comments that hadn't been maintained properly by said patch. Per bug #14799 from Philippe Beaudoin. Back-patch to v10. Discussion:
  • Use more of gcc's __sync_fetch_and_xxx builtin functions for atomic ops. In addition to __sync_fetch_and_add, gcc offers __sync_fetch_and_sub, __sync_fetch_and_and, and __sync_fetch_and_or, which correspond directly to primitive atomic ops that we want. Testing shows that in some cases they generate better code than our generic implementations, so use them. We've assumed that configure's test for __sync_val_compare_and_swap is sufficient to allow assuming that __sync_fetch_and_add is available, so make the same assumption for these functions. Should that prove to be wrong, we can add more configure tests. Yura Sokolov, reviewed by Jesper Pedersen and myself Discussion:
  • Remove duplicate reads from the inner loops in generic atomic ops. The pg_atomic_compare_exchange_xxx functions are defined to update *expected to whatever they read from the target variable. Therefore, there's no need to do additional explicit reads after we've initialized the "old" variable. The actual benefit of this is somewhat debatable, but it seems fairly unlikely to hurt anything, especially since we will override the generic implementations in most performance-sensitive cases. Yura Sokolov, reviewed by Jesper Pedersen and myself Discussion:
  • Merge duplicative code for \sf/\sv, \ef/\ev in psql/command.c. Saves ~150 lines, costs little. Fabien Coelho, reviewed by Victor Drobny Discussion:
  • Sync function prototype with its actual definition. Use the same parameter names as in the definition. Cosmetic fix only. Tatsuro Yamada Discussion:
  • Further marginal hacking on generic atomic ops. In the generic atomic ops that rely on a loop around a CAS primitive, there's no need to force the initial read of the "old" value to be atomic. In the typically-rare case that we get a torn value, that simply means that the first CAS attempt will fail; but it will update "old" to the atomically-read value, so the next attempt has a chance of succeeding. It was already being done that way in pg_atomic_exchange_u64_impl(), but let's duplicate the approach in the rest. (Given the current coding of the pg_atomic_read functions, this change is a no-op anyway on popular platforms; it only makes a difference where pg_atomic_read_u64_impl() is implemented as a CAS.) In passing, also remove unnecessary take-a-pointer-and-dereference-it coding in the pg_atomic_read functions. That seems to have been based on a misunderstanding of what the C standard requires. What actually matters is that the pointer be declared as pointing to volatile, which it is. I don't believe this will change the assembly code at all on x86 platforms (even ignoring the likelihood that these implementations get overridden by others); but it may help on less-mainstream CPUs. Discussion:
  • Fix handling of savepoint commands within multi-statement Query strings. Issuing a savepoint-related command in a Query message that contains multiple SQL statements led to a FATAL exit with a complaint about "unexpected state STARTED". This is a shortcoming of commit 4f896dac1, which attempted to prevent such misbehaviors in multi-statement strings; its quick hack of marking the individual statements as "not top-level" does the wrong thing in this case, and isn't a very accurate description of the situation anyway. To fix, let's introduce into xact.c an explicit model of what happens for multi-statement Query strings. This is an "implicit transaction block in progress" state, which for many purposes works like the normal TBLOCK_INPROGRESS state --- in particular, IsTransactionBlock returns true, causing the desired result that PreventTransactionChain will throw error. But in case of error abort it works like TBLOCK_STARTED, allowing the transaction to be cancelled without need for an explicit ROLLBACK command. Commit 4f896dac1 is reverted in toto, so that we go back to treating the individual statements as "top level". We could have left it as-is, but this allows sharpening the error message for PreventTransactionChain calls inside functions. Except for getting a normal error instead of a FATAL exit for savepoint commands, this patch should result in no user-visible behavioral change (other than that one error message rewording). There are some things we might want to do in the line of changing the appearance or wording of error and warning messages around this behavior, which would be much simpler to do now that it's an explicitly modeled state. But I haven't done them here. Although this fixes a long-standing bug, no backpatch. The consequences of the bug don't seem severe enough to justify the risk that this commit itself creates some new issue. Patch by me, but it owes something to previous investigation by Takayuki Tsunakawa, who also reported the bug in the first place. Also thanks to Michael Paquier for reviewing. Discussion:
  • Improve documentation about behavior of multi-statement Query messages. We've long done our best to sweep this topic under the rug, but in view of recent work it seems like it's time to explain it more precisely. Here's an initial cut at doing that. Discussion:
  • Improve performance of get_actual_variable_range with recently-dead tuples. In commit fccebe421, we hacked get_actual_variable_range() to scan the index with SnapshotDirty, so that if there are many uncommitted tuples at the end of the index range, it wouldn't laboriously scan through all of them looking for a live value to return. However, that didn't fix it for the case of many recently-dead tuples at the end of the index; SnapshotDirty recognizes those as committed dead and so we're back to the same problem. To improve the situation, invent a "SnapshotNonVacuumable" snapshot type and use that instead. The reason this helps is that, if the snapshot rejects a given index entry, we know that the indexscan will mark that index entry as killed. This means the next get_actual_variable_range() scan will proceed past that entry without visiting the heap, making the scan a lot faster. We may end up accepting a recently-dead tuple as being the estimated extremal value, but that doesn't seem much worse than the compromise we made before to accept not-yet-committed extremal values. The cost of the scan is still proportional to the number of dead index entries at the end of the range, so in the interval after a mass delete but before VACUUM's cleaned up the mess, it's still possible for get_actual_variable_range() to take a noticeable amount of time, if you've got enough such dead entries. But the constant factor is much much better than before, since all we need to do with each index entry is test its "killed" bit. We chose to back-patch commit fccebe421 at the time, but I'm hesitant to do so here, because this form of the problem seems to affect many fewer people. Also, even when it happens, it's less bad than the case fixed by commit fccebe421 because we don't get the contention effects from expensive TransactionIdIsInProgress tests. Dmitriy Sarafannikov, reviewed by Andrey Borodin Discussion:
  • Add much-more-extensive TAP tests for pgbench. Fabien Coelho, reviewed by Nikolay Shaplov and myself Discussion:
  • Fix assorted portability issues in new pgbench TAP tests. * Our own version of getopt_long doesn't support abbreviation of long options. * It doesn't do automatic rearrangement of non-option arguments to the end, either. * Test was way too optimistic about the platform independence of NaN and Infinity outputs. I rather imagine we might have to lose those tests altogether, but for the moment just allow case variation and fully spelled out Infinity. Per buildfarm.
  • Fix more portability issues in new pgbench TAP tests. Strike two on the --bad-option test. Three strikes and it's out. Fabien Coelho, per buildfarm
  • Fix more portability issues in new pgbench TAP tests. * Remove no-such-user test case, output isn't stable, and we really don't need to be testing such cases here anyway. * Fix the process exit code test logic to match PostgresNode::psql (but I didn't bother with looking at the "core" flag). * Give up on inf/nan tests. Per buildfarm.
  • Remove mention of password_encryption = plain in postgresql.conf.sample. Evidently missed in commit eb61136dc. Spotted by Oleg Bartunov. Discussion:
  • Doc: update v10 release notes through today. Also, another round of copy-editing. I merged a few items that didn't seem to be meaningfully different from a user's perspective.
  • Fix pgbench TAP tests to work with --disable-thread-safety. Probably matters to nobody but me; but I'd like to still be able to get through the TAP tests on gaur/pademelon, from time to time.
  • Fix more portability issues in new pgbench TAP tests. Not completely sure, but I think bowerbird is spitting up on attempting to include ">" in a temporary file name. (Why in the world are we writing this stuff into files at all? A hash would be a better answer.)
  • Fix uninitialized-variable bug. map_partition_varattnos() failed to set its found_whole_row output parameter if the given expression list was NIL. This seems to be a pre-existing bug that chanced to be exposed by commit 6f6b99d13. It might be unreachable in v10, but I have little faith in that proposition, so back-patch. Per buildfarm.
  • Fix failure-to-copy bug in commit 6f6b99d13. The previous coding of get_qual_for_list() was careful to copy everything it was using from the input data structure. The new version missed making a copy of pass-by-ref datum values that it's inserting into Consts. This is not optional, however, as revealed by buildfarm failures on machines running -DRELCACHE_FORCE_RELEASE: we're copying from a relcache entry that could go away before the required lifespan of our output expression. I'm pretty sure -DCLOBBER_CACHE_ALWAYS machines won't like this either, but none of them have reported in yet.
  • Add a test harness for the red-black tree code. This improves the regression tests' coverage of rbtree.c from pretty awful (because some of the functions aren't used yet) to basically 100%. Victor Drobny, reviewed by Aleksander Alekseev and myself Discussion:
  • Remove pre-order and post-order traversal logic for red-black trees. This code isn't used, and there's no clear reason why anybody would ever want to use it. These traversal mechanisms don't yield a visitation order that is semantically meaningful for any external purpose, nor are they any faster or simpler than the left-to-right or right-to-left traversals. (In fact, some rough testing suggests they are slower :-(.) Moreover, these mechanisms are impossible to test in any arm's-length fashion; doing so requires knowledge of the red-black tree's internal implementation. Hence, let's just jettison them. Discussion:
  • Quick-hack fix for foreign key cascade vs triggers with transition tables. AFTER triggers using transition tables crashed if they were fired due to a foreign key ON CASCADE update. This is because ExecEndModifyTable flushes the transition tables, on the assumption that any trigger that could need them was already fired during ExecutorFinish. Normally that's true, because we don't allow transition-table-using triggers to be deferred. However, foreign key CASCADE updates force any triggers on the referencing table to be deferred to the outer query level, by means of the EXEC_FLAG_SKIP_TRIGGERS flag. I don't recall all the details of why it's like that and am pretty loath to redesign it right now. Instead, just teach ExecEndModifyTable to skip destroying the TransitionCaptureState when that flag is set. This will allow the transition table data to survive until end of the current subtransaction. This isn't a terribly satisfactory solution, because (1) we might be leaking the transition tables for much longer than really necessary, and (2) as things stand, an AFTER STATEMENT trigger will fire once per RI updating query, ie once per row updated or deleted in the referenced table. I suspect that is not per SQL spec. But redesigning this is a research project that we're certainly not going to get done for v10. So let's go with this hackish answer for now. In passing, tweak AfterTriggerSaveEvent to not save the transition_capture pointer into the event record for a deferrable trigger. This is not necessary to fix the current bug, but it avoids letting dangling pointers to long-gone transition tables persist in the trigger event queue. That's at least a safety feature. It might also allow merging shared trigger states in more cases than before. I added a regression test that demonstrates the crash on unpatched code, and also exposes the behavior of firing the AFTER STATEMENT triggers once per row update. Per bug #14808 from Philippe Beaudoin. Back-patch to v10. Discussion:

Peter Eisentraut pushed:

Simon Riggs pushed:

Robert Haas pushed:

Correctifs en attente

Kyotaro HORIGUCHI sent in another revision of a patch to implement asynchronous execution.

Thomas Munro sent in another revision of a patch to enable sharing record typmods among backend.

Ivan Kartyshov sent in another revision of a patch to add waitlsn.

Fabien COELHO sent in a patch to fix an issue with pg_bench between min_usec and maxsock.

Etsuro Fujita sent in another revision of a patch to remove some useless code from ExecInitModifyTable.

Ivan Kartyshov sent in another revision of a patch to make the replica skip truncate WAL record if some transaction using the same table is already running on replica.

Emre Hasegeli sent in another revision of a patch to improve geometric types.

Ashutosh Bapat and Rushabh Lathia traded patches to improve the \d+ output for partitioned tables in psql.

Kyotaro HORIGUCHI sent in another revision of a patch to enable switching the WAL source in the middle of a record and add some debug code around same.

Alexander Kuzmenkov sent in another revision of a patch to implement index-only count(*) for indexes supporting bitmap scans.

Rajkumar Raghuwanshi and Ashutosh Bapat traded patches to modify bound comparision functions to accept members of PartitionKey, do partition-wise join for 1:1, 1:0, 0:1 partition matching, and add tests for the latter.

Chris Travers sent in a patch to enable pg_rewind to skip config files.

Tsutomu Yamada sent in two more revisions of a patch to add a catalog view for monitoring the progress of CLUSTER commands.

Amul Sul sent in two more revisions of a patch to add hash partitioning.

Ashutosh Bapat and Robert Haas traded patches to add partition-wise join for declaratively partitioned tables.

Amit Kapila sent in three revisions of a patch to fix role handling in parallel workers.

Nathan Bossart sent in four more revisions of a patch to allow multiple VACUUM targets per command.

Amul Sul and Amit Khandekar traded patches to enable UPDATEs of a declaratively partitioned table's partition key.

Arseny Sher sent in a patch to stop LR workers before dropping replication origin.

Tatsuo Ishii sent in another revision of a patch to rearm statement_timeout after each executed query.

Kyotaro HORIGUCHI sent in another revision of a patch to enable showing the aggressiveness of vacuuming in log messages.

Nikolay Shaplov sent in a patch to add tests for reloptions.

Kyotaro HORIGUCHI sent in another revision of a patch to clean up the negative cache of pg_statistic when dropping a relation and clean up the negative cache of pg_class when dropping a schema.

Jeevan Chalke and Ashutosh Bapat traded patches to replace lfirst() with lfirst_node() appropriately in planner.c.

Amit Kapila sent in another revision of a patch to ensure that parallel paths include tlist cost.

Masahiko Sawada sent in three more revisions of a patch to enable custom pgbench intialization.

Haribabu Kommi sent in another revision of a patch to implement a pg_stat_wal_write catalog view.

Amit Kapila sent in a patch to enable pushdown of target below GatherMerge in more cases.

Michaël Paquier sent in another revision of a patch to implement pg_receivewal --endpos.

Michaël Paquier sent in another revision of a patch to fix a bug which caused cache lookup errors for missing replication origins.

Amit Langote and Daniel Gustafsson traded patches to fix some copyright headers.

Rafia Sabih sent in a patch to make gather faster.

Ashutosh Bapat sent in another revision of a patch to improve join selectivity estimation for <>.

Alexander Korotkov sent in a patch to make foreign tables writable from a physical-WAL replica.

Alexander Korotkov sent in two revisions of a patch to fit the Bloom WAL TAP test.

Simon Riggs sent in a patch to document the new psql server version variables recently committed.

Fabien COELHO sent in two more revisions of a patch to add special variables to reflect the last query status in psql.

Amit Langote sent in another revision of a patch to expand partitioned inheritance in a non-flattened manner except when the partitioned table in question is the result rel of the query, make planner-side changes for partition-pruning, make interface changes for partition_bound_{cmp/bsearch}, implement get_partitions_for_keys(), and add more tests for the new partitioning-related planning.

Andres Freund and Beena Emerson traded patches to introduce BYTES unit for GUCs and make wal segment size configurable at initdb time.

Peter Geoghegan sent in another revision of a patch to add a Bloom filter data structure implementation and use it to add amcheck verification of indexes against the heap.

Thomas Munro sent in another revision of a patch to introduce a synchronous replay mode to avoid stale reads on hot standbys.

Kyotaro HORIGUCHI sent in another revision of a patch to add two columns, "live," and "distance" to pg_replication_slot.

Konstantin Knizhnik sent in another revision of a patch to optimize secondary index usage.

Ildus Kurbangaliev sent in a patch to implement custom compression methods.

Pavel Stěhule sent in another revision of a patch to fix a bug where record or row variable could not be part of multiple-item INTO list.

Tomas Vondra sent in another revision of a patch to introduce multivariate histograms and MCV lists.

Etsuro Fujita sent in another revision of a patch to fix a bug which manifested as tuple-routing for certain partitioned tables not working as expected.

Alexey Chernyshov sent in another revision of a patch to pageinspect which adds functions on GIN and GiST indexes from gevel.

Dmitry Dolgov sent in another revision of a patch to implement generic type subscripting and refactor arrays and JSONB to use it.

Amit Langote sent in a patch to set pd_lower correctly in the GIN metapage, set pd_lower correctly in the BRIN index metapage, and set pd_lower correctly in the SP-GiST index metapage.

Masahiko Sawada sent in another revision of a patch to move extension_lock out of heavyweight lock.

Pavel Stěhule sent in another revision of a patch to expand psql's describe method.

Amul Sul sent in a patch to add extended hash functions to hstore and citext.

Amit Langote sent in another revision of a patch to decouple RelationGetPartitionDispatchInfo() from the executor and make RelationGetPartitionDispatch expansion order depth-first.

Masahiko Sawada sent in another revision of a patch to implement block-level parallel VACUUM.

Jeevan Chalke sent in another revision of a patch to implement partition-wise aggregation/grouping.

Antonin Houska sent in a patch to implement infrastructure to propagate the result of partial aggregation from the base relation or join to the root of the join tree and to use these as input for the final aggregation.

Amit Khandekar sent in another revision of a patch to implement parallel append.

Fabien COELHO sent in another revision of a patch to pgbench to enable storing select results into variables.

Peter Eisentraut sent in another revision of a patch to adminpack to add a test suite.

Fabien COELHO sent in a patch to fix assorted portability issues in new pgbench TAP tests.

Yura Sokolov sent in another revision of a patch to make a more correct use of spinlock inside LWLockWaitListLock, perform atomic LWLock acquirement or putting into wait list, use a custom loop for LWLockWaitForVar, make acquiring LWLock look more like spinlock, fix the implementation description in lwlock.c, and make SpinDelayStatus a bit lighter.

Peter Eisentraut and Thomas Munro traded patches to allow custom search filters to be configured for LDAP auth, add an LDAP authentication test suite, and add tests for the ldapsearchfilter functionality.

Jeevan Chalke and Pavel Stěhule traded patches to use names as the primary names of plpgsql function parameters instead $ based names.

Haribabu Kommi sent in another revision of a patch to change create access method to include a storage handler, add storage AM API hooks and related functions, add a storageam handler to relation structure, add a tuple visibility function to the storage AM, add slot hooks to the storage AM, add a tuple insert API to the storage AM, and add scan functions to the storage AM.

Haribabu Kommi sent in another revision of a patch to refactor pg_dump and pg_dumpall database handling.

Pavel Stěhule sent in another revision of a patch to refactor the psql help list.

Andres Freund sent in a patch to const-ify numeric.c's local vars in support of upcoming JIT work.

Michaël Paquier sent in a patch to fix a race condition in the recovery TAP tests.

Michaël Paquier sent in another revision of a patch to support channel binding for SCRAM-SHA-256.