-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Support timestamp input for set_system_time function and align…
… its implementation with the original extension (#80) * Support timestamp input for set_system_time function and align its implementation with the original extension * Fix CI failure * Added back set_system_time tests * Update documentation
- Loading branch information
1 parent
923ffb5
commit 6dd5ad8
Showing
6 changed files
with
53 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,17 @@ | ||
-- version 0.6.1 | ||
|
||
CREATE OR REPLACE FUNCTION set_system_time(user_timestamp text) | ||
RETURNS text AS $$ | ||
CREATE OR REPLACE FUNCTION set_system_time(user_timestamp timestamptz) | ||
RETURNS void AS $$ | ||
DECLARE | ||
custom_system_time text; | ||
BEGIN | ||
IF user_timestamp IS NULL THEN | ||
custom_system_time := null; | ||
ELSE | ||
PERFORM | ||
REGEXP_MATCHES(user_timestamp, | ||
'(\d){4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1]) ([0-1]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d{1,3})?(\.\d{1,6})?', | ||
'g'); | ||
IF NOT FOUND THEN | ||
RAISE 'You must enter a timestamp in the following format: YYYY-MM-DD HH24:MI:SS.MS.US (hours are in 24-hour format 00-23, MS and US are optional)'; | ||
ELSE | ||
custom_system_time := user_timestamp; | ||
END IF; | ||
custom_system_time := TO_CHAR(user_timestamp, 'YYYY-MM-DD HH24:MI:SS'); | ||
END IF; | ||
|
||
PERFORM set_config('user_defined.system_time', custom_system_time, false); | ||
|
||
return custom_system_time; | ||
PERFORM set_config('user_defined.system_time', custom_system_time, false); | ||
|
||
END; | ||
END; | ||
$$ LANGUAGE plpgsql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters