Skip to content

Commit 69aa4f7

Browse files
committed
Merge branch 'master' into 21_dryrun
2 parents d16bdc2 + 08d28df commit 69aa4f7

File tree

8 files changed

+113
-26
lines changed

8 files changed

+113
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.so
44
regress/regression.diffs
55
regress/regression.out
6+
dist/*.zip

META.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
"name": "pg_repack",
33
"abstract": "PostgreSQL module for data reorganization",
44
"description": "Reorganize tables in PostgreSQL databases with minimal locks",
5-
"version": "1.2.0-beta1",
5+
"version": "1.2.1",
66
"maintainer": [
77
"Josh Kupershmidt <schmiddy@gmail.com>",
88
"Daniele Varrazzo <daniele.varrazzo@gmail.com>"
99
],
1010
"tags": [ "bloat", "maintenance", "vacuum", "cluster" ],
11-
"release_status": "testing",
11+
"release_status": "stable",
1212
"license": "bsd",
1313
"provides": {
1414
"pg_repack": {
1515
"file": "lib/pg_repack.sql",
16-
"version": "1.2.0-beta1",
16+
"version": "1.2.1",
1717
"abstract": "Reorganize tables in PostgreSQL databases with minimal locks"
1818
}
1919
},

Makefile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@
77
#
88

99
PG_CONFIG ?= pg_config
10+
EXTENSION = pg_repack
1011

11-
# Pull out the version number from pg_config
12+
.PHONY: dist/$(EXTENSION)-$(EXTVERSION).zip
13+
14+
# Pull out PostgreSQL version number from pg_config
1215
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
1316
ifeq ("$(VERSION)","")
1417
$(error pg_config not found)
1518
endif
1619

17-
# version as a number, e.g. 9.1.4 -> 901
20+
# PostgreSQL version as a number, e.g. 9.1.4 -> 901
1821
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed 's/\([[:digit:]]\{1,\}\)\.\([[:digit:]]\{1,\}\).*/\1*100+\2/'))))
1922

23+
# The version number of the library
24+
EXTVERSION = $(shell grep '"version":' META.json | head -1 \
25+
| sed -e 's/[ ]*"version":[ ]*"\(.*\)",/\1/')
26+
2027
# We support PostgreSQL 8.3 and later.
2128
ifeq ($(shell echo $$(($(INTVERSION) < 803))),1)
22-
$(error pg_repack requires PostgreSQL 8.3 or later. This is $(VERSION))
29+
$(error $(EXTENSION) requires PostgreSQL 8.3 or later. This is $(VERSION))
2330
endif
2431

2532

@@ -36,3 +43,12 @@ check installcheck:
3643
$(MAKE) -C $$dir $@ || CHECKERR=$$?; \
3744
done; \
3845
exit $$CHECKERR
46+
47+
# Prepare the package for PGXN submission
48+
package: dist dist/$(EXTENSION)-$(EXTVERSION).zip
49+
50+
dist:
51+
mkdir -p dist
52+
53+
dist/$(EXTENSION)-$(EXTVERSION).zip:
54+
git archive --format zip --prefix=$(EXTENSION)-$(EXTVERSION)/ --output $@ master

README.rst

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,34 @@ CLUSTER directly.
1717
Please check the documentation (in the ``doc`` directory or online_) for
1818
installation and usage instructions.
1919

20+
All users of pg_reorg 1.1.9 or earlier, and pg_repack 1.2.0-beta1 or earlier,
21+
are **urged to upgrade** to the latest pg_repack version to fix a serious
22+
data corruption issue_.
23+
2024
.. _pg_repack: http://reorg.github.com/pg_repack
2125
.. _CLUSTER: http://www.postgresql.org/docs/current/static/sql-cluster.html
2226
.. _VACUUM FULL: VACUUM_
2327
.. _VACUUM: http://www.postgresql.org/docs/current/static/sql-vacuum.html
2428
.. _online: pg_repack_
29+
.. _issue: https://github.com/reorg/pg_repack/issues/23
2530

2631

2732
What about pg_reorg?
2833
--------------------
2934

3035
pg_repack is a fork of the pg_reorg_ project, which has proven hugely
31-
successful. Unfortunately development appears to have stopped after the
32-
release of the version 1.1.7, around August 2011.
33-
34-
pg_repack 1.1.8 was released as a drop-in replacement for pg_reorg, addressing
35-
some of the shortcomings of the last pg_reorg version (such as support for
36-
PostgreSQL 9.2 and EXTENSION packaging) and known bugs. Shortly after the
37-
first pg_repack release, pg_reorg 1.1.8 was released too, merging all the
38-
pg_repack changes. Version 1.1.8 is the last pg_reorg release at the time of
39-
writing.
40-
41-
pg_repack 1.2 is a new development line based on the original pg_reorg
42-
codebase and offering new features. Its behaviour may be different from the
43-
1.1.x release so it shouldn't be considered a drop-in replacement: you are
44-
advised to check the documentation__ before upgrading from previous versions.
36+
successful. Unfortunately new feature development on pg_reorg_ has slowed
37+
or stopped since late 2011.
38+
39+
pg_repack was initially released as a drop-in replacement for pg_reorg,
40+
addressing some of the shortcomings of the last pg_reorg version (such as
41+
support for PostgreSQL 9.2 and EXTENSION packaging) and known bugs.
42+
43+
pg_repack 1.2 introduces further new features (parallel index builds,
44+
ability to rebuild only indexes) and bugfixes. In some cases its behaviour
45+
may be different from the 1.1.x release so it shouldn't be considered a
46+
drop-in replacement: you are advised to check the documentation__ before
47+
upgrading from previous versions.
4548

4649
.. __: pg_repack_
4750
.. _pg_reorg: http://reorg.projects.pgfoundry.org/

doc/pg_repack.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ Releases
450450
* Don't wait for locks held in other databases (pg_repack issue #11).
451451
* Bugfix: correctly handle key indexes with options such as DESC, NULL
452452
FIRST/LAST, COLLATE (pg_repack issue #3).
453+
* Fixed data corruption bug on delete (pg_repack issue #23).
453454
* More helpful program output and error messages.
454455

455456
* pg_repack 1.1.8

doc/release.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
What to do to release pg_repack
2+
===============================
3+
4+
This document is the list of operations to do to release a new pg_repack
5+
version. The version number in this document is indicated by ``$VER``: it
6+
should be a three-digit dot-separated version, eventually followed by a
7+
pre-release string: ``1.2.0``, ``1.2.1``, ``1.2-dev0``, ``1.2.0-beta1`` are
8+
valid version numbers.
9+
10+
In order to release the package you will accounts on Github, Freecode and PGXN
11+
with the right privileges: contact Daniele Varrazzo to obtain them.
12+
13+
- Set the right version number in ``META.json`` (note: it's in two different
14+
places).
15+
- Set the right release_status in ``META.json``: ``testing`` or ``stable``.
16+
- Commit the above metadata changes.
17+
- Create a tag, signed if possible::
18+
19+
git tag -a -s ver_$VER
20+
21+
- Create a package running ``make package``. The package will be called
22+
``dist/pg_repack-$VER.zip``.
23+
24+
- Check the packages installs and tests ok with `pgxn client`__::
25+
26+
pgxn install --sudo -- dist/pg_repack-$VER.zip
27+
pgxn check dist/pg_repack-$VER.zip
28+
29+
(note that ``check`` may require the Postgres bin directory to be added to
30+
the path; check the ``install`` log to see where ``pg_repack`` executable
31+
was installed).
32+
33+
.. __: http://pgxnclient.projects.pgfoundry.org/
34+
35+
- Push the code changes and tags on github::
36+
37+
git push
38+
git push --tags
39+
40+
- Upload the package on http://manager.pgxn.org/.
41+
42+
- Check the uploaded package works as expected::
43+
44+
pgxn install --sudo -- pg_repack
45+
pgxn check pg_repack
46+
47+
- Upload the docs by pushing in the repos at
48+
http://reorg.github.io/pg_repack/. The operations are roughly::
49+
50+
git clone git@github.com:reorg/reorg.github.com.git
51+
cd reorg.github.com.git
52+
git submodule init
53+
git submodule update
54+
make
55+
git commit -a -m "Docs upload for release $VER"
56+
git push
57+
58+
- Check the page http://reorg.github.io/pg_repack/ is right.
59+
60+
- Announce the package on reorg-general@pgfoundry.org and
61+
pgsql-announce@postgresql.org.
62+
63+
- Announce the package on http://freecode.com/.

lib/pg_repack.sql.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ CREATE VIEW repack.tables AS
190190
'INSERT INTO repack.table_' || R.oid || ' VALUES ($1.*)' AS sql_insert,
191191
'DELETE FROM repack.table_' || R.oid || ' WHERE ' || repack.get_compare_pkey(PK.indexrelid, '$1') AS sql_delete,
192192
'UPDATE repack.table_' || R.oid || ' SET ' || repack.get_assign(R.oid, '$2') || ' WHERE ' || repack.get_compare_pkey(PK.indexrelid, '$1') AS sql_update,
193-
'DELETE FROM repack.log_' || R.oid || ' WHERE id <= $1' AS sql_pop
193+
'DELETE FROM repack.log_' || R.oid || ' WHERE id = $1' AS sql_pop
194194
FROM pg_class R
195195
LEFT JOIN pg_class T ON R.reltoastrelid = T.oid
196196
LEFT JOIN repack.primary_keys PK

lib/repack.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,16 @@ repack_apply(PG_FUNCTION_ARGS)
282282
plan_update = repack_prepare(sql_update, 2, &argtypes[1]);
283283
execute_plan(SPI_OK_UPDATE, plan_update, &values[1], &nulls[1]);
284284
}
285+
/* Delete tuple in log.
286+
* XXX It would be a lot more efficient to perform
287+
* this DELETE in bulk, but be careful to only
288+
* delete log entries we have actually processed.
289+
*/
290+
if (plan_pop == NULL)
291+
plan_pop = repack_prepare(sql_pop, 1, argtypes);
292+
execute_plan(SPI_OK_DELETE, plan_pop, values, nulls);
285293
}
286294

287-
/* delete tuple in log */
288-
if (plan_pop == NULL)
289-
plan_pop = repack_prepare(sql_pop, 1, argtypes);
290-
execute_plan(SPI_OK_DELETE, plan_pop, values, nulls);
291-
292295
SPI_freetuptable(tuptable);
293296
}
294297

0 commit comments

Comments
 (0)