| 1 | package Net::Clacks::PostgreSQL2Clacks; | ||||||||||||||||||||||||||||||||||
| 2 | #---AUTOPRAGMASTART--- | ||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use diagnostics; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp qw[carp croak confess cluck longmess shortmess]; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION = 36; | |||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use autodie qw( close ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Array::Contains; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Encode qw(is_utf8 encode_utf8 decode_utf8); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use builtin qw[true false is_bool]; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | no warnings qw(experimental::builtin); ## no critic (TestingAndDebugging::ProhibitNoWarnings) | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | #---AUTOPRAGMAEND--- | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Net::Clacks::Client; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use DBI; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Time::HiRes qw(sleep); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | ▶ | sub new($class, %config) { | |||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 24 | 0 | my $self = bless \%config, $class; | |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if(!defined($self->{clacks})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 27 | 0 | croak("clacks config not defined"); | |||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | 0 | my @requireds = qw(username password clientname); | |||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if(!defined($self->{clacks}->{socket})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 32 | 0 | push @requireds, 'server'; | |||||||||||||||||||||||||||||||||
| 33 | 0 | push @requireds, 'port'; | |||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | 0 | foreach my $required (@requireds) { | |||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if(!defined($self->{clacks}->{$required})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 38 | 0 | croak("clacks setting $required not defined"); | |||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if(!defined($self->{clacks}->{caching})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 43 | 0 | $self->{clacks}->{caching} = 0; | |||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if(!defined($self->{postgres})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 47 | 0 | croak("postgres config not defined"); | |||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 0 | foreach my $required (qw(url username password)) { | |||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if(!defined($self->{postgres}->{$required})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 52 | 0 | croak("postgres setting $required not defined"); | |||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | 0 | my $clacks; | |||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if(defined($self->{clacks}->{socket})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 59 | # Unix domain sockets | ||||||||||||||||||||||||||||||||||
| 60 | $clacks = Net::Clacks::Client->newSocket($self->{clacks}->{socket}, $self->{clacks}->{username}, $self->{clacks}->{password}, $self->{clacks}->{clientname}, $self->{clacks}->{caching}) | ||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | or croak("Failed to connect to Clacks"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||||||||
| 63 | # TCP/IP connection | ||||||||||||||||||||||||||||||||||
| 64 | $clacks = Net::Clacks::Client->new($self->{clacks}->{server}, $self->{clacks}->{port}, $self->{clacks}->{username}, $self->{clacks}->{password}, $self->{clacks}->{clientname}, $self->{clacks}->{caching}) | ||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | or croak("Failed to connect to Clacks"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | my $dbh = DBI->connect($self->{postgres}->{url}, $self->{postgres}->{username}, $self->{postgres}->{password}, | ||||||||||||||||||||||||||||||||||
| 69 | { | ||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | AutoCommit => 0, | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 71 | RaiseError => 0, | ||||||||||||||||||||||||||||||||||
| 72 | AutoInactiveDestroy => 1, | ||||||||||||||||||||||||||||||||||
| 73 | }) or croak($EVAL_ERROR); | ||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->{clacks} = $clacks; | |||||||||||||||||||||||||||||||||
| 76 | 0 | $self->{dbh} = $dbh; | |||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | 0 | $self->{nextping} = time + 10; | |||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->{dbh}->do('LISTEN clacksmessage'); | |||||||||||||||||||||||||||||||||
| 81 | 0 | $self->{dbh}->commit; | |||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||
| 86 | ▶ | sub initFunctions($self) { | |||||||||||||||||||||||||||||||||
|
Subroutine
initFunctions: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | 0 | my @stmts = $self->getStatements(); | |||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | # Create/update function on PostgreSQL side | ||||||||||||||||||||||||||||||||||
| 91 | 0 | foreach my $stmt (@stmts) { | |||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if(!$self->{dbh}->do($stmt)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 93 | 0 | croak($self->{dbh}->errstr); | |||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||
| 96 | 0 | $self->{dbh}->commit; | |||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | 0 | return; | |||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | ▶ | sub run($self) { | |||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 102 | 0 | while(1) { | |||||||||||||||||||||||||||||||||
| 103 | 0 | my @lines = $self->runOnce(); | |||||||||||||||||||||||||||||||||
| 104 | 0 | foreach my $line (@lines) { | |||||||||||||||||||||||||||||||||
| 105 | 0 | print STDERR $line, "\n"; | |||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||
| 107 | 0 | sleep(0.1); | |||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||
| 110 | 0 | return; | |||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||
| 113 | ▶ | sub runOnce($self) { | |||||||||||||||||||||||||||||||||
|
Subroutine
runOnce: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if(!$self->{dbh}->ping) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 115 | 0 | croak("Database connection failed!"); | |||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||
| 117 | 0 | my @lines; | |||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||
| 119 | 0 | $self->{clacks}->doNetwork(); | |||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if(time < $self->{nextping}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 122 | 0 | $self->{clacks}->ping(); | |||||||||||||||||||||||||||||||||
| 123 | 0 | $self->{nextping} = time + 10; | |||||||||||||||||||||||||||||||||
| 124 | 0 | $self->{clacks}->doNetwork(); | |||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | while((my $message = $self->{clacks}->getNext())) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 129 | # We mostly do this to keep the inbuffer nice and empty. | ||||||||||||||||||||||||||||||||||
| 130 | # Since we neither LISTEN nor expect any other message, we should be fine | ||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if($message->{type} eq 'serverinfo') { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 132 | 0 | push @lines, "Connected to " . $message->{data}; | |||||||||||||||||||||||||||||||||
| 133 | } elsif($message->{type} eq 'disconnect') { | ||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if($message->{data} eq 'timeout') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 135 | 0 | push @lines, "Connection timeout! If you use runOnce() instead of run(), make sure to call it at least every 10 seconds!"; | |||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||
| 137 | 0 | push @lines, "Connection to server lost."; | |||||||||||||||||||||||||||||||||
| 138 | } elsif($message->{type} eq 'reconnected') { | ||||||||||||||||||||||||||||||||||
| 139 | 0 | push @lines, "Reconnected to server."; | |||||||||||||||||||||||||||||||||
| 140 | } else { | ||||||||||||||||||||||||||||||||||
| 141 | 0 | push @lines, "Clacks-Message: " . $message->{type} . " ignored.\n"; | |||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | while((my $notify = $self->{dbh}->pg_notifies)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 147 | 0 | my ($nname, $npid, $npayload) = @{$notify}; | |||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||
| 149 | 0 | my ($command, $name, $value) = split/\§\§\§CLACKSDELIMETER\§\§\§/, $npayload; | |||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if(!defined($name)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 152 | 0 | $name = ''; | |||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if(!defined($value)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 156 | 0 | $value = ''; | |||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||
| 159 | 0 | my $line = join(' ', $command, $name, $value); | |||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if($command eq 'NOTIFY') { | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 161 | 0 | $self->{clacks}->notify($name); | |||||||||||||||||||||||||||||||||
| 162 | } elsif($command eq 'SET') { | ||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->{clacks}->set($name, $value); | |||||||||||||||||||||||||||||||||
| 164 | } elsif($command eq 'STORE') { | ||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->{clacks}->store($name, $value); | |||||||||||||||||||||||||||||||||
| 166 | } elsif($command eq 'SETANDSTORE') { | ||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->{clacks}->setAndStore($name, $value); | |||||||||||||||||||||||||||||||||
| 168 | } elsif($command eq 'INCREMENT') { | ||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->{clacks}->increment($name, $value); | |||||||||||||||||||||||||||||||||
| 170 | } elsif($command eq 'DECREMENT') { | ||||||||||||||||||||||||||||||||||
| 171 | 0 | $self->{clacks}->decrement($name, $value); | |||||||||||||||||||||||||||||||||
| 172 | } elsif($command eq 'REMOVE') { | ||||||||||||||||||||||||||||||||||
| 173 | 0 | $self->{clacks}->remove($name); | |||||||||||||||||||||||||||||||||
| 174 | } else { | ||||||||||||||||||||||||||||||||||
| 175 | 0 | $line = 'UNKNOWN COMMAND: ' . $line; | |||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | 0 | push @lines, $line; | |||||||||||||||||||||||||||||||||
| 179 | 0 | $self->{dbh}->commit; | |||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{clacks}->doNetwork(); | |||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->{dbh}->commit; | |||||||||||||||||||||||||||||||||
| 183 | 0 | $self->{clacks}->doNetwork(); | |||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||
| 185 | 0 | return @lines; | |||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | ▶ | sub DESTROY($self) { | |||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 190 | # Try to disconnect cleanly, but socket might already be DESTROYed, so catch any errors | ||||||||||||||||||||||||||||||||||
| 191 | 0 | eval { ## no critic (ErrorHandling::RequireCheckingReturnValueOfEval) | |||||||||||||||||||||||||||||||||
| 192 | 0 | $self->{clacks}->disconnect(); | |||||||||||||||||||||||||||||||||
| 193 | 0 | $self->{dbh}->disconnect(); | |||||||||||||||||||||||||||||||||
| 194 | }; | ||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||
| 196 | 0 | return; | |||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||
| 199 | ▶ | sub getStatements($self) { | |||||||||||||||||||||||||||||||||
|
Subroutine
getStatements: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 200 | return ( | ||||||||||||||||||||||||||||||||||
| 201 | 0 | "CREATE OR REPLACE FUNCTION clacks_notify(clacksname text) RETURNS void AS \$\$ | |||||||||||||||||||||||||||||||||
| 202 | BEGIN | ||||||||||||||||||||||||||||||||||
| 203 | PERFORM pg_notify('clacksmessage', 'NOTIFY' || '§§§CLACKSDELIMETER§§§' || clacksname); | ||||||||||||||||||||||||||||||||||
| 204 | RETURN; | ||||||||||||||||||||||||||||||||||
| 205 | END | ||||||||||||||||||||||||||||||||||
| 206 | \$\$ LANGUAGE plpgsql;", | ||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||
| 208 | "CREATE OR REPLACE FUNCTION clacks_set(clacksname text, clacksvalue text) RETURNS void AS \$\$ | ||||||||||||||||||||||||||||||||||
| 209 | BEGIN | ||||||||||||||||||||||||||||||||||
| 210 | PERFORM pg_notify('clacksmessage', 'SET' || '§§§CLACKSDELIMETER§§§' || clacksname || '§§§CLACKSDELIMETER§§§' || clacksvalue); | ||||||||||||||||||||||||||||||||||
| 211 | RETURN; | ||||||||||||||||||||||||||||||||||
| 212 | END | ||||||||||||||||||||||||||||||||||
| 213 | \$\$ LANGUAGE plpgsql;", | ||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||
| 215 | "CREATE OR REPLACE FUNCTION clacks_store(clacksname text, clacksvalue text) RETURNS void AS \$\$ | ||||||||||||||||||||||||||||||||||
| 216 | BEGIN | ||||||||||||||||||||||||||||||||||
| 217 | PERFORM pg_notify('clacksmessage', 'STORE' || '§§§CLACKSDELIMETER§§§' || clacksname || '§§§CLACKSDELIMETER§§§' || clacksvalue); | ||||||||||||||||||||||||||||||||||
| 218 | RETURN; | ||||||||||||||||||||||||||||||||||
| 219 | END | ||||||||||||||||||||||||||||||||||
| 220 | \$\$ LANGUAGE plpgsql;", | ||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | "CREATE OR REPLACE FUNCTION clacks_setandstore(clacksname text, clacksvalue text) RETURNS void AS \$\$ | ||||||||||||||||||||||||||||||||||
| 223 | BEGIN | ||||||||||||||||||||||||||||||||||
| 224 | PERFORM pg_notify('clacksmessage', 'SETANDSTORE' || '§§§CLACKSDELIMETER§§§' || clacksname || '§§§CLACKSDELIMETER§§§' || clacksvalue); | ||||||||||||||||||||||||||||||||||
| 225 | RETURN; | ||||||||||||||||||||||||||||||||||
| 226 | END | ||||||||||||||||||||||||||||||||||
| 227 | \$\$ LANGUAGE plpgsql;", | ||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | "CREATE OR REPLACE FUNCTION clacks_increment(clacksname text, clacksvalue text) RETURNS void AS \$\$ | ||||||||||||||||||||||||||||||||||
| 230 | BEGIN | ||||||||||||||||||||||||||||||||||
| 231 | PERFORM pg_notify('clacksmessage', 'INCREMENT' || '§§§CLACKSDELIMETER§§§' || clacksname || '§§§CLACKSDELIMETER§§§' || clacksvalue); | ||||||||||||||||||||||||||||||||||
| 232 | RETURN; | ||||||||||||||||||||||||||||||||||
| 233 | END | ||||||||||||||||||||||||||||||||||
| 234 | \$\$ LANGUAGE plpgsql;", | ||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||
| 236 | "CREATE OR REPLACE FUNCTION clacks_decrement(clacksname text, clacksvalue text) RETURNS void AS \$\$ | ||||||||||||||||||||||||||||||||||
| 237 | BEGIN | ||||||||||||||||||||||||||||||||||
| 238 | PERFORM pg_notify('clacksmessage', 'DECREMENT' || '§§§CLACKSDELIMETER§§§' || clacksname || '§§§CLACKSDELIMETER§§§' || clacksvalue); | ||||||||||||||||||||||||||||||||||
| 239 | RETURN; | ||||||||||||||||||||||||||||||||||
| 240 | END | ||||||||||||||||||||||||||||||||||
| 241 | \$\$ LANGUAGE plpgsql;", | ||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | "CREATE OR REPLACE FUNCTION clacks_remove(clacksname text) RETURNS void AS \$\$ | ||||||||||||||||||||||||||||||||||
| 244 | BEGIN | ||||||||||||||||||||||||||||||||||
| 245 | PERFORM pg_notify('clacksmessage', 'REMOVE' || '§§§CLACKSDELIMETER§§§' || clacksname); | ||||||||||||||||||||||||||||||||||
| 246 | RETURN; | ||||||||||||||||||||||||||||||||||
| 247 | END | ||||||||||||||||||||||||||||||||||
| 248 | \$\$ LANGUAGE plpgsql;", | ||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||
| 250 | }; | ||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||
| 253 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 254 | __END__ | ||||||||||||||||||||||||||||||||||