]> err.no Git - sope/blob - sope-gdl1/MySQL/MySQL4Context.m
use %p for pointer formats
[sope] / sope-gdl1 / MySQL / MySQL4Context.m
1 /* 
2    MySQL4Context.m
3
4    Copyright (C) 2003-2005 SKYRIX Software AG
5
6    Author: Helge Hess (helge.hess@skyrix.com)
7
8    This file is part of the MySQL4 Adaptor Library
9
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Library General Public
12    License as published by the Free Software Foundation; either
13    version 2 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Library General Public License for more details.
19
20    You should have received a copy of the GNU Library General Public
21    License along with this library; see the file COPYING.LIB.
22    If not, write to the Free Software Foundation,
23    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25
26 #include "MySQL4Context.h"
27 #include "MySQL4Channel.h"
28 #include "common.h"
29
30 /*
31   Note: MySQL doesn't know 'BEGIN TRANSACTION'. It prefers 'START TRANSACTION'
32         which was added in 4.0.11, which is why we use just 'BEGIN' (available
33         since 3.23.17)
34 */
35
36 @implementation MySQL4Context
37
38 - (void)channelDidInit:_channel {
39   if ([channels count] > 0) {
40     [NSException raise:@"TooManyOpenChannelsException"
41                  format:@"MySQL4 only supports one channel per context"];
42   }
43   [super channelDidInit:_channel];
44 }
45
46 - (BOOL)primaryBeginTransaction {
47   BOOL result;
48   
49   result = [[[channels lastObject]
50                        nonretainedObjectValue]
51                        evaluateExpression:@"BEGIN"];
52   
53   return result;
54 }
55
56 - (BOOL)primaryCommitTransaction {
57   BOOL result;
58
59   result = [[[channels lastObject]
60                        nonretainedObjectValue]
61                        evaluateExpression:@"COMMIT"];
62
63   return result;
64 }
65
66 - (BOOL)primaryRollbackTransaction {
67   BOOL result;
68
69   result = [[[channels lastObject]
70                        nonretainedObjectValue]
71                        evaluateExpression:@"ROLLBACK"];
72   return result;
73 }
74
75 - (BOOL)canNestTransactions {
76   return NO;
77 }
78
79 // NSCopying methods
80
81 - (id)copyWithZone:(NSZone *)zone {
82   return [self retain];
83 }
84
85 @end /* MySQL4Context */
86
87 void __link_MySQL4Context() {
88   // used to force linking of object file
89   __link_MySQL4Context();
90 }