File: rmlo.cxx

package info (click to toggle)
libpqxx 4.0.1%2Bdfsg3-8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 16,012 kB
  • ctags: 9,469
  • sloc: sh: 11,289; cpp: 10,801; xml: 1,256; makefile: 287; ansic: 195; python: 159
file content (55 lines) | stat: -rw-r--r-- 836 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Remove large objects given on the command line from the default database
#include <iostream>

#include "pqxx/pqxx"

using namespace PGSTD;
using namespace pqxx;

namespace
{
  class RemoveLO : public transactor<>
  {
    oid m_O;
  public:
    explicit RemoveLO(oid O) : m_O(O) {}

    void operator()(argument_type &T)
    {
      largeobject L(m_O);
      L.remove(T);
    }
  };
}

int main(int, char *argv[])
{
  lazyconnection C;
  bool Failures = false;

  try
  {
    for (int i=1; argv[i]; ++i)
    {
      oid O;
      from_string(argv[i], O);
      try
      {
        C.perform(RemoveLO(O));
      }
      catch (const exception &e)
      {
        cerr << e.what() << endl;
        Failures = true;
      }
    }
  }
  catch (const exception &e)
  {
    cerr << e.what() << endl;
    return 2;
  }

  return Failures;
}