-------------------------------------- -- -- -- DEPRECATED IN FAVOR OF ps.sql -- -- -- -------------------------------------- DROP TYPE process_table_type CASCADE; CREATE OR REPLACE FUNCTION init_ps () RETURNS VOID LANGUAGE plperlu AS $$ use Proc::ProcessTable; my $t = new Proc::ProcessTable; my $sql = "CREATE TYPE process_table_type AS (\n"; foreach my $field (@{[$t->fields]}) { next unless $field =~ /\S/; if ($field =~ /id$/) { $sql .= qq( "ps_$field" INTEGER,\n); } else { $sql .= qq( "ps_$field" TEXT,\n); } } $sql =~ s/,\n$/\n);/m; my $rv = spi_exec_query($sql); return; $$; COMMENT ON FUNCTION init_ps() IS $$ Copyright (c) 2004, David Fetter All rights reserved. Redistribution and use allowed under a BSD license. $$; SELECT init_ps(); CREATE OR REPLACE FUNCTION get_ps () RETURNS SETOF process_table_type LANGUAGE plperlu AS $$ use Proc::ProcessTable; my $sql = < 0 AND NOT a.attisdropped ORDER BY a.attnum SQL my $rv = spi_exec_query($sql); my @fields; foreach my $i ( @{$rv->{rows}} ) { push @fields, $i->{attname}; } my $rows = []; my $proctab = new Proc::ProcessTable; foreach my $proc ( @{$proctab->table} ) { my $row = {}; foreach my $field (@fields) { $row->{$field} = $proc->{ substr($field,3) }; } push @$rows, $row; } return $rows; $$ ; COMMENT ON FUNCTION get_ps() IS $$ Copyright (c) 2004, David Fetter All rights reserved. Redistribution and use allowed under a BSD license. $$;