-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
135 lines (113 loc) · 4.35 KB
/
Copy pathtypes.go
File metadata and controls
135 lines (113 loc) · 4.35 KB
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
// this package contains special command types
package pgxspecial
import "github.com/jackc/pgx/v5"
type SpecialResultKind int
const (
ResultKindRows SpecialResultKind = iota
ResultKindDescribeTable
ResultKindExtensionVerbose
)
// SpecialCommand represents a parsed and executable special command.
//
// It contains the normalized command name, descriptive metadata, and the handler
// function invoked during execution. SpecialCommand values are stored internally
type SpecialCommand struct {
Cmd string
Syntax string
Description string
Handler SpecialHandler
CaseSensitive bool
}
// SpecialCommandRegistry describes a special command registration.
//
// It defines the command name, optional aliases, documentation metadata, and
// execution handler used when registering commands via RegisterCommand.
type SpecialCommandRegistry struct {
Cmd string
Alias []string
Syntax string
Description string
Handler SpecialHandler
CaseSensitive bool
}
type SpecialCommandResult interface {
// ResultKind indicates the kind of special result.
ResultKind() SpecialResultKind
}
// RowResult is a wrapper around pgx.Rows to implement SpecialCommandResult.
// It is used for commands that return a set of rows.
// For example, \dt to list tables.
// The caller is responsible for closing the Rows when done.
type RowResult struct {
Rows pgx.Rows
}
func (r RowResult) ResultKind() SpecialResultKind {
return ResultKindRows
}
// TableFooterMeta holds the metadata found at the footer of a \d table description
// this is not used in any return types directly, but is embedded in
// DescribeTableResult.
type TableFooterMeta struct {
Indexes []string // lines under "Indexes:"
CheckConstraints []string // "Check constraints:"
ForeignKeys []string // "Foreign-key constraints:"
ReferencedBy []string // "Referenced by:"
ViewDefinition *string // "View definition:"
RulesEnabled []string // under "Rules:"
RulesDisabled []string // "Disabled rules:"
RulesAlways []string // "Rules firing always:"
RulesReplica []string // "Rules firing on replica only:"
TriggersEnabled []string // "Triggers:"
TriggersDisabled []string // "Disabled triggers:"
TriggersAlways []string // "Triggers firing always:"
TriggersReplica []string // "Triggers firing on replica only:"
PartitionOf []string // "Partition of:"
PartitionConstraints []string // "Partition constraint:"
PartitionKey *string // "Partition key:"
Partitions []string // "Partitions:" (or leave empty)
PartitionsSummary *string // "Number of partitions ..." (non-verbose form)
Inherits []string // "Inherits"
ChildTables []string // "Child tables" (verbose)
ChildTablesSummary *string // "Number of child tables..."
TypedTableOf *string // "Typed table of type:"
HasOIDs *bool // "Has OIDs: yes|no"
Options *string // "Options: ..."
Server *string // "Server: ..." (foreign tables)
FDWOptions *string // "FDW Options: (...)" (foreign tables)
OwnedBy *string // "Owned by:" (sequences)
}
// DescribeTableResult holds the result of a describe table command.
// this is not used in any return types directly, but is embedded in
// DescribeTableListResult.
//
// syntax: \d table_name
type DescribeTableResult struct {
Columns []string
Data [][]string
TableMetaData TableFooterMeta
}
// DescribeTableListResult holds multiple DescribeTableResult entries.
// This is used when multiple tables are described in a single command.
type DescribeTableListResult struct {
Results []DescribeTableResult
}
func (DescribeTableListResult) ResultKind() SpecialResultKind {
return ResultKindDescribeTable
}
// ExtensionVerboseResult holds the result of a single extension verbose command.
// This is not used in any return types directly, but is embedded in
// ExtensionVerboseListResult.
type ExtensionVerboseResult struct {
Name string
Description []string
}
// ExtensionVerboseListResult holds multiple ExtensionVerboseResult entries.
// This is used when multiple extensions are described in a single command.
//
// syntax: \dx+ extension_pattern**
type ExtensionVerboseListResult struct {
Results []ExtensionVerboseResult
}
func (ExtensionVerboseListResult) ResultKind() SpecialResultKind {
return ResultKindExtensionVerbose
}