Commit 4eb35a4
committed
Extended properties (
Storage lives on a new `Database.ExtendedProperties` (`ConcurrentDictionary<ExtendedPropertyKey, SqlValue>`) keyed by `(byte class, int major_id, int minor_id, string name)`. `ExtendedPropertyKey` is a readonly-struct with explicit `Equals` / `GetHashCode` overrides that route the `Name` comparison through `Collation.Default` (case-insensitive per real SQL Server). Per-DB flat dict mirrors `sys.extended_properties`'s catalog shape (not per-schema).
Sproc trio in new `Simulation.ExtendedProperties.cs` partial — three branches in `Simulation.Exec.cs` dispatch to a shared `InvokeSpExtendedProperty(batch, ExtendedPropertyOp)` body that parses 8 named args (`@name`, `@value`, `@level0type` / `@level0name` / `@level1type` / `@level1name` / `@level2type` / `@level2name` — the `AtPrefixedString` token's `Value` is already `@`-stripped, so the arg-name comparison uses bare names). `ResolveExtendedPropertyTarget` walks the level0..2 chain, accepting a closed set (level0 = SCHEMA; level1 = TABLE / VIEW / PROCEDURE / FUNCTION / TYPE; level2 = COLUMN) and returning the `(ExtendedPropertyKey, targetLabel)` pair the error wording needs.
Four new error factories with probe-confirmed verbatim wording against SQL Server 2025 (2026-05-14):
- Msg 15233 (`ExtendedPropertyAlreadyExists`): `"Property cannot be added. Property '<name>' already exists for '<target>'."` — target label is `'object specified'` for DB-level, `'<schema>'` for schema, `'<schema>.<name>'` for table/view/proc/func, `'<schema>.<table>.<col>'` for column.
- Msg 15217 (`ExtendedPropertyDoesNotExist`): same shape for update/drop on missing.
- Msg 15135 (`ExtendedPropertyTargetMissing`): `"Object is invalid. Extended properties are not permitted on '<target>', or the object does not exist."` — target label uses the failing-level's value (`'no_such_schema'` / `'dbo.no_such_table'` / `'dbo.t1.no_such_col'`).
- Msg 15600 (`InvalidExtendedPropertyParameter`): `"An invalid parameter or option was specified for procedure '<proc>'."` — positional arg, unknown @-name, missing required arg, unknown level type.
`sys.extended_properties` catalog view in `BuiltInResources.cs` enumerates the dict with the shipped 6-column subset: `class` (tinyint) / `class_desc` (sysname — 0→DATABASE, 1→OBJECT_OR_COLUMN, 3→SCHEMA) / `major_id` (int) / `minor_id` (int — 0 for table-level, 1-based column ordinal for column-level) / `name` (sysname) / `value` (nvarchar(MAX), since `sql_variant` isn't modeled — AW's 538 properties are all nvarchar values so lossless for the bacpac workload).
`fn_listextendedproperty` in new `Selection.ListExtendedProperty.cs` partial — built-in system TVF dispatched alongside `OPENJSON` / `STRING_SPLIT` in `ParseSingleFromSource`. 7 args (each may be NULL), returns 4 columns (`objtype` / `objname` / `name` / `value`). Filter pipeline: parse args as expressions, eval per-row to nullable strings, build `ExtendedPropertyListFilter` from the resolved target (class + major_id + minor_id + name + minor_id-must-be-nonzero gate for the "all columns of a table" shape), walk the dict and project matches. `'default'` wildcard at level1name / level2name fans out across every object of that level-type under the parent (probe-confirmed). Missing target returns zero rows (distinct from the sproc path's Msg 15135). Unknown level type (not SCHEMA / TABLE / VIEW / PROCEDURE / FUNCTION / TYPE / COLUMN) raises `NotSupportedException`.
21 new tests in `ExtendedPropertyTests.cs` cover: schema / table / column / DB-level read-back via `sys.extended_properties` (class + class_desc + minor_id correctness), all four duplicate-add target-label variants for Msg 15233, update + drop happy paths, all three missing-target variants for Msg 15135, Msg 15217 / 15600 paths, plus 5 `fn_listextendedproperty` cases (table-level scalar read, name filter across levels, column-level filter by ordinal, missing-target zero rows, `'default'` wildcard fanout). Full suite 4640 → 4661, all green Debug + Release.
`docs/claude/bacpac-prerequisites.md` flips the Extended-properties bullet from `[ ]` to `[x]` with the full implementation walkthrough and renumbers the order-of-operations sequence (`hierarchyid` is now next). CLAUDE.md gains a sibling Feature-reference index entry next to the existing UDDT one. Two known gaps documented as deferred: PARAMETER / INDEX / TRIGGER / CONSTRAINT level types (NotSupportedException — AW doesn't exercise them, bacpac-loader baseline doesn't need them), and non-nvarchar `sql_variant` values lossy-coerce on read-back (invisible in practice since AW's properties are all nvarchar).sp_addextendedproperty + sp_updateextendedproperty + sp_dropextendedproperty + sys.extended_properties + fn_listextendedproperty) — third bacpac prerequisite. Pure-metadata surface, no semantic effect on queries; covers AW's 538 <SqlExtendedProperty> elements (461 column + 69 table + 5 schema + 1 DB + 2 filegroup/DDL-trigger which remain out of scope per the simulator's broader feature roster).1 parent 73c1420 commit 4eb35a4
10 files changed
Lines changed: 1080 additions & 9 deletions
File tree
- SqlServerSimulator.Tests
- SqlServerSimulator
- Errors
- Parser
- Simulation
- docs/claude
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
786 | 786 | | |
787 | 787 | | |
788 | 788 | | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
789 | 807 | | |
790 | 808 | | |
791 | 809 | | |
| |||
811 | 829 | | |
812 | 830 | | |
813 | 831 | | |
| 832 | + | |
814 | 833 | | |
815 | 834 | | |
816 | 835 | | |
| |||
893 | 912 | | |
894 | 913 | | |
895 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
896 | 950 | | |
897 | 951 | | |
898 | 952 | | |
| |||
0 commit comments