Commit Graph

2219 Commits

Author SHA1 Message Date
Peter Eisentraut 5cfd5bb15b pg_upgrade: Remove check for pg_config
It is no longer used, but was still being checked for.

bug #7548 from Reinhard Max
2012-09-18 22:04:28 -04:00
Andrew Dunstan f8c81c5dde In pg_upgrade, try a few times to open a log file.
If we call pg_ctl stop, the server might continue and thus
hold a log file for a short time after it has deleted its pid file,
(which is when pg_ctl will exit), and so a subsequent attempt to
open the log file might fail.

We therefore try to open it a few times, sleeping one second between
tries, to give the server time to exit.

This corrects an error that was observed on the buildfarm.

Backpatched to 9.2,
2012-09-05 23:14:49 -04:00
Peter Eisentraut 4c60b80094 pgbench: Show better progress when loading tuples
Show target number of tuples and percentage in addition to current
number.
2012-09-05 23:07:47 -04:00
Andrew Dunstan f8f5cf33a3 Fix pg_upgrade test script's line end handling on Windows.
Call pg_dumpall using -f switch instead of redirection, to avoid
writing the output in text mode and generating spurious carriage
returns. Remove to carriage return ignoring hack introduced by
commit e442b0f0c6.

Backpatch to 9.2.
2012-09-05 18:00:31 -04:00
Andrew Dunstan ea0b414a0d Fix line end mishandling in pg_upgrade on Windows.
pg_upgrade opened the output from pg_dumpall in text mode and
wrote the split files in text mode. This caused unwanted eating
of intended carriage returns on input and production of spurious
carriage returns on output. To avoid this, open all these files
in binary mode. On non-Windows platforms, this change has no
effect.

Backpatch to 9.0. On 9.0 and 9.1, we also switch from redirecting
pg_dumpall's output to using pg_dumpall's -f switch, for the same
reason.
2012-09-05 17:41:43 -04:00
Tom Lane b98fd52a55 Silence -Wunused-result warning in contrib/pg_upgrade.
This is just neatnik-ism, but since we do it for comparable code in elog.c,
we may as well do it here.
2012-09-05 14:37:22 -04:00
Robert Haas aa2b237ce5 sepgsql cleanups.
This is needed to match recent changes elsewhere.  Along the way, some
renaming for clarity.

KaiGai Kohei
2012-09-05 14:01:59 -04:00
Bruce Momjian 022cd22f0f In pg_upgrade, document why we can't issue \n\n in the command logfile
on Windows.  Slightly cleanup log output on Windows given this
restriction.

Backpatch to 9.2.
2012-09-05 00:01:13 -04:00
Andrew Dunstan 2042185baf Fix transcription error. 2012-09-04 09:39:49 -04:00
Andrew Dunstan 0829c7087e Fix command echoing in pg_upgade's analyze script for Windows. 2012-09-04 05:49:22 -04:00
Andrew Dunstan 2f0c7d5854 Indent fix_path_separator() header properly. 2012-09-03 22:59:19 -04:00
Andrew Dunstan e442b0f0c6 Allow pg_upgrade "make check" to run on Windows/MSys.
Backpatch to 9.2.
2012-09-03 22:32:17 -04:00
Bruce Momjian a80b8037cf In pg_upgrade, pull the port number from postmaster.pid, like we do for
socket location.  Also, prevent putting the socket in the current
directory for pre-9.1 servers in live check and non-live check mode,
because pre-9.1 pg_ctl -w can't handle it.

Backpatch to 9.2.
2012-09-03 22:15:09 -04:00
Andrew Dunstan 504aeea692 Use correct path separator for Windows builtin commands.
pg_upgrade produces a platform-specific script to remove the old
directory, but on Windows it has not been making sure that the
paths it writes as arguments for rmdir and del use the backslash
path separator, which will cause these scripts to fail.

The fix is backpatched to Release 9.0.
2012-09-03 18:06:47 -04:00
Andrew Dunstan 6259678f8f Fix bugs in exec.c that prevented pg_upgrade working in Windows.
Backpatch to 9.2 - code before that is quite different and should
not have these defects.
2012-09-03 15:31:26 -04:00
Tom Lane f763b77193 Fix pg_upgrade to cope with non-default unix_socket_directory scenarios.
When starting either an old or new postmaster, force it to place its Unix
socket in the current directory.  This makes it even harder for accidental
connections to occur during pg_upgrade, and also works around some
scenarios where the default socket location isn't usable.  (For example,
if the default location is something other than "/tmp", it might not exist
during "make check".)

When checking an already-running old postmaster, find out its actual socket
directory location from postmaster.pid, if possible.  This dodges problems
with an old postmaster having a configured location different from the
default built into pg_upgrade's libpq.  We can't find that out if the old
postmaster is pre-9.1, so also document how to cope with such scenarios
manually.

In support of this, centralize handling of the connection-related command
line options passed to pg_upgrade's subsidiary programs, such as pg_dump.
This should make future changes easier.

Bruce Momjian and Tom Lane
2012-09-03 13:52:40 -04:00
Alvaro Herrera c219d9b0a5 Split tuple struct defs from htup.h to htup_details.h
This reduces unnecessary exposure of other headers through htup.h, which
is very widely included by many files.

I have chosen to move the function prototypes to the new file as well,
because that means htup.h no longer needs to include tupdesc.h.  In
itself this doesn't have much effect in indirect inclusion of tupdesc.h
throughout the tree, because it's also required by execnodes.h; but it's
something to explore in the future, and it seemed best to do the htup.h
change now while I'm busy with it.
2012-08-30 16:52:35 -04:00
Alvaro Herrera 9df55c8c3f Fix assorted compilation failures in contrib
Evidently I failed to test a compile after my earlier header shuffling.
2012-08-28 23:50:49 -04:00
Tom Lane 0a83f2492f Remove pg_stat_statements--1.0.sql, too.
Per Peter Geoghegan.
2012-08-28 14:33:56 -04:00
Tom Lane 9db098dfa9 Remove hstore--1.0.sql.
Since we're not installing this file anymore, it has no reason to exist,
other than as historical reference; but we have an SCM for that.
2012-08-28 14:29:55 -04:00
Bruce Momjian 0f3351aacf Adjust pg_test_timing to show shortest test durations first, place
percentage column before count column.  Docs updated.
2012-08-28 12:57:13 -04:00
Alvaro Herrera 088c065ce8 pg_upgrade: Fix exec_prog API to be less flaky
The previous signature made it very easy to pass something other than
the printf-format specifier in the corresponding position, without any
warning from the compiler.

While at it, move some of the escaping, redirecting and quoting
responsibilities from the callers into exec_prog() itself.  This makes
the callsites cleaner.
2012-08-27 14:29:14 -04:00
Alvaro Herrera 34c02044ed Fix thinko in comment
It was confusing symlinks with hard links.
2012-08-27 14:29:14 -04:00
Alvaro Herrera ab577e63fa Remove analyze_new_cluster.sh on make clean, too 2012-08-27 14:29:14 -04:00
Peter Eisentraut 7afa8bed65 pg_upgrade: Run the created scripts in the test suite
Just to check that they actually work.
2012-08-23 02:29:21 -04:00
Tom Lane b2a01b9ad1 Fix bugs in contrib/pg_trgm's LIKE pattern analysis code.
Extraction of trigrams did not process LIKE escape sequences properly,
leading to possible misidentification of trigrams near escapes, resulting
in incorrect index search results.

Fujii Masao
2012-08-20 13:25:42 -04:00
Tom Lane adc97d03b9 Prevent access to external files/URLs via contrib/xml2's xslt_process().
libxslt offers the ability to read and write both files and URLs through
stylesheet commands, thus allowing unprivileged database users to both read
and write data with the privileges of the database server.  Disable that
through proper use of libxslt's security options.

Also, remove xslt_process()'s ability to fetch documents and stylesheets
from external files/URLs.  While this was a documented "feature", it was
long regarded as a terrible idea.  The fix for CVE-2012-3489 broke that
capability, and rather than expend effort on trying to fix it, we're just
going to summarily remove it.

While the ability to write as well as read makes this security hole
considerably worse than CVE-2012-3489, the problem is mitigated by the fact
that xslt_process() is not available unless contrib/xml2 is installed,
and the longstanding warnings about security risks from that should have
discouraged prudent DBAs from installing it in security-exposed databases.

Reported and fixed by Peter Eisentraut.

Security: CVE-2012-3488
2012-08-14 18:31:18 -04:00
Bruce Momjian 85642ec00b Prevent pg_upgrade from crashing if it can't write to the current
directory.

Backpatch to 9.2.
2012-08-10 17:14:48 -04:00
Bruce Momjian fbcfa90bb8 Fix pg_upgrade file share violation on Windows created by the commit
4741e9afb9.  This was done by adding an
optional second log file parameter to exec_prog(), and closing and
reopening the log file between system() calls.

Backpatch to 9.2.
2012-08-07 13:10:44 -04:00
Bruce Momjian e8969c4733 In pg_upgrade, use pg_log() instead of prep_status() for
newline-terminated messages, per suggestion from Tom.

Backpatch to 9.2.
2012-08-03 12:43:37 -04:00
Tom Lane 41b9c8452b Replace libpq's "row processor" API with a "single row" mode.
After taking awhile to digest the row-processor feature that was added to
libpq in commit 92785dac2e, we've concluded
it is over-complicated and too hard to use.  Leave the core infrastructure
changes in place (that is, there's still a row processor function inside
libpq), but remove the exposed API pieces, and instead provide a "single
row" mode switch that causes PQgetResult to return one row at a time in
separate PGresult objects.

This approach incurs more overhead than proper use of a row processor
callback would, since construction of a PGresult per row adds extra cycles.
However, it is far easier to use and harder to break.  The single-row mode
still affords applications the primary benefit that the row processor API
was meant to provide, namely not having to accumulate large result sets in
memory before processing them.  Preliminary testing suggests that we can
probably buy back most of the extra cycles by micro-optimizing construction
of the extra results, but that task will be left for another day.

Marko Kreen
2012-08-02 13:10:30 -04:00
Bruce Momjian 4da8fc05f0 Simplify pg_upgrade's handling when returning directory listings.
Backpatch to 9.2.
2012-07-26 06:22:22 -04:00
Robert Haas 46b2b7e0ff Make pgbench vacuum before building indexes.
This is apparently faster than doing things the other way around when
the scale factor is large.

Along the way, adjust -n to suppress vacuuming during initialization
as well as during test runs.

Jeff Janes, with some small changes by me.
2012-07-23 14:42:35 -04:00
Robert Haas 3a0e4d36eb Make new event trigger facility actually do something.
Commit 3855968f32 added syntax, pg_dump,
psql support, and documentation, but the triggers didn't actually fire.
With this commit, they now do.  This is still a pretty basic facility
overall because event triggers do not get a whole lot of information
about what the user is trying to do unless you write them in C; and
there's still no option to fire them anywhere except at the very
beginning of the execution sequence, but it's better than nothing,
and a good building block for future work.

Along the way, add a regression test for ALTER LARGE OBJECT, since
testing of event triggers reveals that we haven't got one.

Dimitri Fontaine and Robert Haas
2012-07-20 11:39:01 -04:00
Tom Lane faf26bf117 Get rid of useless global variable in pg_upgrade.
Since the scandir() emulation was taken out of pg_upgrade, there's
no longer any need for scandir_file_pattern to exist as a global
variable.  Replace it with a local in the one remaining function
that was making use of it.
2012-07-18 01:23:12 -04:00
Tom Lane 3d6ec663bb Improve pg_upgrade's load_directory() function.
Error out on out-of-memory, rather than returning -1, which the sole
existing caller wasn't checking for anyway.  There doesn't seem to be
any use-case for making the caller check for failure here.

Detect failure return from readdir().

Use a less platform-dependent method of calculating the entrysize.
It's possible, but not yet confirmed, that this explains bug #6733,
in which Mike Wilson reports a pg_upgrade crash that did not occur
in 9.1.  (Note that load_directory is effectively new code in 9.2,
at least on platforms that have scandir().)

Fix up comments, avoid uselessly using two counters, reduce the number
of realloc calls to something sane.
2012-07-18 01:13:20 -04:00
Peter Eisentraut dd16f9480a Remove unreachable code
The Solaris Studio compiler warns about these instances, unlike more
mainstream compilers such as gcc.  But manual inspection showed that
the code is clearly not reachable, and we hope no worthy compiler will
complain about removing this code.
2012-07-16 22:15:03 +03:00
Tom Lane a36088bcfa Skip text->binary conversion of unnecessary columns in contrib/file_fdw.
When reading from a text- or CSV-format file in file_fdw, the datatype
input routines can consume a significant fraction of the runtime.
Often, the query does not need all the columns, so we can get a useful
speed boost by skipping I/O conversion for unnecessary columns.

To support this, add a "convert_selectively" option to the core COPY code.
This is undocumented and not accessible from SQL (for now, anyway).

Etsuro Fujita, reviewed by KaiGai Kohei
2012-07-12 16:26:59 -04:00
Bruce Momjian c742d1dbe7 Update pg_upgrade comments for recent configpath fix. 2012-07-06 09:39:22 -04:00
Bruce Momjian 2eeb5eb23f Fix PGDATAOLD and PGDATANEW to properly set pgconfig location, per
report from Tom.

Backpatch to 9.2.
2012-07-05 23:36:43 -04:00
Alvaro Herrera 666d494d19 pg_upgrade: abstract out copying of files from old cluster to new
Currently only pg_clog is copied, but some other directories could need
the same treatment as well, so create a subroutine to do it.

Extracted from my (somewhat larger) FOR KEY SHARE patch.
2012-07-05 11:38:42 -04:00
Bruce Momjian 042d9ffc28 Run newly-configured perltidy script on Perl files.
Run on HEAD and 9.2.
2012-07-04 21:47:49 -04:00
Robert Haas d7c734841b Reduce messages about implicit indexes and sequences to DEBUG1.
Per recent discussion on pgsql-hackers, these messages are too
chatty for most users.
2012-07-04 20:35:29 -04:00
Robert Haas 17676c785a Make oid2name, pgbench, and vacuumlo set fallback_application_name.
Amit Kapila, reviewed by Shigeru Hanada and Peter Eisentraut,
with some modifications by me.
2012-07-04 15:39:33 -04:00
Alvaro Herrera 4741e9afb9 Make the pg_upgrade log files contain actual commands
Now the log file not only contains the output from commands executed by
system(), but also what command it was in the first place.  This
arrangement makes debugging a lot simpler.
2012-06-29 11:39:11 -04:00
Alvaro Herrera 9e26326ad6 pg_upgrade: fix off-by-one mistake in snprintf
snprintf counts trailing NUL towards the char limit.  Failing to account
for that was causing an invalid value to be passed to pg_resetxlog -l,
aborting the upgrade process.
2012-06-28 23:37:27 -04:00
Heikki Linnakangas 038f3a0509 Fix pg_upgrade, broken by the xlogid/segno -> 64-bit int refactoring.
The xlogid + segno representation of a particular WAL segment doesn't make
much sense in pg_resetxlog anymore, now that we don't use that anywhere
else. Use the WAL filename instead, since that's a convenient way to name a
particular WAL segment.

I did this partially for pg_resetxlog in the original xlogid/segno -> uint64
patch, but I neglected pg_upgrade and the docs. This should now be more
complete.
2012-06-26 07:49:02 +03:00
Peter Eisentraut b8b2e3b2de Replace int2/int4 in C code with int16/int32
The latter was already the dominant use, and it's preferable because
in C the convention is that intXX means XX bits.  Therefore, allowing
mixed use of int2, int4, int8, int16, int32 is obviously confusing.

Remove the typedefs for int2 and int4 for now.  They don't seem to be
widely used outside of the PostgreSQL source tree, and the few uses
can probably be cleaned up by the time this ships.
2012-06-25 01:51:46 +03:00
Heikki Linnakangas 0ab9d1c4b3 Replace XLogRecPtr struct with a 64-bit integer.
This simplifies code that needs to do arithmetic on XLogRecPtrs.

To avoid changing on-disk format of data pages, the LSN on data pages is
still stored in the old format. That should keep pg_upgrade happy. However,
we have XLogRecPtrs embedded in the control file, and in the structs that
are sent over the replication protocol, so this changes breaks compatibility
of pg_basebackup and server. I didn't do anything about this in this patch,
per discussion on -hackers, the right thing to do would to be to change the
replication protocol to be architecture-independent, so that you could use
a newer version of pg_receivexlog, for example, against an older server
version.
2012-06-24 19:19:45 +03:00
Robert Haas 47c7365e79 Make pgbench -i emit only one-tenth as many status messages.
These days, even a wimpy system can insert 10000 tuples in the blink of
an eye, so there's no real need for this much verbosity.

Per complaint from Tatsuo Ishii.
2012-06-22 09:03:25 -04:00