]> err.no Git - sope/blob - sope-gdl1/PostgreSQL/PostgreSQL72Context.m
Add libxml2-dev to libsope-xml4.7-dev deps
[sope] / sope-gdl1 / PostgreSQL / PostgreSQL72Context.m
1 /* 
2    PostgreSQL72Context.m
3
4    Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
5    Copyright (C) 2007 Helge Hess
6
7    Author: Helge Hess (helge@mdlink.de)
8
9    This file is part of the PostgreSQL72 Adaptor Library
10
11    This library is free software; you can redistribute it and/or
12    modify it under the terms of the GNU Library General Public
13    License as published by the Free Software Foundation; either
14    version 2 of the License, or (at your option) any later version.
15
16    This library is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19    Library General Public License for more details.
20
21    You should have received a copy of the GNU Library General Public
22    License along with this library; see the file COPYING.LIB.
23    If not, write to the Free Software Foundation,
24    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27 #import "PostgreSQL72Context.h"
28 #import "PostgreSQL72Channel.h"
29 #include "common.h"
30
31 @implementation PostgreSQL72Context
32
33 - (void)channelDidInit:_channel {
34   if ([channels count] > 0) {
35     [NSException raise:@"TooManyOpenChannelsException"
36                  format:@"SybaseAdaptor10 only supports one channel per context"];
37   }
38   [super channelDidInit:_channel];
39 }
40
41 - (BOOL)primaryBeginTransaction {
42   NSException *error;
43
44   error = [[[channels lastObject]
45                       nonretainedObjectValue]
46                       evaluateExpressionX:@"BEGIN TRANSACTION"];
47   if (error == nil)
48     return YES;
49   
50   NSLog(@"%s: could not begin transaction: %@", __PRETTY_FUNCTION__, error);
51   return NO;
52 }
53
54 - (BOOL)primaryCommitTransaction {
55   NSException *error;
56
57   error = [[[channels lastObject]
58                       nonretainedObjectValue]
59                       evaluateExpressionX:@"COMMIT TRANSACTION"];
60
61   if (error == nil)
62     return YES;
63   
64   NSLog(@"%s: could not commit transaction: %@", __PRETTY_FUNCTION__, error);
65   return NO;
66 }
67
68 - (BOOL)primaryRollbackTransaction {
69   NSException *error;
70
71   error = [[[channels lastObject]
72                       nonretainedObjectValue]
73                       evaluateExpressionX:@"ROLLBACK TRANSACTION"];
74
75   if (error == nil)
76     return YES;
77   
78   NSLog(@"%s: could not rollback transaction: %@", __PRETTY_FUNCTION__, error);
79   return NO;
80 }
81
82 - (BOOL)canNestTransactions {
83   return NO;
84 }
85
86 /* NSCopying methods */
87
88 - (id)copyWithZone:(NSZone *)zone {
89   // called when the object is used in some datastructures?
90   return [self retain];
91 }
92
93 @end /* PostgreSQL72Context */
94
95 void __link_PostgreSQL72Context() {
96   // used to force linking of object file
97   __link_PostgreSQL72Context();
98 }