From 4bcb7641c95dd5e85b90b496406460b79bc2345c Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sun, 9 Dec 2012 11:35:52 +0000 Subject: [PATCH] Function get_index_keys() renamed to get_order_by() It was a FIXME item in the source. Reasonably so. --- bin/expected/repack.out | 16 ++++++++-------- bin/sql/repack.sql | 8 ++++---- lib/pg_repack.sql.in | 6 +++--- lib/repack.c | 13 +++++-------- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/bin/expected/repack.out b/bin/expected/repack.out index 25e15b0..9dfb4eb 100644 --- a/bin/expected/repack.out +++ b/bin/expected/repack.out @@ -322,26 +322,26 @@ CREATE UNIQUE INDEX issue3_idx1 ON issue3 (col1, col2 DESC); CREATE UNIQUE INDEX issue3_idx2 ON issue3 (col1 DESC, col2 text_pattern_ops); CREATE UNIQUE INDEX issue3_idx3 ON issue3 (col1 DESC, col2 DESC); CREATE UNIQUE INDEX issue3_idx4 ON issue3 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST); -SELECT repack.get_index_keys('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid); - get_index_keys +SELECT repack.get_order_by('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid); + get_order_by ----------------- col1, col2 DESC (1 row) -SELECT repack.get_index_keys('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid); - get_index_keys +SELECT repack.get_order_by('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid); + get_order_by --------------------------- col1 DESC, col2 USING ~<~ (1 row) -SELECT repack.get_index_keys('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid); - get_index_keys +SELECT repack.get_order_by('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid); + get_order_by ---------------------- col1 DESC, col2 DESC (1 row) -SELECT repack.get_index_keys('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid); - get_index_keys +SELECT repack.get_order_by('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid); + get_order_by -------------------------------------------------- col1 NULLS FIRST, col2 DESC USING ~<~ NULLS LAST (1 row) diff --git a/bin/sql/repack.sql b/bin/sql/repack.sql index 1446a9a..2268c8b 100644 --- a/bin/sql/repack.sql +++ b/bin/sql/repack.sql @@ -197,7 +197,7 @@ CREATE UNIQUE INDEX issue3_idx2 ON issue3 (col1 DESC, col2 text_pattern_ops); CREATE UNIQUE INDEX issue3_idx3 ON issue3 (col1 DESC, col2 DESC); CREATE UNIQUE INDEX issue3_idx4 ON issue3 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST); -SELECT repack.get_index_keys('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid); -SELECT repack.get_index_keys('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid); -SELECT repack.get_index_keys('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid); -SELECT repack.get_index_keys('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid); +SELECT repack.get_order_by('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid); +SELECT repack.get_order_by('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid); +SELECT repack.get_order_by('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid); +SELECT repack.get_order_by('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid); diff --git a/lib/pg_repack.sql.in b/lib/pg_repack.sql.in index 3f78d19..1767938 100644 --- a/lib/pg_repack.sql.in +++ b/lib/pg_repack.sql.in @@ -44,8 +44,8 @@ $$ $$ LANGUAGE sql STABLE STRICT; -CREATE FUNCTION repack.get_index_keys(oid, oid) RETURNS text AS -'MODULE_PATHNAME', 'repack_get_index_keys' +CREATE FUNCTION repack.get_order_by(oid, oid) RETURNS text AS +'MODULE_PATHNAME', 'repack_get_order_by' LANGUAGE C STABLE STRICT; CREATE FUNCTION repack.get_create_index_type(oid, name) RETURNS text AS @@ -183,7 +183,7 @@ CREATE VIEW repack.tables AS repack.get_drop_columns(R.oid, 'repack.table_' || R.oid) AS drop_columns, 'DELETE FROM repack.log_' || R.oid AS delete_log, 'LOCK TABLE ' || repack.oid2text(R.oid) || ' IN ACCESS EXCLUSIVE MODE' AS lock_table, - repack.get_index_keys(CK.indexrelid, R.oid) AS ckey, + repack.get_order_by(CK.indexrelid, R.oid) AS ckey, 'SELECT * FROM repack.log_' || R.oid || ' ORDER BY id LIMIT $1' AS sql_peek, 'INSERT INTO repack.table_' || R.oid || ' VALUES ($1.*)' AS sql_insert, 'DELETE FROM repack.table_' || R.oid || ' WHERE ' || repack.get_compare_pkey(PK.indexrelid, '$1') AS sql_delete, diff --git a/lib/repack.c b/lib/repack.c index 72bf81d..bd4e9e0 100644 --- a/lib/repack.c +++ b/lib/repack.c @@ -41,7 +41,7 @@ PG_MODULE_MAGIC; extern Datum PGUT_EXPORT repack_version(PG_FUNCTION_ARGS); extern Datum PGUT_EXPORT repack_trigger(PG_FUNCTION_ARGS); extern Datum PGUT_EXPORT repack_apply(PG_FUNCTION_ARGS); -extern Datum PGUT_EXPORT repack_get_index_keys(PG_FUNCTION_ARGS); +extern Datum PGUT_EXPORT repack_get_order_by(PG_FUNCTION_ARGS); extern Datum PGUT_EXPORT repack_indexdef(PG_FUNCTION_ARGS); extern Datum PGUT_EXPORT repack_swap(PG_FUNCTION_ARGS); extern Datum PGUT_EXPORT repack_drop(PG_FUNCTION_ARGS); @@ -50,7 +50,7 @@ extern Datum PGUT_EXPORT repack_disable_autovacuum(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(repack_version); PG_FUNCTION_INFO_V1(repack_trigger); PG_FUNCTION_INFO_V1(repack_apply); -PG_FUNCTION_INFO_V1(repack_get_index_keys); +PG_FUNCTION_INFO_V1(repack_get_order_by); PG_FUNCTION_INFO_V1(repack_indexdef); PG_FUNCTION_INFO_V1(repack_swap); PG_FUNCTION_INFO_V1(repack_drop); @@ -503,20 +503,17 @@ parse_desc_nulls(char *token, char **desc, char **nulls) } /** - * @fn Datum repack_get_index_keys(PG_FUNCTION_ARGS) + * @fn Datum repack_get_order_by(PG_FUNCTION_ARGS) * @brief Get key definition of the index. * - * repack_get_index_keys(index, table) + * repack_get_order_by(index, table) * * @param index Oid of target index. * @param table Oid of table of the index. * @retval Create index DDL for temp table. - * - * FIXME: this function is named get_index_keys, but actually returns - * an expression for ORDER BY clause. get_order_by() might be a better name. */ Datum -repack_get_index_keys(PG_FUNCTION_ARGS) +repack_get_order_by(PG_FUNCTION_ARGS) { Oid index = PG_GETARG_OID(0); Oid table = PG_GETARG_OID(1);