]> granicus.if.org Git - postgresql/commit
Redesign tablesample method API, and do extensive code review.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 25 Jul 2015 18:39:00 +0000 (14:39 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 25 Jul 2015 18:39:00 +0000 (14:39 -0400)
commit6fcb337fa507723d6940ed8e5658d3da1fac6195
treed02ffcbd146e22042d75a2c38d4b9ab1586f990f
parent7d4240d6cd91d83d263a45501cc2f44fb1d0a537
Redesign tablesample method API, and do extensive code review.

The original implementation of TABLESAMPLE modeled the tablesample method
API on index access methods, which wasn't a good choice because, without
specialized DDL commands, there's no way to build an extension that can
implement a TSM.  (Raw inserts into system catalogs are not an acceptable
thing to do, because we can't undo them during DROP EXTENSION, nor will
pg_upgrade behave sanely.)  Instead adopt an API more like procedural
language handlers or foreign data wrappers, wherein the only SQL-level
support object needed is a single handler function identified by having
a special return type.  This lets us get rid of the supporting catalog
altogether, so that no custom DDL support is needed for the feature.

Adjust the API so that it can support non-constant tablesample arguments
(the original coding assumed we could evaluate the argument expressions at
ExecInitSampleScan time, which is undesirable even if it weren't outright
unsafe), and discourage sampling methods from looking at invisible tuples.
Make sure that the BERNOULLI and SYSTEM methods are genuinely repeatable
within and across queries, as required by the SQL standard, and deal more
honestly with methods that can't support that requirement.

Make a full code-review pass over the tablesample additions, and fix
assorted bugs, omissions, infelicities, and cosmetic issues (such as
failure to put the added code stanzas in a consistent ordering).
Improve EXPLAIN's output of tablesample plans, too.

Back-patch to 9.5 so that we don't have to support the original API
in production.
83 files changed:
contrib/pg_stat_statements/pg_stat_statements.c
contrib/tsm_system_rows/Makefile
contrib/tsm_system_rows/expected/tsm_system_rows.out
contrib/tsm_system_rows/sql/tsm_system_rows.sql
contrib/tsm_system_rows/tsm_system_rows--1.0.sql
contrib/tsm_system_rows/tsm_system_rows.c
contrib/tsm_system_rows/tsm_system_rows.control
contrib/tsm_system_time/Makefile
contrib/tsm_system_time/expected/tsm_system_time.out
contrib/tsm_system_time/sql/tsm_system_time.sql
contrib/tsm_system_time/tsm_system_time--1.0.sql
contrib/tsm_system_time/tsm_system_time.c
contrib/tsm_system_time/tsm_system_time.control
doc/src/sgml/catalogs.sgml
doc/src/sgml/datatype.sgml
doc/src/sgml/postgres.sgml
doc/src/sgml/ref/select.sgml
doc/src/sgml/tablesample-method.sgml
doc/src/sgml/tsm-system-rows.sgml
doc/src/sgml/tsm-system-time.sgml
src/backend/access/heap/heapam.c
src/backend/access/tablesample/Makefile
src/backend/access/tablesample/bernoulli.c
src/backend/access/tablesample/system.c
src/backend/access/tablesample/tablesample.c
src/backend/catalog/Makefile
src/backend/catalog/dependency.c
src/backend/commands/explain.c
src/backend/executor/execAmi.c
src/backend/executor/nodeSamplescan.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/nodeFuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/setrefs.c
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/prep/prepjointree.c
src/backend/optimizer/util/pathnode.c
src/backend/parser/gram.y
src/backend/parser/parse_clause.c
src/backend/parser/parse_func.c
src/backend/rewrite/rewriteHandler.c
src/backend/utils/adt/pseudotypes.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/syscache.c
src/backend/utils/errcodes.txt
src/backend/utils/misc/sampling.c
src/bin/psql/tab-complete.c
src/include/access/heapam.h
src/include/access/tablesample.h [deleted file]
src/include/access/tsmapi.h [new file with mode: 0644]
src/include/catalog/catversion.h
src/include/catalog/indexing.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_tablesample_method.h [deleted file]
src/include/catalog/pg_type.h
src/include/executor/nodeSamplescan.h
src/include/nodes/execnodes.h
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/include/nodes/plannodes.h
src/include/optimizer/cost.h
src/include/parser/parse_func.h
src/include/port.h
src/include/utils/builtins.h
src/include/utils/lsyscache.h
src/include/utils/syscache.h
src/port/erand48.c
src/test/regress/expected/rowsecurity.out
src/test/regress/expected/rules.out
src/test/regress/expected/sanity_check.out
src/test/regress/expected/tablesample.out
src/test/regress/output/misc.source
src/test/regress/serial_schedule
src/test/regress/sql/rowsecurity.sql
src/test/regress/sql/tablesample.sql