aboutsummaryrefslogtreecommitdiff
path: root/src/ca/scasqlstr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ca/scasqlstr.cpp')
-rw-r--r--src/ca/scasqlstr.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/ca/scasqlstr.cpp b/src/ca/scasqlstr.cpp
index 6ac526a6..c3ebd43d 100644
--- a/src/ca/scasqlstr.cpp
+++ b/src/ca/scasqlstr.cpp
@@ -4,11 +4,11 @@
4 4
5// sql queries 5// sql queries
6LPCWSTR vcsSqlStringQuery = L"SELECT `String`, `SqlDb_`, `Component_`,`SQL`,`User_`,`Attributes`,`Sequence` " 6LPCWSTR vcsSqlStringQuery = L"SELECT `String`, `SqlDb_`, `Component_`,`SQL`,`User_`,`Attributes`,`Sequence` "
7L"FROM `SqlString` ORDER BY `SqlDb_`,`Sequence`"; 7L"FROM `Wix4SqlString` ORDER BY `SqlDb_`,`Sequence`";
8enum eSqlStringQuery { ssqSqlString = 1, ssqSqlDb, ssqComponent, ssqSQL, ssqUser, ssqAttributes, ssqSequence }; 8enum eSqlStringQuery { ssqSqlString = 1, ssqSqlDb, ssqComponent, ssqSQL, ssqUser, ssqAttributes, ssqSequence };
9 9
10LPCWSTR vcsSqlScriptQuery = L"SELECT `ScriptBinary_`,`Script`, `SqlDb_`, `Component_`,`User_`,`Attributes`,`Sequence` " 10LPCWSTR vcsSqlScriptQuery = L"SELECT `ScriptBinary_`,`Script`, `SqlDb_`, `Component_`,`User_`,`Attributes`,`Sequence` "
11L"FROM `SqlScript` ORDER BY `SqlDb_`,`Sequence`"; 11L"FROM `Wix4SqlScript` ORDER BY `SqlDb_`,`Sequence`";
12enum eSqlScriptQuery { sscrqScriptBinary=1, sscrqSqlScript, sscrqSqlDb, sscrqComponent, sscrqUser, sscrqAttributes, sscrqSequence }; 12enum eSqlScriptQuery { sscrqScriptBinary=1, sscrqSqlScript, sscrqSqlDb, sscrqComponent, sscrqUser, sscrqAttributes, sscrqSequence };
13 13
14LPCWSTR vcsSqlBinaryScriptQuery = L"SELECT `Data` FROM `Binary` WHERE `Name`=?"; 14LPCWSTR vcsSqlBinaryScriptQuery = L"SELECT `Data` FROM `Binary` WHERE `Name`=?";
@@ -44,15 +44,15 @@ HRESULT ScaSqlStrsRead(
44 44
45 SCA_SQLSTR* psss = NULL; 45 SCA_SQLSTR* psss = NULL;
46 46
47 if (S_OK != WcaTableExists(L"SqlString") || S_OK != WcaTableExists(L"SqlDatabase")) 47 if (S_OK != WcaTableExists(L"Wix4SqlString") || S_OK != WcaTableExists(L"Wix4SqlDatabase"))
48 { 48 {
49 WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsRead() - SqlString and/or SqlDatabase table not present"); 49 WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsRead() - Wix4SqlString and/or Wix4SqlDatabase table not present");
50 ExitFunction1(hr = S_FALSE); 50 ExitFunction1(hr = S_FALSE);
51 } 51 }
52 52
53 // loop through all the sql strings 53 // loop through all the sql strings
54 hr = WcaOpenExecuteView(vcsSqlStringQuery, &hView); 54 hr = WcaOpenExecuteView(vcsSqlStringQuery, &hView);
55 ExitOnFailure(hr, "Failed to open view on SqlString table"); 55 ExitOnFailure(hr, "Failed to open view on Wix4SqlString table");
56 while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) 56 while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
57 { 57 {
58 INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; 58 INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN;
@@ -80,30 +80,30 @@ HRESULT ScaSqlStrsRead(
80 psss->isAction = isAction; 80 psss->isAction = isAction;
81 81
82 hr = WcaGetRecordString(hRec, ssqSqlString, &pwzData); 82 hr = WcaGetRecordString(hRec, ssqSqlString, &pwzData);
83 ExitOnFailure(hr, "Failed to get SqlString.String"); 83 ExitOnFailure(hr, "Failed to get Wix4SqlString.String");
84 hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), pwzData); 84 hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), pwzData);
85 ExitOnFailure(hr, "Failed to copy SqlString.String: %ls", pwzData); 85 ExitOnFailure(hr, "Failed to copy Wix4SqlString.String: %ls", pwzData);
86 86
87 // find the database information for this string 87 // find the database information for this string
88 hr = WcaGetRecordString(hRec, ssqSqlDb, &pwzData); 88 hr = WcaGetRecordString(hRec, ssqSqlDb, &pwzData);
89 ExitOnFailure(hr, "Failed to get SqlString.SqlDb_ for SqlString '%ls'", psss->wzKey); 89 ExitOnFailure(hr, "Failed to get Wix4SqlString.SqlDb_ for SqlString '%ls'", psss->wzKey);
90 hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), pwzData); 90 hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), pwzData);
91 ExitOnFailure(hr, "Failed to copy SqlString.SqlDb_: %ls", pwzData); 91 ExitOnFailure(hr, "Failed to copy Wix4SqlString.SqlDb_: %ls", pwzData);
92 92
93 hr = WcaGetRecordInteger(hRec, ssqAttributes, &psss->iAttributes); 93 hr = WcaGetRecordInteger(hRec, ssqAttributes, &psss->iAttributes);
94 ExitOnFailure(hr, "Failed to get SqlString.Attributes for SqlString '%ls'", psss->wzKey); 94 ExitOnFailure(hr, "Failed to get Wix4SqlString.Attributes for SqlString '%ls'", psss->wzKey);
95 95
96 //get the sequence number for the string (note that this will be sequenced with scripts too) 96 //get the sequence number for the string (note that this will be sequenced with scripts too)
97 hr = WcaGetRecordInteger(hRec, ssqSequence, &psss->iSequence); 97 hr = WcaGetRecordInteger(hRec, ssqSequence, &psss->iSequence);
98 ExitOnFailure(hr, "Failed to get SqlString.Sequence for SqlString '%ls'", psss->wzKey); 98 ExitOnFailure(hr, "Failed to get Wix4SqlString.Sequence for SqlString '%ls'", psss->wzKey);
99 99
100 // execute SQL 100 // execute SQL
101 hr = WcaGetRecordFormattedString(hRec, ssqSQL, &pwzData); 101 hr = WcaGetRecordFormattedString(hRec, ssqSQL, &pwzData);
102 ExitOnFailure(hr, "Failed to get SqlString.SQL for SqlString '%ls'", psss->wzKey); 102 ExitOnFailure(hr, "Failed to get Wix4SqlString.SQL for SQL string '%ls'", psss->wzKey);
103 103
104 Assert(!psss->pwzSql); 104 Assert(!psss->pwzSql);
105 hr = StrAllocString(&psss->pwzSql, pwzData, 0); 105 hr = StrAllocString(&psss->pwzSql, pwzData, 0);
106 ExitOnFailure(hr, "Failed to alloc string for SqlString '%ls'", psss->wzKey); 106 ExitOnFailure(hr, "Failed to alloc string for SQL string '%ls'", psss->wzKey);
107 107
108 *ppsssList = AddSqlStrToList(*ppsssList, psss); 108 *ppsssList = AddSqlStrToList(*ppsssList, psss);
109 psss = NULL; // set the sss to NULL so it doesn't get freed below 109 psss = NULL; // set the sss to NULL so it doesn't get freed below
@@ -113,7 +113,7 @@ HRESULT ScaSqlStrsRead(
113 { 113 {
114 hr = S_OK; 114 hr = S_OK;
115 } 115 }
116 ExitOnFailure(hr, "Failure occured while reading SqlString table"); 116 ExitOnFailure(hr, "Failure occured while reading Wix4SqlString table");
117 117
118LExit: 118LExit:
119 // if anything was left over after an error clean it all up 119 // if anything was left over after an error clean it all up
@@ -157,19 +157,19 @@ HRESULT ScaSqlStrsReadScripts(
157 SCA_SQLSTR sss; 157 SCA_SQLSTR sss;
158 SCA_SQLSTR* psss = NULL; 158 SCA_SQLSTR* psss = NULL;
159 159
160 if (S_OK != WcaTableExists(L"SqlScript") || S_OK != WcaTableExists(L"SqlDatabase") || S_OK != WcaTableExists(L"Binary")) 160 if (S_OK != WcaTableExists(L"Wix4SqlScript") || S_OK != WcaTableExists(L"Wix4SqlDatabase") || S_OK != WcaTableExists(L"Binary"))
161 { 161 {
162 WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsReadScripts() - SqlScripts and/or SqlDatabase table not present"); 162 WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsReadScripts() - Wix4SqlScript and/or Wix4SqlDatabase table not present");
163 ExitFunction1(hr = S_FALSE); 163 ExitFunction1(hr = S_FALSE);
164 } 164 }
165 165
166 // open a view on the binary table 166 // open a view on the binary table
167 hr = WcaOpenView(vcsSqlBinaryScriptQuery, &hViewBinary); 167 hr = WcaOpenView(vcsSqlBinaryScriptQuery, &hViewBinary);
168 ExitOnFailure(hr, "Failed to open view on Binary table for SqlScripts"); 168 ExitOnFailure(hr, "Failed to open view on Binary table for SQL scripts");
169 169
170 // loop through all the sql scripts 170 // loop through all the sql scripts
171 hr = WcaOpenExecuteView(vcsSqlScriptQuery, &hView); 171 hr = WcaOpenExecuteView(vcsSqlScriptQuery, &hView);
172 ExitOnFailure(hr, "Failed to open view on SqlScript table"); 172 ExitOnFailure(hr, "Failed to open view on Wix4SqlScript table");
173 while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) 173 while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
174 { 174 {
175 INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; 175 INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN;
@@ -196,33 +196,33 @@ HRESULT ScaSqlStrsReadScripts(
196 sss.isAction = isAction; 196 sss.isAction = isAction;
197 197
198 hr = WcaGetRecordString(hRec, sscrqSqlScript, &pwzData); 198 hr = WcaGetRecordString(hRec, sscrqSqlScript, &pwzData);
199 ExitOnFailure(hr, "Failed to get SqlScript.Script"); 199 ExitOnFailure(hr, "Failed to get Wix4SqlScript.Script");
200 hr = ::StringCchCopyW(sss.wzKey, countof(sss.wzKey), pwzData); 200 hr = ::StringCchCopyW(sss.wzKey, countof(sss.wzKey), pwzData);
201 ExitOnFailure(hr, "Failed to copy SqlScript.Script: %ls", pwzData); 201 ExitOnFailure(hr, "Failed to copy Wix4SqlScript.Script: %ls", pwzData);
202 202
203 // find the database information for this string 203 // find the database information for this string
204 hr = WcaGetRecordString(hRec, sscrqSqlDb, &pwzData); 204 hr = WcaGetRecordString(hRec, sscrqSqlDb, &pwzData);
205 ExitOnFailure(hr, "Failed to get SqlScript.SqlDb_ for SqlScript '%ls'", sss.wzKey); 205 ExitOnFailure(hr, "Failed to get Wix4SqlScript.SqlDb_ for SqlScript '%ls'", sss.wzKey);
206 hr = ::StringCchCopyW(sss.wzSqlDb, countof(sss.wzSqlDb), pwzData); 206 hr = ::StringCchCopyW(sss.wzSqlDb, countof(sss.wzSqlDb), pwzData);
207 ExitOnFailure(hr, "Failed to copy SqlScritp.SqlDbb: %ls", pwzData); 207 ExitOnFailure(hr, "Failed to copy Wix4SqlScript.SqlDbb: %ls", pwzData);
208 208
209 hr = WcaGetRecordInteger(hRec, sscrqAttributes, &sss.iAttributes); 209 hr = WcaGetRecordInteger(hRec, sscrqAttributes, &sss.iAttributes);
210 ExitOnFailure(hr, "Failed to get SqlScript.Attributes for SqlScript '%ls'", sss.wzKey); 210 ExitOnFailure(hr, "Failed to get Wix4SqlScript.Attributes for SqlScript '%ls'", sss.wzKey);
211 211
212 hr = WcaGetRecordInteger(hRec, sscrqSequence, &sss.iSequence); 212 hr = WcaGetRecordInteger(hRec, sscrqSequence, &sss.iSequence);
213 ExitOnFailure(hr, "Failed to get SqlScript.Sequence for SqlScript '%ls'", sss.wzKey); 213 ExitOnFailure(hr, "Failed to get Wix4SqlScript.Sequence for SqlScript '%ls'", sss.wzKey);
214 214
215 // get the sql script out of the binary stream 215 // get the sql script out of the binary stream
216 hr = WcaExecuteView(hViewBinary, hRec); 216 hr = WcaExecuteView(hViewBinary, hRec);
217 ExitOnFailure(hr, "Failed to open SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); 217 ExitOnFailure(hr, "Failed to open Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey);
218 hr = WcaFetchSingleRecord(hViewBinary, &hRecBinary); 218 hr = WcaFetchSingleRecord(hViewBinary, &hRecBinary);
219 ExitOnFailure(hr, "Failed to fetch SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); 219 ExitOnFailure(hr, "Failed to fetch Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey);
220 220
221 // Note: We need to allocate an extra character on the stream to NULL terminate the SQL script. 221 // Note: We need to allocate an extra character on the stream to NULL terminate the SQL script.
222 // The WcaGetRecordStream() function won't let us add extra space on the end of the stream 222 // The WcaGetRecordStream() function won't let us add extra space on the end of the stream
223 // so we'll read the stream "the old fashioned way". 223 // so we'll read the stream "the old fashioned way".
224 //hr = WcaGetRecordStream(hRecBinary, ssbsqData, (BYTE**)&pbScript, &cbScript); 224 //hr = WcaGetRecordStream(hRecBinary, ssbsqData, (BYTE**)&pbScript, &cbScript);
225 //ExitOnFailure(hr, "Failed to read SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); 225 //ExitOnFailure(hr, "Failed to read Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey);
226 er = ::MsiRecordReadStream(hRecBinary, ssbsqData, NULL, &cbRead); 226 er = ::MsiRecordReadStream(hRecBinary, ssbsqData, NULL, &cbRead);
227 hr = HRESULT_FROM_WIN32(er); 227 hr = HRESULT_FROM_WIN32(er);
228 ExitOnFailure(hr, "failed to get size of stream"); 228 ExitOnFailure(hr, "failed to get size of stream");
@@ -472,7 +472,7 @@ HRESULT ScaSqlStrsReadScripts(
472 { 472 {
473 hr = S_OK; 473 hr = S_OK;
474 } 474 }
475 ExitOnFailure(hr, "Failure occured while reading SqlString table"); 475 ExitOnFailure(hr, "Failure occured while reading Wix4SqlScript table");
476 476
477LExit: 477LExit:
478 // if anything was left over after an error clean it all up 478 // if anything was left over after an error clean it all up