Files
stocksearch/vendor/github.com/lib/pq/internal/pqsql/copy.go
hayato5246 ba18887ed8
Some checks failed
Build Push and Restart Compose / deploy (push) Failing after 1m47s
PostgreSQL 의존성 및 내부 유틸리티 추가:
- `github.com/lib/pq` PostgreSQL 드라이버 vendor 디렉토리에 추가.
- PostgreSQL 관련 내부 패키지(`pqsql`, `proto`, `pqtime`, `pgpass`, `pgservice`, `pqutil`) 구현:
  - SQL 어휘 처리, 프로토콜 상수 및 구조 정의, 시간 파서/포맷터(`Parse`, `Format`).
  - `.pgpass` 파일 및 `pg_service.conf` 관리 기능 추가.
  - 파일/사용자 권한 검증 및 플랫폼별 사용자 정보 조회 기능 포함.
- 데이터베이스 초기화 로직 추가 (`services/db.go`):
  - PostgreSQL 연결 설정 및 초기 스키마 생성.
- 자동매매 관련 DB 레포지토리(`services/autotrade_repo.go`) 구현:
  - 자동매매 규칙 및 포지션 관리 로직 추가 (`dbInsertRule`, `dbLoadRules` 등).
2026-04-08 19:07:32 +09:00

38 lines
858 B
Go

package pqsql
// StartsWithCopy reports if the SQL strings start with "copy", ignoring
// whitespace, comments, and casing.
func StartsWithCopy(query string) bool {
if len(query) < 4 {
return false
}
var linecmt, blockcmt bool
for i := 0; i < len(query); i++ {
c := query[i]
if linecmt {
linecmt = c != '\n'
continue
}
if blockcmt {
blockcmt = !(c == '/' && query[i-1] == '*')
continue
}
if c == '-' && len(query) > i+1 && query[i+1] == '-' {
linecmt = true
continue
}
if c == '/' && len(query) > i+1 && query[i+1] == '*' {
blockcmt = true
continue
}
if c == ' ' || c == '\t' || c == '\r' || c == '\n' {
continue
}
// First non-comment and non-whitespace.
return len(query) > i+3 && c|0x20 == 'c' && query[i+1]|0x20 == 'o' &&
query[i+2]|0x20 == 'p' && query[i+3]|0x20 == 'y'
}
return false
}