Function get_index_keys() renamed to get_order_by()

It was a FIXME item in the source. Reasonably so.
This commit is contained in:
Daniele Varrazzo 2012-12-09 11:35:52 +00:00
parent a47686a7ee
commit 4bcb7641c9
4 changed files with 20 additions and 23 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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,

View File

@ -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);