@@ -116,7 +116,7 @@ def get_database_schema_names(config):
116116 #
117117 # Database name is any character sequence not including a " or
118118 # whitespace. Arguably both are allowed by:
119- #
119+ #
120120 # https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
121121 #
122122 # with suitable quoting but ... really.
@@ -170,7 +170,7 @@ def get_database_user_name(config):
170170 #
171171 # Database name is any character sequence not including a " or
172172 # whitespace. Arguably both are allowed by:
173- #
173+ #
174174 # https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
175175 #
176176 # with suitable quoting but ... really.
@@ -560,14 +560,51 @@ def clear(self):
560560 self .cursor .execute ('DROP SEQUENCE _%s_ids' % cn )
561561 self .cursor .execute ('CREATE SEQUENCE _%s_ids' % cn )
562562
563+ def getnode (self , classname , nodeid , fetch_multilinks = True ):
564+ """ For use of savepoint see 'Class' below """
565+ self .sql ('savepoint sp' )
566+ try :
567+ getnode = rdbms_common .Database .getnode
568+ return getnode (self , classname , nodeid , fetch_multilinks )
569+ except psycopg2 .errors .DataError as err :
570+ self .sql ('rollback to savepoint sp' )
571+ raise hyperdb .HyperdbValueError (str (err ).split ('\n ' )[0 ])
572+
563573
564574class PostgresqlClass :
565575 order_by_null_values = '(%s is not NULL)'
566576 case_insensitive_like = 'ILIKE'
567577
568578
569579class Class (PostgresqlClass , rdbms_common .Class ):
570- pass
580+ """ We re-raise database-specific data errors as HyperdbValueError
581+ Note that we re-use the savepoint so that at most one savepoint
582+ is used.
583+ """
584+
585+ def filter (self , * args , ** kw ):
586+ self .db .sql ('savepoint sp' )
587+ try :
588+ return rdbms_common .Class .filter (self , * args , ** kw )
589+ except psycopg2 .errors .DataError as err :
590+ self .db .sql ('rollback to savepoint sp' )
591+ raise hyperdb .HyperdbValueError (str (err ).split ('\n ' )[0 ])
592+
593+ def filter_iter (self , * args , ** kw ):
594+ self .db .sql ('savepoint sp' )
595+ try :
596+ return rdbms_common .Class .filter_iter (self , * args , ** kw )
597+ except psycopg2 .errors .DataError as err :
598+ self .db .sql ('rollback to savepoint sp' )
599+ raise hyperdb .HyperdbValueError (str (err ).split ('\n ' )[0 ])
600+
601+ def is_retired (self , nodeid ):
602+ self .db .sql ('savepoint sp' )
603+ try :
604+ return rdbms_common .Class .is_retired (self , nodeid )
605+ except psycopg2 .errors .DataError as err :
606+ self .db .sql ('rollback to savepoint sp' )
607+ raise hyperdb .HyperdbValueError (str (err ).split ('\n ' )[0 ])
571608
572609
573610class IssueClass (PostgresqlClass , rdbms_common .IssueClass ):
0 commit comments