WIP: Compiled SQL function #33

Draft
flecomte wants to merge 37 commits from compiled_sql_function into master
10 changed files with 57 additions and 50 deletions
Showing only changes of commit 2cd69d4501 - Show all commits

View File

@@ -278,7 +278,7 @@ class RequesterTest : TestAbstract() {
fun `call exec on function with pair as arguments`() {
val resources = this::class.java.getResource("/sql/function/Test")?.toURI()
val result = Requester(connection, functionsDirectory = resources)
.getFunction("function_void")
.getFunction("test_function_void")
.exec("name" to "test")
assertEquals(1, result.rowsAffected)

View File

@@ -74,7 +74,7 @@ BEGIN
END;
$$;
CREATE OR REPLACE FUNCTION function_void (name text default 'plop') returns void
CREATE OR REPLACE FUNCTION test_function_void (name text default 'plop') returns void
LANGUAGE plpgsql
AS
$$

View File

@@ -1,8 +0,0 @@
CREATE OR REPLACE FUNCTION test_function (name text default 'plop', IN hi text default 'hello', out result json)
LANGUAGE plpgsql
AS
$$
BEGIN
result = json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name);
END;
$$

View File

@@ -1,8 +0,0 @@
CREATE OR REPLACE FUNCTION function_void (name text default 'plop') returns void
LANGUAGE plpgsql
AS
$$
BEGIN
PERFORM 1;
END;
$$;

View File

@@ -0,0 +1,8 @@
create or replace function test_function(name text default 'plop', in hi text default 'hello', out result json)
language plpgsql
as
$$
begin
result = json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name);
end;
$$

View File

@@ -1,4 +1,4 @@
CREATE OR REPLACE FUNCTION function_multiparam (
create or replace function test_function_multiparam(
name varchar(45) default 'plop',
numeric(4, 5),
num float(5),
@@ -13,7 +13,7 @@ CREATE OR REPLACE FUNCTION function_multiparam (
num10 double precision,
num11 smallserial,
num12 serial,
"num13" bigserial,
num13 bigserial,
num14 serial,
num15 money,
num16 character varying(789),
@@ -25,10 +25,10 @@ CREATE OR REPLACE FUNCTION function_multiparam (
num20 anyelement,
num21 anyarray
)
LANGUAGE plpgsql
AS
language plpgsql
as
$$
BEGIN
PERFORM 1;
END;
begin
perform 1;
end;
$$;

View File

@@ -1,11 +1,11 @@
CREATE OR REPLACE FUNCTION test_function_multiple (name text default 'plop', IN hi text default 'hello', out result json)
LANGUAGE plpgsql
AS
create or replace function test_function_multiple(name text default 'plop', in hi text default 'hello', out result json)
language plpgsql
as
$$
BEGIN
begin
result = json_build_array(
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name),
json_build_object('id', '8d20abb0-7f77-4b6c-9991-44acd3c88faa', 'name', hi)
);
END;
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name),
json_build_object('id', '8d20abb0-7f77-4b6c-9991-44acd3c88faa', 'name', hi)
);
end;
$$

View File

@@ -1,8 +1,8 @@
CREATE OR REPLACE FUNCTION test_function_object (inout resource json)
LANGUAGE plpgsql
AS
create or replace function test_function_object(inout resource json)
language plpgsql
as
$$
BEGIN
begin
resource = json_build_object('id', '1e5f5d41-6d14-4007-897b-0ed2616bec96', 'name', 'changedName');
END;
end;
$$

View File

@@ -1,14 +1,21 @@
CREATE OR REPLACE FUNCTION test_function_paginated (name text default 'plop', IN "limit" int default 10, IN "offset" int default 0, out result json, out total int)
LANGUAGE plpgsql
AS
create or replace function test_function_paginated(
name text default 'plop',
in "limit" int default 10,
in "offset" int default 0,
out result json,
out total int
)
language plpgsql
as
$$
BEGIN
SELECT json_build_array(
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name::text),
json_build_object('id', '8d20abb0-7f77-4b6c-9991-44acd3c88faa', 'name', name::text || '-2')
),
10
INTO result, total
LIMIT "limit" OFFSET "offset";
END;
begin
select
json_build_array(
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name::text),
json_build_object('id', '8d20abb0-7f77-4b6c-9991-44acd3c88faa', 'name', name::text || '-2')
),
10
into result, total
limit "limit" offset "offset";
end;
$$

View File

@@ -0,0 +1,8 @@
create or replace function test_function_void(name text default 'plop') returns void
language plpgsql
as
$$
begin
perform 1;
end;
$$;