# HG changeset patch # User František Kučera # Date 1409600306 -7200 # Node ID 88bf2cb5e7575699b0cb81634f5321bc6d469c32 # Parent 9963cf89ffd7f6dd20c7aef1ebe80e9f08f21e8b prototyp: processes – skeleton diff -r 9963cf89ffd7 -r 88bf2cb5e757 prototyp/prototyp.sql --- a/prototyp/prototyp.sql Mon Sep 01 21:08:55 2014 +0200 +++ b/prototyp/prototyp.sql Mon Sep 01 21:38:26 2014 +0200 @@ -100,8 +100,6 @@ use User::grent; - my $i = 0; - setgrent(); while (my $group = getgrent()) { return_next({ @@ -146,8 +144,6 @@ use encoding "UTF-8"; use User::pwent; - my $i = 0; - setpwent(); while (my $user = getpwent()) { return_next({ @@ -197,3 +193,42 @@ ; COMMENT ON COLUMN users_groups.initial IS 'whether this group is the „initial login group“ of given user (the primary group)'; + +-- processes: ---------------------------------------------------------------- + +DROP VIEW IF EXISTS processes; +DROP FUNCTION IF EXISTS processes(); +DROP TYPE IF EXISTS unix_sql_api_processes; + +CREATE TYPE unix_sql_api_processes AS ( + id INTEGER, + uid INTEGER, + owner VARCHAR, + command VARCHAR, + arguments VARCHAR[], + working_dir VARCHAR +); + +CREATE OR REPLACE FUNCTION processes() +RETURNS SETOF unix_sql_api_processes STABLE AS $$ + use strict; + use warnings; + + use encoding "UTF-8"; + + return_next({ + id => 123, + uid => 456, + owner => "nikdo", + command => "/bin/omg", + arguments => ["a", "b"], + working_dir => "/tmp" + }); + + return undef; +$$ LANGUAGE plperlu; + +CREATE OR REPLACE VIEW processes AS + SELECT * FROM processes() +; +