Robert Haas [Tue, 29 Apr 2014 19:30:36 +0000 (19:30 +0000)]
Cache the results of the last sb_find_leaf operation.
If all the memory we're accessing is in the same 4GB segment of the address
space, this eliminates calls to sb_find_leaf altogether, a significant
savings. But even if we're ranging across more than one segment, this
should win in cases that have some degree of access locality.
Robert Haas [Tue, 29 Apr 2014 18:08:46 +0000 (18:08 +0000)]
Avoid referencing memory we've already freed.
Robert Haas [Tue, 29 Apr 2014 17:17:41 +0000 (13:17 -0400)]
Finish up sb_free.
Robert Haas [Tue, 29 Apr 2014 16:58:18 +0000 (12:58 -0400)]
Teach sb_free to unlink spans and return their storage to fpm.
The spans themselves don't get reclaimed yet.
Robert Haas [Tue, 29 Apr 2014 15:42:29 +0000 (11:42 -0400)]
Reset allocator after use.
Robert Haas [Tue, 29 Apr 2014 15:38:36 +0000 (11:38 -0400)]
Fix bug.
Robert Haas [Tue, 29 Apr 2014 15:31:41 +0000 (11:31 -0400)]
Fix a bug.
Robert Haas [Tue, 29 Apr 2014 15:24:42 +0000 (11:24 -0400)]
Fix erroneous use of fpm_base rather than base.
Robert Haas [Tue, 29 Apr 2014 15:20:32 +0000 (11:20 -0400)]
Correct completely bogus Assert.
Robert Haas [Tue, 29 Apr 2014 15:20:13 +0000 (11:20 -0400)]
Add an Assert.
Robert Haas [Tue, 29 Apr 2014 13:53:17 +0000 (09:53 -0400)]
Fix typo.
Robert Haas [Tue, 29 Apr 2014 11:36:24 +0000 (07:36 -0400)]
test_sballoc: make a big linked list, then free it one node at a time
Robert Haas [Tue, 15 Apr 2014 21:15:37 +0000 (17:15 -0400)]
Sketch out sb_free.
Robert Haas [Fri, 11 Apr 2014 18:44:04 +0000 (14:44 -0400)]
test_sballoc: show palloc stats, and delete context explicitly
Robert Haas [Fri, 11 Apr 2014 18:31:06 +0000 (14:31 -0400)]
add some stats on memory consumption
Robert Haas [Fri, 11 Apr 2014 17:22:55 +0000 (13:22 -0400)]
fix contiguous freespace reporting for previous patch
Robert Haas [Fri, 11 Apr 2014 17:09:01 +0000 (13:09 -0400)]
improve FreePageManager
- fix a bug when the btree root is created from the last free page
- when the btree root is a leaf and is surrounded on either side by
freespace, collapse it to a singleton range
Robert Haas [Fri, 11 Apr 2014 14:35:32 +0000 (14:35 +0000)]
Fix bugs.
Robert Haas [Fri, 11 Apr 2014 14:32:24 +0000 (14:32 +0000)]
further test_sballoc temporary changes
Robert Haas [Fri, 11 Apr 2014 01:07:08 +0000 (01:07 +0000)]
Refactoring to streamline the common case.
It makes more sense this way, too.
Robert Haas [Thu, 10 Apr 2014 23:51:43 +0000 (23:51 +0000)]
Remove sb_try_to_steal_superblock.
It makes no sense with just one heap per size class.
Robert Haas [Thu, 10 Apr 2014 22:57:20 +0000 (22:57 +0000)]
sb_region: Improve private freelist management.
Robert Haas [Thu, 10 Apr 2014 21:12:31 +0000 (21:12 +0000)]
nused->nallocatable. this avoids computing nmax for every allocation,
which turns out to speed things up *a lot* (3.7s vs. 5.3s for 100m
8-byte allocations)
Robert Haas [Thu, 10 Apr 2014 20:01:52 +0000 (20:01 +0000)]
Push obsize/nmax computation down.
Testing shows this is faster (5.4s vs 5.7s for 100m 8-byte allocations).
Robert Haas [Thu, 10 Apr 2014 19:53:52 +0000 (19:53 +0000)]
temporary hack for test_sballoc
Robert Haas [Thu, 10 Apr 2014 19:29:07 +0000 (19:29 +0000)]
Remove num_size_classes. For now, at least, it's a constant.
Robert Haas [Thu, 10 Apr 2014 18:00:34 +0000 (18:00 +0000)]
Remove support for N heaps per size class.
Profiling shows that this is wicked expensive.
Robert Haas [Thu, 10 Apr 2014 16:43:56 +0000 (16:43 +0000)]
Fix bugs.
Robert Haas [Wed, 9 Apr 2014 18:18:18 +0000 (18:18 +0000)]
Fix bugs.
Robert Haas [Wed, 9 Apr 2014 17:01:00 +0000 (17:01 +0000)]
Fix compiler warnings.
Robert Haas [Fri, 28 Mar 2014 05:51:44 +0000 (22:51 -0700)]
Add debugging code, fix bugs.
Robert Haas [Wed, 26 Mar 2014 23:55:43 +0000 (16:55 -0700)]
test_sballoc improvements.
Robert Haas [Wed, 26 Mar 2014 23:53:44 +0000 (16:53 -0700)]
sb_reset_allocator
Robert Haas [Wed, 26 Mar 2014 23:23:59 +0000 (16:23 -0700)]
Fix bugs.
Robert Haas [Wed, 26 Mar 2014 00:07:19 +0000 (17:07 -0700)]
test_sballoc: comparison testing vs. palloc
Robert Haas [Wed, 26 Mar 2014 00:01:12 +0000 (17:01 -0700)]
Fix bugs.
Robert Haas [Tue, 25 Mar 2014 23:23:55 +0000 (16:23 -0700)]
Fix bugs.
Robert Haas [Tue, 25 Mar 2014 18:29:16 +0000 (11:29 -0700)]
Fix bug in test_sballoc.
Robert Haas [Tue, 25 Mar 2014 18:26:48 +0000 (11:26 -0700)]
Oops.
Robert Haas [Tue, 25 Mar 2014 00:22:08 +0000 (17:22 -0700)]
Fix bug.
Robert Haas [Tue, 25 Mar 2014 00:19:26 +0000 (17:19 -0700)]
test_sballoc
Robert Haas [Mon, 24 Mar 2014 23:06:21 +0000 (16:06 -0700)]
last bits of sb_alloc_from_heap
Robert Haas [Mon, 24 Mar 2014 21:55:04 +0000 (14:55 -0700)]
fill in more of sb_alloc_from_heap
Robert Haas [Sat, 22 Mar 2014 14:51:17 +0000 (10:51 -0400)]
rough sketch of sb_alloc_from_heap
Robert Haas [Fri, 21 Mar 2014 18:35:56 +0000 (14:35 -0400)]
more of sb_alloc, still missing some guts
Robert Haas [Fri, 21 Mar 2014 16:51:12 +0000 (12:51 -0400)]
sb_alloc, less guts.
Robert Haas [Fri, 21 Mar 2014 11:36:22 +0000 (07:36 -0400)]
sb_create_private_allocator
Robert Haas [Thu, 20 Mar 2014 21:43:37 +0000 (17:43 -0400)]
sb_private_region_for_allocator, part two.
Robert Haas [Wed, 19 Mar 2014 20:35:00 +0000 (16:35 -0400)]
Add private flag to sb_allocator.
Robert Haas [Wed, 19 Mar 2014 20:28:25 +0000 (16:28 -0400)]
sb_private_region_for_allocator, part one.
Robert Haas [Wed, 19 Mar 2014 19:47:55 +0000 (15:47 -0400)]
sb_report_contiguous_freespace
Robert Haas [Wed, 12 Mar 2014 17:25:40 +0000 (13:25 -0400)]
Add FreePageManagerInquireLargest.
Robert Haas [Wed, 12 Mar 2014 16:40:43 +0000 (12:40 -0400)]
sb_region_lookup
Robert Haas [Tue, 11 Mar 2014 21:33:48 +0000 (17:33 -0400)]
Stub out sb_alloc/sb_region.
Robert Haas [Tue, 11 Mar 2014 21:31:17 +0000 (17:31 -0400)]
sb_map: Fix typo.
Robert Haas [Tue, 11 Mar 2014 19:39:10 +0000 (15:39 -0400)]
sb_map
Robert Haas [Tue, 11 Mar 2014 18:04:36 +0000 (14:04 -0400)]
Fix typo.
Robert Haas [Fri, 28 Feb 2014 18:27:09 +0000 (13:27 -0500)]
Fix bugs.
Robert Haas [Thu, 27 Feb 2014 18:07:28 +0000 (13:07 -0500)]
More hacking.
Robert Haas [Thu, 27 Feb 2014 16:41:54 +0000 (11:41 -0500)]
More hacking.
Robert Haas [Wed, 26 Feb 2014 13:18:17 +0000 (08:18 -0500)]
More hacking.
Robert Haas [Fri, 21 Feb 2014 05:41:13 +0000 (00:41 -0500)]
Fix bugs.
Robert Haas [Thu, 20 Feb 2014 21:17:31 +0000 (16:17 -0500)]
Fix bugs.
Robert Haas [Thu, 20 Feb 2014 19:48:28 +0000 (14:48 -0500)]
Fix bugs.
Robert Haas [Thu, 20 Feb 2014 17:25:17 +0000 (12:25 -0500)]
Fix bugs.
Robert Haas [Thu, 20 Feb 2014 16:01:44 +0000 (11:01 -0500)]
test_freepage fixes.
Robert Haas [Thu, 20 Feb 2014 15:45:59 +0000 (10:45 -0500)]
test_freepage harness.
Robert Haas [Thu, 20 Feb 2014 13:16:10 +0000 (08:16 -0500)]
More hacking.
Robert Haas [Thu, 20 Feb 2014 11:30:38 +0000 (06:30 -0500)]
More hacking.
Robert Haas [Thu, 20 Feb 2014 03:00:30 +0000 (22:00 -0500)]
More hacking.
Robert Haas [Thu, 20 Feb 2014 01:47:13 +0000 (20:47 -0500)]
More hacking.
Robert Haas [Wed, 19 Feb 2014 22:54:35 +0000 (17:54 -0500)]
More hacking.
Robert Haas [Wed, 19 Feb 2014 22:18:19 +0000 (17:18 -0500)]
More hacking.
Robert Haas [Wed, 19 Feb 2014 20:47:18 +0000 (15:47 -0500)]
More hacking.
Robert Haas [Wed, 19 Feb 2014 20:26:16 +0000 (15:26 -0500)]
More hacking.
Robert Haas [Wed, 19 Feb 2014 20:05:22 +0000 (15:05 -0500)]
More hacking.
Robert Haas [Mon, 17 Feb 2014 05:47:47 +0000 (00:47 -0500)]
More hacking.
Robert Haas [Sun, 16 Feb 2014 17:49:52 +0000 (12:49 -0500)]
More hacking.
Robert Haas [Fri, 14 Feb 2014 13:09:32 +0000 (08:09 -0500)]
More hacking.
Robert Haas [Thu, 13 Feb 2014 03:39:29 +0000 (22:39 -0500)]
More hacking.
Robert Haas [Wed, 12 Feb 2014 18:33:26 +0000 (13:33 -0500)]
Beginnings of new free page manager.
Fujii Masao [Wed, 2 Jul 2014 03:42:20 +0000 (12:42 +0900)]
Prevent psql from issuing BEGIN before ALTER SYSTEM when AUTOCOMMIT is off.
The autocommit-off mode works by issuing an implicit BEGIN just before
any command that is not already in a transaction block and is not itself
a BEGIN or other transaction-control command, nor a command that
cannot be executed inside a transaction block. This commit prevents psql
from issuing such an implicit BEGIN before ALTER SYSTEM because it's
not allowed inside a transaction block.
Backpatch to 9.4 where ALTER SYSTEM was added.
Report by Feike Steenbergen
Tom Lane [Wed, 2 Jul 2014 00:10:38 +0000 (20:10 -0400)]
Allow CREATE/ALTER DATABASE to manipulate datistemplate and datallowconn.
Historically these database properties could be manipulated only by
manually updating pg_database, which is error-prone and only possible for
superusers. But there seems no good reason not to allow database owners to
set them for their databases, so invent CREATE/ALTER DATABASE options to do
that. Adjust a couple of places that were doing it the hard way to use the
commands instead.
Vik Fearing, reviewed by Pavel Stehule
Tom Lane [Tue, 1 Jul 2014 23:02:21 +0000 (19:02 -0400)]
Refactor CREATE/ALTER DATABASE syntax so options need not be keywords.
Most of the existing option names are keywords anyway, but we can get rid
of LC_COLLATE and LC_CTYPE as keywords known to the lexer/grammar. This
immediately reduces the size of the grammar tables by about 8KB, and will
save more when we add additional CREATE/ALTER DATABASE options in future.
A side effect of the implementation is that the CONNECTION LIMIT option
can now also be spelled CONNECTION_LIMIT. We choose not to document this,
however.
Vik Fearing, based on a suggestion by me; reviewed by Pavel Stehule
Tom Lane [Tue, 1 Jul 2014 21:51:53 +0000 (17:51 -0400)]
Remove some useless code in the configure script.
Almost ten years ago, commit
e48322a6d6cfce1ec52ab303441df329ddbc04d1 broke
the logic in ACX_PTHREAD by looping through all the possible flags rather
than stopping with the first one that would work. This meant that
$acx_pthread_ok was no longer meaningful after the loop; it would usually
be "no", whether or not we'd found working thread flags. The reason nobody
noticed is that Postgres doesn't actually use any of the symbols set up
by the code after the loop. Rather than complicate things some more to
make it work as designed, let's just remove all that dead code, and thereby
save a few cycles in each configure run.
Tom Lane [Tue, 1 Jul 2014 21:23:16 +0000 (17:23 -0400)]
Improve handling of OOM score adjustment in sample Linux start script.
Per a suggestion from Christoph Berg.
Tom Lane [Tue, 1 Jul 2014 15:22:43 +0000 (11:22 -0400)]
Fix inadequately-sized output buffer in contrib/unaccent.
The output buffer size in unaccent_lexize() was calculated as input string
length times pg_database_encoding_max_length(), which effectively assumes
that replacement strings aren't more than one character. While that was
all that we previously documented it to support, the code actually has
always allowed replacement strings of arbitrary length; so if you tried
to make use of longer strings, you were at risk of buffer overrun. To fix,
use an expansible StringInfo buffer instead of trying to determine the
maximum space needed a-priori.
This would be a security issue if unaccent rules files could be installed
by unprivileged users; but fortunately they can't, so in the back branches
the problem can be labeled as improper configuration by a superuser.
Nonetheless, a memory stomp isn't a nice way of reacting to improper
configuration, so let's back-patch the fix.
Robert Haas [Tue, 1 Jul 2014 14:34:42 +0000 (10:34 -0400)]
Avoid copying index tuples when building an index.
The previous code, perhaps out of concern for avoid memory leaks, formed
the tuple in one memory context and then copied it to another memory
context. However, this doesn't appear to be necessary, since
index_form_tuple and the functions it calls take precautions against
leaking memory. In my testing, building the tuple directly inside the
sort context shaves several percent off the index build time.
Rearrange things so we do that.
Patch by me. Review by Amit Kapila, Tom Lane, Andres Freund.
Tom Lane [Tue, 1 Jul 2014 02:03:37 +0000 (22:03 -0400)]
Issue a WARNING about invalid rule file format in contrib/unaccent.
We were already issuing a WARNING, albeit only elog not ereport, for
duplicate source strings; so warning rather than just being stoically
silent seems like the best thing to do here. Arguably both of these
complaints should be upgraded to ERRORs, but that might be more
behavioral change than people want.
Note: the faulty line is already printed via an errcontext hook,
so there's no need for more information than these messages provide.
Tom Lane [Tue, 1 Jul 2014 01:46:29 +0000 (21:46 -0400)]
Allow multi-character source strings in contrib/unaccent.
This could be useful in languages where diacritic signs are represented as
separate characters; more generally it supports using unaccent dictionaries
for substring substitutions beyond narrowly conceived "diacritic removal".
In any case, since the rule-file parser doesn't complain about
multi-character source strings, it behooves us to do something unsurprising
with them.
Tom Lane [Tue, 1 Jul 2014 00:51:26 +0000 (20:51 -0400)]
Allow empty replacement strings in contrib/unaccent.
This is useful in languages where diacritic signs are represented as
separate characters; it's also one step towards letting unaccent be used
for arbitrary substring substitutions.
In passing, improve the user documentation for unaccent, which was sadly
vague about some important details.
Mohammad Alhashash, reviewed by Abhijit Menon-Sen
Bruce Momjian [Mon, 30 Jun 2014 23:55:55 +0000 (19:55 -0400)]
pg_upgrade: update C comments about pg_dumpall
There were some C comments that hadn't been updated from the switch of
using only pg_dumpall to using pg_dump and pg_dumpall, so update them.
Also, don't bother using --schema-only for pg_dumpall --globals-only.
Backpatch through 9.4
Noah Misch [Mon, 30 Jun 2014 20:59:19 +0000 (16:59 -0400)]
Don't prematurely free the BufferAccessStrategy in pgstat_heap().
This function continued to use it after heap_endscan() freed it. In
passing, don't explicit create a strategy here. Instead, use the one
created by heap_beginscan_strat(), if any. Back-patch to 9.2, where use
of a BufferAccessStrategy here was introduced.
Andres Freund [Mon, 30 Jun 2014 08:48:39 +0000 (10:48 +0200)]
Fix typos in the cluster_name commit.
Thom Brown and Fujii Masao
Andres Freund [Sun, 29 Jun 2014 15:08:04 +0000 (17:08 +0200)]
Check interrupts during logical decoding more frequently.
When reading large amounts of preexisting WAL during logical decoding
using the SQL interface we possibly could fail to check interrupts in
due time. Similarly the same could happen on systems with a very high
WAL volume while creating a new logical replication slot, independent
of the used interface.
Previously these checks where only performed in xlogreader's read_page
callbacks, while waiting for new WAL to be produced. That's not
sufficient though, if there's never a need to wait. Walsender's send
loop already contains a interrupt check.
Backpatch to 9.4 where the logical decoding feature was introduced.
Heikki Linnakangas [Mon, 30 Jun 2014 07:13:48 +0000 (10:13 +0300)]
Fix and enhance the assertion of no palloc's in a critical section.
The assertion failed if WAL_DEBUG or LWLOCK_STATS was enabled; fix that by
using separate memory contexts for the allocations made within those code
blocks.
This patch introduces a mechanism for marking any memory context as allowed
in a critical section. Previously ErrorContext was exempt as a special case.
Instead of a blanket exception of the checkpointer process, only exempt the
memory context used for the pending ops hash table.
Tom Lane [Sun, 29 Jun 2014 17:50:58 +0000 (13:50 -0400)]
Remove use_json_as_text options from json_to_record/json_populate_record.
The "false" case was really quite useless since all it did was to throw
an error; a definition not helped in the least by making it the default.
Instead let's just have the "true" case, which emits nested objects and
arrays in JSON syntax. We might later want to provide the ability to
emit sub-objects in Postgres record or array syntax, but we'd be best off
to drive that off a check of the target field datatype, not a separate
argument.
For the functions newly added in 9.4, we can just remove the flag arguments
outright. We can't do that for json_populate_record[set], which already
existed in 9.3, but we can ignore the argument and always behave as if it
were "true". It helps that the flag arguments were optional and not
documented in any useful fashion anyway.
Andres Freund [Sun, 29 Jun 2014 12:15:09 +0000 (14:15 +0200)]
Add cluster_name GUC which is included in process titles if set.
When running several postgres clusters on one OS instance it's often
inconveniently hard to identify which "postgres" process belongs to
which postgres instance.
Add the cluster_name GUC, whose value will be included as part of the
process titles if set. With that processes can more easily identified
using tools like 'ps'.
To avoid problems with encoding mismatches between postgresql.conf,
consoles, and individual databases replace non-ASCII chars in the name
with question marks. The length is limited to NAMEDATALEN to make it
less likely to truncate important information at the end of the
status.
Thomas Munro, with some adjustments by me and review by a host of people.
Andres Freund [Sat, 28 Jun 2014 19:40:40 +0000 (21:40 +0200)]
Remove Alpha and Tru64 support.
Support for running postgres on Alpha hasn't been tested for a long
while. Due to Alpha's uniquely lax cache coherency model it's a hard
to develop for platform (especially blindly!) and thought to be
unlikely to currently work correctly.
As Alpha is the only supported architecture for Tru64 drop support for
it as well. Tru64's support has ended 2012 and it has been in
maintenance-only mode for much longer.
Also remove stray references to __ksr__ and ultrix defines.
Tom Lane [Sat, 28 Jun 2014 06:08:08 +0000 (23:08 -0700)]
Allow pushdown of WHERE quals into subqueries with window functions.
We can allow this even without any specific knowledge of the semantics
of the window function, so long as pushed-down quals will either accept
every row in a given window partition, or reject every such row. Because
window functions act only within a partition, such a case can't result
in changing the window functions' outputs for any surviving row.
Eliminating entire partitions in this way obviously can reduce the cost
of the window-function computations substantially.
The fly in the ointment is that it's hard to be entirely sure whether
this is true for an arbitrary qual condition. This patch allows pushdown
if (a) the qual references only partitioning columns, and (b) the qual
contains no volatile functions. We are at risk of incorrect results if
the qual can produce different answers for values that the partitioning
equality operator sees as equal. While it's not hard to invent cases
for which that can happen, it seems to seldom be a problem in practice,
since no one has complained about a similar assumption that we've had
for many years with respect to DISTINCT. The potential performance
gains seem to be worth the risk.
David Rowley, reviewed by Vik Fearing; some credit is due also to
Thomas Mayer who did considerable preliminary investigation.