user32: Remove _wassert workaround.
[wine.git] / dlls / msi / alter.c
blob7d272118537f1529025f680366d584f5a948228a
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2006 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "wine/debug.h"
27 #include "msi.h"
28 #include "msiquery.h"
29 #include "objbase.h"
30 #include "objidl.h"
31 #include "msipriv.h"
33 #include "query.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
37 typedef struct tagMSIALTERVIEW
39 MSIVIEW view;
40 MSIDATABASE *db;
41 MSIVIEW *table;
42 column_info *colinfo;
43 INT hold;
44 } MSIALTERVIEW;
46 static UINT ALTER_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
48 MSIALTERVIEW *av = (MSIALTERVIEW*)view;
50 TRACE("%p %d %d %p\n", av, row, col, val );
52 return ERROR_FUNCTION_FAILED;
55 static UINT ALTER_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
57 MSIALTERVIEW *av = (MSIALTERVIEW*)view;
59 TRACE("%p %d %d %p\n", av, row, col, stm );
61 return ERROR_FUNCTION_FAILED;
64 static UINT ALTER_execute( struct tagMSIVIEW *view, MSIRECORD *record )
66 MSIALTERVIEW *av = (MSIALTERVIEW*)view;
67 UINT ref;
69 TRACE("%p %p\n", av, record);
71 if (av->colinfo)
72 return av->table->ops->add_column(av->table, av->colinfo->column,
73 av->colinfo->type, av->hold == 1);
75 if (av->hold == 1)
76 av->table->ops->add_ref(av->table);
77 else if (av->hold == -1)
79 ref = av->table->ops->release(av->table);
80 if (ref == 0)
81 av->table = NULL;
84 return ERROR_SUCCESS;
87 static UINT ALTER_close( struct tagMSIVIEW *view )
89 MSIALTERVIEW *av = (MSIALTERVIEW*)view;
91 TRACE("%p\n", av );
93 return ERROR_SUCCESS;
96 static UINT ALTER_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
98 MSIALTERVIEW *av = (MSIALTERVIEW*)view;
100 TRACE("%p %p %p\n", av, rows, cols );
102 return ERROR_FUNCTION_FAILED;
105 static UINT ALTER_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
106 UINT *type, BOOL *temporary, LPCWSTR *table_name )
108 MSIALTERVIEW *av = (MSIALTERVIEW*)view;
110 TRACE("%p %d %p %p %p %p\n", av, n, name, type, temporary, table_name );
112 return ERROR_FUNCTION_FAILED;
115 static UINT ALTER_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
116 MSIRECORD *rec, UINT row )
118 MSIALTERVIEW *av = (MSIALTERVIEW*)view;
120 TRACE("%p %d %p\n", av, eModifyMode, rec );
122 return ERROR_FUNCTION_FAILED;
125 static UINT ALTER_delete( struct tagMSIVIEW *view )
127 MSIALTERVIEW *av = (MSIALTERVIEW*)view;
129 TRACE("%p\n", av );
130 if (av->table)
131 av->table->ops->delete( av->table );
132 msi_free( av );
134 return ERROR_SUCCESS;
137 static const MSIVIEWOPS alter_ops =
139 ALTER_fetch_int,
140 ALTER_fetch_stream,
141 NULL,
142 NULL,
143 NULL,
144 NULL,
145 NULL,
146 NULL,
147 ALTER_execute,
148 ALTER_close,
149 ALTER_get_dimensions,
150 ALTER_get_column_info,
151 ALTER_modify,
152 ALTER_delete,
153 NULL,
154 NULL,
155 NULL,
156 NULL,
157 NULL,
160 UINT ALTER_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR name, column_info *colinfo, int hold )
162 MSIALTERVIEW *av;
163 UINT r;
165 TRACE("%p %p %s %d\n", view, colinfo, debugstr_w(name), hold );
167 av = msi_alloc_zero( sizeof *av );
168 if( !av )
169 return ERROR_FUNCTION_FAILED;
171 r = TABLE_CreateView( db, name, &av->table );
172 if (r != ERROR_SUCCESS)
174 msi_free( av );
175 return r;
178 if (colinfo)
179 colinfo->table = name;
181 /* fill the structure */
182 av->view.ops = &alter_ops;
183 av->db = db;
184 av->hold = hold;
185 av->colinfo = colinfo;
187 *view = &av->view;
189 return ERROR_SUCCESS;