ReactOS  0.4.14-dev-297-g23e575c
query.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "objidl.h"
#include "msi.h"
#include "msiquery.h"
#include "msipriv.h"
#include "wine/list.h"
Include dependency graph for query.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sql_str
 
struct  complex_expr
 
union  ext_column
 
struct  expr
 
struct  SQL_input
 

Macros

#define OP_EQ   1
 
#define OP_AND   2
 
#define OP_OR   3
 
#define OP_GT   4
 
#define OP_LT   5
 
#define OP_LE   6
 
#define OP_GE   7
 
#define OP_NE   8
 
#define OP_ISNULL   9
 
#define OP_NOTNULL   10
 
#define EXPR_COMPLEX   1
 
#define EXPR_COLUMN   2
 
#define EXPR_COL_NUMBER   3
 
#define EXPR_IVAL   4
 
#define EXPR_SVAL   5
 
#define EXPR_UVAL   6
 
#define EXPR_STRCMP   7
 
#define EXPR_WILDCARD   9
 
#define EXPR_COL_NUMBER_STRING   10
 
#define EXPR_COL_NUMBER32   11
 
#define EXPR_UNARY   12
 

Functions

UINT MSI_ParseSQL (MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview, struct list *mem) DECLSPEC_HIDDEN
 
UINT TABLE_CreateView (MSIDATABASE *db, LPCWSTR name, MSIVIEW **view) DECLSPEC_HIDDEN
 
UINT SELECT_CreateView (MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, const column_info *columns) DECLSPEC_HIDDEN
 
UINT DISTINCT_CreateView (MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table) DECLSPEC_HIDDEN
 
UINT ORDER_CreateView (MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, column_info *columns) DECLSPEC_HIDDEN
 
UINT WHERE_CreateView (MSIDATABASE *db, MSIVIEW **view, LPWSTR tables, struct expr *cond) DECLSPEC_HIDDEN
 
UINT CREATE_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, column_info *col_info, BOOL hold) DECLSPEC_HIDDEN
 
UINT INSERT_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, column_info *columns, column_info *values, BOOL temp) DECLSPEC_HIDDEN
 
UINT UPDATE_CreateView (MSIDATABASE *db, MSIVIEW **view, LPWSTR table, column_info *list, struct expr *expr) DECLSPEC_HIDDEN
 
UINT DELETE_CreateView (MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table) DECLSPEC_HIDDEN
 
UINT ALTER_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR name, column_info *colinfo, int hold) DECLSPEC_HIDDEN
 
UINT STREAMS_CreateView (MSIDATABASE *db, MSIVIEW **view) DECLSPEC_HIDDEN
 
UINT STORAGES_CreateView (MSIDATABASE *db, MSIVIEW **view) DECLSPEC_HIDDEN
 
UINT DROP_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR name) DECLSPEC_HIDDEN
 
int sqliteGetToken (const WCHAR *z, int *tokenType, int *skip) DECLSPEC_HIDDEN
 
MSIRECORDmsi_query_merge_record (UINT fields, const column_info *vl, MSIRECORD *rec) DECLSPEC_HIDDEN
 
UINT msi_create_table (MSIDATABASE *db, LPCWSTR name, column_info *col_info, MSICONDITION persistent) DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ EXPR_COL_NUMBER

#define EXPR_COL_NUMBER   3

Definition at line 49 of file query.h.

◆ EXPR_COL_NUMBER32

#define EXPR_COL_NUMBER32   11

Definition at line 56 of file query.h.

◆ EXPR_COL_NUMBER_STRING

#define EXPR_COL_NUMBER_STRING   10

Definition at line 55 of file query.h.

◆ EXPR_COLUMN

#define EXPR_COLUMN   2

Definition at line 48 of file query.h.

◆ EXPR_COMPLEX

#define EXPR_COMPLEX   1

Definition at line 47 of file query.h.

◆ EXPR_IVAL

#define EXPR_IVAL   4

Definition at line 50 of file query.h.

◆ EXPR_STRCMP

#define EXPR_STRCMP   7

Definition at line 53 of file query.h.

◆ EXPR_SVAL

#define EXPR_SVAL   5

Definition at line 51 of file query.h.

◆ EXPR_UNARY

#define EXPR_UNARY   12

Definition at line 57 of file query.h.

◆ EXPR_UVAL

#define EXPR_UVAL   6

Definition at line 52 of file query.h.

◆ EXPR_WILDCARD

#define EXPR_WILDCARD   9

Definition at line 54 of file query.h.

◆ OP_AND

#define OP_AND   2

Definition at line 37 of file query.h.

◆ OP_EQ

#define OP_EQ   1

Definition at line 36 of file query.h.

◆ OP_GE

#define OP_GE   7

Definition at line 42 of file query.h.

◆ OP_GT

#define OP_GT   4

Definition at line 39 of file query.h.

◆ OP_ISNULL

#define OP_ISNULL   9

Definition at line 44 of file query.h.

◆ OP_LE

#define OP_LE   6

Definition at line 41 of file query.h.

◆ OP_LT

#define OP_LT   5

Definition at line 40 of file query.h.

◆ OP_NE

#define OP_NE   8

Definition at line 43 of file query.h.

◆ OP_NOTNULL

#define OP_NOTNULL   10

Definition at line 45 of file query.h.

◆ OP_OR

#define OP_OR   3

Definition at line 38 of file query.h.

Function Documentation

◆ 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:36
MSIVIEW view
Definition: alter.c:39
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by yyparse().

◆ CREATE_CreateView()

UINT CREATE_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
LPCWSTR  table,
column_info col_info,
BOOL  hold 
)

Definition at line 161 of file create.c.

163 {
164  MSICREATEVIEW *cv = NULL;
165  UINT r;
166  column_info *col;
167  BOOL temp = TRUE;
168  BOOL tempprim = FALSE;
169 
170  TRACE("%p\n", cv );
171 
172  r = check_columns( col_info );
173  if( r != ERROR_SUCCESS )
174  return r;
175 
176  cv = msi_alloc_zero( sizeof *cv );
177  if( !cv )
178  return ERROR_FUNCTION_FAILED;
179 
180  for( col = col_info; col; col = col->next )
181  {
182  if (!col->table)
183  col->table = table;
184 
185  if( !col->temporary )
186  temp = FALSE;
187  else if ( col->type & MSITYPE_KEY )
188  tempprim = TRUE;
189  }
190 
191  if ( !temp && tempprim )
192  {
193  msi_free( cv );
194  return ERROR_FUNCTION_FAILED;
195  }
196 
197  /* fill the structure */
198  cv->view.ops = &create_ops;
199  msiobj_addref( &db->hdr );
200  cv->db = db;
201  cv->name = table;
202  cv->col_info = col_info;
203  cv->bIsTemp = temp;
204  cv->hold = hold;
205  *view = (MSIVIEW*) cv;
206 
207  return ERROR_SUCCESS;
208 }
void msiobj_addref(MSIOBJECTHDR *info)
Definition: handle.c:218
static const MSIVIEWOPS create_ops
Definition: create.c:125
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
struct _column_info * next
Definition: msipriv.h:216
MSIVIEW view
Definition: create.c:44
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
BOOL bIsTemp
Definition: create.c:47
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
LPCWSTR name
Definition: create.c:46
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
#define MSITYPE_KEY
Definition: msipriv.h:49
static calc_node_t temp
Definition: rpn_ieee.c:38
unsigned int UINT
Definition: ndis.h:50
BOOL temporary
Definition: msipriv.h:214
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
LPCWSTR table
Definition: msipriv.h:211
MSIDATABASE * db
Definition: create.c:45
static UINT check_columns(const column_info *col_info)
Definition: create.c:148
column_info * col_info
Definition: create.c:49
MSIOBJECTHDR hdr
Definition: msipriv.h:97

Referenced by yyparse().

◆ DELETE_CreateView()

UINT DELETE_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
MSIVIEW table 
)

Definition at line 199 of file delete.c.

200 {
201  MSIDELETEVIEW *dv = NULL;
202 
203  TRACE("%p\n", dv );
204 
205  dv = msi_alloc_zero( sizeof *dv );
206  if( !dv )
207  return ERROR_FUNCTION_FAILED;
208 
209  /* fill the structure */
210  dv->view.ops = &delete_ops;
211  dv->db = db;
212  dv->table = table;
213 
214  *view = &dv->view;
215 
216  return ERROR_SUCCESS;
217 }
#define ERROR_SUCCESS
Definition: deptool.c:10
MSIVIEW view
Definition: delete.c:53
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
MSIVIEW * table
Definition: delete.c:55
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
smooth NULL
Definition: ftsmooth.c:416
MSIDATABASE * db
Definition: delete.c:54
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
static const MSIVIEWOPS delete_ops
Definition: delete.c:176

Referenced by yyparse().

◆ DISTINCT_CreateView()

UINT DISTINCT_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
MSIVIEW table 
)

Definition at line 294 of file distinct.c.

295 {
296  MSIDISTINCTVIEW *dv = NULL;
297  UINT count = 0, r;
298 
299  TRACE("%p\n", dv );
300 
301  r = table->ops->get_dimensions( table, NULL, &count );
302  if( r != ERROR_SUCCESS )
303  {
304  ERR("can't get table dimensions\n");
305  return r;
306  }
307 
308  dv = msi_alloc_zero( sizeof *dv );
309  if( !dv )
310  return ERROR_FUNCTION_FAILED;
311 
312  /* fill the structure */
313  dv->view.ops = &distinct_ops;
314  msiobj_addref( &db->hdr );
315  dv->db = db;
316  dv->table = table;
317  dv->translation = NULL;
318  dv->row_count = 0;
319  *view = (MSIVIEW*) dv;
320 
321  return ERROR_SUCCESS;
322 }
void msiobj_addref(MSIOBJECTHDR *info)
Definition: handle.c:218
static const MSIVIEWOPS distinct_ops
Definition: distinct.c:271
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
smooth NULL
Definition: ftsmooth.c:416
MSIVIEW * table
Definition: distinct.c:51
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int UINT
Definition: ndis.h:50
MSIDATABASE * db
Definition: distinct.c:50
MSIOBJECTHDR hdr
Definition: msipriv.h:97
UINT * translation
Definition: distinct.c:53

Referenced by yyparse().

◆ DROP_CreateView()

UINT DROP_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
LPCWSTR  name 
)

Definition at line 118 of file drop.c.

119 {
120  MSIDROPVIEW *dv;
121  UINT r;
122 
123  TRACE("%p %s\n", view, debugstr_w(name));
124 
125  dv = msi_alloc_zero(sizeof *dv);
126  if(!dv)
127  return ERROR_FUNCTION_FAILED;
128 
129  r = TABLE_CreateView(db, name, &dv->table);
130  if (r != ERROR_SUCCESS)
131  {
132  msi_free( dv );
133  return r;
134  }
135 
136  dv->view.ops = &drop_ops;
137  dv->db = db;
138 
139  *view = (MSIVIEW *)dv;
140 
141  return ERROR_SUCCESS;
142 }
#define ERROR_SUCCESS
Definition: deptool.c:10
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view) DECLSPEC_HIDDEN
Definition: table.c:2162
MSIVIEW view
Definition: drop.c:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static const MSIVIEWOPS drop_ops
Definition: drop.c:95
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
MSIVIEW * table
Definition: drop.c:41
unsigned int UINT
Definition: ndis.h:50
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
Definition: name.c:36
MSIDATABASE * db
Definition: drop.c:40

Referenced by yyparse().

◆ INSERT_CreateView()

UINT INSERT_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
LPCWSTR  table,
column_info columns,
column_info values,
BOOL  temp 
)

Definition at line 361 of file insert.c.

363 {
364  MSIINSERTVIEW *iv = NULL;
365  UINT r;
366  MSIVIEW *tv = NULL, *sv = NULL;
367 
368  TRACE("%p\n", iv );
369 
370  /* there should be one value for each column */
371  if ( count_column_info( columns ) != count_column_info(values) )
372  return ERROR_BAD_QUERY_SYNTAX;
373 
374  r = TABLE_CreateView( db, table, &tv );
375  if( r != ERROR_SUCCESS )
376  return r;
377 
378  r = SELECT_CreateView( db, &sv, tv, columns );
379  if( r != ERROR_SUCCESS )
380  {
381  if( tv )
382  tv->ops->delete( tv );
383  return r;
384  }
385 
386  iv = msi_alloc_zero( sizeof *iv );
387  if( !iv )
388  return ERROR_FUNCTION_FAILED;
389 
390  /* fill the structure */
391  iv->view.ops = &insert_ops;
392  msiobj_addref( &db->hdr );
393  iv->table = tv;
394  iv->db = db;
395  iv->vals = values;
396  iv->bIsTemp = temp;
397  iv->sv = sv;
398  *view = (MSIVIEW*) iv;
399 
400  return ERROR_SUCCESS;
401 }
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
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
MSIVIEW * sv
Definition: insert.c:48
static const MSIVIEWOPS insert_ops
Definition: insert.c:330
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
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
MSIVIEW view
Definition: insert.c:44
BOOL bIsTemp
Definition: insert.c:47
static UINT count_column_info(const column_info *ci)
Definition: insert.c:353
UINT(* delete)(struct tagMSIVIEW *)
Definition: msipriv.h:299
static calc_node_t temp
Definition: rpn_ieee.c:38
unsigned int UINT
Definition: ndis.h:50
MSIVIEW * table
Definition: insert.c:45
column_info * vals
Definition: insert.c:49
MSIOBJECTHDR hdr
Definition: msipriv.h:97
MSIDATABASE * db
Definition: insert.c:46
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973

Referenced by yyparse().

◆ msi_create_table()

UINT msi_create_table ( MSIDATABASE db,
LPCWSTR  name,
column_info col_info,
MSICONDITION  persistent 
)

Definition at line 716 of file table.c.

718 {
719  enum StringPersistence string_persistence = (persistent) ? StringPersistent : StringNonPersistent;
720  UINT r, nField;
721  MSIVIEW *tv = NULL;
722  MSIRECORD *rec = NULL;
723  column_info *col;
724  MSITABLE *table;
725  UINT i;
726 
727  /* only add tables that don't exist already */
728  if( TABLE_Exists(db, name ) )
729  {
730  WARN("table %s exists\n", debugstr_w(name));
731  return ERROR_BAD_QUERY_SYNTAX;
732  }
733 
734  table = msi_alloc( sizeof (MSITABLE) + lstrlenW(name)*sizeof (WCHAR) );
735  if( !table )
736  return ERROR_FUNCTION_FAILED;
737 
738  table->ref_count = 1;
739  table->row_count = 0;
740  table->data = NULL;
741  table->data_persistent = NULL;
742  table->colinfo = NULL;
743  table->col_count = 0;
744  table->persistent = persistent;
745  lstrcpyW( table->name, name );
746 
747  for( col = col_info; col; col = col->next )
748  table->col_count++;
749 
750  table->colinfo = msi_alloc( table->col_count * sizeof(MSICOLUMNINFO) );
751  if (!table->colinfo)
752  {
753  free_table( table );
754  return ERROR_FUNCTION_FAILED;
755  }
756 
757  for( i = 0, col = col_info; col; i++, col = col->next )
758  {
759  UINT table_id = msi_add_string( db->strings, col->table, -1, string_persistence );
760  UINT col_id = msi_add_string( db->strings, col->column, -1, string_persistence );
761 
762  table->colinfo[ i ].tablename = msi_string_lookup( db->strings, table_id, NULL );
763  table->colinfo[ i ].number = i + 1;
764  table->colinfo[ i ].colname = msi_string_lookup( db->strings, col_id, NULL );
765  table->colinfo[ i ].type = col->type;
766  table->colinfo[ i ].offset = 0;
767  table->colinfo[ i ].ref_count = 0;
768  table->colinfo[ i ].hash_table = NULL;
769  table->colinfo[ i ].temporary = col->temporary;
770  }
771  table_calc_column_offsets( db, table->colinfo, table->col_count);
772 
773  r = TABLE_CreateView( db, szTables, &tv );
774  TRACE("CreateView returned %x\n", r);
775  if( r )
776  {
777  free_table( table );
778  return r;
779  }
780 
781  r = tv->ops->execute( tv, 0 );
782  TRACE("tv execute returned %x\n", r);
783  if( r )
784  goto err;
785 
786  rec = MSI_CreateRecord( 1 );
787  if( !rec )
788  goto err;
789 
790  r = MSI_RecordSetStringW( rec, 1, name );
791  if( r )
792  goto err;
793 
794  r = tv->ops->insert_row( tv, rec, -1, persistent == MSICONDITION_FALSE );
795  TRACE("insert_row returned %x\n", r);
796  if( r )
797  goto err;
798 
799  tv->ops->delete( tv );
800  tv = NULL;
801 
802  msiobj_release( &rec->hdr );
803  rec = NULL;
804 
805  if( persistent != MSICONDITION_FALSE )
806  {
807  /* add each column to the _Columns table */
808  r = TABLE_CreateView( db, szColumns, &tv );
809  if( r )
810  goto err;
811 
812  r = tv->ops->execute( tv, 0 );
813  TRACE("tv execute returned %x\n", r);
814  if( r )
815  goto err;
816 
817  rec = MSI_CreateRecord( 4 );
818  if( !rec )
819  goto err;
820 
821  r = MSI_RecordSetStringW( rec, 1, name );
822  if( r )
823  goto err;
824 
825  /*
826  * need to set the table, column number, col name and type
827  * for each column we enter in the table
828  */
829  nField = 1;
830  for( col = col_info; col; col = col->next )
831  {
832  r = MSI_RecordSetInteger( rec, 2, nField );
833  if( r )
834  goto err;
835 
836  r = MSI_RecordSetStringW( rec, 3, col->column );
837  if( r )
838  goto err;
839 
840  r = MSI_RecordSetInteger( rec, 4, col->type );
841  if( r )
842  goto err;
843 
844  r = tv->ops->insert_row( tv, rec, -1, FALSE );
845  if( r )
846  goto err;
847 
848  nField++;
849  }
850  if( !col )
851  r = ERROR_SUCCESS;
852  }
853 
854 err:
855  if (rec)
856  msiobj_release( &rec->hdr );
857  /* FIXME: remove values from the string table on error */
858  if( tv )
859  tv->ops->delete( tv );
860 
861  if (r == ERROR_SUCCESS)
862  list_add_head( &db->tables, &table->entry );
863  else
864  free_table( table );
865 
866  return r;
867 }
const WCHAR * msi_string_lookup(const string_table *st, UINT id, int *len) DECLSPEC_HIDDEN
Definition: string.c:347
StringPersistence
Definition: msipriv.h:757
UINT MSI_RecordSetStringW(MSIRECORD *, UINT, LPCWSTR) DECLSPEC_HIDDEN
Definition: record.c:649
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * name
MSIOBJECTHDR hdr
Definition: msipriv.h:141
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
struct _column_info * next
Definition: msipriv.h:216
BOOL msi_add_string(string_table *st, const WCHAR *data, int len, enum StringPersistence persistence) DECLSPEC_HIDDEN
Definition: string.c:307
UINT(* execute)(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: msipriv.h:268
#define lstrlenW
Definition: compat.h:407
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
UINT MSI_RecordSetInteger(MSIRECORD *, UINT, int) DECLSPEC_HIDDEN
Definition: record.c:328
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
string_table * strings
Definition: msipriv.h:99
#define debugstr_w
Definition: kernel32.h:32
struct list entry
struct list tables
Definition: msipriv.h:107
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
const MSIVIEWOPS * ops
Definition: msipriv.h:348
static const WCHAR szColumns[]
Definition: table.c:79
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view)
Definition: table.c:2162
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:242
static void table_calc_column_offsets(MSIDATABASE *db, MSICOLUMNINFO *colinfo, DWORD count)
Definition: table.c:502
MSIRECORD * MSI_CreateRecord(UINT) DECLSPEC_HIDDEN
Definition: record.c:79
static const WCHAR szTables[]
Definition: table.c:77
#define err(...)
static void free_table(MSITABLE *table)
Definition: table.c:372
UINT(* delete)(struct tagMSIVIEW *)
Definition: msipriv.h:299
#define lstrcpyW
Definition: compat.h:406
BYTE * data
unsigned int UINT
Definition: ndis.h:50
Definition: name.c:36
static void * msi_alloc(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1204
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973
BOOL TABLE_Exists(MSIDATABASE *db, LPCWSTR name)
Definition: table.c:971
UINT(* insert_row)(struct tagMSIVIEW *view, MSIRECORD *record, UINT row, BOOL temporary)
Definition: msipriv.h:258

Referenced by CREATE_execute().

◆ MSI_ParseSQL()

UINT MSI_ParseSQL ( MSIDATABASE db,
LPCWSTR  command,
MSIVIEW **  phview,
struct list mem 
)

Definition at line 2714 of file sql.tab.c.

2716 {
2717  SQL_input sql;
2718  int r;
2719 
2720  *phview = NULL;
2721 
2722  sql.db = db;
2723  sql.command = command;
2724  sql.n = 0;
2725  sql.len = 0;
2726  sql.r = ERROR_BAD_QUERY_SYNTAX;
2727  sql.view = phview;
2728  sql.mem = mem;
2729 
2730  r = sql_parse(&sql);
2731 
2732  TRACE("Parse returned %d\n", r);
2733  if( r )
2734  {
2735  if (*sql.view)
2736  {
2737  (*sql.view)->ops->delete(*sql.view);
2738  *sql.view = NULL;
2739  }
2740  return sql.r;
2741  }
2742 
2743  return ERROR_SUCCESS;
2744 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD len
Definition: query.h:103
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
UINT r
Definition: query.h:104
int sql_parse(SQL_input *info)
DWORD n
Definition: query.h:103
LPCWSTR command
Definition: query.h:102
MSIVIEW ** view
Definition: query.h:105
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
struct list * mem
Definition: query.h:109
MSIDATABASE * db
Definition: query.h:101
int command(const char *fmt,...)
Definition: ftp.c:266
Definition: mem.c:156
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973

Referenced by MSI_DatabaseOpenViewW().

◆ msi_query_merge_record()

MSIRECORD* msi_query_merge_record ( UINT  fields,
const column_info vl,
MSIRECORD rec 
)

Definition at line 67 of file insert.c.

68 {
69  MSIRECORD *merged;
70  DWORD wildcard_count = 1, i;
71 
72  merged = MSI_CreateRecord( fields );
73  for( i=1; i <= fields; i++ )
74  {
75  if( !vl )
76  {
77  TRACE("Not enough elements in the list to insert\n");
78  goto err;
79  }
80  switch( vl->val->type )
81  {
82  case EXPR_SVAL:
83  TRACE("field %d -> %s\n", i, debugstr_w(vl->val->u.sval));
84  MSI_RecordSetStringW( merged, i, vl->val->u.sval );
85  break;
86  case EXPR_IVAL:
87  MSI_RecordSetInteger( merged, i, vl->val->u.ival );
88  break;
89  case EXPR_WILDCARD:
90  if( !rec )
91  goto err;
92  MSI_RecordCopyField( rec, wildcard_count, merged, i );
93  wildcard_count++;
94  break;
95  default:
96  ERR("Unknown expression type %d\n", vl->val->type);
97  }
98  vl = vl->next;
99  }
100 
101  return merged;
102 err:
103  msiobj_release( &merged->hdr );
104  return NULL;
105 }
UINT MSI_RecordSetStringW(MSIRECORD *, UINT, LPCWSTR) DECLSPEC_HIDDEN
Definition: record.c:649
UINT MSI_RecordCopyField(MSIRECORD *, UINT, MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:169
MSIOBJECTHDR hdr
Definition: msipriv.h:141
struct _column_info * next
Definition: msipriv.h:216
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
UINT MSI_RecordSetInteger(MSIRECORD *, UINT, int) DECLSPEC_HIDDEN
Definition: record.c:328
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:242
#define EXPR_WILDCARD
Definition: query.h:54
MSIRECORD * MSI_CreateRecord(UINT) DECLSPEC_HIDDEN
Definition: record.c:79
#define err(...)
#define ERR(fmt,...)
Definition: debug.h:109
struct expr * val
Definition: msipriv.h:215

Referenced by INSERT_execute(), and UPDATE_execute().

◆ ORDER_CreateView()

UINT ORDER_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
MSIVIEW table,
column_info columns 
)

◆ SELECT_CreateView()

UINT SELECT_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
MSIVIEW table,
const column_info columns 
)

Definition at line 424 of file select.c.

426 {
427  MSISELECTVIEW *sv = NULL;
428  UINT count = 0, r = ERROR_SUCCESS;
429 
430  TRACE("%p\n", sv );
431 
432  count = select_count_columns( columns );
433 
435  if( !sv )
436  return ERROR_FUNCTION_FAILED;
437 
438  /* fill the structure */
439  sv->view.ops = &select_ops;
440  sv->db = db;
441  sv->table = table;
442  sv->num_cols = 0;
443  sv->max_cols = count;
444 
445  while( columns )
446  {
447  r = SELECT_AddColumn( sv, columns->column, columns->table );
448  if( r )
449  break;
450  columns = columns->next;
451  }
452 
453  if( r == ERROR_SUCCESS )
454  *view = &sv->view;
455  else
456  msi_free( sv );
457 
458  return r;
459 }
UINT max_cols
Definition: select.c:47
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
struct _column_info * next
Definition: msipriv.h:216
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
static const MSIVIEWOPS select_ops
Definition: select.c:353
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR column
Definition: msipriv.h:212
UINT num_cols
Definition: select.c:46
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
MSIVIEW view
Definition: select.c:43
MSIVIEW * table
Definition: select.c:45
static int select_count_columns(const column_info *col)
Definition: select.c:416
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int UINT
Definition: ndis.h:50
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
LPCWSTR table
Definition: msipriv.h:211
MSIDATABASE * db
Definition: select.c:44
static UINT SELECT_AddColumn(MSISELECTVIEW *sv, LPCWSTR name, LPCWSTR table_name)
Definition: select.c:376

Referenced by INSERT_CreateView(), UPDATE_CreateView(), and yyparse().

◆ sqliteGetToken()

int sqliteGetToken ( const WCHAR z,
int tokenType,
int skip 
)

Definition at line 209 of file tokenize.c.

209  {
210  int i;
211 
212  *skip = 0;
213  switch( *z ){
214  case ' ': case '\t': case '\n': case '\f':
215  for(i=1; isSpace(z[i]); i++){}
216  *tokenType = TK_SPACE;
217  return i;
218  case '-':
219  if( z[1]==0 ) return -1;
220  *tokenType = TK_MINUS;
221  return 1;
222  case '(':
223  *tokenType = TK_LP;
224  return 1;
225  case ')':
226  *tokenType = TK_RP;
227  return 1;
228  case '*':
229  *tokenType = TK_STAR;
230  return 1;
231  case '=':
232  *tokenType = TK_EQ;
233  return 1;
234  case '<':
235  if( z[1]=='=' ){
236  *tokenType = TK_LE;
237  return 2;
238  }else if( z[1]=='>' ){
239  *tokenType = TK_NE;
240  return 2;
241  }else{
242  *tokenType = TK_LT;
243  return 1;
244  }
245  case '>':
246  if( z[1]=='=' ){
247  *tokenType = TK_GE;
248  return 2;
249  }else{
250  *tokenType = TK_GT;
251  return 1;
252  }
253  case '!':
254  if( z[1]!='=' ){
255  *tokenType = TK_ILLEGAL;
256  return 2;
257  }else{
258  *tokenType = TK_NE;
259  return 2;
260  }
261  case '?':
262  *tokenType = TK_WILDCARD;
263  return 1;
264  case ',':
265  *tokenType = TK_COMMA;
266  return 1;
267  case '`': case '\'': {
268  int delim = z[0];
269  for(i=1; z[i]; i++){
270  if( z[i]==delim )
271  break;
272  }
273  if( z[i] ) i++;
274  if( delim == '`' )
275  *tokenType = TK_ID;
276  else
277  *tokenType = TK_STRING;
278  return i;
279  }
280  case '.':
281  if( !isDigit(z[1]) ){
282  *tokenType = TK_DOT;
283  return 1;
284  }
285  /* Fall through */
286  case '0': case '1': case '2': case '3': case '4':
287  case '5': case '6': case '7': case '8': case '9':
288  *tokenType = TK_INTEGER;
289  for(i=1; isDigit(z[i]); i++){}
290  return i;
291  case '[':
292  for(i=1; z[i] && z[i-1]!=']'; i++){}
293  *tokenType = TK_ID;
294  return i;
295  default:
296  if( !isIdChar[*z] ){
297  break;
298  }
299  for(i=1; isIdChar[z[i]]; i++){}
300  *tokenType = sqliteKeywordCode(z, i);
301  if( *tokenType == TK_ID && z[i] == '`' ) *skip = 1;
302  return i;
303  }
304  *tokenType = TK_ILLEGAL;
305  return 1;
306 }
Definition: sql.tab.c:181
static int isDigit(WCHAR c)
Definition: tokenize.c:191
static int sqliteKeywordCode(const WCHAR *z, int n)
Definition: tokenize.c:142
Definition: sql.tab.c:197
Definition: sql.tab.c:193
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
GLdouble GLdouble z
Definition: glext.h:5874
Definition: sql.tab.c:207
Definition: sql.tab.c:182
Definition: sql.tab.c:185
static int isSpace(WCHAR c)
Definition: tokenize.c:199
Definition: sql.tab.c:196
Definition: sql.tab.c:200
Definition: sql.tab.c:178
#define skip(...)
Definition: atltest.h:64
static const char isIdChar[]
Definition: tokenize.c:168

Referenced by sql_lex().

◆ STORAGES_CreateView()

UINT STORAGES_CreateView ( MSIDATABASE db,
MSIVIEW **  view 
)

Definition at line 528 of file storages.c.

529 {
530  MSISTORAGESVIEW *sv;
531  INT rows;
532 
533  TRACE("(%p, %p)\n", db, view);
534 
535  sv = msi_alloc_zero( sizeof(MSISTORAGESVIEW) );
536  if (!sv)
537  return ERROR_FUNCTION_FAILED;
538 
539  sv->view.ops = &storages_ops;
540  sv->db = db;
541 
542  rows = add_storages_to_table(sv);
543  if (rows < 0)
544  {
545  msi_free( sv );
546  return ERROR_FUNCTION_FAILED;
547  }
548  sv->num_rows = rows;
549 
550  *view = (MSIVIEW *)sv;
551 
552  return ERROR_SUCCESS;
553 }
#define ERROR_SUCCESS
Definition: deptool.c:10
int32_t INT
Definition: typedefs.h:56
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 TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
static INT add_storages_to_table(MSISTORAGESVIEW *sv)
Definition: storages.c:470
MSIDATABASE * db
Definition: storages.c:52
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
static const MSIVIEWOPS storages_ops
Definition: storages.c:447

Referenced by TABLE_CreateView().

◆ STREAMS_CreateView()

UINT STREAMS_CreateView ( MSIDATABASE db,
MSIVIEW **  view 
)

Definition at line 558 of file streams.c.

559 {
560  MSISTREAMSVIEW *sv;
561  UINT r;
562 
563  TRACE("(%p, %p)\n", db, view);
564 
565  r = load_streams( db );
566  if (r != ERROR_SUCCESS)
567  return r;
568 
569  if (!(sv = msi_alloc_zero( sizeof(MSISTREAMSVIEW) )))
570  return ERROR_OUTOFMEMORY;
571 
572  sv->view.ops = &streams_ops;
574  sv->db = db;
575 
576  *view = (MSIVIEW *)sv;
577 
578  return ERROR_SUCCESS;
579 }
MSIDATABASE * db
Definition: streams.c:45
#define ERROR_SUCCESS
Definition: deptool.c:10
static const MSIVIEWOPS streams_ops
Definition: streams.c:393
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
#define NUM_STREAMS_COLS
Definition: streams.c:40
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
unsigned int UINT
Definition: ndis.h:50
static UINT load_streams(MSIDATABASE *db)
Definition: streams.c:465
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
MSIVIEW view
Definition: streams.c:44

Referenced by TABLE_CreateView().

◆ TABLE_CreateView()

UINT TABLE_CreateView ( MSIDATABASE db,
LPCWSTR  name,
MSIVIEW **  view 
)

Definition at line 2162 of file table.c.

2163 {
2164  MSITABLEVIEW *tv ;
2165  UINT r, sz;
2166 
2167  TRACE("%p %s %p\n", db, debugstr_w(name), view );
2168 
2169  if ( !strcmpW( name, szStreams ) )
2170  return STREAMS_CreateView( db, view );
2171  else if ( !strcmpW( name, szStorages ) )
2172  return STORAGES_CreateView( db, view );
2173 
2174  sz = FIELD_OFFSET( MSITABLEVIEW, name[lstrlenW( name ) + 1] );
2175  tv = msi_alloc_zero( sz );
2176  if( !tv )
2177  return ERROR_FUNCTION_FAILED;
2178 
2179  r = get_table( db, name, &tv->table );
2180  if( r != ERROR_SUCCESS )
2181  {
2182  msi_free( tv );
2183  WARN("table not found\n");
2184  return r;
2185  }
2186 
2187  TRACE("table %p found with %d columns\n", tv->table, tv->table->col_count);
2188 
2189  /* fill the structure */
2190  tv->view.ops = &table_ops;
2191  tv->db = db;
2192  tv->columns = tv->table->colinfo;
2193  tv->num_cols = tv->table->col_count;
2195 
2196  TRACE("%s one row is %d bytes\n", debugstr_w(name), tv->row_size );
2197 
2198  *view = (MSIVIEW*) tv;
2199  lstrcpyW( tv->name, name );
2200 
2201  return ERROR_SUCCESS;
2202 }
MSICOLUMNINFO * colinfo
Definition: table.c:69
#define ERROR_SUCCESS
Definition: deptool.c:10
static UINT msi_table_get_row_size(MSIDATABASE *db, const MSICOLUMNINFO *cols, UINT count, UINT bytes_per_strref)
Definition: table.c:384
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
#define LONG_STR_BYTES
Definition: msipriv.h:54
MSIDATABASE * db
Definition: table.c:1008
MSITABLE * table
Definition: table.c:1009
UINT col_count
Definition: table.c:70
#define lstrlenW
Definition: compat.h:407
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
UINT STORAGES_CreateView(MSIDATABASE *db, MSIVIEW **view) DECLSPEC_HIDDEN
Definition: storages.c:528
#define debugstr_w
Definition: kernel32.h:32
static const MSIVIEWOPS table_ops
Definition: table.c:2139
MSIVIEW view
Definition: table.c:1007
MSICOLUMNINFO * columns
Definition: table.c:1010
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR name[1]
Definition: table.c:1013
const MSIVIEWOPS * ops
Definition: msipriv.h:348
static const WCHAR szStorages[]
Definition: msipriv.h:1179
static UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table_ret)
Definition: table.c:583
UINT row_size
Definition: table.c:1012
#define lstrcpyW
Definition: compat.h:406
UINT STREAMS_CreateView(MSIDATABASE *db, MSIVIEW **view) DECLSPEC_HIDDEN
Definition: streams.c:558
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int UINT
Definition: ndis.h:50
static const WCHAR szStreams[]
Definition: msipriv.h:1178
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
Definition: name.c:36
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
UINT num_cols
Definition: table.c:1011

Referenced by alter_add_column(), ALTER_CreateView(), DROP_CreateView(), INSERT_CreateView(), merge_table(), msi_create_table(), msi_table_apply_transform(), msi_table_load_transform(), TABLE_drop(), TABLE_remove_column(), UPDATE_CreateView(), WHERE_CreateView(), and yyparse().

◆ UPDATE_CreateView()

UINT UPDATE_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
LPWSTR  table,
column_info list,
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
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().

◆ WHERE_CreateView()

UINT WHERE_CreateView ( MSIDATABASE db,
MSIVIEW **  view,
LPWSTR  tables,
struct expr cond 
)

Definition at line 1209 of file where.c.

1211 {
1212  MSIWHEREVIEW *wv = NULL;
1213  UINT r, valid = 0;
1214  WCHAR *ptr;
1215 
1216  TRACE("(%s)\n", debugstr_w(tables) );
1217 
1218  wv = msi_alloc_zero( sizeof *wv );
1219  if( !wv )
1220  return ERROR_FUNCTION_FAILED;
1221 
1222  /* fill the structure */
1223  wv->view.ops = &where_ops;
1224  msiobj_addref( &db->hdr );
1225  wv->db = db;
1226  wv->cond = cond;
1227 
1228  while (*tables)
1229  {
1230  JOINTABLE *table;
1231 
1232  if ((ptr = strchrW(tables, ' ')))
1233  *ptr = '\0';
1234 
1235  table = msi_alloc(sizeof(JOINTABLE));
1236  if (!table)
1237  {
1238  r = ERROR_OUTOFMEMORY;
1239  goto end;
1240  }
1241 
1242  r = TABLE_CreateView(db, tables, &table->view);
1243  if (r != ERROR_SUCCESS)
1244  {
1245  WARN("can't create table: %s\n", debugstr_w(tables));
1246  msi_free(table);
1248  goto end;
1249  }
1250 
1251  r = table->view->ops->get_dimensions(table->view, NULL,
1252  &table->col_count);
1253  if (r != ERROR_SUCCESS)
1254  {
1255  ERR("can't get table dimensions\n");
1256  table->view->ops->delete(table->view);
1257  msi_free(table);
1258  goto end;
1259  }
1260 
1261  wv->col_count += table->col_count;
1262  table->table_index = wv->table_count++;
1263 
1264  table->next = wv->tables;
1265  wv->tables = table;
1266 
1267  if (!ptr)
1268  break;
1269 
1270  tables = ptr + 1;
1271  }
1272 
1273  if( cond )
1274  {
1275  r = WHERE_VerifyCondition( wv, cond, &valid );
1276  if( r != ERROR_SUCCESS )
1277  goto end;
1278  if( !valid ) {
1280  goto end;
1281  }
1282  }
1283 
1284  *view = (MSIVIEW*) wv;
1285 
1286  return ERROR_SUCCESS;
1287 end:
1288  WHERE_delete(&wv->view);
1289 
1290  return r;
1291 }
void msiobj_addref(MSIOBJECTHDR *info)
Definition: handle.c:218
static const MSIVIEWOPS where_ops
Definition: where.c:1097
#define ERROR_SUCCESS
Definition: deptool.c:10
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view) DECLSPEC_HIDDEN
Definition: table.c:2162
JOINTABLE * tables
Definition: where.c:68
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define WARN(fmt,...)
Definition: debug.h:111
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
GLuint GLuint end
Definition: gl.h:1545
static UINT WHERE_VerifyCondition(MSIWHEREVIEW *wv, struct expr *cond, UINT *valid)
Definition: where.c:1120
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
struct expr * cond
Definition: where.c:74
UINT col_count
Definition: where.c:70
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
UINT table_count
Definition: where.c:71
smooth NULL
Definition: ftsmooth.c:416
static UINT WHERE_delete(struct tagMSIVIEW *view)
Definition: where.c:987
#define TRACE(s)
Definition: solgame.cpp:4
MSIDATABASE * db
Definition: where.c:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
const MSIVIEWOPS * ops
Definition: msipriv.h:348
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int UINT
Definition: ndis.h:50
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
static void * msi_alloc(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1204
struct nls_table * tables
Definition: nls_base.c:22
MSIVIEW view
Definition: where.c:66
MSIOBJECTHDR hdr
Definition: msipriv.h:97
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by UPDATE_CreateView(), and yyparse().