summaryrefslogtreecommitdiff
path: root/src/bin/scripts/common.c
AgeCommit message (Collapse)Author
2014-05-06pgindent run for 9.4Bruce Momjian
This includes removing tabs after periods in C comments, which was applied to back branches, so this change should not effect backpatching.
2014-01-07Update copyright for 2014Bruce Momjian
Update all files in head, and files COPYRIGHT and legal.sgml in all back branches.
2013-12-18Fix incorrect error message reported for non-existent usersBruce Momjian
Previously, lookups of non-existent user names could return "Success"; it will now return "User does not exist" by resetting errno. This also centralizes the user name lookup code in libpgport. Report and analysis by Nicolas Marchildon; patch by me
2013-03-17Move pqsignal() to libpgport.Tom Lane
We had two copies of this function in the backend and libpq, which was already pretty bogus, but it turns out that we need it in some other programs that don't use libpq (such as pg_test_fsync). So put it where it probably should have been all along. The signal-mask-initialization support in src/backend/libpq/pqsignal.c stays where it is, though, since we only need that in the backend.
2013-02-12Create libpgcommon, and move pg_malloc et al to itAlvaro 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.
2013-01-01Update copyrights for 2013Bruce Momjian
Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
2012-10-02Work around unportable behavior of malloc(0) and realloc(NULL, 0).Tom Lane
On some platforms these functions return NULL, rather than the more common practice of returning a pointer to a zero-sized block of memory. Hack our various wrapper functions to hide the difference by substituting a size request of 1. This is probably not so important for the callers, who should never touch the block anyway if they asked for size 0 --- but it's important for the wrapper functions themselves, which mistakenly treated the NULL result as an out-of-memory failure. This broke at least pg_dump for the case of no user-defined aggregates, as per report from Matthew Carrington. Back-patch to 9.2 to fix the pg_dump issue. Given the lack of previous complaints, it seems likely that there is no live bug in previous releases, even though some of these functions were in place before that.
2012-10-02Standardize naming of malloc/realloc/strdup wrapper functions.Tom Lane
We had a number of variants on the theme of "malloc or die", with the majority named like "pg_malloc", but by no means all. Standardize on the names pg_malloc, pg_malloc0, pg_realloc, pg_strdup. Get rid of pg_calloc entirely in favor of using pg_malloc0. This is an essentially cosmetic change, so no back-patch. (I did find a couple of places where psql and pg_dump were using plain malloc or strdup instead of the pg_ versions, but they don't look significant enough to bother back-patching.)
2012-06-10Run pgindent on 9.2 source tree in preparation for first 9.3Bruce Momjian
commit-fest.
2012-03-21Improve connectMaintenanceDatabase() error reporting.Robert Haas
The prior coding instructs the user to pick an alternative maintenance database, but this is overly clever, since it obscures whatever the real cause of the failure is. Josh Kupershmidt
2012-01-01Update copyright notices for year 2012.Bruce Momjian
2011-12-06Make command-line tools smarter about finding a DB to connect to.Robert Haas
If unable to connect to "postgres", try "template1". This allows things to work more smoothly in the case where the postgres database has been dropped. And just in case that's not good enough, also allow the user to specify a maintenance database to be used for the initial connection, to cover the case where neither postgres nor template1 is suitable.
2011-09-05Adjust translator comment format to xgettext expectationsAlvaro Herrera
2011-06-29Unify spelling of "canceled", "canceling", "cancellation"Peter Eisentraut
We had previously (af26857a2775e7ceb0916155e931008c2116632f) established the U.S. spellings as standard.
2011-01-01Stamp copyrights for year 2011.Bruce Momjian
2010-09-20Remove cvs keywords from all files.Magnus Hagander
2010-02-26pgindent run for 9.0Bruce Momjian
2010-02-05Modify recently added PQconnectdbParams() with new argument, expand_dbname.Joe Conway
If expand_dbname is non-zero and dbname contains an = sign, it is taken as a conninfo string in exactly the same way as if it had been passed to PQconnectdb. This is equivalent to the way PQsetdbLogin() works, allowing PQconnectdbParams() to be a complete alternative. Also improve the way the new function is called from psql and replace a previously missed call to PQsetdbLogin() in psql. Additionally use PQconnectdbParams() for pg_dump and friends, and the bin/scripts command line utilities such as vacuumdb, createdb, etc. Finally, update the documentation for the new parameter, as well as the nuances of precedence in cases where key words are repeated or duplicated in the conninfo string.
2010-01-02Update copyright for the year 2010.Bruce Momjian
2009-06-118.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian
provided by Andrew.
2009-04-05Remove a boatload of useless definitions of 'int optreset'. If weTom Lane
are using our own ports of getopt or getopt_long, those will define the variable for themselves; and if not, we don't need these, because we never touch the variable anyway.
2009-02-26Add a -w/--no-password option that prevents all password prompts to allPeter Eisentraut
programs that have a -W/--password option. In passing, remove the ancient PSQL_ALWAYS_GET_PASSWORDS compile option.
2009-02-25Remove feof(stdin) calls related to when to prompt for a password,Peter Eisentraut
leftovers from when the password was read from stdin.
2009-01-01Update copyright for 2009.Bruce Momjian
2008-05-12Improve psql's internal print.c code by introducing an actual print API.Alvaro Herrera
Provides for better code readability, but mainly this is infrastructure changes to allow further changes such as arbitrary footers on printed tables. Also, the translation status of each element in the table is more easily customized. Brendan Jurd, with some editorialization by me.
2008-01-01Update copyrights in source tree to 2008.Bruce Momjian
2007-12-09Fix up the PQconnectionUsedPassword mess: create a separateTom Lane
PQconnectionNeedsPassword function that tells the right thing for whether to prompt for a password, and improve PQconnectionUsedPassword so that it checks whether the password used by the connection was actually supplied as a connection argument, instead of coming from environment or a password file. Per bug report from Mark Cave-Ayland and subsequent discussion.
2007-11-15pgindent run for 8.3.Bruce Momjian
2007-09-25Small string tweaksPeter Eisentraut
2007-07-08Get rid of client-code dependencies on the exact text of the no-passwordTom Lane
error message, by using PQconnectionUsedPassword() instead. Someday we might be able to localize that error message, but not until this coding technique has disappeared everywhere.
2007-04-09Add cancel handlers so it's possible to Ctrl-C clusterdb, reindexdbMagnus Hagander
and vacuumdb. ITAGAKI Takahiro, with minor fixes from me.
2007-01-05Update CVS HEAD for 2007 copyright. Back branches are typically notBruce Momjian
back-stamped for this.
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-10-03Fix yesno_prompt() memory leak in /script tools, reported by Converity.Bruce Momjian
2006-09-22Surely this temp buffer needn't be static.Tom Lane
2006-09-22Rearrange yes/no prompting code so that the prompts always show thePeter Eisentraut
(possibly (un)translated) letters that are actually expected as input. Also reject invalid responses instead of silenty taken them as "no". with help from Bernd Helmle
2006-03-05Update copyright for 2006. Update scripts.Bruce Momjian
2005-10-15Standard pgindent run for 8.1.Bruce Momjian
2005-08-15Make createlang and droplang proof against weird search_path settingsTom Lane
by forcing search_path to be just pg_catalog.
2005-02-22Use _() macro consistently rather than gettext(). Add translationBruce Momjian
macros around strings that were missing them.
2005-01-08Consistently use geteuid() not getuid(); there were a few places deviatingTom Lane
from our long-established standard.
2004-12-31Tag appropriate files for rc3PostgreSQL Daemon
Also performed an initial run through of upgrading our Copyright date to extend to 2005 ... first run here was very simple ... change everything where: grep 1996-2004 && the word 'Copyright' ... scanned through the generated list with 'less' first, and after, to make sure that I only picked up the right entries ...
2004-12-12Add missing newlines at end of error messages.Peter Eisentraut
2004-11-09Get rid of perror(), substitute some better phrased error messages.Peter Eisentraut
malloc() doesn't set errno, so most uses were buggy anyway.
2004-10-16Allow pg_ctl to determine the server is up when getting a request for aBruce Momjian
password. Make password error message a #define and use it consistently. Sean Chittenden
2004-08-29Pgindent run for 8.0.Bruce Momjian
2004-08-29Update copyright to 2004.Bruce Momjian
2004-06-01Remove init_nls() functions, call set_pglocale() directly.Bruce Momjian
Add locale to pg_ctl.c.
2004-05-25Make the locale location relocatable.Bruce Momjian
Adjust get_*_path functions to be limited to MAXPGPATH.
2004-04-19* Most changes are to fix warnings issued when compiling win32Bruce Momjian
* removed a few redundant defines * get_user_name safe under win32 * rationalized pipe read EOF for win32 (UPDATED PATCH USED) * changed all backend instances of sleep() to pg_usleep - except for the SLEEP_ON_ASSERT in assert.c, as it would exceed a 32-bit long [Note to patcher: If a SLEEP_ON_ASSERT of 2000 seconds is acceptable, please replace with pg_usleep(2000000000L)] I added a comment to that part of the code: /* * It would be nice to use pg_usleep() here, but only does 2000 sec * or 33 minutes, which seems too short. */ sleep(1000000); Claudio Natoli