ReactOS 0.4.16-dev-306-g647d351
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)
 
UINT TABLE_CreateView (MSIDATABASE *db, LPCWSTR name, MSIVIEW **view)
 
UINT SELECT_CreateView (MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, const column_info *columns)
 
UINT DISTINCT_CreateView (MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table)
 
UINT ORDER_CreateView (MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, column_info *columns)
 
UINT WHERE_CreateView (MSIDATABASE *db, MSIVIEW **view, LPWSTR tables, struct expr *cond)
 
UINT CREATE_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, column_info *col_info, BOOL hold)
 
UINT INSERT_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, column_info *columns, column_info *values, BOOL temp)
 
UINT UPDATE_CreateView (MSIDATABASE *db, MSIVIEW **view, LPWSTR table, column_info *list, struct expr *expr)
 
UINT DELETE_CreateView (MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table)
 
UINT ALTER_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR name, column_info *colinfo, int hold)
 
UINT STREAMS_CreateView (MSIDATABASE *db, MSIVIEW **view)
 
UINT STORAGES_CreateView (MSIDATABASE *db, MSIVIEW **view)
 
UINT DROP_CreateView (MSIDATABASE *db, MSIVIEW **view, LPCWSTR name)
 
int sqliteGetToken (const WCHAR *z, int *tokenType, int *skip)
 
MSIRECORDmsi_query_merge_record (UINT fields, const column_info *vl, MSIRECORD *rec)
 
UINT msi_create_table (MSIDATABASE *db, LPCWSTR name, column_info *col_info, MSICONDITION persistent, BOOL hold)
 
UINT msi_select_update (MSIVIEW *view, MSIRECORD *rec, UINT row)
 
UINT msi_view_refresh_row (MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD *rec)
 

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 160 of file alter.c.

161{
162 struct alter_view *av;
163 UINT r;
164
165 TRACE("%p %p %s %d\n", view, colinfo, debugstr_w(name), hold );
166
167 av = calloc( 1, sizeof *av );
168 if( !av )
170
171 r = TABLE_CreateView( db, name, &av->table );
172 if (r != ERROR_SUCCESS)
173 {
174 free( av );
175 return r;
176 }
177
178 if (colinfo)
179 colinfo->table = name;
180
181 /* fill the structure */
182 av->view.ops = &alter_ops;
183 av->db = db;
184 av->hold = hold;
185 av->colinfo = colinfo;
186
187 *view = &av->view;
188
189 return ERROR_SUCCESS;
190}
static const MSIVIEWOPS alter_ops
Definition: alter.c:137
#define free
Definition: debug_ros.c:5
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define debugstr_w
Definition: kernel32.h:32
unsigned int UINT
Definition: ndis.h:50
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view)
Definition: table.c:2191
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
MSIVIEW * table
Definition: alter.c:41
MSIDATABASE * db
Definition: alter.c:40
column_info * colinfo
Definition: alter.c:42
INT hold
Definition: alter.c:43
MSIVIEW view
Definition: alter.c:39
Definition: name.c:39
const MSIVIEWOPS * ops
Definition: msipriv.h:355
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985

◆ CREATE_CreateView()

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

Definition at line 160 of file create.c.

162{
163 struct create_view *cv = NULL;
164 UINT r;
165 column_info *col;
166 BOOL temp = TRUE;
167 BOOL tempprim = FALSE;
168
169 TRACE("%p\n", cv );
170
172 if( r != ERROR_SUCCESS )
173 return r;
174
175 cv = calloc( 1, sizeof *cv );
176 if( !cv )
178
179 for( col = col_info; col; col = col->next )
180 {
181 if (!col->table)
182 col->table = table;
183
184 if( !(col->type & MSITYPE_TEMPORARY) )
185 temp = FALSE;
186 else if ( col->type & MSITYPE_KEY )
187 tempprim = TRUE;
188 }
189
190 if ( !temp && tempprim )
191 {
192 free( cv );
194 }
195
196 /* fill the structure */
197 cv->view.ops = &create_ops;
198 msiobj_addref( &db->hdr );
199 cv->db = db;
200 cv->name = table;
201 cv->col_info = col_info;
202 cv->bIsTemp = temp;
203 cv->hold = hold;
204 *view = (MSIVIEW*) cv;
205
206 return ERROR_SUCCESS;
207}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static UINT check_columns(const column_info *col_info)
Definition: create.c:147
static const MSIVIEWOPS create_ops
Definition: create.c:124
void msiobj_addref(MSIOBJECTHDR *info)
Definition: handle.c:217
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MSITYPE_TEMPORARY
Definition: msipriv.h:53
#define MSITYPE_KEY
Definition: msipriv.h:52
static calc_node_t temp
Definition: rpn_ieee.c:38
UINT type
Definition: table.c:55
BOOL bIsTemp
Definition: create.c:46
LPCWSTR name
Definition: create.c:45
MSIVIEW view
Definition: create.c:43
MSIDATABASE * db
Definition: create.c:44
BOOL hold
Definition: create.c:47
column_info * col_info
Definition: create.c:48
MSIOBJECTHDR hdr
Definition: msipriv.h:108

◆ DELETE_CreateView()

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

Definition at line 190 of file delete.c.

191{
192 struct delete_view *dv = NULL;
193
194 TRACE("%p\n", dv );
195
196 dv = calloc( 1, sizeof *dv );
197 if( !dv )
199
200 /* fill the structure */
201 dv->view.ops = &delete_ops;
202 dv->db = db;
203 dv->table = table;
204
205 *view = &dv->view;
206
207 return ERROR_SUCCESS;
208}
static const MSIVIEWOPS delete_ops
Definition: delete.c:167
MSIVIEW * table
Definition: delete.c:55
MSIDATABASE * db
Definition: delete.c:54
MSIVIEW view
Definition: delete.c:53

◆ DISTINCT_CreateView()

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

Definition at line 273 of file distinct.c.

274{
275 struct distinct_view *dv = NULL;
276 UINT count = 0, r;
277
278 TRACE("%p\n", dv );
279
280 r = table->ops->get_dimensions( table, NULL, &count );
281 if( r != ERROR_SUCCESS )
282 {
283 ERR("can't get table dimensions\n");
284 return r;
285 }
286
287 dv = calloc( 1, sizeof *dv );
288 if( !dv )
290
291 /* fill the structure */
292 dv->view.ops = &distinct_ops;
293 msiobj_addref( &db->hdr );
294 dv->db = db;
295 dv->table = table;
296 dv->translation = NULL;
297 dv->row_count = 0;
298 *view = (MSIVIEW*) dv;
299
300 return ERROR_SUCCESS;
301}
#define ERR(fmt,...)
Definition: precomp.h:57
static const MSIVIEWOPS distinct_ops
Definition: distinct.c:250
GLuint GLuint GLsizei count
Definition: gl.h:1545
UINT row_count
Definition: distinct.c:52
MSIVIEW view
Definition: distinct.c:49
MSIDATABASE * db
Definition: distinct.c:50
MSIVIEW * table
Definition: distinct.c:51
UINT * translation
Definition: distinct.c:53

◆ DROP_CreateView()

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

Definition at line 118 of file drop.c.

119{
120 struct drop_view *dv;
121 UINT r;
122
123 TRACE("%p %s\n", view, debugstr_w(name));
124
125 dv = calloc(1, sizeof *dv);
126 if(!dv)
128
129 r = TABLE_CreateView(db, name, &dv->table);
130 if (r != ERROR_SUCCESS)
131 {
132 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}
static const MSIVIEWOPS drop_ops
Definition: drop.c:95
Definition: drop.c:38
MSIVIEW * table
Definition: drop.c:41
MSIVIEW view
Definition: drop.c:39
MSIDATABASE * db
Definition: drop.c:40

◆ INSERT_CreateView()

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

Definition at line 351 of file insert.c.

353{
354 struct insert_view *iv = NULL;
355 UINT r;
356 MSIVIEW *tv = NULL, *sv = NULL;
357
358 TRACE("%p\n", iv );
359
360 /* there should be one value for each column */
361 if ( count_column_info( columns ) != count_column_info(values) )
363
364 r = TABLE_CreateView( db, table, &tv );
365 if( r != ERROR_SUCCESS )
366 return r;
367
368 r = SELECT_CreateView( db, &sv, tv, columns );
369 if( r != ERROR_SUCCESS )
370 {
371 if( tv )
372 tv->ops->delete( tv );
373 return r;
374 }
375
376 iv = calloc( 1, sizeof *iv );
377 if( !iv )
379
380 /* fill the structure */
381 iv->view.ops = &insert_ops;
382 msiobj_addref( &db->hdr );
383 iv->table = tv;
384 iv->db = db;
385 iv->vals = values;
386 iv->bIsTemp = temp;
387 iv->sv = sv;
388 *view = (MSIVIEW*) iv;
389
390 return ERROR_SUCCESS;
391}
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
static UINT count_column_info(const column_info *ci)
Definition: insert.c:343
static const MSIVIEWOPS insert_ops
Definition: insert.c:320
UINT SELECT_CreateView(MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, const column_info *columns)
Definition: select.c:425
BOOL bIsTemp
Definition: insert.c:46
MSIVIEW * table
Definition: insert.c:44
MSIDATABASE * db
Definition: insert.c:45
MSIVIEW view
Definition: insert.c:43
MSIVIEW * sv
Definition: insert.c:47
column_info * vals
Definition: insert.c:48
UINT(* delete)(struct tagMSIVIEW *)
Definition: msipriv.h:324
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973

◆ msi_create_table()

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

Definition at line 707 of file table.c.

709{
710 UINT r, nField;
711 MSIVIEW *tv = NULL;
712 MSIRECORD *rec = NULL;
713 column_info *col;
715 UINT i;
716
717 /* only add tables that don't exist already */
718 if( TABLE_Exists(db, name ) )
719 {
720 WARN("table %s exists\n", debugstr_w(name));
722 }
723
724 table = malloc( sizeof(MSITABLE) + wcslen(name) * sizeof(WCHAR) );
725 if( !table )
727
728 table->ref_count = 0;
729 table->row_count = 0;
730 table->data = NULL;
731 table->data_persistent = NULL;
732 table->colinfo = NULL;
733 table->col_count = 0;
734 table->persistent = persistent;
735 lstrcpyW( table->name, name );
736
737 if( hold )
738 table->ref_count++;
739
740 for( col = col_info; col; col = col->next )
741 table->col_count++;
742
743 table->colinfo = malloc( table->col_count * sizeof(*table->colinfo) );
744 if (!table->colinfo)
745 {
746 free_table( table );
748 }
749
750 for( i = 0, col = col_info; col; i++, col = col->next )
751 {
752 UINT table_id = msi_add_string( db->strings, col->table, -1, persistent );
753 UINT col_id = msi_add_string( db->strings, col->column, -1, persistent );
754
755 table->colinfo[ i ].tablename = msi_string_lookup( db->strings, table_id, NULL );
756 table->colinfo[ i ].number = i + 1;
757 table->colinfo[ i ].colname = msi_string_lookup( db->strings, col_id, NULL );
758 table->colinfo[ i ].type = col->type;
759 table->colinfo[ i ].offset = 0;
760 table->colinfo[ i ].hash_table = NULL;
761 }
762 table_calc_column_offsets( db, table->colinfo, table->col_count);
763
764 r = TABLE_CreateView( db, L"_Tables", &tv );
765 TRACE("CreateView returned %x\n", r);
766 if( r )
767 {
768 free_table( table );
769 return r;
770 }
771
772 r = tv->ops->execute( tv, 0 );
773 TRACE("tv execute returned %x\n", r);
774 if( r )
775 goto err;
776
777 rec = MSI_CreateRecord( 1 );
778 if( !rec )
779 goto err;
780
781 r = MSI_RecordSetStringW( rec, 1, name );
782 if( r )
783 goto err;
784
785 r = tv->ops->insert_row( tv, rec, -1, persistent == MSICONDITION_FALSE );
786 TRACE("insert_row returned %x\n", r);
787 if( r )
788 goto err;
789
790 tv->ops->delete( tv );
791 tv = NULL;
792
793 msiobj_release( &rec->hdr );
794 rec = NULL;
795
796 if( persistent != MSICONDITION_FALSE )
797 {
798 /* add each column to the _Columns table */
799 r = TABLE_CreateView( db, L"_Columns", &tv );
800 if( r )
801 goto err;
802
803 r = tv->ops->execute( tv, 0 );
804 TRACE("tv execute returned %x\n", r);
805 if( r )
806 goto err;
807
808 rec = MSI_CreateRecord( 4 );
809 if( !rec )
810 goto err;
811
812 r = MSI_RecordSetStringW( rec, 1, name );
813 if( r )
814 goto err;
815
816 /*
817 * need to set the table, column number, col name and type
818 * for each column we enter in the table
819 */
820 nField = 1;
821 for( col = col_info; col; col = col->next )
822 {
823 r = MSI_RecordSetInteger( rec, 2, nField );
824 if( r )
825 goto err;
826
827 r = MSI_RecordSetStringW( rec, 3, col->column );
828 if( r )
829 goto err;
830
831 r = MSI_RecordSetInteger( rec, 4, col->type );
832 if( r )
833 goto err;
834
835 r = tv->ops->insert_row( tv, rec, -1, FALSE );
836 if( r )
837 goto err;
838
839 nField++;
840 }
841 if( !col )
843 }
844
845err:
846 if (rec)
847 msiobj_release( &rec->hdr );
848 /* FIXME: remove values from the string table on error */
849 if( tv )
850 tv->ops->delete( tv );
851
852 if (r == ERROR_SUCCESS)
853 list_add_head( &db->tables, &table->entry );
854 else
855 free_table( table );
856
857 return r;
858}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
#define WARN(fmt,...)
Definition: precomp.h:61
#define malloc
Definition: debug_ros.c:4
#define lstrcpyW
Definition: compat.h:749
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:241
BOOL TABLE_Exists(MSIDATABASE *db, LPCWSTR name)
Definition: table.c:962
static void free_table(MSITABLE *table)
Definition: table.c:364
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view)
Definition: table.c:2191
static void table_calc_column_offsets(MSIDATABASE *db, struct column_info *colinfo, DWORD count)
Definition: table.c:494
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL msi_add_string(string_table *st, const WCHAR *data, int len, BOOL persistent)
Definition: string.c:303
UINT MSI_RecordSetInteger(MSIRECORD *, UINT, int)
Definition: record.c:280
const WCHAR * msi_string_lookup(const string_table *st, UINT id, int *len)
Definition: string.c:343
UINT MSI_RecordSetStringW(MSIRECORD *, UINT, LPCWSTR)
Definition: record.c:597
MSIRECORD * MSI_CreateRecord(UINT)
Definition: record.c:76
@ MSICONDITION_FALSE
Definition: msiquery.h:26
#define L(x)
Definition: ntvdm.h:50
#define err(...)
const WCHAR * name
struct list entry
BYTE * data
struct list tables
Definition: msipriv.h:118
string_table * strings
Definition: msipriv.h:110
MSIOBJECTHDR hdr
Definition: msipriv.h:151
UINT(* insert_row)(struct tagMSIVIEW *view, MSIRECORD *record, UINT row, BOOL temporary)
Definition: msipriv.h:283
UINT(* execute)(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: msipriv.h:293
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CREATE_execute().

◆ MSI_ParseSQL()

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

Referenced by MSI_DatabaseOpenViewW().

◆ msi_query_merge_record()

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

Definition at line 66 of file insert.c.

67{
68 MSIRECORD *merged;
69 DWORD wildcard_count = 1, i;
70
71 merged = MSI_CreateRecord( fields );
72 for( i=1; i <= fields; i++ )
73 {
74 if( !vl )
75 {
76 TRACE("Not enough elements in the list to insert\n");
77 goto err;
78 }
79 switch( vl->val->type )
80 {
81 case EXPR_SVAL:
82 TRACE( "field %lu -> %s\n", i, debugstr_w(vl->val->u.sval) );
83 MSI_RecordSetStringW( merged, i, vl->val->u.sval );
84 break;
85 case EXPR_IVAL:
86 MSI_RecordSetInteger( merged, i, vl->val->u.ival );
87 break;
88 case EXPR_WILDCARD:
89 if( !rec )
90 goto err;
91 MSI_RecordCopyField( rec, wildcard_count, merged, i );
92 wildcard_count++;
93 break;
94 default:
95 ERR("Unknown expression type %d\n", vl->val->type);
96 }
97 vl = vl->next;
98 }
99
100 return merged;
101err:
102 msiobj_release( &merged->hdr );
103 return NULL;
104}
unsigned long DWORD
Definition: ntddk_ex.h:95
const char * fields[10]
Definition: parser.c:313
UINT MSI_RecordCopyField(MSIRECORD *, UINT, MSIRECORD *, UINT)
Definition: record.c:166
#define EXPR_WILDCARD
Definition: query.h:54
#define EXPR_IVAL
Definition: query.h:50
#define EXPR_SVAL
Definition: query.h:51

Referenced by INSERT_execute(), and UPDATE_execute().

◆ msi_select_update()

UINT msi_select_update ( MSIVIEW view,
MSIRECORD rec,
UINT  row 
)

Definition at line 251 of file select.c.

252{
253 struct select_view *sv = (struct select_view *)view;
254 UINT r, i, col, type, val;
256 LPCWSTR str;
257
258 for (i = 0; i < sv->num_cols; i++)
259 {
260 col = sv->cols[i];
261
263 if (r != ERROR_SUCCESS)
264 {
265 ERR("Failed to get column information: %d\n", r);
266 return r;
267 }
268
270 {
271 if (MSI_RecordGetIStream(rec, i + 1, &stream))
273 r = sv->table->ops->set_stream(sv->table, row, col, stream);
274 IStream_Release(stream);
275 }
276 else if (type & MSITYPE_STRING)
277 {
278 int len;
279 str = msi_record_get_string(rec, i + 1, &len);
280 r = sv->table->ops->set_string(sv->table, row, col, str, len);
281 }
282 else
283 {
284 val = MSI_RecordGetInteger(rec, i + 1);
285 r = sv->table->ops->set_int(sv->table, row, col, val);
286 }
287
288 if (r != ERROR_SUCCESS)
289 {
290 ERR("Failed to modify record: %d\n", r);
291 return r;
292 }
293 }
294
295 return ERROR_SUCCESS;
296}
static UINT SELECT_get_column_info(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: select.c:225
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLsizei len
Definition: glext.h:6722
int MSI_RecordGetInteger(MSIRECORD *, UINT)
Definition: record.c:213
UINT MSI_RecordGetIStream(MSIRECORD *, UINT, IStream **)
Definition: record.c:852
const WCHAR * msi_record_get_string(const MSIRECORD *, UINT, int *)
Definition: record.c:420
#define MSITYPE_IS_BINARY(type)
Definition: msipriv.h:62
#define MSITYPE_STRING
Definition: msipriv.h:50
const WCHAR * str
UINT cols[1]
Definition: select.c:50
MSIVIEW * table
Definition: select.c:47
UINT num_cols
Definition: select.c:48
Definition: parse.h:23
UINT(* set_stream)(struct tagMSIVIEW *view, UINT row, UINT col, IStream *stream)
Definition: msipriv.h:271
UINT(* set_string)(struct tagMSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len)
Definition: msipriv.h:264
UINT(* set_int)(struct tagMSIVIEW *view, UINT row, UINT col, int val)
Definition: msipriv.h:257
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by SELECT_modify(), and UPDATE_execute().

◆ msi_view_refresh_row()

UINT msi_view_refresh_row ( MSIDATABASE db,
MSIVIEW view,
UINT  row,
MSIRECORD rec 
)

Definition at line 287 of file msiquery.c.

288{
289 UINT row_count = 0, col_count = 0, i, ival, ret, type;
290
291 TRACE("%p %p %d %p\n", db, view, row, rec);
292
293 ret = view->ops->get_dimensions(view, &row_count, &col_count);
294 if (ret)
295 return ret;
296
297 if (!col_count)
299
300 for (i = 1; i <= col_count; i++)
301 {
302 ret = view->ops->get_column_info(view, i, NULL, &type, NULL, NULL);
303 if (ret)
304 {
305 ERR("Error getting column type for %d\n", i);
306 continue;
307 }
308
310 {
311 IStream *stm = NULL;
312
313 ret = view->ops->fetch_stream(view, row, i, &stm);
314 if ((ret == ERROR_SUCCESS) && stm)
315 {
316 MSI_RecordSetIStream(rec, i, stm);
317 IStream_Release(stm);
318 }
319 else
320 WARN("failed to get stream\n");
321
322 continue;
323 }
324
325 ret = view->ops->fetch_int(view, row, i, &ival);
326 if (ret)
327 {
328 ERR("Error fetching data for %d\n", i);
329 continue;
330 }
331
332 if (! (type & MSITYPE_VALID))
333 ERR("Invalid type!\n");
334
335 if (type & MSITYPE_STRING)
336 {
337 int len;
338 const WCHAR *sval = msi_string_lookup(db->strings, ival, &len);
339 msi_record_set_string(rec, i, sval, len);
340 }
341 else
342 {
343 if ((type & MSI_DATASIZEMASK) == 2)
344 MSI_RecordSetInteger(rec, i, ival ? ival - (1<<15) : MSI_NULL_INTEGER);
345 else
346 MSI_RecordSetInteger(rec, i, ival - (1u<<31));
347 }
348 }
349
350 return ERROR_SUCCESS;
351}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
UINT msi_record_set_string(MSIRECORD *, UINT, const WCHAR *, int)
Definition: record.c:573
#define MSITYPE_VALID
Definition: msipriv.h:48
UINT MSI_RecordSetIStream(MSIRECORD *, UINT, IStream *)
Definition: record.c:836
#define MSI_DATASIZEMASK
Definition: msipriv.h:47
#define MSI_NULL_INTEGER
Definition: msiquery.h:32
int ret

Referenced by msi_view_get_row(), and SELECT_modify().

◆ 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 425 of file select.c.

427{
428 struct select_view *sv = NULL;
429 UINT count = 0, r = ERROR_SUCCESS;
430
431 TRACE("%p\n", sv );
432
433 count = select_count_columns( columns );
434
435 sv = calloc( 1, offsetof( struct select_view, cols[count] ) );
436 if( !sv )
438
439 /* fill the structure */
440 sv->view.ops = &select_ops;
441 sv->db = db;
442 sv->table = table;
443 sv->num_cols = 0;
444 sv->max_cols = count;
445
446 while( columns )
447 {
448 r = SELECT_AddColumn( sv, columns->column, columns->table );
449 if( r )
450 break;
451 columns = columns->next;
452 }
453
454 if( r == ERROR_SUCCESS )
455 *view = &sv->view;
456 else
457 free( sv );
458
459 return r;
460}
static const MSIVIEWOPS select_ops
Definition: select.c:355
static UINT SELECT_AddColumn(struct select_view *sv, const WCHAR *name, const WCHAR *table_name)
Definition: select.c:378
static int select_count_columns(const column_info *col)
Definition: select.c:417
#define offsetof(TYPE, MEMBER)
MSIDATABASE * db
Definition: select.c:46
UINT max_cols
Definition: select.c:49
MSIVIEW view
Definition: select.c:45

Referenced by INSERT_CreateView(), and UPDATE_CreateView().

◆ sqliteGetToken()

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

Definition at line 172 of file tokenize.c.

172 {
173 int i;
174
175 *skip = 0;
176 switch( *z ){
177 case ' ': case '\t': case '\n': case '\f':
178 for(i=1; isSpace(z[i]); i++){}
179 *tokenType = TK_SPACE;
180 return i;
181 case '-':
182 if( z[1]==0 ) return -1;
183 *tokenType = TK_MINUS;
184 return 1;
185 case '(':
186 *tokenType = TK_LP;
187 return 1;
188 case ')':
189 *tokenType = TK_RP;
190 return 1;
191 case '*':
192 *tokenType = TK_STAR;
193 return 1;
194 case '=':
195 *tokenType = TK_EQ;
196 return 1;
197 case '<':
198 if( z[1]=='=' ){
199 *tokenType = TK_LE;
200 return 2;
201 }else if( z[1]=='>' ){
202 *tokenType = TK_NE;
203 return 2;
204 }else{
205 *tokenType = TK_LT;
206 return 1;
207 }
208 case '>':
209 if( z[1]=='=' ){
210 *tokenType = TK_GE;
211 return 2;
212 }else{
213 *tokenType = TK_GT;
214 return 1;
215 }
216 case '!':
217 if( z[1]!='=' ){
218 *tokenType = TK_ILLEGAL;
219 return 2;
220 }else{
221 *tokenType = TK_NE;
222 return 2;
223 }
224 case '?':
225 *tokenType = TK_WILDCARD;
226 return 1;
227 case ',':
228 *tokenType = TK_COMMA;
229 return 1;
230 case '`': case '\'': {
231 int delim = z[0];
232 for(i=1; z[i]; i++){
233 if( z[i]==delim )
234 break;
235 }
236 if( z[i] ) i++;
237 if( delim == '`' )
238 *tokenType = TK_ID;
239 else
240 *tokenType = TK_STRING;
241 return i;
242 }
243 case '.':
244 if( !isDigit(z[1]) ){
245 *tokenType = TK_DOT;
246 return 1;
247 }
248 /* Fall through */
249 case '0': case '1': case '2': case '3': case '4':
250 case '5': case '6': case '7': case '8': case '9':
251 *tokenType = TK_INTEGER;
252 for(i=1; isDigit(z[i]); i++){}
253 return i;
254 case '[':
255 for(i=1; z[i] && z[i-1]!=']'; i++){}
256 *tokenType = TK_ID;
257 return i;
258 default:
259 if( !isIdChar[*z] ){
260 break;
261 }
262 for(i=1; isIdChar[z[i]]; i++){}
263 *tokenType = sqliteKeywordCode(z, i);
264 if( *tokenType == TK_ID && z[i] == '`' ) *skip = 1;
265 return i;
266 }
267 *tokenType = TK_ILLEGAL;
268 return 1;
269}
#define skip(...)
Definition: atltest.h:64
GLdouble GLdouble z
Definition: glext.h:5874
static int sqliteKeywordCode(const WCHAR *z, int n)
Definition: tokenize.c:105
static const char isIdChar[]
Definition: tokenize.c:131
static int isDigit(WCHAR c)
Definition: tokenize.c:154
static int isSpace(WCHAR c)
Definition: tokenize.c:162

◆ STORAGES_CreateView()

UINT STORAGES_CreateView ( MSIDATABASE db,
MSIVIEW **  view 
)

Definition at line 515 of file storages.c.

516{
517 struct storages_view *sv;
518 INT rows;
519
520 TRACE("(%p, %p)\n", db, view);
521
522 sv = calloc(1, sizeof(*sv));
523 if (!sv)
525
526 sv->view.ops = &storages_ops;
527 sv->db = db;
528
529 rows = add_storages_to_table(sv);
530 if (rows < 0)
531 {
532 free(sv);
534 }
535 sv->num_rows = rows;
536
537 *view = (MSIVIEW *)sv;
538
539 return ERROR_SUCCESS;
540}
static INT add_storages_to_table(struct storages_view *sv)
Definition: storages.c:464
static const MSIVIEWOPS storages_ops
Definition: storages.c:441
MSIDATABASE * db
Definition: storages.c:52
UINT num_rows
Definition: storages.c:55
MSIVIEW view
Definition: storages.c:51
int32_t INT
Definition: typedefs.h:58

Referenced by TABLE_CreateView().

◆ STREAMS_CreateView()

UINT STREAMS_CreateView ( MSIDATABASE db,
MSIVIEW **  view 
)

Definition at line 539 of file streams.c.

540{
541 struct streams_view *sv;
542 UINT r;
543
544 TRACE("(%p, %p)\n", db, view);
545
546 r = load_streams( db );
547 if (r != ERROR_SUCCESS)
548 return r;
549
550 if (!(sv = calloc( 1, sizeof(*sv) )))
551 return ERROR_OUTOFMEMORY;
552
553 sv->view.ops = &streams_ops;
555 sv->db = db;
556
557 *view = (MSIVIEW *)sv;
558
559 return ERROR_SUCCESS;
560}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static const MSIVIEWOPS streams_ops
Definition: streams.c:373
static UINT load_streams(MSIDATABASE *db)
Definition: streams.c:445
#define NUM_STREAMS_COLS
Definition: streams.c:39
UINT num_cols
Definition: streams.c:45
MSIVIEW view
Definition: streams.c:43
MSIDATABASE * db
Definition: streams.c:44

Referenced by TABLE_CreateView().

◆ TABLE_CreateView()

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

Definition at line 2191 of file table.c.

2192{
2193 struct table_view *tv ;
2194 UINT r, sz;
2195
2196 TRACE("%p %s %p\n", db, debugstr_w(name), view );
2197
2198 if ( !wcscmp( name, L"_Streams" ) )
2199 return STREAMS_CreateView( db, view );
2200 else if ( !wcscmp( name, L"_Storages" ) )
2201 return STORAGES_CreateView( db, view );
2202
2203 sz = FIELD_OFFSET( struct table_view, name[lstrlenW( name ) + 1] );
2204 tv = calloc( 1, sz );
2205 if( !tv )
2206 return ERROR_FUNCTION_FAILED;
2207
2208 r = get_table( db, name, &tv->table );
2209 if( r != ERROR_SUCCESS )
2210 {
2211 free( tv );
2212 WARN("table not found\n");
2213 return r;
2214 }
2215
2216 TRACE("table %p found with %d columns\n", tv->table, tv->table->col_count);
2217
2218 /* fill the structure */
2219 tv->view.ops = &table_ops;
2220 tv->db = db;
2221 tv->columns = tv->table->colinfo;
2222 tv->num_cols = tv->table->col_count;
2224
2225 TRACE("%s one row is %d bytes\n", debugstr_w(name), tv->row_size );
2226
2227 *view = (MSIVIEW*) tv;
2228 lstrcpyW( tv->name, name );
2229
2230 return ERROR_SUCCESS;
2231}
#define lstrlenW
Definition: compat.h:750
static const MSIVIEWOPS table_ops
Definition: table.c:2168
static UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table_ret)
Definition: table.c:575
static UINT table_get_row_size(MSIDATABASE *db, const struct column_info *cols, UINT count, UINT bytes_per_strref)
Definition: table.c:376
#define LONG_STR_BYTES
Definition: msipriv.h:57
UINT STREAMS_CreateView(MSIDATABASE *db, MSIVIEW **view)
Definition: streams.c:539
UINT STORAGES_CreateView(MSIDATABASE *db, MSIVIEW **view)
Definition: storages.c:515
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
UINT num_cols
Definition: table.c:1002
MSIDATABASE * db
Definition: table.c:999
UINT row_size
Definition: table.c:1003
MSITABLE * table
Definition: table.c:1000
WCHAR name[1]
Definition: table.c:1004
struct column_info * columns
Definition: table.c:1001
MSIVIEW view
Definition: table.c:998
struct column_info * colinfo
Definition: table.c:66
UINT col_count
Definition: table.c:67
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by ALTER_CreateView(), DROP_CreateView(), INSERT_CreateView(), merge_table(), msi_create_table(), msi_table_apply_transform(), TABLE_add_column(), TABLE_drop(), table_load_transform(), TABLE_remove_column(), TransformView_Create(), UPDATE_CreateView(), and WHERE_CreateView().

◆ UPDATE_CreateView()

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

Definition at line 220 of file update.c.

222{
223 struct update_view *uv = NULL;
224 UINT r;
225 MSIVIEW *sv = NULL, *wv = NULL;
226
227 TRACE("%p\n", uv );
228
229 if (expr)
230 r = WHERE_CreateView( db, &wv, table, expr );
231 else
232 r = TABLE_CreateView( db, table, &wv );
233
234 if( r != ERROR_SUCCESS )
235 return r;
236
237 /* then select the columns we want */
238 r = SELECT_CreateView( db, &sv, wv, columns );
239 if( r != ERROR_SUCCESS )
240 {
241 wv->ops->delete( wv );
242 return r;
243 }
244
245 uv = calloc( 1, sizeof *uv );
246 if( !uv )
247 {
248 wv->ops->delete( wv );
250 }
251
252 /* fill the structure */
253 uv->view.ops = &update_ops;
254 msiobj_addref( &db->hdr );
255 uv->db = db;
256 uv->vals = columns;
257 uv->wv = sv;
258 *view = (MSIVIEW*) uv;
259
260 return ERROR_SUCCESS;
261}
UINT WHERE_CreateView(MSIDATABASE *db, MSIVIEW **view, LPWSTR tables, struct expr *cond)
Definition: where.c:1225
Definition: query.h:86
MSIVIEW view
Definition: update.c:43
MSIVIEW * wv
Definition: update.c:45
MSIDATABASE * db
Definition: update.c:44
column_info * vals
Definition: update.c:46
static const MSIVIEWOPS update_ops
Definition: update.c:198

◆ WHERE_CreateView()

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

Definition at line 1225 of file where.c.

1228{
1229 MSIWHEREVIEW *wv = NULL;
1230 UINT r, valid = 0;
1231 WCHAR *ptr;
1232
1233 TRACE("(%s)\n", debugstr_w(tables) );
1234
1235 wv = calloc(1, sizeof *wv);
1236 if( !wv )
1237 return ERROR_FUNCTION_FAILED;
1238
1239 /* fill the structure */
1240 wv->view.ops = &where_ops;
1241 msiobj_addref( &db->hdr );
1242 wv->db = db;
1243 wv->cond = cond;
1244
1245 while (*tables)
1246 {
1247 struct join_table *table;
1248
1249 if ((ptr = wcschr(tables, ' ')))
1250 *ptr = '\0';
1251
1252 table = malloc(sizeof(*table));
1253 if (!table)
1254 {
1256 goto end;
1257 }
1258
1259 r = TABLE_CreateView(db, tables, &table->view);
1260 if (r != ERROR_SUCCESS)
1261 {
1262 WARN("can't create table: %s\n", debugstr_w(tables));
1263 free(table);
1265 goto end;
1266 }
1267
1268 r = table->view->ops->get_dimensions(table->view, NULL,
1269 &table->col_count);
1270 if (r != ERROR_SUCCESS)
1271 {
1272 ERR("can't get table dimensions\n");
1273 table->view->ops->delete(table->view);
1274 free(table);
1275 goto end;
1276 }
1277
1278 wv->col_count += table->col_count;
1279 table->table_index = wv->table_count++;
1280
1281 table->next = wv->tables;
1282 wv->tables = table;
1283
1284 if (!ptr)
1285 break;
1286
1287 tables = ptr + 1;
1288 }
1289
1290 if( cond )
1291 {
1292 r = WHERE_VerifyCondition( wv, cond, &valid );
1293 if( r != ERROR_SUCCESS )
1294 goto end;
1295 if( !valid ) {
1297 goto end;
1298 }
1299 }
1300
1301 *view = (MSIVIEW*) wv;
1302
1303 return ERROR_SUCCESS;
1304end:
1305 WHERE_delete(&wv->view);
1306
1307 return r;
#define wcschr
Definition: compat.h:17
static UINT WHERE_VerifyCondition(MSIWHEREVIEW *wv, struct expr *cond, UINT *valid)
Definition: where.c:1136
static UINT WHERE_delete(struct tagMSIVIEW *view)
Definition: where.c:1033
static const MSIVIEWOPS where_ops
Definition: where.c:1113
struct nls_table * tables
Definition: nls_base.c:22
BOOLEAN valid
GLuint GLuint end
Definition: gl.h:1545
static PVOID ptr
Definition: dispmode.c:27
struct expr * cond
Definition: where.c:73
struct join_table * tables
Definition: where.c:67
UINT table_count
Definition: where.c:70
MSIVIEW view
Definition: where.c:65
MSIDATABASE * db
Definition: where.c:66
UINT col_count
Definition: where.c:69

Referenced by UPDATE_CreateView().