2024-07-09 09:37:17 +00:00
|
|
|
-- Testing integer formats
|
2024-09-18 15:22:36 +00:00
|
|
|
select printf('%%d: %d', 123);
|
|
|
|
select printf('%%d: %d', -123);
|
|
|
|
select printf('%%d: %d', 0);
|
|
|
|
select printf('%%d: %d', 9223372036854775807);
|
|
|
|
select printf('%%i: %i', 123);
|
|
|
|
select printf('%%u: %u', 123);
|
|
|
|
select printf('%%o: %o', 123);
|
|
|
|
select printf('%%x: %x', 123);
|
|
|
|
select printf('%%X: %X', 123);
|
2024-07-09 09:37:17 +00:00
|
|
|
|
|
|
|
-- Testing floating point formats
|
2024-09-18 15:22:36 +00:00
|
|
|
select printf('%%f: %f', 0.0);
|
|
|
|
select printf('%%f: %f', 123.456);
|
|
|
|
select printf('%%f: %f', -123.456);
|
|
|
|
select printf('%%F: %F', 123.456);
|
|
|
|
select printf('%%e: %e', 123.456);
|
|
|
|
select printf('%%E: %E', 123.456);
|
|
|
|
select printf('%%g: %g', 123.456);
|
|
|
|
select printf('%%G: %G', 123.456);
|
|
|
|
select printf('%%a: %a', 123.456);
|
|
|
|
select printf('%%A: %A', 123.456);
|
2024-07-09 09:37:17 +00:00
|
|
|
|
|
|
|
-- Testing character formats
|
2024-09-18 15:22:36 +00:00
|
|
|
select printf('%%s: %s', 'abc');
|
|
|
|
SELECT printf('%%s: %s', '\n\t') FORMAT PrettyCompact;
|
|
|
|
select printf('%%s: %s', '');
|
2024-07-09 09:37:17 +00:00
|
|
|
|
|
|
|
-- Testing the %% specifier
|
2024-09-18 15:22:36 +00:00
|
|
|
select printf('%%%%: %%');
|
2024-07-11 04:15:44 +00:00
|
|
|
|
|
|
|
-- Testing integer formats with precision
|
2024-09-18 15:22:36 +00:00
|
|
|
select printf('%%.5d: %.5d', 123);
|
2024-07-11 04:15:44 +00:00
|
|
|
|
|
|
|
-- Testing floating point formats with precision
|
2024-09-18 15:22:36 +00:00
|
|
|
select printf('%%.2f: %.2f', 123.456);
|
|
|
|
select printf('%%.2e: %.2e', 123.456);
|
|
|
|
select printf('%%.2g: %.2g', 123.456);
|
2024-07-11 04:15:44 +00:00
|
|
|
|
|
|
|
-- Testing character formats with precision
|
2024-09-18 15:22:36 +00:00
|
|
|
select printf('%%.2s: %.2s', 'abc');
|
2024-08-03 14:43:12 +00:00
|
|
|
|
|
|
|
select printf('%%X: %X', 123.123); -- { serverError BAD_ARGUMENTS }
|
|
|
|
select printf('%%A: %A', 'abc'); -- { serverError BAD_ARGUMENTS }
|
|
|
|
select printf('%%s: %s', 100); -- { serverError BAD_ARGUMENTS }
|
|
|
|
select printf('%%n: %n', 100); -- { serverError BAD_ARGUMENTS }
|
2024-09-18 15:22:36 +00:00
|
|
|
select printf('%%f: %f', 0); -- { serverError BAD_ARGUMENTS }
|