ReactOS  0.4.15-dev-1374-g8d3e80e
alter.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 "query.h"
Include dependency graph for alter.c:

Go to the source code of this file.

Classes

struct  tagMSIALTERVIEW
 

Typedefs

typedef struct tagMSIALTERVIEW MSIALTERVIEW
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msidb)
 
static UINT ALTER_fetch_int (struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
 
static UINT ALTER_fetch_stream (struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
 
static UINT ALTER_get_row (struct tagMSIVIEW *view, UINT row, MSIRECORD **rec)
 
static UINT ITERATE_columns (MSIRECORD *row, LPVOID param)
 
static BOOL check_column_exists (MSIDATABASE *db, LPCWSTR table, LPCWSTR column)
 
static UINT alter_add_column (MSIALTERVIEW *av)
 
static UINT ALTER_execute (struct tagMSIVIEW *view, MSIRECORD *record)
 
static UINT ALTER_close (struct tagMSIVIEW *view)
 
static UINT ALTER_get_dimensions (struct tagMSIVIEW *view, UINT *rows, UINT *cols)
 
static UINT ALTER_get_column_info (struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
 
static UINT ALTER_modify (struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
 
static UINT ALTER_delete (struct tagMSIVIEW *view)
 
static UINT ALTER_find_matching_rows (struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle)
 
UINT ALTER_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR name, column_info *colinfo, int hold)
 

Variables

static const MSIVIEWOPS alter_ops
 

Typedef Documentation

◆ MSIALTERVIEW

Function Documentation

◆ alter_add_column()

static UINT alter_add_column ( MSIALTERVIEW av)
static

Definition at line 109 of file alter.c.

110 {
111  UINT r, colnum = 1;
112  MSIQUERY *view;
113  MSIVIEW *columns;
114 
115  static const WCHAR szColumns[] = {'_','C','o','l','u','m','n','s',0};
116  static const WCHAR query[] = {
117  'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
118  '`','_','C','o','l','u','m','n','s','`',' ','W','H','E','R','E',' ',
119  '`','T','a','b','l','e','`','=','\'','%','s','\'',' ','O','R','D','E','R',' ',
120  'B','Y',' ','`','N','u','m','b','e','r','`',0
121  };
122 
123  r = TABLE_CreateView(av->db, szColumns, &columns);
124  if (r != ERROR_SUCCESS)
125  return r;
126 
127  if (check_column_exists(av->db, av->colinfo->table, av->colinfo->column))
128  {
129  columns->ops->delete(columns);
130  return ERROR_BAD_QUERY_SYNTAX;
131  }
132 
133  r = MSI_OpenQuery(av->db, &view, query, av->colinfo->table, av->colinfo->column);
134  if (r == ERROR_SUCCESS)
135  {
137  msiobj_release(&view->hdr);
138  if (r != ERROR_SUCCESS)
139  {
140  columns->ops->delete(columns);
141  return r;
142  }
143  }
144  r = columns->ops->add_column(columns, av->colinfo->table,
145  colnum, av->colinfo->column,
146  av->colinfo->type, (av->hold == 1));
147 
148  columns->ops->delete(columns);
149  return r;
150 }
#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
MSIDATABASE * db
Definition: alter.c:40
static UINT ITERATE_columns(MSIRECORD *row, LPVOID param)
Definition: alter.c:73
UINT MSI_OpenQuery(MSIDATABASE *, MSIQUERY **, LPCWSTR,...) DECLSPEC_HIDDEN
Definition: msiquery.c:143
UINT(* add_column)(struct tagMSIVIEW *view, LPCWSTR table, UINT number, LPCWSTR column, UINT type, BOOL hold)
Definition: msipriv.h:327
LPCWSTR column
Definition: msipriv.h:212
static BOOL check_column_exists(MSIDATABASE *db, LPCWSTR table, LPCWSTR column)
Definition: alter.c:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
const MSIVIEWOPS * ops
Definition: msipriv.h:348
static const WCHAR szColumns[]
Definition: table.c:79
column_info * colinfo
Definition: alter.c:42
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:242
UINT(* delete)(struct tagMSIVIEW *)
Definition: msipriv.h:299
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
LPCWSTR table
Definition: msipriv.h:211
static IOleDocumentView * view
Definition: activex.c:1749
UINT MSI_IterateRecords(MSIQUERY *, LPDWORD, record_func, LPVOID) DECLSPEC_HIDDEN
Definition: msiquery.c:168
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973

Referenced by ALTER_execute().

◆ ALTER_close()

static UINT ALTER_close ( struct tagMSIVIEW view)
static

Definition at line 174 of file alter.c.

175 {
177 
178  TRACE("%p\n", av );
179 
180  return ERROR_SUCCESS;
181 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRACE(s)
Definition: solgame.cpp:4

◆ ALTER_CreateView()

UINT ALTER_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
LPCWSTR  name,
column_info colinfo,
int  hold 
)

Definition at line 255 of file alter.c.

256 {
257  MSIALTERVIEW *av;
258  UINT r;
259 
260  TRACE("%p %p %s %d\n", view, colinfo, debugstr_w(name), hold );
261 
262  av = msi_alloc_zero( sizeof *av );
263  if( !av )
264  return ERROR_FUNCTION_FAILED;
265 
266  r = TABLE_CreateView( db, name, &av->table );
267  if (r != ERROR_SUCCESS)
268  {
269  msi_free( av );
270  return r;
271  }
272 
273  if (colinfo)
274  colinfo->table = name;
275 
276  /* fill the structure */
277  av->view.ops = &alter_ops;
278  av->db = db;
279  av->hold = hold;
280  av->colinfo = colinfo;
281 
282  *view = &av->view;
283 
284  return ERROR_SUCCESS;
285 }
#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
MSIDATABASE * db
Definition: alter.c:40
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
column_info * colinfo
Definition: alter.c:42
MSIVIEW * table
Definition: alter.c:41
static const MSIVIEWOPS alter_ops
Definition: alter.c:232
unsigned int UINT
Definition: ndis.h:50
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
LPCWSTR table
Definition: msipriv.h:211
Definition: name.c:38
MSIVIEW view
Definition: alter.c:39
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by yyparse().

◆ ALTER_delete()

static UINT ALTER_delete ( struct tagMSIVIEW view)
static

Definition at line 212 of file alter.c.

213 {
215 
216  TRACE("%p\n", av );
217  if (av->table)
218  av->table->ops->delete( av->table );
219  msi_free( av );
220 
221  return ERROR_SUCCESS;
222 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
MSIVIEW * table
Definition: alter.c:41
UINT(* delete)(struct tagMSIVIEW *)
Definition: msipriv.h:299
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227

◆ ALTER_execute()

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

Definition at line 152 of file alter.c.

153 {
155  UINT ref;
156 
157  TRACE("%p %p\n", av, record);
158 
159  if (av->hold == 1)
160  av->table->ops->add_ref(av->table);
161  else if (av->hold == -1)
162  {
163  ref = av->table->ops->release(av->table);
164  if (ref == 0)
165  av->table = NULL;
166  }
167 
168  if (av->colinfo)
169  return alter_add_column(av);
170 
171  return ERROR_SUCCESS;
172 }
#define ERROR_SUCCESS
Definition: deptool.c:10
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
column_info * colinfo
Definition: alter.c:42
MSIVIEW * table
Definition: alter.c:41
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
UINT(* release)(struct tagMSIVIEW *view)
Definition: msipriv.h:322
static UINT alter_add_column(MSIALTERVIEW *av)
Definition: alter.c:109
UINT(* add_ref)(struct tagMSIVIEW *view)
Definition: msipriv.h:317

◆ ALTER_fetch_int()

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

Definition at line 46 of file alter.c.

47 {
49 
50  TRACE("%p %d %d %p\n", av, row, col, val );
51 
52  return ERROR_FUNCTION_FAILED;
53 }
#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

◆ ALTER_fetch_stream()

static UINT ALTER_fetch_stream ( struct tagMSIVIEW view,
UINT  row,
UINT  col,
IStream **  stm 
)
static

Definition at line 55 of file alter.c.

56 {
58 
59  TRACE("%p %d %d %p\n", av, row, col, stm );
60 
61  return ERROR_FUNCTION_FAILED;
62 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#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

◆ ALTER_find_matching_rows()

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

Definition at line 224 of file alter.c.

226 {
227  TRACE("%p, %d, %u, %p\n", view, col, val, *handle);
228 
229  return ERROR_FUNCTION_FAILED;
230 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4

◆ ALTER_get_column_info()

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

Definition at line 192 of file alter.c.

194 {
196 
197  TRACE("%p %d %p %p %p %p\n", av, n, name, type, temporary, table_name );
198 
199  return ERROR_FUNCTION_FAILED;
200 }
GLdouble n
Definition: glext.h:7729
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4
Definition: name.c:38
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

◆ ALTER_get_dimensions()

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

Definition at line 183 of file alter.c.

184 {
186 
187  TRACE("%p %p %p\n", av, rows, cols );
188 
189  return ERROR_FUNCTION_FAILED;
190 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4

◆ ALTER_get_row()

static UINT ALTER_get_row ( struct tagMSIVIEW view,
UINT  row,
MSIRECORD **  rec 
)
static

Definition at line 64 of file alter.c.

65 {
67 
68  TRACE("%p %d %p\n", av, row, rec );
69 
70  return av->table->ops->get_row(av->table, row, rec);
71 }
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
MSIVIEW * table
Definition: alter.c:41
UINT(* get_row)(struct tagMSIVIEW *view, UINT row, MSIRECORD **rec)
Definition: msipriv.h:246
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

◆ ALTER_modify()

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

Definition at line 202 of file alter.c.

204 {
206 
207  TRACE("%p %d %p\n", av, eModifyMode, rec );
208 
209  return ERROR_FUNCTION_FAILED;
210 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4

◆ check_column_exists()

static BOOL check_column_exists ( MSIDATABASE db,
LPCWSTR  table,
LPCWSTR  column 
)
static

Definition at line 79 of file alter.c.

80 {
81  MSIQUERY *view;
82  MSIRECORD *rec;
83  UINT r;
84 
85  static const WCHAR query[] = {
86  'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
87  '`','_','C','o','l','u','m','n','s','`',' ','W','H','E','R','E',' ',
88  '`','T','a','b','l','e','`','=','\'','%','s','\'',' ','A','N','D',' ',
89  '`','N','a','m','e','`','=','\'','%','s','\'',0
90  };
91 
92  r = MSI_OpenQuery(db, &view, query, table, column);
93  if (r != ERROR_SUCCESS)
94  return FALSE;
95 
97  if (r != ERROR_SUCCESS)
98  goto done;
99 
100  r = MSI_ViewFetch(view, &rec);
101  if (r == ERROR_SUCCESS)
102  msiobj_release(&rec->hdr);
103 
104 done:
105  msiobj_release(&view->hdr);
106  return (r == ERROR_SUCCESS);
107 }
#define ERROR_SUCCESS
Definition: deptool.c:10
MSIOBJECTHDR hdr
Definition: msipriv.h:141
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
UINT MSI_ViewExecute(MSIQUERY *, MSIRECORD *) DECLSPEC_HIDDEN
Definition: msiquery.c:443
UINT MSI_OpenQuery(MSIDATABASE *, MSIQUERY **, LPCWSTR,...) DECLSPEC_HIDDEN
Definition: msiquery.c:143
UINT MSI_ViewFetch(MSIQUERY *, MSIRECORD **) DECLSPEC_HIDDEN
Definition: msiquery.c:364
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:242
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static IOleDocumentView * view
Definition: activex.c:1749

Referenced by alter_add_column().

◆ ITERATE_columns()

static UINT ITERATE_columns ( MSIRECORD row,
LPVOID  param 
)
static

Definition at line 73 of file alter.c.

74 {
75  (*(UINT *)param)++;
76  return ERROR_SUCCESS;
77 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLfloat param
Definition: glext.h:5796
unsigned int UINT
Definition: ndis.h:50

Referenced by alter_add_column().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msidb  )

Variable Documentation

◆ alter_ops

const MSIVIEWOPS alter_ops
static
Initial value:
=
{
}
static UINT ALTER_get_row(struct tagMSIVIEW *view, UINT row, MSIRECORD **rec)
Definition: alter.c:64
static UINT ALTER_delete(struct tagMSIVIEW *view)
Definition: alter.c:212
static UINT ALTER_fetch_stream(struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
Definition: alter.c:55
static UINT ALTER_execute(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: alter.c:152
static UINT ALTER_modify(struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
Definition: alter.c:202
static UINT ALTER_close(struct tagMSIVIEW *view)
Definition: alter.c:174
static UINT ALTER_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
Definition: alter.c:183
static UINT ALTER_find_matching_rows(struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle)
Definition: alter.c:224
static UINT ALTER_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
Definition: alter.c:46
#define NULL
Definition: types.h:112
static UINT ALTER_get_column_info(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: alter.c:192

Definition at line 232 of file alter.c.

Referenced by ALTER_CreateView().