ReactOS  0.4.14-dev-376-gaedba84
update.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wine/debug.h"
#include "msi.h"
#include "msiquery.h"
#include "objbase.h"
#include "objidl.h"
#include "msipriv.h"
#include "winnls.h"
#include "query.h"
Include dependency graph for update.c:

Go to the source code of this file.

Classes

struct  tagMSIUPDATEVIEW
 

Typedefs

typedef struct tagMSIUPDATEVIEW MSIUPDATEVIEW
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msidb)
 
static UINT UPDATE_fetch_int (struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
 
static UINT UPDATE_execute (struct tagMSIVIEW *view, MSIRECORD *record)
 
static UINT UPDATE_close (struct tagMSIVIEW *view)
 
static UINT UPDATE_get_dimensions (struct tagMSIVIEW *view, UINT *rows, UINT *cols)
 
static UINT UPDATE_get_column_info (struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
 
static UINT UPDATE_modify (struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
 
static UINT UPDATE_delete (struct tagMSIVIEW *view)
 
static UINT UPDATE_find_matching_rows (struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle)
 
UINT UPDATE_CreateView (MSIDATABASE *db, MSIVIEW **view, LPWSTR table, column_info *columns, struct expr *expr)
 

Variables

static const MSIVIEWOPS update_ops
 

Typedef Documentation

◆ MSIUPDATEVIEW

Function Documentation

◆ UPDATE_close()

static UINT UPDATE_close ( struct tagMSIVIEW view)
static

Definition at line 129 of file update.c.

130 {
132  MSIVIEW *wv;
133 
134  TRACE("%p\n", uv);
135 
136  wv = uv->wv;
137  if( !wv )
138  return ERROR_FUNCTION_FAILED;
139 
140  return wv->ops->close( wv );
141 }
MSIVIEW * wv
Definition: update.c:45
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
UINT(* close)(struct tagMSIVIEW *view)
Definition: msipriv.h:273

◆ UPDATE_CreateView()

UINT UPDATE_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
LPWSTR  table,
column_info columns,
struct expr expr 
)

Definition at line 228 of file update.c.

230 {
231  MSIUPDATEVIEW *uv = NULL;
232  UINT r;
233  MSIVIEW *sv = NULL, *wv = NULL;
234 
235  TRACE("%p\n", uv );
236 
237  if (expr)
238  r = WHERE_CreateView( db, &wv, table, expr );
239  else
240  r = TABLE_CreateView( db, table, &wv );
241 
242  if( r != ERROR_SUCCESS )
243  return r;
244 
245  /* then select the columns we want */
246  r = SELECT_CreateView( db, &sv, wv, columns );
247  if( r != ERROR_SUCCESS )
248  {
249  wv->ops->delete( wv );
250  return r;
251  }
252 
253  uv = msi_alloc_zero( sizeof *uv );
254  if( !uv )
255  {
256  wv->ops->delete( wv );
257  return ERROR_FUNCTION_FAILED;
258  }
259 
260  /* fill the structure */
261  uv->view.ops = &update_ops;
262  msiobj_addref( &db->hdr );
263  uv->db = db;
264  uv->vals = columns;
265  uv->wv = sv;
266  *view = (MSIVIEW*) uv;
267 
268  return ERROR_SUCCESS;
269 }
void msiobj_addref(MSIOBJECTHDR *info)
Definition: handle.c:218
#define ERROR_SUCCESS
Definition: deptool.c:10
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view) DECLSPEC_HIDDEN
Definition: table.c:2162
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const struct column * columns
Definition: query.h:86
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
MSIVIEW * wv
Definition: update.c:45
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
column_info * vals
Definition: update.c:46
UINT SELECT_CreateView(MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, const column_info *columns) DECLSPEC_HIDDEN
Definition: select.c:424
smooth NULL
Definition: ftsmooth.c:416
MSIVIEW view
Definition: update.c:43
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
MSIDATABASE * db
Definition: update.c:44
UINT WHERE_CreateView(MSIDATABASE *db, MSIVIEW **view, LPWSTR tables, struct expr *cond) DECLSPEC_HIDDEN
Definition: where.c:1209
unsigned int UINT
Definition: ndis.h:50
MSIOBJECTHDR hdr
Definition: msipriv.h:97
static const MSIVIEWOPS update_ops
Definition: update.c:206

Referenced by yyparse().

◆ UPDATE_delete()

static UINT UPDATE_delete ( struct tagMSIVIEW view)
static

Definition at line 182 of file update.c.

183 {
185  MSIVIEW *wv;
186 
187  TRACE("%p\n", uv );
188 
189  wv = uv->wv;
190  if( wv )
191  wv->ops->delete( wv );
192  msiobj_release( &uv->db->hdr );
193  msi_free( uv );
194 
195  return ERROR_SUCCESS;
196 }
#define ERROR_SUCCESS
Definition: deptool.c:10
MSIVIEW * wv
Definition: update.c:45
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
MSIDATABASE * db
Definition: update.c:44
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:242
UINT(* delete)(struct tagMSIVIEW *)
Definition: msipriv.h:299
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
MSIOBJECTHDR hdr
Definition: msipriv.h:97

◆ UPDATE_execute()

static UINT UPDATE_execute ( struct tagMSIVIEW view,
MSIRECORD record 
)
static

Definition at line 58 of file update.c.

59 {
61  UINT i, r, col_count = 0, row_count = 0;
63  MSIRECORD *where = NULL;
64  MSIVIEW *wv;
65  UINT cols_count, where_count;
66  column_info *col = uv->vals;
67 
68  TRACE("%p %p\n", uv, record );
69 
70  /* extract the where markers from the record */
71  if (record)
72  {
74 
75  for (i = 0; col; col = col->next)
76  i++;
77 
78  cols_count = i;
79  where_count = r - i;
80 
81  if (where_count > 0)
82  {
83  where = MSI_CreateRecord(where_count);
84 
85  if (where)
86  for (i = 1; i <= where_count; i++)
87  MSI_RecordCopyField(record, cols_count + i, where, i);
88  }
89  }
90 
91  wv = uv->wv;
92  if( !wv )
93  {
95  goto done;
96  }
97 
98  r = wv->ops->execute( wv, where );
99  TRACE("tv execute returned %x\n", r);
100  if( r )
101  goto done;
102 
103  r = wv->ops->get_dimensions( wv, &row_count, &col_count );
104  if( r )
105  goto done;
106 
107  values = msi_query_merge_record( col_count, uv->vals, record );
108  if (!values)
109  {
111  goto done;
112  }
113 
114  for ( i=0; i<row_count; i++ )
115  {
116  r = wv->ops->set_row( wv, i, values, (1 << col_count) - 1 );
117  if (r != ERROR_SUCCESS)
118  break;
119  }
120 
121 done:
122  if ( where ) msiobj_release( &where->hdr );
123  if ( values ) msiobj_release( &values->hdr );
124 
125  return r;
126 }
UINT MSI_RecordCopyField(MSIRECORD *, UINT, MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:169
#define ERROR_SUCCESS
Definition: deptool.c:10
UINT(* get_dimensions)(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
Definition: msipriv.h:281
MSIOBJECTHDR hdr
Definition: msipriv.h:141
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
struct _column_info * next
Definition: msipriv.h:216
UINT(* execute)(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: msipriv.h:268
MSIVIEW * wv
Definition: update.c:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
column_info * vals
Definition: update.c:46
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
MSIRECORD * msi_query_merge_record(UINT fields, const column_info *vl, MSIRECORD *rec)
Definition: insert.c:67
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:242
MSIRECORD * MSI_CreateRecord(UINT) DECLSPEC_HIDDEN
Definition: record.c:79
UINT(* set_row)(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
Definition: msipriv.h:253
unsigned int UINT
Definition: ndis.h:50
UINT MSI_RecordGetFieldCount(const MSIRECORD *rec) DECLSPEC_HIDDEN
Definition: record.c:111

◆ UPDATE_fetch_int()

static UINT UPDATE_fetch_int ( struct tagMSIVIEW view,
UINT  row,
UINT  col,
UINT val 
)
static

Definition at line 49 of file update.c.

50 {
52 
53  TRACE("%p %d %d %p\n", uv, row, col, val );
54 
55  return ERROR_FUNCTION_FAILED;
56 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

◆ UPDATE_find_matching_rows()

static UINT UPDATE_find_matching_rows ( struct tagMSIVIEW view,
UINT  col,
UINT  val,
UINT row,
MSIITERHANDLE handle 
)
static

Definition at line 198 of file update.c.

199 {
200  TRACE("%p %d %d %p\n", view, col, val, *handle );
201 
202  return ERROR_FUNCTION_FAILED;
203 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4

◆ UPDATE_get_column_info()

static UINT UPDATE_get_column_info ( struct tagMSIVIEW view,
UINT  n,
LPCWSTR name,
UINT type,
BOOL temporary,
LPCWSTR table_name 
)
static

Definition at line 157 of file update.c.

159 {
161  MSIVIEW *wv;
162 
163  TRACE("%p %d %p %p %p %p\n", uv, n, name, type, temporary, table_name );
164 
165  wv = uv->wv;
166  if( !wv )
167  return ERROR_FUNCTION_FAILED;
168 
169  return wv->ops->get_column_info( wv, n, name, type, temporary, table_name );
170 }
GLdouble n
Definition: glext.h:7729
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
MSIVIEW * wv
Definition: update.c:45
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
UINT(* get_column_info)(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: msipriv.h:288
Definition: name.c:36

◆ UPDATE_get_dimensions()

static UINT UPDATE_get_dimensions ( struct tagMSIVIEW view,
UINT rows,
UINT cols 
)
static

Definition at line 143 of file update.c.

144 {
146  MSIVIEW *wv;
147 
148  TRACE("%p %p %p\n", uv, rows, cols );
149 
150  wv = uv->wv;
151  if( !wv )
152  return ERROR_FUNCTION_FAILED;
153 
154  return wv->ops->get_dimensions( wv, rows, cols );
155 }
UINT(* get_dimensions)(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
Definition: msipriv.h:281
MSIVIEW * wv
Definition: update.c:45
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348

◆ UPDATE_modify()

static UINT UPDATE_modify ( struct tagMSIVIEW view,
MSIMODIFY  eModifyMode,
MSIRECORD rec,
UINT  row 
)
static

Definition at line 172 of file update.c.

174 {
176 
177  TRACE("%p %d %p\n", uv, eModifyMode, rec );
178 
179  return ERROR_FUNCTION_FAILED;
180 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msidb  )

Variable Documentation

◆ update_ops

const MSIVIEWOPS update_ops
static
Initial value:
=
{
}
static UINT UPDATE_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
Definition: update.c:143
static UINT UPDATE_close(struct tagMSIVIEW *view)
Definition: update.c:129
static UINT UPDATE_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
Definition: update.c:49
smooth NULL
Definition: ftsmooth.c:416
static UINT UPDATE_delete(struct tagMSIVIEW *view)
Definition: update.c:182
static UINT UPDATE_execute(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: update.c:58
static UINT UPDATE_get_column_info(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: update.c:157
static UINT UPDATE_find_matching_rows(struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle)
Definition: update.c:198
static UINT UPDATE_modify(struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
Definition: update.c:172

Definition at line 206 of file update.c.

Referenced by UPDATE_CreateView().