Skip to content

Instantly share code, notes, and snippets.

@GavinRay97
Created December 24, 2022 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GavinRay97/af685f90efd60bc83b1db8fe5bdbfea3 to your computer and use it in GitHub Desktop.
Save GavinRay97/af685f90efd60bc83b1db8fe5bdbfea3 to your computer and use it in GitHub Desktop.
Postgres wire protcol -- Graphviz state chart
digraph state_machine {
rankdir=LR;
size="8,5"
node [shape = doublecircle, style=filled, fillcolor=lightblue]; WaitingForQuery;
node [shape = doublecircle, style=filled, fillcolor=maroon] GotErrorResponseDuringSimpleQuery;
node [shape = circle, style=filled, fillcolor=lightgrey];
InitializingBackend -> GotCommandComplete [ label = "PG3ReadyForQuery", color=green ];
InitializingBackend -> InitializingBackend [ label = "PG3BackendKeyData", color=orange ];
GotDataRow -> GotErrorResponseDuringSimpleQuery [ label = "PG3ErrorResponse", color=red ];
GotDataRow -> GotCommandComplete [ label = "PG3CommandComplete", color=green ];
GotDataRow -> GotDataRow [ label = "PG3DataRow", color=orange ];
GotErrorResponseDuringSimpleQuery -> WaitingForQuery [ label = "PG3ReadyForQuery", color=green ];
GotEmptyQueryResponse -> WaitingForQuery [ label = "PG3ReadyForQuery", color=green ];
GotEmptyQueryResponse -> GotErrorResponseDuringSimpleQuery [ label = "PG3ErrorResponse", color=red ];
Querying -> GotErrorResponseDuringSimpleQuery [ label = "PG3ErrorResponse", color=red ];
Querying -> GotCommandComplete [ label = "PG3CommandComplete", color=green ];
Querying -> GotRowDescription [ label = "PG3RowDescription", color=orange ];
Querying -> GotEmptyQueryResponse [ label = "PG3EmptyQueryResponse", color=green ];
Authenticating -> AuthenticatingWithMD5 [ label = "PG3AuthenticationMD5Password", color=orange ];
Authenticating -> InitializingBackend [ label = "PG3AuthenticationOkMessage", color=green ];
AuthenticatingWithMD5 -> InitializingBackend [ label = "PG3AuthenticationOkMessage", color=green ];
GotCommandComplete -> WaitingForQuery [ label = "PG3ReadyForQuery", color=green ];
GotCommandComplete -> GotErrorResponseDuringSimpleQuery [ label = "PG3ErrorResponse", color=red ];
GotCommandComplete -> GotCommandComplete [ label = "PG3CommandComplete", color=green ];
GotCommandComplete -> GotRowDescription [ label = "PG3RowDescription", color=orange ];
GotRowDescription -> GotErrorResponseDuringSimpleQuery [ label = "PG3ErrorResponse", color=red ];
GotRowDescription -> GotCommandComplete [ label = "PG3CommandComplete", color=green ];
GotRowDescription -> GotDataRow [ label = "PG3DataRow", color=orange ];
}
https://dreampuf.github.io/GraphvizOnline/#digraph%20state_machine%20%7B%0D%0A%20%20rankdir%3DLR%3B%0D%0A%20%20size%3D%228%2C5%22%0D%0A%20%20node%20%5Bshape%20%3D%20doublecircle%2C%20style%3Dfilled%2C%20fillcolor%3Dlightblue%5D%3B%20WaitingForQuery%3B%0D%0A%20%20node%20%5Bshape%20%3D%20doublecircle%2C%20style%3Dfilled%2C%20fillcolor%3Dmaroon%5D%20GotErrorResponseDuringSimpleQuery%3B%0D%0A%20%20node%20%5Bshape%20%3D%20circle%2C%20style%3Dfilled%2C%20fillcolor%3Dlightgrey%5D%3B%0D%0A%20%20InitializingBackend%20-%3E%20GotCommandComplete%20%5B%20label%20%3D%20%22PG3ReadyForQuery%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20InitializingBackend%20-%3E%20InitializingBackend%20%5B%20label%20%3D%20%22PG3BackendKeyData%22%2C%20color%3Dorange%20%5D%3B%0D%0A%20%20GotDataRow%20-%3E%20GotErrorResponseDuringSimpleQuery%20%5B%20label%20%3D%20%22PG3ErrorResponse%22%2C%20color%3Dred%20%5D%3B%0D%0A%20%20GotDataRow%20-%3E%20GotCommandComplete%20%5B%20label%20%3D%20%22PG3CommandComplete%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20GotDataRow%20-%3E%20GotDataRow%20%5B%20label%20%3D%20%22PG3DataRow%22%2C%20color%3Dorange%20%5D%3B%0D%0A%20%20GotErrorResponseDuringSimpleQuery%20-%3E%20WaitingForQuery%20%5B%20label%20%3D%20%22PG3ReadyForQuery%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20GotEmptyQueryResponse%20-%3E%20WaitingForQuery%20%5B%20label%20%3D%20%22PG3ReadyForQuery%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20GotEmptyQueryResponse%20-%3E%20GotErrorResponseDuringSimpleQuery%20%5B%20label%20%3D%20%22PG3ErrorResponse%22%2C%20color%3Dred%20%5D%3B%0D%0A%20%20Querying%20-%3E%20GotErrorResponseDuringSimpleQuery%20%5B%20label%20%3D%20%22PG3ErrorResponse%22%2C%20color%3Dred%20%5D%3B%0D%0A%20%20Querying%20-%3E%20GotCommandComplete%20%5B%20label%20%3D%20%22PG3CommandComplete%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20Querying%20-%3E%20GotRowDescription%20%5B%20label%20%3D%20%22PG3RowDescription%22%2C%20color%3Dorange%20%5D%3B%0D%0A%20%20Querying%20-%3E%20GotEmptyQueryResponse%20%5B%20label%20%3D%20%22PG3EmptyQueryResponse%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20Authenticating%20-%3E%20AuthenticatingWithMD5%20%5B%20label%20%3D%20%22PG3AuthenticationMD5Password%22%2C%20color%3Dorange%20%5D%3B%0D%0A%20%20Authenticating%20-%3E%20InitializingBackend%20%5B%20label%20%3D%20%22PG3AuthenticationOkMessage%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20AuthenticatingWithMD5%20-%3E%20InitializingBackend%20%5B%20label%20%3D%20%22PG3AuthenticationOkMessage%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20GotCommandComplete%20-%3E%20WaitingForQuery%20%5B%20label%20%3D%20%22PG3ReadyForQuery%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20GotCommandComplete%20-%3E%20GotErrorResponseDuringSimpleQuery%20%5B%20label%20%3D%20%22PG3ErrorResponse%22%2C%20color%3Dred%20%5D%3B%0D%0A%20%20GotCommandComplete%20-%3E%20GotCommandComplete%20%5B%20label%20%3D%20%22PG3CommandComplete%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20GotCommandComplete%20-%3E%20GotRowDescription%20%5B%20label%20%3D%20%22PG3RowDescription%22%2C%20color%3Dorange%20%5D%3B%0D%0A%20%20GotRowDescription%20-%3E%20GotErrorResponseDuringSimpleQuery%20%5B%20label%20%3D%20%22PG3ErrorResponse%22%2C%20color%3Dred%20%5D%3B%0D%0A%20%20GotRowDescription%20-%3E%20GotCommandComplete%20%5B%20label%20%3D%20%22PG3CommandComplete%22%2C%20color%3Dgreen%20%5D%3B%0D%0A%20%20GotRowDescription%20-%3E%20GotDataRow%20%5B%20label%20%3D%20%22PG3DataRow%22%2C%20color%3Dorange%20%5D%3B%0D%0A%7D
@GavinRay97
Copy link
Author

GavinRay97 commented Dec 24, 2022

SVG render (zoom way in):
graphviz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment