{"id":1363,"date":"2007-09-01T13:19:28","date_gmt":"2007-09-01T13:19:28","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/2007\/09\/01\/column-types-cannot-be-changed-in-a-patch-or-transform\/"},"modified":"2019-02-17T15:30:12","modified_gmt":"2019-02-17T22:30:12","slug":"column-types-cannot-be-changed-in-a-patch-or-transform","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/column-types-cannot-be-changed-in-a-patch-or-transform\/","title":{"rendered":"Column Types Cannot be Changed in a Patch or Transform"},"content":{"rendered":"<p>Transforms can change just about anything in an installation package &#8211; even the code page. Transforms can also <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa372021.aspx\">add and drop both tables and columns<\/a> but they cannot, however, change the column type. This is true for patches as well, since <a href=\"http:\/\/blogs.msdn.com\/heaths\/archive\/2005\/09\/01\/what-s-in-a-patch.aspx\">a patch package contains transforms<\/a>.<\/p>\n<p>At their core, transforms store data aligned to the size of the data type. An i2 column &#8211; a SHORT, INT, or INTEGER in the <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa367870.aspx\">column definition format<\/a> &#8211; stores 16 bits of data while an i4 column &#8211; a LONG &#8211; stores 32 bits of data. If a product, for example, defines the <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa368596.aspx\">File<\/a> table&#8217;s Sequence column as i2 and a patch updates the Sequence column type to i4 then the data in the patch transform will be misaligned.<\/p>\n<p>When applying the transform or patch, the installation will fail. Windows Installer 4.0 and newer handle this failure gracefully by posting Windows Installer <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa372835.aspx\">error message<\/a> 2247 and returning <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa368542.aspx\">error<\/a> ERROR_PATCH_PACKAGE_INVALID (1636). Windows Installer 3.1 and older will throw an access violation exception.<\/p>\n<p>The best approach if you need to change the column type for a product that has already shipped is to ship a new <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa371855.aspx\">small update<\/a> or <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa370037.aspx\">minor upgrade<\/a> <em>.msi<\/em> package and <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa367575.aspx\">re-cache it when reinstalling<\/a>. This is a full product install but will still follow much of the same behavior as a patch when it comes to updating component resources. The key is that the <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa371182.aspx\">REINSTALLMODE property<\/a> contains &#8220;v&#8221; in its value to copy the new, updated <em>.msi<\/em> package to the cache. Future maintenance installations can then take advantage of the updated column types. You can also use a <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa369786.aspx\">major upgrade<\/a> that removes the existing product. This is a new <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa367570.aspx\">product install<\/a> &#8211; not a reinstall &#8211; and is cached automatically like any other new product install.<\/p>\n<p>If you plan on using the new msidbCustomActionTypePatchUninstall (0x8000) custom action attribute <a href=\"http:\/\/blogs.msdn.com\/heaths\/archive\/2007\/08\/27\/what-s-new-in-windows-installer-4-5-overview.aspx\">introduced in Windows Installer 4.5<\/a> you will need to update the <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa368062.aspx\">CustomAction<\/a> table&#8217;s Type column to i4. Note that ICE validation will fail for <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa368798.aspx\">ICE03<\/a> if you don&#8217;t update the <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa372930.aspx\">_Validation<\/a> table, and for <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa368971.aspx\">ICE45<\/a> with these new bits set when using older <em>.cub<\/em> files. When new <em>.cub<\/em> files are made available for Windows Installer 4.5 you should validate against them.<\/p>\n<p>There is some protection against this problem when generating patches.<\/p>\n<p>When the schemas of the target and upgrade databases differ, <em>PatchWiz.dll<\/em> will return an error. <em>PatchWiz.dll<\/em> 3.1 and older simply log that the authoring transform couldn&#8217;t be created. <em>PatchWiz.dll<\/em> 4.0 and newer is more helpful, logging both the return code from <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa370077.aspx\">MsiDatabaseGenerateTransform<\/a> as ERROR_INSTALL_TRANSFORM_FAILURE (1624) and the last error record, message 2248, which explicitly states that a specific column&#8217;s type differ between the target and upgrade databases. In both cases, <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa372095.aspx\">UiCreatePatchPackage<\/a> and <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa372094.aspx\">UiCreatePatchPackageEx<\/a> (available in <em>PatchWiz.dll<\/em> 4.0 and newer) &#8211; assuming no errors occur during clean-up &#8211; <a href=\"http:\/\/msdn2.microsoft.com\/library\/aa371250.aspx\">return<\/a> ERROR_PCW_CANT_GENERATE_TRANSFORM (0xC00E5173, 3222163827).<\/p>\n<p>In <a href=\"http:\/\/wix.sourceforge.net\/\">WiX<\/a> 3.0.3210.0 support was added for generating a patch from two administrative installations. Currently, if the target or upgrade database schemas differ from the internal table definitions in WiX, a transform will be generated against the internal schema so that the transform builds successfully but will not apply, nor will a patch containing that transform apply, to the target product. It is recommended, therefore, to use the same version of WiX that was used to build the product or use the existing PatchCreation element in WiX to generate a <em>.pcp<\/em> file that can be used with <em>PatchWiz.dll<\/em> from the Windows Installer SDK. You can use <em>msimsp.exe<\/em> also in the SDK as a wrapper around <em>PatchWiz.dll<\/em>. The topic &#8220;Using Patch Creation Properties&#8221; in <em>wix.chm<\/em> has more details and instructions.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Transforms can change just about anything in an installation package &#8211; even the code page. Transforms can also add and drop both tables and columns but they cannot, however, change the column type. This is true for patches as well, since a patch package contains transforms. At their core, transforms store data aligned to the [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[20,23,26,64],"class_list":["post-1363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-installation","tag-logging","tag-msi4-5","tag-wix"],"acf":[],"blog_post_summary":"<p>Transforms can change just about anything in an installation package &#8211; even the code page. Transforms can also add and drop both tables and columns but they cannot, however, change the column type. This is true for patches as well, since a patch package contains transforms. At their core, transforms store data aligned to the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/1363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=1363"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/1363\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=1363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=1363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=1363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}