From 7ee36f2b58dfd5784970f4d6b19c8ebaf6cdb9d9 Mon Sep 17 00:00:00 2001 From: Marc Munro Date: Mon, 30 Jun 2014 12:26:17 -0700 Subject: [PATCH] New stable version 9.3 --- GNUmakefile | 5 +- find_pg_config | 64 +++++++++ src/veil_funcs.h | 2 +- src/veil_interface.c | 4 +- src/veil_interface.d | 5 + src/veil_mainpage.c | 318 ++++++++----------------------------------- src/veil_serialise.c | 48 +++---- veil.control | 4 +- veil_demo.control | 4 +- 9 files changed, 157 insertions(+), 297 deletions(-) create mode 100755 find_pg_config diff --git a/GNUmakefile b/GNUmakefile index 4a15e78..213a050 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,7 +2,7 @@ # # PGXS-based makefile for Veil # -# Copyright (c) 2005 - 2011 Marc Munro +# Copyright (c) 2005 - 2014 Marc Munro # Author: Marc Munro # License: BSD # @@ -37,7 +37,7 @@ ifneq "$(ALLDOCS)" "" DOCS = $(ALLDOCS) endif -PG_CONFIG = pg_config +PG_CONFIG := $(shell ./find_pg_config) PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS) @@ -99,6 +99,7 @@ tarball_clean: # Ensure that tarball tmp files and dirs are removed by the clean target clean: tarball_clean + @rm -f PG_VERSION veil--*sql veil_demon--*sql # Install veil_demo as well as veil install: demo_install diff --git a/find_pg_config b/find_pg_config new file mode 100755 index 0000000..1981486 --- /dev/null +++ b/find_pg_config @@ -0,0 +1,64 @@ +#! /bin/sh +# Figure out where to find pg_config. This is primarily build for +# debian and debian like systems where multiple versions of postgres may +# be installed. + +# Return a simplified (2-part) version string. +# +strip_version() +{ + sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9][0-9]*.*/\1/' +} + +# Attempt to read the postgres version by connecting to the database +# server. If that fails, use the contents of the PG_VERSION file, if it +# exists. +# +pgver() +{ + if [ "x$1" != "x" ]; then + echo $1 + else + if ver=`psql --no-psqlrc --tuples-only \ + --command="select version()"`; then + # All was well, so record the version in PG_VERSION for later + # use by install (which is run from root and may not have access + # to psql or postgres databases. + ver=`echo ${ver} | awk '{print $2}' | strip_version` + echo $ver >PG_VERSION + echo $ver + else + if [ -f ./PG_VERSION ]; then + cat ./PG_VERSION + else + echo "Cannot establish postgres version..." 1>&2 + echo "Specify PG_VERSION explicitly in the make command." 1>&2 + exit 2 + fi + fi + fi +} + + +# Maybe the correct pg_config is where it claims to be. +# +if ver=`pgver $1`; then + if cver=`pg_config --version | strip_version`; then + if [ "x${cver}" = "x${ver}" ]; then + which pg_config + exit 0 + fi + fi + + # Or maybe, we can figure it out from the database version + if [ -f /usr/lib/postgresql/${ver}/bin/pg_config ]; then + echo /usr/lib/postgresql/${ver}/bin/pg_config + exit 0 + fi + + # If we get here, we really have not much idea, nor anywhere else to + # look. + + echo "Cannot find pg_config for postgres version ${ver}" 1>&2 + exit 2 +fi diff --git a/src/veil_funcs.h b/src/veil_funcs.h index bec17cb..027fdd3 100644 --- a/src/veil_funcs.h +++ b/src/veil_funcs.h @@ -134,5 +134,5 @@ extern Datum veil_deserialise(PG_FUNCTION_ARGS); /* veil_serialise */ extern char *vl_serialise_var(char *name); -extern int4 vl_deserialise(char **p_stream); +extern int32 vl_deserialise(char **p_stream); extern VarEntry *vl_deserialise_next(char **p_stream); diff --git a/src/veil_interface.c b/src/veil_interface.c index 6b96c08..485bd7f 100644 --- a/src/veil_interface.c +++ b/src/veil_interface.c @@ -106,7 +106,7 @@ copystr(char *str) * @return Dynamically allocated string. */ static char * -strfromint(int4 val) +strfromint(int32 val) { char *new = palloc((sizeof(char) * 17)); /* Large enough for any 32 * bit number */ @@ -2495,7 +2495,7 @@ Datum veil_deserialise(PG_FUNCTION_ARGS) { char *stream; - int4 result; + int32 result; text *txt; ensure_init(); diff --git a/src/veil_interface.d b/src/veil_interface.d index e69de29..a242884 100644 --- a/src/veil_interface.d +++ b/src/veil_interface.d @@ -0,0 +1,5 @@ +src/veil_interface.o src/veil_interface.d: \ + src/veil_interface.c \ + src/veil_version.h \ + src/veil_funcs.h \ + src/veil_datatypes.h diff --git a/src/veil_mainpage.c b/src/veil_mainpage.c index 67ec97e..688fbf8 100644 --- a/src/veil_mainpage.c +++ b/src/veil_mainpage.c @@ -11,7 +11,7 @@ /*! \mainpage Veil -\version 9.2.0 (Stable)) +\version 9.3.0 (Stable)) \section license License BSD \section intro_sec Introduction @@ -130,9 +130,10 @@ purposes. \subsection BetterNews Better News -In the latest versions of PostgreSQL, some have been made in the area of -security, particularly with respect to security functions and ensuring -that untrusted functions may not leak data that should be hidden. +In the latest versions of PostgreSQL, some improvements have been made +in the area of security, particularly with respect to security functions +and ensuring that untrusted functions may not leak data that should be +hidden. Note that there are likely to be costs associated with some of these improvements, as the query engine will apply untrusted functions later @@ -145,7 +146,7 @@ is worth any measured loss of performance. You are also advised to follow the progress of Row Level Security support in later versions of Postgres, as this may obviate your need for -Veil. +Veil, or change the way in which you will use it. Next: \ref overview-page @@ -1505,7 +1506,7 @@ personal context: - assignments - person_details -\subsubsection demo-project-context Project Context +\subsection demo-project-context Project Context The following tables may be accessed using rights assigned in the project context: - projects @@ -1913,8 +1914,16 @@ To checkout from git, create a suitable directory and do: git clone git://github.com/marcmunro/veil.git \endverbatim -An alternative repository is also available here: -git@bloodnok.com:veil.git +Alternative repositories are also available: +\verbatim + git clone git://bloodnok.com/veil +\endverbatim + +or +\verbatim + git clone git@github.com:marcmunro/veil.git +\endverbatim + \subsection Pre-requisites Pre-requisites You must have a copy of the Postgresql header files available in order @@ -1935,8 +1944,20 @@ To build the postgres extensions, simply run make with no target: $ make \endverbatim +As part of figuring our the configuration, the makefile will attempt to +work out which version of Postgres to build for. If it fails to figure +this out, add PG_VERSION= to the make command. eg: + +\verbatim +$ make PG_VERSION="9.3" +\endverbatim + To build the veil documentation (the documentation you are now reading) -use make docs. +use: + +\verbatim +$ make docs +\endverbatim Note that the build system deliberately avoids using make recursively. Search the Web for "Recursive Make Considered Harmful" for the reasons @@ -2010,6 +2031,18 @@ Next: \ref History */ /*! \page History History and Compatibility \section past Changes History +\subsection v9_3 Version 9.3.0 (Stable) (2014-06-30) +This version supports PostgreSQL V9.3. + +It deals with the loss of the int4 C datatype, using int32 instead. It +also modifies its bitmap usage to use 64-bit integers on 64-bit +architectures. The older 32-bit version can be built by defining +FORCE_32_BIT on the make command line, eg: + +\verbatim +$ make all FORCE_32_BIT=1 +\endverbatim + \subsection v9_2 Version 9.2.0 (Stable) (2014-06-25) This version supports PostgreSQL V9.2. @@ -2035,285 +2068,40 @@ Major changes include: - documentation changes, including improved comments for Veil functions. -\subsection v9_12 Version 0.9.12 (2010-11-19) -Release for compatibility with PostgreSQL V9.0. Minor bugfixes and -improvements to the build system. Also added documentation about Veil's -limitations. - -\subsection v9_11 Version 0.9.11 (2010-03-12) -Bugfix release, fixing a serious memory corruption bug that has existed -in all previous versions. Users are strongly encouraged to avoid using -older versions of Veil. - -The version number has been deliberatley bumped past 0.9.10 to emphasize -that the last part of the version is a two digit number. - -\subsection v9_9 Version 0.9.9 (2009-07-06) -New release to coincide with PostgreSQL V8.4. - -\subsection v9_8 Version 0.9.8 (2008-02-06) -This is the first Beta release. It incorporates a few bug fixes, a new -serialisation API, improvements to the autoconf setup and makefiles, and -some documentation improvements. The status of Veil has been raised to -Beta in recognition of its relative stability. - -\subsection v9_6 Version 0.9.6 (2008-02-06) -This release has minor changes to support PostgreSQL 8.3. - -\subsection v9_5 Version 0.9.5 (2007-07-31) -This is a bugifx release, fixing a memory allocation bug in the use of -bitmap_refs. There are also fixes for minor typos, etc. - -\subsection v9_4 Version 0.9.4 (2007-02-21) -This is a bugifx release, providing: - - fix for major bug with recursive handling of spi connect, etc; - - improvement to session initialisation code to do more up-front work - in ensure_init(); - - safer initialisation of malloc'd data structures; - - improved error messages for shared memory exhaustion cases; - - addition of debug code including canaries in data structures; - - improvement to autoconf to better support Debian GNU/Linux, and OSX; - - improvement to autoconf/make for handling paths containing spaces; - - improvement to regression tests to better support OSX; - - removal of spurious debug warning messages. - -\subsection v9_3 Version 0.9.3 (2006-10-31) -This version uses the new Postgres API for reserving shared memory for -add-ins. It also allows the number of Veil-enabled databases for a -cluster to be configured, and refactors much of the shared memory code. -A small fix for the Darwin makefile was also made. - -\subsection v9_2 Version 0.9.2 (2006-10-01) -This version was released to coincide with Postgres 8.2beta1 and first -made use of new Postgres APIs to allow Veil to be a good Postgres -citizen. - -With prior versions of Veil, or prior versions of Postgres, Veil steals -from Postgres the shared memory that it requires. This can lead to the -exhaustion of Postgres shared memory. - -Unfortunately, the Postgres API for shared memory reservation had to -change follwing 8.2.beta1, and this version of Veil is therefore deprecated. - -\subsection v9_1 Version 0.9.1 (2006-07-04) -This release fixed a small number of bugs and deficiencies: -- major error in veil_perform_reset that prevented proper use of the two -interdependant shared memory contexts -- minor improvements in the build process to "configure" and friends -- minor documentation improvements - -\subsection v9_0 Version 0.9.0 (2005-10-04) -This was the first public alpha release of Veil. - \section forecast Change Forecast New versions will be released with each new major version of -PostgreSQL. Once there are three PostgreSQL versions for which Veil has -been at production status, the change history and support matrix for for -pre-production versions will be removed from this documentation. +PostgreSQL. \section compatibility Supported versions of Postgres - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + - - - - - - - - + + + + + + +
Veil versionPostgres VersionPostgres Version
7.48.08.18.2beta18.28.38.49.0 9.1 9.2
0.9.0 Alpha111-------
0.9.1 Alpha111-------
0.9.2 Alpha-112------
0.9.3 Alpha-11-3-----
0.9.4 Alpha-11-3-----
0.9.5 Alpha-11-3-----
0.9.6 Alpha-11-33----
0.9.8 Beta-11-33----
0.9.9 Beta-11-333---
0.9.11 Beta-11-333---
0.9.12 Beta-----333--9.3
9.1.0 (Stable)-------- Yes Yes-
9.2.0 (Stable)-------- Yes Yes-
9.3.0 (Stable)- - Yes
-Notes: - -1) These combinations of Veil and Postgres provide no configuration - options for shared memory. Veil's shared memory may be exhausted by - too many requests for large shared objects. Furthermore, Postgres' - own shared memory may be easily exhausted by creating too many - Veil-using databases within a cluster. - -2) This version is deprecated - -3) These combinations of Veil and Postgres provide full configuration - options for shared memory usage, and Veil cooperates with Postgres - for the allocation of such memory meaning that it is not possible to - use Veil to exhaust Postgres' shared memory. This is the minimum - Veil configuration recommended for production use. \section platforms Supported Platforms Veil should be buildable on any platform supported by PostgreSQL and diff --git a/src/veil_serialise.c b/src/veil_serialise.c index f0adb7b..4336802 100644 --- a/src/veil_serialise.c +++ b/src/veil_serialise.c @@ -226,7 +226,7 @@ hdrlen(char *name) * @param value The value to be written to the stream. */ static void -serialise_int4(char **p_stream, int4 value) +serialise_int4(char **p_stream, int32 value) { int len = b64_encode((char *) &value, sizeof(int32), *p_stream); (*p_stream) += (len - 1); /* X: dumb optimisation saves a byte */ @@ -243,10 +243,10 @@ serialise_int4(char **p_stream, int4 value) * reading the int4 value. * @return the int4 value read from the stream */ -static int4 +static int32 deserialise_int4(char **p_stream) { - int4 value; + int32 value; char *endpos = (*p_stream) + INT32SIZE_B64; char endchar = *endpos; *endpos = '='; /* deal with dumb optimisation (X) above */ @@ -256,6 +256,7 @@ deserialise_int4(char **p_stream) return value; } +#ifdef UNUSED_BUT_WORKS /** * Serialise an int8 value as a base64 stream into *p_stream. * @@ -292,6 +293,7 @@ deserialise_int8(char **p_stream) (*p_stream) += INT64SIZE_B64; return value; } +#endif /** * Serialise a binary stream as a base64 stream into *p_stream. @@ -304,7 +306,7 @@ deserialise_int8(char **p_stream) * @param instream The binary stream to be written. */ static void -serialise_stream(char **p_stream, int4 bytes, char *instream) +serialise_stream(char **p_stream, int32 bytes, char *instream) { int len = b64_encode(instream, bytes, *p_stream); (*p_stream)[len] = '\0'; @@ -322,9 +324,9 @@ serialise_stream(char **p_stream, int4 bytes, char *instream) * the binary from p_stream is to be written. */ static void -deserialise_stream(char **p_stream, int4 bytes, char *outstream) +deserialise_stream(char **p_stream, int32 bytes, char *outstream) { - int4 len = streamlen(bytes); + int32 len = streamlen(bytes); b64_decode(*p_stream, len, outstream); (*p_stream) += len; } @@ -535,9 +537,9 @@ static VarEntry * deserialise_int4array(char **p_stream) { char *name = deserialise_name(p_stream); - int4 arrayzero; - int4 arraymax; - int4 elems; + int32 arrayzero; + int32 arraymax; + int32 elems; VarEntry *var = vl_lookup_variable(name); Int4Array *array = (Int4Array *) var->obj; @@ -553,7 +555,7 @@ deserialise_int4array(char **p_stream) array = vl_NewInt4Array(array, var->shared, arrayzero, arraymax); var->obj = (Object *) array; - deserialise_stream(p_stream, elems * sizeof(int4), + deserialise_stream(p_stream, elems * sizeof(int32), (char *) &(array->array[0])); return var; } @@ -670,9 +672,9 @@ deserialise_one_bitmap(Bitmap **p_bitmap, char *name, bool shared, char **p_stream) { Bitmap *bitmap = *p_bitmap; - int4 bitzero; - int4 bitmax; - int4 elems; + int32 bitzero; + int32 bitmax; + int32 elems; bitzero = deserialise_int4(p_stream); bitmax = deserialise_int4(p_stream); @@ -758,12 +760,12 @@ static VarEntry * deserialise_bitmap_array(char **p_stream) { char *name = deserialise_name(p_stream); - int4 bitzero; - int4 bitmax; - int4 arrayzero; - int4 arraymax; - int4 array_elems; - int4 idx; + int32 bitzero; + int32 bitmax; + int32 arrayzero; + int32 arraymax; + int32 array_elems; + int32 idx; VarEntry *var = vl_lookup_variable(name); BitmapArray *bmarray = (BitmapArray *) var->obj; @@ -865,8 +867,8 @@ deserialise_bitmap_hash(char **p_stream) { char *name = deserialise_name(p_stream); char *hashkey; - int4 bitzero; - int4 bitmax; + int32 bitzero; + int32 bitmax; VarEntry *var = vl_lookup_variable(name); BitmapHash *bmhash = (BitmapHash *) var->obj; Bitmap *tmp_bitmap = NULL; @@ -937,7 +939,7 @@ vl_serialise_var(char *name) (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Unsupported type for variable serialisation"), errdetail("Cannot serialise objects of type %d.", - (int4) var->obj->type))); + (int32) var->obj->type))); } } @@ -990,7 +992,7 @@ vl_deserialise_next(char **p_stream) * @param **p_stream Pointer into the stream currently being read. * @return A count of the number of variables that have been de-serialised. */ -extern int4 +extern int32 vl_deserialise(char **p_stream) { int count = 0; diff --git a/veil.control b/veil.control index 40d23ed..8d6c8c2 100644 --- a/veil.control +++ b/veil.control @@ -2,13 +2,13 @@ # # Postgres extension control file for Veil # -# Copyright (c) 2011 - 2012 Marc Munro +# Copyright (c) 2011 - 2014 Marc Munro # Author: Marc Munro # License: BSD # directory = 'extension' -default_version = '9.2.0' +default_version = '9.3.0' module_pathname = '$libdir/veil' superuser = true relocatable = false diff --git a/veil_demo.control b/veil_demo.control index 5618b19..b3a7777 100644 --- a/veil_demo.control +++ b/veil_demo.control @@ -2,13 +2,13 @@ # # Postgres extension control file for veil_demo # -# Copyright (c) 2011 - 2012 Marc Munro +# Copyright (c) 2011 - 2014 Marc Munro # Author: Marc Munro # License: BSD # directory = 'extension' -default_version = '9.2.0' +default_version = '9.3.0' superuser = true relocatable = false requires = veil -- 2.39.5