Project

General

Profile

« Previous | Next » 

Revision 14181

schemas/util.sql: added try_cluster()

View differences:

trunk/schemas/util.sql
5163 5163

  
5164 5164

  
5165 5165
--
5166
-- Name: try_cluster(regclass); Type: FUNCTION; Schema: util; Owner: -
5167
--
5168

  
5169
CREATE FUNCTION try_cluster(table_ regclass) RETURNS void
5170
    LANGUAGE plpgsql STRICT
5171
    AS $$
5172
BEGIN
5173
	PERFORM util.cluster(table_);
5174
EXCEPTION
5175
WHEN undefined_object THEN
5176
	IF SQLERRM LIKE 'there is no previously clustered index for table %' THEN NULL;
5177
	ELSE RAISE; -- rethrow
5178
	END IF;
5179
END;
5180
$$;
5181

  
5182

  
5183
--
5184
-- Name: FUNCTION try_cluster(table_ regclass); Type: COMMENT; Schema: util; Owner: -
5185
--
5186

  
5187
COMMENT ON FUNCTION try_cluster(table_ regclass) IS '
5188
idempotent, but reclusters each time
5189
';
5190

  
5191

  
5192
--
5166 5193
-- Name: try_create(text); Type: FUNCTION; Schema: util; Owner: -
5167 5194
--
5168 5195

  

Also available in: Unified diff