Changeset 14722 in project


Ignore:
Timestamp:
05/21/09 16:18:42 (10 years ago)
Author:
sjamaan
Message:

Add tests for NUL-terminated strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/postgresql/trunk/tests/run.scm

    r14721 r14722  
    3636  (test "multi-query returns more results"
    3737        3
    38         (length (exec-query conn "SELECT 1; SELECT 'hi'; SELECT TRUE")))
     38        (length (exec-query conn "SELECT 1; SELECT 'hello'; SELECT TRUE")))
    3939  (test "Correct row count"
    4040        2
     
    8484        'text
    8585        (result-column-format
    86          (car (exec-query conn "SELECT 'hi'")) 0))
     86         (car (exec-query conn "SELECT 'hello'")) 0))
    8787  ;; The only easy way to get a binary column is by creating a binary cursor
    8888  (test "Column format is binary for forced binary data"
     
    9090        (result-column-format
    9191         (cadr (exec-query conn
    92                            (conc "DECLARE b1 BINARY CURSOR FOR SELECT 'hi';"
     92                           (conc "DECLARE b1 BINARY CURSOR FOR SELECT 'hello';"
    9393                                 "FETCH FORWARD 1 FROM b1;"
    9494                                 "CLOSE b1"))) 0))
     
    113113        (result-value
    114114         (car (exec-query conn "SELECT 1")) 0 0))
     115  ;; We are using two levels of escaping here because the ::bytea cast
     116  ;; performs another string interpretation. Yes, this is kinda confusing...
     117  (test "Result value for null-terminated normal string"
     118        "h\\000ello"
     119        (result-value
     120         (car (exec-query conn "SELECT E'h\\\\000ello'::bytea")) 0 0))
    115121  (test "Result value string for binary values"
    116         "hi"
     122        "hello"
    117123        (result-value
    118124         (cadr (exec-query conn
    119                            (conc "DECLARE b1 BINARY CURSOR FOR SELECT 'hi';"
     125                           (conc "DECLARE b1 BINARY CURSOR FOR SELECT 'hello';"
     126                                 "FETCH FORWARD 1 FROM b1;"
     127                                 "CLOSE b1"))) 0 0))
     128  (test "Result value for null-terminated binary string"
     129        "h\x00ello"
     130        (result-value
     131         (cadr (exec-query conn
     132                           (conc "DECLARE b1 BINARY CURSOR FOR SELECT E'h\\\\000ello'::bytea;"
    120133                                 "FETCH FORWARD 1 FROM b1;"
    121134                                 "CLOSE b1"))) 0 0))
Note: See TracChangeset for help on using the changeset viewer.