Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-DbaDbccMemoryStatus - remove dependency on system.data objects and use standard constructs #5031

Merged
merged 3 commits into from
Feb 3, 2019

Conversation

sqllensman
Copy link
Contributor

Type of Change

  • Bug fix (non-breaking change, fixes #)
  • New feature (non-breaking change, adds functionality)
  • Breaking change (effects multiple commands or functionality)
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

Purpose

Adopt standard constructs and simplify code

Approach

Update of Get-DbaDbccMemoryStatus to use more standard approach to execute SQL Statement
In initial Pull request #4698 comments were made around using $server.Query() instead of the system.data objects. This would not work as multiple data sets need to be returned. However subsequent testing found that $server.ConnectionContext.ExecuteWithResults($query) will return the required data

Commands to test

Get-DbaDbccMemoryStatus

@wsmelton wsmelton changed the title Update command to remove dependancy on system.data objects and use standard constructs Get-DbaDbccMemoryStatus - remove dependency on system.data objects and use standard constructs Jan 31, 2019
@wsmelton
Copy link
Member

Use of $server.Query() does support multiple datasets, it simply does not present the Tables class to iterate over.

The logic in the foreach would just have to be updated to handle it properly....

image

@sqllensman
Copy link
Contributor Author

sqllensman commented Feb 1, 2019

The example above of using $server.Query() only shows how to iterate through the data rows of the first recordset returned by DBCC MEMSTATUS

The object returned by $server.Query() is an Object array and each item is a DataRow.

The data returned from DBCC MEMSTATUS on my SQL Server 2017 instance will contain 122 Recordsets and a total of 765 rows of data.

In order to retrieve all the results it needs to be called as
$data = $server.query('DBCC MEMORYSTATUS','master','true') which returns the Tables collection.

I will look to update to use this construct.

@wsmelton
Copy link
Member

wsmelton commented Feb 1, 2019

Ah, I was misreading the output on my computer. I forgot about that 3rd parameter that Fred added in to get the table objects. Need to throw that into the wiki so I remember it.

@potatoqualitee
Copy link
Member

thanks to you both 🙇

@potatoqualitee potatoqualitee merged commit f707a63 into dataplat:development Feb 3, 2019
sphallsphall added a commit to sphallsphall/dbatools that referenced this pull request Mar 11, 2019
* Fix Select-DbaBackupInformation

$_.LastLSN.ToString() -ge $LogBaseLsn
$_.LastLSN.ToString() is STRING, but $LogBaseLsn is BIGINT. Powershell converts [BIGINT]$LogBaseLsn to string and after that compare these variables as strings.

* Fix masking (dataplat#4942)

* Added money type

* Added txt data type

* added min and maxvalue to money type

* otsb

* Small fixes Import-DbaXESessionTemplate (dataplat#4917)

* Update Import-DbaXESessionTemplate.ps1

* Update Import-DbaXESessionTemplate.ps1

* 0.9.740

* ApplicationIntent fixes

* 0.9.741

* Update ConvertTo-DbaTimeline.ps1 (dataplat#4952)

Updated example 3; Send-MailMessage only accepts string for -Body

* 0.9.742

* Figure out the new name before doing the checks.

Otherwise we may check to see if "sourceInstance default profile" exists on the destination then trying to create "destinationInstance default profile" which already exists.

* Update Install-DbaMaintenanceSolution.ps1

Fixed path for output directory in Install-DbaMaintenanceSolution dataplat#4950

* Fixed "Succesful" typo (dataplat#4960)

Addresses Status property spelling error for Successful status.

* Adjust unit test (dataplat#4961)

Adjusting the unit test for `tests/Get-DbaTraceFlag.Tests.ps1`

* add example

* new improved unit tests

* removed link for now :(

* update variable names and fix example

* Do the same replacement check for accounts.

* update to new format

* Update replace of SQL commands to just update the @account_name and @profile_name fields

Also put single quotes around the account and profile name in messages for readability.

* command updates

* Update to contributing and readme files (dataplat#4976)

* adjusting content on contributing guide

* adjusting readme content

* Changed names of jobs and schedules. Fixes dataplat#4972 (dataplat#4973)

* Changed names of jobs and schedules. Fixes dataplat#4972

* Added back the source server name in the default copy and restore job

* Unit test updates round 2 (dataplat#4977)

Unit Test Updates, now uniform and simplified

* Add missing unit tests (dataplat#4979)

* add missing unit tests

* fix encoding

* support hostnames ending with - (dataplat#4978)

* 0.9.743

* tests every function has a tests file, and our standard unit tets

* typo

* adjusting example to use splatting

* Updating editor settings for VS Code

Added additional settings that I found turned off by default in VS Code now. Also added comments so folks can see a bit more info on why we set what.

* 0.9.744

* Update Invoke-ManagedComputerCommand.ps1

User must pass permissions

* Fix lower case / upper case

Also fix this line
$sql = $sql.Replace($db.Name, "<TARGETDB>")
This is wrong because of tempdb on the first line will be replaced.

* fixing output mismatch for continue

* removing comments

* 0.9.745

* Get-DbaProductKey: Get-DbaRegistryRoot add -Credential $Credential

* 0.9.747

* typo fixes: efficient -> inefficient. accomodating -> accommodating

In the CBH context of table parameter.

* fixes dataplat#4999 fixes dataplat#4998

* Sqlupdate 2016 sp2 cu5 (dataplat#5006)

* Sqlupdate 2016 sp2 cu5

* Sqlupdate 2016 sp2 cu5

* Sqlupdate 2016 sp2 cu5

* 0.9.748

* buildref, keep in sync (dataplat#5007)

* removing LSN check from backup

* 0.9.749

* Add type switch to gbh call to improve chances of gettign the right backup back

* resuse server connection for get-dbadefaultpath

* fixed bad db killing the bunch

* removing allowcontinue

* fixing up parameter count test

* 0.9.750

* proposed changes

* update docs

* Changes to Export-DbaScript to resolve Issue 2914

* fix caps

* fixed dataplat#4847

* fixed dataplat#5013

* First attempt at catching up on changelog

* Fix data masking on 724

* Fix failsafe on 725

* Fix remainder of off-by-one errors in release numbers

* support -Database properly fixes dataplat#5015

* Changelog caught up through end of 2018

* Changelog caught up to 0.9.750

* Changelog caught up to 0.9.750

* typo fix in sync-dbaavailabilitygroup (dataplat#5027)

Typos fixed in `Sync-DbaAvailabilityGroup`

* 0.9.751

* Update Backup-DbaDatabase AzureBaseUrl parameter help

Changed a reference from NoCopyOnly to Copy to cleanup help and documentation

* Get-DbaDbccMemoryStatus - remove dependency on system.data objects and use standard constructs (dataplat#5031)

* Remove dependancy on system.Data objects

* Fix case of variable

* Modify to use the  .query custom method

* Fixed math (dataplat#5040)

* Fix Set-DbaAgentJobStep  (dataplat#5030)

* Added option to add job step if it doesn't exist

* Added try/catch block for new job step
Moved job step settings

* Changed param type
Fixed if statement

* Removed comment in param

* Added else statements to alter the job step

* Fixed job check
Added filter for job and job step
Fixed check for job
Fixed check for Database and DatabaseUsername

* Changed if statements to better check for the variables

* Added subsystem server. Fixes dataplat#4715

* Formatted it to be the dbatools way

* Added check if Server value is set

* Reformatted the code

* Removed aliases

* Added parameter to unit test

* Added inputobject parameter

* Added help

* 0.9.752

* Update New-DbaAgentJobCategory.ps1 (dataplat#5042)

changed $instance to $server to fix authentication issue

* fixes piping issue (dataplat#5041)

* Update settings.json (dataplat#5054)

*  Added check if database from $Database array is accessible or not before getting roles membership (dataplat#5046)

* Added check if database from $Database array is accessible or not before getting roles membership

* add messaging in verbose mode

* Invoke-DbatoolsFormatter

* add LoginType to returned [PSCustomObject]$user

* Revert "add LoginType to returned [PSCustomObject]$user"

This reverts commit 9286f97.

revert last commit

* Update Get-DbaDbRoleMember.ps1

got rid of try/catch
add Logintype to output

* Added Stop-Function calls to fix dataplat#5050 (dataplat#5052)

* Added Stop-Function calls to fix dataplat#5050

* Simplified catch block to auto pass $EnableException to Stop-Function

* Pass -Force through to Set-DbaDbState (dataplat#5057)

* Fixes for Update-DbaInstance: parallelism, exceptions (dataplat#5053)

* Changing error handling in internal functions + minor fixes

* Removing $EnableException param

* 0.9.753

* 0.9.751 Changes

* 0.9.752 changes

* 0.9.753 changes

* Correct EOL date for 2014 SP2

* 0.9.754

* deprecating AllowContinue

* fixing tests after putting param back in

* buildref, bump date

* Initial commit of New-DbaDbMailProfile, need to add integration tests

* Add project support for VSCode plugin `markdownlint`. List of rules at
https: //github.com/DavidAnson/markdownlint/blob/v0.11.0/doc/Rules.md

Various fixes pointed out by markdownlint

* fixing type in tests

* doubling up on param names fixed

* updating Invoke-DbaDbUpgrade for dataplat#5047

this fixes dataplat#5047 by checking if each object is in the array instead of containing the array. Also applied to the ExcludeDatabase option

* 0.9.755

* test for existence first

* Get-DecryptedObject - Lowercase sys.credentials

* Copy-DbaLinkedServer - check ProductName

* Update Get-DecryptedObject.ps1

* 0.9.757

* New function to support multithreading

* Tests for advanced update function

* Removing lab computer names

* fixes issue dataplat#5090 and adds test coverage for it

* fix for test

* 0.9.770

* Clarified comments on sequenceNumber

* Fix naming conventions

* Removed unused integration tests. Added test for $priority.

* Fix wrong variable names in tests

* Add new login support for Azure SQL Dbs

Fixes dataplat#5100

* Correct formatting

* Changelog catchup (dataplat#5098)

* Catch up to 0.9.755

* 757

* Caught up to 0.9.770

* change bom

* added account, removed tests for properties that do not exist

* 0.9.771

adding current commands and prepping for future command

* buildref, added cu2 for 2014sp3 and cu16 for 2014sp2 (dataplat#5107)

* Changelog for 0.9.771 (dataplat#5105)

* Fixed self-building process (dataplat#5111)

* Fixed self-building process

* fixed indents

* Add handler for AllUserDatabases to resolve Issue 5108 (dataplat#5110)

* Add handler fro AllUserDatabases to resolve Issue 5108

* Fix OTSB Issue

* adding SmartTarget tag to those cmds using it (dataplat#5109)

* 0.9.772

* Corrected property names for job start & end dates (dataplat#5115)

* Add namespace variable so that full type name can be resolved (dataplat#5114)

* Update Install-DbaMaintenanceSolution to fix dataplat#5096 (dataplat#5112)

Changed $instance to $server to fix sql authentication issue during job removal in a -ReplaceExisting scenario

* 0.9.773

* Make Backup-DbaDatabase use Database and ExcludeDatabase when piping (dataplat#5069)

* fixes dataplat#5044

* fix one test

* in instead of contains

* 0.9.773 changelog (dataplat#5118)

* Pass Login values to Copy-DbaLogin (dataplat#5120)

Call to `Copy-DbaLogin` simply didn't pass the values.

Fixes dataplat#5119

* Update Copy-DbaAgentAlert.ps1

Added check to make sure the operator exists at the destination before creating the alert. If not, skip the alert and update the output object.

* Update Copy-DbaAgentAlert.ps1

Removed trailing spaces per failed test: "176Describe : dbatools style
177Context : indentation
178Name : It Copy-DbaAgentAlert.ps1 has no trailing spaces (line(s) 154,156)
179Result : Failed
180Message : Expected 0, but got 2."

* Fix masking commands (dataplat#5071)

* Added check for unique indexes

* Added procedure to make up what the unique indexes are build with
Added check if excluded column is in a unique index

* Added table

* Added extra options for data generation

* Removed unused rowcount
Added unique value dictionary creation

* Added format for masking types

* Added support for using formatting of values

* Added check if any masking info is present

* Implemented unique index support

* Renamed variable

* Revert "Renamed variable"

This reverts commit 3f7adb8.

* Renamed variable and applied formatiing

* Fixed errors in unique value generation

* Added variable for the unique value columns
Changed the if statement for the unique columns

* Explicitly reset the new value variable

* Moved variables to make sure they get cleared in the loop

* Removed date selection
Added section for finance. Can be used for other types that support max

* Revert "Removed date selection"

This reverts commit 6ec4f16.

* Added section for support of max

* Added part for finance

* Removed finance from other section

* Changed if statement to switch

* Changed switch back to if statement
Removed sections
Added finance to other section

* Removed section for finance

* Added checks for supported data types, masking types and sub types

* Moved retrieval of method and properties to begin
Changed if statements for types

* Changed message of unsupported types

* Added new known types
Added format key to known types

* Added extra known types

* Implemented support for text and ntext data types

* Added ntext and text data types

* Added decimal data type

* Moved data retrieval down

* Added types and synonyms
Rearranged the types to be in alphabetical order

* Added types

* Added types to automatically assign the right maskingtype

* Improved the check for supported data types

* Fixed bug missing curly bracket

* Moved the retrieval of the data
Implemented selective columns for data retrieval

* Changed back to SELECT * instead of selective columns

* Changed the SELECT * to be selective columns from table and not object

* Moved data retrieval
Changed where statement build-up

* Removed debug query outputs

* Moved where build-up

* Added special conversion to date and datetime columns

* Fixed bug with missing comma

* Added error record

* Removed unneccesary if statement
Fixed bug with TEXT and NTEXT cast in WHERE clause

* Implemented handling of temporal  values generation
Formatted code

* Fixed bool handling

* Added decimal type

* Added fax synonyms

* Fixed bool handling

* Updates test should statement

* Changed back the should statement

* Enabled rdp

* Changed rdp password

* Formatted test

* Reset appveyor.yml to original settings

* Changed instance

* Changed instance

* Changed instance back

* Added credential

* 0.9.773

* change instance

* Make Backup-DbaDatabase use Database and ExcludeDatabase when piping (dataplat#5069)

* fixes dataplat#5044

* fix one test

* in instead of contains

* 0.9.773 changelog (dataplat#5118)

* Pass Login values to Copy-DbaLogin (dataplat#5120)

Call to `Copy-DbaLogin` simply didn't pass the values.

Fixes dataplat#5119

* Updated test to use other instance

* Enabled RDP

* Set RDP to be started before tests

* Removed RDP option again

* Added fix for datetime

* Formatted code

* Added extra check for temporal tables

* Changed test back to 2008 instance

* 0.9.774

* fix comparison issue

* 0.9.775

* Update Copy-DbaAgentAlert.ps1

Incorporated approach by @alevyinroc at alevyinroc@8a8a8da . Fixed issues mentioned in review by @wsmelton - thank you!

* Update Copy-DbaAgentAlert.ps1

Checked for $null $sourceAlertOperators so Compare-Object wouldn't fail with a $null -ReferenceObject.

* Update Copy-DbaAgentAlert.ps1

Removed trailing spaces.

* Add testing for skipped wen operator not there

* Update Copy-DbaAgentAlert.ps1

Un-did changes using external command Compare-Object which has poor performance and problems with errors and put in approach by @wsmelton. Thanks, Shawn!

* fix path issues

* Update Backup-DbaDbCertificate.ps1

adding the Certificate param to the call out to Get-DbaDbCertificate

* Doc update - correcting example in Export-DbaDacPackage

* Doc update - fixing example for Invoke-DbaAdvancedUpdate (dataplat#5143)

* Doc update - Fix example in Read-DbaBackupHeader

* Doc update - Fix example in Get-DbaSsisExecutionHistory (dataplat#5140)

* Doc update - Fixing command reference in examples and link - Get-DbaDbccUserOption (dataplat#5141)

* Changes to Restart-DbaService to resolve Issue 5128 (dataplat#5145)

* Update Get-DbaUserPermission.ps1 (dataplat#5135)

Changing the cleanup query to run on tempdb

* Get-DbaServerRoleMember - Correcting call to child call for Get-DbaLogin (dataplat#5132)

* format and correcting connect issue to login cmd

* remove restart of agent (test don't require runing state)

* 0.9.777

* Fixed where statements

* Formatted code

* Fix bug in Get-DbaDbFile NextGrowthEventSize

Update $nextgrowtheventadd calculation for Percent growth types
to account for file size being returned in pages.

Also, update $nextgrowtheventadd calculation for non-Percent
growth types to not account for file size being returned in
pages as the "* 8" calculation is already performed in the
T-SQL calls when growth is not percent-based.

* 0.9.778

* Add Registered Server Support for Core (mac/linux) (dataplat#5153)

* bulk changes to support CMS / Registered Servers

* moved some commands

* 0.9.779

* CommandExecute.sql only runs if $Solution = "All"

* some additions

* yesss

* enable azure for .Query()

* added for invoke as well

* remove comments

* 0.9.780

* fixed windows check

* make sure it queries something

* fixed formatting

* formatting

* Merge pull request dataplat#5157 from SQLGB/patch-1

Update Get-DbaAgentJobHistory.ps1

* Include WindowsGroup login types

* remove output

* Look at $ads to get domain name instead of parsing from the group's DN.

* connstring fixes

* formatting

* 0.9.781

* Use ProviderPath property to allow for UNC paths

* removed default

* enable no transaction

fixes dataplat#5159

* fix found bug

* updated and added tests

* moved commands to proper location

* 0.9.774 changes

* 0.9.775 updates

* 0.9.777 changes

* 0.9.778 updates

* 0.9.779 changes

* 0.9.780 changes

* 0.9.781 changes

* Correct date on 0.9.781

* more azure support (dataplat#5172)

* removed unnecessary params and added azure support

* added feature parity to connect-dbainstance

* Newazur (dataplat#5178)

added documentation

* 0.9.782

* Connect consolidation (dataplat#5180)

Connect-SqlInstance -> Connect-DbaInstance

* remove extra info

* fix tests that take too long

* Fix debug and Path is null issues (dataplat#5183)

* add debug by default and dbatools_enabledebug

* remove missing files

* discard leftovers

* put dac back

* A few more azure fixes (dataplat#5185)

* more azure fixes

* return azure connstring

* add new db support for azure

* remove open requirement

* Invoke-DbaDbDataMasking - made azure compliant, probably (dataplat#5184)

* made azure compliant, probably

* fix path for azure

* fix - before i was getting null exceptions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants