aboutsummaryrefslogtreecommitdiff
path: root/src/tutorial/funcs.source
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-01-17 14:37:38 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2025-01-17 14:37:38 -0500
commit86e4efc52b664b60f9494e062bbf0454cabcb61f (patch)
treeaa59b403af8088c07178c3b040fdc484d388d6e1 /src/tutorial/funcs.source
parent43830ecb8a9b6a1bc322298a77a5e0d87c2e83d4 (diff)
downloadpostgresql-86e4efc52b664b60f9494e062bbf0454cabcb61f.tar.gz
postgresql-86e4efc52b664b60f9494e062bbf0454cabcb61f.zip
Add documentation about calling version-1 C functions from C.
This topic wasn't really covered before, so fill in some details. Author: Florents Tselai <florents.tselai@gmail.com> Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/90853055-5BBD-493D-91E5-721677C7C59B@gmail.com
Diffstat (limited to 'src/tutorial/funcs.source')
-rw-r--r--src/tutorial/funcs.source24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/tutorial/funcs.source b/src/tutorial/funcs.source
index 542b5c81ec9..eb561537542 100644
--- a/src/tutorial/funcs.source
+++ b/src/tutorial/funcs.source
@@ -123,16 +123,25 @@ SELECT * FROM EMP;
-----------------------------
CREATE FUNCTION add_one(integer) RETURNS integer
- AS '_OBJWD_/funcs' LANGUAGE C;
+ AS '_OBJWD_/funcs' LANGUAGE C STRICT;
+
+CREATE FUNCTION add_one(double precision) RETURNS double precision
+ AS '_OBJWD_/funcs' LANGUAGE C STRICT;
CREATE FUNCTION makepoint(point, point) RETURNS point
- AS '_OBJWD_/funcs' LANGUAGE C;
+ AS '_OBJWD_/funcs' LANGUAGE C STRICT;
CREATE FUNCTION copytext(text) RETURNS text
- AS '_OBJWD_/funcs' LANGUAGE C;
+ AS '_OBJWD_/funcs' LANGUAGE C STRICT;
+
+CREATE FUNCTION concat_text(text, text) RETURNS text
+ AS '_OBJWD_/funcs' LANGUAGE C STRICT;
+
+CREATE FUNCTION t_starts_with(text, text) RETURNS boolean
+ AS '_OBJWD_/funcs' LANGUAGE C STRICT;
CREATE FUNCTION c_overpaid(EMP, integer) RETURNS boolean
- AS '_OBJWD_/funcs' LANGUAGE C;
+ AS '_OBJWD_/funcs' LANGUAGE C STRICT;
SELECT add_one(3) AS four;
@@ -140,6 +149,8 @@ SELECT makepoint('(1,2)'::point, '(3,4)'::point ) AS newpoint;
SELECT copytext('hello world!');
+SELECT t_starts_with('foobar', 'foo');
+
SELECT name, c_overpaid(EMP, 1500) AS overpaid
FROM EMP
WHERE name = 'Bill' or name = 'Sam';
@@ -147,10 +158,13 @@ WHERE name = 'Bill' or name = 'Sam';
-- remove functions that were created in this file
DROP FUNCTION c_overpaid(EMP, integer);
+DROP FUNCTION t_starts_with(text, text);
+DROP FUNCTION concat_text(text, text);
DROP FUNCTION copytext(text);
DROP FUNCTION makepoint(point, point);
+DROP FUNCTION add_one(double precision);
DROP FUNCTION add_one(integer);
---DROP FUNCTION clean_EMP();
+DROP FUNCTION clean_EMP();
DROP FUNCTION high_pay();
DROP FUNCTION new_emp();
DROP FUNCTION add_em(integer, integer);