diff options
author | Kevin Grittner | 2011-09-24 16:15:45 +0000 |
---|---|---|
committer | Kevin Grittner | 2011-09-24 16:15:45 +0000 |
commit | af8d5448f8be9c3f5fb030ac94509629cccab09b (patch) | |
tree | 57533e96b2317c49aaa418632ec49046ce0c93a5 | |
parent | bb08357723c3188d73f3eca170987d4d7af58635 (diff) | |
parent | 337c0b03614c45516f2c3ec956405713bb264d54 (diff) |
Merge branch 'master' into serializableserializable
49 files changed, 2713 insertions, 89 deletions
diff --git a/contrib/sepgsql/Makefile b/contrib/sepgsql/Makefile index c83b2e3cef..033c41a819 100644 --- a/contrib/sepgsql/Makefile +++ b/contrib/sepgsql/Makefile @@ -2,7 +2,7 @@ MODULE_big = sepgsql OBJS = hooks.o selinux.o uavc.o label.o dml.o \ - schema.o relation.o proc.o + database.o schema.o relation.o proc.o DATA_built = sepgsql.sql REGRESS = label dml misc diff --git a/contrib/sepgsql/chkselinuxenv b/contrib/sepgsql/chkselinuxenv index a9425de88e..a7c81b2fc8 100755 --- a/contrib/sepgsql/chkselinuxenv +++ b/contrib/sepgsql/chkselinuxenv @@ -127,7 +127,7 @@ if [ "${POLICY_STATUS}" != "on" ]; then echo "turned on in order to enable the rules necessary to run the" echo "regression tests." echo "" - if "${POLICY_STATUS}" = ""; then + if [ "${POLICY_STATUS}" = "" ]; then echo "We attempted to determine the state of this Boolean using" echo "'getsebool', but that command did not produce the expected" echo "output. Please verify that getsebool is available and in" diff --git a/contrib/sepgsql/database.c b/contrib/sepgsql/database.c new file mode 100644 index 0000000000..7f15d9ce71 --- /dev/null +++ b/contrib/sepgsql/database.c @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------------- + * + * contrib/sepgsql/database.c + * + * Routines corresponding to database objects + * + * Copyright (c) 2010-2011, PostgreSQL Global Development Group + * + * ------------------------------------------------------------------------- + */ +#include "postgres.h" + +#include "catalog/dependency.h" +#include "catalog/pg_database.h" +#include "commands/seclabel.h" +#include "sepgsql.h" + +void +sepgsql_database_post_create(Oid databaseId) +{ + char *scontext = sepgsql_get_client_label(); + char *tcontext; + char *ncontext; + ObjectAddress object; + + /* + * Compute a default security label of the newly created database + * based on a pair of security label of client and source database. + * + * XXX - Right now, this logic uses "template1" as its source, because + * here is no way to know the Oid of source database. + */ + object.classId = DatabaseRelationId; + object.objectId = TemplateDbOid; + object.objectSubId = 0; + tcontext = GetSecurityLabel(&object, SEPGSQL_LABEL_TAG); + + ncontext = sepgsql_compute_create(scontext, tcontext, + SEPG_CLASS_DB_DATABASE); + + /* + * Assign the default security label on the new database + */ + object.classId = DatabaseRelationId; + object.objectId = databaseId; + object.objectSubId = 0; + + SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, ncontext); + + pfree(ncontext); + pfree(tcontext); +} + +/* + * sepgsql_database_relabel + * + * It checks privileges to relabel the supplied database with the `seclabel' + */ +void +sepgsql_database_relabel(Oid databaseId, const char *seclabel) +{ + ObjectAddress object; + char *audit_name; + + object.classId = DatabaseRelationId; + object.objectId = databaseId; + object.objectSubId = 0; + audit_name = getObjectDescription(&object); + + /* + * check db_database:{setattr relabelfrom} permission + */ + sepgsql_avc_check_perms(&object, + SEPG_CLASS_DB_DATABASE, + SEPG_DB_DATABASE__SETATTR | + SEPG_DB_DATABASE__RELABELFROM, + audit_name, + true); + /* + * check db_database:{relabelto} permission + */ + sepgsql_avc_check_perms_label(seclabel, + SEPG_CLASS_DB_DATABASE, + SEPG_DB_DATABASE__RELABELTO, + audit_name, + true); + pfree(audit_name); +} diff --git a/contrib/sepgsql/hooks.c b/contrib/sepgsql/hooks.c index ca6ce99808..331bbd7e78 100644 --- a/contrib/sepgsql/hooks.c +++ b/contrib/sepgsql/hooks.c @@ -12,6 +12,7 @@ #include "catalog/objectaccess.h" #include "catalog/pg_class.h" +#include "catalog/pg_database.h" #include "catalog/pg_namespace.h" #include "catalog/pg_proc.h" #include "commands/seclabel.h" @@ -125,6 +126,10 @@ sepgsql_object_access(ObjectAccessType access, case OAT_POST_CREATE: switch (classId) { + case DatabaseRelationId: + sepgsql_database_post_create(objectId); + break; + case NamespaceRelationId: sepgsql_schema_post_create(objectId); break; diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c index 669ee35ac3..a2bf57151e 100644 --- a/contrib/sepgsql/label.c +++ b/contrib/sepgsql/label.c @@ -17,6 +17,7 @@ #include "catalog/indexing.h" #include "catalog/pg_attribute.h" #include "catalog/pg_class.h" +#include "catalog/pg_database.h" #include "catalog/pg_namespace.h" #include "catalog/pg_proc.h" #include "commands/dbcommands.h" @@ -121,9 +122,14 @@ sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel) */ switch (object->classId) { + case DatabaseRelationId: + sepgsql_database_relabel(object->objectId, seclabel); + break; + case NamespaceRelationId: sepgsql_schema_relabel(object->objectId, seclabel); break; + case RelationRelationId: if (object->objectSubId == 0) sepgsql_relation_relabel(object->objectId, @@ -133,6 +139,7 @@ sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel) object->objectSubId, seclabel); break; + case ProcedureRelationId: sepgsql_proc_relabel(object->objectId, seclabel); break; @@ -315,6 +322,7 @@ exec_object_restorecon(struct selabel_handle * sehnd, Oid catalogId) SnapshotNow, 0, NULL); while (HeapTupleIsValid(tuple = systable_getnext(sscan))) { + Form_pg_database datForm; Form_pg_namespace nspForm; Form_pg_class relForm; Form_pg_attribute attForm; @@ -330,6 +338,19 @@ exec_object_restorecon(struct selabel_handle * sehnd, Oid catalogId) */ switch (catalogId) { + case DatabaseRelationId: + datForm = (Form_pg_database) GETSTRUCT(tuple); + + objtype = SELABEL_DB_DATABASE; + + objname = quote_object_name(NameStr(datForm->datname), + NULL, NULL, NULL); + + object.classId = DatabaseRelationId; + object.objectId = HeapTupleGetOid(tuple); + object.objectSubId = 0; + break; + case NamespaceRelationId: nspForm = (Form_pg_namespace) GETSTRUCT(tuple); @@ -506,10 +527,7 @@ sepgsql_restorecon(PG_FUNCTION_ARGS) errmsg("SELinux: failed to initialize labeling handle: %m"))); PG_TRY(); { - /* - * Right now, we have no support labeling on the shared database - * objects, such as database, role, or tablespace. - */ + exec_object_restorecon(sehnd, DatabaseRelationId); exec_object_restorecon(sehnd, NamespaceRelationId); exec_object_restorecon(sehnd, RelationRelationId); exec_object_restorecon(sehnd, AttributeRelationId); diff --git a/contrib/sepgsql/schema.c b/contrib/sepgsql/schema.c index aae68ef964..a167be17b2 100644 --- a/contrib/sepgsql/schema.c +++ b/contrib/sepgsql/schema.c @@ -11,8 +11,10 @@ #include "postgres.h" #include "catalog/dependency.h" +#include "catalog/pg_database.h" #include "catalog/pg_namespace.h" #include "commands/seclabel.h" +#include "miscadmin.h" #include "utils/lsyscache.h" #include "sepgsql.h" @@ -26,22 +28,17 @@ void sepgsql_schema_post_create(Oid namespaceId) { - char *scontext = sepgsql_get_client_label(); + char *scontext; char *tcontext; char *ncontext; ObjectAddress object; /* - * FIXME: Right now, we assume pg_database object has a fixed security - * label, because pg_seclabel does not support to store label of shared - * database objects. - */ - tcontext = "system_u:object_r:sepgsql_db_t:s0"; - - /* * Compute a default security label when we create a new schema object * under the working database. */ + scontext = sepgsql_get_client_label(); + tcontext = sepgsql_get_label(DatabaseRelationId, MyDatabaseId, 0); ncontext = sepgsql_compute_create(scontext, tcontext, SEPG_CLASS_DB_SCHEMA); @@ -54,6 +51,7 @@ sepgsql_schema_post_create(Oid namespaceId) SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, ncontext); pfree(ncontext); + pfree(tcontext); } /* diff --git a/contrib/sepgsql/sepgsql.h b/contrib/sepgsql/sepgsql.h index 35b500c3ff..b4c1dfdfe7 100644 --- a/contrib/sepgsql/sepgsql.h +++ b/contrib/sepgsql/sepgsql.h @@ -284,6 +284,12 @@ extern Datum sepgsql_restorecon(PG_FUNCTION_ARGS); extern bool sepgsql_dml_privileges(List *rangeTabls, bool abort); /* + * database.c + */ +extern void sepgsql_database_post_create(Oid databaseId); +extern void sepgsql_database_relabel(Oid databaseId, const char *seclabel); + +/* * schema.c */ extern void sepgsql_schema_post_create(Oid namespaceId); diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index f95f9cc8bd..fd4be5d74a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1537,7 +1537,7 @@ SET ENABLE_SEQSCAN TO OFF; </varlistentry> <varlistentry id="guc-synchronous-commit" xreflabel="synchronous_commit"> - <term><varname>synchronous_commit</varname> (<type>boolean</type>)</term> + <term><varname>synchronous_commit</varname> (<type>enum</type>)</term> <indexterm> <primary><varname>synchronous_commit</> configuration parameter</primary> </indexterm> diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml index bc2ed012f4..f96b174fcc 100644 --- a/doc/src/sgml/install-windows.sgml +++ b/doc/src/sgml/install-windows.sgml @@ -20,7 +20,7 @@ There are several different ways of building PostgreSQL on <productname>Windows</productname>. The simplest way to build with Microsoft tools is to install a supported version of the - <productname>Microsoft Platform SDK</productname> and use use the included + <productname>Microsoft Platform SDK</productname> and use the included compiler. It is also possible to build with the full <productname>Microsoft Visual C++ 2005 or 2008</productname>. In some cases that requires the installation of the <productname>Platform SDK</productname> diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 163a893fb9..48689a7df2 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -420,7 +420,9 @@ PGconn *PQconnectdbParams(const char **keywords, const char **values, int expand <term><literal>require</literal></term> <listitem> <para> - only try an <acronym>SSL</> connection + only try an <acronym>SSL</> connection. If a root CA + file is present, verify the certificate in the same way as + if <literal>verify-ca</literal> was specified </para> </listitem> </varlistentry> @@ -6732,6 +6734,18 @@ ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*) the connection parameters <literal>sslrootcert</> and <literal>sslcrl</> or the environment variables <envar>PGSSLROOTCERT</> and <envar>PGSSLCRL</>. </para> + + <note> + <para> + For backwards compatibility with earlier versions of PostgreSQL, if a + root CA file exists, the behavior of + <literal>sslmode</literal>=<literal>require</literal> will be the same + as that of <literal>verify-ca</literal>, meaning the sever certificate + is validated against the CA. Relying on this behavior is discouraged, + and applications that need certificate validation should always use + <literal>validate-ca</literal> or <literal>validate-full</literal>. + </para> + </note> </sect2> <sect2 id="libpq-ssl-clientcert"> diff --git a/doc/src/sgml/ref/createuser.sgml b/doc/src/sgml/ref/createuser.sgml index 0c47fb4997..4cbfd69148 100644 --- a/doc/src/sgml/ref/createuser.sgml +++ b/doc/src/sgml/ref/createuser.sgml @@ -241,6 +241,28 @@ PostgreSQL documentation </varlistentry> <varlistentry> + <term><option>--replication</></term> + <listitem> + <para> + The new user will have the REPLICATION privilege, which is + described more fully in the documentation for + <xref linkend="sql-createrole">. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--no-replication</></term> + <listitem> + <para> + The new user will not have the REPLICATION privilege, which is + described more fully in the documentation for + <xref linkend="sql-createrole">. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>-V</></term> <term><option>--version</></term> <listitem> diff --git a/doc/src/sgml/release-8.2.sgml b/doc/src/sgml/release-8.2.sgml index 2ab644fa3f..39bf5da2c9 100644 --- a/doc/src/sgml/release-8.2.sgml +++ b/doc/src/sgml/release-8.2.sgml @@ -1,6 +1,313 @@ <!-- doc/src/sgml/release-8.2.sgml --> <!-- See header comment in release.sgml about typical markup --> + <sect1 id="release-8-2-22"> + <title>Release 8.2.22</title> + + <note> + <title>Release Date</title> + <simpara>2011-09-26</simpara> + </note> + + <para> + This release contains a variety of fixes from 8.2.21. + For information about new features in the 8.2 major release, see + <xref linkend="release-8-2">. + </para> + + <para> + The <productname>PostgreSQL</> community will stop releasing updates + for the 8.2.X release series in December 2011. + Users are encouraged to update to a newer release branch soon. + </para> + + <sect2> + <title>Migration to Version 8.2.22</title> + + <para> + A dump/restore is not required for those running 8.2.X. + However, if you are upgrading from a version earlier than 8.2.14, + see the release notes for 8.2.14. + </para> + + </sect2> + + <sect2> + <title>Changes</title> + + <itemizedlist> + + <listitem> + <para> + Fix multiple bugs in GiST index page split processing (Heikki + Linnakangas) + </para> + + <para> + The probability of occurrence was low, but these could lead to index + corruption. + </para> + </listitem> + + <listitem> + <para> + Avoid possibly accessing off the end of memory in <command>ANALYZE</> + (Noah Misch) + </para> + + <para> + This fixes a very-low-probability server crash scenario. + </para> + </listitem> + + <listitem> + <para> + Fix race condition in relcache init file invalidation (Tom Lane) + </para> + + <para> + There was a window wherein a new backend process could read a stale init + file but miss the inval messages that would tell it the data is stale. + The result would be bizarre failures in catalog accesses, typically + <quote>could not read block 0 in file ...</> later during startup. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak at end of a GiST index scan (Tom Lane) + </para> + + <para> + Commands that perform many separate GiST index scans, such as + verification of a new GiST-based exclusion constraint on a table + already containing many rows, could transiently require large amounts of + memory due to this leak. + </para> + </listitem> + + <listitem> + <para> + Fix performance problem when constructing a large, lossy bitmap + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix array- and path-creating functions to ensure padding bytes are + zeroes (Tom Lane) + </para> + + <para> + This avoids some situations where the planner will think that + semantically-equal constants are not equal, resulting in poor + optimization. + </para> + </listitem> + + <listitem> + <para> + Work around gcc 4.6.0 bug that breaks WAL replay (Tom Lane) + </para> + + <para> + This could lead to loss of committed transactions after a server crash. + </para> + </listitem> + + <listitem> + <para> + Fix dump bug for <literal>VALUES</> in a view (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Disallow <literal>SELECT FOR UPDATE/SHARE</> on sequences (Tom Lane) + </para> + + <para> + This operation doesn't work as expected and can lead to failures. + </para> + </listitem> + + <listitem> + <para> + Defend against integer overflow when computing size of a hash table (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Fix portability bugs in use of credentials control messages for + <quote>peer</> authentication (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix typo in <function>pg_srand48</> seed initialization (Andres Freund) + </para> + + <para> + This led to failure to use all bits of the provided seed. This function + is not used on most platforms (only those without <function>srandom</>), + and the potential security exposure from a less-random-than-expected + seed seems minimal in any case. + </para> + </listitem> + + <listitem> + <para> + Avoid integer overflow when the sum of <literal>LIMIT</> and + <literal>OFFSET</> values exceeds 2^63 (Heikki Linnakangas) + </para> + </listitem> + + <listitem> + <para> + Add overflow checks to <type>int4</> and <type>int8</> versions of + <function>generate_series()</> (Robert Haas) + </para> + </listitem> + + <listitem> + <para> + Fix trailing-zero removal in <function>to_char()</> (Marti Raudsepp) + </para> + + <para> + In a format with <literal>FM</> and no digit positions + after the decimal point, zeroes to the left of the decimal point could + be removed incorrectly. + </para> + </listitem> + + <listitem> + <para> + Fix <function>pg_size_pretty()</> to avoid overflow for inputs close to + 2^63 (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix <application>psql</>'s counting of script file line numbers during + <literal>COPY</> from a different file (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix <application>pg_restore</>'s direct-to-database mode for + <varname>standard_conforming_strings</> (Tom Lane) + </para> + + <para> + <application>pg_restore</> could emit incorrect commands when restoring + directly to a database server from an archive file that had been made + with <varname>standard_conforming_strings</> set to <literal>on</>. + </para> + </listitem> + + <listitem> + <para> + Fix write-past-buffer-end and memory leak in <application>libpq</>'s + LDAP service lookup code (Albe Laurenz) + </para> + </listitem> + + <listitem> + <para> + In <application>libpq</>, avoid failures when using nonblocking I/O + and an SSL connection (Martin Pihlak, Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Improve libpq's handling of failures during connection startup + (Tom Lane) + </para> + + <para> + In particular, the response to a server report of <function>fork()</> + failure during SSL connection startup is now saner. + </para> + </listitem> + + <listitem> + <para> + Make <application>ecpglib</> write <type>double</> values with 15 digits + precision (Akira Kurosawa) + </para> + </listitem> + + <listitem> + <para> + Apply upstream fix for blowfish signed-character bug (CVE-2011-2483) + (Tom Lane) + </para> + + <para> + <filename>contrib/pg_crypto</>'s blowfish encryption code could give + wrong results on platforms where char is signed (which is most), + leading to encrypted passwords being weaker than they should be. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak in <filename>contrib/seg</> (Heikki Linnakangas) + </para> + </listitem> + + <listitem> + <para> + Fix <function>pgstatindex()</> to give consistent results for empty + indexes (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Allow building with perl 5.14 (Alex Hunsaker) + </para> + </listitem> + + <listitem> + <para> + Update configure script's method for probing existence of system + functions (Tom Lane) + </para> + + <para> + The version of autoconf we used in 8.3 and 8.2 could be fooled by + compilers that perform link-time optimization. + </para> + </listitem> + + <listitem> + <para> + Fix assorted issues with build and install file paths containing spaces + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Update time zone data files to <application>tzdata</> release 2011i + for DST law changes in Canada, Egypt, Russia, Samoa, and South Sudan. + </para> + </listitem> + + </itemizedlist> + + </sect2> + </sect1> + <sect1 id="release-8-2-21"> <title>Release 8.2.21</title> diff --git a/doc/src/sgml/release-8.3.sgml b/doc/src/sgml/release-8.3.sgml index 7db9d6bcb0..9b80900353 100644 --- a/doc/src/sgml/release-8.3.sgml +++ b/doc/src/sgml/release-8.3.sgml @@ -1,6 +1,377 @@ <!-- doc/src/sgml/release-8.3.sgml --> <!-- See header comment in release.sgml about typical markup --> + <sect1 id="release-8-3-16"> + <title>Release 8.3.16</title> + + <note> + <title>Release Date</title> + <simpara>2011-09-26</simpara> + </note> + + <para> + This release contains a variety of fixes from 8.3.15. + For information about new features in the 8.3 major release, see + <xref linkend="release-8-3">. + </para> + + <sect2> + <title>Migration to Version 8.3.16</title> + + <para> + A dump/restore is not required for those running 8.3.X. + However, if you are upgrading from a version earlier than 8.3.8, + see the release notes for 8.3.8. + </para> + + </sect2> + + <sect2> + <title>Changes</title> + + <itemizedlist> + + <listitem> + <para> + Fix bugs in indexing of in-doubt HOT-updated tuples (Tom Lane) + </para> + + <para> + These bugs could result in index corruption after reindexing a system + catalog. They are not believed to affect user indexes. + </para> + </listitem> + + <listitem> + <para> + Fix multiple bugs in GiST index page split processing (Heikki + Linnakangas) + </para> + + <para> + The probability of occurrence was low, but these could lead to index + corruption. + </para> + </listitem> + + <listitem> + <para> + Fix possible buffer overrun in <function>tsvector_concat()</> + (Tom Lane) + </para> + + <para> + The function could underestimate the amount of memory needed for its + result, leading to server crashes. + </para> + </listitem> + + <listitem> + <para> + Fix crash in <function>xml_recv</> when processing a + <quote>standalone</> parameter (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Avoid possibly accessing off the end of memory in <command>ANALYZE</> + and in SJIS-2004 encoding conversion (Noah Misch) + </para> + + <para> + This fixes some very-low-probability server crash scenarios. + </para> + </listitem> + + <listitem> + <para> + Fix race condition in relcache init file invalidation (Tom Lane) + </para> + + <para> + There was a window wherein a new backend process could read a stale init + file but miss the inval messages that would tell it the data is stale. + The result would be bizarre failures in catalog accesses, typically + <quote>could not read block 0 in file ...</> later during startup. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak at end of a GiST index scan (Tom Lane) + </para> + + <para> + Commands that perform many separate GiST index scans, such as + verification of a new GiST-based exclusion constraint on a table + already containing many rows, could transiently require large amounts of + memory due to this leak. + </para> + </listitem> + + <listitem> + <para> + Fix performance problem when constructing a large, lossy bitmap + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix array- and path-creating functions to ensure padding bytes are + zeroes (Tom Lane) + </para> + + <para> + This avoids some situations where the planner will think that + semantically-equal constants are not equal, resulting in poor + optimization. + </para> + </listitem> + + <listitem> + <para> + Work around gcc 4.6.0 bug that breaks WAL replay (Tom Lane) + </para> + + <para> + This could lead to loss of committed transactions after a server crash. + </para> + </listitem> + + <listitem> + <para> + Fix dump bug for <literal>VALUES</> in a view (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Disallow <literal>SELECT FOR UPDATE/SHARE</> on sequences (Tom Lane) + </para> + + <para> + This operation doesn't work as expected and can lead to failures. + </para> + </listitem> + + <listitem> + <para> + Defend against integer overflow when computing size of a hash table (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Fix cases where <command>CLUSTER</> might attempt to access + already-removed TOAST data (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix portability bugs in use of credentials control messages for + <quote>peer</> authentication (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix SSPI login when multiple roundtrips are required (Ahmed Shinwari, + Magnus Hagander) + </para> + + <para> + The typical symptom of this problem was <quote>The function requested is + not supported</> errors during SSPI login. + </para> + </listitem> + + <listitem> + <para> + Fix typo in <function>pg_srand48</> seed initialization (Andres Freund) + </para> + + <para> + This led to failure to use all bits of the provided seed. This function + is not used on most platforms (only those without <function>srandom</>), + and the potential security exposure from a less-random-than-expected + seed seems minimal in any case. + </para> + </listitem> + + <listitem> + <para> + Avoid integer overflow when the sum of <literal>LIMIT</> and + <literal>OFFSET</> values exceeds 2^63 (Heikki Linnakangas) + </para> + </listitem> + + <listitem> + <para> + Add overflow checks to <type>int4</> and <type>int8</> versions of + <function>generate_series()</> (Robert Haas) + </para> + </listitem> + + <listitem> + <para> + Fix trailing-zero removal in <function>to_char()</> (Marti Raudsepp) + </para> + + <para> + In a format with <literal>FM</> and no digit positions + after the decimal point, zeroes to the left of the decimal point could + be removed incorrectly. + </para> + </listitem> + + <listitem> + <para> + Fix <function>pg_size_pretty()</> to avoid overflow for inputs close to + 2^63 (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + In <application>pg_ctl</>, support silent mode for service registrations + on Windows (MauMau) + </para> + </listitem> + + <listitem> + <para> + Fix <application>psql</>'s counting of script file line numbers during + <literal>COPY</> from a different file (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix <application>pg_restore</>'s direct-to-database mode for + <varname>standard_conforming_strings</> (Tom Lane) + </para> + + <para> + <application>pg_restore</> could emit incorrect commands when restoring + directly to a database server from an archive file that had been made + with <varname>standard_conforming_strings</> set to <literal>on</>. + </para> + </listitem> + + <listitem> + <para> + Fix write-past-buffer-end and memory leak in <application>libpq</>'s + LDAP service lookup code (Albe Laurenz) + </para> + </listitem> + + <listitem> + <para> + In <application>libpq</>, avoid failures when using nonblocking I/O + and an SSL connection (Martin Pihlak, Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Improve libpq's handling of failures during connection startup + (Tom Lane) + </para> + + <para> + In particular, the response to a server report of <function>fork()</> + failure during SSL connection startup is now saner. + </para> + </listitem> + + <listitem> + <para> + Improve <application>libpq</>'s error reporting for SSL failures (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Make <application>ecpglib</> write <type>double</> values with 15 digits + precision (Akira Kurosawa) + </para> + </listitem> + + <listitem> + <para> + In <application>ecpglib</>, be sure <literal>LC_NUMERIC</> setting is + restored after an error (Michael Meskes) + </para> + </listitem> + + <listitem> + <para> + Apply upstream fix for blowfish signed-character bug (CVE-2011-2483) + (Tom Lane) + </para> + + <para> + <filename>contrib/pg_crypto</>'s blowfish encryption code could give + wrong results on platforms where char is signed (which is most), + leading to encrypted passwords being weaker than they should be. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak in <filename>contrib/seg</> (Heikki Linnakangas) + </para> + </listitem> + + <listitem> + <para> + Fix <function>pgstatindex()</> to give consistent results for empty + indexes (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Allow building with perl 5.14 (Alex Hunsaker) + </para> + </listitem> + + <listitem> + <para> + Update configure script's method for probing existence of system + functions (Tom Lane) + </para> + + <para> + The version of autoconf we used in 8.3 and 8.2 could be fooled by + compilers that perform link-time optimization. + </para> + </listitem> + + <listitem> + <para> + Fix assorted issues with build and install file paths containing spaces + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Update time zone data files to <application>tzdata</> release 2011i + for DST law changes in Canada, Egypt, Russia, Samoa, and South Sudan. + </para> + </listitem> + + </itemizedlist> + + </sect2> + </sect1> + <sect1 id="release-8-3-15"> <title>Release 8.3.15</title> diff --git a/doc/src/sgml/release-8.4.sgml b/doc/src/sgml/release-8.4.sgml index 27e4e2902d..90feb0ecc6 100644 --- a/doc/src/sgml/release-8.4.sgml +++ b/doc/src/sgml/release-8.4.sgml @@ -1,6 +1,531 @@ <!-- doc/src/sgml/release-8.4.sgml --> <!-- See header comment in release.sgml about typical markup --> + <sect1 id="release-8-4-9"> + <title>Release 8.4.9</title> + + <note> + <title>Release Date</title> + <simpara>2011-09-26</simpara> + </note> + + <para> + This release contains a variety of fixes from 8.4.8. + For information about new features in the 8.4 major release, see + <xref linkend="release-8-4">. + </para> + + <sect2> + <title>Migration to Version 8.4.9</title> + + <para> + A dump/restore is not required for those running 8.4.X. + </para> + + <para> + However, if you are upgrading from a version earlier than 8.4.8, + see the release notes for 8.4.8. + </para> + + </sect2> + + <sect2> + <title>Changes</title> + + <itemizedlist> + + <listitem> + <para> + Fix bugs in indexing of in-doubt HOT-updated tuples (Tom Lane) + </para> + + <para> + These bugs could result in index corruption after reindexing a system + catalog. They are not believed to affect user indexes. + </para> + </listitem> + + <listitem> + <para> + Fix multiple bugs in GiST index page split processing (Heikki + Linnakangas) + </para> + + <para> + The probability of occurrence was low, but these could lead to index + corruption. + </para> + </listitem> + + <listitem> + <para> + Fix possible buffer overrun in <function>tsvector_concat()</> + (Tom Lane) + </para> + + <para> + The function could underestimate the amount of memory needed for its + result, leading to server crashes. + </para> + </listitem> + + <listitem> + <para> + Fix crash in <function>xml_recv</> when processing a + <quote>standalone</> parameter (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Make <function>pg_options_to_table</> return NULL for an option with no + value (Tom Lane) + </para> + + <para> + Previously such cases would result in a server crash. + </para> + </listitem> + + <listitem> + <para> + Avoid possibly accessing off the end of memory in <command>ANALYZE</> + and in SJIS-2004 encoding conversion (Noah Misch) + </para> + + <para> + This fixes some very-low-probability server crash scenarios. + </para> + </listitem> + + <listitem> + <para> + Prevent intermittent hang in interactions of startup process with + bgwriter process (Simon Riggs) + </para> + + <para> + This affected recovery in non-hot-standby cases. + </para> + </listitem> + + <listitem> + <para> + Fix race condition in relcache init file invalidation (Tom Lane) + </para> + + <para> + There was a window wherein a new backend process could read a stale init + file but miss the inval messages that would tell it the data is stale. + The result would be bizarre failures in catalog accesses, typically + <quote>could not read block 0 in file ...</> later during startup. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak at end of a GiST index scan (Tom Lane) + </para> + + <para> + Commands that perform many separate GiST index scans, such as + verification of a new GiST-based exclusion constraint on a table + already containing many rows, could transiently require large amounts of + memory due to this leak. + </para> + </listitem> + + <listitem> + <para> + Fix incorrect memory accounting (leading to possible memory bloat) in + tuplestores supporting holdable cursors and plpgsql's <literal>RETURN + NEXT</> command (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix performance problem when constructing a large, lossy bitmap + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix join selectivity estimation for unique columns (Tom Lane) + </para> + + <para> + This fixes an erroneous planner heuristic that could lead to poor + estimates of the result size of a join. + </para> + </listitem> + + <listitem> + <para> + Fix nested PlaceHolderVar expressions that appear only in sub-select + target lists (Tom Lane) + </para> + + <para> + This mistake could result in outputs of an outer join incorrectly + appearing as NULL. + </para> + </listitem> + + <listitem> + <para> + Allow nested <literal>EXISTS</> queries to be optimized properly (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Fix array- and path-creating functions to ensure padding bytes are + zeroes (Tom Lane) + </para> + + <para> + This avoids some situations where the planner will think that + semantically-equal constants are not equal, resulting in poor + optimization. + </para> + </listitem> + + <listitem> + <para> + Fix <command>EXPLAIN</> to handle gating Result nodes within + inner-indexscan subplans (Tom Lane) + </para> + + <para> + The usual symptom of this oversight was <quote>bogus varno</> errors. + </para> + </listitem> + + <listitem> + <para> + Work around gcc 4.6.0 bug that breaks WAL replay (Tom Lane) + </para> + + <para> + This could lead to loss of committed transactions after a server crash. + </para> + </listitem> + + <listitem> + <para> + Fix dump bug for <literal>VALUES</> in a view (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Disallow <literal>SELECT FOR UPDATE/SHARE</> on sequences (Tom Lane) + </para> + + <para> + This operation doesn't work as expected and can lead to failures. + </para> + </listitem> + + <listitem> + <para> + Fix <command>VACUUM</> so that it always updates + <literal>pg_class</>.<literal>reltuples</>/<literal>relpages</> (Tom + Lane) + </para> + + <para> + This fixes some scenarios where autovacuum could make increasingly poor + decisions about when to vacuum tables. + </para> + </listitem> + + <listitem> + <para> + Defend against integer overflow when computing size of a hash table (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Fix cases where <command>CLUSTER</> might attempt to access + already-removed TOAST data (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix portability bugs in use of credentials control messages for + <quote>peer</> authentication (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix SSPI login when multiple roundtrips are required (Ahmed Shinwari, + Magnus Hagander) + </para> + + <para> + The typical symptom of this problem was <quote>The function requested is + not supported</> errors during SSPI login. + </para> + </listitem> + + <listitem> + <para> + Throw an error if <filename>pg_hba.conf</> contains <literal>hostssl</> + but SSL is disabled (Tom Lane) + </para> + + <para> + This was concluded to be more user-friendly than the previous behavior + of silently ignoring such lines. + </para> + </listitem> + + <listitem> + <para> + Fix typo in <function>pg_srand48</> seed initialization (Andres Freund) + </para> + + <para> + This led to failure to use all bits of the provided seed. This function + is not used on most platforms (only those without <function>srandom</>), + and the potential security exposure from a less-random-than-expected + seed seems minimal in any case. + </para> + </listitem> + + <listitem> + <para> + Avoid integer overflow when the sum of <literal>LIMIT</> and + <literal>OFFSET</> values exceeds 2^63 (Heikki Linnakangas) + </para> + </listitem> + + <listitem> + <para> + Add overflow checks to <type>int4</> and <type>int8</> versions of + <function>generate_series()</> (Robert Haas) + </para> + </listitem> + + <listitem> + <para> + Fix trailing-zero removal in <function>to_char()</> (Marti Raudsepp) + </para> + + <para> + In a format with <literal>FM</> and no digit positions + after the decimal point, zeroes to the left of the decimal point could + be removed incorrectly. + </para> + </listitem> + + <listitem> + <para> + Fix <function>pg_size_pretty()</> to avoid overflow for inputs close to + 2^63 (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Weaken plpgsql's check for typmod matching in record values (Tom Lane) + </para> + + <para> + An overly enthusiastic check could lead to discarding length modifiers + that should have been kept. + </para> + </listitem> + + <listitem> + <para> + Correctly handle quotes in locale names during <application>initdb</> + (Heikki Linnakangas) + </para> + + <para> + The case can arise with some Windows locales, such as <quote>People's + Republic of China</>. + </para> + </listitem> + + <listitem> + <para> + Fix <application>pg_upgrade</> to preserve toast tables' relfrozenxids + during an upgrade from 8.3 (Bruce Momjian) + </para> + + <para> + Failure to do this could lead to <filename>pg_clog</> files being + removed too soon after the upgrade. + </para> + </listitem> + + <listitem> + <para> + In <application>pg_ctl</>, support silent mode for service registrations + on Windows (MauMau) + </para> + </listitem> + + <listitem> + <para> + Fix <application>psql</>'s counting of script file line numbers during + <literal>COPY</> from a different file (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix <application>pg_restore</>'s direct-to-database mode for + <varname>standard_conforming_strings</> (Tom Lane) + </para> + + <para> + <application>pg_restore</> could emit incorrect commands when restoring + directly to a database server from an archive file that had been made + with <varname>standard_conforming_strings</> set to <literal>on</>. + </para> + </listitem> + + <listitem> + <para> + Be more user-friendly about unsupported cases for parallel + <application>pg_restore</> (Tom Lane) + </para> + + <para> + This change ensures that such cases are detected and reported before + any restore actions have been taken. + </para> + </listitem> + + <listitem> + <para> + Fix write-past-buffer-end and memory leak in <application>libpq</>'s + LDAP service lookup code (Albe Laurenz) + </para> + </listitem> + + <listitem> + <para> + In <application>libpq</>, avoid failures when using nonblocking I/O + and an SSL connection (Martin Pihlak, Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Improve libpq's handling of failures during connection startup + (Tom Lane) + </para> + + <para> + In particular, the response to a server report of <function>fork()</> + failure during SSL connection startup is now saner. + </para> + </listitem> + + <listitem> + <para> + Improve <application>libpq</>'s error reporting for SSL failures (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Fix <function>PQsetvalue()</> to avoid possible crash when adding a new + tuple to a <structname>PGresult</> originally obtained from a server + query (Andrew Chernow) + </para> + </listitem> + + <listitem> + <para> + Make <application>ecpglib</> write <type>double</> values with 15 digits + precision (Akira Kurosawa) + </para> + </listitem> + + <listitem> + <para> + In <application>ecpglib</>, be sure <literal>LC_NUMERIC</> setting is + restored after an error (Michael Meskes) + </para> + </listitem> + + <listitem> + <para> + Apply upstream fix for blowfish signed-character bug (CVE-2011-2483) + (Tom Lane) + </para> + + <para> + <filename>contrib/pg_crypto</>'s blowfish encryption code could give + wrong results on platforms where char is signed (which is most), + leading to encrypted passwords being weaker than they should be. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak in <filename>contrib/seg</> (Heikki Linnakangas) + </para> + </listitem> + + <listitem> + <para> + Fix <function>pgstatindex()</> to give consistent results for empty + indexes (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Allow building with perl 5.14 (Alex Hunsaker) + </para> + </listitem> + + <listitem> + <para> + Update configure script's method for probing existence of system + functions (Tom Lane) + </para> + + <para> + The version of autoconf we used in 8.3 and 8.2 could be fooled by + compilers that perform link-time optimization. + </para> + </listitem> + + <listitem> + <para> + Fix assorted issues with build and install file paths containing spaces + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Update time zone data files to <application>tzdata</> release 2011i + for DST law changes in Canada, Egypt, Russia, Samoa, and South Sudan. + </para> + </listitem> + + </itemizedlist> + + </sect2> + </sect1> + <sect1 id="release-8-4-8"> <title>Release 8.4.8</title> diff --git a/doc/src/sgml/release-9.0.sgml b/doc/src/sgml/release-9.0.sgml index 4b232f065f..676191f273 100644 --- a/doc/src/sgml/release-9.0.sgml +++ b/doc/src/sgml/release-9.0.sgml @@ -1,6 +1,656 @@ <!-- doc/src/sgml/release-9.0.sgml --> <!-- See header comment in release.sgml about typical markup --> + <sect1 id="release-9-0-5"> + <title>Release 9.0.5</title> + + <note> + <title>Release Date</title> + <simpara>2011-09-26</simpara> + </note> + + <para> + This release contains a variety of fixes from 9.0.4. + For information about new features in the 9.0 major release, see + <xref linkend="release-9-0">. + </para> + + <sect2> + <title>Migration to Version 9.0.5</title> + + <para> + A dump/restore is not required for those running 9.0.X. + </para> + + <para> + However, if you are upgrading from a version earlier than 9.0.4, + see the release notes for 9.0.4. + </para> + + </sect2> + + <sect2> + <title>Changes</title> + + <itemizedlist> + + <listitem> + <para> + Fix catalog cache invalidation after a <command>VACUUM FULL</> or + <command>CLUSTER</> on a system catalog (Tom Lane) + </para> + + <para> + In some cases the relocation of a system catalog row to another place + would not be recognized by concurrent server processes, allowing catalog + corruption to occur if they then tried to update that row. The + worst-case outcome could be as bad as complete loss of a table. + </para> + </listitem> + + <listitem> + <para> + Fix incorrect order of operations during sinval reset processing, + and ensure that TOAST OIDs are preserved in system catalogs (Tom + Lane) + </para> + + <para> + These mistakes could lead to transient failures after a <command>VACUUM + FULL</> or <command>CLUSTER</> on a system catalog. + </para> + </listitem> + + <listitem> + <para> + Fix bugs in indexing of in-doubt HOT-updated tuples (Tom Lane) + </para> + + <para> + These bugs could result in index corruption after reindexing a system + catalog. They are not believed to affect user indexes. + </para> + </listitem> + + <listitem> + <para> + Fix multiple bugs in GiST index page split processing (Heikki + Linnakangas) + </para> + + <para> + The probability of occurrence was low, but these could lead to index + corruption. + </para> + </listitem> + + <listitem> + <para> + Fix possible buffer overrun in <function>tsvector_concat()</> + (Tom Lane) + </para> + + <para> + The function could underestimate the amount of memory needed for its + result, leading to server crashes. + </para> + </listitem> + + <listitem> + <para> + Fix crash in <function>xml_recv</> when processing a + <quote>standalone</> parameter (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Make <function>pg_options_to_table</> return NULL for an option with no + value (Tom Lane) + </para> + + <para> + Previously such cases would result in a server crash. + </para> + </listitem> + + <listitem> + <para> + Avoid possibly accessing off the end of memory in <command>ANALYZE</> + and in SJIS-2004 encoding conversion (Noah Misch) + </para> + + <para> + This fixes some very-low-probability server crash scenarios. + </para> + </listitem> + + <listitem> + <para> + Protect <function>pg_stat_reset_shared()</> against NULL input (Magnus + Hagander) + </para> + </listitem> + + <listitem> + <para> + Fix possible failure when a recovery conflict deadlock is detected + within a sub-transaction (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Avoid spurious conflicts while recycling btree index pages during hot + standby (Noah Misch, Simon Riggs) + </para> + </listitem> + + <listitem> + <para> + Shut down WAL receiver if it's still running at end of recovery (Heikki + Linnakangas) + </para> + + <para> + The postmaster formerly panicked in this situation, but it's actually a + legitimate case. + </para> + </listitem> + + <listitem> + <para> + Fix race condition in relcache init file invalidation (Tom Lane) + </para> + + <para> + There was a window wherein a new backend process could read a stale init + file but miss the inval messages that would tell it the data is stale. + The result would be bizarre failures in catalog accesses, typically + <quote>could not read block 0 in file ...</> later during startup. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak at end of a GiST index scan (Tom Lane) + </para> + + <para> + Commands that perform many separate GiST index scans, such as + verification of a new GiST-based exclusion constraint on a table + already containing many rows, could transiently require large amounts of + memory due to this leak. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak when encoding conversion has to be done on incoming + command strings and <command>LISTEN</> is active (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix incorrect memory accounting (leading to possible memory bloat) in + tuplestores supporting holdable cursors and plpgsql's <literal>RETURN + NEXT</> command (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix trigger <literal>WHEN</> conditions when both <literal>BEFORE</> and + <literal>AFTER</> triggers exist (Tom Lane) + </para> + + <para> + Evaluation of <literal>WHEN</> conditions for <literal>AFTER ROW + UPDATE</> triggers could crash if there had been a <literal>BEFORE + ROW</> trigger fired for the same update. + </para> + </listitem> + + <listitem> + <para> + Fix performance problem when constructing a large, lossy bitmap + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix join selectivity estimation for unique columns (Tom Lane) + </para> + + <para> + This fixes an erroneous planner heuristic that could lead to poor + estimates of the result size of a join. + </para> + </listitem> + + <listitem> + <para> + Fix nested PlaceHolderVar expressions that appear only in sub-select + target lists (Tom Lane) + </para> + + <para> + This mistake could result in outputs of an outer join incorrectly + appearing as NULL. + </para> + </listitem> + + <listitem> + <para> + Allow the planner to assume that empty parent tables really are empty + (Tom Lane) + </para> + + <para> + Normally an empty table is assumed to have a certain minimum size for + planning purposes; but this heuristic seems to do more harm than good + for the parent table of an inheritance hierarchy, which often is + permanently empty. + </para> + </listitem> + + <listitem> + <para> + Allow nested <literal>EXISTS</> queries to be optimized properly (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Fix array- and path-creating functions to ensure padding bytes are + zeroes (Tom Lane) + </para> + + <para> + This avoids some situations where the planner will think that + semantically-equal constants are not equal, resulting in poor + optimization. + </para> + </listitem> + + <listitem> + <para> + Fix <command>EXPLAIN</> to handle gating Result nodes within + inner-indexscan subplans (Tom Lane) + </para> + + <para> + The usual symptom of this oversight was <quote>bogus varno</> errors. + </para> + </listitem> + + <listitem> + <para> + Fix btree preprocessing of <replaceable>indexedcol</> <literal>IS + NULL</> conditions (Dean Rasheed) + </para> + + <para> + Such a condition is unsatisfiable if combined with any other type of + btree-indexable condition on the same index column. The case was + handled incorrectly in 9.0.0 and later, leading to query output where + there should be none. + </para> + </listitem> + + <listitem> + <para> + Work around gcc 4.6.0 bug that breaks WAL replay (Tom Lane) + </para> + + <para> + This could lead to loss of committed transactions after a server crash. + </para> + </listitem> + + <listitem> + <para> + Fix dump bug for <literal>VALUES</> in a view (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Disallow <literal>SELECT FOR UPDATE/SHARE</> on sequences (Tom Lane) + </para> + + <para> + This operation doesn't work as expected and can lead to failures. + </para> + </listitem> + + <listitem> + <para> + Fix <command>VACUUM</> so that it always updates + <literal>pg_class</>.<literal>reltuples</>/<literal>relpages</> (Tom + Lane) + </para> + + <para> + This fixes some scenarios where autovacuum could make increasingly poor + decisions about when to vacuum tables. + </para> + </listitem> + + <listitem> + <para> + Defend against integer overflow when computing size of a hash table (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Fix cases where <command>CLUSTER</> might attempt to access + already-removed TOAST data (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix premature timeout failures during initial authentication transaction + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix portability bugs in use of credentials control messages for + <quote>peer</> authentication (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix SSPI login when multiple roundtrips are required (Ahmed Shinwari, + Magnus Hagander) + </para> + + <para> + The typical symptom of this problem was <quote>The function requested is + not supported</> errors during SSPI login. + </para> + </listitem> + + <listitem> + <para> + Fix failure when adding a new variable of a custom variable class to + <filename>postgresql.conf</> (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Throw an error if <filename>pg_hba.conf</> contains <literal>hostssl</> + but SSL is disabled (Tom Lane) + </para> + + <para> + This was concluded to be more user-friendly than the previous behavior + of silently ignoring such lines. + </para> + </listitem> + + <listitem> + <para> + Fix failure when <command>DROP OWNED BY</> attempts to remove default + privileges on sequences (Shigeru Hanada) + </para> + </listitem> + + <listitem> + <para> + Fix typo in <function>pg_srand48</> seed initialization (Andres Freund) + </para> + + <para> + This led to failure to use all bits of the provided seed. This function + is not used on most platforms (only those without <function>srandom</>), + and the potential security exposure from a less-random-than-expected + seed seems minimal in any case. + </para> + </listitem> + + <listitem> + <para> + Avoid integer overflow when the sum of <literal>LIMIT</> and + <literal>OFFSET</> values exceeds 2^63 (Heikki Linnakangas) + </para> + </listitem> + + <listitem> + <para> + Add overflow checks to <type>int4</> and <type>int8</> versions of + <function>generate_series()</> (Robert Haas) + </para> + </listitem> + + <listitem> + <para> + Fix trailing-zero removal in <function>to_char()</> (Marti Raudsepp) + </para> + + <para> + In a format with <literal>FM</> and no digit positions + after the decimal point, zeroes to the left of the decimal point could + be removed incorrectly. + </para> + </listitem> + + <listitem> + <para> + Fix <function>pg_size_pretty()</> to avoid overflow for inputs close to + 2^63 (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Weaken plpgsql's check for typmod matching in record values (Tom Lane) + </para> + + <para> + An overly enthusiastic check could lead to discarding length modifiers + that should have been kept. + </para> + </listitem> + + <listitem> + <para> + Correctly handle quotes in locale names during <application>initdb</> + (Heikki Linnakangas) + </para> + + <para> + The case can arise with some Windows locales, such as <quote>People's + Republic of China</>. + </para> + </listitem> + + <listitem> + <para> + In <application>pg_upgrade</>, avoid dumping orphaned temporary tables + (Bruce Momjian) + </para> + + <para> + This prevents situations wherein table OID assignments could get out of + sync between old and new installations. + </para> + </listitem> + + <listitem> + <para> + Fix <application>pg_upgrade</> to preserve toast tables' relfrozenxids + during an upgrade from 8.3 (Bruce Momjian) + </para> + + <para> + Failure to do this could lead to <filename>pg_clog</> files being + removed too soon after the upgrade. + </para> + </listitem> + + <listitem> + <para> + In <application>pg_upgrade</>, fix the <literal>-l</> (log) option to + work on Windows (Bruce Momjian) + </para> + </listitem> + + <listitem> + <para> + In <application>pg_ctl</>, support silent mode for service registrations + on Windows (MauMau) + </para> + </listitem> + + <listitem> + <para> + Fix <application>psql</>'s counting of script file line numbers during + <literal>COPY</> from a different file (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Fix <application>pg_restore</>'s direct-to-database mode for + <varname>standard_conforming_strings</> (Tom Lane) + </para> + + <para> + <application>pg_restore</> could emit incorrect commands when restoring + directly to a database server from an archive file that had been made + with <varname>standard_conforming_strings</> set to <literal>on</>. + </para> + </listitem> + + <listitem> + <para> + Be more user-friendly about unsupported cases for parallel + <application>pg_restore</> (Tom Lane) + </para> + + <para> + This change ensures that such cases are detected and reported before + any restore actions have been taken. + </para> + </listitem> + + <listitem> + <para> + Fix write-past-buffer-end and memory leak in <application>libpq</>'s + LDAP service lookup code (Albe Laurenz) + </para> + </listitem> + + <listitem> + <para> + In <application>libpq</>, avoid failures when using nonblocking I/O + and an SSL connection (Martin Pihlak, Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Improve libpq's handling of failures during connection startup + (Tom Lane) + </para> + + <para> + In particular, the response to a server report of <function>fork()</> + failure during SSL connection startup is now saner. + </para> + </listitem> + + <listitem> + <para> + Improve <application>libpq</>'s error reporting for SSL failures (Tom + Lane) + </para> + </listitem> + + <listitem> + <para> + Fix <function>PQsetvalue()</> to avoid possible crash when adding a new + tuple to a <structname>PGresult</> originally obtained from a server + query (Andrew Chernow) + </para> + </listitem> + + <listitem> + <para> + Make <application>ecpglib</> write <type>double</> values with 15 digits + precision (Akira Kurosawa) + </para> + </listitem> + + <listitem> + <para> + In <application>ecpglib</>, be sure <literal>LC_NUMERIC</> setting is + restored after an error (Michael Meskes) + </para> + </listitem> + + <listitem> + <para> + Apply upstream fix for blowfish signed-character bug (CVE-2011-2483) + (Tom Lane) + </para> + + <para> + <filename>contrib/pg_crypto</>'s blowfish encryption code could give + wrong results on platforms where char is signed (which is most), + leading to encrypted passwords being weaker than they should be. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak in <filename>contrib/seg</> (Heikki Linnakangas) + </para> + </listitem> + + <listitem> + <para> + Fix <function>pgstatindex()</> to give consistent results for empty + indexes (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Allow building with perl 5.14 (Alex Hunsaker) + </para> + </listitem> + + <listitem> + <para> + Fix assorted issues with build and install file paths containing spaces + (Tom Lane) + </para> + </listitem> + + <listitem> + <para> + Update time zone data files to <application>tzdata</> release 2011i + for DST law changes in Canada, Egypt, Russia, Samoa, and South Sudan. + </para> + </listitem> + + </itemizedlist> + + </sect2> + </sect1> + <sect1 id="release-9-0-4"> <title>Release 9.0.4</title> diff --git a/doc/src/sgml/release-9.1.sgml b/doc/src/sgml/release-9.1.sgml index a490ccbeaa..aa53c95d00 100644 --- a/doc/src/sgml/release-9.1.sgml +++ b/doc/src/sgml/release-9.1.sgml @@ -1,6 +1,74 @@ <!-- doc/src/sgml/release-9.1.sgml --> <!-- See header comment in release.sgml about typical markup --> + <sect1 id="release-9-1-1"> + <title>Release 9.1.1</title> + + <note> + <title>Release Date</title> + <simpara>2011-09-26</simpara> + </note> + + <para> + This release contains a small number of fixes from 9.1.0. + For information about new features in the 9.1 major release, see + <xref linkend="release-9-1">. + </para> + + <sect2> + <title>Migration to Version 9.1.1</title> + + <para> + A dump/restore is not required for those running 9.1.X. + </para> + + </sect2> + + <sect2> + <title>Changes</title> + + <itemizedlist> + + <listitem> + <para> + Make <function>pg_options_to_table</> return NULL for an option with no + value (Tom Lane) + </para> + + <para> + Previously such cases would result in a server crash. + </para> + </listitem> + + <listitem> + <para> + Fix memory leak at end of a GiST index scan (Tom Lane) + </para> + + <para> + Commands that perform many separate GiST index scans, such as + verification of a new GiST-based exclusion constraint on a table + already containing many rows, could transiently require large amounts of + memory due to this leak. + </para> + </listitem> + + <listitem> + <para> + Fix explicit reference to <literal>pg_temp</> schema in <command>CREATE + TEMPORARY TABLE</> (Robert Haas) + </para> + + <para> + This used to be allowed, but failed in 9.1.0. + </para> + </listitem> + + </itemizedlist> + + </sect2> + </sect1> + <sect1 id="release-9-1"> <title>Release 9.1</title> @@ -377,6 +445,14 @@ rather than by manually invoking their SQL scripts (Dimitri Fontaine, Tom Lane) </para> + + <para> + To update an existing database containing the 9.0 version of a contrib + module, use <literal>CREATE EXTENSION ... FROM unpackaged</literal> + to wrap the existing contrib module's objects into an extension. When + updating from a pre-9.0 version, drop the contrib module's objects + using its old uninstall script, then use <literal>CREATE EXTENSION</>. + </para> </listitem> </itemizedlist> diff --git a/doc/src/sgml/sepgsql.sgml b/doc/src/sgml/sepgsql.sgml index 0a02edb624..24224fb879 100644 --- a/doc/src/sgml/sepgsql.sgml +++ b/doc/src/sgml/sepgsql.sgml @@ -117,13 +117,18 @@ $ for DBNAME in template0 template1 postgres; do </para> <para> - Please note that you may see the following notifications depending on - the combination of a particular version of <productname>libselinux</> - and <productname>selinux-policy</>. + Please note that you may see some or all of the following notifications + depending on the combination of a particular version of + <productname>libselinux</> and <productname>selinux-policy</>. <screen> /etc/selinux/targeted/contexts/sepgsql_contexts: line 33 has invalid object type db_blobs +/etc/selinux/targeted/contexts/sepgsql_contexts: line 36 has invalid object type db_language +/etc/selinux/targeted/contexts/sepgsql_contexts: line 37 has invalid object type db_language +/etc/selinux/targeted/contexts/sepgsql_contexts: line 38 has invalid object type db_language +/etc/selinux/targeted/contexts/sepgsql_contexts: line 39 has invalid object type db_language +/etc/selinux/targeted/contexts/sepgsql_contexts: line 40 has invalid object type db_language </screen> - This message is harmless and may be safely ignored. + These messages are harmless and may be safely ignored. </para> </sect2> diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 040bef6add..fcc90fed5f 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -225,7 +225,6 @@ RangeVarGetRelid(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok, bool nowait) { uint64 inval_count; - Oid namespaceId; Oid relId; Oid oldRelId = InvalidOid; bool retry = false; @@ -278,17 +277,27 @@ RangeVarGetRelid(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok, */ if (relation->relpersistence == RELPERSISTENCE_TEMP) { - if (relation->schemaname) - ereport(ERROR, - (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("temporary tables cannot specify a schema name"))); - if (OidIsValid(myTempNamespace)) + if (!OidIsValid(myTempNamespace)) + relId = InvalidOid; /* this probably can't happen? */ + else + { + if (relation->schemaname) + { + Oid namespaceId; + namespaceId = LookupExplicitNamespace(relation->schemaname); + if (namespaceId != myTempNamespace) + ereport(ERROR, + (errcode(ERRCODE_INVALID_TABLE_DEFINITION), + errmsg("temporary tables cannot specify a schema name"))); + } + relId = get_relname_relid(relation->relname, myTempNamespace); - else /* this probably can't happen? */ - relId = InvalidOid; + } } else if (relation->schemaname) { + Oid namespaceId; + /* use exact schema given */ namespaceId = LookupExplicitNamespace(relation->schemaname); relId = get_relname_relid(relation->relname, namespaceId); diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 6408d1653b..cd9fc92923 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -18,7 +18,6 @@ #include "commands/defrem.h" #include "commands/prepare.h" #include "executor/hashjoin.h" -#include "executor/instrument.h" #include "foreign/fdwapi.h" #include "optimizer/clauses.h" #include "parser/parsetree.h" @@ -76,6 +75,8 @@ static void show_sort_keys_common(PlanState *planstate, List *ancestors, ExplainState *es); static void show_sort_info(SortState *sortstate, ExplainState *es); static void show_hash_info(HashState *hashstate, ExplainState *es); +static void show_instrumentation_count(const char *qlabel, int which, + PlanState *planstate, ExplainState *es); static void show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es); static const char *explain_get_index_name(Oid indexId); static void ExplainScanTarget(Scan *plan, ExplainState *es); @@ -1000,9 +1001,15 @@ ExplainNode(PlanState *planstate, List *ancestors, case T_IndexScan: show_scan_qual(((IndexScan *) plan)->indexqualorig, "Index Cond", planstate, ancestors, es); + if (((IndexScan *) plan)->indexqualorig) + show_instrumentation_count("Rows Removed by Index Recheck", 2, + planstate, es); show_scan_qual(((IndexScan *) plan)->indexorderbyorig, "Order By", planstate, ancestors, es); show_scan_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 1, + planstate, es); break; case T_BitmapIndexScan: show_scan_qual(((BitmapIndexScan *) plan)->indexqualorig, @@ -1011,6 +1018,9 @@ ExplainNode(PlanState *planstate, List *ancestors, case T_BitmapHeapScan: show_scan_qual(((BitmapHeapScan *) plan)->bitmapqualorig, "Recheck Cond", planstate, ancestors, es); + if (((BitmapHeapScan *) plan)->bitmapqualorig) + show_instrumentation_count("Rows Removed by Index Recheck", 2, + planstate, es); /* FALL THRU */ case T_SeqScan: case T_ValuesScan: @@ -1018,6 +1028,9 @@ ExplainNode(PlanState *planstate, List *ancestors, case T_WorkTableScan: case T_SubqueryScan: show_scan_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 1, + planstate, es); break; case T_FunctionScan: if (es->verbose) @@ -1025,6 +1038,9 @@ ExplainNode(PlanState *planstate, List *ancestors, "Function Call", planstate, ancestors, es->verbose, es); show_scan_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 1, + planstate, es); break; case T_TidScan: { @@ -1038,34 +1054,61 @@ ExplainNode(PlanState *planstate, List *ancestors, tidquals = list_make1(make_orclause(tidquals)); show_scan_qual(tidquals, "TID Cond", planstate, ancestors, es); show_scan_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 1, + planstate, es); } break; case T_ForeignScan: show_scan_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 1, + planstate, es); show_foreignscan_info((ForeignScanState *) planstate, es); break; case T_NestLoop: show_upper_qual(((NestLoop *) plan)->join.joinqual, "Join Filter", planstate, ancestors, es); + if (((NestLoop *) plan)->join.joinqual) + show_instrumentation_count("Rows Removed by Join Filter", 1, + planstate, es); show_upper_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 2, + planstate, es); break; case T_MergeJoin: show_upper_qual(((MergeJoin *) plan)->mergeclauses, "Merge Cond", planstate, ancestors, es); show_upper_qual(((MergeJoin *) plan)->join.joinqual, "Join Filter", planstate, ancestors, es); + if (((MergeJoin *) plan)->join.joinqual) + show_instrumentation_count("Rows Removed by Join Filter", 1, + planstate, es); show_upper_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 2, + planstate, es); break; case T_HashJoin: show_upper_qual(((HashJoin *) plan)->hashclauses, "Hash Cond", planstate, ancestors, es); show_upper_qual(((HashJoin *) plan)->join.joinqual, "Join Filter", planstate, ancestors, es); + if (((HashJoin *) plan)->join.joinqual) + show_instrumentation_count("Rows Removed by Join Filter", 1, + planstate, es); show_upper_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 2, + planstate, es); break; case T_Agg: case T_Group: show_upper_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 1, + planstate, es); break; case T_Sort: show_sort_keys((SortState *) planstate, ancestors, es); @@ -1079,6 +1122,9 @@ ExplainNode(PlanState *planstate, List *ancestors, show_upper_qual((List *) ((Result *) plan)->resconstantqual, "One-Time Filter", planstate, ancestors, es); show_upper_qual(plan->qual, "Filter", planstate, ancestors, es); + if (plan->qual) + show_instrumentation_count("Rows Removed by Filter", 1, + planstate, es); break; case T_Hash: show_hash_info((HashState *) planstate, es); @@ -1509,6 +1555,37 @@ show_hash_info(HashState *hashstate, ExplainState *es) } /* + * If it's EXPLAIN ANALYZE, show instrumentation information for a plan node + * + * "which" identifies which instrumentation counter to print + */ +static void +show_instrumentation_count(const char *qlabel, int which, + PlanState *planstate, ExplainState *es) +{ + double nfiltered; + double nloops; + + if (!es->analyze || !planstate->instrument) + return; + + if (which == 2) + nfiltered = planstate->instrument->nfiltered2; + else + nfiltered = planstate->instrument->nfiltered1; + nloops = planstate->instrument->nloops; + + /* In text mode, suppress zero counts; they're not interesting enough */ + if (nfiltered > 0 || es->format != EXPLAIN_FORMAT_TEXT) + { + if (nloops > 0) + ExplainPropertyFloat(qlabel, nfiltered / nloops, 0, es); + else + ExplainPropertyFloat(qlabel, 0.0, 0, es); + } +} + +/* * Show extra information for a ForeignScan node. */ static void diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 680962aa44..06d368e077 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -29,7 +29,6 @@ #include "commands/defrem.h" #include "commands/trigger.h" #include "executor/executor.h" -#include "executor/instrument.h" #include "miscadmin.h" #include "nodes/bitmapset.h" #include "nodes/makefuncs.h" diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c index ffdcc966ee..711e8c7786 100644 --- a/src/backend/executor/execAmi.c +++ b/src/backend/executor/execAmi.c @@ -13,7 +13,6 @@ #include "postgres.h" #include "executor/execdebug.h" -#include "executor/instrument.h" #include "executor/nodeAgg.h" #include "executor/nodeAppend.h" #include "executor/nodeBitmapAnd.h" diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 1dfe8b9ac7..fd7a9ed033 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -47,7 +47,6 @@ #include "commands/tablespace.h" #include "commands/trigger.h" #include "executor/execdebug.h" -#include "executor/instrument.h" #include "miscadmin.h" #include "optimizer/clauses.h" #include "parser/parse_clause.h" diff --git a/src/backend/executor/execProcnode.c b/src/backend/executor/execProcnode.c index 17788761d7..8bdfad2222 100644 --- a/src/backend/executor/execProcnode.c +++ b/src/backend/executor/execProcnode.c @@ -77,7 +77,6 @@ #include "postgres.h" #include "executor/executor.h" -#include "executor/instrument.h" #include "executor/nodeAgg.h" #include "executor/nodeAppend.h" #include "executor/nodeBitmapAnd.h" diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index e90058847d..d4ed235856 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -219,6 +219,8 @@ ExecScan(ScanState *node, return slot; } } + else + InstrCountFiltered1(node, 1); /* * Tuple fails qual, so free per-tuple memory and try again. diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c index bf9bf12ab6..9d30200ab3 100644 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@ -22,6 +22,7 @@ BufferUsage pgBufferUsage; static void BufferUsageAccumDiff(BufferUsage *dst, const BufferUsage *add, const BufferUsage *sub); + /* Allocate new instrumentation structure(s) */ Instrumentation * InstrAlloc(int n, int instrument_options) @@ -31,13 +32,14 @@ InstrAlloc(int n, int instrument_options) /* timer is always required for now */ Assert(instrument_options & INSTRUMENT_TIMER); + /* initialize all fields to zeroes, then modify as needed */ instr = palloc0(n * sizeof(Instrumentation)); if (instrument_options & INSTRUMENT_BUFFERS) { int i; for (i = 0; i < n; i++) - instr[i].needs_bufusage = true; + instr[i].need_bufusage = true; } return instr; @@ -52,8 +54,8 @@ InstrStartNode(Instrumentation *instr) else elog(DEBUG2, "InstrStartNode called twice in a row"); - /* initialize buffer usage per plan node */ - if (instr->needs_bufusage) + /* save buffer usage totals at node entry, if needed */ + if (instr->need_bufusage) instr->bufusage_start = pgBufferUsage; } @@ -77,8 +79,8 @@ InstrStopNode(Instrumentation *instr, double nTuples) INSTR_TIME_SET_ZERO(instr->starttime); - /* Adds delta of buffer usage to node's count. */ - if (instr->needs_bufusage) + /* Add delta of buffer usage since entry to node's totals */ + if (instr->need_bufusage) BufferUsageAccumDiff(&instr->bufusage, &pgBufferUsage, &instr->bufusage_start); @@ -119,12 +121,12 @@ InstrEndLoop(Instrumentation *instr) instr->tuplecount = 0; } +/* dst += add - sub */ static void BufferUsageAccumDiff(BufferUsage *dst, const BufferUsage *add, const BufferUsage *sub) { - /* dst += add - sub */ dst->shared_blks_hit += add->shared_blks_hit - sub->shared_blks_hit; dst->shared_blks_read += add->shared_blks_read - sub->shared_blks_read; dst->shared_blks_written += add->shared_blks_written - sub->shared_blks_written; diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 13d7723480..e769d6d012 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -1204,6 +1204,8 @@ agg_retrieve_direct(AggState *aggstate) return result; } } + else + InstrCountFiltered1(aggstate, 1); } /* No more groups */ @@ -1354,6 +1356,8 @@ agg_retrieve_hash_table(AggState *aggstate) return result; } } + else + InstrCountFiltered1(aggstate, 1); } /* No more groups */ diff --git a/src/backend/executor/nodeBitmapAnd.c b/src/backend/executor/nodeBitmapAnd.c index 82308cba26..5f318c31e7 100644 --- a/src/backend/executor/nodeBitmapAnd.c +++ b/src/backend/executor/nodeBitmapAnd.c @@ -29,7 +29,6 @@ #include "postgres.h" #include "executor/execdebug.h" -#include "executor/instrument.h" #include "executor/nodeBitmapAnd.h" diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 8e50fb1aae..4a8920e6ce 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -278,6 +278,7 @@ BitmapHeapNext(BitmapHeapScanState *node) if (!ExecQual(node->bitmapqualorig, econtext, false)) { /* Fails recheck, so drop it and loop back for another */ + InstrCountFiltered2(node, 1); ExecClearTuple(slot); continue; } diff --git a/src/backend/executor/nodeBitmapIndexscan.c b/src/backend/executor/nodeBitmapIndexscan.c index 9a56fd4b9f..8e1df079b3 100644 --- a/src/backend/executor/nodeBitmapIndexscan.c +++ b/src/backend/executor/nodeBitmapIndexscan.c @@ -22,7 +22,6 @@ #include "postgres.h" #include "executor/execdebug.h" -#include "executor/instrument.h" #include "executor/nodeBitmapIndexscan.h" #include "executor/nodeIndexscan.h" #include "miscadmin.h" diff --git a/src/backend/executor/nodeBitmapOr.c b/src/backend/executor/nodeBitmapOr.c index 4b064b79a9..d2453d5a4f 100644 --- a/src/backend/executor/nodeBitmapOr.c +++ b/src/backend/executor/nodeBitmapOr.c @@ -29,7 +29,6 @@ #include "postgres.h" #include "executor/execdebug.h" -#include "executor/instrument.h" #include "executor/nodeBitmapOr.h" #include "miscadmin.h" diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c index fa403e5406..7bef8bbe8b 100644 --- a/src/backend/executor/nodeGroup.c +++ b/src/backend/executor/nodeGroup.c @@ -118,6 +118,8 @@ ExecGroup(GroupState *node) return result; } } + else + InstrCountFiltered1(node, 1); } /* @@ -179,6 +181,8 @@ ExecGroup(GroupState *node) return result; } } + else + InstrCountFiltered1(node, 1); } /* NOTREACHED */ diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 2ade2d7fad..e72a71bf51 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -28,7 +28,6 @@ #include "commands/tablespace.h" #include "executor/execdebug.h" #include "executor/hashjoin.h" -#include "executor/instrument.h" #include "executor/nodeHash.h" #include "executor/nodeHashjoin.h" #include "miscadmin.h" diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 3a6698105f..c3c4db4bc2 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -325,7 +325,11 @@ ExecHashJoin(HashJoinState *node) return result; } } + else + InstrCountFiltered2(node, 1); } + else + InstrCountFiltered1(node, 1); break; case HJ_FILL_OUTER_TUPLE: @@ -360,6 +364,8 @@ ExecHashJoin(HashJoinState *node) return result; } } + else + InstrCountFiltered2(node, 1); } break; @@ -397,6 +403,8 @@ ExecHashJoin(HashJoinState *node) return result; } } + else + InstrCountFiltered2(node, 1); break; case HJ_NEED_NEW_BATCH: diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index 955008e012..da25384e86 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -96,7 +96,11 @@ IndexNext(IndexScanState *node) econtext->ecxt_scantuple = slot; ResetExprContext(econtext); if (!ExecQual(node->indexqualorig, econtext, false)) - continue; /* nope, so ask index for another one */ + { + /* Fails recheck, so drop it and loop back for another */ + InstrCountFiltered2(node, 1); + continue; + } } return slot; diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index e23dd6c9f5..deaa79ed9f 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -505,6 +505,8 @@ MJFillOuter(MergeJoinState *node) return result; } } + else + InstrCountFiltered2(node, 1); return NULL; } @@ -544,6 +546,8 @@ MJFillInner(MergeJoinState *node) return result; } } + else + InstrCountFiltered2(node, 1); return NULL; } @@ -893,7 +897,11 @@ ExecMergeJoin(MergeJoinState *node) return result; } } + else + InstrCountFiltered2(node, 1); } + else + InstrCountFiltered1(node, 1); break; /* diff --git a/src/backend/executor/nodeNestloop.c b/src/backend/executor/nodeNestloop.c index e98bc0f5a3..49b880d0ca 100644 --- a/src/backend/executor/nodeNestloop.c +++ b/src/backend/executor/nodeNestloop.c @@ -214,6 +214,8 @@ ExecNestLoop(NestLoopState *node) return result; } } + else + InstrCountFiltered2(node, 1); } /* @@ -270,7 +272,11 @@ ExecNestLoop(NestLoopState *node) return result; } } + else + InstrCountFiltered2(node, 1); } + else + InstrCountFiltered1(node, 1); /* * Tuple fails qual, so free per-tuple memory and try again. diff --git a/src/backend/storage/lmgr/README.barrier b/src/backend/storage/lmgr/README.barrier new file mode 100644 index 0000000000..f9f3593b77 --- /dev/null +++ b/src/backend/storage/lmgr/README.barrier @@ -0,0 +1,199 @@ +Memory Barriers +=============== + +Modern CPUs make extensive use of pipe-lining and out-of-order execution, +meaning that the CPU is often executing more than one instruction at a +time, and not necessarily in the order that the source code would suggest. +Furthermore, even before the CPU gets a chance to reorder operations, the +compiler may (and often does) reorganize the code for greater efficiency, +particularly at higher optimization levels. Optimizing compilers and +out-of-order execution are both critical for good performance, but they +can lead to surprising results when multiple processes access the same +memory space. + +Example +======= + +Suppose x is a pointer to a structure stored in shared memory, and that the +entire structure has been initialized to zero bytes. One backend executes +the following code fragment: + + x->foo = 1; + x->bar = 1; + +Meanwhile, at approximately the same time, another backend executes this +code fragment: + + bar = x->bar; + foo = x->foo; + +The second backend might end up with foo = 1 and bar = 1 (if it executes +both statements after the first backend), or with foo = 0 and bar = 0 (if +it executes both statements before the first backend), or with foo = 1 and +bar = 0 (if the first backend executes the first statement, the second +backend executes both statements, and then the first backend executes the +second statement). + +Surprisingly, however, the second backend could also end up with foo = 0 +and bar = 1. The compiler might swap the order of the two stores performed +by the first backend, or the two loads performed by the second backend. +Even if it doesn't, on a machine with weak memory ordering (such as PowerPC +or Itanium) the CPU might choose to execute either the loads or the stores +out of order. This surprising result can lead to bugs. + +A common pattern where this actually does result in a bug is when adding items +onto a queue. The writer does this: + + q->items[q->num_items] = new_item; + ++q->num_items; + +The reader does this: + + num_items = q->num_items; + for (i = 0; i < num_items; ++i) + /* do something with q->items[i] */ + +This code turns out to be unsafe, because the writer might increment +q->num_items before it finishes storing the new item into the appropriate slot. +More subtly, the reader might prefetch the contents of the q->items array +before reading q->num_items. Thus, there's still a bug here *even if the +writer does everything in the order we expect*. We need the writer to update +the array before bumping the item counter, and the reader to examine the item +counter before examining the array. + +Note that these types of highly counterintuitive bugs can *only* occur when +multiple processes are interacting with the same memory segment. A given +process always perceives its *own* writes to memory in program order. + +Avoiding Memory Ordering Bugs +============================= + +The simplest (and often best) way to avoid memory ordering bugs is to +protect the data structures involved with an lwlock. For more details, see +src/backend/storage/lmgr/README. For instance, in the above example, the +writer could acquire an lwlock in exclusive mode before appending to the +queue, and each reader could acquire the same lock in shared mode before +reading it. If the data structure is not heavily trafficked, this solution is +generally entirely adequate. + +However, in some cases, it is desirable to avoid the overhead of acquiring +and releasing locks. In this case, memory barriers may be used to ensure +that the apparent order of execution is as the programmer desires. In +PostgreSQL backend code, the pg_memory_barrier() macro may be used to achieve +this result. In the example above, we can prevent the reader from seeing a +garbage value by having the writer do this: + + q->items[q->num_items] = new_item; + pg_memory_barrier(); + ++q->num_items; + +And by having the reader do this: + + num_items = q->num_items; + pg_memory_barrier(); + for (i = 0; i < num_items; ++i) + /* do something with q->items[i] */ + +The pg_memory_barrier() macro will (1) prevent the compiler from rearranging +the code in such a way as to allow the memory accesses to occur out of order +and (2) generate any code (often, inline assembly) that is needed to prevent +the CPU from executing the memory accesses out of order. Specifically, the +barrier prevents loads and stores written after the barrier from being +performed before the barrier, and vice-versa. + +Although this code will work, it is needlessly inefficient. On systems with +strong memory ordering (such as x86), the CPU never reorders loads with other +loads, nor stores with other stores. It can, however, allow a load to +performed before a subsequent store. To avoid emitting unnecessary memory +instructions, we provide two additional primitives: pg_read_barrier(), and +pg_write_barrier(). When a memory barrier is being used to separate two +loads, use pg_read_barrier(); when it is separating two stores, use +pg_write_barrier(); when it is a separating a load and a store (in either +order), use pg_memory_barrier(). pg_memory_barrier() can always substitute +for either a read or a write barrier, but is typically more expensive, and +therefore should be used only when needed. + +With these guidelines in mind, the writer can do this: + + q->items[q->num_items] = new_item; + pg_write_barrier(); + ++q->num_items; + +And the reader can do this: + + num_items = q->num_items; + pg_read_barrier(); + for (i = 0; i < num_items; ++i) + /* do something with q->items[i] */ + +On machines with strong memory ordering, these weaker barriers will simply +prevent compiler rearrangement, without emitting any actual machine code. +On machines with weak memory ordering, they will will prevent compiler +reordering and also emit whatever hardware barrier may be required. Even +on machines with weak memory ordering, a read or write barrier may be able +to use a less expensive instruction than a full barrier. + +Weaknesses of Memory Barriers +============================= + +While memory barriers are a powerful tool, and much cheaper than locks, they +are also much less capable than locks. Here are some of the problems. + +1. Concurrent writers are unsafe. In the above example of a queue, using +memory barriers doesn't make it safe for two processes to add items to the +same queue at the same time. If more than one process can write to the queue, +a spinlock or lwlock must be used to synchronize access. The readers can +perhaps proceed without any lock, but the writers may not. + +Even very simple write operations often require additional synchronization. +For example, it's not safe for multiple writers to simultaneously execute +this code (supposing x is a pointer into shared memory): + + x->foo++; + +Although this may compile down to a single machine-language instruction, +the CPU will execute that instruction by reading the current value of foo, +adding one to it, and then storing the result back to the original address. +If two CPUs try to do this simultaneously, both may do their reads before +either one does their writes. Eventually we might be able to use an atomic +fetch-and-add instruction for this specific case on architectures that support +it, but we can't rely on that being available everywhere, and we currently +have no support for it at all. Use a lock. + +2. Eight-byte loads and stores aren't necessarily atomic. We assume in +various places in the source code that an aligned four-byte load or store is +atomic, and that other processes therefore won't see a half-set value. +Sadly, the same can't be said for eight-byte value: on some platforms, an +aligned eight-byte load or store will generate two four-byte operations. If +you need an atomic eight-byte read or write, you must make it atomic with a +lock. + +3. No ordering guarantees. While memory barriers ensure that any given +process performs loads and stores to shared memory in order, they don't +guarantee synchronization. In the queue example above, we can use memory +barriers to be sure that readers won't see garbage, but there's nothing to +say whether a given reader will run before or after a given writer. If this +matters in a given situation, some other mechanism must be used instead of +or in addition to memory barriers. + +4. Barrier proliferation. Many algorithms that at first seem appealing +require multiple barriers. If the number of barriers required is more than +one or two, you may be better off just using a lock. Keep in mind that, on +some platforms, a barrier may be implemented by acquiring and releasing a +backend-private spinlock. This may be better than a centralized lock under +contention, but it may also be slower in the uncontended case. + +Further Reading +=============== + +Much of the documentation about memory barriers appears to be quite +Linux-specific. The following papers may be helpful: + +Memory Ordering in Modern Microprocessors, by Paul E. McKenney +* http://www.rdrop.com/users/paulmck/scalability/paper/ordering.2007.09.19a.pdf + +Memory Barriers: a Hardware View for Software Hackers, by Paul E. McKenney +* http://www.rdrop.com/users/paulmck/scalability/paper/whymb.2010.06.07c.pdf + +The Linux kernel also has some useful documentation on this topic. Start +with Documentation/memory-barriers.txt diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c index 1aa9912572..cd1306c182 100644 --- a/src/backend/storage/lmgr/s_lock.c +++ b/src/backend/storage/lmgr/s_lock.c @@ -20,6 +20,7 @@ #include "storage/s_lock.h" +slock_t dummy_spinlock; static int spins_per_delay = DEFAULT_SPINS_PER_DELAY; diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 7112dea0e1..fe5e14b9dc 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -707,8 +707,7 @@ cache_locale_time(void) * otherwise returns the pointer to a static area which * contains the iso formatted locale name. */ -static -char * +static char * IsoLocaleName(const char *winlocname) { #if (_MSC_VER >= 1400) /* VC8.0 or later */ @@ -937,6 +936,29 @@ lc_ctype_is_c(Oid collation) } +/* simple subroutine for reporting errors from newlocale() */ +#ifdef HAVE_LOCALE_T +static void +report_newlocale_failure(const char *localename) +{ + /* copy errno in case one of the ereport auxiliary functions changes it */ + int save_errno = errno; + + /* + * ENOENT means "no such locale", not "no such file", so clarify that + * errno with an errdetail message. + */ + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not create locale \"%s\": %m", + localename), + (save_errno == ENOENT ? + errdetail("The operating system could not find any locale data for the locale name \"%s\".", + localename) : 0))); +} +#endif /* HAVE_LOCALE_T */ + + /* * Create a locale_t from a collation OID. Results are cached for the * lifetime of the backend. Thus, do not free the result with freelocale(). @@ -995,10 +1017,7 @@ pg_newlocale_from_collation(Oid collid) result = _create_locale(LC_ALL, collcollate); #endif if (!result) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not create locale \"%s\": %m", - collcollate))); + report_newlocale_failure(collcollate); } else { @@ -1008,16 +1027,10 @@ pg_newlocale_from_collation(Oid collid) loc1 = newlocale(LC_COLLATE_MASK, collcollate, NULL); if (!loc1) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not create locale \"%s\": %m", - collcollate))); + report_newlocale_failure(collcollate); result = newlocale(LC_CTYPE_MASK, collctype, loc1); if (!result) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not create locale \"%s\": %m", - collctype))); + report_newlocale_failure(collctype); #else /* diff --git a/src/bin/initdb/findtimezone.c b/src/bin/initdb/findtimezone.c index 6d45674b5b..87b8e9a34d 100644 --- a/src/bin/initdb/findtimezone.c +++ b/src/bin/initdb/findtimezone.c @@ -658,9 +658,10 @@ static const struct "Cen. Australia Standard Time", "Cen. Australia Daylight Time", "Australia/Adelaide" }, /* (GMT+09:30) Adelaide */ + /* Central America (other than Mexico) generally does not observe DST */ { "Central America Standard Time", "Central America Daylight Time", - "CST6CDT" + "CST6" }, /* (GMT-06:00) Central America */ { "Central Asia Standard Time", "Central Asia Daylight Time", diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c index 04bbebcaf3..d6e05dd793 100644 --- a/src/bin/scripts/createuser.c +++ b/src/bin/scripts/createuser.c @@ -37,6 +37,8 @@ main(int argc, char *argv[]) {"no-inherit", no_argument, NULL, 'I'}, {"login", no_argument, NULL, 'l'}, {"no-login", no_argument, NULL, 'L'}, + {"replication", no_argument, NULL, 1}, + {"no-replication", no_argument, NULL, 2}, /* adduser is obsolete, undocumented spelling of superuser */ {"adduser", no_argument, NULL, 'a'}, {"no-adduser", no_argument, NULL, 'A'}, @@ -66,6 +68,7 @@ main(int argc, char *argv[]) createrole = TRI_DEFAULT, inherit = TRI_DEFAULT, login = TRI_DEFAULT, + replication = TRI_DEFAULT, encrypted = TRI_DEFAULT; PQExpBufferData sql; @@ -145,6 +148,12 @@ main(int argc, char *argv[]) case 'N': encrypted = TRI_NO; break; + case 1: + replication = TRI_YES; + break; + case 2: + replication = TRI_NO; + break; default: fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); @@ -271,6 +280,10 @@ main(int argc, char *argv[]) appendPQExpBuffer(&sql, " LOGIN"); if (login == TRI_NO) appendPQExpBuffer(&sql, " NOLOGIN"); + if (replication == TRI_YES) + appendPQExpBuffer(&sql, " REPLICATION"); + if (replication == TRI_NO) + appendPQExpBuffer(&sql, " NOREPLICATION"); if (conn_limit != NULL) appendPQExpBuffer(&sql, " CONNECTION LIMIT %s", conn_limit); appendPQExpBuffer(&sql, ";\n"); @@ -316,6 +329,8 @@ help(const char *progname) printf(_(" -R, --no-createrole role cannot create roles\n")); printf(_(" -s, --superuser role will be superuser\n")); printf(_(" -S, --no-superuser role will not be superuser\n")); + printf(_(" --replication role can initiate replication\n")); + printf(_(" --no-replication role cannot initiate replication\n")); printf(_(" --help show this help, then exit\n")); printf(_(" --version output version information, then exit\n")); printf(_("\nConnection options:\n")); diff --git a/src/include/executor/instrument.h b/src/include/executor/instrument.h index 286cd54063..22c3106943 100644 --- a/src/include/executor/instrument.h +++ b/src/include/executor/instrument.h @@ -28,6 +28,7 @@ typedef struct BufferUsage long temp_blks_written; /* # of temp blocks written */ } BufferUsage; +/* Flag bits included in InstrAlloc's instrument_options bitmask */ typedef enum InstrumentOption { INSTRUMENT_TIMER = 1 << 0, /* needs timer */ @@ -37,9 +38,10 @@ typedef enum InstrumentOption typedef struct Instrumentation { + /* Parameters set at node creation: */ + bool need_bufusage; /* TRUE if we need buffer usage data */ /* Info about current plan cycle: */ bool running; /* TRUE if we've completed first tuple */ - bool needs_bufusage; /* TRUE if we need buffer usage */ instr_time starttime; /* Start time of current iteration of node */ instr_time counter; /* Accumulated runtime for this node */ double firsttuple; /* Time for first tuple of this cycle */ @@ -50,6 +52,8 @@ typedef struct Instrumentation double total; /* Total total time (in seconds) */ double ntuples; /* Total tuples produced */ double nloops; /* # of run cycles for this node */ + double nfiltered1; /* # tuples removed by scanqual or joinqual */ + double nfiltered2; /* # tuples removed by "other" quals */ BufferUsage bufusage; /* Total buffer usage */ } Instrumentation; diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index b3eed7d189..c8a0b59864 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -16,6 +16,7 @@ #include "access/genam.h" #include "access/heapam.h" +#include "executor/instrument.h" #include "nodes/params.h" #include "nodes/plannodes.h" #include "utils/reltrigger.h" @@ -314,7 +315,7 @@ typedef struct ResultRelInfo TriggerDesc *ri_TrigDesc; FmgrInfo *ri_TrigFunctions; List **ri_TrigWhenExprs; - struct Instrumentation *ri_TrigInstrument; + Instrumentation *ri_TrigInstrument; List **ri_ConstraintExprs; JunkFilter *ri_junkFilter; ProjectionInfo *ri_projectReturning; @@ -967,8 +968,7 @@ typedef struct PlanState * nodes point to one EState for the whole * top-level plan */ - struct Instrumentation *instrument; /* Optional runtime stats for this - * plan node */ + Instrumentation *instrument; /* Optional runtime stats for this node */ /* * Common structural data for all Plan types. These links to subsidiary @@ -1008,6 +1008,18 @@ typedef struct PlanState #define innerPlanState(node) (((PlanState *)(node))->righttree) #define outerPlanState(node) (((PlanState *)(node))->lefttree) +/* Macros for inline access to certain instrumentation counters */ +#define InstrCountFiltered1(node, delta) \ + do { \ + if (((PlanState *)(node))->instrument) \ + ((PlanState *)(node))->instrument->nfiltered1 += (delta); \ + } while(0) +#define InstrCountFiltered2(node, delta) \ + do { \ + if (((PlanState *)(node))->instrument) \ + ((PlanState *)(node))->instrument->nfiltered2 += (delta); \ + } while(0) + /* * EPQState is state for executing an EvalPlanQual recheck on a candidate * tuple in ModifyTable or LockRows. The estate and planstate fields are diff --git a/src/include/storage/barrier.h b/src/include/storage/barrier.h new file mode 100644 index 0000000000..0286817a38 --- /dev/null +++ b/src/include/storage/barrier.h @@ -0,0 +1,171 @@ +/*------------------------------------------------------------------------- + * + * barrier.h + * Memory barrier operations. + * + * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/storage/barrier.h + * + *------------------------------------------------------------------------- + */ +#ifndef BARRIER_H +#define BARRIER_H + +#include "storage/s_lock.h" + +extern slock_t dummy_spinlock; + +/* + * A compiler barrier need not (and preferably should not) emit any actual + * machine code, but must act as an optimization fence: the compiler must not + * reorder loads or stores to main memory around the barrier. However, the + * CPU may still reorder loads or stores at runtime, if the architecture's + * memory model permits this. + * + * A memory barrier must act as a compiler barrier, and in addition must + * guarantee that all loads and stores issued prior to the barrier are + * completed before any loads or stores issued after the barrier. Unless + * loads and stores are totally ordered (which is not the case on most + * architectures) this requires issuing some sort of memory fencing + * instruction. + * + * A read barrier must act as a compiler barrier, and in addition must + * guarantee that any loads issued prior to the barrier are completed before + * any loads issued after the barrier. Similarly, a write barrier acts + * as a compiler barrier, and also orders stores. Read and write barriers + * are thus weaker than a full memory barrier, but stronger than a compiler + * barrier. In practice, on machines with strong memory ordering, read and + * write barriers may require nothing more than a compiler barrier. + * + * For an introduction to using memory barriers within the PostgreSQL backend, + * see src/backend/storage/lmgr/README.barrier + */ + +#if defined(DISABLE_BARRIERS) + +/* + * Fall through to the spinlock-based implementation. + */ + +#elif defined(__INTEL_COMPILER) + +/* + * icc defines __GNUC__, but doesn't support gcc's inline asm syntax + */ +#define pg_memory_barrier() _mm_mfence() +#define pg_compiler_barrier() __memory_barrier() + +#elif defined(__GNUC__) + +/* This works on any architecture, since it's only talking to GCC itself. */ +#define pg_compiler_barrier() __asm__ __volatile__("" : : : "memory") + +#if defined(__i386__) || defined(__x86_64__) /* 32 or 64 bit x86 */ + +/* + * x86 and x86_64 do not allow loads to be reorded with other loads, or + * stores to be reordered with other stores, but a load can be performed + * before a subsequent store. + * + * "lock; addl" has worked for longer than "mfence". + * + * Technically, some x86-ish chips support uncached memory access and/or + * special instructions that are weakly ordered. In those cases we'd need + * the read and write barriers to be lfence and sfence. But since we don't + * do those things, a compiler barrier should be enough. + */ +#define pg_memory_barrier() \ + __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory") +#define pg_read_barrier() pg_compiler_barrier() +#define pg_write_barrier() pg_compiler_barrier() + +#elif defined(__ia64__) || defined(__ia64) + +/* + * Itanium is weakly ordered, so read and write barriers require a full + * fence. + */ +#define pg_memory_barrier() __asm__ __volatile__ ("mf" : : : "memory") + +#elif defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__) || defined(__powerpc64__) + +/* + * lwsync orders loads with respect to each other, and similarly with stores. + * But a load can be performed before a subsequent store, so sync must be used + * for a full memory barrier. + */ +#define pg_memory_barrier() __asm__ __volatile__ ("sync" : : : "memory") +#define pg_read_barrier() __asm__ __volatile__ ("lwsync" : : : "memory") +#define pg_write_barrier() __asm__ __volatile__ ("lwsync" : : : "memory") + +#elif defined(__alpha) || defined(__alpha__) /* Alpha */ + +/* + * Unlike all other known architectures, Alpha allows dependent reads to be + * reordered, but we don't currently find it necessary to provide a conditional + * read barrier to cover that case. We might need to add that later. + */ +#define pg_memory_barrier() __asm__ __volatile__ ("mb" : : : "memory") +#define pg_read_barrier() __asm__ __volatile__ ("rmb" : : : "memory") +#define pg_write_barrier() __asm__ __volatile__ ("wmb" : : : "memory") + +#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) + +/* + * If we're on GCC 4.1.0 or higher, we should be able to get a memory + * barrier out of this compiler built-in. But we prefer to rely on our + * own definitions where possible, and use this only as a fallback. + */ +#define pg_memory_barrier() __sync_synchronize() + +#endif + +#elif defined(__ia64__) || defined(__ia64) + +#define pg_compiler_barrier() _Asm_sched_fence() +#define pg_memory_barrier() _Asm_mf() + +#elif defined(WIN32_ONLY_COMPILER) + +/* Should work on both MSVC and Borland. */ +#include <intrin.h> +#pragma intrinsic(_ReadWriteBarrier) +#define pg_compiler_barrier() _ReadWriteBarrier() +#define pg_memory_barrier() MemoryBarrier() + +#endif + +/* + * If we have no memory barrier implementation for this architecture, we + * fall back to acquiring and releasing a spinlock. This might, in turn, + * fall back to the semaphore-based spinlock implementation, which will be + * amazingly slow. + * + * It's not self-evident that every possible legal implementation of a + * spinlock acquire-and-release would be equivalent to a full memory barrier. + * For example, I'm not sure that Itanium's acq and rel add up to a full + * fence. But all of our actual implementations seem OK in this regard. + */ +#if !defined(pg_memory_barrier) +#define pg_memory_barrier(x) \ + do { S_LOCK(&dummy_spinlock); S_UNLOCK(&dummy_spinlock); } while (0) +#endif + +/* + * If read or write barriers are undefined, we upgrade them to full memory + * barriers. + * + * If a compiler barrier is unavailable, you probably don't want a full + * memory barrier instead, so if you have a use case for a compiler barrier, + * you'd better use #ifdef. + */ +#if !defined(pg_read_barrier) +#define pg_read_barrier() pg_memory_barrier() +#endif +#if !defined(pg_write_barrier) +#define pg_write_barrier() pg_memory_barrier() +#endif + +#endif /* BARRIER_H */ diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 1f1acdc5e0..f0ed762ccc 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3027,7 +3027,6 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, CachedPlanSource *plansource = (CachedPlanSource *) lfirst(l); ListCell *l2; - Assert(plansource->is_valid); foreach(l2, plansource->query_list) { Query *q = (Query *) lfirst(l2); diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out index b1dedd469d..d20790f909 100644 --- a/src/test/regress/expected/create_table.out +++ b/src/test/regress/expected/create_table.out @@ -204,14 +204,19 @@ CREATE TABLE IF NOT EXISTS test_tsvector( t text ); NOTICE: relation "test_tsvector" already exists, skipping -CREATE UNLOGGED TABLE unlogged1 (a int); -- OK +CREATE UNLOGGED TABLE unlogged1 (a int primary key); -- OK +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "unlogged1_pkey" for table "unlogged1" INSERT INTO unlogged1 VALUES (42); -CREATE UNLOGGED TABLE public.unlogged2 (a int); -- also OK -CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int); -- not OK +CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "unlogged2_pkey" for table "unlogged2" +CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK ERROR: only temporary relations may be created in temporary schemas -CREATE TABLE pg_temp.implicity_temp (a int); -- OK -CREATE TEMP TABLE explicitly_temp (a int); -- also OK -CREATE TEMP TABLE pg_temp.doubly_temp (a int); -- also OK -CREATE TEMP TABLE public.temp_to_perm (a int); -- not OK +CREATE TABLE pg_temp.implicitly_temp (a int primary key); -- OK +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "implicitly_temp_pkey" for table "implicitly_temp" +CREATE TEMP TABLE explicitly_temp (a int primary key); -- also OK +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "explicitly_temp_pkey" for table "explicitly_temp" +CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key); -- also OK +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "doubly_temp_pkey" for table "doubly_temp" +CREATE TEMP TABLE public.temp_to_perm (a int primary key); -- not OK ERROR: cannot create temporary relation in non-temporary schema DROP TABLE unlogged1, public.unlogged2; diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql index c1b2acf94d..a050e8b6d1 100644 --- a/src/test/regress/sql/create_table.sql +++ b/src/test/regress/sql/create_table.sql @@ -241,12 +241,12 @@ CREATE TABLE IF NOT EXISTS test_tsvector( t text ); -CREATE UNLOGGED TABLE unlogged1 (a int); -- OK +CREATE UNLOGGED TABLE unlogged1 (a int primary key); -- OK INSERT INTO unlogged1 VALUES (42); -CREATE UNLOGGED TABLE public.unlogged2 (a int); -- also OK -CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int); -- not OK -CREATE TABLE pg_temp.implicity_temp (a int); -- OK -CREATE TEMP TABLE explicitly_temp (a int); -- also OK -CREATE TEMP TABLE pg_temp.doubly_temp (a int); -- also OK -CREATE TEMP TABLE public.temp_to_perm (a int); -- not OK +CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK +CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK +CREATE TABLE pg_temp.implicitly_temp (a int primary key); -- OK +CREATE TEMP TABLE explicitly_temp (a int primary key); -- also OK +CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key); -- also OK +CREATE TEMP TABLE public.temp_to_perm (a int primary key); -- not OK DROP TABLE unlogged1, public.unlogged2; diff --git a/src/tools/pginclude/pgrminclude b/src/tools/pginclude/pgrminclude index d60519a037..7dc5f58d8b 100755 --- a/src/tools/pginclude/pgrminclude +++ b/src/tools/pginclude/pgrminclude @@ -43,8 +43,8 @@ compile_file() { [ "$INCLUDE" = "postgres_fe.h" ] && continue [ "$INCLUDE" = "pg_config.h" ] && continue [ "$INCLUDE" = "c.h" ] && continue - # CppAsString2 will expand undefined identifiers, so skip files that use it - grep -q '\<CppAsString2\>' "$FILE" && continue + # Stringify macros will expand undefined identifiers, so skip files that use it + egrep -q '\<(CppAsString2?|CppConcat)\>' "$FILE" && continue # preserve configure-specific includes # these includes are surrounded by #ifdef's diff --git a/src/tools/win32tzlist.pl b/src/tools/win32tzlist.pl index a5acee7cad..7b0452a268 100755 --- a/src/tools/win32tzlist.pl +++ b/src/tools/win32tzlist.pl @@ -8,11 +8,11 @@ ################################################################# # -# This script compares the timezone information in the Windows -# registry with that in pgtz.c. A list of changes will be written -# to stdout - no attempt is made to automatically edit the file. +# This script compares the timezone information in the Windows registry +# with that in src/bin/initdb/findtimezone.c. A list of changes will be +# written to stdout - no attempt is made to automatically edit the file. # -# Run the script from the src/timezone directory. +# Run the script from the top-level PG source directory. # use strict; @@ -20,6 +20,8 @@ use warnings; use Win32::Registry; +my $tzfile = 'src/bin/initdb/findtimezone.c'; + # # Fetch all timezones in the registry # @@ -57,16 +59,16 @@ $basekey->Close(); # Fetch all timezones currently in the file # my @file_zones; -open(PGTZ,'<pgtz.c') or die "Could not open pgtz.c!\n"; +open(TZFILE,"<$tzfile") or die "Could not open $tzfile!\n"; my $t = $/; undef $/; -my $pgtz = <PGTZ>; -close(PGTZ); +my $pgtz = <TZFILE>; +close(TZFILE); $/ = $t; # Attempt to locate and extract the complete win32_tzmap struct $pgtz =~ /win32_tzmap\[\] =\s+{\s+\/\*[^\/]+\*\/\s+(.+?)};/gs - or die "Could not locate struct win32_tzmap in pgtz.c!"; + or die "Could not locate struct win32_tzmap in $tzfile!"; $pgtz = $1; # Extract each individual record from the struct |