19 Star 39 Fork 46

openGauss / openGauss-connector-odbc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
configuration.ps1 2.67 KB
一键复制 编辑 原始数据 按行查看 历史
Param(
[string]$configPath
)
function InitConfiguration($savePath = $configurationXmlPath)
{
$configInfo = [xml](Get-Content "$configurationTemplatePath")
if ($env:PROCESSOR_ARCHITECTURE -eq "x86")
{
$x64info = $configInfo.Configuration.x64
$x64info.libpq.include = ""
$x64info.libpq.lib = ""
$x64info.libpq.bin = ""
}
$configInfo.save("$savePath")
return $configInfo
}
function global:GetConfiguration($loadPath = $configurationXmlPath)
{
$configInfo = [xml] (Get-Content "$loadPath")
set-variable -name xmlFormatVersion -value "0.4" -option constant
if ($configInfo.Configuration.formatVersion -ne $xmlFormatVersion)
{
$xmlDoc2 = [xml](Get-Content "$configurationTemplatePath")
$root2 = $XmlDoc2.get_DocumentElement()
$root1 = $configInfo.get_DocumentElement()
unifyNodes $root1 $root2
$root1.formatVersion = $xmlFormatVersion
$configInfo.save("$loadPath")
}
return $configInfo
}
function global:SaveConfiguration($configInfo, $savePath = $configurationXmlPath)
{
$configInfo.save("$savePath")
}
function global:unifyNodes($node1, $node2)
{
$attributes2 = $node2.get_Attributes()
if ($attributes2.Count -gt 0)
{
$attributes1 = $node1.get_Attributes()
foreach ($attrib in $attributes2)
{
$attribname = $attrib.name
if (($attributes1.Count -eq 0) -or ($attributes1.GetNamedItem($attribname) -eq $null))
{
Write-Debug " Adding attribute=$attribname"
$addattr = $node1.OwnerDocument.ImportNode($attrib, $true)
$added = $attributes1.Append($addattr)
}
}
}
if (!$node2.get_HasChildNodes()) {
return;
}
foreach ($child2 in $node2.get_ChildNodes())
{
$nodename = $child2.get_Name()
if ($nodename -eq "#text"){
continue
}
$matchnode = $node1.SelectSingleNode($nodename)
if ($matchnode -eq $null)
{
Write-Debug "Adding node=$nodename"
$addnode = $node1.OwnerDocument.ImportNode($child2, $true)
$added = $node1.AppendChild($addnode)
continue
}
unifyNodes $matchnode $child2
}
}
Write-Debug "configPath=$configPath"
$global:LIBPQ_VERSION="9.3"
$scriptPath = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
$global:configurationTemplatePath = "$scriptPath\configuration_template.xml"
$global:configurationXmlPath = $configPath
if ($configurationXmlPath -eq "") {
$global:configurationXmlPath = "$scriptPath\configuration.xml"
}
if (!(Test-Path -path $configurationXmlPath))
{
InitConfiguration
}
else
{
GetConfiguration
}
Return
C
1
https://gitee.com/opengauss/openGauss-connector-odbc.git
git@gitee.com:opengauss/openGauss-connector-odbc.git
opengauss
openGauss-connector-odbc
openGauss-connector-odbc
master

搜索帮助