SQL Server front-end (T-SQL)

Errors, refused statements and known differences

SQL Server error numbers, what is refused and how the behaviour differs from SQL Server.

Errors#

The table of mappings (with tests) is: 208, 207, 209, 102 / 156 (syntax; 156 when the next word is a reserved word), 2627, 2601, 515, 2628 (string truncation: the text with Truncated value is SQL Server 2019+'s message 2628; 8152 is sent only when the value is not known), 547 (foreign key, reference, check), 245, 241, 8115, 8134, 2714, 1801, 911, 3701, 3702, 3726, 2705, 1913, 8110, 195, 109/110, 4060 and 18456 (login), 137 (undeclared variable), 544, 3902, 3903, 2812. Anything else is 40000 with Raft DB: and the engine's text. Parse errors reject the whole batch before anything runs (as SQL Server does).

Refused (clearly, with number 40000 ... is not supported by the Raft DB SQL Server front-end.)#

Filtered indexes (except a unique one WHERE col IS NOT NULL), CLR (error 6263), Service Broker, Always Encrypted keys, FOR XML EXPLICIT / XMLSCHEMA / XMLDATA and AUTO over several sources, HASHBYTES('SHA2_512'), MERGE TOP, INSTEAD OF triggers for a statement with a FROM, ALTER TABLE ... ADD of an identity column, TOP ... PERCENT WITH TIES, WAITFOR (RECEIVE ...), a CONTAINS condition that mixes AND and OR, geometry / geography; the other items of D95's list. INTERSECT ALL / EXCEPT ALL are SQL Server's own error 156 (it has neither). MARS is not done: SqlClient connects with MultipleActiveResultSets=True and then refuses a second command while a reader is open (There is already an open DataReader associated with this Command which must be closed first.).

Known differences from SQL Server#

  • The server name in messages and @@VERSION text; object ids; times.

  • datetime2(7) has six real digits; varchar and nvarchar store alike (no ? for characters outside the code page); the default collation is the engine's comparison, case-insensitive and accent-sensitive like SQL_Latin1_General_CP1_CI_AS (stage 6 adds the others, see "Stage 6").

  • A varbinary value with bytes that are not valid UTF-8 is not stored exactly (the engine keeps text).

  • FOR XML and FOR JSON give one row (SQL Server cuts the text into rows of 2033 characters).

  • CHECKSUM is a CRC32; its numbers are not SQL Server's.

  • A cancel (attention) stops a WAITFOR or the next statement of a batch; a statement that is already inside the engine runs to its end.

  • A bulk load message is kept in memory (up to 256 MiB; use BatchSize), runs in one transaction and fires no triggers.

  • READ UNCOMMITTED is the only isolation.

  • Unnamed constraints are named PK__table, UQ__table__cols (SQL Server adds a hash).

  • Each statement that changes a table's definition also writes the front-end's two hidden tables in that database.

  • Stage 4: the engine's time is UTC (so GETDATE() is UTC); the history table of a temporal table is a view while versioning is on; SET (SYSTEM_VERSIONING = OFF) rebuilds the table (foreign keys to it and its triggers are lost); a sql_variant is kept as text with its base type in front and compared as text; types and synonyms made by another session are seen after reconnecting; the full-text words are the engine's; varchar goes out in code page 1252 and comparisons ignore case (no CS or BIN2 collations); BULK INSERT reads only below --import-dir.

  • Other known differences: UPPER('straße'), error 220 for a tinyint column, CAST between integers and binary, the seventh digit of datetime2(7) and some details of the catalog.

  • Stage 5: the type columns of sys.objects, sys.tables ... hold U, P, V without the blank of char(2); a schema is a name prefix of the engine's table, INFORMATION_SCHEMA and GRANT ... ON SCHEMA:: follow it since stage 6 (a schema is a name prefix of the engine's table, sys.schemas and sys.tables.schema_id follow it); object ids are CRC32 numbers; the dates of catalog rows are the time of the question; a default made without a name shows as DF__table__column (a named one by its name since stage 6), an unnamed primary key is PK__table; a CHECK added with ALTER TABLE is not in sys.check_constraints; sys.databases and DATABASEPROPERTYEX show fixed values (SIMPLE, READ_WRITE) whatever ALTER DATABASE ... SET said; sp_configure values have no effect; the plans of SHOWPLAN_* are a table scan per table and the numbers of SET STATISTICS IO come from the table size; permissions: a DENY anywhere wins (SQL Server lets a grant on a narrower scope override a deny on a wider one in some cases), server permissions and the fixed server roles other than sysadmin have no effect, EXECUTE AS needs a sysadmin, code in routines is not checked; sys.dm_exec_requests shows only the asking session; Agent schedules never fire; CREATE LOGIN has no password policy (CHECK_POLICY is read and ignored); CREATE USER ... WITH PASSWORD (contained users) is not read.

Stage 7 (D127) took server cursors, LIKE ... ESCAPE / PATINDEX / FORMAT with values that are not literals and mixed CONTAINS conditions off this list; what is still refused after it is listed at the end of Stage 7.

The second pass (D136) took AT TIME ZONE, SWITCHOFFSET, TODATETIMEOFFSET, DATE_BUCKET, the WINDOW clause, IGNORE NULLS, << / >>, MERGE TOP, HASHBYTES('SHA2_512'), COMPRESS / DECOMPRESS, NEWSEQUENTIALID, TYPEPROPERTY, CONVERT styles 22 / 130 / 131, FORMAT of a time, ALTER TABLE ADD of an identity column and Reduce of lines off this list (Second pass). Still refused: hierarchyid, STBuffer, BufferWithTolerance, MakeValid, Reduce of a polygon, FORMSOF and NEAR with a distance. Known differences: COMPRESS of a longer value gives other bytes than SQL Server (both decompress), and IDENT_CURRENT of an identity column fed by a sequence is NULL.

Stage 9 (D146) took hierarchyid, STBuffer / BufferWithTolerance of points, MakeValid of a valid shape, Reduce of a polygon and MERGE TOP with WHEN NOT MATCHED BY SOURCE off this list (Stage 9). Still refused: STBuffer of lines and polygons, MakeValid of an invalid shape, STUnion / STIntersection / STDifference / STSymDifference, FORMSOF and NEAR with a distance, and the out-of-scope features listed there.