src/server/pkg/sql/sql.go
func (r *PGDumpReader) ReadRow() ([]byte, error) {
	if len(r.Header) == 0 {
		err := r.readHeader()
		if err != nil {
			return nil, err
		}
	}
	endLine := "\\.\n" // Trailing '\.' denotes the end of the row inserts
	row, err := r.rd.ReadBytes('\n')
	if err != nil && err != io.EOF {
		return nil, fmt.Errorf("error reading pgdump row: %v", err)
	}
	// corner case: some pgdump files separate lines with \r\n (even on linux),
	// so clean this case up so all handling below is unified
	if len(row) >= 2 && row[len(row)-2] == '\r' {
		row[len(row)-2] = '\n'
		row = row[:len(row)-1]
	}
	if string(row) == endLine {
		r.Footer = append(r.Footer, row...)
		err = r.readFooter()
		row = nil // The endline is part of the footer
	}
	if err == io.EOF && len(r.Footer) == 0 {
		return nil, fmt.Errorf("invalid pgdump - missing footer")
	}
	return row, err
}
func (r *PGDumpReader) ReadRow() ([]byte, error) {
	if len(r.Header) == 0 {
		err := r.readHeader()
		if err != nil {
			return nil, err
		}
	}
	endLine := "\\.\n" // Trailing '\.' denotes the end of the row inserts
	row, err := r.rd.ReadBytes('\n')
	if err != nil && err != io.EOF {
		return nil, fmt.Errorf("error reading pgdump row: %v", err)
	}
	// corner case: some pgdump files separate lines with \r\n (even on linux),
	// so clean this case up so all handling below is unified
	if len(row) >= 2 && row[len(row)-2] == '\r' {
		row[len(row)-2] = '\n'
		row = row[:len(row)-1]
	}
	if string(row) == endLine {
		r.Footer = append(r.Footer, row...)
		err = r.readFooter()
		row = nil // The endline is part of the footer
	}
	if err == io.EOF && len(r.Footer) == 0 {
		return nil, fmt.Errorf("invalid pgdump - missing footer")
	}
	return row, err
}
func ( r * PGDumpReader ) ReadRow ( ) ( [ ] byte , error ) { if len ( r . Header ) == 0 { err := r . readHeader ( ) if err != nil { return nil , err } } endLine := " \\ \n " // Trailing '\.' denotes the end of the row inserts row , err := r . rd . ReadBytes ( '\n' ) if err != nil && err != io . EOF { return nil , fmt . Errorf ( " " , err ) } // corner case: some pgdump files separate lines with \r\n (even on linux), // so clean this case up so all handling below is unified if len ( row ) >= 2 && row [ len ( row ) - 2 ] == '\r' { row [ len ( row ) - 2 ] = '\n' row = row [ : len ( row ) - 1 ] } if string ( row ) == endLine { r . Footer = append ( r . Footer , row ... ) err = r . readFooter ( ) row = nil // The endline is part of the footer } if err == io . EOF && len ( r . Footer ) == 0 { return nil , fmt . Errorf ( " " ) } return row , err }
// ReadRow parses the pgdump file and populates the header and the footer
// It returns EOF when done, and at that time both the Header and Footer will
// be populated. Both header and footer are required. If either are missing, an
// error is returned
ReadRow parses the pgdump file and populates the header and the footer It returns EOF when done and at that time both the Header and Footer will be populated . Both header and footer are required . If either are missing an error is returned