--
--                            Utility SPT_VALUES
--
use sybsystemprocs
go

set string_rtruncation on
go
drop table usptvalues
go

create table usptvalues
  (type      char (3)       not null,
   number    int            not null,
   name      varchar (78)   not null,
   aux1      tinyint        not null,
   aux2      tinyint        not null,

   primary key clustered (type, number))
go

insert into usptvalues
   select type, number, name, isnull (low, 0), isnull (high, 0)
   from master.dbo.spt_values
   where type in ('A', 'B', 'D', 'D2', 'O', 'S', 'V')
     and name <> 'trunc. log on chkpt.'
go

insert into usptvalues
   select 'E1', low, name, 0, 0
   from master.dbo.spt_values
   where type   = 'E'
     and number = 1
go
insert into usptvalues
   select 'E4', low, name, 0, 0
   from master.dbo.spt_values
   where type   = 'E'
     and number = 4
go

insert into usptvalues
   values ('P', -1, 'PROTECT COMPUTATIONS', 0, 0)
go
insert into usptvalues
   select 'P', number, ' ', low, high
   from master.dbo.spt_values
   where type = 'P'
go
delete from usptvalues
where type    = 'D'
  and name like 'trunc.%'
go
delete from usptvalues
where type   = 'O'
  and number = 10
go
update usptvalues
set name = 'rule / check constraint'
where type   = 'O'
  and number = 7
go

insert into usptvalues values ('LK',  -1, 'LOCK SUBTYPES',                                           0, 0)
insert into usptvalues values ('LK',   0, '?',                                                       0, 0)
insert into usptvalues values ('LK',   1, 'Exclusive table',                                         0, 0)
insert into usptvalues values ('LK',   2, 'Shared table',                                            0, 0)
insert into usptvalues values ('LK',   3, 'Exclusive intent',                                        0, 0)
insert into usptvalues values ('LK',   4, 'Shared intent',                                           0, 0)
insert into usptvalues values ('LK',   5, 'Exclusive page',                                          0, 0)
insert into usptvalues values ('LK',   6, 'Shared page',                                             0, 0)
insert into usptvalues values ('LK',   7, 'Update page',                                             0, 0)
insert into usptvalues values ('LK',   8, 'Exclusive extent',                                        0, 0)
insert into usptvalues values ('LK',   9, 'Shared extent',                                           0, 0)
insert into usptvalues values ('LK', 256, ', Lock is blocking another process',                      0, 0)
insert into usptvalues values ('LK', 512, ', Demand lock',                                           0, 0)
insert into usptvalues values ('LK', 768, ', Request lock',                                          0, 0)
go
insert into usptvalues values ('LK2',  0, ' ',                                                       0, 0)
insert into usptvalues values ('LK2',  1, ', Sync duration',                                         0, 0)
go

insert into usptvalues values ('OP',  -2, ' ',                                                       0, 0)
insert into usptvalues values ('OP',  -1, 'LOG OP CODES',                                            0, 0)
insert into usptvalues values ('OP',   0, 'Transaction begin',                                       0, 0)
insert into usptvalues values ('OP',   4, 'Data page insert',                                        0, 0)
insert into usptvalues values ('OP',   5, 'Data page delete',                                        0, 0)
insert into usptvalues values ('OP',   6, 'Indirect insert (from deferred insert/update)',           0, 0)
insert into usptvalues values ('OP',   7, 'Index page insert',                                       0, 0)
insert into usptvalues values ('OP',   8, 'Index page delete',                                       0, 0)
insert into usptvalues values ('OP',   9, 'Direct replace/update',                                   0, 0)
insert into usptvalues values ('OP',  10, 'No Op (skipped in recovery)',                             0, 0)
insert into usptvalues values ('OP',  11, 'Logged in first phase of deferred insert/update',         0, 0)
insert into usptvalues values ('OP',  12, 'Logged in first phase of deferred delete/update',         0, 0)
insert into usptvalues values ('OP',  13, 'Page allocation',                                         0, 0)
insert into usptvalues values ('OP',  14, 'Next available object id for a creation',                 0, 0)
insert into usptvalues values ('OP',  15, 'Generated by 4801 (?)',                                   0, 0)
insert into usptvalues values ('OP',  16, 'Page split',                                              0, 0)
insert into usptvalues values ('OP',  17, 'Checkpoint',                                              0, 0)
insert into usptvalues values ('OP',  18, 'Transaction save',                                        0, 0)
insert into usptvalues values ('OP',  19, 'Logged when any "update" begins',                         0, 0)
insert into usptvalues values ('OP',  20, 'Sort page deallocations',                                 0, 0)
insert into usptvalues values ('OP',  21, 'Page deallocation',                                       0, 0)
insert into usptvalues values ('OP',  22, 'Delete all extents on allocation page',                   0, 0)
insert into usptvalues values ('OP',  23, 'Allocate extent - mark all pages used',                   0, 0)
insert into usptvalues values ('OP',  24, 'Allocation for new page of a split',                      0, 0)
insert into usptvalues values ('OP',  25, 'Direct sysindexes change',                                0, 0)
insert into usptvalues values ('OP',  27, 'Sort record',                                             0, 0)
insert into usptvalues values ('OP',  28, 'SODEALLOC record',                                        0, 0)
insert into usptvalues values ('OP',  30, 'Transaction end',                                         0, 0)
insert into usptvalues values ('OP',  31, 'Sort timestamp record',                                   0, 0)
insert into usptvalues values ('OP',  32, 'Text insert - direct',                                    0, 0)
insert into usptvalues values ('OP',  33, 'Text insert - deferred',                                  0, 0)
insert into usptvalues values ('OP',  34, 'Text delete - deferred',                                  0, 0)
insert into usptvalues values ('OP',  35, 'Indirect insert (log record)',                            0, 0)
insert into usptvalues values ('OP',  36, 'Text delete - log record',                                0, 0)
insert into usptvalues values ('OP',  37, 'OAM page allocation',                                     0, 0)
insert into usptvalues values ('OP',  38, 'OAM page deallocation',                                   0, 0)
insert into usptvalues values ('OP',  39, 'OAM entry insertion',                                     0, 0)
insert into usptvalues values ('OP',  40, 'OAM entry deletion',                                      0, 0)
insert into usptvalues values ('OP',  41, 'OAM allocation during create/sort',                       0, 0)
insert into usptvalues values ('OP',  42, 'No Op cmd record',                                        0, 0)
--
--   43/50 are for Replication Server
--
insert into usptvalues values ('OP',  43, 'Record for stored proc begin exec',                       0, 0)
insert into usptvalues values ('OP',  44, 'Record for stored proc complete',                         0, 0)
insert into usptvalues values ('OP',  45, 'Dump database sync',                                      0, 0)
insert into usptvalues values ('OP',  46, 'Truncation point save',                                   0, 0)
insert into usptvalues values ('OP',  47, 'Load database sync',                                      0, 0)
insert into usptvalues values ('OP',  48, 'Load transaction sync',                                   0, 0)
insert into usptvalues values ('OP',  49, 'Before/after image for replication',                      0, 0)
insert into usptvalues values ('OP',  50, 'Reserved for Replication Server',                         0, 0)
--
insert into usptvalues values ('OP',  51, 'Move OAM entries between OAM pages',                      0, 0)
insert into usptvalues values ('OP',  52, 'Record attribute data on OAM',                            0, 0)
insert into usptvalues values ('OP',  53, 'Deleted a column from a row',                             0, 0)
insert into usptvalues values ('OP',  54, 'Deallocate a run of log pages',                           0, 0)
insert into usptvalues values ('OP',  55, 'Data slice control page',                                 0, 0)
insert into usptvalues values ('OP',  56, 'Deferred insert of an index row',                         0, 0)
insert into usptvalues values ('OP',  58, 'table/procedure schema versioning (replication support)', 0, 0)
insert into usptvalues values ('OP',  59, 'column/parameter schema versioning (replication support)', 0, 0)
go

insert into usptvalues values ('TA', -1, 'TOKEN ACTION', 0, 0)
go
insert into usptvalues
   select 'TA', number, name, 0, 0
   from master.dbo.spt_values
   where type   = 'T'
     and number > -1
     and ((number < 204)  or  (number > 206))
go

insert into usptvalues values ('TP', -1, 'TOKEN PROTECTTYPE', 0, 0)
insert into usptvalues values ('TP',  0, 'Grant*',            0, 0)
insert into usptvalues values ('TP',  1, 'Grant',             0, 0)
insert into usptvalues values ('TP',  2, 'Revoke',            0, 0)
go
insert into usptvalues values ('V', 1024, 'Master device is mirrored',   0, 0)
insert into usptvalues values ('V', 2048, 'Mirror disabled',             0, 0)
insert into usptvalues values ('V', 4096, 'Primary needs unmirroring',   0, 0)
insert into usptvalues values ('V', 8192, 'Secondary needs unmirroring', 0, 0)
go
insert into usptvalues values ('X', -1, 'SYSSERVERS SRVCLASS', 0, 0)
insert into usptvalues values ('X',  0, 'local',               0, 0)
insert into usptvalues values ('X',  1, 'SQL Server',          0, 0)
insert into usptvalues values ('X',  3, 'CIS: DC type',        0, 0)
insert into usptvalues values ('X',  4, 'CIS: DB2 type',       0, 0)
insert into usptvalues values ('X',  5, 'CIS: generic',        0, 0)
go


insert into usptvalues
      values ('XIS', -1, 'SELECTIVITY TEXT',                                0, 0)
go
insert into usptvalues
      values ('XIS',  1, 'create table #selectivity',                       0, 0)
insert into usptvalues
      values ('XIS',  2, '   (id             int               not null,',  0, 0)
insert into usptvalues
      values ('XIS',  3, '    indid          tinyint           not null,',  0, 0)
insert into usptvalues
      values ('XIS',  4, '    uid            smallint          not null,',  0, 0)
insert into usptvalues
      values ('XIS',  5, '    keycnt         tinyint           not null,',  0, 0)
insert into usptvalues
      values ('XIS',  6, '    keytext        char (33)         not null,',  0, 0)
insert into usptvalues
      values ('XIS',  7, '    selectivity    double precision  not null,',  0, 0)
insert into usptvalues
      values ('XIS',  8, '    dselectivity   double precision  not null,',  0, 0)
insert into usptvalues
      values ('XIS',  9, '    prntext        varchar (62)      not null)',  0, 0)
go

insert into usptvalues
      values ('XRI', -1, 'REINDEX TEXT',                                                0, 0)
go
insert into usptvalues
      values ('XRI',  2, '---------------------- DROP ALL REFERENTIAL CONSTRAINTS ---------------------', 0, 0)
insert into usptvalues
      values ('XRI',  3, '---------------------- DROP ALL INDEXES -------------------------------------', 0, 0)
insert into usptvalues
      values ('XRI',  4, '---------------------- DROP ALL INDEX CONSTRAINTS ---------------------------', 0, 0)
insert into usptvalues
      values ('XRI', 11, '---------------------- ADD ALL REFERENTIAL CONSTRAINTS ----------------------', 0, 0)
insert into usptvalues
      values ('XRI', 12, '---------------------- EPILOG -----------------------------------------------', 0, 0)
go

update statistics usptvalues
go

dump transaction sybsystemprocs with truncate_only
go
