| 
									
										
										
										
											2009-02-20 21:40:17 -05:00
										 |  |  | ! Copyright (C) 2009 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  | USING: kernel db.errors peg.ebnf strings sequences math | 
					
						
							| 
									
										
										
										
											2009-02-22 01:42:35 -05:00
										 |  |  | combinators.short-circuit accessors math.parser quoting ;
 | 
					
						
							| 
									
										
										
										
											2009-02-20 21:40:17 -05:00
										 |  |  | IN: db.errors.postgresql | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | EBNF: parse-postgresql-sql-error | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Error = "ERROR:" [ ]+ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TableError =
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:59:23 -05:00
										 |  |  |     Error ("relation "|"table ")(!(" already exists").)+:table " already exists" | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  |         => [[ table >string unquote <sql-table-exists> ]] | 
					
						
							| 
									
										
										
										
											2009-02-21 22:59:23 -05:00
										 |  |  |     | Error ("relation "|"table ")(!(" does not exist").)+:table " does not exist" | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  |         => [[ table >string unquote <sql-table-missing> ]] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:59:23 -05:00
										 |  |  | FunctionError =
 | 
					
						
							|  |  |  |     Error "function" (!(" already exists").)+:table " already exists" | 
					
						
							|  |  |  |         => [[ table >string <sql-function-exists> ]] | 
					
						
							|  |  |  |     | Error "function" (!(" does not exist").)+:table " does not exist" | 
					
						
							|  |  |  |         => [[ table >string <sql-function-missing> ]] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  | SyntaxError =
 | 
					
						
							|  |  |  |     Error "syntax error at end of input":error | 
					
						
							|  |  |  |         => [[ error >string <sql-syntax-error> ]] | 
					
						
							|  |  |  |     | Error "syntax error at or near " .+:syntaxerror | 
					
						
							|  |  |  |         => [[ syntaxerror >string unquote <sql-syntax-error> ]] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:59:23 -05:00
										 |  |  | UnknownError = .* => [[ >string <sql-unknown-error> ]] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PostgresqlSqlError = (TableError | FunctionError | SyntaxError | UnknownError)  | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ;EBNF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ERROR: parse-postgresql-location column line text ;
 | 
					
						
							|  |  |  | C: <parse-postgresql-location> parse-postgresql-location | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | EBNF: parse-postgresql-line-error | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Line = "LINE " [0-9]+:line ": " .+:sql | 
					
						
							|  |  |  |     => [[ f line >string string>number sql >string <parse-postgresql-location> ]]  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ;EBNF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | :: set-caret-position ( error caret-line -- error )
 | 
					
						
							|  |  |  |     caret-line length
 | 
					
						
							|  |  |  |     error line>> number>string length "LINE : " length +
 | 
					
						
							|  |  |  |     - [ error ] dip >>column ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : postgresql-location ( line column -- obj )
 | 
					
						
							|  |  |  |     [ parse-postgresql-line-error ] dip
 | 
					
						
							|  |  |  |     set-caret-position ;
 |