Skip to content

Commit 4bcb764

Browse files
committed
Function get_index_keys() renamed to get_order_by()
It was a FIXME item in the source. Reasonably so.
1 parent a47686a commit 4bcb764

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

bin/expected/repack.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,26 +322,26 @@ CREATE UNIQUE INDEX issue3_idx1 ON issue3 (col1, col2 DESC);
322322
CREATE UNIQUE INDEX issue3_idx2 ON issue3 (col1 DESC, col2 text_pattern_ops);
323323
CREATE UNIQUE INDEX issue3_idx3 ON issue3 (col1 DESC, col2 DESC);
324324
CREATE UNIQUE INDEX issue3_idx4 ON issue3 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
325-
SELECT repack.get_index_keys('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid);
326-
get_index_keys
325+
SELECT repack.get_order_by('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid);
326+
get_order_by
327327
-----------------
328328
col1, col2 DESC
329329
(1 row)
330330

331-
SELECT repack.get_index_keys('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid);
332-
get_index_keys
331+
SELECT repack.get_order_by('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid);
332+
get_order_by
333333
---------------------------
334334
col1 DESC, col2 USING ~<~
335335
(1 row)
336336

337-
SELECT repack.get_index_keys('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid);
338-
get_index_keys
337+
SELECT repack.get_order_by('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid);
338+
get_order_by
339339
----------------------
340340
col1 DESC, col2 DESC
341341
(1 row)
342342

343-
SELECT repack.get_index_keys('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid);
344-
get_index_keys
343+
SELECT repack.get_order_by('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid);
344+
get_order_by
345345
--------------------------------------------------
346346
col1 NULLS FIRST, col2 DESC USING ~<~ NULLS LAST
347347
(1 row)

bin/sql/repack.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ CREATE UNIQUE INDEX issue3_idx2 ON issue3 (col1 DESC, col2 text_pattern_ops);
197197
CREATE UNIQUE INDEX issue3_idx3 ON issue3 (col1 DESC, col2 DESC);
198198
CREATE UNIQUE INDEX issue3_idx4 ON issue3 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
199199

200-
SELECT repack.get_index_keys('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid);
201-
SELECT repack.get_index_keys('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid);
202-
SELECT repack.get_index_keys('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid);
203-
SELECT repack.get_index_keys('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid);
200+
SELECT repack.get_order_by('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid);
201+
SELECT repack.get_order_by('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid);
202+
SELECT repack.get_order_by('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid);
203+
SELECT repack.get_order_by('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid);

lib/pg_repack.sql.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ $$
4444
$$
4545
LANGUAGE sql STABLE STRICT;
4646

47-
CREATE FUNCTION repack.get_index_keys(oid, oid) RETURNS text AS
48-
'MODULE_PATHNAME', 'repack_get_index_keys'
47+
CREATE FUNCTION repack.get_order_by(oid, oid) RETURNS text AS
48+
'MODULE_PATHNAME', 'repack_get_order_by'
4949
LANGUAGE C STABLE STRICT;
5050

5151
CREATE FUNCTION repack.get_create_index_type(oid, name) RETURNS text AS
@@ -183,7 +183,7 @@ CREATE VIEW repack.tables AS
183183
repack.get_drop_columns(R.oid, 'repack.table_' || R.oid) AS drop_columns,
184184
'DELETE FROM repack.log_' || R.oid AS delete_log,
185185
'LOCK TABLE ' || repack.oid2text(R.oid) || ' IN ACCESS EXCLUSIVE MODE' AS lock_table,
186-
repack.get_index_keys(CK.indexrelid, R.oid) AS ckey,
186+
repack.get_order_by(CK.indexrelid, R.oid) AS ckey,
187187
'SELECT * FROM repack.log_' || R.oid || ' ORDER BY id LIMIT $1' AS sql_peek,
188188
'INSERT INTO repack.table_' || R.oid || ' VALUES ($1.*)' AS sql_insert,
189189
'DELETE FROM repack.table_' || R.oid || ' WHERE ' || repack.get_compare_pkey(PK.indexrelid, '$1') AS sql_delete,

lib/repack.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ PG_MODULE_MAGIC;
4141
extern Datum PGUT_EXPORT repack_version(PG_FUNCTION_ARGS);
4242
extern Datum PGUT_EXPORT repack_trigger(PG_FUNCTION_ARGS);
4343
extern Datum PGUT_EXPORT repack_apply(PG_FUNCTION_ARGS);
44-
extern Datum PGUT_EXPORT repack_get_index_keys(PG_FUNCTION_ARGS);
44+
extern Datum PGUT_EXPORT repack_get_order_by(PG_FUNCTION_ARGS);
4545
extern Datum PGUT_EXPORT repack_indexdef(PG_FUNCTION_ARGS);
4646
extern Datum PGUT_EXPORT repack_swap(PG_FUNCTION_ARGS);
4747
extern Datum PGUT_EXPORT repack_drop(PG_FUNCTION_ARGS);
@@ -50,7 +50,7 @@ extern Datum PGUT_EXPORT repack_disable_autovacuum(PG_FUNCTION_ARGS);
5050
PG_FUNCTION_INFO_V1(repack_version);
5151
PG_FUNCTION_INFO_V1(repack_trigger);
5252
PG_FUNCTION_INFO_V1(repack_apply);
53-
PG_FUNCTION_INFO_V1(repack_get_index_keys);
53+
PG_FUNCTION_INFO_V1(repack_get_order_by);
5454
PG_FUNCTION_INFO_V1(repack_indexdef);
5555
PG_FUNCTION_INFO_V1(repack_swap);
5656
PG_FUNCTION_INFO_V1(repack_drop);
@@ -503,20 +503,17 @@ parse_desc_nulls(char *token, char **desc, char **nulls)
503503
}
504504

505505
/**
506-
* @fn Datum repack_get_index_keys(PG_FUNCTION_ARGS)
506+
* @fn Datum repack_get_order_by(PG_FUNCTION_ARGS)
507507
* @brief Get key definition of the index.
508508
*
509-
* repack_get_index_keys(index, table)
509+
* repack_get_order_by(index, table)
510510
*
511511
* @param index Oid of target index.
512512
* @param table Oid of table of the index.
513513
* @retval Create index DDL for temp table.
514-
*
515-
* FIXME: this function is named get_index_keys, but actually returns
516-
* an expression for ORDER BY clause. get_order_by() might be a better name.
517514
*/
518515
Datum
519-
repack_get_index_keys(PG_FUNCTION_ARGS)
516+
repack_get_order_by(PG_FUNCTION_ARGS)
520517
{
521518
Oid index = PG_GETARG_OID(0);
522519
Oid table = PG_GETARG_OID(1);

0 commit comments

Comments
 (0)