ReactOS 0.4.15-dev-8052-gc0e3179
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, BOOL hold) DECLSPEC_HIDDEN
 
UINT msi_select_update (MSIVIEW *view, MSIRECORD *rec, UINT row) DECLSPEC_HIDDEN
 
UINT msi_view_refresh_row (MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD *rec) 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 160 of file alter.c.

161{
162 MSIALTERVIEW *av;
163 UINT r;
164
165 TRACE("%p %p %s %d\n", view, colinfo, debugstr_w(name), hold );
166
167 av = msi_alloc_zero( sizeof *av );
168 if( !av )
170
171 r = TABLE_CreateView( db, name, &av->table );
172 if (r != ERROR_SUCCESS)
173 {
174 msi_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 ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define debugstr_w
Definition: kernel32.h:32
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1148
static void msi_free(void *mem)
Definition: msipriv.h:1159
unsigned int UINT
Definition: ndis.h:50
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view) DECLSPEC_HIDDEN
Definition: table.c:2189
#define TRACE(s)
Definition: solgame.cpp:4
LPCWSTR table
Definition: msipriv.h:222
Definition: name.c:39
MSIDATABASE * db
Definition: alter.c:40
MSIVIEW view
Definition: alter.c:39
MSIVIEW * table
Definition: alter.c:41
column_info * colinfo
Definition: alter.c:42
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 MSICREATEVIEW *cv = NULL;
164 UINT r;
165 column_info *col;
166 BOOL temp = TRUE;
167 BOOL tempprim = FALSE;
168
169 TRACE("%p\n", cv );
170
171 r = check_columns( col_info );
172 if( r != ERROR_SUCCESS )
173 return r;
174
175 cv = msi_alloc_zero( 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 msi_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
struct _column_info * next
Definition: msipriv.h:226
LPCWSTR name
Definition: create.c:45
MSIDATABASE * db
Definition: create.c:44
column_info * col_info
Definition: create.c:48
BOOL bIsTemp
Definition: create.c:46
MSIVIEW view
Definition: create.c:43
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 MSIDELETEVIEW *dv = NULL;
193
194 TRACE("%p\n", dv );
195
196 dv = msi_alloc_zero( 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
MSIDATABASE * db
Definition: delete.c:54
MSIVIEW view
Definition: delete.c:53
MSIVIEW * table
Definition: delete.c:55

◆ DISTINCT_CreateView()

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

Definition at line 273 of file distinct.c.

274{
275 MSIDISTINCTVIEW *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 = msi_alloc_zero( 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: debug.h:113
static const MSIVIEWOPS distinct_ops
Definition: distinct.c:250
GLuint GLuint GLsizei count
Definition: gl.h:1545
MSIVIEW * table
Definition: distinct.c:51
UINT * translation
Definition: distinct.c:53
MSIDATABASE * db
Definition: distinct.c:50

◆ 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)
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}
static const MSIVIEWOPS drop_ops
Definition: drop.c:95
MSIDATABASE * db
Definition: drop.c:40
MSIVIEW view
Definition: drop.c:39
MSIVIEW * table
Definition: drop.c:41

◆ 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 MSIINSERTVIEW *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 = msi_alloc_zero( 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) DECLSPEC_HIDDEN
Definition: select.c:423
MSIDATABASE * db
Definition: insert.c:45
MSIVIEW view
Definition: insert.c:43
MSIVIEW * sv
Definition: insert.c:47
MSIVIEW * table
Definition: insert.c:44
BOOL bIsTemp
Definition: insert.c:46
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 705 of file table.c.

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

Referenced by INSERT_execute(), and UPDATE_execute().

◆ msi_select_update()

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

Definition at line 249 of file select.c.

250{
252 UINT r, i, col, type, val;
254 LPCWSTR str;
255
256 for (i = 0; i < sv->num_cols; i++)
257 {
258 col = sv->cols[i];
259
261 if (r != ERROR_SUCCESS)
262 {
263 ERR("Failed to get column information: %d\n", r);
264 return r;
265 }
266
268 {
269 if (MSI_RecordGetIStream(rec, i + 1, &stream))
271 r = sv->table->ops->set_stream(sv->table, row, col, stream);
272 }
273 else if (type & MSITYPE_STRING)
274 {
275 int len;
276 str = msi_record_get_string(rec, i + 1, &len);
277 r = sv->table->ops->set_string(sv->table, row, col, str, len);
278 }
279 else
280 {
281 val = MSI_RecordGetInteger(rec, i + 1);
282 r = sv->table->ops->set_int(sv->table, row, col, val);
283 }
284
285 if (r != ERROR_SUCCESS)
286 {
287 ERR("Failed to modify record: %d\n", r);
288 return r;
289 }
290 }
291
292 return ERROR_SUCCESS;
293}
static UINT SELECT_get_column_info(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: select.c:223
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
UINT MSI_RecordGetIStream(MSIRECORD *, UINT, IStream **) DECLSPEC_HIDDEN
Definition: record.c:852
#define MSITYPE_IS_BINARY(type)
Definition: msipriv.h:62
const WCHAR * msi_record_get_string(const MSIRECORD *, UINT, int *) DECLSPEC_HIDDEN
Definition: record.c:420
#define MSITYPE_STRING
Definition: msipriv.h:50
int MSI_RecordGetInteger(MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:213
const WCHAR * str
Definition: parse.h:23
UINT cols[1]
Definition: select.c:48
MSIVIEW * table
Definition: select.c:45
UINT num_cols
Definition: select.c:46
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_RecordSetIStream(MSIRECORD *, UINT, IStream *) DECLSPEC_HIDDEN
Definition: record.c:836
#define MSITYPE_VALID
Definition: msipriv.h:48
#define MSI_DATASIZEMASK
Definition: msipriv.h:47
UINT msi_record_set_string(MSIRECORD *, UINT, const WCHAR *, int) DECLSPEC_HIDDEN
Definition: record.c:573
#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 423 of file select.c.

425{
426 MSISELECTVIEW *sv = NULL;
427 UINT count = 0, r = ERROR_SUCCESS;
428
429 TRACE("%p\n", sv );
430
431 count = select_count_columns( columns );
432
434 if( !sv )
436
437 /* fill the structure */
438 sv->view.ops = &select_ops;
439 sv->db = db;
440 sv->table = table;
441 sv->num_cols = 0;
442 sv->max_cols = count;
443
444 while( columns )
445 {
446 r = SELECT_AddColumn( sv, columns->column, columns->table );
447 if( r )
448 break;
449 columns = columns->next;
450 }
451
452 if( r == ERROR_SUCCESS )
453 *view = &sv->view;
454 else
455 msi_free( sv );
456
457 return r;
458}
static const MSIVIEWOPS select_ops
Definition: select.c:352
static UINT SELECT_AddColumn(MSISELECTVIEW *sv, LPCWSTR name, LPCWSTR table_name)
Definition: select.c:375
static int select_count_columns(const column_info *col)
Definition: select.c:415
LPCWSTR column
Definition: msipriv.h:223
UINT max_cols
Definition: select.c:47
MSIVIEW view
Definition: select.c:43
MSIDATABASE * db
Definition: select.c:44
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

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 MSISTORAGESVIEW *sv;
518 INT rows;
519
520 TRACE("(%p, %p)\n", db, view);
521
522 sv = msi_alloc_zero( sizeof(MSISTORAGESVIEW) );
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 msi_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(MSISTORAGESVIEW *sv)
Definition: storages.c:464
static const MSIVIEWOPS storages_ops
Definition: storages.c:441
MSIDATABASE * db
Definition: storages.c:52
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 MSISTREAMSVIEW *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 = msi_alloc_zero( sizeof(MSISTREAMSVIEW) )))
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
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 2189 of file table.c.

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

Referenced by ALTER_CreateView(), DROP_CreateView(), INSERT_CreateView(), merge_table(), msi_create_table(), msi_table_apply_transform(), msi_table_load_transform(), TABLE_add_column(), TABLE_drop(), 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 MSIUPDATEVIEW *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 = msi_alloc_zero( 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) DECLSPEC_HIDDEN
Definition: where.c:1226
Definition: query.h:87
MSIDATABASE * db
Definition: update.c:44
MSIVIEW view
Definition: update.c:43
column_info * vals
Definition: update.c:46
MSIVIEW * wv
Definition: update.c:45
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 1226 of file where.c.

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

Referenced by UPDATE_CreateView().